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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/27  Problem: 064_arc_b / Link: https://abc048.contest.atcoder.jp/tasks/arc064_b?lang=en  ----- */
/* ------問題------

長さ 3 以上の文字列 s があります。 s の中に同一の文字が隣り合う箇所はありません。
高橋君と青木君がゲームで勝負します。 二人は交互に次の操作を行います。 高橋君が先手です。
s から両端以外の文字をひとつ取り除く。 ただし、その文字を取り除くことで、s の中に同一の文字が隣り合う箇所ができる場合、その文字を取り除くことはできない。
先に操作を行えなくなった人が負けです。 二人が最適に行動したとき、どちらが勝つかを判定してください。

-----問題ここまで----- */
/* -----解説等-----

終了条件は端が一緒で文字列が奇数のとき
端が異なって文字列が偶数のとき
手によれず勝てた

----解説ここまで---- */

LL N;

LL ans = 0LL;

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	string s;
	cin >> s;
	cout << ((s.front() == s.back())^(SZ(s)%2)?"First":"Second") << "\n";

	return 0;
}


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

int main()
{
int N,K;cin >> N >> K;
int ans=0;
vector<int> l(N);
for(int i=0;i<N;i++){cin >> l.at(i);}
sort(l.begin(),l.end());
for(int i=0;i<K;i++){ans+=l.at(N-i-1);}
cout << ans;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		int x=sc.nextInt();
		int p1,p2,p3;
		int cnt=0;
		while(n!=0 || x!=0){
			for(p1=1;p1<=n;p1++){
				for(p2=(p1+1);p2<=n;p2++){
					if((p1+p2)>=x ) break;
					for(p3=(p2+1);p3<=n;p3++){
						if((p1+p2+p3)>x){
							break;
						}else if((p1+p2+p3)==x){
							cnt++;
						}
					}//for	
				}//for
			}//for
			System.out.println(cnt);
			cnt=0;
			n=sc.nextInt();
			x=sc.nextInt();
		}//while
	}
}

Measured memory_bytes: 19732
import sys
input = sys.stdin.buffer.readline
n, c = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(c)]
C = [list(map(int, input().split())) for _ in range(n)]
A = [[0]*c for _ in range(3)]
for i in range(n):
  for j in range(n):
    x = C[i][j] - 1
    r = (i+j)%3
    for y in range(c):
      A[r][y] += D[x][y]
ans = float("inf")
for i in range(c):
  for j in range(c):
    for k in range(c):
      if i == j or j == k or k == i:
        continue
      temp = A[0][i] + A[1][j] + A[2][k]
      ans = min(ans, temp)
print(ans)

Measured memory_bytes: 44764
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
a, b = [], []
for i in range(n):
    if i % 2 == 0:
        a.append(v[i])
    else:
        b.append(v[i])

c = list(Counter(a).items())
d = list(Counter(b).items())

c.sort(key=lambda x: x[1], reverse = True)
d.sort(key=lambda x: x[1], reverse=True)

if c[0] != d[0]:
    print(n - c[0][1] - d[0][1])
else:
    d1 = c[0][1]
    d2 = d[0][1]
    if len(d) > 1:
        d1 += d[1][1]
    if len(c) > 1:
        d2 += c[1][1]
    print(n - max(d1, d2))


Measured memory_bytes: 21084
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <bitset>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
bool pairCompare(const P& firstElof,const P& secondElof){
    return firstElof.first<secondElof.first;
}
//10^12<2^41

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n,m,x,y;cin>>n>>m>>x>>y;
    ll a[n],b[m];
    rep(i,0,n)cin>>a[i];
    rep(i,0,m)cin>>b[i];
    sort(a,a+n);
    sort(b,b+m);
    if(b[0]-a[n-1]<0){
        cout<<"War"<<endl;
        return 0;
    }
    if(b[0]-a[n-1]>y-x){
        rep(i,x+1,y+1){
            if(i>b[0])break;
            if(i>a[n-1]&&i<=b[0]){
                cout<<"No War"<<endl;
                return 0;
            }
        }
    }else{
        rep(i,a[n-1]+1,b[0]+1){
            if(i>y)break;
            if(i>x&&i<=y){
                cout<<"No War"<<endl;
                return 0;
            }
        }
    }
    cout<<"War"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n;
  cin >> n;
  int k[4];
  rep(i,4)k[i]=0;
  rep(i,n){
    string s;
    cin >> s;
    if(s=="AC")k[0]++;
    else if(s=="TLE")k[2]++;
    else if(s=="WA")k[1]++;
    else k[3]++;
  }
  cout << "AC" << " " << 'x' << " " << k[0] << endl;
  cout << "WA" << " " << 'x' << " " << k[1] << endl;
  cout << "TLE" << " " << 'x' << " " << k[2] << endl;
  cout << "RE" << " " << 'x' << " " << k[3] << endl;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

