akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

int main() {
	cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	rep(i, n) {
		cin >> a[i];
		b[i]=a[i];
	}
	
	sort(b.begin(), b.end(), greater<ll>());
	ll max = b[0];
	ll max2 = 0;
	rep(i, n) {
		if (b[i] != max) {
			max2 = b[i];
			break;
		}
	}
	ll cnt = 0;
	rep(i, n) {
		if (a[i] == max) {
			cnt++;
		}
	}
	if (cnt >= 2) {
		rep(i, n) {
			cout << max << endl;
		}
	}
	else {
		rep(i, n) {
			if (a[i] < max) {
				cout << max << endl;
			}
			else if (a[i] == max) {
				cout << max2 << endl;
			}
		}
	}
}



Measured memory_bytes: 4736
#include<bits/stdc++.h>
# define mp make_pair
# define ll long long int
# define INF 10e9+7
using namespace std;

main()
{
  string x,y;
  cin>>x>>y;
  int n,m;
  n=x.size();
  m=y.size();
  
  int l[n+1][m+1]={};
  for(int i=1;i<=n;++i)
  {
  	for(int j=1;j<=m;++j)
  	{
  		l[i][j]=max(l[i-1][j],l[i][j-1]);
  		if(x[i-1]==y[j-1]) l[i][j]=l[i-1][j-1]+1;
  	}
  }
  int px=n,py=m;
  string ans;
  while(l[px][py])
  {
  	if(x[px-1]==y[py-1])
  	{
  		ans=x[px-1]+ans;
  		px--;
  		py--;
  	}
  	else if(l[px-1][py]>l[px][py-1]) px--;
  	else py--;
  }
  cout<<ans;
}

Measured memory_bytes: 35456
c = 0
while c == 0:
    ans = 0
    n,x = map(int,input().split())
    if n == 0 and x == 0:
        c = 1
    else:
        li = []
        for i in range(n):
            li.append(i+1)
        for a in range(1,n):
            for b in range(1,n):
                d = x - a - b
                if a != b and b != d and d != a and d <= n and a < b < d and d in li:
                    ans += 1
        print(ans)


Measured memory_bytes: 5600
#include <iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		ll a,b;
		cin >> a >> b;
		cout << a* b << endl;
	}
	return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main(){
    double n; cin >> n;
    for(int x = 1; x <= n; x++){
        if((int)(x*1.08) == n) {
            cout << x << endl;
            return 0;
        }
    }
    cout << ":(" << endl;

    return 0;
}

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

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

using namespace std;

typedef pair<int,int> ii;

const int IINF = INT_MAX;

struct Point3d {
  int x,y,z;
  bool operator < ( const Point3d &p ) const {
    if( z != p.z ) return z < p.z;
    if( y != p.y ) return y > p.y;
    return x > p.x;
  }
};


int a, b, C = ~(1<<31), M = (1<<16)-1;
int r() {
  a = 36969 * (a & M) + (a >> 16);
  b = 18000 * (b & M) + (b >> 16);
  return (C & ((a << 16) + b)) % 1000000;
}


const int MAX = 300010;
int m,n,A,B;
Point3d ps[MAX];
set<ii> dp[MAX];

bool check(int index,ii v){
  set<ii>::iterator it = dp[index].lower_bound(v);
  while( (*it).second < v.second ){
    if( (*it).first < v.first ) return true;
    --it;
  }
  return false;
}

void update(int index,ii v){
  set<ii>::iterator it = dp[index].lower_bound(v);
  --it;
  if( (*it).second <= v.second ) return;
  ++it;
  while( (*it).second >= v.second ){
    dp[index].erase(it++);
  }
  dp[index].insert(v);
}

void compute(){
  rep(i,m+n+1) {
    dp[i].clear();
    dp[i].insert(ii(-1,IINF));
    dp[i].insert(ii(IINF,-1));
  }
  dp[0].insert(ii(-1,-1));

  sort(ps,ps+m+n);
  vector<ii> vec;
  rep(i,n+m) vec.push_back(ii(ps[i].y,ps[i].x));

  //rep(i,n+m) cout << ps[i].x << "," << ps[i].y << "," << ps[i].z << endl;

  int maxi = 0;
  rep(i,n+m){
    int low = 0, hig = n+m;
    while( hig - low ) {
      int mid = ( low + hig ) / 2;
      if( check(mid,vec[i]) ) low = mid + 1;
      else                    hig = mid;
    }
    maxi = max(maxi,low);
    update(low,vec[i]);
  }
  printf("%d\n",maxi+1);
}

int main(){
  while( scanf("%d %d %d %d",&m,&n,&A,&B), m|n|A|B ){
    a = A, b = B;
    rep(i,m) scanf("%d %d %d",&ps[i].x,&ps[i].y,&ps[i].z);
    rep(i,n) {
      ps[m+i].x = r();
      ps[m+i].y = r();
      ps[m+i].z = r();
    }
    compute();
  }
  return 0;
}

