akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Numerics.BitOperations;

namespace abc176{
    class SolverC
    {
        static void Main()
        {
            SetOut(new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false});
            new SolverC().Solve();
            Out.Flush();
        }

        public void Solve()
        {
            checked
            {
                long N = Get.Long();
                long[] A = Get.Longs();
                long l = 0;
                long ans = 0;
                for(int i=0; i<N; i++){
                    if(A[i] < l){
                        ans += l - A[i];
                    }else if(A[i] > l){
                        l = A[i];
                    }
                }
                WriteLine(ans);
            }
        }




        private static class Get
        {
            public static string Str() => ReadLine().Trim();
            public static int Int() => int.Parse(Str());
            public static long Long() => long.Parse(Str());
            public static double Double() => double.Parse(Str());
            public static string[] Strs() => Str().Split(' ', StringSplitOptions.RemoveEmptyEntries);
            public static int[] Ints() => Strs().Select(int.Parse).ToArray();
            public static long[] Longs() => Strs().Select(long.Parse).ToArray();
            public static double[] Doubles() => Strs().Select(double.Parse).ToArray();
            static bool TypeEq<T,U>() => typeof(T).Equals(typeof(U));
            static T TypeConv<T,U>(U u) => (T)Convert.ChangeType(u, typeof(T));
            static T TypeConv<T>(string s) => TypeEq<T, int>() ?   TypeConv<T, int>(int.Parse(s))
                                        : TypeEq<T, long>() ?       TypeConv<T, long>(long.Parse(s))
                                        : TypeEq<T, double>() ?     TypeConv<T, double>(long.Parse(s))
                                        : TypeConv<T, string>(s);
            public static (T,U) Tuple<T,U>() {string[] strs = Strs(); T t = TypeConv<T>(strs[0]); U u = TypeConv<U>(strs[1]); return(t,u);}
            public static (T,U,V) Tuple<T,U,V>() {string[] strs = Strs(); T t = TypeConv<T>(strs[0]); U u = TypeConv<U>(strs[1]); V v = TypeConv<V>(strs[2]); return(t,u,v);}
        }
    }
}


Measured memory_bytes: 47352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mxn= 1e6+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    rishabh();
    int a,b;
    cin>>a>>b;
    for(int i=1;i<1010;i++){
        if((i*8)/100==a&&(i)/10==b){
            cout<<i;
            return 0;
        }
    }
    cout<<-1;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define _ << " " <<

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

int main()
{
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);

  int rje=0;
  for (; rje < 1000000; rje++) {
    if (a % 2 || b % 2 || c % 2) break;
    int a2 = a/2, b2 = b/2, c2 = c/2;
    a = b2 + c2;
    b = c2 + a2;
    c = a2 + b2;
  }

  printf("%d\n", rje < 1000000 ? rje : -1);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <map>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
using namespace std;

typedef long long ll;

int rs[100000+10];
struct Q {
  int id;
  int t;
  int a;
  int res;
};
bool byT(const Q& a, const Q& b) {
  return a.t < b.t;
}
bool byId(const Q& a, const Q& b) {
  return a.id < b.id;
}
Q qs[100000+10];


int main(void) {
  int total;
  scanf("%d", &total);
  int nR;
  scanf("%d", &nR);
  REP(i, nR) {
    scanf("%d", &rs[i+1]);
  }
  rs[nR+1] = 1000000009;
  int nQ;
  scanf("%d", &nQ);
  REP(i, nQ) {
    scanf("%d%d", &qs[i].t, &qs[i].a);
    qs[i].id = i;
  }
  sort(qs, qs + nQ, byT);

  int a1 = 0;
  int a2 = total;
  int diff = 0;
  int iq = 0;
  bool aToB = true;
  REP(ir, nR+1) {
    while(iq < nQ && qs[iq].t < rs[ir+1]) {
      qs[iq].res = (qs[iq].a < a1 ? a1 : qs[iq].a < a2 ? qs[iq].a : a2) + diff;
      qs[iq].res = min(total, max(0, qs[iq].res + (aToB ? -1 : 1) * (qs[iq].t - rs[ir])));
      assert(qs[iq].res >= 0);
      assert(qs[iq].res <= total);
      ++iq;
    }
    // a1, a2, diff の更新
    if(aToB) {
      diff -= min(rs[ir+1] - rs[ir], total);
      a1 = max(a1, -diff);
      a2 = max(a1, a2);
    } else {
      diff += min(rs[ir+1] - rs[ir], total);
      a2 = min(a2, total-diff);
      a1 = min(a1, a2);
    }
    aToB = !aToB;
  }
  assert(iq == nQ);
  sort(qs, qs + nQ, byId);
  REP(i, nQ) {
    printf("%d\n", qs[i].res);
  }
  return 0;
}


Measured memory_bytes: 3200
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int s = Integer.parseInt(scanner.next());
        scanner.close();

        final int seconds = s % 60;
        final int minutes = ((s - seconds) / 60) % 60;
        final int hours = (((s - seconds) / 60) - minutes) / 60;

        System.out.println(hours + ":" + minutes + ":" + seconds);
    }
}


