akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  int n; cin >> n; vector<int> v(n);
  for(auto &x:v) cin >> x;
  int ans = v[0];
  for(int i=1;i<n;i++) ans = __gcd(ans, v[i]);
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	static Node[] V;
	
	public static void main(String[] args) {
		int Vn = sc.nextInt();
		int En = sc.nextInt();
		
		V = new Node[Vn]; 
		for(int i=0; i<Vn; i++) {
			V[i] = new Node();
			V[i].id = i;
		}
		
		PriorityQueue<Edge> edges = new PriorityQueue<>((a, b) -> a.d - b.d);
		for(int i=0; i<En; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			int d = sc.nextInt();
			edges.add(new Edge(s, t, d));
		}
		
		int ans = 0;
		
		while(!edges.isEmpty()) {
			Edge e = edges.poll();
			int sp = V[e.s].findParent();
			int tp = V[e.t].findParent();
			
			if(sp != tp) {
				ans += e.d;
				V[tp].parent = sp;
			}
		}
		
		System.out.println(ans);
	}
	
	static class Node {
		int id;
		int parent = -1;
		
		int findParent() {
			if(parent == -1) {
				return id;
			}
			
			int p = V[parent].findParent();
			parent = p;
			return p;
		}
	}
	
	static class Edge {
		int s;
		int t;
		int d;
		
		Edge(int s, int t, int d) {
			this.s = s;
			this.t = t;
			this.d = d;
		}
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}

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

vector<vector<int>> V;

void dfs(vector<int> cur, set<int> s) {
    if (s.size() == 0) {
        V.push_back(cur);
    }
    else {
        for (auto itr = s.begin(); itr != s.end(); itr++) {
            vector<int> cur_t = cur;
            set<int> s_t = s;
            cur_t.push_back(*itr);
            s_t.erase(*itr);
            dfs(cur_t, s_t);
        }
    }
    return;
}

int main() {

    int N;
    cin >> N;

    vector<int> P(1e4);
    rep(i, N) cin >> P[i];
    vector<int> Q(1e4);
    rep(i, N) cin >> Q[i];

    set<int> S;
    vector<int> v;
    rep(i, N) S.insert(i+1);
    dfs(v, S);

    int a, b;
    rep(i, V.size()) {
        bool p_ok = true;
        bool q_ok = true;
        rep(j, N) {
            if (V[i][j] != P[j]) p_ok = false;
            if (V[i][j] != Q[j]) q_ok = false;
        }
        if (p_ok) a = i;
        if (q_ok) b = i;
    }

    cout << abs(a-b) << endl;

    return 0;
}


Measured memory_bytes: 3384
mod = 1000000007

N, M = map(int, input().split())
broken = [0] * (N+1)
s = [0 for _ in range(N+1)]
for _ in range(M):
    a = int(input())
    broken[a] = 1
s[0] = 1
for i in range(1, N+1):
    if broken[i]:
        s[i] = 0
    else:
        s[i] = (s[i-1] + s[i-2]) % mod
        s[i] %= mod
print(s[N] % mod)
'''
s[0] = 0
s[1] = 1
s[2] = 2

cur_ix = 0
for i in range(1, 3):
    if a[cur_ix] == i:
        s[i] = 0
        cur_ix += 1
    else:
        if i == 1:
            s[i] = 1
        elif i == 2:
            s[i] = s[i-1] + s[i-2] + 1

for i in range(3, N+1):
    if cur_ix < len(a) and a[cur_ix] == i:
        s[i] = 0
        cur_ix += 1
    else:
        s[i] = (s[i-1] + s[i-2]) % 1000000007
'''


Measured memory_bytes: 7836
n = int(input())
a = list(map(int, input().split(' ')))
q = int(input())
for i in range(q):
    b, e, t = list(map(int, input().split(' ')))
    for k in range(e-b):
        a[b+k], a[t+k] = a[t+k], a[b+k]
print(' '.join(list(map(str, a))))


Measured memory_bytes: 5640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)

        {
            var k = long.Parse(Console.ReadLine());
            long ans = 0;

            for(long i = 1; i <= k; i++)
            {
                for(long j = 1; j <= k; j++)
                {
                    for(long l = 1; l <= k; l++)
                    {
                        ans += Gcd(Gcd(i, j), l);
                    }
                }
            }

            Console.WriteLine(ans);
                
                





        }

       
        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }

        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }
    }
}


Measured memory_bytes: 27316
c = [int(i) for i in input().split()]
a = c[0]
b = c[1]

r = int((a*b)/2)
if a == 1 or b == 1:
    print(1)
elif a%2 == 0 or b%2 == 0:
    print(r)
else:
    print(r+1)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 10;
const double EPS = 1e-10;

int dx[2][7] = {
  {0, 1, 1, 0, -1, -1, 0},
  {0, 1, 1, 0, -1, -1, 0},
};

int dy[2][7] = {
  {1, 0, -1, -1, -1, 0, 0},
  {1, 1, 0, -1, 0, 1, 0},
};
    

const int geta = 198;
int dist[6][400][400];
int kagu[400][400];