Measured memory_bytes: 56972
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
using namespace std;
int main(){
    long long int x;
    cin>>x;
    long long int ans=(x/11)*2;
    if(x%11!=0){
        if(x%11<=6){
            ans++;
        }else{
            ans+=2;
        }
    }
    cout<<ans<<endl;
}   




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

int main() {
	string S; cin >> S;
	string T;
	for(int i=0; i<S.size(); ++i){
	    if(S[i]=='B'){
	        if(T.size()>0) T.pop_back();
	    }
	    else if(S[i]=='0') T += '0';
	    else T += '1';
	}
	cout << T << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    x,n = map(int,input().split())
    p = list(map(int,input().split()))
    min = 100000
    ans = 0
    for i in range(-10000,10000):
        if i in p:
            pass
        elif min > abs(i-x):
            min = abs(i-x)
            ans = i
            
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9180
// ConsoleApplication9.cpp : アプリケーションのエントリ ポイントを定義します。
//


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define p(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
//#define int long long


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;

bool arr[100000100];
vector<ll>sosuu;
void Eratosthenes() {
	ll N = 10000010;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (ll i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (ll j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (int ll i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu.pb(i);
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}


bool prime(ll n) {
	if (n == 1)return false;
	if (n == 2)return true;
	for (int i = 2; i < (int)sqrt(n) + 1; i++) {
		if (n%i == 0)return false;
	}
	return true;
}
vector<ll>sosu;
map<ll, ll>mp;
int main() {
	ll N, P;
	cin >> N >> P;
	Eratosthenes();
	/*
	FOR(i, 2, 1000020) {
	if (prime(i))sosu.pb(i);
	}
	*/

	if (N == 1) {
		p(P);
		return 0;
	}
	ll x = P;
	if (P == 1) {
		p(1);
		return 0;
	}
	while (x >= 2) {
		for (auto i : sosuu) {
			if (x%i == 0) {
				mp[i]++;
				x /= i;
				break;
			}
			if (i >= (ll)sqrt(P))goto END;
		}
	}
END:
	ll ans = 1;
	for (auto x : mp) {
		while (x.second / N > 0) {
			ans *= x.first;
			x.second -= N;
		}
	}
	p(ans);
}



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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 5e3 + 9, M = 5e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


int f(ll a, ll b){
    int l1 = (a == 0), l2 = (b == 0);
    while(a)    l1++, a /= 10;
    while(b)    l2++, b /= 10;
    return max(l1, l2);
}

int main(){
    init();

    ll n;   cin >> n;

    int ans = OO;
    for(ll i = 1;i * i <= n;i++){
        if(n % i == 0){
            ans = min(ans, f(i, n / i));
        }
    }

    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
int A1, A2, A3;

void fastio() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
}

int main() {
  fastio();
  std::cin >> A1 >> A2 >> A3;
  std::cout << (((A1 + A2 + A3) >= 22) ? "bust" : "win") << '\n';
  return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int N=5005,P=1e9+7;
int n,sz[N],f[N][N],g[N],t[N];
int pp,lnk[N],nxt[N*2],to[N*2];
void ae(int k1,int k2){to[++pp]=k2,nxt[pp]=lnk[k1],lnk[k1]=pp;}
void mod(int&k1){
	k1+=k1>>31&P;
}
void dfs(int k1,int k2){
	sz[k1]=1;
	f[k1][1]=1;
	for(int i=lnk[k1];i;i=nxt[i])if(to[i]!=k2){
		dfs(to[i],k1);
		rep(a,0,sz[k1]){
			t[a]=f[k1][a];
			f[k1][a]=0;
		}
		per(a,sz[k1],0)per(b,sz[to[i]],0){
			(f[k1][a+b]+=1LL*t[a]*f[to[i]][b]%P)%=P;
		}
		sz[k1]+=sz[to[i]];
	}
	for(int j=1;j<=sz[k1]/2;++j)mod(f[k1][0]-=1LL*f[k1][j*2]*g[j*2]%P);
	//printf("f[%d] : ",k1);
	//for(int j=0;j<=sz[k1];++j)printf("%d ",f[k1][j]);
	//puts("");
}
int main(){
	g[0]=1;
	rep(i,1,N-1)if(~i&1)g[i]=1LL*g[i-2]*(i-1)%P;
	scanf("%d",&n);
	rep(i,2,n){
		int k1,k2;scanf("%d%d",&k1,&k2);
		ae(k1,k2),ae(k2,k1);
	}
	dfs(1,0);
	printf("%d\n",(P-f[1][0])%P);
	return 0;
}

Measured memory_bytes: 58152
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define pb push_back
#define MOD 1000000007
//#define MOD 998244353
//define MOD 1000000007000000
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    int n;
    cin>>n;
    vector<int> l(n);
    vector<int> r(n);
    rep(i,n){
        cin>>l[i]>>r[i];
    }
    ll ans=0;
    rep(i,n){
        ans+=r[i]-l[i]+1;
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  cout << n * (n + 1) / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
int h,w;
int main(void) {
    cin >> h>>w;
    bool a[h][w];
    ll cnt=0;
    rep(i,h)rep(j,w){
        ll tmp;
        cin >> tmp;
        a[i][j]=tmp%2==1;
        if(a[i][j])cnt++;
    }
    ll done=0;
    bool state=false;
    vector<string> out;
    rep(i,w){
        if(i%2==0){
            rep(j,h){
                if(done>=cnt/2*2)break;
                if(!state&&a[j][i]){ 
                    state=true;
                    done++;
                    continue;
                }
                if(i==0&&j==0)continue;
                if(state){
                    if(j==0)out.push_back(to_string(j+1)+" "+to_string(i)+" "+to_string(j+1)+" "+to_string(i+1));
                    else out.push_back(to_string(j)+" "+to_string(i+1)+" "+to_string(j+1)+" "+to_string(i+1));
                }
                if(state&&a[j][i]){
                    state=false;
                    done++;
                }
            }
        }else{
            for(int j=h-1;j>=0;j--){
                if(done>=cnt/2*2)break;
                if(!state&&a[j][i]){ 
                    state=true;
                    done++;
                    continue;
                }
                if(i==0&&j==0)continue;
                if(state){
                    if(j==h-1)out.push_back(to_string(j+1)+" "+to_string(i)+" "+to_string(j+1)+" "+to_string(i+1));
                    else out.push_back(to_string(j+2)+" "+to_string(i+1)+" "+to_string(j+1)+" "+to_string(i+1));
                }
                if(state&&a[j][i]){
                    state=false;
                    done++;
                }
            }
        }
    }
    cout << out.size() << endl;
    for(auto x:out){
        cout << x << endl;
    }
    return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 200000
i64 N;
map<string, i64> dict;

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

  i64 maxv = 0;
  REP(i, N) {
    cin >> s;
    if (dict.count(s) == 0) {
      dict[s] = 1;
    } else {
      dict[s]++;
    }
    if (dict[s] > maxv) maxv = dict[s];
  }

  for (auto it = dict.begin(); it != dict.end(); it++) {
    if (it->S == maxv) {
      cout << it->F << endl;
    }
  }

  return 0;
}

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

int main() {
    int x, y, z;
/*   x = 0.5;
   y = 4;   */
    cin >> x >> y;
    z = x + y;
    cout << z / 2 + z % 2 << endl;
//    double a, b;
//    cin >> a >> b;
//    cout <<  << endl;
}

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

long long charsum(const char s[])
{
    long long ret = 0;
    for (size_t i=0; i<strlen(s); i++) {
        ret += s[i] - '0';
    }
    return ret;
}

int main()
{
    char in[12];
    scanf("%s", in);
    long long ll = atoll(in);
    
    printf("%s\n", (ll%charsum(in)) ? "No" : "Yes");
    return 0;
}


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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> v(m);
	for (int i = 0; i < n; ++i) {
		int k;
		cin >> k;
		for (int j = 0; j < k; ++j) {
			int w;
			cin >> w;
			w--;
			v[w]++;
		} 
	}	  
	int cnt = 0;
	for (int i = 0; i < m; ++i) {
		if (v[i] == n) {
			cnt++;
		}
	}
	cout << cnt;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
bool chmin(ll& a, ll& b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll& b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main(){
    cin >> n;
    rep(i, n) {
        cin >> x;
        if (x % 2 == 1)ans = 1;
    }

    if (ans == 1)cout << "first" << endl;
    else cout << "second" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

vector<long> soinsu(long A){
    long t = A;
    vector<long> l;
    l.push_back(1);

    for(long i=2; i<=sqrt(A)+1; i++){
        if(t % i != 0) continue;
        while(t % i == 0){
            t /= i;
        }
        l.push_back(i);
    }

    if(t != 1) l.push_back(t);

    return l;
}

int main(){
    long A, B;
    cin >> A >> B;

    vector<long> la = soinsu(A);
    vector<long> lb = soinsu(B);

    long cnt = 0;
    for(auto ita=la.begin(); ita!=la.end(); ita++){
        for(auto itb=lb.begin(); itb!=lb.end(); itb++){
            if(*ita == *itb){
                cnt++;
                break;
            }
        }
    }

    cout << cnt << endl;
 
    return 0;

}



Measured memory_bytes: 256
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p = sorted(p)
q = sorted(q)
r = sorted(r)
P = A - X
Q = B - Y
R = C - 1
found = True
for i in range(C+1):
    if R < 0:
        break
    if P < A:
        if (r[C-i-1] >= p[P]):
            if Q < B:
                if (q[Q] >= p[P]):
                    P += 1
                    R -= 1
                elif r[C-i-1] > q[Q]:
                    Q += 1
                    R -= 1
                else:
                    break
            else:
                P += 1
                R -= 1
        elif Q < B:
            if r[C-i-1] > q[Q]:
                Q += 1
                R -= 1
            else:
                break
        else:
            break
    elif Q < B:
        if r[C-i-1] > q[Q]:
            Q += 1
            R -= 1
        else:
            break    
    else:
        break
print(sum(p[P:])+sum(q[Q:])+sum(r[R+1:]))

Measured memory_bytes: 106980
import sys,collections
input = sys.stdin.readline
N=int(input())
A=list(map(int,input().split()))
B = []
C = []
for i,a in enumerate(A):
    B.append(i+a)
    C.append(i-a)
cnt = 0
Bc = collections.Counter(B)
Cc = collections.Counter(C)

for key,val in Bc.items():
    cnt += val*Cc[key]
print(cnt)


Measured memory_bytes: 63716
fn input() -> String {
    let mut buf = String::new(); //A
    std::io::stdin().read_line(&mut buf).unwrap(); //B
    buf.trim().to_string() //C
}

fn rectangle(line: Vec<i32>) {
    let i = line[0];
    let j = line[1];
    println!("{} {}", i * j, i * 2 + j * 2);
}

fn main() {
    let line = &input();
    let seg: Vec<i32> = line
        .split_whitespace()
        .map(|s| s.parse::<i32>().unwrap())
        .collect();
    rectangle(seg);
}


Measured memory_bytes: 5024
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define all(a) a.begin(), a.end()
// #pragma comment(linker, "/stack:2000000000")
 
typedef long long ll;
 
typedef long double ld;
 
using namespace std;
 
const ll maxn = 1e6;
const ll inf = 1e9;
const ld eps = 1e-9;
 
ll n, m, k, t;

void rec(string s, ll cur) {
    if (s.length() == n) {
        cout << s << '\n';
        return;
    }
    for (int i = 0; i <= cur; i++) {
        string nw = s + char('a' + i);
        if (i != cur)rec(nw, cur);
        else {
            rec(nw, cur + 1);
        }
    }
}

int main() {
    ll q, w, e, d;
    pyshnapyshnakaa;
    cin >> n;
    rec("", 0);
    return 0;
}


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

using namespace std;

int n;
int a[200001], ans[200001];

vector<int> tmp;
vector<int> adj[200001];

void dfs(int u, int p)
{       
	int pre = -1;
	int pos = lower_bound(tmp.begin(), tmp.end(), a[u]) - tmp.begin();
	if (pos == tmp.size())
		tmp.push_back(a[u]);
	else
	{
		pre = tmp[pos];
		tmp[pos] = a[u];
	}
	ans[u] = tmp.size();
	for (int v : adj[u])
		if (v != p)	
			dfs(v, u);

	if (pre != -1)
	{
		assert(pos != tmp.size());
		tmp[pos] = pre;
	}	
	else 
	{
		assert(!tmp.empty());
		tmp.pop_back();
	}	
}

int main(int argc, char** argv)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(1, -1);
	for (int i = 1; i <= n; i++)
		cout << ans[i] << '\n';
}

Measured memory_bytes: 27604
#include <bits/stdc++.h>
    using namespace std;
	typedef long long int ll; 
     
    int main() {
		string S;
    	cin >> S;
        bool flag=0;
      	if(S.at(0)==S.at(1)){
          if((S.at(2)==S.at(3))&&(S.at(0)!=S.at(2))) flag=1; 
        }else{
          if((S.at(0)==S.at(2))&&(S.at(1)==S.at(3))) flag=1; 
          if((S.at(0)==S.at(3))&&(S.at(1)==S.at(2))) flag=1;
        }
      if(flag){
        cout<< "Yes"<< endl;
      }else{
        cout<< "No"<< endl;
      }
    }

Measured memory_bytes: 256
N,M = gets.split.map(&:to_i)


def factorial(number)
    a = 1
    for i in 1..number 
        
        a = (a * i) % ((10 ** 9) + 7)

    end

    a 

end

if (N-M).abs >= 2

    puts 0

elsif N == M 

    puts  (2 * factorial(N) * factorial(M)) % ((10 ** 9) + 7)

elsif (N-M).abs == 1

    puts (factorial(N) * factorial(M)) % ((10 ** 9) + 7)

end




Measured memory_bytes: 3836
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)
    x=x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL)
    x=x->right;
  return x;
}

Node treeSearch(Node u, int k){
while(u!=NIL && k!=u->key){
    if(k<u->key) u=u->left;
    else u=u->right;         }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL)
    return treeMinimum(x->right);

  y=x->parent;
  while(y!=NIL && x==y->right)
    {x=y;
      y=y->parent;}
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left == NIL || z->right == NIL)y=z;
  else y=treeSuccessor(z);
  }

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL)
    {y=x;
      if(z->key < x->key) x=x->left;
      else x=x->right;  }
  z->parent = y;
  if(y==NIL) root=z;
  else
    { if(z->key < y->key)y->left=z;
      else y->right=z;
    }
}

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


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

int main() {

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (a + b == c + d) {
		cout << "Balanced";
	}
	else if (a + b > c + d) {
		cout << "Left";
	}
	else {
		cout << "Right";
	}

	return 0;
}

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


int main(){
    long long N, A, grand_sum = 0;
    long long n, ans;
    std::cin >> N;

    vector<long long> A_list(N);
    map<long long, long long> balls;

    for(int i = 0; i < N; i++){
        std::cin >> A;
        A_list[i] = A;
        if(balls.count(A)){
            balls[A] = balls[A] + 1;
        }else{
            balls[A] = 1;
        }
    }

    std::map<long long, long long>::iterator iter = balls.begin();
    for(int i = 0; i < balls.size(); i++){
        n = iter->second;
        grand_sum = grand_sum + n * (n - 1) / 2;
        iter++;
    }

    //std::cout << grand_sum << "\n";

    for(int k = 0; k < N; k ++ ){
        ans = grand_sum - (balls[A_list[k]] - 1);
        std::cout << ans << "\n";
    }
}

Measured memory_bytes: 12736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

ll a[10];
string s;

int main(){
	while (cin >> s){
		if (s.find("AB") != -1){
			a[2]++;
			continue;
		}
		if (s.find("A") != -1){
			a[0]++;
		}
		else if (s.find("B") != -1){
			a[1]++;
		}
		else{
			a[3]++;
		}
	}
	REP(i, 4){
		cout << a[i] << endl;
	}
}

Measured memory_bytes: 1180
def solve2(ins):
    ins = ins.split("\n")
    h = list(map(int, ins[1].split(" ")))
    # costs = [abs(h1 - h2) for h1, h2 in zip(h, h[1:])]
    a, b = 0, abs(h[0] - h[1])
    for i in range(2, len(h)):
        a, b = b, min(a + abs(h[i] - h[i - 2]), b + abs(h[i] - h[i - 1]))
    return b


if __name__ == "__main__":
    print(solve2("\n".join([input(), input()])))


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

int main() {
    int N; cin >> N;
    vector<int> S(N+1);
    int now = 2;
    while(now*now <= N){
        S[now*now]++;
        for (int i = now*now+now; i <= N; i+=now){
            S[i] += 2;
        }
        now++;
    }

    ll ans = 0;
    for (int i = 1; i <= N; i++){
        ll s = S[i]+2;
        if(i == 1)s--;
        ans += s*i;
        //cout << i << " " << ans << endl;
    }

    cout << ans << endl;

    return 0;

    return 0;
}

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

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
const int INF = 100000000;

int side(int from, int to){
  return (to+2)%3 - (from+2)%3;
}
int main(){
  string s;
  while(cin>>s && s != "#"){
    int N = s.size();
    int dp[100001][2] = {};
    FOR(i, 1, 100000)REP(j,2)dp[i][j] = INF;
    FOR(i, 1, N){
      dp[i][0] = dp[i-1][0] + 1;
      dp[i][1] = dp[i-1][1] + 1;
      if(side(s[i-1], s[i]) >= 0) dp[i][1] = min(dp[i][1], dp[i-1][0]);
      if(side(s[i-1], s[i]) <= 0) dp[i][0] = min(dp[i][0], dp[i-1][1]);
    }
    cout<<min(dp[N-1][0], dp[N-1][1])<<endl;
  }
  return 0;
}

Measured memory_bytes: 1920
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e16;

lint N, A, _gcd;

lint gcd(lint A, lint B) {
	if (B == 0) return A;
	else return gcd(B, A % B);
}

int main() {
	cin >> N;
	cin >> _gcd;
	REP(i, N - 1) {
		cin >> A;
		_gcd = gcd(_gcd, A);
	}
	cout << _gcd << endl;
}


Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <cfloat>
#include <algorithm>
using namespace std;

int main() {
  pair<double, int> t[24];
  for (int i=0; i<24; i++) {
    cin >> t[i].second >> t[i].first;
  }
  for (int i=0; i<3; i++) {
    sort(t+8*i, t+8*(i+1));
    for (int j=0; j<2; j++) {
      cout << t[8*i+j].second << " " << fixed << setprecision(2) << t[8*i+j].first << endl;
      t[8*i+j].first = DBL_MAX;
    }
  }
  sort(t, t+24);
  for (int i=0; i<2; i++) {
    cout << t[i].second << " " << fixed << setprecision(2) << t[i].first << endl;
  }

  return 0;
}

Measured memory_bytes: 1296
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

static int
gcd(int m, int n) {
  int tmp;

  if (m < n) {
    tmp = m;
    m = n;
    n = tmp;
  }

  return (m % n) ? gcd(n, m % n) : n;
}

int main(int argc, char **argv) {
  int m, n, ret;

  ret = scanf("%d %d", &m, &n);
  if (errno != 0) perror("scanf: m, n");
  if (ret < 1) exit(1);

  printf("%d\n", gcd(m, n));
  exit(0);
}


Measured memory_bytes: 2108
#include<stdio.h>
#define INF 1000000
void warshall_floyd();
int min(int,int);
int graph[101][101],n,c,d;

int main(){
  int k,i,j,x,e,a,b;

  while(scanf("%d %d",&n,&k),n,k){

    for(i=0;i<=n;i++)
      for(j=0;j<=n;j++)
	graph[i][j]=i==j?0:INF;

    for(i=0;i<k;i++){

      if(scanf("%d",&x),x){
	scanf("%d %d %d",&c,&d,&e);

	if(graph[c][d]>e){
	graph[c][d]=graph[d][c]=e;
	warshall_floyd();
	}
      }else{
	scanf("%d %d",&a,&b);
	printf(graph[a][b]>=INF?"-1\n":"%d\n",graph[a][b]);
      }
    }
  }
  return 0;
}

void warshall_floyd(){
  int i,j;
  for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
      graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][c]+graph[c][d]+graph[d][j]);
}