Measured memory_bytes: 26032
import java.util.Set;
import java.util.HashSet;
import java.util.Scanner;

public class Main{

    public static void main(String[] args){
        Set<Character> table = new HashSet<Character>();

        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();

        for(int i = 0; i < str.length(); i++) table.add(str.charAt(i));

        for(char c = 'a'; c <= 'z'; c++){
            if(!table.contains(c)){
                System.out.println(c);
                return;
            }
        }
        System.out.println("None");
    }

}

Measured memory_bytes: 26436
//Do what you can't.
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {

  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter w = new PrintWriter(System.out);
    BigInteger b1=new BigInteger(in.readString()),b2=new BigInteger(in.readString());
    int i=b1.compareTo(b2);
    if (i==0)
      w.println("EQUAL");
    else if (i==1)
      w.println("GREATER");
    else
      w.println("LESS");
    w.close();
    }
  static class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int snext() {
      if (snumChars == -1)
      throw new InputMismatchException();
      if (curChar >= snumChars) {
        curChar = 0;
        try {
          snumChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (snumChars <= 0)
        return -1;
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9')
        throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long nextLong() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9')
        throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public int[] nextIntArray(int n) {
      int a[] = new int[n];
      for (int i = 0; i < n; i++) {
        a[i] = nextInt();
      }
      return a;
    }

    public String readString() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public String nextLine() {
      int c = snext();
      while (isSpaceChar(c))
      c = snext();
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isEndOfLine(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null)
      return filter.isSpaceChar(c);
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
      return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }
}


Measured memory_bytes: 22740
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int N, M, Q; cin >> N >> M >> Q;
	vector<int> ngr(N+2, 0), ngl(N+2, 0);
	vector<vector<int>> ng(N+1, vector<int>(N+1, 0));
	for(int i=0; i<M; ++i){
	    int L, R; cin >> L >> R;
	    ++ngr[R-1];
	    ++ngl[L+1];
	    if(L+1<R) ++ng[L+1][R-1];
	}
	for(int i=N; i>0; --i) ngr[i-1] += ngr[i];
	for(int i=0; i<N; ++i) ngl[i+1] += ngl[i];
	for(int i=0; i<=N; ++i){
	    for(int j=N; j>i; --j) ng[i][j-1] += ng[i][j];
	}
	for(int i=0; i<=N; ++i){
	    for(int j=0; j<i; ++j) ng[j+1][i] += ng[j][i];
	}
	for(int i=0; i<Q; ++i){
	    int p, q; cin >> p >> q;
	    cout << M-ngr[q]-ngl[p]+ng[p][q] << endl;
	}
	return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
   string s;
   cin>>s;
   int count=0;
   int len = s.length();
   for(int i=0; i<len; i++)
   {
       if(s[i]=='o'){count++;}
   }
   cout<<700+count*100;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(true){
    c=c-b;
    if(c<=0){
      cout << "Yes";
      break;
    }
    a=a-d;
    if(a<=0){
      cout << "No";
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3584
import java.io.IOException;
import java.util.Scanner;

public class Main
 {

	/**
	 * ??????????????¨????????¢???????????¨????????? y = x^2 x = 600 ?????????????¨????????????????
	 * 
	 * @param args
	 * @throws IOException
	 * @throws NumberFormatException
	 */
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int width = sc.nextInt();
			calcArea(width);

		}

	}

	public static void calcArea(int width) {
		int sum = 0, d = width;
		for (int i = 1; d * i <= 600 - d; i++) {
			sum += Math.pow(d * i, 2) * d;
		}
		System.out.println(sum);

	}

}

Measured memory_bytes: 17196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    cout << char(a.at(0) + 'A' - 'a') << char(b.at(0) + 'A' - 'a') << char(c.at(0) + 'A' - 'a');
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,0,-1,1,-1,-1,1,2,0,-2,0};
const int dy[]={0,1,-1,0,1,1,-1,-1,0,2,0,-2};
const int INF = 1<<30;
const double EPS = 1e-8;
#define PB push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
typedef pair<int,int> Pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
vector < Pii > D[7];
vector < Pii > N[7];
int main(){
	int W,H;
	while(scanf("%d%d",&W,&H),(W|H)){
		rep(i,7){
			D[i].clear();
		}
		rep(i,H){
			char s[1024];
			scanf("%s",s);
			rep(j,W){
				if(s[j] == 'S'){
					D[0].PB(Pii(i,j));
				}
				else if(s[j] == 'G'){
					D[6].PB(Pii(i,j));
				}
				else if(s[j] != '.'){
					D[s[j]-'0'].PB(Pii(i,j));
				}
			}
		}
		int dp[6][1024];
		Pii ans;
		ans.fr = INF;
		ans.sc = INF;

		N[0] = D[0];
		N[5] = D[6];
		
		reps(f,1,6){
			//init
			rep(i,6){
				rep(j,1024){
					dp[i][j] = INF;
				}
			}
			dp[0][0] = 0;

			//p
			reps(i,1,5){
				int prev = ((f+i-1)%5)+1;
				N[i] = D[prev];
			}

			//dp
			rep(i,6){
				if(i == 5)continue;
				rep(j,N[i].size()){
					rep(k,N[i+1].size()){
						dp[i+1][k] = min(dp[i+1][k],dp[i][j]+abs(N[i][j].fr-N[i+1][k].fr)+abs(N[i][j].sc-N[i+1][k].sc));
						//printf("%d\n",dp[i+1][k]);
					}
				}
			}

			//update
			ans = min(ans,Pii(dp[5][0],f));
		}

		if(ans.fr == INF){
			puts("NA");
		}
		else{
			printf("%d %d\n",ans.sc,ans.fr);
		}
	}
	return 0;
}

Measured memory_bytes: 1304
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N;
    cin >> N;
    cout << (N+1)/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
 int a,b,x;
  cin >> a >> b >> x;
  if(x<=a+b && a<=x){
  cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,x,l[101];
  int sum =0,ans = 0;
  scanf("%d %d",&n,&x);
  for (int i=0;i<n;i++){
    scanf("%d",&l[i]);
  }

  for (int j=0;j<n;j++){
    sum = sum + l[j];
    if (sum <= x){
      ans += 1;
    }else {
      printf("%d",ans+1);
      return 0;
    }
  }
  printf("%d",ans+1);
  return 0;
}

Measured memory_bytes: 128
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}
# sumの追加
class Array
  define_method(:sum){self.inject(:+).to_i} unless method_defined?(:sum)