int main(){
  int n;
  int sx, sy, gx, gy;
  int lx, ly;
  cin >> sx >> sy >> gx >> gy;
  cin >> n;

  memset(kagu, 0, sizeof(kagu));
  
  REP(i, n){
    int x, y;
    cin >> x >> y;
    kagu[x + geta][y + geta] = true;
  }
  
  cin >> lx >> ly;
  
  sx += geta; sy += geta;
  gx += geta; gy += geta;

  fill(&dist[0][0][0], &dist[0][0][0] + 6 * 400 * 400, INF);
  
  dist[0][sx][sy] = 0;
  
  priority_queue<pair<P, P>, vector<pair<P, P> >, greater<pair<P, P > > > que;
  que.push(MP(P(0, 0), P(sx, sy)));
  
  while(!que.empty()){
    int c = que.top().first.first;
    int t = que.top().first.second;
    int x = que.top().second.first;
    int y = que.top().second.second;
    que.pop();
    
    if(c > dist[t][x][y]) continue;
    if(x == gx && y == gy){
      cout << c << endl;
      return 0;
    }

    REP(i, 7){
      int nx = x + dx[x % 2][i];
      int ny = y + dy[x % 2][i];
      int nt = (t + 1) % 6;
      int tmp = c + (i != abs((x - geta) * (y - geta) * t) % 6);
      if(kagu[nx][ny]) continue;
      if(abs(nx - geta) <= lx && abs(ny - geta)<=ly && tmp < dist[nt][nx][ny]){
        dist[nt][nx][ny] = tmp;
        que.push(MP(P(tmp, nt), P(nx, ny)));
      }
    }
  }
  cout << -1 << endl;
  return 0;
}    

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

