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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

    int N;
    cin >> N;

    char arare;
    bool gflag = false;
    bool wflag = false;
    bool pflag = false;
    bool yflag = false;
    for (int i = 0; i < N; i++) {
        cin >> arare;
        if (arare == 'G') {
            gflag = true;
        }
        if (arare == 'W') {
            wflag = true;
        }
        if (arare == 'P') {
            pflag = true;
        }
        if (arare == 'Y') {
            yflag = true;
        }
    }

    if (gflag && wflag && pflag && yflag) {
        cout << "Four" << endl;
    } else {
        cout << "Three" << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
    ///{}
    int n;
    cin>>n;
    vector<int>v(n);
    int mni=0;
    int mxi=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
        if(v[i]>v[mxi])
            mxi=i;
        if(v[i]<v[mni])
            mni=i;
    }
    int m=0;
    vector<pair<int,int> >vout;
    if(abs(v[mni])>abs(v[mxi])){
        for(int i=0;i<n;i++){
            if(i==mni)
                continue;
            v[i]+=v[mni];
            vout.push_back({mni,i});
        }
        for(int i=n-1;i>0;i--){
            if(v[i]<v[i-1]){
                v[i-1]+=v[i];
                vout.push_back({i,i-1});
            }
        }
    }else{
        for(int i=0;i<n;i++){
            if(i==mxi)
                continue;
            v[i]+=v[mxi];
            vout.push_back({mxi,i});
        }
        for(int i=0;i<n-1;i++){
            if(v[i]>v[i+1]){
                v[i+1]+=v[i];
                vout.push_back({i,i+1});
            }
        }
    }
    cout<<vout.size()<<'\n';
    for(int i=0;i<vout.size();i++){
    cout<<vout[i].first+1<<' '<<vout[i].second+1<<'\n';
    }
    return 0;
}


Measured memory_bytes: 3620
def main():
    a = int(input())
    b = int(input())
    c = int(input())
    x = int(input())

    ans = 0
    for ai in range(a+1):
        for bi in range(b+1):
            for ci in range(c+1):
                if 500*ai + 100*bi + 50*ci == x:
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38896
line = input()
a, b, c = [int(n) for n in line.split()]
if a>b:
    maior=a
    menor=b
else:
    maior=b
    menor=a
v = []
for i in range(1, menor+1, 1):
    if menor%i==0 and maior%i==0:
        v.append(i)
print(v[-c])

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>

#include <map>

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

typedef long long   signed int LL;
typedef long long unsigned int LU;

template<typename T> void swap(T &x, T &y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, q, ans;
LL num[100001];
std::map<LL, LL> m; // pos, num

void ins(LL x, LL y) {
	auto result = m.insert(std::make_pair(x, y));
	if( ! result.second) {
		result.first -> second = y;
	}
}

void test() {
	for(auto it = m.begin(); it != m.end(); it++) {
		printf("<%lld, %lld> ", it->first, it->second);
	}
	printf("\n");
}

int main() {
	scanf("%d%d", &n, &q);
	
	m.insert(std::make_pair(-1, 20000000000001LL));
	m.insert(std::make_pair(n, 0));
	inc(t, q) {
		int a;
		LL b;
		scanf("%d%lld", &a, &b);
		
		int ccc = 0;
		while(b > 0) {
			auto it2 = m.lower_bound(a - 1); 
			auto it = it2; it--;
			LL x = (it -> first);
			LL y = (it -> second);
			LL ny = (it2 -> second);
			LL d = a - 1 - x;
			LL s = d * (y - ny);
			
			
			//ccc++; if(ccc > 20) { return 1; }
			//test();
			//printf("lb: <%lld, %lld>\n", it->first, it->second);
			//printf("t: %d, ccc: %d, xy: <%lld, %lld>, ny: %lld, d: %lld, s: %lld\n", t, ccc, x, y, ny, d, s);
			
			
			if(b > s) {
				m.erase(x);
				ins(a - 1, y);
			} else {
				if(b > s - d) { m.erase(x); } ins((b - 1) % d + 1 + x, (b - 1) / d + 1 + ny);
				if(b > d && b % d != 0) { ins(a - 1, (b - 1) / d + ny); }
			}
			
			b -= s;
		}
	}
	
	auto it = m.begin();
	inc(i, n) {
		while(i > (it -> first)) { it++; }
		printf("%lld\n", it -> second);
	}
	
	return 0;
}


Measured memory_bytes: 7680
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pub push_back
#define pob push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}


ll i,j,k,ii,jj;
ll n,m;
ll a,b,c,d,e,g,h,r;
ll l,ans,num;
ll x[1000005],y[500005],z[500005];
bool dame,flag;
char s[500005],t[500005];
bool used[500005];

int main(){
    cin >> n >> k;
	m = k;
	for(i=2;i*i<=m;i++){
		while(k % i == 0){
			x[i]++;
			k /= i;
		}
		if(k == 1)break;
	}
	ans = 1;
	for(i=2;i*i<=m;i++){
		if(x[i]){
			for(j=0;j<x[i]/n;j++){
				ans *= i;
			}
		}
	}
	if(n == 1){
		ans = m;
	}
	p(ans);
    return 0;
}


Measured memory_bytes: 28544
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;
ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);


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

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  k--;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (n < k)
    return 0;
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}

