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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

int main(){
    ll N, C, K;
    cin >> N >> C >> K;
    //vector<ll> T(N);
    priority_queue<ll, vector<ll>, greater<ll> > que;
    REP(i,N){
        ll t;
        cin >> t;
        //T[i] = t;
        que.push(t);
    }

    //sort(T.begin(), T.end());

    ll ans = 0;
    ll time = -1;
    ll cnt = 0;
    while(!que.empty()){
        ll t = que.top();
        if(time == -1){
            time = t;
            cnt++;
            que.pop();
        }
        else{
            if(t - time <= K){
                cnt++;
                que.pop();
            }
            else{
                ans++;
                time = -1;
                cnt = 0;
            }
        }


        if(cnt == C){
            ans++;
            cnt = 0;
            time = -1; 
        }
    }

    if(cnt != 0) ans++;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main(){
	int t, d, l;
	while (cin >> t >>d >> l, t) {
		int out = 0; int rest = 0;
		rep(i, t) {
			int x; cin >> x;
			if (x >= l)rest = d;
			if (rest > 0&&i<t-1) {
				out++; rest--;
			}
		}
		cout << out << endl;
	}
	return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking
#define fi first
#define se second
#define BG begin
#define ED end
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?(x)-=mo:233)%s
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(x) (1ll*x*x)
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
#define INF (1ll<<60)
using namespace std;
const int N=2005;
int a[N][N],b[N][N],c[N][N];
int n,D;
int calc(int x){
	int l=0,r=400,ans=-1;
	while (l<=r){
		int mid=(l+r)/2;
		if (mid*mid<x)
			ans=mid,l=mid+1;
		else r=mid-1;
	}
	return ans;
}
int SUMB(int l,int r,int x,int y){
	if (l>r||x>y) return 0;
	return b[r][y]-(l?b[l-1][y]:0)-(x?b[r][x-1]:0)+(l&&x?b[l-1][x-1]:0);
}
int SUMC(int l,int r,int x,int y){
	if (l>r||x>y) return 0;
	return c[r][y]-(l?c[l-1][y]:0)-(x?c[r][x-1]:0)+(l&&x?c[l-1][x-1]:0);
}
bool check(int mid,int v){
	memset(b,0,sizeof(b));
	memset(c,0,sizeof(c));
	int sum=0;
	For(i,0,D-1) For(j,0,D-1) if (a[i][j])
		if (a[i][j]<=v) b[i][j]++;
		else c[i][j]++,sum++;
	For(i,0,2*D-1) For(j,0,2*D-1)
		b[i][j]=b[i%D][j%D],c[i][j]=c[i%D][j%D];
	For(i,1,2*D-1) For(j,0,2*D-1)
		b[i][j]+=b[i-1][j],c[i][j]+=c[i-1][j];
	For(i,0,2*D-1) For(j,1,2*D-1)
		b[i][j]+=b[i][j-1],c[i][j]+=c[i][j-1];
	For(i,0,D-1) For(j,0,D-1){
		int s1=SUMB(i+mid,i+D-1,j+mid,j+D-1);
		int s2=SUMC(i,i+mid-1,j,j+mid-1);
		if (s1==0&&s2==sum) return 1;
	}
	return 0;
}
int main(){
	scanf("%d%d",&n,&D);
	For(i,1,n){
		int x,y;
		scanf("%d%d",&x,&y);
		a[x%D][y%D]++;
	}
	int mx=0;
	For(i,0,D-1) For(j,0,D-1)
		mx=max(mx,calc(a[i][j]));
	For(i,0,D-1) For(j,0,D-1)
		a[i][j]=max(0,a[i][j]-mx*mx);
	int l=0,r=D,ans=23333;
	while (l<=r){
		int mid=(l+r)/2;
		if (check(mid,mx)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d\n",mx*D+ans-1);
}

Measured memory_bytes: 41216
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                           //     #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                  #define VI vector<int>
                                        using namespace std;
                                        
                                  class pas{
                                    	public:
                                    	int x,y;
                                    	pas(int x=0,int y=0):x(x),y(y) {}
                                    	pas operator + (pas p) {return pas(x+p.x,y+p.y);}
                                    	pas operator - (pas p) {return pas(x-p.x,y-p.y);}
                                    	pas operator * (int a) {return pas(x*a,y*a);}
                                    	pas operator / (int a) {return pas(x/a,y/a);}
                                    //	double absv() {return sqrt(norm());}
                                    	int norm() {return x*x+y*y;}
                                    	bool operator < (const pas &p) const{
                                    		return x != p.x ? x<p.x: y<p.y;
                                    	}
                                    	bool operator == (const pas &p) const{
                                    		return x==p.x && y==p.y;
                                    	}
                                    };
int a[60];
           signed main(){
        
           	int x,t;
           	cin>>x>>t;
           	
           	if(x>t) cout<<x-t<<endl;
           	else cout<<0<<endl;
           	
           	return 0;
           	
           	
           }
             

Measured memory_bytes: 256
import copy
H, W, K = map(int,input().split())
C = [list(input()) for y in range(H)]
D = copy.deepcopy(C)       #Cの保管
ans = 0
import itertools


def retu(x):            #x+1列目を赤くする
    for y in range(H):
        C[y][x] = "R"

def gyou(x):            #x+1行目を赤くする
    for y in range(W):
        C[x][y] = "R"


for p in range(2**H):
    for q in range(2**W):
        for r in range(H):
            if p >> r & 1:
                gyou(r)
        for s in range(W):
            if q >> s & 1:
                retu(s)
        E = list(itertools.chain.from_iterable(C))  
        #１次元化して#の個数をわかりやすくする
        if E.count("#") == K:
            ans += 1
        C = copy.deepcopy(D)


print(ans)



Measured memory_bytes: 9192
vn,en = map(int,input().split())
dis = [[float("inf") for __ in range(vn)] for _ in range(vn)]
for i in range(vn):
    dis[i][i] = 0
for _ in range(en):
    s,t,d = map(int,input().split())
    dis[s][t] = d
for k in range(vn):
    for i in range(vn):
        for j in range(vn):
            dis[i][j] = min(dis[i][k]+dis[k][j], dis[i][j])
            if i==j:
                if dis[i][j]<0:
                    print('NEGATIVE CYCLE')
                    exit()
for i in range(vn):
    ans = []
    for j in range(vn):
        if dis[i][j] == float('inf'):
            ans.append('INF')
        else:
            ans.append(str(dis[i][j]))
    print(' '.join(ans))






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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    vector<int> c(n-1);
    rep(i,n) {
        cin >> a[i];
        a[i]--;
    }
    rep(i,n) cin >> b[i];
    rep(i,n-1) cin >> c[i];

    int ans = 0;
    rep(i,n) {
        ans += b[a[i]];
        if (i > 0 && a[i] == a[i-1]+1) {
            ans += c[a[i-1]];
        }
    }

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


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<int,int> P1;
typedef pair<P1,P1> P2;
vector<P2> G[30][30][4];
int s[30][30],c[4];
int d[30][30][4];
bool used[30][30][4];
int dx[]={0,1,0,-1},dy[]={-1,0,1,0}; //??? ??± ??? ?\?
int turn(int d,bool r) {
	if(r) {
		return (d+1)%4;
	}else {
		return (d+3)%4;
	}
}
int main() {
	int w,h;
	while(scanf("%d %d",&w,&h),w) {
		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				scanf("%d",&s[i][j]);
			}
		}
		for(int i=0;i<4;i++) {
			scanf("%d",&c[i]);
		}
		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				for(int k=0;k<4;k++) {
					G[i][j][k].clear();
					for(int op=0;op<4;op++) {
						int cost=(op==s[i][j])?0:c[op];
						int nk=k;
						if(op==1) nk=turn(k,1);
						if(op==2) nk=(k+2)%4;
						if(op==3) nk=turn(k,0);
						int ni=i+dy[nk],nj=j+dx[nk];
						if(0>ni||ni>=h||0>nj||nj>=w) continue;
						G[i][j][k].push_back(P2(P1(ni,nj),P1(nk,cost)));
					}
				}
			}
		}
		fill((bool*)used,(bool*)(used+30),0);
		fill((int*)d,(int*)(d+30),1<<30);
		d[0][0][1]=0;
		while(1) {
			int ni,nj,nk;
			ni=nj=nk=-1;
			for(int i=0;i<h;i++) for(int j=0;j<w;j++) for(int k=0;k<4;k++) {
				if(!used[i][j][k] && (ni==-1||d[i][j][k]<d[ni][nj][nk])) ni=i,nj=j,nk=k;
			}
			if(ni==-1) break;
			used[ni][nj][nk]=1;
			for(int i=0;i<G[ni][nj][nk].size();i++) {
				int ti=G[ni][nj][nk][i].first.first;
				int tj=G[ni][nj][nk][i].first.second;
				int tk=G[ni][nj][nk][i].second.first;
				int tc=G[ni][nj][nk][i].second.second;
				d[ti][tj][tk]=min(d[ti][tj][tk],d[ni][nj][nk]+tc);
			}
		}
		int ans=1<<30;
		for(int i=0;i<4;i++) {
			ans=min(ans,d[h-1][w-1][i]);
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 2984
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n;
  string s;
  cin >> n;
  if (n >=400 && n < 600) cout << 8 << endl;
  else if (n >=600 && n <800) cout << 7 << endl;
  else if (n >=800 && n <1000) cout << 6 << endl;
  else if (n >=1000 && n <1200) cout << 5 << endl;
  else if (n >=1200 && n <1400) cout << 4 << endl;
  else if (n >=1400 && n <1600) cout << 3 << endl;
  else if (n >=1600 && n <1800) cout << 2 << endl;
  else if (n >=1800 && n <2000) cout << 1 << endl;

  return 0;
}


Measured memory_bytes: 3624
from collections import defaultdict

S = input()
d = defaultdict(int)
for i in S:
    d[i] += 1

if len(d) == 1 or len(d) == 3:
    print('No')
else:
    if len(d) == 4:
        print('Yes')
    elif 'N' in d:
        if 'S' in d:
            print('Yes')
        else:
            print('No')
    elif 'W' in d:
        if 'E' in d:
            print('Yes')
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int h, w, n;
  cin >> h >> w >> n;

  int ans = 0;
  int b = 0;
  int i = 0;
  while (1) {
    if (h < w) {
      if (i < w) {
        b += w;
      }
    } else {
      if (i < h) {
        b += h;
      }
    }

    i++;

    if (b >= n) {
      break;
    }
  }

  cout << i << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;

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

    long aryA[n][m];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> aryA[i][j];
            // cout << aryA[i][j] << endl;
        }
    }

    long aryB[m][l];
    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++){
            cin >> aryB[i][j];
            // cout << aryB[i][j] << endl;
        }
    }

    long long aryC[n][l];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){

            // printf("(%d * %d) + (%d * %d) \n", aryA[i][0], aryB[0][j], aryA[i][1], aryB[1][j] );

            // aryC[i][j] = (aryA[i][0] * aryB[0][j]) + (aryA[i][1] * aryB[1][j]);
            // cout << aryC[i][j];
            // if(j != l - 1){
            //     cout << " ";
            // }
            aryC[i][j] = 0;
            for(int k = 0; k < m; k++){
                // cout << (long)aryA[i][k] * (long)aryB[k][j] << endl;
                aryC[i][j] += (aryA[i][k] * aryB[k][j]);
                // cout << aryC[i][j] << endl;
            }
            cout << aryC[i][j];
            if(j != l - 1){
                cout << " ";
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3300
#include<cstdio>
#include<iostream>
using namespace std;
const int Maxn=300000+20;
int n,tot;
int a[Maxn],b[Maxn];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		tot^=a[i];
	}
	for(int i=1;i<=n;++i)
	{
		b[i]=tot^a[i];
		printf("%d ",b[i]);
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 5348
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REP2D(i,j,h,w) for(long long i=0;i<h;i++) for(long long j=0;j<w;j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=h;i++) for(long long j=1;j<=w;j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) (a.begin()),(a.end())
#define RANGE(a) (a),(a+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<a<<endl;
#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << a << endl
#define DBSTART if(1){
#define DBEND }
#else
#define DBPRT(a) do{}while(0)
#define DBSTART if(0){
#define DBEND }
#endif
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 100000
//---------------------

ll a,b,c,d;
int main(){
	cin >> a >> b>>c>>d;

	if(a==c) cout << 0 <<endl;
	else cout << 1 <<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
int main(){
int N,K,X,Y;
std::cin >> N >> K >> X;
if(N==K && K==X)
std::cout << 1 << std::endl;
else if(N!=K && K!=X && X!=N)
std::cout << 3 << std::endl;
else
std::cout << 2 << std::endl;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from scipy.sparse.csgraph import floyd_warshall
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush, heapify
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def main():
    n = int(input())
    a = list(map(int,input().split()))
    ans = 0
    for i in range(n):
        if i%2==0 and a[i]%2 == 1:
            ans += 1
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 77228
N = int(input())
i=0
while i < N:
 x,y,z = map(int,input().split())
 if x<=z and y<=z: 
     if z**2 == x**2+y**2: print("YES")
     else: print("NO")
 elif x<=y and z<=y:
     if y**2 == x**2+z**2: print("YES")
     else: print("NO")
 else: 
     if x**2 == y**2+z**2: print("YES")
     else: print("NO")

 i += 1


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



int main() {
  int dp[100010];
  dp[0] = 0;
  for ( int n = 1; n <= 100000; n++ ) {
    dp[n] = 1e9;
    int power = 1;
    while ( power <= n ) {
      dp[n] = min(dp[n],dp[n-power]+1);
      power *= 6;
    }
    power = 1;
    while ( power <= n ) {
      dp[n] = min(dp[n],dp[n-power]+1);
      power *= 9;
    }    
  }
  int N;  cin >> N;
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[200111];
int B[200111];
int ans;

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);
    REP (i, N) scanf("%d", B+i);

    REP (t, 31) {
	LL bit = 1LL<<t;
	LL base = 2LL<<t;
	vector<LL> v;
	REP (i, N) {
	    int val = A[i] & (base-1);
	    v.push_back(val);
	}
	sort(v.begin(), v.end());
	int cnt = 0;
	REP (i, N) {
	    LL val = B[i] & (base-1);
	    int tmp = 0;
	    // [bit, base);
	    tmp += lower_bound(v.begin(), v.end(), base - val)
		- lower_bound(v.begin(), v.end(), bit - val);
	    tmp += lower_bound(v.begin(), v.end(), base + base - val)
		- lower_bound(v.begin(), v.end(), base + bit - val);

	    cnt += tmp;
	}

	if (cnt & 1) ans ^= bit;
    }
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

int main(void) {
    int cnt[32] = {};
    string w;
    bool ans = true;
    cin >> w;
    for (int i = 0; i < w.size(); i++) {
        cnt[w[i] - 'a']++;
    }
    for (int i = 'a'; i <= 'z'; i++) {
        if (cnt[i - 'a'] % 2) {
            ans = false;
            break;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cerrno>
#include <cfenv>
#include <cstring>
#include <bitset>
#include <queue>
#include <iomanip>

using namespace std;
long long N,A,B;
long long ans = 0;
long long amari = 0;
long long shou = 0;
int main()
{
	cin >> N >> A >> B;

	amari = N % (A + B);
	shou = N / (A + B);
	if (amari<=A)
	{
		ans = shou * A + amari;
	}
	else
	{
		ans = shou * A + A;	
	}
	cout << ans;


}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func main() {
	a := readInt64Slice(5)

	zeroPosition := 0
	for i, v := range a {
		if v == 0 {
			zeroPosition = i
		}

	}
	fmt.Println(zeroPosition + 1)

}

var (
	scanner *bufio.Scanner
)

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

func readInt64Slice(n int64) []int64 {
	s := make([]int64, n)
	var t string

	for i := 0; i < int(n); i++ {
		if scanner.Scan() {
			t = scanner.Text()
		}

		num, err := strconv.ParseInt(t, 10, 64)
		if err != nil {
			log.Fatal(err)
		}
		s[i] = num
	}

	return s
}



Measured memory_bytes: 1820
count=0
def merge(A,left,mid,right):
    global count
    L=A[left:mid]+[10**9+1]
    R=A[mid:right]+[10**9+1] 
    i=0
    j=0
    for k in range(left,right):
        if L[i]<R[j]:
            A[k]=L[i]
            i+=1
        else:
            A[k]=R[j]
            j+=1
            count+=(mid-left-i)
       
def mergeSort(A,left,right):
    if left+1<right:
        mid=(left+right)//2
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)

n=int(input())
S=[int(i) for i in input().split()]
mergeSort(S,0,n)
print(count)


Measured memory_bytes: 27476
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    ll ans = 0;
    rep(i, n-2){
        if(s.substr(i,3) == "ABC")ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from math import sin,cos,pi
a,b,h,m = map(int,input().split())
def d(x0,y0,x1,y1):
    return ((x1-x0)**2+(y1-y0)**2)**(0.5)
t2 = ((h + (m/60))%12)/12*2*pi
t1 = (m/60)*2*pi
print(d(a*cos(t2),a*sin(t2),b*cos(t1),b*sin(t1)))

Measured memory_bytes: 9572
// Jump, and you will find out how to unfold your wings as you fall.

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn=21,mod=1e9+7;
const ll inf=1e18;

int dp[1<<maxn];
bool is[maxn][maxn];

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
	    cin>>is[i][j];
	}
    }
    dp[0]=1;
    for(int msk=1;msk<(1<<n);msk++){
	int id=__builtin_popcount(msk)-1;
	for(int i=0;i<n;i++){
	    if(bit(msk,i) && is[i][id])
		dp[msk]=(dp[msk]+dp[msk ^ (1<<i)])%mod;
	}
    }
    return cout<<dp[(1<<n)-1]<<endl,0;
}
// Deathly mistakes:
//  * Read the problem curfully.
//  * Check maxn.
//  * Overflows.


Measured memory_bytes: 8448
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  long n,ii,jj,kk,rr;
  long k,max,sum,dropNum;
  vector<long> v,box;
  max = 0;
  cin >> n >> k;
  
  v.resize(n);
  //box.resize(k);
  for(ii=0;ii<n;ii++){
    cin >> v[ii];
  }

  if(n>=k){
    dropNum = k;
  }
  else{
    dropNum = n;
  }
  //右からとる個数
  for(rr=0;rr<=dropNum;rr++){

    // 左からとる個数
    for(ii=0;ii<=dropNum-rr;ii++){
      sum = 0;
      box.clear();

      //左から取る
      for(jj=0;jj<ii;jj++){
	box.push_back(v[jj]);
      }
      
      //右から取る
      for(jj=0;jj<rr;jj++){
	box.push_back(v[(n-1)-jj]);
	if(jj==0){
	  //cout << "(k-1)-jj:" << ((n-1)-jj) << "v:" << v[(n-1)-jj] << endl;
	}
      }

      sort(box.begin(),box.end());
	
      //取った宝石の価値を数える
      for(jj=0;jj<ii+rr;jj++){
	sum += box[jj];
      }

      //cout << "sum:" << sum << "---";
      long num;

      //取れる個数と取った個数の小さい方を選択
      if(k-ii-rr<box.size()){
	num = k-ii-rr;
      }
      else{
	num = box.size();
      }


      //マイナスの部分を取る
      for(jj=0;jj<num;jj++){
	//cout << "jj:" << jj << endl;
	if(box[jj] < 0){
	  sum -= box[jj];
	}
      }
      if(sum > max){
	max = sum;
      }
      
      //cout << "ii:" << ii << "rr:" << rr << "sum:" << sum << endl;
    }
  }  
  cout << max << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i,a[100];
  scanf("%d",&n);
  for(i=0;i < n;i++){
    scanf("%d",&a[i]);
  }
  if(n >= 1){
    printf("%d",a[n-1]);
  }
  for(i=n-2;i>=0;i--){
    printf(" %d",a[i]);
  }
  putchar('\n');
  return 0;
}



Measured memory_bytes: 2092
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1000000007;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
	int n;
	string s;
	cin >> n >> s;
	string r = s.substr(1,n-1);
	int ans = s.size();
	int tmp = 0;
	for (int i = 0; i < r.size(); i++) {
		if (r[i] == 'E') {
			tmp++;
		}
	}
	ans = tmp;
	for (int i = 1; i < n; i++) {
		if(s[i-1] == 'W') {
			tmp++;
		}
		if (s[i] == 'E') {
			tmp--;
		}
		ans = min(ans,tmp);
	}
	cout << ans;
	return 0;
}


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

const string temp[5] = {"(((AaB)bC)cD)",
			"((Aa(BbC))cD)",
			"((AaB)b(CcD))",
			"(Aa((BbC)cD))",
			"(Aa(Bb(CcD)))"};
string s;
int pos;
int fact();
int term();
int exp();

int fact() {
  int x;
  if(s[pos] == '(') {
    ++pos;
    x = exp();
    ++pos;
  } else if(isdigit(s[pos])) {
    x = s[pos]-'0';
    ++pos;
  }
  return x;
}

int term() {
  int x = fact();
  while(s[pos] == '*') {
    ++pos;
    x *= fact();
  }
  return x;
}

int exp() {
  int x = term();
  while(s[pos] == '+' || s[pos] == '-') {
    char op = s[pos++];
    if(op == '+') {
      x += term();
    } else if(op == '-') {
      x -= term();
    }
  }
  return x;
}

int main() {
  while(1) {
    int a[4];
    for(int i = 0; i < 4; ++i) {
      cin >> a[i];
    }
    if(a[0]|a[1]|a[2]|a[3]) ; else break;
    sort(a,a+4);
    bool flag = true;
    do {
      char conv[128];
      for(int i = 0; i < 4; ++i) {
	conv['A'+i] = a[i]+'0';
      }
      for(int t = 0; flag && t < 27; ++t) {
	for(int i = 0, tmp = t; i < 3; ++i) {
	  char &op = conv['a'+i];
	  switch(tmp%3) {
	  case 0: op = '+'; break;
	  case 1: op = '-'; break;
	  case 2: op = '*'; break;
	  }
	  tmp /= 3;
	}
	for(int k = 0; flag && k < 5; ++k) {
	  pos = 0;
	  s = temp[k];
	  for(int j = 0; j < s.size(); ++j) {
	    if(isalpha(s[j])) s[j] = conv[s[j]];
	  }
	  if(exp() == 10) {
	    cout << s << endl;
	    flag = false;
	  }
	}
      }
    } while(flag && next_permutation(a,a+4));
    if(flag) cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
//	-*- mode: C++ -*-
//	Card Game
//
//		Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner obtains 3 points. In the case of a draw, they obtain 1 point each.
//
//		Write a program which reads a sequence of cards Taro and Hanako have and reports the final scores of the game.
//
//	Input
//		In the first line, the number of cards n is given. In the following n lines, the cards for n turns are given respectively. For each line, the first string represents the Taro's card and the second one represents Hanako's card.
//
//	Constraints
//		n ≤ 1000
//		The length of the string ≤ 100
//	Output
//		Print the final scores of Taro and Hanako respectively. Put a single space character between them.
//
//	Sample Input
//		3
//		cat dog
//		fish fish
//		lion tiger
//	Sample Output
//		1 7

#include <iostream>
#include <string>
#include <utility>

int	main(int	argc,
		 char*	argv[])
{
	const unsigned int	win		{3};
	const unsigned int	draw	{1};

	std::pair<unsigned int, unsigned int>	score	{0, 0};

	unsigned int	count	{0};

	std::cin >> count;

	for(unsigned int i = 0; i < count; i++){
		std::string	first	{};
		std::string	second	{};

		std::cin >> first >> second;

		int	cmp	= first.compare(second);
		if(cmp > 0){
			score.first		+= win;
		}
		else if(cmp < 0){
			score.second	+= win;
		}
		else{
			score.first		+= draw;
			score.second	+= draw;
		}
	}

	std::cout <<  score.first << ' ' << score.second << '\n';
    return 0;
}



Measured memory_bytes: 3152
require 'prime'

n = gets.strip.to_i

dim=Array.new(n+1, 0)
(1..n).each do |c|
  c.prime_division.each do |b, d|
    dim[b]+=d
  end
end

result=0
target_pairs = [[5,5,3], [15, 5], [25,3], [75]]

targets = dim.select {|e| e>0 }
targets.length.times do |i|
end

targets.combination(3).each do |a, b, c|
  result+=1 if (a>=4 && b>= 4 && c >= 2)
  result+=1 if (a>=4 && b>= 2 && c >= 4)
  result+=1 if (a>=2 && b>= 4 && c >= 4)
end

targets.combination(2).each do |a, b|
  [ [14, 4], [24, 2] ].each do |t1, t2|
    result+=1 if (a>=t1 && b>= t2)
    result+=1 if (a>=t2 && b>=t1)
  end
end

result+=targets.select {|e| e>=74 }.length

p result
#p targets


Measured memory_bytes: 3964
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
vector<int> e[100000];

vector<int> v;
bool dfs(int n, int p){
	if(n == N-1){
		v.pb(n);
		return true;
	}
	rep(i, e[n].size()){
		if(e[n][i] == p) continue;
		bool tmp = dfs(e[n][i], n);
		if(tmp){
			v.pb(n);
			return true;
		}
	}
	return false;
}

int siz(int n, int p){
	int ret = 1;
	rep(i, e[n].size()){
		if(e[n][i] == p) continue;
		ret += siz(e[n][i], n);
	}
	return ret;
}

signed main(){
	cin >> N;
	rep(i, N-1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		e[a].pb(b);
		e[b].pb(a);
	}

	dfs(0, -1);
	reverse(all(v));
	
	if(siz(v[(v.size()-1)/2], v[(v.size()-1)/2+1]) > siz(v[(v.size()-1)/2+1], v[(v.size()-1)/2])){
		cout << "Fennec" << endl;
	}
	else cout << "Snuke" << endl;
}

Measured memory_bytes: 11004
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_A
// Graph I - Depth First Search

#define SUBMIT

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <limits>
#include <numeric>
#include <functional>
#include <set>
#include <cmath>
#include <cstring>
#include <climits>
#include <memory>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const ui64 MAX_N = 100;

enum class color_type {
    white,
    gray,
    black
};

int adj[MAX_N][MAX_N];
color_type color[MAX_N];
int find_time[MAX_N];
int complete_time[MAX_N];
int n;
int curr_time;

void dfs(int u) {
    curr_time++;
    color[u] = color_type::gray;
    find_time[u] = curr_time;

    // search adj nodes
    for (int v = 0; v < n; ++v) {
        if (adj[u][v] != 0 && color[v] == color_type::white) dfs(v);
    }
    curr_time++;
    color[u] = color_type::black;
    complete_time[u] = curr_time;
}

void run_dfs() {
    for (int v = 0; v < n; ++v) {
        color[v] = color_type::white;
        find_time[v] = 0;
        complete_time[v] = 0;
    }

    curr_time = 0;
    for (int v = 0; v < n; ++v) {
        if (color[v] == color_type::white) dfs(v);
    }
}

int main() {
    memset(adj, 0, sizeof(adj));
    cin >> n;

    int u, degree;
    for (int i = 0; i < n; ++i) {
        cin >> u >> degree;
        u--; // 0-origin

        int v;
        for (int j = 0; j < degree; ++j) {
            cin >> v;
            v--; //0-origin
            adj[u][v] = 1;
        }
    }

    run_dfs();
    for (int i = 0; i < n; ++i) cout << i + 1 << " " << find_time[i] << " " << complete_time[i] << endl;
    return 0;
}


Measured memory_bytes: 3152
//usr/bin/env picoc $0 - $@;exit
#include <stdio.h>
int main(){
	int n,a,b,r=0,i,j;
	scanf("%d%d%d",&n,&a,&b);
	for(i=1;i<=n;i++){
		int s=0;
		j=i;
		for(;j;j/=10)s+=j%10;
		if(a<=s&&s<=b)r+=i;
	}
	printf("%d\n",r);
	return 0;
}


Measured memory_bytes: 128
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (998244353)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
ll inv[400003],mult[400003],invmult[400003];
ll gcd(ll a,ll b){
	while(b!=0){
		
		a=a%b;
		swap(a,b);
	}
	return a;
}
 
ll extend_gcd(ll a,ll b,ll &x,ll &y){
	if(b==0){
		x=1;
		y=0;
		return a;
	}
	ll x1,y1;
	ll ans =extend_gcd(b,a%b,x1,y1);
	x=y1;
	y=x1-(a/b)*y1;
 
	return ans;
}
 
ll combination(ll n,ll r){
	if(r==0)
		return 1;
	if(n<r)
		return 0;
	ll ans=1;
	ans*=mult[n];
	ans%=mod;
	ans*=invmult[r];
	ans%=mod;
	ans*=invmult[n-r];
	ans%=mod;
	return ans;
}
 
ll initcombi(){
	int i;
	f(i,1,400001){
		ll x,y;
		ll val=extend_gcd(mod,i,x,y);
		if(y>0)
			inv[i]=y%mod;
		else{
				inv[i]=(y+mod)%mod;
		}
	}
	mult[0]=1;
	f(i,1,400001){
		mult[i]=mult[i-1]*i;
		mult[i]%=mod;
	}
	invmult[0]=1;
	f(i,1,400001){
		invmult[i]=invmult[i-1]*inv[i];
		invmult[i]%=mod;
	}
	return 0;
}
 

int main(){
    std::ios::sync_with_stdio(false);
 	initcombi();
 	//int i;
 	ll n,a,b,k;
 	cin>>n>>a>>b>>k;
 	ll gg=__gcd(a,b);
 	a/=gg;
 	b/=gg;
 	if(k%gg){
 		cout<<0<<endl;
 		return 0;
 	}   
 	k/=gg;
 	ll i,val,flag=0,sol=0;
 	rep(i,b){
 		val=k-i*a;
 		if(val<0){
 			break;
 		}
 		if(val%b==0){
 			sol=i;
 			flag=1;
 			break;
 		}
 	}
 	if(flag==0){
 		cout<<0<<endl;
 		return 0;
 	}
 	ll ans=0,haha;
 	while(sol<=n){
 		val=k-sol*a;
 		haha=val/=b;
 		if(haha>=0  && haha<=n){
 			ans+=combination(n,sol)*combination(n,haha);
 			ans%=mod;
 		}
 		sol+=b;
 	}
 	cout<<ans<<endl;

    
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
 int n;
string a,b;
int main() {
  	cin >>n >>a>>b;
  	string ans="";
  
   for(int i=0;i<n;i++) {
     ans += a[i];
     ans += b[i];
   }
  
  cout << ans << endl;
	return 0;  
}

Measured memory_bytes: 256
/*****************************************************
 *     created by: nayakashutosh9
 * "Winners Never Quit and Quitters Never Win".
*****************************************************/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 300005;
/**********************************************************************************************/

void solve() {
	int a, b, c, k; cin >> a >> b >> c >> k;
	int ans = 0;
	if (k > 0 && a > 0) {
		if (a >= k) ans += k, k = 0;
		else ans += a, k -= a;
	}
	if (k > 0 && b > 0) {
		if (b >= k) k = 0;
		else k -= b;
	}
	if (k > 0 && c > 0) {
		if (c >= k) ans -= k, k = 0;
		else ans -= c, k -= c;
	}
	cout << ans << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1, z = 1;
	// cin >> t; cin.ignore();
	while (t--) {
		// cout << "Case #" << (z++) << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10000)

N,M = map(int, input().split())
a = [int(input()) for i in range(M)]

def fib(n):
        a, b = 0, 1
        for i in range(n):
            a, b = b, a + b
        return b if n >= 0 else 0

if M == 0:
    ans = fib(N) % (10**9+7)


elif M == 1:
    ans = fib(a[0]-1) * fib(N-a[0]-1)
    ans %= (10**9+7)

else:
    ans = fib(a[0]-1)
    for i in range(M-1):
        ans = (ans * fib(a[i+1]-a[i]-2))%(10**9+7)

    ans = (ans * fib(N-a[-1]-1))%(10**9+7)

print(ans)

Measured memory_bytes: 7076
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ACalc {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int a; cin >> a;
      cout << a + a*a  + a*a*a << endl;
    }
};

signed main() {
  ACalc solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3568
#include <stdio.h>

int main(void){

  int p,q,r;
  scanf("%d %d %d", &p, &q, &r);

  int answer = p+q+r;
  int max = p;
  if (q > max) {
    max = q;
  }
  if (r > max) {
    max = r;
  }
  answer -= max;
  printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b;
  cin >> a >>b;
  if(a > b)
  {
    cout << 2*a-1;
  }
  else if(b > a)
  {
  	cout << 2*b-1;
  }
  else
  {
    cout << a + b; 
  }
    
}

Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int n, c[N];
vector<pair<int,int>> adj[N];

void dfs(int u, int p, int col) {
	c[u] = col;
	for(auto v : adj[u]) {
		if(v.first == p) continue;
		dfs(v.first, u, col ^ v.second);
	}
}	

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

	cin >> n;

	for(int i = 0; i < n - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		w = w & 1;
		u--;
		v--;
		adj[u].push_back(make_pair(v, w));
		adj[v].push_back(make_pair(u, w));
	}

	dfs(0, 0, 0);

	for(int i = 0; i < n; i++) cout << c[i] << "\n";

	return 0;
}


Measured memory_bytes: 8448
import bisect
 
a,b,q = map(int,input().split())
inf = 10**18
S = [-inf]+[int(input()) for _ in range(a)]+[inf]
T = [-inf]+[int(input()) for _ in range(b)]+[inf]
ans = inf
for _ in range(q):
  x = int(input())
  b,d = bisect.bisect_right(S,x),bisect.bisect_right(T,x)
  ans = inf
  for s in [S[b-1],S[b]]:
    for t in [T[d-1],T[d]]:
      tmp1,tmp2 = abs(s-x)+abs(s-t) ,abs(t-x)+abs(t-s)
      ans = min(ans ,tmp1,tmp2)
  print(ans)
      



Measured memory_bytes: 13840
#include <iostream>
#include <queue>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <array>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int H,W;
string board[405];
int memo[405][405][2];
bool used[405][405];
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
bool overbound(int y,int x)
{
  if(y>=H || y<0 || x>=W || x<0) return true;
  else return false;
}

bool check(int y,int x,int d)
{
  int ny=y+dy[d];
  int nx=x+dx[d];
  if(overbound(ny,nx)) return false;
  if(board[y][x]==board[ny][nx]) return false;
  else return true;
}

int main(int argc,char const* argv[])
{
  ll ans=0;
  ll b=0,w=0;
  memset(memo,-1,sizeof(memo));
  memset(used,false,sizeof(used));
  cin >> H >> W;
  for(int i=0;i<H;i++)
    {
      cin >> board[i];
    }
  for(int y=0;y<H;y++)
    {
      for(int x=0;x<W;x++)
	{
	  if(used[y][x]) continue;
	  b=0,w=0;
	  queue<P> que;
	  used[y][x]=true;
	  que.push(P(y,x));
	  while(!que.empty())
	    {
	      P p=que.front();
	      que.pop();
	      int nowy=p.first;
	      int nowx=p.second;
	      if(board[nowy][nowx]=='#')b++;
	      else w++;
	      for(int d=0;d<4;d++)
		{
		  if(!check(nowy,nowx,d)) continue;
		  int ny=nowy+dy[d];
		  int nx=nowx+dx[d];
		  if(used[ny][nx]) continue;
		  used[ny][nx]=true;
		  que.push(P(ny,nx));
		}
	    }
	  ans+=b*w;
	}
    }
  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int power(int a, int b){
	int res=1;
	while(b>0){
		if(b&1){
			res=res*a%MOD;
		}
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a;
	cin>>n;
	int ans=1;
	REP(i, n){
		cin>>a;
		if(a%2==0){
			ans*=2;
		}
	}
	cout<<power(3, n)-ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
use std::collections::HashMap;
fn main() {
    let n: usize = read();
    let mut hs = HashMap::new();
    for _ in 0..n {
        let s: String = read();
        *hs.entry(s).or_insert(0) += 1;
    }
    for s in &["AC", "WA", "TLE", "RE"] {
        println!("{} x {}", s, hs.entry(s.to_string()).or_insert(0));
    }
}

Measured memory_bytes: 2192
s=input()

sodd=0
sevn=0

for i in range(len(s)):
    if i%2==0:
        if s[i]=="0":
            sevn+=1
        else:
            sodd+=1
    else:
        if s[i]=="1":
            sevn+=1
        else:
            sodd+=1

print(min(sodd,sevn))
        

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define MOD 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(var) (var).begin(), (var).end()
#define MAXX 9000000000000000000
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> > 
#define vvpi vector<vector<pair<int,int> > >

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int c;
	cin >> c;
	if(c < 600)
	{
		cout << 8;
	}
	else if(c < 800)
	{
		cout << 7;
	}
	else if(c < 1000)
	{
		cout << 6;
	}
	else if(c < 1200)
	{
		cout << 5;
	}
	else if(c < 1400)
	{
		cout << 4;
	}
	else if(c < 1600)
	{
		cout << 3;
	}
	else if(c < 1800)
	{
		cout << 2;
	}
	else 
	{
		cout << 1;
	}









	
	return 0;
}

Measured memory_bytes: 3652