akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#define bufsize 1<<22
char ibuf[bufsize];
char *ptr=ibuf;

void readint(int *i)
{
    *i=0;
    while(*ptr>='0')
    {
        *i=*i*10+*ptr-'0';
        ++ptr;
    }
    ++ptr;
}

int h,w;
#define obs(i,j) ptr[i*(w+1)+j]=='@'

main()
{
    fread(ibuf,1,bufsize,stdin);

    int k,sx,sy,tx,ty;
    readint(&h);
    readint(&w);
    readint(&k);
    readint(&sx);
    readint(&sy);
    readint(&tx);
    readint(&ty);
    sx--,sy--,tx--,ty--;
    const int dst=tx*w+ty;

    struct po {int x,y;};
    struct po qu[1<<20];
    struct po *beg=qu,*end=qu+1;
    beg->x=sx,beg->y=sy;
    unsigned int dist[1<<20];
    memset(dist,-1,sizeof(dist));
    dist[sx*w+sy]=0;
    while(beg!=end)
    {
        const int x=beg->x,y=beg->y;
        const unsigned int d=dist[x*w+y];
        ++beg;
        for(int i=1,a=x,b=y,z=a*w+y; i<=k; i++)
        {
            a++,z+=w;
            if(a==h||obs(a,b)||dist[z]<=d) break;
            if(z==dst)
            {
                printf("%u\n",d+1);
                return 0;
            }
            if(dist[z]!=d+1)
            {
                end->x=a,end->y=b;
                dist[z]=d+1;
                ++end;
            }
        }
        for(int i=1,a=x,b=y,z=a*w+y; i<=k; i++)
        {
            b++,z++;
            if(b==w||obs(a,b)||dist[z]<=d) break;
            if(z==dst)
            {
                printf("%u\n",d+1);
                return 0;
            }
            if(dist[z]!=d+1)
            {
                end->x=a,end->y=b;
                dist[z]=d+1;
                ++end;
            }
        }
        for(int i=1,a=x,b=y,z=a*w+y; i<=k; i++)
        {
            a--,z-=w;
            if(a<0||obs(a,b)||dist[z]<=d) break;
            if(z==dst)
            {
                printf("%u\n",d+1);
                return 0;
            }
            if(dist[z]!=d+1)
            {
                end->x=a,end->y=b;
                dist[z]=d+1;
                ++end;
            }
        }
        for(int i=1,a=x,b=y,z=a*w+y; i<=k; i++)
        {
            b--,z--;
            if(b<0||obs(a,b)||dist[z]<=d) break;
            if(z==dst)
            {
                printf("%u\n",d+1);
                return 0;
            }
            if(dist[z]!=d+1)
            {
                end->x=a,end->y=b;
                dist[z]=d+1;
                ++end;
            }
        }
    }
    puts("-1");
}


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

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

int main(){
cin.sync_with_stdio(false);
cin.tie(0);
        string s, t;
        cin>> s>> t;
        string ans = "Yes";
        if(s.size()+1== t.size()){
            for(int i =0;i< s.size();i++){
                if(s[i]!=t[i]){ans="No";break;}
            }
        }
        else{ans = "No";}
    cout<< ans<< endl;
return 0;}




Measured memory_bytes: 3644
n, x = input().split()
n, x = int(n), int(x)

a = [1]
for i in range(n):
    a.append(a[i] * 2 + 3)
 
p = [1]
for i in range(n):
    p.append(p[i] * 2 + 1)
 
def solve(n, x):
    if n == 0:
        if x <= 0:
            return 0
        else:
            return 1
    elif x == 1:
        return 0
    elif 1 <  x <=  1 + a[n - 1]:
        return solve(n - 1, x - 1)
    elif x == 2 + a[n-1]:
        return p[n-1] + 1
    elif 2 + a[n-1] < x and x <= 2 + 2 * a[n-1]:
        return solve(n - 1, x - 2 - a[n - 1]) + p[n-1] + 1
    elif x == 3 + 2 * a[n - 1]:
        return 2 * p[n-1] + 1
 
print(solve(n, x))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using namespace std;
 
double dp[3001][3001];
double solve(vector<double>& ar, int i, int x)
{
    if(x == 0)
        return 1;
    if(i == 0)
        return 0;
    if(dp[i][x] > -0.1)
        return dp[i][x];
    return dp[i][x] = ar[i]*solve(ar, i-1, x-1) + (1-ar[i])*solve(ar,i-1,x);  
}
 
int main() {
    int n;
    cin >> n;
    memset(dp, -1, sizeof dp);
    vector<double> ar(n+1);
    for(int i=1;i<n+1;i++)
        cin >> ar[i];    
    cout<<fixed<<setprecision(10)<<(solve(ar, n, (n+1)/2));
}


Measured memory_bytes: 74388
#include <bits/stdc++.h>
 