int main(void){
  ll h, w, a, b;
  cin >> h >> w >> a >> b;
  
  ll c = 1, d = nck(w - b - 1 + h - 1, h - 1);

  ll res = c * d;
  for (int k = 1; k < h - a; k++){
    c = (c * (b + k - 1) % MOD) * inv(k) % MOD;
    d = (d * (h - k) % MOD) * inv(w - b + h - k - 1) % MOD;
    res = (res + c * d % MOD) % MOD;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,x,y,c[MAXN],w[MAXN];
int fact[MAXN],invf[MAXN];
vector<P> col[MAXN];
vector<int> G[MAXN];
vector<P> cross;
bool vis[MAXN];
map<int,int> cnt;
int pow_mod(int a,int i)
{
    int s=1;
    while(i)
    {
        if(i&1) s=1LL*s*a%MOD;
        a=1LL*a*a%MOD;
        i>>=1;
    }
    return s;
}
void add_edge(int u,int v)
{
    G[u].push_back(v);
    G[v].push_back(u);
}
void dfs(int v)
{
    vis[v]=true;cnt[c[v]]++;
    for(auto to:G[v]) if(!vis[to]) dfs(to);
}
int main()
{
    fact[0]=invf[0]=1;
    for(int i=1;i<=200000;i++) fact[i]=1LL*fact[i-1]*i%MOD;
    invf[200000]=pow_mod(fact[200000],MOD-2);
    for(int i=199999;i>=1;i--) invf[i]=1LL*invf[i+1]*(i+1)%MOD;
    scanf("%d%d%d",&n,&x,&y);
    for(int i=1;i<=n;i++) 
    {
        scanf("%d%d",&c[i],&w[i]);
        col[c[i]].push_back(P(w[i],i));
    }
    for(int i=1;i<=n;i++) sort(col[i].begin(),col[i].end());
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<(int)col[i].size();j++)
        {
            if(col[i][0].F+col[i][j].F<=x) add_edge(col[i][0].S,col[i][j].S);
            else break;
        }
    }
    for(int i=1;i<=n;i++) if(col[i].size()) cross.push_back(col[i][0]);
    if(cross.size()>1)
    {
        sort(cross.begin(),cross.end());
        for(int i=1;i<=n;i++)
        {
            if(c[i]!=c[cross[0].S]&&cross[0].F+w[i]<=y) add_edge(i,cross[0].S);
            if(c[i]!=c[cross[1].S]&&cross[1].F+w[i]<=y) add_edge(i,cross[1].S);
        }
    }
    int ans=1;
    memset(vis,false,sizeof(vis));
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            cnt.clear();
            dfs(i);
            int tot=0;
            for(auto x:cnt) ans=1LL*ans*invf[x.S]%MOD,tot+=x.S;
            ans=1LL*ans*fact[tot]%MOD;
        }
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 30708
N = int(input())
ans = float('inf')
ls = []
l = [1]
tmp = 6
while tmp <= 100000:
    l += [tmp]
    tmp *= 6

tmp = 9
while tmp <= 100000:
    l += [tmp]
    tmp *= 9

dp = [float('inf')]*(N+1)
dp[0] = 0
dp[1] = 1
for i in range(N+1):
    for n in l:
        if i-n>=0:
            dp[i] = min(dp[i], dp[i-n]+1)

print(dp[N])

Measured memory_bytes: 44240
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int>a(N+1);
    for(int i=0;i<N;++i)cin>>a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    a.pop_back();
    int Alice=0;
    int Bob=0;
    for (int i=0;i<N;++i){
        if(i%2==0)Alice+=a[i];
        else Bob+=a[i];
    }
    cout<<Alice-Bob<<endl;
}

Measured memory_bytes: 256
N = int(input())
cooking = []

aoki = 0
for _ in range(N):
    a, b = map(int, input().split())
    cooking.append([a + b, a, b])
    aoki += b
chokudai = 0
cooking.sort(reverse=True)
for i in range(0, N , 2):
    chokudai += cooking[i][1]
    aoki -= cooking[i][2]
ans = chokudai - aoki

print(ans)

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


vector<int> adj[200002];
long long ans[200003];