end

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N = gets_i
a_list = gets_i_list
b_list = gets_i_list

negative_diffs = []
positive_diffs = []

0.upto(N-1) do |i|
  if a_list[i] < b_list[i]
    negative_diffs.push(b_list[i] - a_list[i])
  else a_list[i] > b_list[i]
    positive_diffs.push(a_list[i] - b_list[i])
  end
end

diff_total = negative_diffs.sum

if diff_total == 0
  puts "0"
  exit
else
  count = 0
  positive_diffs.sort!
  positive_diffs.reverse_each do |d|
    diff_total -= d
    count += 1
    break if diff_total <= 0
  end

  if diff_total <= 0
    puts count + negative_diffs.size
  else
    puts -1
  end
end

Measured memory_bytes: 18724
// Example program
#include <iostream>
#include <string>
using namespace std;

int main()
{
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    int ret=0;
    if(A >= K){
        ret = K;
        cout << ret <<endl;
        return 0;
    }else if(A+B>=K){
        ret = A;
        cout << ret << endl;
        return 0;
    }else{
        ret = A - (K - (A+B));
        cout<<ret<<endl;
        return 0;
    }
    
}

Measured memory_bytes: 3624
import collections
from operator import itemgetter

N = int(input())
S = []
for _ in range(N):
    S.append(input())

s = collections.Counter(S)
#print(list(s.items()))
ss = list(s.items())
#s2 = collections.OrderedDict(s)
maxint = s.most_common()[0][1]
s3 = sorted(ss, key=itemgetter(0))
s4 = sorted(s3, key=itemgetter(1), reverse=True)
#print(s3,s4,sep="\n")

count = 0
for i in range(N):
    if(s4[i][1] == maxint):
        print(s4[i][0])
        count += s4[i][1]
        if(N==count):
            break
    else:
        break



Measured memory_bytes: 59376
#include <stdio.h>