int main() {
  int N, M;
  cin >> N;

  int i,j;
  vector<string> str(N);
  vector<int> point(N);
  string s;
  for (i=0;i<N;i++){
    cin >> str.at(i);
    point.at(i) = 1;
  }

  cin >> M;
  for (i=0;i<M;i++){
    cin >> s;
    str.push_back(s);
    point.push_back(-1);
  }

  vector<bool> flag(N+M, false);
  int p = 0, temp = 0;
  for (i=0;i<M+N;i++){
    if (flag.at(i) == true) {
      continue;
    } else {
      flag.at(i) = true;
    }
    temp = 0;
    for (j=i;j<M+N;j++){
      if (str.at(j) == str.at(i)){
        temp += point.at(j);
        flag.at(j) = true;
      }
    }
    if (i = 0) {
      p = temp;
    } else if (temp > p) {
      p = temp;
    }
  }
  if (p < 0) {
    p = 0;
  }
  cout << p << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 200005, mo = 1000000007 ;
using namespace std ;

int n, d[2][N], f[2][N] ; 
ll A, B, a[N] ;

int main() {
	scanf("%d%lld%lld", &n, &A, &B) ;
	rep(i, 1, n) {
		scanf("%lld", &a[i]) ;
	}
	f[0][0] = f[1][0] = 1 ;
	d[0][++ d[0][0]] = 0 ;
	d[1][++ d[1][0]] = 0 ;
	int l[2] = {0} ;
	rep(i, 2, n) {
		for ( ; l[0] < i - 2 && a[i] - a[l[0] + 1] >= A ; ++ l[0]) ;
		for ( ; l[1] < i - 2 && a[i] - a[l[1] + 1] >= B ; ++ l[1]) ;
		f[0][i - 1] = f[1][l[0]] ;
		f[1][i - 1] = f[0][l[1]] ;
		if (a[i] - a[i - 1] < A) {
			for ( ; d[0][0] ; -- d[0][0]) f[0][d[0][d[0][0]]] = 0 ;
		}
		if (a[i] - a[i - 1] < B) {
			for ( ; d[1][0] ; -- d[1][0]) f[1][d[1][d[1][0]]] = 0 ;
		}
		f[0][i - 1] = (f[0][i - 1] + f[0][i - 2]) % mo ;
		f[1][i - 1] = (f[1][i - 1] + f[1][i - 2]) % mo ;
		d[0][++ d[0][0]] = i - 1 ;
		d[1][++ d[1][0]] = i - 1 ;
	}
	printf("%d\n", (f[0][n - 1] + f[1][n - 1]) % mo) ;
	return 0 ;
}

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

const int N= 200001;
int parent[N];
int rnk[N];

void make_set(int r){
    parent[r]=r;
    rnk[r]=0;
}

int find_set(int r){
    if(parent[r]==r){
        return r;
    }else{
        return parent[r]=find_set(parent[r]);
    }
}

void union_set(int a, int b){
    a= find_set(a);
    b=find_set(b);
    if(a!=b){
        if(rnk[a]<rnk[b]){
            swap(a,b);
        }
        parent[b]=a;
        if(rnk[a]==rnk[b]){
            rnk[a]++;
        }
    }
}

int main(){
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n;++i){
        make_set(i);
    }
    for(int i=0; i<q; ++i){
        int t,u,v;
        cin>>t>>u>>v;
        if(t==0){
            union_set(u,v);
        }else{
            cout<<((find_set(u)==find_set(v))? 1:0)<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4920
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int[] L = new int[N];
        for(int i = 0; i < N; i++){
            L[i] = sc.nextInt();
        }
        
        int D = 0;
        int count = 1;
        for(int i = 0; i < N; i++){
            D += L[i];
            if(D <=X){
                count++;
            }else{
                break;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 22996
#include <stdio.h>
#include <math.h>

int main(void)
{
	int a[110];
	int n, i;
	double b[110];
	double s;
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d", &a[i]);
	}
	s=0.0;
	for(i=0;i<n;i++){
		b[i]=1.0/(double)a[i];
		s=s+b[i];
	}
	printf("%lf", 1.0/s);
	return 0;
}

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

const int MOD = (int)1e9+7;

int main(){
	int N;
	cin >> N;
	vector<int> a(N),b(N),c(N);
	for(int i=0;i<N;i++)	cin >> a.at(i) >> b.at(i) >> c.at(i);
	
	vector<vector<int>> dp(N+1,vector<int>(3,0));
	for(int i=0;i<N;i++){
		dp.at(i+1).at(0)=max({dp.at(i+1).at(0),dp.at(i).at(1)+a.at(i),dp.at(i).at(2)+a.at(i)});
		dp.at(i+1).at(1)=max({dp.at(i+1).at(1),dp.at(i).at(0)+b.at(i),dp.at(i).at(2)+b.at(i)});
		dp.at(i+1).at(2)=max({dp.at(i+1).at(2),dp.at(i).at(0)+c.at(i),dp.at(i).at(1)+c.at(i)});
		//cout << "i:" << i << ", " << dp.at(i+1).at(0) << ", " << dp.at(i+1).at(1) << ", " << dp.at(i+1).at(2) << endl;
	}
	int ans=0;
	for(int i=0;i<3;i++){
		ans=max(ans,dp.at(N).at(i));
	}
	cout << ans << endl;

	return 0;
}


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

vector< pair< pair<string, int>, int> >cook;

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		int p;
		cin>>p;
		cook.push_back(make_pair(make_pair(s,-p), i+1));
	}
	sort(cook.begin(), cook.end());
	for(int j=0;j<n;j++){
		cout<<cook[j].second<<endl;
	}
}

Measured memory_bytes: 3620
d,n=map(int, input().split())

if d==0 and n==100:
  print(101)
elif d==0:
  print(n)

if d==1 and n==100:
    print(10100)
elif d==1:
  print(100*n)
  
if d==2 and n==100:
    print(1010000)
elif d==2:
  print(10000*n)

Measured memory_bytes: 3060
a,b = map(int, raw_input().split())

if a==b:
	print "Draw"
else:
	if a!=1 and b!=1:
		if a<b:
			print "Bob"
		else:
			print "Alice"
	elif a==1 and b!=1:
		print "Alice"
	else:
		print "Bob"

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

using namespace std;

int n, ans = 0;
int a[110], b[110];
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    for (int i = 0; i < n; i++)
    {
        if (a[i] == b[i])
        {
            ans++;
            if (ans == 3)
                return cout << "Yes", 0;
        }
        else
            ans = 0;
    }
    return cout << "No", 0;
    return 0;    
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
	    public static void main(String[] args) {
	        Scanner scan = new Scanner(System.in);
	        String str = scan.next();
	        scan.close();

	        String strAfter = null;
			for(int i=0; i<str.length() ;i++) {
				 str.charAt(i);
				 strAfter += "x";
			}
          	System.out.print(strAfter.replace("null", ""));

    }
}


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

long long N,A,B,X[100009],sum;

int main(){
	cin>>N>>A>>B;
	for(int i=0;i<N;i++) cin>>X[i];
	sort(X,X+N);
	for(int i=0;i<N-1;i++){
		sum+=min(B,(X[i+1]-X[i])*A);
	}
	cout<<sum<<endl;
	return 0;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

vector<int64_t> fct, inv;
void finit(int cmx, ll mod =MD){
	fct.resize(cmx+20); inv.resize(cmx+20);
	auto bin_pows =[](ll x, ll n, ll mod){
		ll res = 1LL;
		for(; n > 0; n >>=1, x = x*x %mod) if(n & 1) res = res * x %mod;
		return res;
	};
	fct[0] = fct[1] = inv[1] = 1;
	for(int i=2;i<cmx+3;i++) fct[i] = fct[i-1] * i % mod;
	inv[cmx] = bin_pows(fct[cmx], mod-2, mod);
	for(int i=cmx;i>=1;i--) inv[i-1] = inv[i] * i % mod;
}
ll nCk(ll n, ll k, ll mod =MD) {
	if(k > n || n <0 || k <0) return 0;
	ll ret =fct[n] * inv[k] % mod * inv[n-k] % mod;
	return ret;
}
map<ll, int> fctm( ll x ){
	map<ll, int> fmp;
	for( ;x>=4 && x%2==0; x/=2)  fmp[2]++;
	for(ll d=3, q=x/d; q>=d ; q=x/d){if(x%d==0) fmp[d]++, x=q; else d +=2;}
	if(x!=1) fmp[x]++;
	return fmp;
}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll m,  ans =1;
	cin >>n >>m;
	
	finit(n*2+300);
	
	for(auto& z: fctm(m)){
		(ans *= nCk(z.second + n -1, n-1) )%=MD;;
	}
	cout << ans <<"\n";
	return 0;
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A+B > C+D) cout << "Left" << endl;
  if(A+B == C+D) cout << "Balanced" << endl;
  if(A+B < C+D) cout << "Right" << endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {

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

    if (a >= k) {
        printf("%d", k);
    } else if (a + b >= k) {
        printf("%d", k-b);
    } else {
        printf("%d", a - (k - a - b));
    }

    return 0;
} 

Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
  string line;
  int W,H,x,y,r;
  getline (cin,line);
  stringstream(line) >> W >> H >> x >> y >> r;
  if ( x-r < 0 || y-r < 0 || x+r > W || y+r > H )
  { cout << "No\n"; }
  else
  { cout << "Yes\n"; }
  return 0;
}

Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
	ll a, b, n;
	cin >> a >> b >> n;
	ll ans = b / n;
	ans -= (a - 1) / n;
	if (a == 0) {
		ans++;
		if (n == 1)	ans--;
	}
	cout << ans << endl;
	return 0;
}

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