using graph=vector<vector<int>>;

int n;
graph T;

int sz[200000];
mint res[200000];

void dfs(int u,int p){
	sz[u]=1;

	vector<int> a;
	for(int v:T[u]) if(v!=p) {
		dfs(v,u);
		sz[u]+=sz[v];
		a.emplace_back(sz[v]);
	}
	if(sz[u]<n) a.emplace_back(n-sz[u]);

	res[u]=pow(mint(2),n-1)-1;
	for(int x:a) res[u]-=pow(mint(2),x)-1;
}

int main(){
	scanf("%d",&n);
	T.resize(n);
	rep(i,n-1){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		T[u].emplace_back(v);
		T[v].emplace_back(u);
	}

	dfs(0,-1);

	cout<<accumulate(res,res+n,mint(0))/pow(mint(2),n)<<'\n';

	return 0;
}


Measured memory_bytes: 28544
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if (((a % 3) == 0) || ((b % 3) == 0) || (((a + b) % 3) == 0)) {
      System.out.println("Possible");
    } else {
      System.out.println("Impossible");
    }

  }
}

Measured memory_bytes: 35536
import java.util.Scanner;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[][] a = new int[2][N];
        for(int i = 0;i < 2;i++){
            for(int j = 0; j < N;j++){
                a[i][j] = sc.nextInt();
            }
        }
        int[] sum = new int[N];
        for(int i = 0;i < N;i++){
            int l = 0;
            while(l <= i){
                sum[i] += a[0][l];
                l++;
            }
            for(int j = i; j < N;j++){
                sum[i] += a[1][j];
            }
        }
        Arrays.sort(sum);
        System.out.println(sum[N-1]);
    }
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    string s,s2;
    cin>>s>>s2;
    bool m[52]={0};
    int l=0;
    for(int i=0;i<n;++i){
        if(s[i]==s[i+1]){
            m[l]=1;
            i++;
        }
        else{
            m[l]=0;
        }
        l++;
    }
    long long ans;
    for(int i=0;i<l;++i){
        if(i==0){
            if(m[i])ans=6;
            else ans=3;
        }else{
            if(m[i-1]==1 && m[i]==0)continue;
            if(m[i-1]==1 && m[i]==1)ans*=3;
            else ans*=2;
        }
        ans%=1000000007;
    }
    cout<<ans<<endl;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	string s;cin>>s;
	ll k;cin>>k;
	if(k==1){
		cout<<s[0]<<endl;
		return 0;
	}
	else{
		int cnt=0;
		rep(i,s.size()){
			if(s[i]=='1'){
				cnt++;
			}
			else{
				break;
			}
		}
		if(k<=cnt){
			cout<<1<<endl;
		}
		else{
			rep(i,s.size()){
				if(s[i]!='1'){
					cout<<s[i]<<endl;
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i32 = input();
    let op: String = input();
    let b: i32 = input();
    println!("{}", if op == "+" { a + b } else { a - b });
}


Measured memory_bytes: 4352
#069_C
n = int(input())
a = list(map(int, input().split()))

mod1, mod2, mod4 = [0] * 3
for ai in a:
    if ai % 4 == 0:
        mod4 += 1
    elif ai % 2 == 0:
        mod2 +=1
    else:
        mod1 +=1
        
if mod2 == 0:
    print('No' if mod1 > mod4 + 1 else 'Yes')
else:
    print('No' if mod1 > mod4 else 'Yes')

Measured memory_bytes: 14252
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;
 
 
int main()
{
	IOS;
	string str;
	cin>>str;
	int i=0;
	int j=str.size()-1;
	int ans=0;
	while(i<=j){
		ans+=(str[i]!=str[j]);
		i++;
		j--;
	}
	cout<<ans<<ln;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 10000;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int, PP> PPP;
struct edge { int to; int cost; };

signed main() {
	int n, k; cin >> n >> k;
	cout << n - k + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;

int main() 
{ 
    FIO
    ll n;
    cin >> n;

    ll n1 = n%500;
    ll ans = 1000*(n/500);

    ans += 5*(n1/5); 

    cout << ans << endl;
    return 0; 
} 


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; ll k;
	cin>>n>>k;
	vector<int> cnt(40, 0);
	for(int i = 0; i < n; i++){
		ll x; cin>>x;
		for(int j = 0; j < 40; j++){
			if((x>>j)&1)cnt[j]++;
		}
	}
	ll ans = 0;
	ll cur = 0;
	for(int i = 39; i >= 0; i--){
		if((k>>i)&1){
			ll tmp = cur + cnt[i]*(1LL<<i);
			for(int j = i - 1; j >= 0; j--){
				tmp += max(cnt[j], n - cnt[j])*(1LL<<j);
			}
			ans = max(ans, tmp);
			cur += (n - cnt[i])*(1LL<<i);
		}else{
			cur += cnt[i]*(1LL<<i);
		}
	}
	ans = max(ans, cur);
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())
#define DEBUG

using namespace std;
typedef vector<long> VI;
typedef vector<VI> VVI;
typedef pair<long,long> pr;
typedef map<double,pr> mp;

int N;
int total = 0;
int l,r;
int main(void){
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> l >> r;
        total += r - l + 1;
    }
    cout << total;
    return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <bits/stdc++.h>
 
#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}
 
using namespace std;                                                                                  
 
mt19937 mrand(random_device{}()); 
const ll mod = 1e9 + 7;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
 
typedef pair < int , int > pii ;                                            
typedef pair < long long  , long long > pll ;

const int N = 3e5 + 123;

int n, m, k;

int a[N];
int cnt[300];
string s;
vector < int > gr[300];
int t[N];
void upd(int x){
	for(; x < 3e5; x+= x & -x)
		t[x]++;
}
int get(int r){
	int res = 0;
	for(; r > 0; r -= r & -r)
		res += t[r];
	return res;
}
main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>s;
	n = sz(s);
	s = '$' + s;
	for(int i = 1; i <= n;i++){
		cnt[s[i]]^=1;
        gr[s[i]].pb(i);
	}
	int x = 0 , id = -1;
	for(int i = 'a'; i <= 'z';i++)
		if(cnt[i]){
			x++;
			id = gr[i][sz(gr[i])/2];
		}

	if(x > 1)
		ret(-1);	
	int ans = 0;
	
	if(id != -1){
	//	ans += abs(id - (n / 2 + 1));
	    for(int i = 'a'; i <= 'z';i++)		
	    	for(int j = 0; j < sz(gr[i]) / 2;j++){
    			if(id < gr[i][j])ans++;
    			if(gr[i][sz(gr[i]) - 1 - j] < id)
	    				ans++;
	    	}
	}
	vector <  pii  > vc;
    for(int i = 'a'; i <= 'z';i++){
		for(int l = 0, r = sz(gr[i]) - 1; l < r; l++, r--){
			vc.pb({gr[i][l],gr[i][r]});
		}    		
    }   

    sort(all(vc));
	for(int i = 0 ; i < sz(vc); i++){
		ans += get(vc[i].se) + get(vc[i].fi);
		//ababa
		upd(vc[i].se);
	}
	//ababcc
	//ababcc
    ret(ans);
    
}
 


Measured memory_bytes: 8648
#include<stdio.h>

int main(void)
{
    int n,m;
    scanf("%d%d",&n,&m);
    while((2>n||n>100)||(2>m||m>100))
    {
        scanf("%d%d",&n,&m);
    }
    printf("%d\n",n*m-n-m+1);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main(){
  int i,j,cnt=0;
  int n;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  ll b[n];
  b[0]=a[0];
  cnt=1;
  for(i=1;i<n;i++){
    if(a[i-1]!=a[i])b[cnt++]=a[i];
  }
  if(cnt>3){
    cout<<"No";
    return 0;
  }
  int c[3]={0};
  for(i=0;i<n;i++){
    if(a[i]==b[0])c[0]++;
    if(cnt>=2){
      if(a[i]==b[1])c[1]++;
    }
    if(cnt==3){
      if(a[i]==b[2])c[2]++;
    }
  }
  if(cnt==1 && b[0]==0)cout<<"Yes";
  else if(cnt==2 && 2*c[0]==c[1] && b[0]==0)cout<<"Yes";
  else if(cnt==3 && c[0]==c[1] && c[1]==c[2] && (b[0]^b[1])==b[2])cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;

int main() {
  char str[222];
  cin >> str;

  int n = strlen(str);
  for (int i = n - 2; i; i -=2) {
    if (strncmp(str, str+i/2, i/2) == 0) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;

const ll NMAX = 2010;
using namespace std;

ll dp[NMAX+3][NMAX+3];

int main(){
    ll n;
    cin >> n;
    vector<pair<ll, int> > a(n+1);
    for(int i = 0; i < n; i++){
        ll v;
        cin >> v;
        a[i] = make_pair(v,i+1);
    }
    sort(a.begin(), a.end(), std::greater<pair<ll, int> >());  

    for(ll i = 0; i <= NMAX; i++){
        for(ll j = 0; j <= NMAX; j++){
            dp[i][j] = 0;
        }
    }
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= i; j++){
            int l = j;
            int r = i-j;
            dp[l+1][r] = max(dp[l+1][r], dp[l][r]+a[i].first*abs(a[i].second - (l+1)));
            dp[l][r+1] = max(dp[l][r+1], dp[l][r]+a[i].first*abs(a[i].second - (n-r)));
        }
    }
    ll ans = 0;
    for(int i = 0; i <= n; i++){
        ans = max(ans, dp[i][n-i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 35292
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
using namespace std;

long long gcd(long long a, long long b) {
  long long _max = a > b ? a : b;
  long long _min = a > b ? b : a;
  if (!(_max%_min)) return _min;
  else return gcd(_min, _max%_min);
}
 
long long lcm(long long a, long long b) {
  return a/gcd(a,b)*b;
}


void solve(long long N, std::vector<long long> A){
    auto ans = LONG_LONG_MAX;
    for(auto a=-100ll; a<=100ll; a++){
        auto acc=0ll;
        for(auto b: A)acc+=(b-a)*(b-a);
        ans = min(ans, acc);
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
    int A, B;
    cin >> A >> B;

    int sub = abs(A - B);

    if (sub % 2 == 0) {
        int64_t ans = min(A, B) + (sub / 2); 
        cout << ans << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, string> PS;

int main() {
  ll n;
  cin >> n;
  vector<ll> v;
  map<int, int> m;
  REP(i, n) {
    ll p;
    cin >> p;
    v.pb(p);
    m[p]++;
  }

  sort(v.begin(), v.end(), greater<ll>());
  ll ans = 0;
  for (auto &a : v) {
    for (ll i = 32; i >= 0; i--) {
      if (a > (1LL << i)) {
        // cout << a << " " << (1LL << i) << endl;
        break;
      }
      ll ma = m[a];
      if (ma == 0) {
        break;
      }
      ll mi = m[(1LL << i) - a];
      if ((1LL << i) - a == a) {
        if (ma > 1) {
          mi -= 2;
          ans++;
        }
      } else if (mi > 0 && ma > 0) {
        mi--;
        ans++;
        ma--;
      }

      m[a] = ma;
      m[(1LL << i) - a] = mi;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 49392
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
bool compare(pair<int,int> a,pair<int,int> b){
    return a.first>b.first;}
int main(){
int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    if((int)s[k-1]>90){
        s[k-1]=s[k-1]-32;
    }
    else{
        s[k-1]=s[k-1]+32;
    }
    cout<<s;
    
    return 0;
}
     

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

string s;

void ans(int a, int64_t b) {  
  //cout << "a:" << a << " b:" << b << " num:" << int64_t(pow(26,a-1)) << endl;
  if(a==1) s.push_back(96+b);
  
  else {
    int64_t num = pow(26,a-1);
    if(b%num!=0) ans(a-1, b%num);
    else ans(a-1, num);
    if(b/num!=26 && b%num==0) s.push_back(96+b/num);
    else if(b/num!=26) s.push_back(97+b/num);
    else s.push_back('z');
  }
}

int main() {
  int64_t n;
  cin >> n;
  
  int digit = 0;
  int64_t sum = 0;
  for(int i=1;;i++) {
    int64_t num = pow(26,i);
    if((n-sum)/num==0) {
      if((n-sum)%num==0) {
        digit = i-1;
        sum -= pow(26,i-1);
      }
      else digit = i;
    }
    if(digit!=0) break;
    sum += num;
  }
  
  ans(digit, n-sum);
  reverse(s.begin(), s.end());
  
  cout << s << endl;
  return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

void solve() {

}

int main() {
  int N,K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  REP(i,K,N) {
    if( A[i-K] < A[i] ) puts("Yes");
    else puts("No");
  }

  return 0;
}


Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
long long dp[405][405];
long long a[405],sum[405];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
//	for(int i=0;i<n;i++) dp[i][i]=a[i];
	sum[0]=a[0];
	for(int i=1;i<n;i++) sum[i]=sum[i-1]+a[i];
	for(int len=1;len<n;len++){
		for(int l=0;l+len<n;l++){
			int r=l+len;
			dp[l][r]=1e15;
			for(int k=l;k<r;k++){
				dp[l][r]=min(dp[l][r],dp[l][k]+dp[k+1][r]+sum[r]-((l)?sum[l-1]:0));
			}
		//	cout<<l<<" "<<r<<" "<<dp[l][r]<<endl;
		}
	}
	cout<<dp[0][n-1];
	return 0;
}

Measured memory_bytes: 1536
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    long k = Long.parseLong(sc.next());
    char[] ch = new char[str.length()];
    for(int i = 0; i < str.length(); i++) ch[i] = str.charAt(i);
    int count = 0;
    char ans = str.charAt(0);
    while(count < k) {
      if(ch[count] == '1') {
        count++;
      } else {
        ans = ch[count];
        break;
      }
    }
    System.out.println(ans);
  }
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
//const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

LL N;

int main()
{
    cin >> N;
    LL cnt = 0;

    _for(i,1,N){
        int k = N/i;
        if(N % i == 0){
            k--;
        }
        cnt += k;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  string S;
  cin >> S;
  int len = S.size();
  int hitomozi = 1;
  int kotae = 1;
  int i =1;
  while (i < len){
    if (hitomozi){
      if (S[i-1] == S[i]){
	i += 2;
	hitomozi = 0;
	kotae += 1;
      } else {
	i +=1;
	hitomozi = 1;
	kotae += 1;
      }
    } else {
      i += 1;
      hitomozi = 1;
      kotae += 1;
    }
    if (i == len-2){
      break;
    }
  }
  if (i == len) {
    cout << kotae << endl;
  } else {
    if (hitomozi){
      if (S[i-1] == S[i]){
	kotae += 1;
	cout << kotae << endl;
      } else {
	if (S[len-2] == S[len-1]){
	  cout << kotae+1 << endl;
	} else {
	  cout << kotae+2 << endl;
	}
      }
    } else {
      if (S[len-2]==S[len-1]) {
	cout << kotae +1 << endl;
      } else {
	cout <<kotae+2 <<endl;
      }
    }
  }
  return 0;
}


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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)

typedef long long ll;
typedef pair<int, int> point;

int main(){
    string a, b;
    cin >> a >> b;
    string kopija = a;

    for(int i = sz(b) - 1; i >= 0; --i){
        if(a.substr(0, sz(b)) == b){
            cout << "Yes";
            return 0;
        }
        a = kopija[i] + a;
    }
    if(a.substr(0, sz(b)) == b){
            cout << "Yes";
            return 0;
    }
    cout << "No";
}


Measured memory_bytes: 256
N=int(input())
L=100
x=[0 for i in range(N)]
y=[0 for i in range(N)]
h=[0 for i in range(N)]
p=(-1,-1,-1)
for i in range(N):
    x[i],y[i],h[i]=map(int,input().split())
for i in range(N):
    if h[i]!=0:
        p=(x[i],y[i],h[i])
        break
if p[2]==-1:
    print("Baka")
    exit()
for Cx in range(L+1):
    for Cy in range(L+1):
        H=p[2]+abs(Cx-p[0])+abs(Cy-p[1])
        flag=1
        for i in range(N):
            hd=max([H-abs(x[i]-Cx)-abs(y[i]-Cy),0])
            if h[i]!=hd:
                flag=0
                break
        if flag==1:
            print(Cx,Cy,H)
            exit()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <limits>

using lint = long long;
constexpr lint INF = std::numeric_limits<lint>::max();

int main() {
    int n;
    lint m;
    std::cin >> n >> m;

    std::vector<lint> as(n);
    for (auto& a : as) std::cin >> a;
    std::sort(as.begin(), as.end());

    // Sを二分探索
    lint ok = 0, ng = INF;
    while (ng - ok > 1) {
        lint mid = (ok + ng) / 2;

        lint cnt = 0;
        for (int i = 0; i < n; ++i) {
            // S-ai以下の要素の個数
            int r = as.end() - std::lower_bound(as.begin(), as.end(), mid - as[i]);
            cnt += r;
        }

        (cnt < m ? ng : ok) = mid;
    }

    // 累積和
    std::vector<lint> ss(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        ss[i + 1] = ss[i] + as[i];
    }

    lint ans = 0;
    for (int i = 0; i < n; ++i) {
        int r = as.end() - std::lower_bound(as.begin(), as.end(), ok - as[i]);
        m -= r;
        ans += ss[n] - ss[n - r] + as[i] * r;
        // 後ろr個の和 + aiをr個分
    }
    ans += ok * m;  // 余剰分を引く

    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
using namespace std;
int main(void){
    long long a,b,c;
    cin >> a >> b >> c;
    long long x = c-a-b;
    if(x < 0){
        cout << "No";
        return 0;
    }
    if(4*a*b < x*x) cout << "Yes";
    else cout << "No";
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

string s;
void solve(){
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(i%2==0)cout << s[i];
  }
  cout << endl;

}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int i=0;
  int Ans=0;
  while(7*i<=N){
    if((N-7*i)%4==0){
      Ans=1;
    }
    i++;
  }
  if(Ans==1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
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 m = sc.nextInt();

        Map<Integer, Integer>[] graph = new HashMap[n + 1];

        for(int i = 1; i <= n; i++)
            graph[i] = new HashMap<>();

        Set<Integer> nodes = new HashSet<>();
        
        for(int i = 0; i < m; i++) {
            int from = sc.nextInt();
            int to = sc.nextInt();
            int w = sc.nextInt();
            nodes.add(from);
          nodes.add(to);
            graph[from].put(to, w);
            graph[to].put(from, -w);
        }

        boolean[] visited = new boolean[n + 1];
        long[] weights = new long[n + 1];

        for(int i : nodes) {
            if(visited[i]) continue;
             
            if(!dfs(graph, visited, weights, i, 0)) {
                System.out.println("No");
                return;
            }
            
        }
        
        System.out.println("Yes");
    }

    private static boolean dfs(Map<Integer, Integer>[] graph, boolean[] visited, long[] weights, int node, int prevWeight) {
       // for(long ww : weights)
        //        System.out.print("weights:" +  ww + "," );
        //System.out.println("node:" +  node + ", prevWeight:" + prevWeight);
        if(visited[node]) {
            return weights[node] == prevWeight;
        }

        weights[node] = prevWeight;
        visited[node] = true;

        for(Map.Entry<Integer, Integer> entry : graph[node].entrySet()) {
            
            int to = entry.getKey();
            int w = entry.getValue();
//System.out.println("to:" +  to + "," );
            if(!dfs(graph, visited, weights, to, w + prevWeight))
                return false;
        }
        return true;
    }
}


Measured memory_bytes: 200684
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int b = 1;
        int count = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            if (b == a[b - 1]) {
                System.out.println(-1);
                System.exit(0);
            }
            b = a[b - 1];
            count++;
            if (b == 2) {
                System.out.println(count);
                System.exit(0);
            }
        }
        System.out.println(-1);
    }
}


Measured memory_bytes: 50740
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int main() { IO;
  int n, m;
  cin >> n >> m;

  vector<int> foods(m + 1);
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;

    for (int j = 0; j < k; ++j) {
      int a;
      cin >> a;
      foods[a]++;
    }
  }

  int ans = count(foods.begin(), foods.end(), n);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

template <class T>
struct BIT {
	int n;
	vector<T> x;
	BIT(int n_ = 0) : n(n_), x(n + 1, 0) {}
	int size() const { return n; }
	T sum(int r) const {
		T S = 0;
		for(r = r - 1; r >= 0; r = (r & (r + 1)) - 1) S += x[r];
		return S;
	}
	T sum(int l, int r) const { return sum(r) - sum(l); }
	void add(int k, const T &a) {
		for(; k < n; k |= k + 1) x[k] += a;
	}
	void set(int k, const T &a) { add(k, a - sum(k, k + 1)); }
	int lower_bound(T x) {
		int ng = -1, ok = n - 1;
		while(abs(ng - ok) > 1) {
			int mid = (ng + ok) / 2;
			if(sum(0, mid + 1) >= x) ok = mid;
			else ng = mid;
		}
		return ok;
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S, T;
	cin >> S >> T;

	int N = S.size(), M = T.size();
	BIT<ll> sa(N), sb(N), ta(M), tb(M);

	for(int i = 0; i < N; i++) {
		if(S[i] == 'A') sa.add(i, 1);
		else sb.add(i, 1);
	}
	for(int i = 0; i < M; i++) {
		if(T[i] == 'A') ta.add(i, 1);
		else tb.add(i, 1);
	}

	int Q;
	cin >> Q;
	while(Q--) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--, c--;
		int sasum = sa.sum(a, b);
		int sbsum = sb.sum(a, b);
		int tasum = ta.sum(c, d);
		int tbsum = tb.sum(c, d);
		if((sasum + sbsum * 2) % 3 == (tasum + tbsum * 2) % 3 ||
			(sasum * 2 + sbsum) % 3 == (tasum * 2 + tbsum) % 3) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 4048
#include<iostream>

using namespace std;

int main()

{

	int n,a[1005],b[1005],t=0;

	cin>>n;

	for(int i=1;i<=n;i++)

	{

		cin>>a[i]>>b[i];

		t=t+b[i]-a[i]+1;

	}

	cout<<t<<endl;

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define mem(a,b) memset(a,b,sizeof(a))
#define IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+5;
int tot,head[maxn];
struct E{
	int to,next;
}edge[maxn<<1];
void add(int u,int v){
	edge[tot].to=v;
	edge[tot].next=head[u];
	head[u]=tot++;
}
int n,m,ans[maxn],cnt=0;
void bfs(int x){
	ans[x]=1;cnt+=1;
	queue<int> q;q.push(x);
	while(!q.empty()){
		int now=q.front();q.pop();
		for(int i=head[now];i!=-1;i=edge[i].next){
			int v=edge[i].to;
			if(!ans[v]){
				cnt+=1;
				ans[v]=now;
				q.push(v);
			}
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);mem(head,-1);
	while(m--){
		int u,v;scanf("%d%d",&u,&v);
		add(u,v);add(v,u);
	}
	bfs(1);
	if(cnt!=n) {puts("No");return 0;}
	puts("Yes");
	for(int i=2;i<=n;i++){
		cout<<ans[i]<<endl;
	}
}


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

int minCost(int *arr, int n,int k, int *dp){
    if(n==1) return 0;
    if(k>=n) k=n-1;
    
    if(dp[n]!=-1) return dp[n];
    
    int minC=INT_MAX;
    for(int i=1;i<=k;i++){
        minC=min(minC,abs(arr[n]-arr[n-i]) + minCost(arr,n-i,k,dp));
        
    }
    dp[n]= minC;
    return dp[n];
}

int main(){
	int n,k;
  	cin>>n>>k;
  	int *arr=new int[n+1];
    for(int i=1;i<=n;i++){
    	int h;
      	cin>>h;
      	arr[i]=h;
    }
    
    int *dp=new int[n+1];
    memset(dp,-1,sizeof(dp[0])*(n+1));
    
    cout<< minCost(arr,n,k,dp)<<endl;
    return 0;
}

Measured memory_bytes: 10368
import java.util.*;

public class Main {
	int N;
	long[] A;
	long result;

	Main() {
		Scanner in = new Scanner(System.in);
		N = Integer.parseInt(in.nextLine());
		A = new long[N];
		String[] tokens = in.nextLine().split(" ");
		for (int i = 0; i < N; ++i) {
			A[i] = Long.parseLong(tokens[i]);
		}
		in.close();
	}

	void calc() {
		result = gcd(A[0], A[1]);
		for (int i = 2; i < N; ++i) {
			result = gcd(A[i], result);
		}
	}

	long gcd(long large, long small) {
		if (small > large) {
			return gcd(small, large);
		}
		long mod = large % small;
		if (mod == 0) {
			return small;
		}
		return gcd(small, mod);
	}

	public static void main(String[] args) {
		Main ins = new Main();
		ins.calc();
		System.out.println(ins.result);
	}

}

Measured memory_bytes: 50316
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
class Edge{
    public:
    int to;
    ll w;
};

ll n;
vector<vector<Edge>> g;
vector<int> visited;
vector<int> color;

void dfs(int now){
    visited[now] = 1;

    for(int i = 0; i < g[now].size(); i++){
        Edge nexte = g[now][i];
        if(visited[nexte.to] == 1) continue;

        if(nexte.w % 2 == 0){
            if(color[now] == 1){
                color[nexte.to] = 1;
            } else {
                color[nexte.to] = 0;
            }
        } else {
            if(color[now] == 1){
                color[nexte.to] = 0;
            } else {
                color[nexte.to] = 1;
            }
        }

        dfs(nexte.to);
    }
}

int main(void){
    cin >> n;
    g.resize(n);
    visited.resize(n);
    color.resize(n);

    for(ll i = 0; i < n - 1; i++){
        int u, v;
        ll w;
        cin >> u >> v >> w;
        u--;
        v--;

        Edge e;
        e.to = v;
        e.w = w;
        g[u].push_back(e);

        e.to = u;
        g[v].push_back(e);
    }

    color[0] = 0;

    dfs(0);

    for(int i = 0; i < n; i++){
        cout << color[i] << endl;
    }


}

Measured memory_bytes: 9216
"""
<<全探索問題//ABC079C>>

1. itertoolsを用いた方法
2. bit全探索を用いた方法
"""

#1. itertoolsを用いた方法
import itertools
A,B,C,D=input()
for i in itertools.product(['+','-'],repeat=3):
    formula=''
    formula=A+i[0]+B+i[1]+C+i[2]+D
    if eval(formula)==7:
        print(formula+'=7')
        break




Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < ((int)(b)); ++i)
#define rrep(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define sz(c) ((int)c.size())
#define all(c) c.begin(), c.end()

int gcd(int a, int b) {
    if (a == 0) return b;
    return gcd(b % a, a);
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

signed main() {
    int N, M;
    cin >> N >> M;
    string S, T;
    cin >> S >> T;
    
    int L = lcm(N, M);
    for (int i = 0; i < N; ++i) {
        if (i * M % N == 0) {
            int j = i * M / N;
            if (S[i] != T[j]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    for (int i = 0; i < M; ++i) {
        if (i * N % M == 0) {
            int j = i * N / M;
            if (S[j] != T[i]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << L << endl;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long
#define R(i,a,n) for(int i=a;i<n;i++)
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef pair<P,int>Pi;
#define fi first
#define se second
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
int ddx[]={0,1,1,1,0,-1,-1,-1};
int ddy[]={-1,-1,0,1,1,1,0,-1};
#define pb push_back

int n,a[100009],b[100009],k;

//int dp[100009][4];
//int used[100009],i1=0,i2=0,x=0,l,r;
int sol1(){
	int ans=0;
	priority_queue<Pi>v1;
	priority_queue<Pi,vector<Pi>,greater<Pi> >v2;
	for(int i=0;i<n;i++){
		v1.push(Pi(P(a[i],-b[i]),i));
		v2.push(Pi(P(b[i],-a[i]),i));
	}
	int used[100009]={},i1=0,i2=0,x=0,l,r;
	for(int i=0;i<n;i++){
		int Y;
		if(i%2==0){
			while(1){
				Pi T=v1.top();v1.pop();
				if(used[T.se])continue;
				Y=T.first.first;
				l=T.fi.fi;
				r=T.fi.se*(-1);
				used[T.second]=1;
				break;
			}
		}
		else{
			while(1){
				Pi T=v2.top();v2.pop();
				if(used[T.se])continue;
				Y=T.first.first;
				r=T.fi.fi;
				l=T.fi.se*(-1);
				used[T.second]=1;
				break;
			}
		}
		if(!(l<=x&&x<=r)){
			ans+=abs(x-Y);
			x=Y;
		}
	}
	ans+=abs(x);
	return ans;
}

int sol2(){
	int ans=0;
	priority_queue<Pi>v1;
	priority_queue<Pi,vector<Pi>,greater<Pi> >v2;
	for(int i=0;i<n;i++){
		v1.push(Pi(P(a[i],-b[i]),i));
		v2.push(Pi(P(b[i],-a[i]),i));
	}
	//return 0;
	int used[100009]={},i1=0,i2=0,x=0,l,r;
	for(int i=0;i<n;i++){//cout<<n<<endl;
		int Y;
		if(i%2==1){
			while(1){
				Pi T=v1.top();v1.pop();
				//cout<<T.second<<' '<<i<<endl;
				if(used[T.se])continue;
				Y=T.first.first;
				l=T.fi.fi;
				r=T.fi.se*(-1);
				used[T.second]=1;
				break;
			}
		}
		else{
			while(1){
				Pi T=v2.top();v2.pop();
				//cout<<T.second<<' '<<i<<endl;
				if(used[T.se])continue;
				Y=T.first.first;
				r=T.fi.fi;
				l=T.fi.se*(-1);
				used[T.second]=1;
				break;
			}
		}
		//cout<<i<<endl;
		if(!(l<=x&&x<=r)){
			ans+=abs(x-Y);
			x=Y;
		}
		//cout<<n<<endl;
	}
	//cout<<1<<endl;
	ans+=abs(x);
	return ans;
}
signed main(){
	cin>>n;
	r(i,n)cin>>a[i]>>b[i];
	//cout<<sol1()<<endl;
	//cout<<sol2()<<endl;
	cout<<max(sol1(),sol2())<<endl;
}

Measured memory_bytes: 10740
program main;
var 
    ans : QWord;
    a, i : integer;
    ar : array[1..100000] of QWord;
begin
    readln(a);
    ans := 1;
    for i := 1 to a do 
        begin 
            read(ar[i]);    
            if ( ar[i] = 0 ) then 
                begin 
                    writeln('0');
                    exit;
                end;
        end;
    for i := 1 to a do 
        begin
            if ans > 1000000000000000000 div ar[i] then 
                    begin
                        writeln('-1');
                        exit;
                    end;
            ans := ans * ar[i];
        end;
        
    writeln(ans);
end.

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

int main() {
  int N, a, x, y;
  cin >> N;
  a = 10000000;

  // ここにプログラムを追記
  for (int i = 0; i < N; i++) {
    y = 0;
    cin >> x;
    while (x % 2 == 0) {
      y++;
      x /= 2;
    }
    
    if (a > y) {
      a = y;
    }
    
    if (a == 0) {
      cout << 0 << endl;
      break;
    }
    
    if (N == i + 1) {
      cout << a << endl;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct Node{
    int key;
    Node *r,*l,*p;
};
Node *root,*NIL;
void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = (Node*)malloc(sizeof(Node));
    z->key = k;
    z->l = NIL;
    z->r = NIL;
    while(x != NIL) {
        y = x;
        if(z->key < x->key) x = x->l;
        else x = x->r;
    }
    z->p = y;
    if(y == NIL) root = z;
    else {
        if(z->key < y->key) y->l = z;
        else y->r = z;
    } 
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->l);
    printf(" %d",u->key);
    inorder(u->r);
}
void preorder(Node *u) {
    if(u == NIL) return ;
    printf(" %d",u->key);
    preorder(u->l);
    preorder(u->r);
}

int main() {
    int n,x;
    string com;
    scanf("%d",&n);
    for(int i = 0;i < n;i++) {
        cin>>com;
        if(com == "insert") {
            scanf("%d",&x);
            insert(x);
        }
        else if(com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}



Measured memory_bytes: 26740
#include <iostream>
#include <stdio.h>
#include <queue>
#include <vector>
#include <string.h>
using namespace std;
const int N=123456;
vector <int> vec[N];
bool vis[N];
bool color[N];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	queue<int> que;
	while(!que.empty()) que.pop();
	memset(vis,false,sizeof(vis));
	vis[1]=true;vis[n]=true;
	que.push(1);que.push(n);
	color[1]=false;color[n]=true;
	while(!que.empty()){
		int temp=que.front();
		bool flag;
		que.pop();
		for(int x:vec[temp]){
			flag=color[temp];
			if(!vis[x]){
				color[x]=flag;
				que.push(x);
				vis[x]=1;
			}
		}
	}
	int s1=0,s2=0;
	for(int i=1;i<=n;i++){
		if(color[i]) s1++;
		else s2++;
	}
	if(s2>s1){
		puts("Fennec");
	} else {
		puts("Snuke");
	}
	return 0;
}


Measured memory_bytes: 6656