int main()
{
    long long int n, m, i, j, ans;
    scanf("%lld %lld", &n, &m);
    ans = 1;
    for (i=1; i*i<=m; i++)
    {
        if (m%i == 0) {
            j = m / i;
            if (m >= n * i) {
                if (i > ans) {
                    ans = i;
                }
            }
            if (m >= n * j) {
                if (j > ans) {
                    ans = j;
                }
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
/***
	chauhan176's code

	DO WHATEVER IT TAKES!!!
	Nothing happens , nothing happens and then everything happens.
	But the thing is nothing happens in air:)-
***/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define ull
#define fi first
#define se second
#define mod 1000000007
#define maxn 2005
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define stringio cin.ignore(256, '\n')  //to take string input after taking integer inputs
#define go_t int t;cin>>t;while(t--)
#define go_pt int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef pair<ll,ll>pii;
typedef pair<ll,ll>piii;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
vector<int>adj[maxn];
vector<int>dist;
queue<int>q;
void bfs(int v,int p)
{
    while(!q.empty())
    {
        int x = q.front();
        q.pop();
        for(int u : adj[x])
        {
            if(dist[u]==0)
            {
                dist[u] = dist[x] + 1;
                q.push(u);
            }
        }
    }
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    //freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    //freopen("output.txt", "w", stdout);
    #endif

    fastio;
    int n;
    cin>>n;
    string mat[n+2];
    for(int i=0;i<n;i++)
        cin>>mat[i];
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(mat[i][j]=='1')
            {
                adj[i+1].pb(j+1);
                adj[j+1].pb(i+1);
            }
        }
    }
    int ans=0;
    dist.assign(n+1,0);
    q.push(1);
    dist[1]=1;
    bfs(1,1);
    vector<int>cyc[n+1];
    for(int i=1;i<=n;i++)
    {
        cyc[dist[i]].pb(i);
    }
    for(int i=1;i<=n;i++)
    {
        if(cyc[i].size()==0)break;
        for(int j=0;j<cyc[i].size();j++)
        {
            for(int k=j+1;k<cyc[i].size();k++)
            {
                int f = cyc[i][j],s = cyc[i][k];
                if(mat[f-1][s-1]=='1')
                {
                    cout<<-1<<endl;
                    return 0;
                }
            }
        }
    }
    for(int i=2;i<=n;i++)
    {
        dist.assign(n+1,0);
        q.push(i);
        dist[i]=1;
        bfs(i,i);
        for(int j=1;j<=n;j++)
        {
            ans = max(ans,dist[j]);
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> s;
    vector<int> ord(n + 1, -1);
    int c = 1, l = 0;
    {
        int v = 1;
        while (ord[v] == -1)
        {
            ord[v] = s.size();
            s.push_back(v);
            v = a[v-1];
        }
        c = s.size() - ord[v];
        l = ord[v];
    }

    if (k < l)
        cout << s[k] << endl;
    else
    {
        k -= l;
        k %= c;
        cout << s[l + k] << endl;
    }
    return 0;
}


Measured memory_bytes: 5796
#include<bits/stdc++.h>
using namespace std;
int main(){
	char ch;
	cin >> ch;
	if(ch == 'A')
		cout << "T";
	else if(ch == 'T')
		cout << "A";
	else if(ch == 'C')
		cout << "G";
	else
		cout << "C";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,N) for(int (i)=0;(i)<(N);(i)++)
#define REPR(i,N) for(int (i)=(N);i>=0;i--)
#define FOR (i,m,n) for(int (i)=m;(i)<(n);(i)++)

int main(){
  int num, xi, ans=1e9, temp;
  bool flag=0;
  cin >> num;
  REP(i,num){
    cin >> xi;
    temp=0;
    while(xi%2==0){
      xi/=2;
      temp++;
    }
    if(temp<ans)ans=temp;
    if(temp==0){
      cout << 0 << endl;
      flag=true;
      break;
    }
  }
  if(flag==0)cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N string
	fmt.Scan(&N)

	var point int

	switch len(N) {
	case 1:
		point = 0
	case 2:
		point = 1
	case 3:
		point = 2
	}

	switch string(N[point]) {
	case "0":
		fmt.Println("pon")
	case "1":
		fmt.Println("pon")
	case "2":
		fmt.Println("hon")
	case "3":
		fmt.Println("bon")
	case "4":
		fmt.Println("hon")
	case "5":
		fmt.Println("hon")
	case "6":
		fmt.Println("pon")
	case "7":
		fmt.Println("hon")
	case "8":
		fmt.Println("pon")
	case "9":
		fmt.Println("hon")
	}

}

Measured memory_bytes: 1816
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>

#define REP(i,n) for(int i = 0; i < (n); i++)
#define REPC(x,c) for(auto x:(c))
#define FOR(i, b, e) for(int i = (b); i < (e); i++)
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>

using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;

	int w = 0;
	int e = 0;

	REPC(c, s) {
		if (c == 'E') {
			++e;
		}
	}

	int val = e;
	REPC(c, s) {
		if (c == 'E') {
			--e;
		}

		val = min(val, w + e);

		if (c == 'W') {
			++w;
		}
	}

	cout << val << endl;
}

Measured memory_bytes: 900
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>

using namespace std;

int main() {
    long long int n, a;
    scanf("%lld", &n);
    vector<long long int> v;
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a);
        v.push_back(a - i);
    }

    sort(v.begin(), v.end());
    long long int size = v.size();
    long long int m = v[size / 2];
    long long int sad = 0;
    for (long long int e: v) sad += abs(e - m);

    printf("%lld\n", sad);

    return 0;
}


Measured memory_bytes: 2420
def main():
  n = int(input())
  hs = tuple(map(int, input().split()))

  a, b = 0, abs(hs[1] - hs[0])

  for i in range(2, n):
    d1 = a + abs(hs[i] - hs[i-2])
    d2 = b + abs(hs[i] - hs[i-1])
    a, b = b, d1 if d1 <= d2 else d2

  print(b)

if __name__ == "__main__":
  main()


Measured memory_bytes: 14184
#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int k = ri();
	int a = ri();
	int b = ri();
	bool ok = false;
	for (int i = a; i <= b; i++) if (i % k == 0) ok = true;
	std::cout << (ok ? "OK" : "NG") << std::endl;
	return 0;
}


Measured memory_bytes: 3760
N = int(input())
list_ = [x for x in range(N)]
if N%2 == 0:
  cmb_list = [[k, N-k+1] for k in range(1,int(N/2)+1)]
  print(int(N*(N-2)/2))
else:
  cmb_list = [[k, N-k] for k in range(1,int(N/2+1))]
  cmb_list.append([N])
  print(int((N-1)**2/2))

for list_ in cmb_list:
  for c in list_:
    for idx in range(1,c):
      if (idx not in list_):
        print("%s %s"%(idx, c))