long long dfs(int s, int p,int pay){
    for(int node: adj[s]) {
        if(node == p) continue;
        dfs(node, s, pay + ans[node]);
        ans[node]+=pay;
    }
}
int main() {
	int n, q;
	cin >> n >> q;
	int i;
	for(i=1;i<=n-1;i++) {
	    int a, b;
	    cin >> a >> b;
	    adj[a].push_back(b);
	    adj[b].push_back(a);
	}
	while(q-- ){
	    int a, b;
	    cin >> a >> b;
	    ans[a]+=b;
	}
	dfs(1, 0, ans[1]);
	for(i=1;i<=n;i++) cout<<ans[i]<<" ";
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 30464
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination

int cal(int a,int b){
    if((a==1&&b==0)||(a==0&&b==1)){
        return 1;
    }else{
        return 0;
    }
}

int main(){
    ll n,ans=0,a;
    cin >>n;
    rep(i,n){
        cin >>a;
        ans^=a;//排他的論理和XOR
    }
    if(ans==0){
        cout<<"Yes"<<endl;
        return 0;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 384
import java.util.Scanner;

/**
 * Main
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String N = sc.next();

        String ans = N.substring(N.length()-1);

        if(ans.equals("0") || ans.equals("1") || ans.equals("6") || ans.equals("8")){
            System.out.println("pon");
        }else if(ans.equals("2") || ans.equals("4") || ans.equals("5") || ans.equals("7") || ans.equals("9")){
            System.out.println("hon");
        }else{
            System.out.println("bon");
        }

        
    }
}

Measured memory_bytes: 26948
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

int main(){
    ll K;
    string S;
    cin >> K >> S;
    ll N = S.size();
    if(N <= K){
        cout << S << endl;
    }else{
        cout << S.substr(0,K) << "..." << endl;
    }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG
static const int MAX = 50;

int main(){
  int N;
  cin >> N;
  double sum;
  int A;
  rep(i, N){
    cin >> A;
    sum += 1.0/A;
  }

  cout << 1/sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int a,b;
  cin >> a >> b;
  
  int M = max(a,b);
  int  m = min(a,b);
  
  
  int answer = 0;
    
  for (int i = 0; i < M; i++)
      answer += m*pow(10,i);
  
  cout << answer <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mod 1000000007
#define modd 998244353
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define ar array
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
lld n,m;
lld arr[300000];
lld brr[300000];
lld fastpower(lld x, unsigned lld y, lld p)
{
    lld res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main()
{
     ios;
     lld TESTS,q,a,s,b,l,r,c,k,p,h,w,d,x,y,z,xs,ys,t;
     TESTS=1;
     memset(brr,-1,sizeof(brr));
     //cin>>TESTS;
     while(TESTS--)
     {
         cin>>n;
         ar<lld,2> pts;
         //lld cur=0;
         rep(i,0,n){
             cin>>arr[i];
             if (brr[arr[i]]!=-1){
                pts[1]=i;
                pts[0]=brr[arr[i]];
             }
             brr[arr[i]]=i;
         }
         if (n==1){
            cout<<"1\n1";
            return 0;
         }
         x=pts[0];
         y=n-pts[1];
         //cout<<pts[0]<<" "<<pts[1]<<"\n";
         x=x+y;
         ar<lld,2> prev;
         prev[0]=1;
         prev[1]=0;
         ar<lld,4> cur;
         cur[0]=n-1;
         cur[1]=1;
         cur[2]=x;
         //if (n-1==x)while(true);
         cur[3]=1;
         lld val=1;
         rep(i,1,n-1){
             lld now=(prev[0]*cur[0])%mod;
             now*=fastpower(cur[1],mod-2,mod);
             now%=mod;
             lld ret=(2*prev[0])%mod;
             ret+=now;
             ret%=mod;
             ret+=prev[1];
             ret%=mod;
             if (i-1<=x){
                 ret+=mod-val;
                 ret%=mod;
                 val*=cur[2];
                 val%=mod;
                 val*=fastpower(cur[3],mod-2,mod);
                 val%=mod;
             }
             cur[0]--;
             cur[1]++;
             cur[2]--;
             cur[3]++;
             prev[1]=prev[0];
             prev[0]=now;
             cout<<ret<<"\n";
         }
        if (x!=n-1)
         cout<<n+1<<"\n"<<1;
         else cout<<n<<"\n"<<1;
     }
    return 0;
}


Measured memory_bytes: 5376
n,k=map(int,input().split())
mod=10**9+7
def comb(n,k,mod):
    x = y = 1
    for i in range(min(k,n-k)):
        x = x*(n-i)%mod # 組み合わせの分子
        y = y*(i+1)%mod # 組み合わせの分母
    return x * pow(y, mod-2, mod) % mod
  
for i in range(1,k+1):
  if n-k+1>=i: # 赤のボールが青のボールを置く場所以上にある場合
    
    print((comb(n-k+1,i,mod)*comb(k-1,i-1,mod))%mod)
  else:
    print(0)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")

long long int knapsack(vector<long long int>& wt, vector<long long int>& val, int n, int Weight){
    vector<long long int> dp(10e5);
    for(int i=1; i<=n; i++){
        for(int w=Weight; w>=0; w--){
            if(w>=wt[i-1])
                dp[w] = max(dp[w-wt[i-1]]+val[i-1], dp[w]);
        }
    }
    return dp[Weight];
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    int n, w;
    cin>>n>>w;
    vector<long long int> wt(n), val(n);
    for(int i=0;i<n;i++)
        cin>>wt[i]>>val[i];
    cout<<knapsack(wt, val, n, w)<<endl;
    return 0;
}

Measured memory_bytes: 8064
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: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n = read::<i64>();
    let v = read_vec::<i64>();
    let mut sub = v.into_iter().enumerate().map(|(i,x)| x - i as i64).collect::<Vec<i64>>();
    sub.sort();
    let mid = sub[(n/2) as usize];
    let ans = sub.iter().fold(0,|x,y| x + (y - mid).abs());
    println!("{}",ans);
}


Measured memory_bytes: 8444
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>

using namespace std;

int h;
int map[11][6];

int main(){
  int num = 1;

  while(cin>>h){
    if(h == 0)
      break;
    // cout<<"--------------------"<<num<<"-----------------------"<<endl;
    //num++;
    memset(map,0,sizeof(map));
    for(int i = 10-h+1;i<11;i++){
      for(int j = 0;j<5;j++){
	cin>>map[i][j];
      }
    }

    int point = 0;
    bool update = true;
    /*
    for(int i = 0;i<10;i++){
      for(int j = 0;j<5;j++){
	cout<<map[i][j]<<"\t";
      }
      cout<<endl;
    }
    */
    while(update){
      update = false;
      for(int i = 10-h+1;i <= 10;i++){
	int tmp = 1;
	for(int j = 1;j<6;j++){
	  if(j != 5 && map[i][j] == 0)
	    continue;
	  if(map[i][j] == map[i][j-1]){
	    tmp++;
	  }else if(tmp >= 3){
	    point += tmp * map[i][j-1];

	    update = true;
	    for(int k = j-tmp;k<j;k++){
	      for(int l = i;l >= 0;l--){
		map[l][k] = map[l-1][k];
	      }
	    }
	    tmp = 0;
	  }else{
	    tmp = 1;
	  }

	}
      }
      /*
      cout<<"--------------------------"<<endl;

    for(int i = 0;i<10;i++){
      for(int j = 0;j<5;j++){
	cout<<map[i][j]<<"\t";
      }
      cout<<endl;
      }

      */
    }
    cout<<point<<endl;
  }
    
	
  return 0;
}

Measured memory_bytes: 3092
<?php
$s=trim(fgets(STDIN));
$n=strlen($s);
$ans='keyence';

$i=0;
while($i<7){
	if($s[$i]===$ans[$i]){
		++$i;
	}else{
		break;
	}
}

$j=0;
while($j<7){
	if($s[$n-1-$j]===$ans[6-$j]){
		++$j;
	}else{
		break;
	}
}

echo ($i+$j>=7)?'YES':'NO';

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

int main(void){
    char c;
    cin >> c;
    if(c == 'A') cout << 'T' << endl;
    else if(c == 'G') cout << 'C' << endl;
    else if(c == 'C') cout << 'G' << endl;
    else cout << 'A' << endl;
    
    return 0;
}


Measured memory_bytes: 256
int main() {
	long long int n,result=1,time,m;
  	char str[55],str2[55];
	scanf("%lld%s%s", &n,str,str2);
	
	if (str[0] == str[1]) {
		result *= 6;
		time = 2;
	}
	else {
		result *= 3;
		time = 1;
	}
	for (int i = time; i < n; i += time) {
		if (str[i] == str[i+1]&&time==2) {
			result *= 3;
			time = 2;
		}
		else if(str[i] == str[i + 1] && time == 1){
			result *= 2;
			time = 2;
		}
		else if (str[i] != str[i + 1] && time == 2) {
			result *= 1;
			time = 1;
		}
		else if (str[i] != str[i + 1] && time == 1) {
			result *= 2;
			time = 1;
		}
	}
	result %= 1000000007;
	printf("%lld", result);
}

Measured memory_bytes: 128
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    xyh = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    xyh.sort(key=lambda x: x[2], reverse=True)
    for i in range(101):
        for j in range(101):
            th = -1
            b = True
            for x, y, h in xyh:
                if th == -1:
                    th = h + abs(x - i) + abs(y - j)
                else:
                    if h != max(th - abs(x - i) - abs(y - j), 0):
                        b = False
                        break
            if b:
                print(i, j, th)
                exit()


if __name__ == '__main__':
    slove()


Measured memory_bytes: 40304
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int N, W;
vector<int> v, w;

ll dp[110][100001];

void input() {
	cin >> N >> W;
	v.resize(N);
	w.resize(N);
	rep(i,N) cin >> w[i] >> v[i];
}

ll solve() {
	rep(i,N+1) rep(j,100001) dp[i][j] = INF + 1;
	dp[0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= 100000; j++) {
			if (j - v[i] >= 0) {
				dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + w[i]);
			} else {
				dp[i+1][j] = dp[i][j];
			}
		}
	}

	ll res;
	for (int j = 100000; j >= 0; j--) {
		if (dp[N][j] <= W) {
			res = j;
			break;
		}
	}
	return res;
}