using namespace std;
 
 
int main()
{
    long long n, count=0;
    string s;
    cin >>n>>s;
    for(int i=0; i<n-2; i++){
        if (s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')count++;
    }
    cout<<count;
    
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#AGC014A
import sys
#import collections

#n= int(input())
tmp = input().split()
a,b,c = list(map(lambda a: int(a), tmp))

#print(a)
#print(b)
#print(c)


count=0
while(1):
	if((a==b)and(b==c)):
		if(a%2==1):
			print(count)
			sys.exit()
		else:
			print(-1)
			sys.exit()
	if((a%2==1)or(b%2==1)or(c%2==1)):
		print(count)
#		print(a)
#		print(b)
#		print(c)
		sys.exit()
	a//=2
	b//=2
	c//=2
	tmp=a
	a+=b
	b+=c
	c+=tmp
	count+=1




Measured memory_bytes: 3064
import collections
N = int(input())
s = input()
t = input()
ans = list(s)
table = collections.defaultdict(int)
if s == t:
    print(N)
    exit(0)
for i in range(1, N):
    if (s + t[-i:]).endswith(t):

        print(N+i)
        exit(0)
print(2*N)


Measured memory_bytes: 3316
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		PriorityQueue<Integer> que = new PriorityQueue<Integer>();
		int n = sc.nextInt();
		for(int i = 0;i < n; i++) {
			que.add(-1*sc.nextInt());
		}
		int ans = 0;
		for(int i = 0; i < n; i++) {
			if(i%2 == 0) ans -= que.poll();
			else ans += que.poll();
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 21844
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
  
  string s,t;
  cin>>s>>t;
  if(s==t){
    cout<<"Yes"<<endl;
    return 0;
  }
  for(uli i=0;i<s.length()-1;++i){
    string a;
    a=s[s.size()-1];
    //cout<<a<<' ';
    s.pop_back();
    //cout<<s<<' ';
    a+=s;
    //cout<<a<<' ';
    s=a;
    if(s==t){
      cout<<"Yes"<<endl;
      return 0;
    }
    //cout<<endl;
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr long long LLINF = 1LL << 62;

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int main() {
  long long n, a, b; cin>>n>>a>>b;

  long long d = b - a;
  long long l = a-1, r = n-b;
  long long ans = LLINF;

  if (d % 2 == 0) ans = min(ans, d / 2);
  else {
    ans = min(ans, l + 1 + d / 2);
    ans = min(ans, r + 1 + d / 2);
  }

  print(ans);

  return 0;
}

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

#define INF 2e9;
int N,M;
int D[1001];
int C[1001];

int dp[1001][1001] = {0};

int main(){
	scanf("%d%d",&N,&M);
	for(int i = 1; i <= N; i++){
		scanf("%d",&D[i]);
	}
	for(int i = 1; i <= M; i++){
		scanf("%d",&C[i]);
	}
	for(int i = 1; i <= N && i-1 <= M; i++){
		dp[i][i-1] = INF;
	}


	for(int i = 1; i <= N; i++){ // D
		for(int j = i; j <= M; j++){ // C
			dp[i][j] = min(dp[i-1][j-1] + D[i]*C[j], dp[i][j-1]);
		}
	}
	printf("%d\n",dp[N][M]);

	return 0;
}



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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(),(x).rend()

typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;

const int inf=1e9;
const int mod=1e9+7;

vi dp(100005,inf);

int main(){
	int n;
	cin>>n;
	int h[n];
	for (int i = 0; i < n; ++i){
		cin>>h[i];
	}

	dp[0]=0;
	for (int i = 0; i < n; ++i){
		dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
		dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
	}

	cout<<dp[n-1]<<endl;


	return 0;
}

Measured memory_bytes: 1024
n=int(input())
l=[]
for i in range(n):
    l.append(list(map(int,input().split())))
ans=n
for i in range(n):
    for j in range(n):
        if i<j:
            p=l[i][0]-l[j][0]
            q=l[i][1]-l[j][1]
            kai=n
            for x in range(n):
                for y in range(n):
                    if l[x][0]-l[y][0]==p and l[x][1]-l[y][1]==q:
                        kai-=1
            ans=min(ans,kai)
print(ans)

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

/*
    |
  B |  A
----P------
  C |  D
*/
#define ll long long
const int maxn=2e5+9;
struct point{
    int x,y;
    int bc,ad;
};
int n;
point D[maxn];
void init(){
    //n=readint();
    cin>>n;
    for(int i=1;i<=n;++i)
        //D[i].x=readint(),D[i].y=readint();
       cin>>D[i].x>>D[i].y;
}



struct tree_node{
    int l,r;
    int num;
};
tree_node T[maxn*3];
//int _deep=0;
void maketree(int p,int l,int r){
//    for(int q=0;q<_deep;++q)printf("  ");
//    _deep++;
//    printf("making p=%d l=%d r=%d\n",p,l,r);
//    if(p>=n*2){
//        printf("wtf1\n");
//        //return;
//    }
    T[p].l=l;T[p].r=r;
    T[p].num=0;
    if(l==r){
//        _deep--;
        return;
    }
    int m=(l+r)/2;
    maketree(p*2,l,m);
    maketree(p*2+1,m+1,r);
//    _deep--;
}
int insert(int p,int x){
//    if(p>=n*2){
//        printf("wtf2\n");
//        return 0;
//    }
    if(T[p].l==T[p].r /*&& T[p].l==x*/){
        T[p].num+=1;
        return 0;
    }
    int m=(T[p].l+T[p].r)/2;
    T[p].num+=1;
    if(x<=m){
        return insert(p*2,x);
    }else{
//        if(p*2>=n*2){
//            printf("wtf3\n");
//            return 0;
//        }
        return insert(p*2+1,x)+T[p*2].num;
    }
}
int insert_and_check_left(int x){
    return insert(1,x);
}






const int MOD=998244353;
int p2[maxn];
void initp2(){
    p2[0]=1;
    for(int i=1;i<n;++i)
        p2[i]=(p2[i-1]*2)%MOD;
}
int p(int i){
    return p2[i];
}
int mul(int a,int b,int c,int d){
    ll r=a;
    r=(r*b)%MOD;
    r=(r*c)%MOD;
    r=(r*d)%MOD;
    return r;
}
int calc(int a,int b,int c,int d){
//    printf("calc %d %d %d %d\n",a,b,c,d);
    int ret;
    ret=p(n-1);
    ret=(ret+mul(p(b),p(d),p(a)-1,p(c)-1))%MOD;
    ret=(ret+mul(p(a),p(c),p(b)-1,p(d)-1))%MOD;
    ret=(ret-mul(p(a)-1,p(b)-1,p(c)-1,p(d)-1)+MOD)%MOD;
    //printf("ret=%d\n",ret);
    return ret;
}

bool cmp_x(point a,point b){return a.x<b.x;}
bool cmp_y(point a,point b){return a.y<b.y;}
int solve(){
    sort(D+1,D+n+1,cmp_x);
    for(int i=1;i<=n;++i){
        D[i].bc=i-1;
        D[i].ad=n-i;
    }
    sort(D+1,D+n+1,cmp_y);
    int a,b,c=0,d=0;
    initp2();
//    int sum=calc(D[1].ad,D[1].bc,0,0);
//    insert_and_check_left(D[1].x);
    maketree(1,1,n);
    int sum=0;
    for(int i=1;i<=n;++i){
        //if(D[i].x>D[i-1].x)c++;else d++;
        c=insert_and_check_left(D[i].bc+1);//index of X
        d=i-1-c;
        a=D[i].ad-d;
        b=D[i].bc-c;
//        printf("point (%d,%d)\n",D[i].x,D[i].y);
        sum=(sum+calc(a,b,c,d))%MOD;
    }
    return sum;
}
int main(){
    init();
    cout<<solve()<<endl;
    return 0;
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int n; cin >> n;

    vector<int> ans;
    if (n == 1) ans.push_back(1);
    else if (n == 2) ans.push_back(2);
    else {
        while (true) {
            int tmp = 0;
            int cnt = 0;
            REP(i, n) {
                tmp += i;
                if (n <= tmp) {
                    cnt = i;
                    break ;
                }
            }
            n -= cnt;
            ans.push_back(cnt);
            if (n == 1) {
                ans.push_back(n);
                break ;
            } else if (n == 2) {
                ans.push_back(n);
                break ;
            }
        }
    }

    for (int i = ans.size() - 1; i >= 0; i--)
        cout << ans[i] << '\n';
    return 0;
}

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

int main() {
  long a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  long v=a[0]*a[1]*a[2];
  long m=a[0]*a[1]*(a[2]/2);
  cout<<(v-m)-m<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

void print_a(VI v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int l,r,d;
    cin>>l>>r>>d;
    int ans = (r/d) - ((l-1)/d);
    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  if (N == 1)
  {
    cout << "Hello World" << endl;
  }
  else if (N == 2)
  {
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int N,S;cin>>N>>S;
    vector<int> A;
    for(int i = 0;i < N;i++){
        int _a;cin>>_a;
        A.push_back(_a);
    }
    ll MOD = 998244353;
    ll res = 0;
    vector<vector<ll>> dp(N+1, vector<ll>(S+1,0));
    dp[0][0] = 1;
    for(int i = 1;i < N+1;i++){
        for(int j = 0;j <= S;j++){
            dp[i][j] = (dp[i-1][j]*2%MOD + dp[i][j])%MOD;
            if(j-A[i-1]>=0){
                dp[i][j] = (dp[i][j] + dp[i-1][j-A[i-1]])%MOD;
            }
        }
    }
    cout<<dp[N][S]<<endl;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int main()
{
    int n,m;
    cin >>n >>m;
    vector<string> f(n);
    rep(i,n) cin >>f[i];

    int ans=n*m;

    //0~i:W, i+1~j:B, j+1~n-1:R ??§??????
    rep(i,n-2)for(int j=i+1; j<n-1; ++j)
    {
        int ct=0;
        //W
        for(int y=0; y<=i; ++y)rep(x,m)
        {
            if(f[y][x]!='W') ++ct;
        }
        //B
        for(int y=i+1; y<=j; ++y)rep(x,m)
        {
            if(f[y][x]!='B') ++ct;
        }
        //R
        for(int y=j+1; y<n; ++y)rep(x,m)
        {
            if(f[y][x]!='R') ++ct;
        }

        ans=min(ans,ct);
    }

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

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second


void solve()
{
    int n,w;cin>>n>>w;
    ll weight[n],value[n];
    REP(i,n)cin>>weight[i]>>value[i];
    vector<vector<ll> >dp(n+1,vector<ll>(w+1,0));
    REP(i,n)
        REP(j,w+1)
            dp[i+1][j]=j>=weight[i]?max(dp[i][j],dp[i][j-weight[i]]+value[i]):dp[i][j];
    cout<<dp[n][w]<<endl;
}

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

Measured memory_bytes: 80256
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin >> n >> k;
  cout << (n-1+k-1-1)/(k-1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  vector<int> v;
  if(k*2>=b-a+1){
    for(int i=a;i<=b;i++) cout<<i<<endl;
    return 0;
  }
  rep(i,k){
    v.push_back(a+i);
    v.push_back(b-i);
  }
  sort(v.begin(),v.end());
  rep(i,v.size()) cout<<v[i]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
#define ll  long long
#define ld long double
#define ms(a,v) memset(a,v,sizeof a)
#define pii pair<int, int>
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n; scanf("%d", &n);
	double a[n];
	for (int i=0; i<n; ++i)scanf("%lf", a+i);
	sort(a, a+n);
	double ans=a[0];
	for (int i=1; i<n; ++i) ans = (ans+a[i])/2.000000;
	printf("%lf", ans);
	return 0;
}


Measured memory_bytes: 512
use std::io;
use std::str::FromStr;

fn main() {
    let (n, l) = {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let mut it = buf.split_whitespace();
        (usize::from_str(it.next().unwrap()).unwrap(),
        i32::from_str(it.next().unwrap()).unwrap())
    };

    let mut r: Vec<i32> = vec![];
    for i in 1..n+1 {
        r.push(l + i as i32 - 1);
    }
    r.sort_by(|a, b| b.abs().cmp(&a.abs()));
    r.pop();
    let ans: i32 = r.iter().sum();
    println!("{}", ans);
}


Measured memory_bytes: 4352
use std::collections::HashMap;

fn main() {
    let n = read::<usize>();
    let v = read_vec::<u64>();
    let mut map: HashMap<u64, u64> = HashMap::new();
    for i in 0..n {
        let a = v[i];
        let entry = map.entry(a).or_insert(0);
        *entry += 1;
    }

    let mut ret = 0;
    for (k, v) in map.iter() {
        if *k < *v {
            ret += *v - *k;
        } else if *k > *v {
            ret += *v;
        }
    }

    println!("{}", ret);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 12540
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,cnt=0,a;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;

    while(a%2==0)
    {
        cnt++;
        a=a/2;

    }
    }
    printf("%d\n",cnt);
    return 0;


}


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

int main(){
    int n, k, x, y; cin >> n >> k >> x >> y;
    int ans = 0;
    if(n < k){
        for(int i = 0; i < n; i++){
            ans += x;
        }
        cout << ans << endl;
    }else{
         for(int i = 0; i < k; i++){
            ans += x;
        }
        for(int i = k; i < n; i++){
            ans += y;
        }
        cout << ans << endl;
    }
    
}

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

int main()
{
  int N, n, i = 1, sum, k;

  cin >> N;
  n = N;
  k = N;

  if (k < 10)
  {
    cout << "Yes" << endl;
    exit(0);
  }
  while (k > 9)
  {
    k /= 10;
    i *= 10;
  }
  sum = k;

  while (true)
  {
    N -= k * i;
    i /= 10;
    k = N / i;
    sum += k;
    if (i == 1)
    {
      break;
    }
  }
  if (n % sum == 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;
using veb = vector<bool>;
using qul = queue<ll>;

void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

int binary_search(ll x, vel a){
    auto ite = lower_bound(ALL(a), x);
    if(ite != a.end() && *ite == x) {
        return ite - a.begin() ;
    } else {
        return -1;
    }

}

ll modpow(ll a, ll n, ll mod) {
    if(n == 0)
        return 1;
    if(n == 1)
        return a % mod;
    if(n % 2 == 1)
        return (a * modpow(a, n - 1, mod)) % mod;
    ll t = modpow(a, n / 2, mod);
    return (t * t) % mod;
}

int main() {
    ll N, X, T, ans;
    cin >> N >> X >> T;
    if(N % X == 0){
        ans = N/X * T;
    } else {
        ans = (N/X + 1) * T; 
    }

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

Measured memory_bytes: 3596
### main

loop do
  ms = gets.split.map(&:to_i)

  n = ms.shift
  break if n == 0

  s = ms.shift

  n2 = n * 2

  wls = n2.times.map{(s + 1).times.map{nil}}
  (0...n2).each{|i| wls[i][1] = 0}

  for si in (2..s)
    for i in (0...n2)
      j = (i + 1) % n2
      for mi in (1..ms[i])
        si0 = si - mi
        break if si0 < 1
        if wls[j][si0] == 0
          wls[i][si] = 1
          break
        end
        wls[i][si] = 0 if wls[i][si].nil?
      end
    end
  end

  puts wls[0][s]
end

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

#define fio                            \
     ios_base::sync_with_stdio(false); \
     cin.tie(NULL);                    \
     cout.tie(NULL);
#define ll long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
ll M = 1e9 + 7;
const ll N = 300000 + 5;

ll mod(ll a, ll m)
{
     return (a % m + m) % m;
}

int main()
{
     fio;
     unordered_set<string> str;
     ll n;
     cin >> n;
     string s;
 
     for (int i = 0; i<n; i++)
     {
cin>>s;
str.insert(s);
          }
cout<<str.size();
          return 0;
     }

Measured memory_bytes: 17712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
typedef long long ll;
//const ll INF = 10000000000;
//const ll MOD = 1000000007;

int main() {
    //cin.tie(0); ios::sync_with_stdio(false);
    int N; cin >> N;
    char S[N][N];
    rep(i, N) rep(j, N) cin >> S[i][j];
    bool is_same[N][N];
    rep(i, N) rep(j, N) is_same[i][j] = true;
    
    rep(i, N) rep(j, N) rep(k, N) {
        if (S[(i+k)%N][j]!=S[i][(j+k)%N]) is_same[i][j] = false;
    }
    
    int ans = 0;
    
    rep(i, N) rep(j, N) {
        bool flag = true;
        rep(k, N) flag &= is_same[(i+k)%N][(j+k)%N];
        if (flag) ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 384
n = int(input())
a = []
now = n
for i in range(2, n):
    while now % i == 0:
        now //= i
        a.append(i)
    if i * i > n:
        break
if now != 1:
    a.append(now)
print(str(n) + ":", end = "")
for i in a:
    print(" " + str(i), end = "")
print()


Measured memory_bytes: 5596
n=int(input())
s=[input() for i in range(n)]
if (len(s) == len(set(s))) == 0:
  print("No")
  exit()
for c,d in zip(s[0:],s[1:]):

  if c[-1] == d[0]:
    pass
  else:
    print("No")
    exit()
print("Yes")

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

struct NODE{
	int src,dst,cap,weight;
};
bool operator < (const NODE &a,const NODE &b){
	return a.weight > b.weight;
}
map<string,int> dic;
int get(string s){
	if( dic.count(s) ) return dic[s];
	int k = dic.size();
	return dic[s] = k;
}

int main(){
	int n,m,cap;
	while( cin >> n >> m >> cap&& n ){
		vector<NODE> g[6010];
		int LPG[6010] = {};
		dic.clear();
		string s_,g_;
		cin >> s_ >> g_;
		int s = get(s_);
		int gg = get(g_);
		for(int i = 0 ; i < n ; i++){
			string a_,b_;
			cin >> a_ >> b_;
			int a = get(a_);
			int b = get(b_);
			int c; cin >> c;
			g[a].push_back({a,b,0,c});
			g[b].push_back({b,a,0,c});
		}
		for(int i = 0 ; i < m ; i++){
			string x_; cin >> x_;
			int x = get(x_);
			LPG[x] = true;
		}
		priority_queue<NODE> Q;
		int done[6010]={};
		for(int i = 0 ; i < 6010 ; i++) done[i] = -1;
		Q.push({s,-114514,cap*10,0});
		while( Q.size() ){
			NODE q = Q.top(); Q.pop();
			if( q.cap < 0 ) continue;
			if( q.src == gg ){
				cout << q.weight << endl;
				goto ok;
			}
			if( done[q.src] < q.cap ){
				done[q.src] = q.cap;
			}else continue;
			if( cap*10 != q.cap && LPG[q.src] ){
				Q.push({q.src,-114514,cap*10,q.weight});
			}else{
				for( auto e : g[q.src] ){
					Q.push({e.dst,-114514,q.cap-e.weight,q.weight+e.weight});
				}
			}
		}
		cout << -1 << endl;
		ok:;
		
		
	}
}

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

#define int long long

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; i < n - 2; i++)
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
			ans++;
	cout << ans;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;
 
int main() {
    int n;
    cin >> n;
    vector<char> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    if (n % 2 != 0) {
        cout<< "No"<<endl;
        return 0;
    }
    int j = n / 2;
    for (int i = 0; i < n / 2; i++, j++) {
        if (s[i] != s[j]) {
            cout << "No" <<endl;
            return 0;
        }
    }
    cout << "Yes"<<endl;
    return 0;
}

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

     int main(){
     int n,t,a;
     cin>>n>>t>>a;
     int h[n],ans=0;
     for(int i=0;i<n;i++) {
       cin >> h[i];
       if(abs(1000*(t-a)-h[i]*6)<abs(1000*(t-a)-h[ans]*6))ans=i;
     }
     cout<<ans+1<<endl;

     }

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc160/submissions/11310424

def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1

    def dist(a, b, X=X, Y=Y):
        return min(
            abs(a - b),
            abs(a - X) + abs(b - Y) + 1,
            abs(a - Y) + abs(b - X) + 1
        )

    ctr = [0] * N
    for b in range(N):
        for a in range(b):
            ctr[dist(a, b)] += 1

    it = iter(ctr)
    next(it)
    print(*it, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define int long long
int read(){
	int ans=0,f=1;
	char c=getchar();
	while(c<'0' && c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0' && c<='9'){
		ans=(ans<<3)+(ans<<1)+c-'0';
		c=getchar();
	}
	return ans*f;
}
int a[10010][10010],top[10010];
bool vis[10010];
int n,m,ans;
signed main(){
	int i,j,ans=0;
	n=read();
	for (i=1;i<=n;i++){
		top[i]=1;
		for (j=1;j<n;j++)a[i][j]=read();
	}
	while(++ans){
		memset(vis,0,sizeof vis);
		for (i=1;i<=n;i++){
			int x=a[i][top[i]];
			if(a[x][top[x]]==i && !vis[i] && !vis[x])top[i]++,top[x]++,vis[i]=vis[x]=1;
		}
		bool flag=0;
		for (i=1;i<=n;i++)if(top[i]<n){flag=1;break;}
		if(!flag)break;
		if(ans>n*(n-1)/2)return puts("-1"),0;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 78336
/*▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄█████████████  █▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
// #define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<int, int, int> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<char> vc;

const ll INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1000000007;
// const ll MAXN = 3e5;
const ld eps = 1e-6;
const ld eps2 = 1e-9;
const ll MOD2 = 998244353;
const ll dosz = 5e5;
const ll SZ = (1<<18);
const ld PI = atan2l(0, -1);


void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
        // freopen("a.in", "r",stdin);
#else
       // freopen("sum.in", "r", stdin);
       // freopen("sum.out", "w", stdout);
#endif
}


void solve(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int cnt = 0;
    while(a>0 && c>0){
        if(!cnt){
            c -= b;
        } else{
            a -= d;
        }
        cnt ^= 1;
    }
    if(cnt){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
} 
 

signed main() {
    fast_io();
    int q = 1;
    // cout << fixed;
    // cin >> q;
    while(q--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};



int main(){
    int n;cin >> n;
    int mi = INF, f = 0;
    for (int i = 0; i < n; i++) {
        int a;cin >> a;
        f = (f + a) % 2;
        chmin(mi, a);
    }
    if(n % 2){
        if(f) puts("First");
        else puts("Second");
    }
    else{
        if(mi % 2 == 0 && f == 0) puts("Second");
        else puts("First");
    }
    return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
     
     if(n > m){
     	for(int i = 1; i <= n; i++){
     		printf("%d", m);
     	}
     	printf("\n");
     }else{

     	for(int i = 1; i <= m; i++){
     		printf("%d", n);
     	}
     	printf("\n");

     }
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,ans=0;
    cin>>n>>m;
    for(int i=1;i*i<=m;i++)
        if(m%i==0){
            int i1=i,i2=m/i;
            if(i1<=m/n && i1>ans)
                ans=i1;
            if(i2<=m/n && i2>ans)
                ans=i2;
        }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <limits>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

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

  int a = 0, b = 0;
  for (int i = 0; i < s.size(); ++i)
  {
    if (s[i] == '0')
      a++;
    else
      b++;
  }
  cout << min(a, b) * 2 << endl;

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
 
int main(){
 int n;
 cin >> n;
 string tar,han;
 int ctar= 0,chan =0;
 
 for(int i=0; i<n; i++){
  cin >> tar >> han;
  for(int j=0; j<max(tar.size(),han.size());j++){
   if(tar[j] > han[j]){
    ctar += 3;
    break;
   }
   else if(tar[j] < han[j]){
    chan += 3;
    break;
   }
   if(j == max(tar.size(),han.size())-1 ){
    ctar++;
    chan++;
   }
  }
 }
 cout << ctar << " " << chan << endl;
}


Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

#define ll long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define per(i,a,n) for(int i = n-1; i >= a; i--)

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

  if (s.size() < 4) {
    cout << "No" << endl;
    return 0;
  }

  s = s.substr(0,4);
  if (s == "YAKI")
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

double dp[300000][20];
double ans[300000];

int main(){
	dp[0][0]=1;
	double sum=0;
	rep(i,200000){
		ans[i]=sum;
		rep(j,15){
			if(dp[i][j]==0)continue;
			double p=1;rep(k,j)p*=0.5;
			sum+=p*dp[i][j];
			dp[i+1][j+1]+=dp[i][j]*p;
			dp[i+1][0]+=dp[i][j]*(1-p);
		}
	}
	int n;
	while(cin>>n,n){
		printf("%.12lf\n",ans[n]);
	}
}


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

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

    if (c >= 'a')
        cout << "a\n";
    else
        cout << "A\n";

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>

using namespace std;
int n, a[200001];
int fr[200001];
int main()
{
    cin >> n;
    for(int i = 1; i < n; i++) {
        int x;
        cin >> x;
        fr[x]++;
    }

    for(int i = 1; i <= n; i++)
        cout << fr[i] << "\n";
    return 0;
}


Measured memory_bytes: 4404
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

ll rui(ll a,ll n){
  ll ans=1;
  while(n>0){
    if(n&1) ans=ans*a%mod;
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int> > s(m);
  rep(i,m){
    int k; cin >> k;
    rep(j,k){
      int a; cin >> a; a--;
      s[i].push_back(a);
    }
  }
  vector<int> p(m);
  rep(i,m) cin >> p[i];
  int ans=0;
  rep(i,(1<<n)){
    vector<int> cnt(m,0);
    rep(j,m){
      rep(k,s[j].size()){
        if(i&(1<<s[j][k])) cnt[j]++;
      }
      cnt[j]%=2;
    }
    bool f=1;
    rep(j,m) if(cnt[j]!=p[j]) f=0;
    if(f){
      ans++;
      //cout << i << endl;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define PB push_back
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;

int n;
int ans[2007];
int dist[2007];
vector<vi> graph;

void bfs(int i){
	FOR(i, n) dist[i] = 1e9;
	queue<pii> q;
	bitset<2007> vis;
	q.push({i, 0});
	while(!q.empty()){
		int atual = q.front().F;
		int d = q.front().S;
		q.pop();
		dist[atual] = min(dist[atual], d);
		if(vis[atual] == 1) continue;
		vis[atual] = 1;
		for(auto& v : graph[atual]){
			if(vis[v] == 0){
				q.push({v, d+1});
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 
	int x, y; cin >> n >> x >> y;
	graph.resize(n);
	FOR(i, n-1){
		graph[i].PB(i+1);
		graph[i+1].PB(i);
	}
	graph[x-1].PB(y-1);
	graph[y-1].PB(x-1);
	
	FOR(i, n){
		bfs(i);
		FOR(i, n)
			ans[dist[i]]++;
	}

	FOR(i, n-1)
		cout << ans[i+1]/2 << '\n';

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cmath>
#include <time.h>
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) ((c).rbegin(),(c).rend())
#define ll long long
#define fi first
#define se second
#define inf (999999999)
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n, q;
int par[10100], rank1[10100];
inline void init() {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		rank1[i] = 0;
	}
}
inline int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		par[x] = find(par[x]);
		return par[x];
	}
}
inline bool same(int x,int y) {
	return find(x) == find(y);
}
inline void unite(int x, int y) {
	if (find(x) == find(y))return;
	else {
		if (rank1[x] > rank1[y]) {
			par[y] = x;
		}
		else {
			par[x] = y;
			if (rank1[x] == rank1[y]) {
				rank1[y]++;
			}
		}
	}
}
inline void Union(int x,int y) {
	unite(find(x), find(y));
}
int main() {
	cin >> n >> q;
	init();
	for (int i = 0; i < q; i++) {
		int comp, x, y; cin >> comp >> x >> y;
		if (comp) {
			//cout << comp << " " << x << " " << y << endl;
			//for (int j = 0; j < n; j++) {
				//cout << par[j] << " ";
			//}
			//cout << endl;
			cout << same(x, y) << endl;
		}
		else {
			Union(x, y);
		}
	}
	return 0;
}

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

int main(){
  int N, X, T;
  cin >> N >> X >> T;
  if(N % X == 0){
    cout << N * T / X << endl;
  }
  else{
    cout << (N / X + 1) * T << endl;
  }
}

Measured memory_bytes: 3632
#include<stdio.h>

int main()
{
	int w,h,n,i;
	
	int x1,x2,x3,x4;
	int y1,y2,y3,y4;
	
	if(scanf("%d %d %d",&w,&h,&n) < 3) {
    fprintf(stderr, "error: ill-formed fraction.\n");
    exit(1);
		
	}
	int a,b,c;
	
	x1 = 0;
	y1 = 0;
	x2 = w;
	y2 = 0;
	x3 = 0;
	y3 = h;
	x4 = w;
	y4 = h;
	

	
	for(i=0;i<n;i++){
		if(scanf("%d %d %d",&a,&b,&c) < 3) {
    fprintf(stderr, "error: ill-formed fraction.\n");
    exit(1);
		}
		
		switch(c){
			case 1:if(x1<a){
				x1 = a;
				x3 = a;
			}
			break;
			case 2:if(x2>a){
				x2 = a;
				x4 = a;
			}
			break;
			case 3:if(y1<b){
				y1 = b;
				y2 = b;
			}
			break;
			case 4:if(y3>b){
				y3 = b;
				y4 = b;
			}
			break;
		}
	}
		
		int xa,ya;
		xa = x2-x1;
		ya = y3-y1;
		if(xa<0||ya<0){
			printf("0\n");
		}else{
			printf("%d\n",xa*ya);
		}
	return 0;
}

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

int main(){
int n, sum=0,dummy;
cin >> n;
vector <int> a;
vector<int>b;
for (int i=0;i<n;i++){
cin >> dummy;
a.push_back(dummy);
}
for (int i=0;i<n;i++){
cin >> dummy;
b.push_back(dummy);
}
for (int i = 0;i<n;i++){
if (a[i]>b[i]){
sum+= a[i]-b[i];}
}
cout << sum << "\n";
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n;
  cin>>k;
  int ans=1;
  for(int i=i=0;i<n;i++){
    if(ans<k) ans+=ans;
    else ans+=k;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    static Scanner in;
    static PrintWriter out;


    static final int mod = (int) 1e9 + 7;
    static final int inf = 0x3f3f3f3f;
    static final int maxn = (int) 500 + 2;
    static int total;
    static int[] par = new int[maxn];

    public static void main(String[] args) throws Exception {
        //Test.main();
        try {
            System.setIn(new FileInputStream("night_input"));
        } catch (FileNotFoundException e) {

        }

        in = new Scanner(System.in);
        out = new PrintWriter(System.out);


        int n;
        Integer[] a = new Integer[110];

        while (in.hasNext()) {
            n = in.nextInt();
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }
            Arrays.sort(a, 0, n, Comparator.reverseOrder());
            int sum = 0;
            for (int i = 0; i < n; ++i) {
                sum += (i % 2 == 0 ? 1 : -1) * a[i];
            }
            out.println(sum);
        }

        in.close();
        out.close();
    }

    static int find(int x) {
        return (par[x] = par[x] == x ? x : find(par[x]));
    }

    static void init() {
        total = 0;
        for (int i = 0; i < par.length; ++i) {
            par[i] = i;
        }
    }
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1e9

typedef long long ll;

int dp[41][401][401];
int n, m_a, m_b;
int a[41], b[41], c[41];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m_a >> m_b;
    for(int i = 1; i <= n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    for(int i = 0; i <= 400; i++){
        for(int j = 0; j <= 400; j++){
            dp[0][i][j] = INF;
        }
    }
    dp[0][0][0] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= 400; j++){
            for(int k = 0; k <= 400; k++){
                dp[i][j][k] = INF;
                dp[i][j][k] = min(dp[i][j][k],dp[i-1][j][k]);
                if(j - a[i] >= 0 && k - b[i] >= 0){
                        dp[i][j][k] = min(dp[i][j][k], dp[i-1][j-a[i]][k-b[i]] + c[i]);
                }
            }
        }
    }
    int ans = INF;
    int i = 1;
    while(i*m_a <= 400 && i*m_b <= 400){
        ans = min(ans, dp[n][i*m_a][i*m_b]);
        i++;
    }
    if(ans >= INF){
        cout << -1;
    }
    else{
        cout << ans;
    }
}


Measured memory_bytes: 25984
def main():
  N, K = (int(x) for x in input().split())
  p = [(int(x)+1)/2 for x in input().split()]
  wa = [0] * (N + 1)
  for i in range(1, N + 1):
    wa[i] = wa[i-1] + p[i-1]
  ret = 0
  for i in range(N-K+1):
    ret = max(ret, wa[K+i]-wa[i])
  print(ret)
  return

if __name__ == '__main__':
  main()
    

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

int main()
{
    int N, val, left = 400, right = 600;
    cin>>N;
    val = 8;
    while(true)
    {
        if(left<=N && N<right)
        {
            cout<<val;
            break;
        }
        else
        {
            left+=200;
            right+=200;
            val-=1;
        }
    }
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

int N, X, T;

int main() {
    cin >> N >> X >> T;
    cout << (N + X - 1) / X * T << endl;
}

Measured memory_bytes: 3564