int min(int x,int y){
  return x<y?x:y;
}

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

#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define rrange(v) v.rbegin(), v.rend()
#define mod (int)(1e9 + 7)
#define inf (int)(5e18)
#define N (int)(2e5 + 10)

using namespace std;


struct hull {

	struct line {
		int m, c;
	};

	double intersect(line a, line b) {
		return ((a.c - b.c) / ((double) b.m - a.m));
	}

	double get(line a, int x) {
		return a.m * x + a.c;
	}

	deque<line> d;
	deque<double> pts;

	void addLine(line a) {
		if (d.empty()) {
			d.pb(a);
			return;
		}

		while (d.size() > 1 and intersect(d[d.size() - 2], a) <= pts.back()) {
			d.pop_back();
			pts.pop_back();
		}

		pts.pb(intersect(a, d.back()));
		d.pb(a);
	}

	double findbest(int x) {
		int idx = lower_bound(range(pts), x) - pts.begin();
		return get(d[idx], x);
	}

};

void solve() {
	int n, c;
	cin >> n >> c;
	vector<int> a(n);
	for (int &i : a) cin >> i;
	hull h;
	vector<int> dp(n);
	for (int i = 0; i < n; i++) {
		if (i) dp[i] = h.findbest(2 * a[i]) + a[i] * a[i] + c;
		h.addLine({ -a[i], dp[i] + a[i] * a[i]});
	}

	cout << dp[n - 1] << endl;
}
// Remember to clear the global containers