int main() {
	input();
	cout << solve() << endl;
}

Measured memory_bytes: 82512
#include<bits/stdc++.h>
#include<ext/rope>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1

using namespace std;
using namespace __gnu_cxx;

const double g=10.0,eps=1e-7;
const int N=100+10,maxn=100000+10,inf=0x3f3f3f;

int a[N];
int main()
{
    int n;
    scanf("%d",&n);
    int ans1=1,ans2=1;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        ans1*=3;
        if(a[i]%2==0)ans2*=2;
    }
    printf("%d\n",ans1-ans2);
    return 0;
}
/********************

********************/


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int a = 0;
                int b=0; int c=0; int d=0;
        for(int i = 0; i <4;++i) {
            int temp= sc.nextInt();
            if(temp == 1) {
                a = 1;
            }else if(temp == 9) {
                b = 1;
            }else if(temp == 7) {
                c = 1;
            }else if(temp == 4) {
                d = 1;
            }
                
        }
        if((a+b+c+d) == 4) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
    }

}


Measured memory_bytes: 22868
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N, M;
    cin >> N >> M;

    vector<ll> X(M);
    REP(i, M)
    {
        cin >> X[i];
    }

    //訪れる地点よりコマの数が多い場合または訪れる地点が1地点のみの場合、操作は不要
    if (N >= M || M == 1)
    {
        cout << 0 << endl;
        return 0;
    }

    //昇順で並べ替える
    sort(ALL(X));

    //各地点間の距離を計算する
    vector<ll> D(M - 1);
    REP(i, M - 1)
    {
        D[i] = abs(X[i + 1] - X[i]);
    }

    //距離を降順にソート
    sort(ALL(D), greater<ll>());

    //コマの数-1の数だけ長い区間を無視（スキップ）することが可能
    //残った区間の距離が移動すべき距離になる
    ll ans = 0;
    FOR(i, N - 1, M - 1)
    {
        ans += D[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4248
#include<cstdio>
using namespace std;
int a[1000002];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	int ans = 1;
	int state = 0; // 0 - 1 up -1 own
	for (int i = 1; i < n; i++) {
		//if ()
		switch (state) {
			case 0: {
				if (a[i] > a[i - 1]) {
					state = 1; 
				} else if (a[i] < a[i - 1]) {
					state = -1;
				}
				break;
			} case 1: {
				if (a[i] < a[i - 1]) {
					ans++;
					state = 0;
				}
				break;
			} case -1: {
				if (a[i] > a[i - 1]) {
					ans++;
					state = 0;
				}
				break;
			}			
		}		
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
#include <fstream>
 
  using namespace std;
   
 
//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ

  typedef long long ll;
  typedef long double lld;
//   typedef unsigned long long ull;
  // ll INF = INT_MAX;
  // ll mod = 1000000007;
  // lld PI = 3.141592653;
 
// const int N = 2e5 + 5;

void solve(){

  int a,b;
  cin>>a>>b;
  int now = a;
  while (!(now*8/100 == a && now*10/100 == b) && now<=10000)now++;
  if (now==10001) now = -1;
  cout<<now<<"\n";

}
 
  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
      // ifstream cin("input.txt");

    solve();

}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define int long long
using namespace std;

void solve();

signed main()
{
#ifdef _______
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#else
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    int _ = _ = _ = 1;
    for (_; _; --_)
    {
        solve();
    }
}

const int N = 4e5 + 13, mod = 1e9 + 7;

void solve()
{
    int n, k, ans = 0;
    cin >> n >> k;
    for (int i = k; i <= n + 1; i++)
    {
        int mns = i * (i - 1) / 2 % mod;
        int mxs = n * (n + 1) / 2 % mod;
        mxs = (mxs + mod - (n - i) * (n - i + 1) / 2 % mod) % mod;
        ans = (ans + 1 + (mxs - mns + mod) % mod) % mod;
    }
    cout << ans;
}

Measured memory_bytes: 3620
import java.awt.geom.*;
import java.io.*;
import java.util.*;
public class Main {
	double EPS = 1.0e-08;

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			P [] stars = new P[n];
			for(int i = 0 ; i < n; i++){
				double [] temp = new double[3];
				for(int j = 0 ; j < 3; j++){
					temp[j] = sc.nextDouble();
				}
				stars[i] = new P(temp);
			}
			int m = sc.nextInt();
			P [] mlist = new P[m];
			double [] radlist = new double[m];
			for(int i = 0 ; i < m; i++){
				double [] temp = new double[3];
				for(int j = 0 ; j < 3; j++){
					temp[j] = sc.nextDouble();
				}
				mlist[i] = new P(temp);
				radlist[i] = sc.nextDouble();
			}
			
			int ans = 0;
			for(int i = 0 ; i < n; i++){
				if(find(stars[i], mlist, radlist)){
					ans++;
				}
			}
			System.out.println(ans);
		}
	}
	
	private boolean find(P p, P[] mlist, double[] radlist) {
		for(int i = 0 ; i < mlist.length; i++){
			double rad1 = angle(p, mlist[i]);
			if(radlist[i] + EPS > rad1) return true;
		}
		return false;
	}

	private double angle(P p1, P p2) {
		double a = dot(p1,p2);
		double b = abs(p1);
		double c = abs(p2);
		return Math.acos(a / (b * c));
	}

	class P{
		double [] p;
		public P(double[] p) {
			this.p = new double[3];
			for(int i =0; i < 3; i++){
				this.p[i] = p[i];
			}
			this.p = p;
		}
	}

	private double abs(P p) {
		return Math.sqrt(norm(p));
	}

	private double norm(P p) {
		return dot(p,p);
	}

	private double dot(P p1, P p2) {
		double res = 0.0;
		for(int i = 0; i < 3; i++){
			res += p1.p[i] * p2.p[i];
		}
		return res;
	}

	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 13000
import java.io.*;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		InputStreamReader in = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(in);
		
		try {
			String NMQ = reader.readLine();
			String[] NMQ_sp = NMQ.split(" ");
			int N = Integer.parseInt(NMQ_sp[0]);
			int M = Integer.parseInt(NMQ_sp[1]);
			int Q = Integer.parseInt(NMQ_sp[2]);
			int[] L = new int[M];
			int[] R = new int[M];
			int[] p = new int[Q];
			int[] q = new int[Q];
			int[][] train = new int[N + 1][N + 1];
			int[][] sum = new int[N + 1][N + 1];
			
			for(int i = 0; i < M; i++) {
				String LR = reader.readLine();
				String[] LR_sp = LR.split(" ");
				L[i] = Integer.parseInt(LR_sp[0]);
				R[i] = Integer.parseInt(LR_sp[1]);		
			}
			
			for(int i = 0; i < Q; i++) {
				String pq = reader.readLine();
				String[] pq_sp = pq.split(" ");
				p[i] = Integer.parseInt(pq_sp[0]);
				q[i] = Integer.parseInt(pq_sp[1]);	
			}
			
			for(int i = 1; i <= N; i++) {
				for(int j = 1; j <= N; j++) {
					train[i][j] = 0;
				}
			}
			
			for(int i = 0; i < M; i++) {
				train[L[i]][R[i]] += 1;
			}
		
			for(int i = 0; i <= N; i++) {
				for(int j = 0; j <= N; j++) {
					sum[i][j] = 0;
				}
			}	
			
			for(int i = 1; i <= N; i++) {
				for(int j = 1; j <= N; j++) {
					sum[i][j] = sum[i][j - 1] + train[i][j];
				}
			}
				
			for(int i = 0; i < Q; i++) {
				int count = 0;
				for(int j = p[i]; j <= q[i]; j++) {
					int a = sum[j][q[i]] - sum[j][p[i] - 1];
					count += a;
				}
				System.out.println(count);
			}
							
		} catch(IOException e) {
			System.out.println(e);
		}
	}
}