Measured memory_bytes: 3352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll po[15];
ll a[100],b[100];
ll n,m;

string change(ll y){
  stringstream ss;
  string res;
  ss<<y;
  ss>>res;
  return res;
}

void solve(ll x,ll y,ll n,ll m){
 
  n-=b[x];
  y+=n/(x+1);
  n%=(x+1);
  string ans="";
  while(ans.size()<n+m+1){
    ans=ans+change(y);
    y++;
  }
  for(int i=n;i<n+m;i++){
    cout<<ans[i];
  }
  cout<<endl;
}

int main(){
  po[0]=1;
  for(int i=1;i<15;i++)po[i]=po[i-1]*10;
  
  for(int i=1;i<=10;i++){
    a[i]=po[i-1]*9*i;
    b[i]=a[i]+b[i-1];
  }
  
  while(1){
    cin>>n>>m;
    if(n==0&&m==0)break;
    n--;
    ll x=0;
    while(1){
      if(n<=b[x+1])break;
      x++;
    }
    ll y=po[x];
    solve(x,y,n,m);
  }
  
  return 0;
}


//123456789

Measured memory_bytes: 1228
using System;class P{static void Main(string[] args){bool a=false;int b,c,d,e;int[] f,g=new int[4],h=new int[4],i=new int[]{10,50,100,500};while(true){b=int.Parse(Console.ReadLine());if(b==0){break;}if(!a){a=!a;}else{Console.WriteLine();}c=0;f=Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);for(e=3;e>=0;e--){c+=f[e]*i[e];}d=c-b;for(e=3;e>=0;e--){g[e]=d/i[e];d=d%i[e];h[e]=f[e]-g[e];}for(e=0;e<4;e++){if(h[e]>0){Console.WriteLine("{0} {1}",i[e],h[e]);}}}}}


Measured memory_bytes: 9376
def gcd(t, n):
    if n == 0:
        return t
    return gcd(n, t%n)


def lcm(t, n):
    return (t * n) // gcd(t, n)


def main():
    n = 1
    for _ in range(int(input())):
        t = int(input())
        n = lcm(t, n)
    print(n)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
using namespace std;