// Got stuck and want to leave ? look at the bottom once..
int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
	// cin >> t_c;
	while (t_c--)
		solve();
}
/* Come on Dude .. Dont get up until u get the solution
 * Giving up not gonna help ryt ? So get ur lazy ass to code already
 * You can do it ... Stay Calm and Dont Panic :)
 */


Measured memory_bytes: 11260
from collections import defaultdict, deque

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ns = defaultdict(int)
for i in a:
    ns[i] += 1
for i in b:
    ns[i] += 1
if max(ns.values()) > n:
    print('No')
    exit()

j = -1
k = -1
md = 0
for i in range(2, n + 1):
    while j + 1 < n and a[j + 1] < i:
        j += 1
    while k + 1 < n and b[k + 1] < i - 1:
        k += 1
    md = max(md, j - k)

for i in range(n):
    if a[i] == b[(i - md) % n]:
        md += 1
        break

d = deque(b)
d.rotate(md)

print('Yes')
print(' '.join([str(x) for x in d]))


Measured memory_bytes: 133244
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//FUNCTION



void solve(void)
{
  int H,W; cin>>H; cin>>W;
  int A,B; cin>>A; cin>>B; 
  vector<vector<int> > vvec (H,vector<int>(W,0)); 
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      int P = (int)(i>=B);
      int Q = (int)(j>=A);
      vvec[i][j] = P^Q;
    }
    
  }
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cout<<vvec[i][j];
    }
    cout<<endl;
    
  }
  

  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 9088