Measured memory_bytes: 75956
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <random>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

llong pow(int x, int n){
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}

template <typename T> struct BIT { // 1-indexed
private:
    vector<T> array;
    const int n;

public:
    // 初期化
    BIT(int _n) : array(_n + 1, 0), n(_n) {}

    // 1番目からi番目までの累積和を求める
    T sum(int i) {
        T s = 0;
        while(i > 0) {
            s += array[i];
            i -= i & -i; // LSB減算
        }

        return s;
    }

    // [i, j]の要素の総和
    T sum(int i, int j) {
        T ret_i = sum(i - 1);
        T ret_j = sum(j);

        return ret_j - ret_i;
    }

    // i番目に要素xを追加
    void add(int i, T x) {
        while (i <= n) {
            array[i] += x;
            i += i & -i; // LSB加算
        }
    }
};

template <typename T> struct BIT2 { // 1-indexed
private:
    vector<vector<T> > array;
    const int n;
    const int m;

public:
    // 初期化
    BIT2(int _n, int _m) : array(_n + 1, vector<T>(_m + 1, 0)), n(_n), m(_m) {}

    // (1, 1)から(x, y)までの累積和を求める
    T sum(int x, int y) {
        T s = 0;
        for (int i = x; i > 0; i -= i & (-i)) {
            for (int j = y; j > 0; j -= j & (-j)) {
                s += array[i][j];
            }
        }

        return s;
    }

    // [(x1, y1), (x2, y2)]の要素の総和
    T sum(int x1, int y1, int x2, int y2) {
        return sum(x2, y2) - sum(x1 - 1, y2) - sum(x2, y1 - 1) + sum(x1 - 1, y1 - 1);
    }

    // (x, y)に要素kを追加
    void add(int x, int y, T k) {
        for (int i = x; i <= n; i += i & (-i)) {
            for (int j = y; j <= m; j += j & (-j)) {
                array[i][j] += k;
            }
        }
    }
};

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

