akhauriyash/Code-Regression huggingface dataset:
h,w,d = map(int, input().split( ))
a = [list(map(int, input().split( ))) for i in range(h)]

p = [() for i in range(h*w)]

for i in range(h):
    for j in range(w):
        a[i][j] -= 1###
        p[a[i][j]] = (i,j)

def mp(a,b):
    return abs(a[0]-b[0])+abs(a[1]-b[1])

p2 = [p[i::d] for i in range(d)]
p3 = [[mp(p2[j][i+1],p2[j][i]) for i in range(len(p2[j])-1)] for j in range(d)]
p4 = [[0] for j in range(d)]

for j in range(d):
    sm = 0
    for i in range(len(p3[j])):
        sm += p3[j][i]
        p4[j].append(sm)


q = int(input())

for i in range(q):
    li,ri = map(int,input().split( ))
    li-=1;ri-=1;##a[i]を取得したときに1引いているのでそろえる、これどちらかに統一したほうが
    j = li%d

    print(p4[j][ri//d]-p4[j][li//d])


Measured memory_bytes: 73452
#include <iostream>

int main()
{
    int a,hanako = 0,tosiki = 0;
    std::cin >> a;
    std::string str1,str2;
    for(int b = 0; b < a;b++){
        std::cin >> str1;
        std::cin >> str2;
        if(str1 < str2){
            tosiki = tosiki + 3;
        }
        if(str1 > str2){
            hanako = hanako + 3;
        }
        if(str1 == str2){
            tosiki++;
            hanako++;
        }
    }
    std::cout << hanako <<" "<<tosiki<<std::endl;
    return 0;
}

Measured memory_bytes: 3216
from collections import deque
n=int(input())
tree=[[] for _ in range(n)]
for i in range(n-1):
  a,b,c=map(int,input().split())
  tree[a-1].append([b-1,c])
  tree[b-1].append([a-1,c])
q,k=map(int,input().split())
dis=[-1 for i in range(n)]
dis[k-1]=0
que=deque()
que.append(k-1)
while que:
  x=que.popleft()
  for i,c in tree[x]:
    if dis[i]==-1:
      que.append(i)
      dis[i]=dis[x]+c
for i in range(q):
  x,y=map(int,input().split())
  print(dis[x-1]+dis[y-1])

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 200005;
int n, a[MX];
ll res;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	forn (i, n) cin >> a[i];
	sort(a, a + n, greater<int>());

	forn (i, n) res += a[i / 2];
	res -= a[0];

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 4444
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    a, b = input().split()
    n = int(a+b)
    if math.sqrt(n) % 1 == 0:
        print("Yes")
    else:
        print("No")
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 10420
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
	
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int ans = 0,n,m;
bool is_visited[50] = {false},G[50][50] = {false},visitedlist[50] = {false};

void dfs(int v,int cnt){
	
	is_visited[v] = true;
	visitedlist[v] = true;
	
	rep(i,0,n){
		if(!is_visited[i] && G[v][i]){
			dfs(i,cnt+1);
		}
	}
	
	is_visited[v] = false;
}

int main(){
	int closing = 0,a[50],b[50];
	cin >> n >> m;
	
	rep(i,0,m){
		cin >> a[i] >> b[i];
		a[i]--;b[i]--;
		G[a[i]][b[i]] = G[b[i]][a[i]] = true;
	}
	
	rep(i,0,m){
		rep(j,0,50){
			is_visited[j] = false;
			visitedlist[j] = false;
		}
		G[a[i]][b[i]] = G[b[i]][a[i]] = false;
		dfs(0,0);
		G[a[i]][b[i]] = G[b[i]][a[i]] = true;
		
		rep(j,0,n){
			if(!visitedlist[j]){
				break;
			}
			else if(j == n-1){
				ans++;
			}
		}
	}
	
	cout << m-ans << endl;
	
	
  	return 0;
}





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

int main() {
    int n, m;
    cin >> n >> m;
    long long sum=0;
    for (int i=0; i<m; i++) {
        long long num; cin >> num;
        sum+=num;
    }
    if (sum>n) cout << -1 << endl;
    else cout << n-sum << endl;
}

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

int main() {
    //freopen("mvcoin.inp", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    if ((b-a-1)%2==0) {
        cout << "Borys\n";
    }
    else {
        cout << "Alice\n";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> ans;
  for(int i=0;i<n;i+=2){
    ans.pb(a[i]);
  }
  reverse(ans.begin(),ans.end());
  for(int i=1;i<n;i+=2){
    ans.pb(a[i]);
  }
  if(n%2==0){
    reverse(ans.begin(), ans.end());
  }
  rep(i,n){
    if(i!=0) cout << " ";
    cout << ans[i];
  }
  cout << endl;

  return 0;
}


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

const int MAX = 2001;
const int MOD = 1000000007;

void    ComInit(vector<long> &fac, vector<long> &finv, vector<long> &inv) {
    fac.at(0) = 1;
    fac.at(1) = 1;
    finv.at(0) = 1;
    finv.at(1) = 1;
    inv.at(1) = 1;
    for (int i=2; i<MAX; i++) {
        fac.at(i) = (fac.at(i-1)*i) %MOD;
        inv.at(i) = MOD - (inv.at(MOD%i)*(MOD/i)) %MOD;
        finv.at(i) = (finv.at(i-1)*inv.at(i)) %MOD;
    }
}

long    COM(int N, int K, vector<long> &fac, vector<long> &finv) {
    if (N<K)
        return 0;
    if ((N<0)||(K<0))
        return 0;
    return (fac.at(N) * ((finv.at(K)*finv.at(N-K)) %MOD)) %MOD;
}

int main() {
    // Array
    vector<long> fac(MAX);
    vector<long> finv(MAX);
    vector<long> inv(MAX);
    // Initialize
    ComInit(fac, finv, inv);
    int n, k;
    cin >>n >>k;
    cout <<COM(n-1, n-k, fac, finv) <<endl;
    return 0;
}



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

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

    int n;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    
    int b[n];
    
    // rep(i,n){
    //     cout << a[n-i-1] << "|";
    // }
    // cout << endl;
    
    for(int i=n; i>=1; i--){
        int sum = 0;
        int j = 2;
        
        while(i * j <= n){
            sum += b[i*j-1];
            j++;
        }
        
        if(sum % 2 == a[i-1]){
            b[i-1] = 0;
        }else{
            b[i-1] = 1;
        }
        
        // cout << sum % 2 << "=";
        // cout << j-1 << "-";
            // cout << sum << "|";
    }
    
    vector<int> ans;
    int count = 0;
    
    rep(i,n){
        if(b[i] == 1){
            count++;
            ans.push_back(i+1);
        }
    }
    
    cout << count << endl;
    rep(i, ans.size()){
        cout << ans[i] << " ";
    }
    
    return 0;
}

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

int main()
{
    long long H, W;
    cin >> H >> W;

    if (H == 1 || W == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    long long ans = W * (H / 2);
    if (H % 2 == 1)
    {
        ans += (W + 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import itertools

def has_duplicates(seq):
    return len(seq) != len(set(seq))

N = int(input())

if N < 3:
  print('0')
else:
 numList = list(map(int,input().split()))
 cnt = 0
 comblist = itertools.combinations(numList,3)
 for pair  in comblist:
  if has_duplicates(pair):  
   continue
  else:
   if (pair[0] + pair[1] > pair[2]) and (pair[0] + pair[2] > pair[1]) and (pair[1] + pair[2] > pair[0]):
    cnt = cnt + 1
 print(cnt)

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
//auto->.
//map<int,int>::iterator i

vector<int> sieve(int n) 
{ 

    vector<bool> prime(n+1,true); 
       
    prime[0] = false; 
    prime[1] = false; 
    int m = sqrt(n); 
   vector<int> ans;
    for (int p=2; p<=m; p++) 
    { 
    
        if (prime[p]) 
        { 
         
            for (int i=p*2; i<=n; i += p) 
            prime[i] = false; 
        } 
    }  
    //vector<int> ans; 
    for (int i=0;i<n;i++) 
        if (prime[i]) 
            ans.push_back(i); 
    return ans; 
}

int gcd(int a,int b)
{
	if(b==0) return a;
	return gcd(b,a%b);
}
int mod = 1e9 + 7;
int power(int a , ll b)
{
	int res = 1;
	while(b)
	{
		if(b & 1)
			res = 1LL * res * a % mod;
		a = 1LL * a * a % mod;
		b >>= 1;
	}
	return res;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
ll min(int a,ll b)
{
	if(a>b)
	return b;
	return a;
}
ll max(int a,ll b)
{
	if(a>b)
	return a;
	return b;
}
ll myXOR(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}
int conti(int x)
{
	if(x<1)
	return 0;
	if(x%4==0)
	return x;
	if(x%4==1)
	return 1;
	if(x%4==2)
	return x+1;
	if(x%4==3)
	return 0;
}
  
bool ispfsq(long double x) 
{   
  // Find floating point value of  
  // square root of x. 
  long double sr = sqrt(x); 
  
  // If square root is an integer 
  return ((sr - floor(sr)) == 0); 
}
ll cnt(ll x,ll lcm,ll m)
{
return (x/lcm)*m + min(m,x-(x/lcm)*lcm+1);

}
#define PI 3.141592653589793
int n;
int fen[1000010];
void update(int i,int d)
{
	fen[i]+=d;
	for(;i<n;i+=(i&(-1*i)))
	 fen[i]+=d;
}
int sum(int ind)
{
	int s=0;
	while(ind>0)
	{
		s+=fen[ind];
		ind-=ind&(-1*ind);
	}
	return s;
}
int a[30002],b[30002];
void solve()
{
int n,k;
cin>>n>>k;
int arr[n],dp[n];
for(int i=0;i<n;i++)
{
cin>>arr[i];
dp[i]=INT_MAX;
}
dp[0]=0;
for(int i=0;i<n;i++)
{
	for(int j=1;j<=k;j++)
	{
		if(i+j<n)
		{
			dp[i+j]=min(abs(arr[i]-arr[i+j])+dp[i],dp[i+j]);
		}
	}
}

cout<<dp[n-1];
}


   
/*void dfs(vector<int> adj[],bool visited[],int a)
{
	if(visited[a]==false)
	visited[a]=true;
	else
	return;
	v++;
	e+=adj[a].size();
	for(int i=0;i<adj[a].size();i++)
	{
		
		if(!visited[adj[a][i]])
		{
		
		dfs(adj,visited,adj[a][i]);

	      }
	}
	}	
*/	
	


/*int dfs(vector<int> adj[],int v,int c,int p)
{
//	cout<<p<<" "<<v<<" "<<c<<"\n";
	c+=arr[v];
	if(c>m)
	{
	return 0;
    }
	if(adj[v].size()==1&&v!=1)
	return 1;
	int a=0;
	for(int i=0;i<adj[v].size();i++)
	{
		if(adj[v][i]!=p)
		{
			
			int x=dfs(adj,adj[v][i],c*arr[adj[v][i]],v);
			a+=x;
		}
	}
	return a;
}
*/

int main()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//func();
int mul=0;
if(mul==1)
{
 int t;
 
    cin>>t;
   while(t--)
    {
		solve();
	cout<<"\n";
    }
}
else
{
	solve();
}
}

Measured memory_bytes: 1024
// とちゅう
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<int,ll> mp;
  rep(i,n) {
    int k;
    cin >> k;
    k--;
    a[i] = k;
    mp[a[i]]++;
  }
  ll cnt=0;
  for(auto p: mp) {
    if(p.second>1) cnt += p.second*(p.second-1)/2;
  }
  rep(i,n) {
    if (mp.at(a[i])>1) cout << cnt-(mp.at(a[i])-1) << endl;
    else cout << cnt << endl;
  }
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#define ll long long
#define pb push_back
using namespace std;


int main()
{
	ll int n,i,x;
	cin>>n;
	ll int f[n+1]={0};
	for(i=0;i<n-1;i++)
	{
		cin>>x;
		f[x]++;
		
	}
	for(i=1;i<n+1;i++)
	{
		cout<<f[i]<<endl;
	}
	
	
	
}



	
  
  

		
		
		
		
		
		
	
	
	 
		
		
	
	
	

	


	
	
	
   



Measured memory_bytes: 5156
#include "bits/stdc++.h"
using namespace std;
     
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
     
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main() {
  int n, i, j;
  cin >> n;
  vi a(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  int cnt = 0;
  vector<bool> used(n, false);
  used[0] = true;
  int now = 0;
  while (now != 1) {
    cnt++;
    now = a[now];
    if (used[now]) {
      cout << -1 << endl;
      return 0;
    }
    else {
      used[now] = true;
    }
  }
  cout << cnt << endl;
}
  


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

//********************************template END****************************************//

void solve(void){
	int N;
	cin >> N;
	if (N < 1200)
	{
		cout << "ABC" << endl;
	}
	else if(N < 2800)
	{
		cout << "ARC" << endl;
	}
	else
	{
		cout << "AGC" << endl;
	}
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range;R=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def MI():return map(int,input().split())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def Ra():return map(int,open(0).read().split())
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):
    #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in R(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in R(base**n):s=[tb//(base**bt)%base for bt in R(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def YN(x):print(['NO','YES'][x])
def Yn(x):print(['No','Yes'][x])
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase
sys.setrecursionlimit(10**9)
read=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()

########################################################################################################################################################################

show_flg=False
show_flg=True

ans=0

x,y=LI()

while y>=x:
    y>>=1
    ans+=1

print(ans)



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,k,c=0;
    cin >> a >> b >> k;
    for(int i=1;i<=min(a,b);i++) {
        if(a%i==0&&b%i==0) {
            c++;
        }
    }
    c++;
    for(int i=1;i<=min(a,b);i++) {
        if(a%i==0&&b%i==0) {
            c--;
        }
        if(c==k) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#! /usr/bin/env ruby

input = STDIN.read.split("\n").map{|l| l.split(" ").map{|i| i.to_i}}
input.shift

points = input.sort_by!{|p| -p[2]}

def get_center_height(cx, cy, px, py, ph)
  return ph + (px - cx).abs + (py - cy).abs
end

def is_center(cx, cy, points) 
  current_ch = nil
  for pt in points do
    px = pt[0]
    py = pt[1]
    ph = pt[2]

    if ph == 0 then
      checking_ch = current_ch - (px - cx).abs - (py - cy).abs
      ok = checking_ch <= 0
      if !ok then
        return false
      end
      next
    end

    ch = get_center_height(cx, cy, px, py, ph)

    if current_ch == nil then
      current_ch = ch
    elsif current_ch != ch then
      return false
    end
  end

  return ch
end

def get_center(points)
  for cx in 0..100 do
    for cy in 0..100 do
      is_center = is_center(cx, cy, points)
      if is_center != false
        return "#{cx} #{cy} #{is_center}"
      end
    end
  end
  return "No"
end

puts get_center(points)

Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

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

  rep(i, sz(S)) {
    S[i] += N;
    if (S[i] > 'Z')
      S[i] -= 26;
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        s[i] = ((s[i] - 'A') + n) % 26 + 'A';
    }
    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
class XorShift{
public:
  static int rand();
private:
  static unsigned int x;
  static unsigned int y;
  static unsigned int z;
  static unsigned int w;
  static unsigned int t;
};
unsigned int XorShift::x = 123456789;
unsigned int XorShift::y = 362436069;
unsigned int XorShift::z = 521288629;
unsigned int XorShift::w = 88675123;
unsigned int XorShift::t = 1;
 
int XorShift::rand()
{
  t = x ^ (x << 11);
  x = y;
  y = z;
  z = w;
  w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
  return w & 0x7fffffff;
}

void mainmain(){
	int n;
	cin>>n;
	vector<string> vs(n);
  vector<pii> v;
	rep(i,n){
    cin>>vs[i];
    int tmp=0;
    rep(j,vs[i].size()){
      if(vs[i][j]=='o'){
        tmp++;
      }
      else if(vs[i][j]=='x'){
        tmp--;
      }
    }
    // cout<<tmp<<endl;
    if(tmp==vs[i].size()-1){
      rep(j,1000){
        cout<<i+1<<endl;
        int t;
        cin>>t;
      }
      return;
    }
    v.PB(mkp(-tmp,i));
  }
  sort(ALL(v));
  vector<pii> tt;
  vint used(20,0);
  rep(i,v.size()){
    bool f=false;
    rep(j,vs[v[i].S].size()){
      if(used[j]==0&&vs[v[i].S][j]=='o'){
        f=true;
        used[j]=1;
      }
    }
    if(f) tt.PB(v[i]);
    f=true;
    rep(j,n){
      if(used[j]==0){
        f=false;
      }
    }
    if(f) break;
  }
  int t;
	rep(i,1000){
    t=XorShift::rand();
    // cout<<t<<endl;
    t%=tt.size();
    cout<<tt[t].S+1<<endl;
		cin>>t;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1332
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

X,Y=LI()
for i in range(0, X+1):
    if (i*2 + (X-i)*4) == Y:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 9256
n = int(input())

for __ in range(n):
    sentence = input()
    length = 0

    while True:
        try:
            sentence[length]
            length += 1
        except:
            break
    
    for i in range(length-6):
        if sentence[i] == "H":
            if sentence[i+1] == "o":
                if sentence[i+2] == "s":
                    if sentence[i+3] == "h":
                        if sentence[i+4] == "i":
                            if sentence[i+5] == "n":
                                if sentence[i+6] == "o":
                                    after = ""
                                    for j in range(i+6):
                                        after += sentence[j]
                                    after += "a"
                                    for j in range(i+7,length):
                                        after += sentence[j]
                                    sentence = after

    print(sentence)


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

int main()
{
    int n; cin >> n;
    vector<int> v(n);

    for(auto &x : v) cin >> x;

    for(auto it = v.crbegin(); it != v.crend(); ++it)
        cout << *it << (((it+1)==v.crend()? "" : " "));
    cout << endl;

    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX = 1e9;
ll ans;
ll h,w;
int main(int argc, char** argv) {
	ans = MAX;
	cin>>h>>w;
	
	if(h >= 2) {
		for(int i=1;i<h;i++) {
			ll a = w * i;
			if((h-i)%2==0 || w%2==0)ans = min(ans,abs(a - (w * h - w * i) / 2));
			else {
				
				if((h - i) > w) {
					ll t = (h - i) / 2;
					ll m = max(a,max(t * w, h*w - a - t*w));
					ll n = min(a,min(t*w,h*w-a-t*w));
					ans = min(ans,abs(m-n));
				}else{
					ll t = w / 2;
					ll m = max(a,max(t*(h-i),h*w-a-t*(h-i)));
					ll n = min(a,min(t*(h-i),h*w-a-t*(h-i)));
					ans = min(ans,abs(m-n));
				}
				//cout<<i<<" "<<ans<<endl;
			}
		}
	}
	
	if(w >= 2) {
		for(int i=1;i<w;i++) {
			ll a = h * i;
			if((w-i)%2==0 || h%2==0)ans = min(ans,abs(a - (w * h - h * i) / 2));
			else {
				if((w - i) > h) {
					ll t = (w - i) / 2;
					ll m = max(a,max(t * h, h*w - a - t*h));
					ll n = min(a,min(t * h, h*w - a - t*h));
					ans = min(ans,abs(m-n));
				}else{
					ll t = h / 2;
					ll m = max(a,max(t*(w-i),h*w-a-t*(w-i)));
					ll n = min(a,min(t*(w-i),h*w-a-t*(w-i)));
					ans = min(ans,abs(m-n));
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))

N = int(input())
bs = [int(input()) for _ in range(0, N)]

ans1 = [0, 0, 0]
ans2 = [0, 0, 0]
ans3 = [0, 0, 0]

def bingo_column():
    return ans1 == [1,1,1] or ans2 == [1,1,1] or ans3 == [1,1,1]

def bingo_row():
    if ans1[0] == 1 and ans2[0] == 1 and ans3[0] == 1:
        return True
    if ans1[1] == 1 and ans2[1] == 1 and ans3[1] == 1:
        return True
    if ans1[2] == 1 and ans2[2] == 1 and ans3[2] == 1:
        return True
    
    return False

def bingo_naname():
    if ans1[0] == 1 and ans2[1] == 1 and ans3[2] == 1:
        return True
    if ans1[2] == 1 and ans2[1] == 1 and ans3[0] == 1:
        return True
    return False

bingo = False
for b in bs:
    if b in A1:
        ix = A1.index(b)
        ans1[ix] = 1
    if b in A2:
        ix = A2.index(b)
        ans2[ix] = 1
    if b in A3:
        ix = A3.index(b)
        ans3[ix] = 1

    if bingo_column():
        bingo = True
    if bingo_row():
        bingo = True
    if bingo_naname():
        bingo = True

if bingo: 
    print('Yes')
else:
    print('No')

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

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; }

using ll = long long;

int main() {
  ll N;
  cin >> N;
  ll ans = 0LL;
  if (N % 2LL == 1LL) ans = 0LL;
  else {
    ll n = N / 2;
    while(n > 0) {
      n /= 5;
      ans += n;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
H, W = map(int, input().split())
cy, cx = map(int, input().split())
dy, dx = map(int, input().split())
maze = ['#'*(W+2)]
for hh in range(H):
    maze.append('#' + input() + '#')
maze.append('#'*(W+2))

stepx = [-1, 0, 1, 0]
stepy = [0, -1, 0, 1]
visited = [[0]*(W+2) for _ in range(H+2)]

deque2 = deque()
def floodfill(comp, src):
    count = 0
    while len(src) > 0:
        stak = []
        for (sy, sx) in src:
            #add to new component
            visited[sy][sx] = comp
            count += 1
            deque2.append((sy, sx))
            for i in range(4):
                ny, nx = sy + stepy[i], sx + stepx[i]
                if nx > 0 and nx <= W and ny > 0 and ny <= H\
                        and visited[ny][nx] == 0 and maze[ny][nx] == '.':
                    visited[ny][nx] = -1
                    stak.append((ny, nx))
        src = stak

    return count


def findnextz():
    nxt = []
    while len(deque2) > 0:
        (h, w) = deque2.popleft()
        for ii in range(-2, 3):
            nh = h + ii
            if nh > 0 and nh <= H:
                for jj in range(-2, 3):
                    nw = w + jj
                    if nw > 0 and nw <= W and visited[nh][nw] == 0 and maze[nh][nw] == '.':
                        visited[nh][nw] = -1
                        nxt.append((nh, nw))
    return nxt

def findnext(comp):
    count = 0
    nxt = []
    for h in range(1, H+1):
        for w in range(1, W+1):
            if visited[h][w] == comp:
                for ii in range(-2, 3):
                    nh = h + ii
                    if nh > 0 and nh <= H:
                        for jj in range(-2, 3):
                            nw = w + jj
                            if nw > 0 and nw <= W and visited[nh][nw] == 0 and maze[nh][nw] == '.':
                                visited[nh][nw] = -1
                                nxt.append((nh, nw))

    return nxt

ans = 0
total = 0
comp = 1

#floodfill source
if maze[cy][cx] == '.' and visited[cy][cx] == 0:
    count = floodfill(comp, [(cy, cx)])

# #floodfill dest
# if maze[dy][dx] == '.' and visited[dy][dx] == 0:
#     count = floodfill(comp, (dy, dx))
#     if count > 0:
#         total += count
#         comp += 1
#
#
while count > 0 and visited[dy][dx] <= 0:
    total += count
    #src = findnext(comp)
    src = findnextz()
    comp += 1
    if len(src) > 0:
        count = floodfill(comp, src)
    else: count = 0

print(visited[dy][dx] - 1)


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

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

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

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    for(int i=0; i<N; i++) {
        cin >> x.at(i);
    }

    int ans = INT32_MAX;
    for(int i=0; i+K-1<N; i++) {
        int left = i;
        int right = i+K-1;
        int left_distance = x[left];
        int right_distance = x[right];
        if(right_distance <= 0 || 0 <= left_distance) {
            ans = min(ans, max(abs(left_distance), abs(right_distance)));
        } else {
            ans = min(ans, abs(left_distance) + abs(right_distance) + min(abs(left_distance), abs(right_distance)));
        }
    }

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


Measured memory_bytes: 640
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
//别急 dp找状态 问题看看本身的规律 贪心找方法
char be[maxn];
char en[maxn];
int Xiaobo()
{
	string s;
	cin>>s;
	int q;
	cin>>q;
	int fz=0;
	int len1=0;
	int len2=0;
	while(q--) {
		int t,f;
		scanf("%d",&t);
		if(t==1) fz++;
		else{
			scanf("%d",&f);
			char c;
			cin>>c;
		//	DEBUG(c);
			if(fz%2) {
				if(f==1) en[len2++]=c;
				//s+=c;
				else be[len1++]=c;
				//s=c+s;
			}
			else {
				if(f==1) be[len1++]=c;
				//s=c+s;
				else en[len2++]=c;
				//s+=c;
			}
		}
	}
//	cout<<"\ngg\n";
//	for(int i=0;i<len1;i++)cout<<be[i];
//	cout<<"\ngg\n";
//	
//	cout<<"\ngg\n";
//	for(int i=0;i<len1;i++)cout<<be[i];
//	cout<<"\ngg\n";
	reverse(be,be+len1);
	s=be+s;
	s+=en;
	if(fz%2) reverse(s.begin(),s.end());
	cout<<s<<'\n';
	return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    int N;
    cin >> N;
    vchar S;
    int div = 2, i = 0;
    if (N == 0)
    {
        cout << 0;
        return 0;
    }
    while (N != 0)
    {
        if (N == 1)
        {
        }
        if (N % 2 == 0)
        {
            S.push_back('0');
        }
        else
        {
            S.push_back('1');
        }
        N -= pow(-1, i) * (S.back() - '0');
        N /= 2;

        i++;
    }
    reverse(all(S));

    rep(i, S.size())
    {
        if (!(i == 0 and S[i] == '0'))
            cout << S[i];
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#ifndef STOPIT
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;
#else
#define debug 0;
#endif

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, m; std::cin >> n >> m;
  std::cout << std::max(0, n - 2 * m) << std::endl;
  return 0;
}


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

int main(){
  
  string S;
  cin >> S;
  
  if(S.at(0)=='7' ||S.at(1)=='7' ||S.at(2)=='7')
    cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,x;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;
    
    int total,ans;
    ans=0;
    
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                total=500*i+100*j+50*k;
                if(total == x){
                    ans++;
                }
            }
        }
    }
    
    cout << ans << endl;
	
	return 0;
}


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

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = abs(a - c);
    int y = abs(b - d);
    int z = __gcd(x, y);
    cout << (x / z + y / z - 1) * z << endl;
    return 0;
}

Measured memory_bytes: 256
a,b,t,i;
main(N){
    long long c;
    for(scanf("%d",&N);N--;i++){
        scanf("%d",&t);
        a=i&&a<t?a:t;
        b=i&&b>t?b:t;
        c+=t;
    }
    printf("%d %d %lld\n",a,b,c);
}

Measured memory_bytes: 1776
#include <iostream>
using namespace std;
int main() {
string s, t;
cin >> s;
bool ans = false;
t = s[1];
t += s[0];
if (s[0] == s[1] && s[1] == s[2] && s[2] == s[3]) {
        ans = false;
} else if ((s[0] == s[1] && s[2] == s[3]) or
                (s.substr(0,2) == s.substr(2) or t == s.substr(2))) {
        ans = true;
}
if (ans) {
        cout << "Yes" << endl;
} else {
        cout << "No" << endl;
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    
    int A, B;
    cin >> A >> B;
    cout << max(A + B, max(A - B, A * B)) << endl;

    return 0;
}

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

const int MOD = 1000000007;


ll POWER(ll x,ll y)
{
	ll ret=1;
	ll p=x;
	for (ll i=y;i>0;i/=2)
	{
		if (i%2) ret=(ret*p)%MOD;
		p=(p*p)%MOD;
	}
	return ret;
}
ll gcm(ll a, ll b)
{
	if (b>a) {ll c=a; a=b; b=c;}
	while (b>0)
	{
		ll r=a%b;
		a=b;
		b=r;
	}
	return a;
}


int main(int argc, char *argv[])
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ret=0;
	if (k<=a) ret=k; else if (a+b>=k) ret=a; else ret=a-(k-a-b);
	

	cout<<ret<<endl;
	return 0;
}



Measured memory_bytes: 3632
A = [[0 for j in range(3)] for i in range(3)]


for i in range(3):
    A[i][0], A[i][1], A[i][2] = map(int, input().split())
    
N = int(input())

k = 0
flag = [[0 for j in range(3)] for i in range(3)]

b = [0] * N
for n in range(N):
    b[n] = int(input())
    for i in range(3):
        for j in range(3):
            #print('for')
            if(b[n] == A[i][j]):
                A[i][j] = 0
                #print('count',i+j+1)
            '''
            if(b[n] == A[i][j]): #該当箇所にフラグ1の配列をつくる
                flag[i][j] = 1
           
            '''
ans = 'No'

for i in range(3):            
    if(sum(A[i]) == 0):
        ans = 'Yes'

for j in range (3):
    if( A[0][j] + A[1][j] + A[2][j] == 0):
        ans = 'Yes'
        
if(A[0][0] + A[1][1] + A[2][2] == 0):
    ans = 'Yes'

if(A[0][2] + A[1][1] + A[2][0] == 0):
    ans = 'Yes' 
    
print(ans)

Measured memory_bytes: 3064
n, m = map(int, input().split())
ary_n = [input() for _ in range(n)]
s = "".join([input() for _ in range(m)])

ret = "No"
for x in range(n - m + 1):
    tmp = ""
    for y in range(n):
        tmp += ary_n[y][x:x+m]
    if tmp.find(s) >= 0:
        ret = "Yes"
        break
print(ret)

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

int main() {
  int N;
  long L0 = 2, L1 = 1, tmp;
  cin >> N;
  for (int i = 1; i < N; i++) {
    tmp = L0;
    L0 = L1;
    L1 = L1 + tmp;
  }
  cout << L1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int a,b,c,k;
  int temp,r;
  int temp1,temp2;
  int kei=0;
  scanf("%d",&k);

  for(a=1;a<=k;a++)
  {
    for(b=1;b<=k;b++)
    {
      for(c=1;c<=k;c++)
      {
        temp1=a;
        temp2=b;
        if(temp1<temp2)
        {
          temp=temp1;
          temp1=temp2;
          temp2=temp;
        }
        while((r=temp1%temp2)!=0)
        {
          temp1=temp2;
          temp2=r;
        }

        temp1=temp2;
        temp2=c;
        if(temp1<temp2)
        {
          temp=temp1;
          temp1=temp2;
          temp2=temp;
        }
        while((r=temp1%temp2)!=0)
        {
          temp1=temp2;
          temp2=r;
        }
        kei = kei +temp2;
      }
    }
  }
  printf("%d",kei);
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include<math.h>

using namespace std;


int main() {

    string S;
    cin >> S;


    int A, B, C, D;

    A = atoi(S.substr(0, 1).c_str());
    B = atoi(S.substr(1, 1).c_str());
    C = atoi(S.substr(2, 1).c_str());
    D = atoi(S.substr(3, 1).c_str());

    // + + +
    if (A + B + C + D == 7) {
        cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
        return 0;
    }

    // + + -
    if (A + B + C - D == 7) {
        cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
        return 0;
    }

    // + - +
    if (A + B - C + D == 7) {
        cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
        return 0;
    }

    // + - -
    if (A + B - C - D == 7) {
        cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
        return 0;
    }
    
    // - + +
    if (A - B + C + D == 7) {
        cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
        return 0;
    }

    // - + -
    if (A - B + C - D == 7) {
        cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
        return 0;
    }

    // - - +
    if (A - B - C + D == 7) {
        cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
        return 0;
    }

    // - - -
    if (A + B + C - D == 7) {
        cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
        return 0;
    }
}


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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  vector<string> b(m);
  int i, j, p, q;
  for(i = 0; i < n; i++)
  {
    cin >> a.at(i);
  }
  for(i = 0; i < m; i++)
  {
    cin >> b.at(i);
  }
  int check = 0;
  int s = 0;
  p = 0;
  q = 0;
  while(q <= n-m)
  {
    for(i = 0; i < m; i++)
    {
      for(j = 0; j < m; j++)
      {
        if(a.at(i+p).at(j+q)==b.at(i).at(j))
        {
          check++;
        }
      }
    }
    if(check == m*m)
    {
      s = 1;
      break;
    }
    else
    {
      check = 0;
      p++;
      if(p > n-m)
      {
        p = 0;
        q++;
      }
    }
  }
  if(s == 1)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 100001
using namespace std;
int a[maxn], b[maxn], m[maxn];
int main()
{
    int A, B, M, x, y, z;
    scanf("%d%d%d", &A, &B, &M);
    for (int i = 1; i <= A; i++)
        scanf("%d", a + i);
    for (int i = 1; i <= B; i++)
        scanf("%d", b + i);
    for (int i = 1; i <= M; i++)
    {
        scanf("%d%d%d", &x, &y, &z);
        m[i] = a[x] + b[y] - z;
    }
    sort(a + 1, a + A + 1);
    sort(b + 1, b + B + 1);
    sort(m + 1, m + M + 1);
    int ans = min(m[1], a[1] + b[1]);
    printf("%d", ans);
    return 0;
}

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

using namespace std;

int q = 0;

bool ok(int pos){
	q += 1;
	assert(q < 20);
	cout << pos << '\n';
	cout << flush;
	string res;
	cin >> res;
	if(res == "Vacant")	exit(0);
	else if(res == "Male") return 0;
	else return 1;
}

int main(){
	int N;
	cin >> N;
	int lo = 1, hi = N - 1;
	int v = ok(0);
	while(lo <= hi){
		int mid = (lo + hi) / 2;
		int k = ok(mid) ^ (mid & 1);
		if(k == v) lo = mid + 1;
		else hi = mid - 1;
	}
	return 0;
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x=0;
    int max=0;
    int n;
    cin>>n;
    vector<char> s(n);
    for(int i=0;i<n;i++){
        cin>>s.at(i);
    }
    for(int i=0;i<n;i++){
        if(s.at(i)=='I'){
            x++;
            if(x>max) max=x;
        }
        if(s.at(i)=='D'){
            x--;
            if(x>max) max=x;
        }
    }
    cout<<max<<endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;

int main()
{
    // freopen("input01.txt", "r", stdin);
    // freopen("output01.txt", "w", stdout);
    string s;
    cin >> s;
    int i, n = s.size(), ct = 0;
    int mem[n + 1] = {0};
    if (s[0] == 'R')
        mem[0] = 1, ct = 1;
    for (i = 1; i < n; i++)
    {
        if (s[i] == 'R')
            mem[i] = mem[i - 1] + 1;

        ct = max(ct, mem[i]);
    }

    cout<<ct;
    return 0;
}

Measured memory_bytes: 3620
fun main(args:Array<String>) {
    val n = readLine()!!.toInt()
    val (t,a) = readLine()!!.split(" ").map { it.toInt() }
    val pointList = readLine()!!.split(" ").map { it.toInt() }.let { a-> a.indices.map { Pos(it + 1, a[it]) }}.sortedBy { Math.abs(a - ( t - (0.006.toDouble() * it.takasa))) }
    println(pointList[0].idx)
}

class Pos(val idx:Int, val takasa:Int)

Measured memory_bytes: 37872
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#include<fstream>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

#define MAX_N 1000000
long long extgcd(long long a, long long b, long long& x, long long& y) {
	long long d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else {
		x = 1; y = 0;
	}
	return d;
}
long long mod_inverse(long long a, long long m) {
	long long x, y;
	if(extgcd(a, m, x, y) == 1) return (m + x % m) % m;
	else return -1;
}
vector<long long> fact(MAX_N+1, INF);
long long mod_fact(long long n, long long& e) {
	if(fact[0] == INF) {
		fact[0]=1;
		if(MAX_N != 0) fact[1]=1;
		for(ll i = 2; i <= MAX_N; ++i) {
			fact[i] = (fact[i-1] * i) % MOD;
		}
	}
	e = 0;
	if(n == 0) return 1;
	long long res = mod_fact(n / MOD, e);
	e += n / MOD;
	if((n / MOD) % 2 != 0) return (res * (MOD - fact[n % MOD])) % MOD;
	return (res * fact[n % MOD]) % MOD;
}
// return nCk
long long mod_comb(long long n, long long k) {
	if(n < 0 || k < 0 || n < k) return 0;
	long long e1, e2, e3;
	long long a1 = mod_fact(n, e1), a2 = mod_fact(k, e2), a3 = mod_fact(n - k, e3);
	if(e1 > e2 + e3) return 0;
	return (a1 * mod_inverse((a2 * a3) % MOD, MOD)) % MOD;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> a(n+1);
	REP(i,n+1) cin>>a[i];
	vector<ll> ans(n+2,0);
	FOR(i,1,n+2) ans[i]+=mod_comb(n+1,i);
	vector<ll> v(n+1,-1);
	ll l=0,r=0;
	REP(i,n+1) {
		if(v[a[i]]!=-1) {
			l=v[a[i]];
			r=i;
		} else {
			v[a[i]]=i;
		}
	}
	ll poyo=l+(n-r);
	FOR(i,1,n+2) {
		if(i-1<=poyo) ans[i]-=mod_comb(poyo,i-1);
	}
	FOR(i,1,n+2) {
		cout<<(ans[i]%MOD+MOD)%MOD<<endl;
	}
}

Measured memory_bytes: 11392