#define int long long

const int N = 2e5 + 7;

string str[N]; 



int nxt[1000001][27], ptr = 1;


void insrt(string &s) {
	int cur = 1;
	for(auto ch: s) {
		if(!nxt[cur][ch - 'a']) {
			nxt[cur][ch - 'a'] = ++ptr;
 		}
 		cur = nxt[cur][ch - 'a'];
	}
	nxt[cur][26]++;
}

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> str[i];
		reverse(str[i].begin(), str[i].end());
		insrt(str[i]);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		vector <int> f(26, -1);
		int cur = 1;
		for(int j = 0; j < str[i].size(); j++) {
			f[str[i][j] - 'a'] = j;
		}
		for(int j = 0; j < 26; j++) if(f[j] > -1) {
			ans += nxt[nxt[cur][j]][26];
		}
		for(int j = 0; j < str[i].size(); j++) {
			cur = nxt[cur][str[i][j] - 'a'];
			for(int k = 0; k < 26; k++) {
				if(f[k] > j)
				ans += nxt[nxt[cur][k]][26];
			}
		}
		--ans;
		//cout << i << " " << ans << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 221512
N=int(input())

A=list(map(int,input().split()))
ans=0
S=1
if 0 in A:
    print(0)
else:
    for i in range(N):
        S=S*A[i]
        if S>10**18:
            print(-1)
            ans=1
            break
    if ans==0:
        print(S)


Measured memory_bytes: 21800
package main

import (
	"fmt"
	"log"
	"math"
)

func main() {

	var A, B int //
	var result int

		_, err := fmt.Scan(&A, &B)
		if err != nil {
			log.Fatal(err)
		}

		if A == B{
			result = A + B
		}else{
			result = int(math.Max(float64(A),float64(B))) * 2 - 1
		}

		fmt.Println(result)
}


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

int digitsum(int n)
{
    int sum = 0;
    while(n > 0)
    {
        sum += n % 10;
        n = n / 10;
    }
    return sum;
}

int main(void){
    // Your code here!
    int N;
    cin >> N;
    int sum = 0;
    sum = digitsum(N);
    
    if (N % sum == 0) 
    {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,k=map(int,input().split())
    H=list(map(int,input().split()))
    dp=[-1]*n #足湯iまでに着くまでに支払うコストの総和の最小値
    dp[0]=0
    for i in range(n):
        for j in range(1,k+1):
            ni=i+j
            if ni>=n:continue
            if dp[ni]==-1:
                dp[ni]=dp[i]+abs(H[ni]-H[i])
            else:
                dp[ni]=min(dp[ni],dp[i]+abs(H[ni]-H[i]))
    print(dp[n-1])
if __name__=='__main__':
    main()

Measured memory_bytes: 52448
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100005
int n,ans;
int cnt1[MAXN],cnt2[MAXN],m1,m2,n1,n2;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if(i%2)
		{
			cnt1[x]++;
			if(m1<cnt1[x])
				m1=cnt1[x],n1=x;
		}
		else 
		{
			cnt2[x]++;
			if(m2<cnt2[x])
				m2=cnt2[x],n2=x;
		}
	}
	sort(cnt1,cnt1+MAXN);
	sort(cnt2,cnt2+MAXN);
	if(n1!=n2)
		ans=n-m1-m2;
	else ans=n-max(m1+cnt2[MAXN-2],m2+cnt1[MAXN-2]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		double pi = Math.PI;
		System.out.printf("%f %f", pi * r * r, 2 * pi * r);
		sc.close();
	}
}


Measured memory_bytes: 28224
#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;
    ll N, K;
    cin >> N >> K;
    if(2*K-1 > N){
        cout << -1 << endl;
    }else{
        if(N%2 == 0){
            ll l = N/2;
            for(int i = 0; i < l; i++){
                cout << K+l-1-i << ' ' << K+2*l+2*i+1 << ' ' << K+2*N+i << endl;
            }
            for(int i = 0; i < l; i++){
                cout << K+2*l-i-1 << ' ' << K+2*l+2*i << ' ' << K+2*N+l+i << endl;
            }
        }else{
            ll l = (N-1)/2;
            for(int i = 0; i < l; i++){
                cout << K+l-1-i << ' ' << K+2*l+2*i+2 << ' ' << K+2*N+i << endl;
            }
            for(int i = 0; i <= l; i++){
                cout << K+2*l-i << ' ' << K+2*l+2*i+1 << ' ' << K+2*N+l+i << endl;
            }
        }
    }
}