string toUpper(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = toupper(s[i]);
    }
    return t;
}

string toLower(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = tolower(s[i]);
    }
    return t;
}

int main() {
    int r; cin >> r;
    if (r < 1200) {
        cout << "ABC" << endl;
        return 0;
    }
    if (1200 <= r && r < 2800) {
        cout << "ARC" << endl;
        return 0;
    }
    
    cout << "AGC" << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	int n;
	scanf("%d\n", &n);
	int[][] g = new int[][n];
	int[] degree = new int[n];
	foreach (i; 0..n-1) {
		int x, y;
		scanf("%d %d\n", &x, &y);
		--x; --y;
		g[x] ~= y;
		g[y] ~= x;
		degree[x]++;
		degree[y]++;
	}
	string c = readln().chomp;

	bool[] live = new bool[n];
	live[] = true;

	alias Queue = DList!int;
	auto q = new Queue();
	foreach (i; 0..n) {
		if (degree[i] == 1) {
			q.insertBack(i);
		}
	}

	int L = n;
	while (!q.empty) {
		int v = q.front();
		q.removeFront();
		if (c[v] == 'W') continue;
		live[v] = false; L--;
		foreach (u; g[v]) {
			degree[u]--;
			if (degree[u] == 1) {
				q.insertBack(u);
			}
		}
	}
	if (L == 0) {
		writeln(0);
		return;
	}
	int base = L*2;

	int[] score = new int[n];
	foreach (v; 0..n) {
		if (!live[v]) continue;
		score[v] = (degree[v] + (c[v]=='B'?0:1)) % 2;
		base += score[v];
	}

	int best = 0;
	int dfs(int v, int parent=-1) {
		int ret = score[v];
		foreach (u; g[v]) {
			if (u == parent) continue;
			if (!live[u]) continue;
			int s = dfs(u,v);
			best = max(best, ret+s);
			ret = max(ret, s+score[v]);
		}
		return ret;
	}
	foreach (v; 0..n) {
		if (!live[v]) continue;
		dfs(v);
		break;
	}

	writeln(base-best*2-2);
}