int main(){
	int n;	cin >> n;
	int ans = 0;
	int tmp;

	for( int i = 0; i < n; i++ ){
		cin >> tmp;

		if( i % 2 == 0 && tmp % 2 == 1 ){
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3632
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
//Variables End

int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		double p=3.14159265358979323846;
		double a;cin>>a;
		double ans=2.0*p*a;
		cout<<fixed<<setprecision(12)<<ans<<endl;
    }
    return 0;
        
}


Measured memory_bytes: 3804
s=list(input())
k=0
bef="x"
n=[]
ans=0
def kai(n):
  if n==0:
    return 0
  ret=0
  for i in range(1,n+1):
    ret+=i
  return ret

for i in s:
  if bef!=i:
    if bef=="x":
      st=i
      bef=i
      k+=1
      continue
    bef=i
    n.append(k)
    k=0
  k+=1
n.append(k)
n.reverse()
if st==">":
  ans+=kai(n.pop())
while len(n)!=0:
  if len(n)==1:
    ans+=kai(n.pop())
  else:
    f=n.pop()
    s=n.pop()
    if f>s:
      ans+=kai(f)+kai(s-1)
    else:
      ans+=kai(f-1)+kai(s)
    #print("{} {}".format(f,s))

print(ans)

Measured memory_bytes: 15212
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(void){
    int n, q;
    cin >> n >> q;

    string s;
    cin >> s;

    int num[n];
    num[0] = 0;
    rep(i, n-1){
        if(s[i] == 'A' && s[i+1] == 'C')
            num[i+1] = num[i] + 1;
        else
            num[i+1] = num[i];
    }

    int count[q];
    rep(i, q){
        int l, r;
        cin >> l >> r;
        l--;
        r--;

        count[i] = num[r] - num[l];
    }

    rep(i, q)
        cout << count[i] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int k;
	string s;
	cin >> k >> s;

	if (s.length() <= k) cout << s << "\n";
	else cout << s.substr(0, k) << "...\n";

	return 0;
}




Measured memory_bytes: 3104
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;

int N,M,X,n;
ll cost,mi;
int B[20],ans[20];	//B是每个算法的总理解度
bool flag;

struct node
{
	int A[20],C;	//A是书能给的理解度 ，C是书的钱 
}nod[20];

void dfs(int u,int last)
{
	if(u==n)
	{
		cost=0;
		memset(B,0,sizeof(B));
		for(int i=0;i<u;i++)
		{
			for(int j=0;j<M;j++)
			{
				B[j]+=nod[ans[i]].A[j];
			}
			cost+=nod[ans[i]].C;
		}
		flag=true;
		//printf("cost=%d",cost) ;
		for(int i=0;i<M;i++)
		{
			if(B[i]<X)
			{
				flag=false;
				break;
			}
		}
		if(flag)
		{
			mi=min(cost,mi);
		}
		return ;
	}
	for(int i=1;i<=N;i++)
	{
		if(i>last)
		{
			last=i;
			ans[u]=i;
			dfs(u+1,last);
		}
		
	}
	
}

int main()
{
	scanf("%d%d%d",&N,&M,&X);
	for(int i=1;i<=N;i++)
	{
		scanf("%d",&nod[i].C);
		for(int j=0;j<M;j++)
		{
			scanf("%d",&nod[i].A[j]);
		}
	}
	mi=1e10;
	for(n=1;n<=N;n++)
	{
		dfs(0,0);
	}
	if(mi==1e10)
	{
		printf("-1");
	}
	else
	{
		printf("%lld",mi);
	}
	return 0;
	
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

template <typename T>
struct SegmentTree{
    typedef function<T(T,T)> F;
    int n;
    F f;
    T d1;
    vector<T> dat;
    SegmentTree(){};
    SegmentTree(int n_,F f,T d1, vector<T> v=vector<T>()): f(f), d1(d1){
        init(n_);
        if(n_==(int)v.size()) build(n_,v);
    }
    void init(int n_){
        n=1;
        while(n<n_) n*=2;
        dat.clear();
        dat.resize(2*n-1,d1);
    }
    void build(int n_, vector<T> v){
        for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
        for(int i=n-2;i>=0;i--)
        dat[i]=f(dat[i*2+1],dat[i*2+2]);
    }
    void update(int k, T a){
        k+=n-1;
        dat[k]=a;
        while(k>0){
        k=(k-1)/2;
        dat[k]=f(dat[k*2+1],dat[k*2+2]);
        }
    }
    inline T query(int a,int b){
        T vl=d1,vr=d1;
        for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
            if(l&1) vl=f(vl,dat[(l++)-1]);
            if(r&1) vr=f(dat[(--r)-1],vr);
        }
        return f(vl,vr);
    }
};

//一点更新・区間の最小値を求めるセグ木
SegmentTree<ll> get_range_min_query(int n){
    auto f = [](ll a, ll b){return min(a,b);};
    return SegmentTree<ll>(n, f, (1LL << 31) - 1);
}

int main(void)
{
    int n,q;
    cin >> n >> q;
    vector<int> ans;
    auto st = get_range_min_query(n);
    REP(i, q){
        int com,x,y;
        cin >> com >> x >> y;
        if(com)
            ans.pb(st.query(x, y+1));
        else
            st.update(x, y);
    }
    for(auto&& i : ans){
        pr(i);
    }
}


Measured memory_bytes: 5244
#include <bits/stdc++.h>
using namespace std;

#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))

typedef long long ll;
int main(){
    vector<pair<long long int,int>> v;
    long long int n; cin >> n;
    for(long long int i=2;i<=1000000;i++){
        if(n%i == 0){
            int c = 0;
            while(n%i==0){ n = n/i; c++;}
            v.push_back(make_pair(i, c));
        }
    }
    if(n!=1) v.push_back(make_pair(n, 1));
    int ans = 0;
    rep(i,v.size()){
        int ex = v[i].second;
        int sum = 0;
        int c = 0;
        for(int i=1;i+sum<=ex;i++){ sum += i; c++; }
        ans += c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll n;
  cin>>n;
  ll k;
  cin>>k;
  ll a[n];
  for(ll i=0;i<n;i++)cin>>a[i];
  ll b[n];
  for(ll i=0;i<n;i++)b[i]=1e9+5;
  b[0]=0;
  for(ll i=1;i<n;i++){
          for(ll j=0;j<k;j++){
            if(i-j-1<0)continue;
              ll c;
              c=a[i]-a[i-j-1];
              if(c<0)c=-c;
              b[i]=min(b[i-j-1]+c,b[i]);
          }
    }
  cout<<b[n-1]<<endl;
  }


Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Program
{
    public class ABC123A
    {
        static public void Main(string[] args)
        {
            var a = NextIntArray(6);

            Console.WriteLine(Math.Abs(a[0] - a[4]) <= a[5] ? "Yay!" : ":(");
        }

        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static int NextInt => int.Parse(Console_.NextString());
        static int[] NextIntArray(int N)
        {
            var ret = new int[N];
            for (int i = 0; i < N; ++i) ret[i] = NextInt;
            return ret;
        }
        static long NextLong => long.Parse(Console_.NextString());
        static long[] NextLongArray(int N)
        {
            var ret = new long[N];
            for (int i = 0; i < N; ++i) ret[i] = NextLong;
            return ret;
        }
        static string NextString => Console_.NextString();
        static void Rep(int count, Action<int> func)
        {
            for (int i = 0; i < count; ++i) func(i);
        }
        static void Rep(int count, Action func)
        {
            for (int i = 0; i < count; ++i) func();
        }
        static void Foreach<T>(IEnumerable<T> list, Action<T> func)
        {
            foreach (var item in list) func(item);
        }
        static void Foreach<T>(IEnumerable<T> list, Action<T, int> func)
        {
            int idx = -1;
            foreach (var item in list) func(item, ++idx);
        }
        static IEnumerable<long> Prime(long x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (long)(Math.Sqrt(x) / 2);
            for (long i = 1; i <= max; ++i)
            {
                if (table[i]) continue;
                var add = 2 * i + 1;
                yield return add;
                for (long j = 2 * i * (i + 1); j <= halfx; j += add) table[j] = true;
            }
            for (long i = max + 1; i <= halfx; ++i) if (!table[i]) yield return 2 * i + 1;
        }
        static IEnumerable<long> Divisor(long x)
        {
            if (x < 1) yield break;
            var max = (long)Math.Sqrt(x);
            for (long i = 1; i < max; ++i)
            {
                if (x % i != 0) continue;
                yield return i;
                if (i != x / i) yield return x / i;
            }
        }
        static long GCD(long a, long b)
        {
            long tmpa = a, tmpb = b;
            while (tmpb > 0) { var tmp = tmpb; tmpb = tmpa % tmpb; tmpa = tmp; }
            return tmpa;
        }
    }
}


Measured memory_bytes: 11220
#include<stdio.h>
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i, j;
	long long int x[1003], y[1003], z[1003];
	for (i = 0; i < n; i++)
		scanf("%lld %lld %lld", &x[i], &y[i], &z[i]);
	long long int p[8][1003];
	long long int ans = 0;
	long long int f, sum;
	for (i = 0; i < n; i++)
	{
		p[0][i] = x[i] + y[i] + z[i];
		p[1][i] = x[i] + y[i] - z[i];
		p[2][i] = x[i] - y[i] + z[i];
		p[3][i] = x[i] - y[i] - z[i];
		p[4][i] = -x[i] + y[i] + z[i];
		p[5][i] = -x[i] + y[i] - z[i];
		p[6][i] = -x[i] - y[i] + z[i];
		p[7][i] = -x[i] - y[i] - z[i];
	}
	for (i = 0; i < 8; i++)
	{
		for (j = 0; j < n - 1; j++)
		{
			if (p[i][j] < p[i][j + 1])
			{
				f = p[i][j];
				p[i][j] = p[i][j + 1];
				p[i][j + 1] = f;
				if (j > 0)
					j -= 2;
			}
		}
	}
	for (i = 0; i < 8; i++)
	{
		sum = 0;
		for (j = 0; j < m; j++)
			sum += p[i][j];
		if (ans < sum)
			ans = sum;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	int N1, N2, N3;

	cin >> N1 >> N2 >> N3;

	if(N1 == N2 && N2 == N3){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
def weigh(w):
    if w <= 48.0:
        print('light fly')
    elif w > 48.0 and w <= 51.0:
        print('fly')
    elif w > 51.0 and w <= 54.0:
        print('bantam')
    elif w > 54.0 and w <= 57.0:
        print('feather')
    elif w > 57.0 and w <= 60.0:
        print('light')
    elif w > 60.0 and w <= 64.0:
        print('light welter')
    elif w > 64.0 and w <= 69.0:
        print('welter')
    elif w > 69.0 and w <= 75.0:
        print('light middle')
    elif w > 75.0 and w <= 81.0:
        print('middle')
    elif w > 81.0 and w <= 91.0:
        print('light heavy')
    else:
        print('heavy')
    return 0

d = []
while True:
    try:
        d.append(float(input()))
    except EOFError:
        break

for i in range(len(d)):
    weigh(d[i])

Measured memory_bytes: 7528
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n , a , b; cin>>n>>a>>b;
  vector<int>v(n);
  for(int& i : v)cin>>i;
  int ans = n;
  b--;
  for(int i = 0 ; i < n; ++i){
    if(v[i] >= a && v[i] <= b)ans--;
  }
  cout<<ans<<"\n";

}

Measured memory_bytes: 3628
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A={1,2,3,5,6,9,10,13,17};
    if(find(A.begin(), A.end(), N)!=A.end())prt("No");
    else prt("Yes");

    return 0;
}



Measured memory_bytes: 3652
#include<stdio.h>
int student[31];
int main(){
	int i,c;
	for(i=0;i<28;i++){
		scanf("%d",&c);
		student[c]=1;
	}
	for(c=1;c<=30;c++){
		if(student[c]==0){
			printf("%d\n",c);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int N, M, R;
int r[8];
int to[205][205];
int ans = INF;
bool used[8];

void dfs(int num, int pre, int dist) {
    if (num>=R) {
        if (ans>dist) ans = dist;
        return;
    }
    rep(i,R) {
        if(used[i]) continue;
        used[i] = true;
        if(pre==-1) dfs(num+1, i, 0);
        else        dfs(num+1, i, dist + to[r[pre]][r[i]]);
        used[i] = false;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	cin >> N >> M >> R;
    rep(i,R) {
        cin >> r[i];
        --r[i];
    }
    rep(i,R) used[i] = false;
    rep(i,N) rep(j,N) {
        if(i==j) to[i][j] = 0;
        else     to[i][j] = INF;
    }
    rep(i,M) {
        int a, b, c;
        cin >> a >> b >> c;
        to[a-1][b-1] = c;
        to[b-1][a-1] = c;
    }
    rep(k,N) rep(i,N) rep(j,N) mins(to[i][j], to[i][k] + to[k][j]);
    // rep(i,N) rep(j,N) cout << to[i][j];
    dfs(0, -1, 0);
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3792
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()

kk = 0
k2 = 0

for i in range(1,n+1):
    if i%k == 0:
        kk += 1
    elif i%(k/2) == 0:
        k2 += 1
        
print(kk**3 + k2**3)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,k;cin>>n>>k;
    ll dp[n+1][n*n+n+1][n+1];
    memset(dp,0,sizeof dp);
    dp[n][0][0]=1;
    rrep(i,n,1){
        rep(j,0,n*n+n+1){
            rep(l,0,n+1){
                if(dp[i][j][l]==0)continue;
                if(l>0){
                    (dp[i-1][j-(i-1)*2][l-1]+=l*l*dp[i][j][l])%=mod;
                }
                (dp[i-1][j][l]+=(2*l+1)*dp[i][j][l])%=mod;
                (dp[i-1][j+(i-1)*2][l+1]+=dp[i][j][l])%=mod;
            }
        }
    }
    cout<<dp[0][k][0]<<endl;
}


Measured memory_bytes: 52096
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

//二次元平面を探索しよう
template <typename T,typename U>                                                   
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {   
    return {l.first+r.first,l.second+r.second};                                    
} 

vector<pair<int, int>> nei;
void nei_init(){
	nei.push_back(make_pair(-1,0));nei.push_back(make_pair(1,0));nei.push_back(make_pair(0,-1));nei.push_back(make_pair(0,1));
	//4近傍ならコメントアウト
	//nei.push_back(make_pair(-1,-1));nei.push_back(make_pair(1,-1));nei.push_back(make_pair(1,1));nei.push_back(make_pair(-1,1));
}

bool is_safe(pair<int, int> p, int h, int w){
	if(p.first < 0 || p.second < 0) return false;
	else if(p.first >=h || p.second >=w) return false;
	else return true;
}
//

int main() {
	int ans = 0;
	int tmp;
	nei_init();
	int h, w;
	cin >> h >> w;
	vector<string> mp(h);
	REP(i, h) cin >> mp[i];
	queue<pair<pair<int, int>,int> > q;
	bool ch[h][w] ={};
	int count = h*w;
	REP(i, h) REP(j, w) if(mp[i][j] == '#'){
		q.push(make_pair(make_pair(i, j),1));
		ch[i][j] = true;
		count--;
	}
	pair<int, int> now;
	int ope;
	while(!q.empty() && count > 0){
		now = q.front().first;
		ope = q.front().second;
		q.pop();
		ans = max(ans, ope);
		REP(i, nei.size()){
			pair<int, int> see = make_pair(now.first+nei[i].first, now.second+nei[i].second); 
			if(is_safe(see, h, w) && !ch[see.first][see.second]){
				q.push(make_pair(see, ope+1));
				ch[see.first][see.second] = true;
				count--;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 18340
using System;
namespace ConsoleApplication1{
    class Program{
        static void Main(string[] args){
            String str;
		    while((str=Console.ReadLine())!=null){
                String[] strArray=str.Split();
			    double x1=double.Parse(strArray[0]);
			    double y1=double.Parse(strArray[1]);
			    double x2=double.Parse(strArray[2]);
			    double y2=double.Parse(strArray[3]);
			    double x3=double.Parse(strArray[4]);
			    double y3=double.Parse(strArray[5]);
			    double xp=double.Parse(strArray[6]);
			    double yp=double.Parse(strArray[7]);
			    double z1=(x3-x2)*(yp-y2)-(y3-y2)*(xp-x2);
			    double z2=(x1-x3)*(yp-y3)-(y1-y3)*(xp-x3);
			    double z3=(x2-x1)*(yp-y1)-(y2-y1)*(xp-x1);
                Console.WriteLine(z1>=0&&z2>=0&&z3>=0||z1<=0&&z2<=0&&z3<=0?"YES":"NO");
		    }
        }
    }
}

Measured memory_bytes: 5696
#include <bits/stdc++.h>
using namespace std;

bool f(vector<char> s){
  int n = s.size();
  vector<char> a(n/2), b(n/2);
  for(int i = 0; i < n/2; i++) a[i] = s[i];
  for(int i = 0; i < n/2; i++) b[i] = s[n-i-1];
  if(a==b) return true;
  else return false;
}

int main(){
  string s; cin >> s;
  int n = s.length();
  vector<char> a(n), b(n/2);
  for(int i = 0; i < n; i++) a[i] = s[i];
  for(int i = 0; i < n/2; i++) b[i] = s[i];
  if(f(a) && f(b)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int n;

bool sosuu(int a){
	for(int i = 2; i*i <= a; i++){
		if(a % i == 0) return 0;
	}
	return 1;
}

int main(){
	cin >> n;
	
	int c = 0;
	for(int i = 6; i < 55555; i+=5){
		if(sosuu(i)){ 
			cout << i << " "; 
			c++;
		}
		if(c == n) break;
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  long long N;
  cin >> N;

  long long ans = N;
  for(long long i = 1; i <= sqrt(N); ++i) {
    if(N % i == 0) {
      ans = min(ans, (i - 1) + ((N / i) - 1));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3688