Measured memory_bytes: 2304
while True:
    h,w=map(int,input().split())
    if h==0 and w==0:
        break
    for i in range(h):
        for j in range(w):
            if i==0 or i==h-1 or j==0 or j==w-1:
                print('#',end='')
            else:
                print('.',end='')
        print()
    print()


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

int main() {
    int K,S;
    cin >> K >> S;

    int count = 0;

    for (int i = 0; i <= K; i++) {
        for (int j = 0; j <= K; j++) {
            int z = S - (i + j);
            if (0 <= z && z <= K) {
                count++;
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3608
n = int(input())
a = list(map(int, input().split()))
a.append(0)
for i in range(n):
    a[n] ^= a[i]
    #全ての排他的論理和を求める。→興味があるのは、2進数で1が偶数個立ってる列。
    #ここでa[n]に奇数個しか1がないもの
for i in range(n):
    a[i] &= ~a[n]
r = 0
for i in range(60, -1, -1):
    for j in range(r, n):
        if (a[j] >> i) & 1:
            a[r], a[j] = a[j], a[r]
            break
    else:
        continue
        
    for j in range(n):
        if j == r:
            continue
        if (a[j]>>i) & 1:
            a[j] ^= a[r]
    r+=1
s = 0
for i in range(r):
    s ^= a[i]
    
print(s*2 + a[n])

Measured memory_bytes: 76960
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,memo=-10,sum=0;
  cin >>n;
  vector<int> a(n),b(n),c(n-1);
  for(int i=0;i<n;i++){
      cin >>a[i];
  }
  for(int i=0;i<n;i++){
      cin >>b[i];
  }
  for(int i=0;i<n-1;i++){
      cin >>c[i];
  }
  for (int food:a){
      sum +=b[food-1];
      if(memo==food-1)sum+=c[memo-1];
      memo=food;


  }
  cout <<sum<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

int c[3][3];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);

    REP(i, 3)
    {
        REP(j, 3)
        {
            cin >> c[i][j];
        }
    }
    for (int i = -100; i <= 100; ++i)
    {
        for (int j = -100; j <= 100; ++j)
        {
            if (i + j < 0 && i + j != c[0][0])
                continue;

            //iはa0, jはb0の値
            int a1 = c[1][0] - j;
            int a2 = c[2][0] - j;
            int b1 = c[0][1] - i;
            int b2 = c[0][2] - i;
            if (a1 + b1 == c[1][1] && a2 + b1 == c[2][1] && a1 + b2 == c[1][2] && a2 + b2 == c[2][2])
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
template<typename T> T my_max(T lhs, T rhs)
{
	return (lhs > rhs)? lhs : rhs;
}
int main()
{
	long long a = 0, b = 0, x = 0;
	cin >> a >> b >> x;
	long long val1 = my_max(a - 1, (long long)0) / x;
	long long val2 = b / x;
	long long ans = val2 - val1;
	if(a == 0) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,f,Alice=0,Bob=0;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    f=(n+1)/2;
    for(int i=0;i<f;i++){
        Alice+=a.at(i*2);
        if(i*2+1<=n-1)
        Bob+=a.at(i*2+1);
    }
    cout<<Alice-Bob<<endl;
}























































































































































































































































































































































































































































































































































































































































































































































Measured memory_bytes: 3588
def main():
	N, K = map(int, input().split())
	h = list(map(int, input().split()))

	dp=[0]*N
 
	for i in range(1,N):
		dp[i] = min(
			dp[g] + abs(h[i] - h[g]) for g in range(max(i-K,0), i)
		)
	print(dp[N-1])
main()


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 1e-10;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(n) cin >> a[i];
    
    if(a[0] != 0){
        cout << -1 << endl;
        return 0;
    }

    ll ans = 0LL;
    repp(i, n-1){
        if(a[i]+1 < a[i+1]){
            cout << -1 << endl;
            return 0;
        }else if(a[i]+1 > a[i+1]){
            ans += a[i];
        }
    }
    ans += a[n-1];
    cout << ans << endl;
    return 0;
}

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

const int mod = 1000000007, inv2 = mod + 1 >> 1;
long long fac[200010], inv[200010];
int B, W;

long long Pow(long long x, long long y)
{
    long long ans = 1;
    for (; y; y >>= 1, x = x * x % mod)
        if (y & 1) ans = ans * x % mod;
    return ans;
}
void pre(int n = 200000)
{
    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = fac[i - 1] * i % mod;
    inv[n] = Pow(fac[n], mod - 2);
    for (int i = n - 1; i >= 0; i--)
        inv[i] = inv[i + 1] * (i + 1) % mod;
}
long long C(int x, int y)
{
    if (x < y) return 0;
    return fac[x] * inv[y] % mod * inv[x - y] % mod;
}
int main()
{
    pre();
    scanf("%d%d", &B, &W);
    if (B < W)
    {
        for (int i = 1; i <= B; i++)
            printf("%d\n", inv2);
        long long hh = Pow(inv2, B + 1);
        long long now = (inv2 - hh + mod) % mod;
        for (int i = B + 1; i <= W; i++)
        {
            printf("%lld\n", now);
            now = (now - hh * Pow(inv2, i - B) % mod * C(i - 1, B - 1) % mod + mod) % mod;
        }
    }
    else
        for (int i = 1; i <= W; i++)
            printf("%d\n", inv2);
    long long now1 = 0, now2 = 1;
    for (int i = 1; i < B; i++)
        now1 = (now1 + C(W, i)) % mod;
    for (int i = W + 1; i <= W + B; i++)
    {
        printf("%lld\n", (now1 * Pow(inv2, i) % mod + now2 * Pow(inv2, W) % mod) % mod);
        now1 = ((now1 * 2 % mod - C(i - 1, i - W) - C(i - 1, B - 1)) % mod + mod) % mod;
        now2 = (now2 + Pow(inv2, i - W) * C(i - 1, W - 1) % mod) % mod;
    }
}


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

#define MAXN 200005
#define int long long
#define LL long long
#define pii pair<long, long>
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
using namespace std;

int N, M;

struct Seg {
    int idx, l, r, m, tag, val;
    void build(int id, int s, int e);
    Seg& left();
    Seg& right();
    void pushdown();
    void update(int s, int e, int off);
    int query(int s, int e);
} nodes[MAXN*4];
Seg& Seg::left() { return nodes[idx*2]; };
Seg& Seg::right() { return nodes[idx*2+1]; }
void Seg::build(int id, int s, int e) {
    idx = id, l = s, r = e, m = (l+r)>>1, tag = 0, val = 0;
    if (l != r) left().build(id*2, s, m), right().build(id*2+1, m+1, e);
}
void Seg::pushdown() {
    if (l == r) return;
    if (tag) {
        left().update(l, m, tag);
        right().update(m+1, r, tag);
        tag = 0;
    }
}
void Seg::update(int s, int e, int off) {
    if (l == s && r == e) {
        tag += off, val += off;
        return;
    }
    pushdown();
    if (e <= m) left().update(s, e, off);
    else if (s > m) right().update(s, e, off);
    else left().update(s, m, off), right().update(m+1, e, off);
    val = max(left().val, right().val);
}
int Seg::query(int s, int e) {
    if (l == s && e == r) return val;
    pushdown();
    if (e <= m) return left().query(s, e);
    if (s > m) return right().query(s, e);
    return max(left().query(s, m), right().query(m+1, e));
}

pair<pii, int> a[MAXN];

signed main() {
    fastio;
    cin >> N >> M;
    for (int i = 1; i <= M; i++) {
        cin >> a[i].fi.fi >> a[i].fi.se >> a[i].se;
    }
    nodes[1].build(1, 0, N);
    sort(a+1, a+1+M, [](const pair<pii, int>& p1, const pair<pii, int>& p2) {
        return p1.fi.se < p2.fi.se;
    });
    int j = 1;
    for (int i = 1; i <= N; i++) {
        nodes[1].update(i, i, nodes[1].query(0, i) - nodes[1].query(i, i));
        while (j <= M && a[j].fi.se <= i) {
            nodes[1].update(a[j].fi.fi, a[j].fi.se, a[j].se);
            j++;
        }
    }
    cout << nodes[1].query(0, N) << endl;
    return 0;
}

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

int main() {
  std::vector<int> x(3);

  for (auto &i : x) {
    std::cin >> i;
  }
  std::sort(x.begin(), x.end());
  int count = 0;

  if (x[0] % 2 == x[1] % 2 && x[0] % 2 != x[2] % 2) {
    count++;
    x[0]++;
    x[1]++;
  } else if (x[0] % 2 == x[2] % 2 && x[0] % 2 != x[1] % 2) {
    count++;
    x[0]++;
    x[2]++;
  } else if (x[1] % 2 == x[2] % 2 && x[0] % 2 != x[1] % 2) {
    count++;
    x[1]++;
    x[2]++;
  }
  count += (x[2] - x[0]) / 2;
  count += (x[2] - x[1]) / 2;
  std::cout << count << std::endl;
  return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;

int main() {

    int n, m;
    cin >> n >> m;
    vector<vector<int>> jobs(m);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        if (a > m) continue;
        jobs[m - a].push_back(b);

    }

    priority_queue<int> q;
    ll ans = 0;

    for (int i = m - 1; i >= 0; i--) {
        for(int b : jobs[i]) {
            q.push(b);
        }
        if(!q.empty()) {
            ans += q.top();
            q.pop();
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <set>
#include <cassert>
#include <algorithm>
using namespace std;

int N;
vector<int> a;
vector<vector<int> > loser;
int solve(int winner) {
  vector<int> tmp;
  for(int t: loser[winner]) {
    tmp.push_back(solve(t));
  }
  sort(tmp.rbegin(), tmp.rend());
  int ret = 0;
  for(int i = 0; i < tmp.size(); i++) {
    ret = max(ret, tmp[i] + i + 1);
  }
  return ret;
}
int main() {
  cin >> N;
  a = vector<int>(N);
  loser = vector<vector<int>>(N);
  for(int i = 1 ; i < N; i++) {
    cin >> a[i];
    a[i]--;
    loser[a[i]].push_back(i);
  }
  cout << solve(0) << endl;;
  return 0;
}

Measured memory_bytes: 15488
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#define INT_MAX 10000
using namespace std;

class dinic{
	public :
	void add_edge(int from,int to ,int cap){
	//	cout << from << " " << to << " "  << cap << endl;
		G[from].push_back((edge){to,cap,G[to].size()});
		G[to].push_back((edge){from,0,G[from].size()-1});
	}
	
	void add_edge_both(int from,int to ,int cap){
		add_edge(from,to,cap);
		add_edge(to,from,cap);
	}
	
	int max_flow(int s,int t){
		int flow=0;
		for(;;){
			bfs(s);
			if(level[t]<0) return flow;
			memset(iter,0,sizeof(iter));
			int f;
			while((f=dfs(s,t,DINIC_INF))>0){
				flow+=f;
			}
		}
	}
	private:
	
	struct edge{int to,cap,rev;};
	static const int DINIC_INF = INT_MAX;
	vector<edge> G[500];
	int level[500];
	int iter[500];
	
	void bfs(int s){
		memset(level,-1,sizeof(level));
		queue<int> que;
		level[s]=0;
		que.push(s);
		while(!que.empty()){
			int v=que.front();que.pop();
			for(int i=0;i< G[v].size(); i++){
				edge &e=G[v][i];
				if(e.cap>0 && level[e.to] <0){
					level[e.to]=level[v]+1;
					que.push(e.to);
				}
			}
		}
	}

	int dfs(int v,int t,int f){
		if(v==t) return f;
		for(int &i=iter[v];i<G[v].size();i++){
			edge &e= G[v][i];
			if(e.cap>0 && level[v]<level[e.to]){
				int d=dfs(e.to,t,min(f,e.cap));
				if(d>0){
					e.cap -=d;
					G[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}	
};


const int inf= 1 << 29;

int main(void){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		dinic D;
		int sum=0;
		int w,h;
		int r[20][20];
		cin >> w >> h;
		for(int j=0;j<h;j++){
			for(int k=0;k<w;k++){
				cin >> r[j][k];
				sum+=r[j][k];
			}
		}
		for(int j=0;j<h;j++){
			for(int k=0;k<w;k++){
				int v=w*j+k+2;
				bool odd=(j+k)%2;
				if(odd){
					D.add_edge(0,v,r[j][k]);
					D.add_edge(v,1,0);
					if(j-1>=0) // up
						D.add_edge(v,w*(j-1)+k+2,inf);
					if(k-1>=0) // left
						D.add_edge(v,w*j+k-1+2,inf);
					if(k+1<w)  // right
						D.add_edge(v,w*j+k+1+2,inf);
					if(j+1<h)  // down
						D.add_edge(v,w*(j+1)+k+2,inf);
				}else{
					D.add_edge(0,v,0);
					D.add_edge(v,1,r[j][k]);
					
				}
			}
		}
		int ans=sum-D.max_flow(0,1);
		cout << "Case " << i+1 << ": " << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1300
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int x,y,z,k;
	cin >> x >> y >> z >> k;

	vector<ll> a(x) , b(y) , c(z);

	rep(i,0,x) cin >> a[i];
	rep(i,0,y) cin >> b[i];
	rep(i,0,z) cin >> c[i];
	vector<ll> ab;

	rep(i,0,x){
		rep(j,0,y){
			ab.push_back(a[i]+b[j]);
		}
	}

	vsort(ab);
	reverse(ab.begin() , ab.end());

	vsort(c);
	reverse(c.begin() , c.end() );

	vector<ll> ans;
	rep(i,0, min( int(ab.size()) , k )){
		rep(j,0, min( int(c.size()) , k )){
			ans.push_back( ab[i] + c[j] );
		}
	}

	vsort(ans);
	reverse(ans.begin() , ans.end());

	rep(i,0,k) cout << ans[i] << endl;

	ret 0;
}

Measured memory_bytes: 42728
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}

int main() {
	string S;
	cin >> S;
	ll an=1;
	if (S.at(0) == S.at(1)&&S.at(0)=='R') {
		an = 2;
	}
	if (S.at(2) == S.at(1) && S.at(1) == 'R') {
		an = 2;
	}
	if (S.at(0) == S.at(1)&& S.at(0) == S.at(2) && S.at(1) == 'R') {
		an = 3;
	}
	if (S.at(0) == S.at(1) && S.at(0) == S.at(2) && S.at(1) == 'S') {
		an = 0;
	}

	cout << an << endl;
}

Measured memory_bytes: 3632
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s:chars,
    }

    let n = s.len();
    let first_half = &s[0..(n - 1) / 2];
    let second_half = &s[(n + 3) / 2 - 1..n];

    if first_half != second_half {
        println!("No");
        return;
    }

    let mut reversed = vec!['a'; (n - 1) / 2];
    reversed.copy_from_slice(first_half);
    reversed.reverse();

    if first_half != &reversed[..] {
        println!("No");
        return;
    }

    println!("Yes");
}


Measured memory_bytes: 4352
-module('Main').
-export([main/1]).

main(_) ->
    {ok, [A, B]} = io:fread("", "~d ~d"),
    case (A rem 2) + (B rem 2) of 
        2 -> io:format("Odd~n");
        _ -> io:format("Even~n")
    end,
    halt().

Measured memory_bytes: 21672
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	int n; cin >> n;
	while(n--){
		string str1; cin >> str1;
		int ans;
		bool isfirst = true;
		while(1){
			if(str1[1] !='[') break;

			string str2;
			int j=0, num[10000]={0};
			for(int i=0; str1[i] != '\0'; i++){
				if(str1[i] == ']') str2 += ']';
				else if(str1[i]=='[' && str1[i+1] =='[') str2 += '[';
				else if(isdigit(str1[i])){
					while(isdigit(str1[i])){
						num[j]*=10;
						num[j]+=str1[i]-'0';
						i++;
					}
					if(isfirst) num[j] = num[j]/2+1;
					j++;
					i++;
					if(str1[i] ==']'){
						sort(num, num+j);
						int tmp=0;
						for(int k=0; k<j/2+1; k++) tmp += num[k];
						for(int k=0; k<j; k++) num[k] = 0;
						for(int k=1000000; k>0; k/=10){
							if(tmp/k) str2 += (tmp/k % 10) +'0';
						}
						str2 += ']';
						j=0;
						ans = tmp;
					}
				}
			}
			str1 = str2;
			isfirst = false;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  double ans = 0;
  rep2(i, 1, n+1){
    double add = (double)1/n;
    int now = i;
    while(now < k){
      now *= 2;
      add /= 2;
    }
    ans += add;
  }
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <map>
#include <string>
#include <cmath>
#include <queue>
#include <ctime>
#include <set>

using namespace std;

typedef long long ll;
typedef long double ld;
#define int ll
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define pb push_back

const ll SIZE = 5 * 1e5 + 10, INF = 1e9 * 1e9, MOD = 1e9 + 7;

vector<vector<ll>> graph;
ll edge[705][705];
ll used[705];

ll n, m;
pair<ll, ll> cur;
ll cl[705];

void dfs(int v, int col) {
    cl[v] = col;

    if (col) {
        cur.first++;
    }
    else {
        cur.second++;
    }
    used[v] = 1;

    for (int i = 0; i < n; i++) {
        if (!used[i] && edge[v][i]) {
            dfs(i, (!col));
        }
        else if (used[i] && edge[v][i]) {
            if (i != v && cl[i] != (!col)) {
                cout << "-1";
                exit(0);
            }
        }
    }
}

signed main() {
    fastInp;

    cin >> n >> m;
    graph.resize(n);
    for (int i = 0; i < m; i++) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        edge[u][v] = 1;
        edge[v][u] = 1;
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            edge[i][j] = !edge[i][j];
        }
    }
    vector<pair<ll, ll>> sz;
    vector<ll> bc(n + 2), nw(n + 2);
    for (int i = 0; i < n; i++) {
        cur = { 0, 0 };
        if (!used[i]) {
            dfs(i, 0);
            sz.pb(cur);
        }
    }
    bc[0] = 1;
    for (auto cur : sz) {
        for (int i = 0; i <= n; i++) nw[i] = 0;
        for (int i = n; i >= 0; i--) {
            ll fst = i - cur.first, snd = i - cur.second;
            if (fst >= 0) {
                nw[i] = max(bc[fst], nw[i]);
            }
            if (snd >= 0) {
                nw[i] = max(bc[snd], nw[i]);
            }
        }
        bc = nw;
    }

    ll ans = INF;
    for (ll i = 0; i <= n; i++) {
        if (bc[i]) {
            ans = min(ans, ((i - 1) * i) / 2 + ((n - i - 1) * (n - i)) / 2);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 7440
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
using ll = long long;
//#define int ll
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
signed main(){
    char a,b;
    cin>>a>>b;
    if(a>b)cout<<">"<<endl;
    else if(a==b)cout<<"="<<endl;
    else cout<<"<"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,x,cnt=1,sum=0,arr[110];
  cin>>n>>x;
  for(int i=0; i<n;i++)
  {
    cin>>arr[i];
    sum = sum + arr[i];
    if(sum<=x)
    {
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}
  
  

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int w=sc.nextInt();
        int wt[]=new int[n];
        int val[]=new int[n];
        for(int i=0;i<n;i++){
        wt[i]=sc.nextInt();
        val[i]=sc.nextInt();
        }
        long dp[][]=new long[n+1][w+1];
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=w;j++)
            {
                if(j>=wt[i-1])
                dp[i][j]=Math.max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
                else
                dp[i][j]=dp[i-1][j];
            }
        } 
    System.out.println(dp[n][w]);
}
}

Measured memory_bytes: 126032
#include <stdio.h>

int main(void) {
	int students[31] = {0};
	int i, n;
	for(i = 0; i < 28; i++ ) {
		scanf("%d",&n);
		students[n]++;
	}
	for(i = 1; i < 31; i++ ) {
		if(students[i] == 0) { 
		printf("%d\n",i);
		}
	}
	return 0;
}

Measured memory_bytes: 596