Measured memory_bytes: 11800
let scan_int () = Scanf.scanf " %d" (fun x -> x)
let print_int n = Printf.printf "%d\n" n

let () =
  let n = scan_int() in
  let ans = 
    if n < 10 then n
    else if n < 100 then 9
    else if n < 1000 then n - 90
    else if n < 10000 then 909
    else if n < 100000 then n - 9090
    else 90909 in
  print_int ans


Measured memory_bytes: 384
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        long sc = scanner.nextLong() - 1;
        long sc2 = scanner.nextLong();
        long sc3 = scanner.nextLong();
        long sc4 = scanner.nextLong();
        long bet = sc2 - sc;
        
        long tmp = sc2/sc3;
        long tmp2 = sc/sc3;
        long minus1 = tmp - tmp2;

        long tmp3 = sc2/sc4;
        long tmp4 = sc/sc4;
        long minus2 = tmp3 - tmp4;

        long tmp5 = sc2/lcm(sc3,sc4);
        long tmp6 = sc/lcm(sc3,sc4);
        long minus3 = tmp5 - tmp6;
        long ans = bet - minus1 - minus2 + minus3;
        System.out.println(ans);
    }
    private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
    }
    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }
}

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

int main(){
  int n;
  string s,t;
  cin>>n>>s>>t;
  if(s==t) {
    cout<<n<<"\n";
    return 0;
  }
  int l = 0;
  for(int i=0; i<n; i++) {
    if(s.substr(n-i)==t.substr(0,i)) l = max(l,i);
  }
  cout<<2*n - l<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(0, a + b - n) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll a,b,c,d;
	string s = "Yes";

	cin >> a >> b >> c >> d;

	while (1)
	{
		c -= b;
		if (c <= 0)
		{
			break;
		}
		a -= d;
		if (a <= 0)
		{
			s = "No";
			break;
		}
	}

	cout << s;

}


Measured memory_bytes: 3632
local a, b = io.read("*l", "*l")
local ok = true
for j = 0, #a - 1 do
  ok = true
  for i = 1, #a do
    local bi = i + j
    if #a < bi then bi = bi - #a end
    if a:sub(i, i) ~= b:sub(bi, bi) then ok = false break end
  end
  if ok then break end