#include<stdio.h>
#include<stdlib.h>
#define N 10001
#define P 1<<15
typedef long long Int;
Int get_primes(Int primes[P],Int num){
    Int i,j,n=0,flag[P];
    for(i=0;i<num/2;i++) flag[i*2+1] = 1;
    for(i=0;i<num/2;i++) flag[i*2] = 0;
    flag[0] = flag[1] = 0; flag[2] = 1; primes[n++] = 2;
    for(i=3;i<num;i++) if(flag[i]) {
        for(j=2;j<=(num-1)/i;j++) flag[i*j] = 0;
        primes[n++] = i;
    }
    return n;
}
Int pf_decompose(Int num,Int prime_factor[P]){
    Int i,num_pf;
    for(i=2,num_pf=0;i*i<=num;i++){
        if(num%i==0) prime_factor[num_pf++] = i;
        while(num%i==0) num/=i;
    }
    if(num!=1) prime_factor[num_pf++] = num;
    return num_pf;
}
Int gcd(Int a,Int b){ return (a==0)?b:gcd(b%a,a); }
Int Iabs(Int a){ return (a<0)?-a:a; }
int cmp(const void* a,const void* b){ Int c=*(Int*)a,d=*(Int*)b; return (c<d)?-1:(c>d); }
void print(Int A[N],Int n){ int i; for(i=0;i<n;i++) printf("%lld ",A[i]); printf("\n"); }
int main(void){
    Int i,j,n,np,m,g,poly[N],tmp[N],primes[P],ans[P];
    scanf("%lld",&n);
    np = get_primes(primes,n+1);
    for(i=n;i>=0;i--) scanf("%lld",&poly[i]);
    for(i=g=0;i<=n;i++) g = gcd(g,Iabs(poly[i]));
    m = pf_decompose(g,ans);
    for(i=0;i<np;i++){
        for(j=0;j<primes[i];j++) tmp[j] = 0;
        tmp[0] = poly[0];
        for(j=1;j<=n;j++) tmp[(j-1)%(primes[i]-1)+1] += poly[j];
        for(j=0;j<primes[i];j++) if( tmp[j]%primes[i] ) break;
        if(j==primes[i]) ans[m++] = primes[i];
    }
    if(m!=0){
        qsort(ans,m,sizeof(Int),cmp);
        printf("%lld\n",ans[0]);
        for(i=1;i<m;i++) if(ans[i]!=ans[i-1]) printf("%lld\n",ans[i]);
    }
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
using namespace std;

int ceil(int a) {
	return (a + (10 - 1)) / 10;
}

int main() {
	int N[5], tmp1, tmp2, tmp3,tmp4,tmp5;
	int ans = 100000;
	for (int i = 0; i < 5; i++) cin >> N[i];
	tmp1 = N[0] + ceil(N[1])*10 + ceil(N[2])*10 + ceil(N[3])*10 + ceil(N[4])*10;
	if (tmp1 < ans) ans = tmp1;
	tmp2 = N[1] + ceil(N[0]) * 10 + ceil(N[2]) * 10 + ceil(N[3]) * 10 + ceil(N[4]) * 10;
	if (tmp2 < ans) ans = tmp2;
	tmp3 = N[2] + ceil(N[1]) * 10 + ceil(N[0]) * 10 + ceil(N[3]) * 10 + ceil(N[4]) * 10;
	if (tmp3 < ans) ans = tmp3;
	tmp4 = N[3] + ceil(N[1]) * 10 + ceil(N[2]) * 10 + ceil(N[0]) * 10 + ceil(N[4]) * 10;
	if (tmp4 < ans) ans = tmp4;
	tmp5 = N[4] + ceil(N[1]) * 10 + ceil(N[2]) * 10 + ceil(N[3]) * 10 + ceil(N[0]) * 10;
	if (tmp5 < ans) ans = tmp5;

	cout << ans << endl;
}

Measured memory_bytes: 256
import math
while 1:
	n = int(input())
	if n == 0:
		break
	count = 0
	if n == 1:
		count = 1
		x = n + 2
	elif n % 2 == 1:
		x = n + 2
	elif n == 2:
		count = 1
		x = n + 1
	else:
		x = n + 1
	for i in range(x,n*2+1,2):
		y = math.trunc(math.sqrt(i))+3
		if y % 2 == 1:
			z = y-2
		else:
			z = y-1
		for j in range(3,y,2):
			if i % j == 0:
				break
			if j == z:
				count += 1
	print count

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

ll gcd(ll a,ll b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
int main(){
  int n,m;cin >> n >> m;
  vector<bool> AC(n+1, false);
  vector<int> WA(n+1, 0);
  int ansac = 0;
  int pena = 0;
  for(int i=0; i<m; i++){
    int p; cin >> p;
    string s; cin >> s;
    if(AC.at(p)){
      continue;
    }else{
      if(s=="WA"){
        WA.at(p)++;
      }else{
        ansac++;
        pena += WA.at(p);
        AC.at(p) = true;
      }
    }
  }
  cout << ansac << ' ' << pena << endl;
      
}


Measured memory_bytes: 640
#include<bits/stdc++.h>//万能文件头
using namespace std;
string s="CODEFESTIVAL2016";//好像也没什么用
string a;
long long ans;
int main(){
    cin>>a;
    if(a[0] != 'C') ans++;
    if(a[1] != 'O') ans++;
    if(a[2] != 'D') ans++;
    if(a[3] != 'E') ans++;
    if(a[4] != 'F') ans++;
    if(a[5] != 'E') ans++;
    if(a[6] != 'S') ans++;
    if(a[7] != 'T') ans++;
    if(a[8] != 'I') ans++;
    if(a[9] != 'V') ans++;
    if(a[10] != 'A') ans++;
    if(a[11] != 'L') ans++;
    if(a[12] != '2') ans++;
    if(a[13] != '0') ans++;
    if(a[14] != '1') ans++;
    if(a[15] != '6') ans++;
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <bitset>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dcm(a) setprecision(a)<<fixed
#define MOD 1000000007
#define clr(memo, a) memset(memo,a,sizeof(memo))
#define PI acos(-1)
void solve()
{
string s,t;
cin>>s>>t;
int ans=0;
for(int i=0;i<s.size();i++)
    if(s[i]!=t[i])
    ans++;
cout<<ans<<endl;
}


int main()
{
    fast;

    solve();

    }


Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
int a[3005];
int main(){
    double L,t,r,m,x=0.0,y=0.0;int n,i,j;
    scanf("%d%d",&n,&i);
    m=(6.0/(n*(n-1)))/(n-2);
    L=M_PI/i;
    for(i=1;i<=n;++i)scanf("%d",&a[i]);
    for(j=2;j<=n;++j)for(i=1;i!=j;++i){
        t=L*(a[i]+a[j]);
        r=m*(n-((j-i)<<1));
        x+=cos(t)*r;
        y+=sin(t)*r;
    }
    printf("%.15lf %.15lf",x,y);
    return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>

using sll = signed long long;


struct food {
	sll a, b, dif;

	friend decltype(auto)
		operator>>(std::istream& is, food&f) {
		is >> f.a >> f.b;
		f.dif = f.a - f.b;
		return is;
	}
	food() = default;
};

int main() {
	unsigned n;
	std::cin >> n;

	std::vector<food> v{ n };

	sll ans{};
	for (auto &e : v) {
		sll a, b;
		std::cin >> a >> b;
		e = food{ a,b };
		ans -= b;
	}

	std::sort(std::begin(v), std::end(v)
		, [](const auto& x, const auto& y) {
		return
			x.a + x.b < y.a + y.b;
	});


	for (sll i{n-1}; i>=0; i-=2) {
		ans += v[i].a + v[i].b;
	}

	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define pic pair<ll,char>
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define st  set <ll, greater <ll> >
#define mst  multiset <ll, greater <ll> >
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mapp  unordered_map <ll, ll>
#define ppii pair< pii, pii > 
#define test(t) ll t;cin>>t;while(t--)
#define inarr(n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i];
#define ingra(m) vvi arr(100005);for(ll i=0;i<m;i++){ll u,v;cin>>u>>v;arr[u].pb(v);arr[v].pb(u);}
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
ld dp[3001][3001];
ld arr[3001];
ll n;
signed main()
{
    fast;
    cin>>n;
    ll i,j;
    for(i=1;i<=n;i++)
        cin>>arr[i];
    dp[0][0] = 1.0;
    for(i=1;i<=n;i++)
    {
        for(j=0;j<=i;j++)
        {
            if(j==0)
                dp[i][j] = dp[i-1][j]*(1.0-arr[i]);
            else
                dp[i][j] = dp[i-1][j-1]*arr[i]+dp[i-1][j]*(1.0-arr[i]);
        }
    }
    ll p = n/2+1;
    ld ans = 0.0;
    for(i=p;i<=n;i++)
        ans+=dp[n][i];
    cout<<fixed<<setprecision(20)<<ans;
}

Measured memory_bytes: 139136
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll max(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
double max(double a, double b) {

	if (a > b)return a;
	else return b;

}
//a??¨b?????§?????????

ll min(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//a??¨b????°??????????

ll avd_i(ll a, ll b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//a??¨b???????????¶??????

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//p????´???°,a???b??????p??§?????£?????????

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//p????´???°,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//?????§??¬?´???°

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//????°???¬?????°

int main() {
	
	int H, W;

	while (1) {

		cin >> H >> W;
		
		if (H == 0 && W == 0)break;
		else {

			for (int i = 0; i < H; i++) {

				for (int j = 0; j < W; j++) {

					if (i == 0 || j == 0 || i == H - 1 || j == W - 1)cout << "#";
					else cout << ".";

				}
				cout << endl;

			}
			cout << endl;

		}

	}

	return 0;
}

Measured memory_bytes: 3132