end
print(ok and "Yes" or "No")


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

int main(){
	int n;
	double a;
	while(cin >> n && n){
		int count[6] = {};
		for(int i=0;i<n;i++){
			cin >> a;
			if(a>=185.0) count[5]++;
			else if(a>=180.0) count[4]++;
			else if(a>=175.0) count[3]++;
			else if(a>=170.0) count[2]++;
			else if(a>=165.0) count[1]++;
			else count[0]++;
		}
		for(int i=0;i<6;i++){
			cout << i+1 << ':' ;
			if(count[i] != 0){
				for(int j=0;j<count[i];j++){
					cout << '*';
				}
			}
			cout << '\n' ;
		}
	}
	return 0;
}

Measured memory_bytes: 0
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math



Sn = str(input())
X,Y = map(int, input().split())

xyn = [0]
for c in Sn:
  if c == 'T':
    xyn.append(0)
  else:
    xyn[-1] += 1

Xn = xyn[2::2]
Yn = xyn[1::2]

dp_x = {xyn[0]}
for i in range(len(Xn)):
  dp_xn = {}
  for j in dp_x:
    dp_xn[j+Xn[i]] = 1
    dp_xn[j-Xn[i]] = 1
  dp_x = dp_xn

dp_y = {0}
for i in range(len(Yn)):
  dp_yn = {}
  for j in dp_y:
    dp_yn[j+Yn[i]] = 1
    dp_yn[j-Yn[i]] = 1
  dp_y = dp_yn


if X in dp_x and Y in dp_y:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 73948
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;

vector<vector<int>> adj;
vector<int> dp[2];

const int mod = 1e9 + 7;
enum Color {
  Black, White
};

int calc(int c, int u, int p) {
  if (dp[c][u] != -1) return dp[c][u];
  dp[c][u] = 1;
  for (auto to: adj[u]) {
    if (to == p) continue;
    if (c == Black) {
      dp[c][u] = dp[c][u] * 1ll * calc(White, to, u) % mod;
    } else {
      dp[c][u] = dp[c][u] * 1ll * (calc(White, to, u) + calc(Black, to, u)) % mod;
    }
  }
  return dp[c][u];
}
int main() {

  int n;
  cin >> n;
  int x, y;
  adj.resize(n);
  dp[Black].assign(n, -1);
  dp[White].assign(n, -1);
  for (int i = 0; i < n-1; ++i) {
    cin >> x >> y;
    adj[x-1].push_back(y-1);
    adj[y-1].push_back(x-1);
  }
  cout << (calc(Black, 0, 0) + calc(White, 0, 0)) % mod << '\n';
  return 0;
}


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

#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

Node root;

Node treeSearch(Node u, int k){

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

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

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

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

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

void inorder(Node u){

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

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

int main(){

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

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

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

void search(long &hp,long pos, vl &To, vl &Damage){
    //if(To.size() == 0) return;

    long maxi = To.size();
    long mini = 0;
    while(maxi - mini > 1){
        long mid = (maxi + mini) / 2;
        if(pos <= To.at(mid)) maxi = mid;
        else mini = mid;
    }

    hp -= Damage.at(Damage.size() - 1) - Damage.at(mini);

}

int main(){
    long n,d,a;
    cin >> n >> d >> a;
    vector<pll> data(n);
    rep(i,n) cin >> data.at(i).first >> data.at(i).second;
    sort(all(data));

    vector<long> To(1,-1),Damage(1,0); //to , sum_damage
    long ans = 0;

    rep(i,n){
        long from = data.at(i).first;
        long hp = data.at(i).second;

        search(hp,from,To,Damage);
        
        if(hp <= 0) continue;

        long to = from + 2*d;
        long bomb = (hp+a-1)/a;
        long damage = a * bomb;

        To.push_back(to);
        long m = Damage.size();
        Damage.push_back(Damage.at(m-1) + damage);
        ans += bomb;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
vector<int> a, b, c, d;
ll mx = 0;
void f(vector<int> T, int M, int N, int Q) {
  if (T.size() == N) {
    ll num = 0;
    REP(i, Q) {
      if (T[b[i]] - T[a[i]] == c[i]) num += d[i];
    }
    mx = max(num, mx);
    return;
  }
  for (int i = T[T.size() - 1]; i <= M;i++){
    T.push_back(i);
    f(T, M, N, Q);
    T.pop_back();
  }
  return;
}
int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<int> v(M);
  a.resize(Q), b.resize(Q), c.resize(Q), d.resize(Q);
  REP(i, Q) cin >> a[i] >> b[i] >> c[i] >> d[i], a[i]--, b[i]--;
  REP(i, 9) {
    vector<int> T(0);
    T.push_back(i+1);
    f(T, M, N, Q);
  }
  cout << mx << endl;
}

Measured memory_bytes: 3636