akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <list>
#include <utility>

void calc_counter(int N, std::vector<long long> &counter,
    std::vector<long long> &plus_count,
    std::vector<std::list<long long> > &to_list,
    long long from, long long tmp, long long sum)
{
    sum += plus_count[tmp];
    counter[tmp] = sum;
    // printf("%lld, %lld, %lld, %lld\n", from, tmp, plus_count[tmp], sum);
    // for(int i=0; i<N-1; i++){
    //     if(a[i] == tmp && b[i] != from)
    //         calc_counter(N, counter, plus_count, a, b, tmp, b[i], sum);
    //     else if(b[i] == tmp && a[i] != from)
    //         calc_counter(N, counter, plus_count, a, b, tmp, a[i], sum);
    // }
    for(auto &&itr = to_list[tmp].begin(); itr != to_list[tmp].end(); itr++){
        if((*itr) != from)
            calc_counter(N, counter, plus_count, to_list, tmp, *itr, sum);
    }
}

int main()
{
    int N, Q;
    std::cin >> N >> Q;
    std::vector<long long> a(N-1), b(N-1);
    for(int i=0; i<N-1; i++){
        scanf(" %lld %lld", &a[i], &b[i]);
        a[i]--; b[i]--;
    }
    std::vector<long long> p(Q), x(Q);
    for(int i=0; i<Q; i++){
        scanf(" %lld %lld", &p[i], &x[i]);
        p[i]--;
    }

    std::vector<long long> plus_count(N, 0);
    for(int i=0; i<Q; i++){
        plus_count[p[i]] += x[i];
    }

    std::vector<std::list<long long> > to_list(N);
    for(int i=0; i<N-1; i++){
        to_list[a[i]].push_back(b[i]);
        to_list[b[i]].push_back(a[i]);
    }

    std::vector<long long> counter(N);
    calc_counter(N, counter, plus_count, to_list, -1, 0, 0);

    for(int i=0; i<N; i++) printf("%lld ", counter[i]);
    printf("\n");
}

Measured memory_bytes: 49280
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int a[12][12];
int f[12][12];
int res[12][12];
int b[20] = {1};
int dh[5] = {0, 0, 0, 1, -1};
int dw[5] = {0, 1, -1, 0, 0};

signed main(void){
  int i, j, k, l;
  rep1(i, 20)b[i] = b[i - 1] << 1;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n);
    for(;n--;){
      rep(i, 10)rep(j, 10)scanf("%d", &a[i + 1][j + 1]);
      rep(k, b[10]){
        rep(i, 12)rep(j, 12){
          f[i][j] = a[i][j];
          res[i][j] = 0;
        }
        for(int x = k, d = 1;x;x /= 2){
          res[1][d] = x % 2;
          if(x % 2 == 1)rep(l, 5)f[1 + dh[l]][d + dw[l]] ^= 1;
          ++d;
        }

        rep1(i, 10)rep(j, 10)if(f[i][j + 1] == 1){
          res[i + 1][j + 1] = 1;
          rep(l, 5)f[i + 1 + dh[l]][j + 1 + dw[l]] ^= 1;
        }
        bool isok = true;
        rep(i, 10)rep(j, 10)if(f[i + 1][j + 1] == 1)isok = false;
        if(isok){
          rep(i, 10){
            rep(j, 9)printf("%d ", res[i + 1][j + 1]);
            printf("%d\n", res[i + 1][j + 1]);
          }
          break;
        }
      }
    }


/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3192
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<string> cells(H);
    REP(h, H) cin >> cells[h];
    
    // <x,y>
    vector<vector<int>> seen(H, vector<int>(W));
    vector<pair<int,int>> blacks;
    REP(h, H) {
        REP(w, W) {
            if (cells[h][w] == '#') {
                blacks.pb(mp(w, h));
                seen[h][w] = 1;
            }
        }
    }

    int dy[] = {0, 0, 1, -1};
    int dx[] = {1, -1, 0, 0};
    int ans = 1;
    while(1) {
        // cout << "====" << endl;
        // REP(h, H) {
        //     REP(w, W) cout << seen[h][w] << " ";
        //     cout << endl;
        // }
        // cout << endl;

        vector<pair<int,int>> next;
        for(auto xy: blacks) {
            auto x = xy.first;
            auto y = xy.second;
            REP(d, 4) {
                auto x2 = x + dx[d];
                auto y2 = y + dy[d];
                if (x2 < 0 || x2 >= W || y2 < 0 || y2 >= H) continue;
                if (seen[y2][x2]) continue;
                
                next.pb(mp(x2, y2));
                seen[y2][x2] = ans + 1;
            }
        }

        if (SIZE(next) == 0) break;
        blacks = next;
        
        ++ans;
    }
    cout << ans - 1 << endl;

    return 0;
}


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

int main(){
  vector<int> A(3);
  for(int i=0;i<3;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());

  if(A.at(0)==A.at(1)){
    if(A.at(1)==A.at(2)){
    cout << 1 << endl;
  }else{
    cout << 2 << endl;
  }
  }else{
    if(A.at(1)==A.at(2)){
    cout << 2 << endl;
  }else{
    cout << 3 << endl;
  }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const ll MOD=1e9+7; //定义MOD代替1e9+7
int n,i,j,k;
ll dp[101][4][4][4],ans; 
int main()
{
	cin>>n;
	for(i=0;i<4;i++)
		for(j=0;j<4;j++)
			for(k=0;k<4;k++)
				if((i==0&&j==1&&k==2)||(i==0&&j==2&&k==1)||(i==2&&j==0&&k==1))
					dp[3][i][j][k]=0;
				else
					dp[3][i][j][k]=1;

	for (int len=4;len<=n;++len)
		for (int i=0;i<4;++i)
			for (int j=0;j<4;++j)
				for (int k=0;k<4;++k)
					for (int l=0;l<4;++l)
					{
						if (j==0 && k==2 && l==1) continue;
						if (j==2 && k==0 && l==1) continue;
						if (j==0 && k==1 && l==2) continue;
						if (i==0 && k==2 && l==1) continue;
						if (i==0 && j==2 && l==1) continue;
						dp[len][j][k][l]+=dp[len-1][i][j][k];
						dp[len][j][k][l]%=MOD;
					}
	for (int i=0;i<4;++i)
		for (int j=0;j<4;++j)
			for (int k=0;k<4;++k)
				ans+=dp[n][i][j][k],ans%=MOD;//最终求len=n时的总数，累加
	cout<<ans; 
	return 0;
}

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

int main(){
	string s, t;
  	cin >> s >> t;
  
  	int ans = 0;
  	rep(i, 3){
    	if(s[i] == t[i]) ans++;
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 3624
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 130000;
char cn[CM + 10], * ci = cn + 10, c, * owa = cn + CM;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	swap(c, ci[8]);
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	swap(c, ci[8]);
	ci += (64 - dig >> 3) + 1;

	if (ci - owa > 0) {
		memcpy(cn, owa, 10);
		ci -= CM;
		fread(cn + 10, 1, CM, stdin);
	}
	return tmp;
}

char* di = cn;
const int MAX = 200000;
class shuturyoku_unko {
public:
	char C[MAX * 6 - 100000];
	int K[MAX + 10];
	constexpr shuturyoku_unko() : C(), K() {
		auto di = C + 1;
		C[0] = '0';
		K[1] = 1;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
			K[i + 1] = K[i] + keta;
		}
	}
} f;
inline void putint(ll X) {
	int ue = X / 100000;
	if (ue) {
		memcpy(di, f.C + f.K[ue], f.K[ue + 1] - f.K[ue]);
		di += f.K[ue + 1] - f.K[ue];
		int sita = X - ue * 100000ll;
		rep(i, 5 - f.K[sita + 1] + f.K[sita])* di++ = '0';
		for (int i = f.K[sita]; i < f.K[sita + 1]; i++)* di++ = f.C[i];
	}
	else for (int i = f.K[X]; i < f.K[X + 1]; i++)* di++ = f.C[i];
	*di++ = '\n';
}

int B[200001];

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


	fread(ci, 1, CM, stdin);

	int N = getint();
	ll kotae = 1;
	int A[200000];
	rep(i, N) kotae += B[(A[i] = getint())]++;
	int *a = A;
	
	int amari = N % 10800;
	int shou = N / 10800;
	rep(j, shou) {
		rep(k, 10800) putint(kotae - B[*a++]);
		fwrite(cn, 1, di - cn, stdout);
		di = cn;
	}
	rep(k, amari) putint(kotae - B[*a++]);
	fwrite(cn, 1, di - cn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s, t;
	cin >> s >> t;
	for(int i = 0; i < s.size(); i++){
		if(s[i] != t[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3628
from itertools import permutations as p


N = int(input())
P = "".join(input().split())
Q = "".join(input().split())

permutations = ["".join(str(i) for i in iterable) for iterable in p(range(1,N+1))]

print(
    abs(permutations.index(P) - permutations.index(Q))
)

Measured memory_bytes: 6040
#include <stdio.h>

int main(void)
{
   int N,n=3;
   int ABCD[4];
   char cal[3]={'+','+','+'};
  scanf("%d",&N);
  while(n>=0){
  	ABCD[n]=N%10;
  	N/=10;
  	n--;
  }
  int a,b,c,d;
 // printf("%d%c%d%c%d%c%d=7\n",ABCD[0],cal[0],ABCD[1],cal[1],ABCD[2],cal[2],ABCD[3]);
  for(a=0;a<8;a++){
  	int ans=ABCD[0];

  	if((a&4)==4){ans+=ABCD[1];cal[0]='+';}else{ans-=ABCD[1];cal[0]='-';}

  	if((a&2)==2){ans+=ABCD[2];cal[1]='+';}else{ans-=ABCD[2];cal[1]='-';}

  	if((a&1)==1){ans+=ABCD[3];cal[2]='+';}else{ans-=ABCD[3];cal[2]='-';}

  	if(ans==7){
  		printf("%d%c%d%c%d%c%d=7\n",ABCD[0],cal[0],ABCD[1],cal[1],ABCD[2],cal[2],ABCD[3]);
  		break;
  	}
  }
	return 0;
}

Measured memory_bytes: 128
## coding: UTF-8
from collections import deque

N = int(input())
c = input()
l = deque()
for i in range(N):
    l.append(c[i])
#print(l)


t = 0
#前処理(t = 0)
def shori():
    stat = True
    while stat:
        if(len(l) > 0):
            if(l[0] == 'R'):
                l.popleft()
            else:
                stat = False
        else:
            stat = False

    stat = True
    while stat:
        if(len(l) > 0):
            if(l[-1] == 'W'):
                l.pop()
            else:
                stat = False
        else:
            stat = False

    #print('t=', t, l)

shori()

while len(l) > 0:
    l.popleft()
    l.pop()
    t += 1
    shori()

print(t)



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

int main()
{
    int n, m, c;
    scanf("%d %d %d", &n, &m, &c);
    int *bs;
    bs = (int *)calloc(m, sizeof(int));
    if (bs == NULL) {
        exit(EXIT_FAILURE);
    }
    for (int i=0; i<m; i++) {
        scanf("%d" , &bs[i]);
    }
    int **as;
    as = (int **)calloc(n, sizeof(int *));
    for (int i=0; i<n; i++) {
        as[i] = (int *)calloc(m, sizeof(int));
    }
    if (as == NULL) {
        exit(EXIT_FAILURE);
    }
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            scanf("%d" , &as[i][j]);
        }
    }
    int ans = 0;
    for (int i=0; i<n; i++) {
        int sum = 0;
        for (int j=0; j<m; j++) {
            sum += bs[j] * as[i][j];
        }
        if ((sum + c) > 0) {
            ans++;
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var card = new List<string[]>();
            card.Add(Console.ReadLine().Split());
            card.Add(Console.ReadLine().Split());
            card.Add(Console.ReadLine().Split());
            var N = int.Parse(Console.ReadLine());
            var nums = new List<string>();
            for(var i=0;i<N;i++)
            {
                nums.Add(Console.ReadLine());
            }
            foreach(var num in nums)
            {
                for(var i=0;i<3;i++)
                {
                    for(var j=0;j<3;j++)
                    {
                        if (card[i][j] == num) card[i][j] = "";
                    }
                }
            }
            for (var i = 0; i < 3; i++)
            {
                if (card[i][0] == "" && card[i][1] == "" && card[i][2] == "")
                {
                    Console.WriteLine("Yes");
                    return;
                }
                if (card[0][i] == "" && card[1][i] == "" && card[2][i] == "")
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            if (card[0][0] == "" && card[1][1] == "" && card[2][2] == "")
            {
                Console.WriteLine("Yes");
                return;
            }
            if (card[0][2] == "" && card[1][1] == "" && card[2][0] == "")
            {
                Console.WriteLine("Yes");
                return;
            }
                Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13396
from sys import stdin
import math
def input():
	return stdin.readline()[:-1]

def intput():
	return int(input().rstrip())

def sinput():
	return input().rstrip().split()

def intsput():
	return map(int, sinput())

def main():
	str = input()
	val = 700
	for i in str:
		if (i == 'o'):
			val += 100
	print(val)

if __name__ == '__main__':
	main()

Measured memory_bytes: 38256
#include <cstdio>
#include <vector>

using namespace std;

int na,nb;
vector<int> va,vb;

int check(int sb){
	int ans = 0;
	int a = 0;
	for(int b=sb;b<nb;b++){
		while(1){
			if(vb[b] == va[a]){
				//printf("Find a[%d] , b[%d] -> %d\n",a,b,va[a]);
				ans++;
				a++;
				break;
			}else{
				a++;
				if(a >= na){
					return ans;
				}
			}
		}
	}	
	return ans;
}

int main(){
	int self;
	scanf("%d %d",&na,&nb);
	for(int i=0;i<na;i++){
		scanf("%d",&self);
		va.push_back(self);
	}
	for(int i=0;i<nb;i++){
		scanf("%d",&self);
		vb.push_back(self);
	}
	
	int ans = 0;
	for(int i=0;i<nb;i++){
		self = check(i);
		//printf("%d->%d\n",i,self);
		if(self > ans){
			ans = self;
		}
	}
	
	printf("%d\n",ans);
}

Measured memory_bytes: 844
H,W = map(int,input().split())
src = [input() for i in range(H)]

ans = []
for row in src:
    ans.append(list(row))

dxy = [(-1,-1),(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1)]
for y in range(H):
    for x in range(W):
        if ans[y][x] == '#': continue
        c = 0
        for dx,dy in dxy:
            if x+dx < 0 or x+dx > W-1 or y+dy < 0 or y+dy > H-1: continue
            if ans[y+dy][x+dx] == '#': c += 1
        ans[y][x] = c

for row in ans:
    print("".join(list(map(str,row))))

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

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if ( a!=1 && b!=1 && c!=1 && d!=1 ) {cout << "NO" << endl;}
	else if ( a!=7 && b!=7 && c!=7 && d!=7 ) {cout << "NO" << endl;}
	else if ( a!=9 && b!=9 && c!=9 && d!=9 ) {cout << "NO" << endl;}
	else if ( a!=4 && b!=4 && c!=4 && d!=4 ) {cout << "NO" << endl;}
	else cout << "YES" << endl;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

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

    string s;
    cin >> s;

    if (s.back() == 's') s += "es";
    else s += "s";
    cout << s << "\n";

    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;

int main(void)
{
    int a,b;
    cin>>a>>b;
    int sum = 0;
    for(int i = a; i <= b; ++i)
    {

        string s(to_string(i));
        int t = s.size();
        bool yes = true;
        for(int i = 0; i < t/2; ++i)
            if(s[i] != s[t-i-1])
            {
                yes = false;
                break;
            }
        sum += yes;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define pb  push_back
#define mp make_pair
#define ll long long
#define pr pair<int, int> 
#define vpr vector<pr> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define all(n) n.begin(),n.end()
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define Test printf("Case %d: ",tc++);
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
const int mod = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;

int solve() 
{
	//happy coding

	int n;
	cin>>n;
	int a[n+1];
	map<int,int>m;
	for(int i=0;i<n-1;i++){
		cin>>a[i];
		m[a[i]]++;
	}

	for(int i=1;i<=n;i++){
		cout<<m[i]<<endl;
	}
	

	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}

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

using namespace std;

int main() {
	int a, n, m, y, mul, tmp, sum, cnt;

	y = 1;
	cnt = 0;
	cin >> a >> n >> m;
	mul = pow(y + a, n);
	while (mul > 0 && mul <= m) {
		sum = 0;
		tmp = mul;
		while (tmp) {
			sum += tmp % 10;
			tmp /= 10;
		}
		if (y == sum) {
			++cnt;
		}
		++y;
		mul = pow(y + a, n);
	}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3268
N,A,B = map(int,input().split())
X = list(map(int,input().split()))

ans = 0
for i in range(1,N):
    if (X[i]-X[i-1])*A > B:
        ans += B
    else:
        ans += (X[i]-X[i-1])*A
print(ans)

Measured memory_bytes: 14252
// Problem : B - Mix Juice
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vlli vector<int>
#define slli set<int>
#define mlli map<int,int>
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fint fast;test
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;

void solve(){
	int n,k;
	cin>>n>>k;
	int arr[n];
	FOR(i,n)cin>>arr[i];
	sort(arr,arr+n);
	int y=min(n,k);
	int ans=0;
	int i=0;
	while(y--)ans+=arr[i++];
	cout<<ans;
	return;	
}


int32_t main() {
    // fint{
    	fast;
    	solve();
    // }
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#define FL "a"
using namespace std;
typedef long long ll;
typedef long double dd;
const int N=105;
inline ll read(){
  ll d=0,w=1;char ch=getchar();
  while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
  if(ch=='-')w=-1,ch=getchar();
  while(ch<='9'&&ch>='0')d=d*10+ch-48,ch=getchar();
  return d*w;
}
inline void file(){
  freopen(FL".in","r",stdin);
  freopen(FL".out","w",stdout);
}

char s[N];int n,res;
int main()
{
  n=read();scanf("%s",s+1);
  for(int i=1;i<=n;i++)
    res+=s[i]=='R'?1:-1;
  puts(res>0?"Yes":"No");
  return 0;
}


Measured memory_bytes: 256
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<typeof((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------

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

    VVI A(N, VI(N));
    VVI use(N, VI(N, true));

    REP(i, N)
    {
        REP(j, N)
        {
            cin >> A[i][j];
        }
    }

    REP(i, N)
    {
        REP(j, N)
        {
            REP(k, N)
            {
                if (i != k && j != k) {
                    if (A[i][j] > A[i][k] + A[k][j]) {
                        cout << -1 << endl;
                        return 0;
                    }

                    if (A[i][j] == A[i][k] + A[k][j]) {
                        use[i][j] = false;
                    }
                }
            }
        }
    }

    ll sum = 0;

    REP(i, N)
    {
        REP(j, N)
        {
            if (use[i][j])
                sum += A[i][j];
        }
    }

    cout << sum / 2 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
/*int p = 998244353;*/
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
#define end_pr(s) cout << s <<endl;return 0
#define itn int
int RE() {
	vel v(3, 2);
	return v.at(4);
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a,p - 2);
}
vel dis(int mid1, vvel &way) {
	int n = way.size();
	vel dist(n, -1); dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front(); q.pop();
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
pin most_far(int now, int n, vvel &way) {
	vel dist1 = dis(now, way);
	pin ans = mkp(-1, 0);
	rep(i, n) {
		if (dist1[i] > ans.first) { ans = mkp(dist1[i], i); }
	}
	return ans;
}

template<typename T>
V<T> uni(V<T> &v) {
	if (v.size() == 0) { return v; }
	sor(v);
	V<T> ans(1, v[0]);
	for (int i = 1; i < v.size(); i++) {
		if (v[i] != v[i - 1]) { ans.push_back(v[i]); }
	}
	v = ans;
	return v;
}
int s_gcd(int a, int b) {
	if (b == 0) { return a; }
	return s_gcd(b, a%b);
}
int gcd(int a, int b) {
	a = abs(a);
	b = abs(b);
	if (a < b) { swap(a, b); }
	return s_gcd(a, b);
}
vel dx{ 1,1,0,0,-1,-1 };
vel dy{ 0,1,1,-1,-1,0 };
int solve(int i, vvel &chi, vel &p) {
	if (chi[i].size() == 0) {
		return (p[i]/2)+1;
	}
	vel list;
	for (auto x : chi[i]) { list.push_back(solve(x,chi,p)); }
	sor(list);
	int n = list.size(); n = (n + 1) / 2;
	int ans = 0;
	rep(i, n) { ans += list[i]; }
	return ans;
}
signed main() {
	while (true) {
		int n; cin >> n;
		V<qin> c(1);
		int w, d; cin >> w >> d;
		if (w == 0) { break; }
		c[0] = mkp(w*d, mkp(w, d));
		rep(i, n) {
			int p1; cin >> p1; p1--;
			int s1; cin >> s1;
			V<qin> nc;
			rep(j, i + 1) { if (j != p1) { nc.push_back(c[j]); } }
			int w1 = c[p1].second.first;
			int h1 = c[p1].second.second;
			s1 %= (h1 + w1);
			if (s1 < w1) {
				V<qin> qnc;
				qnc.push_back(mkp(s1*h1, mkp(s1, h1)));
				qnc.push_back(mkp((w1 - s1)*h1, mkp(w1 - s1, h1)));
				sor(qnc);
				rep(j, 2) { nc.push_back(qnc[j]); }
			}
			else {
				V<qin> qnc;
				s1 -= w1;
				qnc.push_back(mkp(w1*s1, mkp(w1, s1)));
				qnc.push_back(mkp(w1*(h1 - s1), mkp(w1, h1 - s1)));
				sor(qnc);
				rep(j, 2) { nc.push_back(qnc[j]); }
			}
			c = nc;
			nc = {};
		}
		sor(c);
		rep(i, n) { cout << c[i].first << " "; }
		cout << c[n].first << endl;
	}
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N;
  cin >> N;
  ll A[1LL << 18];
  REP(i, 0, 1LL << N) scanf("%lld", A + i);

  ll ans = 0;
  REP(k, 1, 1LL << N) {
    ll p = 0, q = 0;
    ll i = k;
    do {
      if(A[i] > p) {
        q = p;
        p = A[i];
      } else if(A[i] > q) {
        q = A[i];
      }
      i = (i - 1) & k;
    } while(i != k);
    if(p + q > ans) ans = p + q;
    printf("%lld\n", ans);
  }
}

Measured memory_bytes: 5120
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		if(a <= b*2) {
			System.out.println(0);
		}else {
			System.out.println(a-b*2);
		}
		
	}

}


Measured memory_bytes: 25172
MOD =  1000000007

N, M = map(int, input().split())

a_list = set()
for _ in range(M):
	a_list.add(int(input()))

#print(a_list)

counts = [0] * (N + 10)
counts[0] = 1
for i in range(N):
	if not i in a_list:
		counts[i + 1] = (counts[i + 1] + counts[i]) % MOD
		counts[i + 2] = (counts[i + 2] + counts[i]) % MOD

#print(counts)
print(counts[N])


Measured memory_bytes: 11968
#include<stdio.h>
#define N 100000
typedef struct treeee
{
  int p;
  int l;
  int r;
}tree;
tree T[N];
int n;

int depth(int i){
  int count=0,iNoOya;
  iNoOya=i;
  while(1){
    if(T[iNoOya].p==-1) break;
    iNoOya=T[iNoOya].p;
    count++;
    
  }
  return count;
}

void hantei(int i){
  if(T[i].l==-1&&T[i].p!=-1) printf("leaf,");
  else if( T[i].p == -1)printf("root,");
  else if(T[i].l !=-1) printf("internal node,");
}

void printChild(int i){
  int ani;
  printf(" [");
  if(T[i].l !=-1){
    printf("%d",T[i].l);
    ani= T[i].l;
    while(1){
      if(T[ani].r==-1)break;
      printf(", %d",T[ani].r);
      ani=T[ani].r;
    }
  }
  printf("]\n");
}



int main(){
    int i,j,node,zisu,child,left;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=-1;
    T[i].l=-1;
    T[i].r=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&node,&zisu);
    for(j=0;j<zisu;j++){
      scanf("%d",&child);
      if(j==0){
	T[node].l=child;
	T[child].p = node;
      }   
      else{
	T[left].r=child;
	T[child].p=node;
      }
      left = child;
    }
  }

  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,depth(i));
    hantei(i);
    printChild(i);
   
  }
  return 0;
}

Measured memory_bytes: 1784
#include <iostream>
using namespace std;
int main() {
  int A, B;
  cin >> A;
  cin >> B;
 
  if (A != B && B == 1) {
    if (A == 2) {
      cout << 3 << endl;
    }
    else {
      cout << 2 << endl;
    }
  }
  if (A != B && B == 2) {
    if (A == 1) {
      cout << 3 << endl;
    }
    else {
      cout << 1 << endl;
    }
  }
   if (A != B && B == 3) {
    if (A == 2) {
      cout << 1 << endl;
    }
    else {
      cout << 2 << endl;
    }
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <functional>
#include<cstdio>  

using namespace std;

int main(void){
	int n,m;
	int a;
	while(1){
		cin >> n >> m;
		if(n==0 && m==0)break;
		int ans=0;
		vector<int> num;
		for(a=0;a<n;a++){
			int nn;
			scanf("%d",&nn);
			num.push_back(nn);
		}
		sort(num.begin(),num.end(), greater<int>() );
		for(a=0;a<n;a++){
			ans+=num[a];
		}
		for(a=1*m-1;a<n;a+=m){
			ans-=num[a];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 0
package main

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

func fill(s []int, x int) {
	for i := 0; i < len(s); i++ {
		s[i] = x
	}
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func readKey() [2]int {
	a := readInt()
	b := readInt()
	m := 0
	for i := 0; i < b; i++ {
		c := readInt()
		m |= 1 << uint(c-1)
	}
	return [2]int{a, m}
}

func main() {
	N := readInt()
	M := readInt()
	keys := make([][2]int, M)
	for i := 0; i < M; i++ {
		keys[i] = readKey()
	}

	dp := make([]int, 1<<uint(N))
	fill(dp, math.MaxInt64)

	dp[0] = 0
	maxM := 0
	for i := 0; i < M; i++ {
		a, m := keys[i][0], keys[i][1]
		for j := maxM; j >= 0; j-- {
			if dp[j] == math.MaxInt64 {
				continue
			}
			if j|m > maxM {
				maxM = j|m
			}
			if dp[j]+a < dp[j|m] {
				dp[j|m] = dp[j]+a
			}
		}
	}
	if dp[(1<<uint(N))-1] == math.MaxInt64 {
		fmt.Println(-1)
	} else {
		fmt.Println(dp[(1<<uint(N))-1])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define ri register int
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> poly;
#define pb push_back
const int rlen=1<<18|1,inf=0x3f3f3f3f;
const ll Inf=1e18;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read() {
  int ans=0;
  bool f=1;
  char ch=gc();
  while(!isdigit(ch)) f^=ch=='-',ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return f?ans:-ans;
}
inline ll readl() {
  ll ans=0;
  bool f=1;
  char ch=gc();
  while(!isdigit(ch)) f^=ch=='-',ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return f?ans:-ans;
}
inline int Read(char*s) {
  int tp=0;
  char ch=gc();
  while(!isdigit(ch)&&!isalpha(ch)) ch=gc();
  while(isdigit(ch)||isalpha(ch)) s[++tp]=ch,ch=gc();
  return tp;
}
namespace modular {
  const int mod=998244353;
  inline int add(int a,int b) { return a+b<mod?a+b:a+b-mod; }
  inline int dec(int a,int b) { return a<b?a-b+mod:a-b; }
  inline int mul(int a,int b) { return (ll)a*b%mod; }
  inline void Add(int&a,int b) { a=a+b<mod?a+b:a+b-mod; }
  inline void Dec(int&a,int b) { a=a<b?a-b+mod:a-b; }
  inline void Mul(int&a,int b) { a=(ll)a*b%mod; }
  inline int ksm(int a,int p) { int ret=1;for(;p;p>>=1,Mul(a,a)) (p&1)&&(Mul(ret,a),1);return ret; }
  inline int Inv(int a) { return ksm(a,mod-2); }
  inline int sqr(int a) { return mul(a,a); }
  inline int cub(int a) { return (ll)a*a%mod*a%mod; }
}
using namespace modular;
template<typename T> inline void ckmax(T&a,T b) { a<b?a=b:0; }
template<typename T> inline void ckmin(T&a,T b) { a>b?a=b:0; }
template<typename T> inline T gcd(T a,T b) { T t;while(b)t=a,a=b,b=t-t/a*a;return a; }
template<typename T> inline T Abs(T x) { return x<0?-x:x; }
inline int rd() { return rand()|(rand()<<15); }
const int N=1e7+5;
int n,fac[N],ifac[N];
inline int C(int n,int m) { return n<m||m<0?0:mul(fac[n],mul(ifac[m],ifac[n-m])); }
inline void init_fac() {
  fac[0]=fac[1]=ifac[0]=ifac[1]=1;
  for(ri i=2;i<=n;++i) {
    fac[i]=mul(fac[i-1],i);
    ifac[i]=mul(ifac[mod-mod/i*i],mod-mod/i);
  }
  for(ri i=2;i<=n;++i) Mul(ifac[i],ifac[i-1]);
}
int main() {
  #ifdef ldxcaicai
  freopen("lx.in","r",stdin);
  #endif
  n=read();
  init_fac();
  int res=0,m=n/2;
  for(ri nf,ng,i=0,f=1,g=0;i<=n;++i) {
    if(i>=m) Add(res,mul(C(n,i),f));
    ng=add(f,g),nf=dec(ng+1,C(i+1,m+1));
    f=nf,g=ng;
  }
  cout<<res;
  return 0;
}

Measured memory_bytes: 78336
#include <stdio.h>
int main(void){
  int len=0;
  int lenmax=0;
  char s[11],c;
  char *str;
  scanf("%s",s);
  str=s;
  while(c=*str++){
    if(c=='A'||c=='T'||c=='C'||c=='G')len++;
    else{
      len=0;
    }
    if(lenmax < len)lenmax = len;
  }
  printf("%d",lenmax);
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
using namespace std;

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

long long x, y;
long long ans = 0;

int main() {
  cin >> x >> y;

  while (x <= y) {
    ++ans;
    x *= 2;
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define REEP(i, N) for(ll i = N - 1; i >= 0; --i)
#define FOR(i,m,n) for(ll i = m; i < n; ++i)
#define RFOR(i,m,n) for(ll i = n - 1; i >= m; --i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define PB push_back
#define KIRIAGE(a, b) a += (b - a % b) % b
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;}
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

class unionfind
{
private:
	ll _size;				// 森の要素数
	vector<ll> _parent;		// 自分の親
	vector<ll> _rank;		// 自分以下の深さ
public:
	unionfind(ll size = 0) {
		_size = size;
		_parent.resize(_size);
		_rank.resize(_size);
		for(ll i = 0; i < _size; ++i) {
			_parent[i] = i;
			_rank[i] = 1;
		}
	}
	virtual ~unionfind() {

	}
private:
	ll find(ll pos) {		// 引数の親を返す
		if(_parent[pos] == pos) {
			return pos;
		} else {
			return _parent[pos] = find(_parent[pos]); // 辺を縮約
		}
	}
public:
	void unite(ll a, ll b) {	// a を含む木と b を含む木を併合
		a = find(a);
		b = find(b);
		if(a == b) return;
		if(_rank[a] < _rank[b]) {
			_parent[a] = b;
		} else {
			_parent[b] = a;
		} if(_rank[a] == _rank[b]) ++_rank[a];
	}
	bool same(ll a, ll b) {		// a と b が同じ木に属するか
		return find(a) == find(b);
	}
	ll count() {
		ll res = 0;
		for(ll i = 0; i < _size; ++i) {
			if(_parent[i] == i) ++res;
		}
		return res;
	}
};

int main(void) {
	int W, a, b;
	cin>>W>>a>>b;
	if(a <= b + W && b <= a + W) cout<<0<<endl;
	else if(b + W < a) cout<<a - (b + W)<<endl;
	else if(b > a + W) cout<<b - (a + W)<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    long long n, a, b, i;

    long long x[100000];

    long long k = 0;

         
   
    scanf("%lld %lld %lld", &n, &a, &b );

    for( i = 1 ; i <= n ; i = i + 1 ){

         scanf("%lld", &x[i] );

         }


    for( i = 1 ; i < n ; i = i + 1 ){

         if( ( x[i + 1] - x[i] ) * a < b ) k += ( x[i + 1] - x[i] ) * a;

         else k += b;

         }

    
    printf("%lld", k );

    return 0;

    }

Measured memory_bytes: 896
import numpy as np

N = int(input())
S = np.array(list(input()))


def match_length(s1, s2, m):
    x = np.zeros(len(s1) + 2, dtype=bool)
    x[1:-1] = (s1 == s2)

    l = max(np.diff(np.nonzero(x == 0)[0]) - 1)
    return min(m, l)


ans = 0
for i in range(1, N - 1):
    ans = max(ans, match_length(S[i:], S[:-i], i))
print(ans)


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

using namespace std;

int main(){

  	int input;
  	vector<int>number;
  	while(cin >> input){
    	number.push_back(input);
    }
  	
  	bool answer = false;

  	for(int i = 0; i<2; i++){
    	if(number.at(i) < number.at(i+1)){
        	answer = true;
        }
      	else{
        	answer = false;
          	break;
        }
     }
  	
  
  	if(answer){
    	cout << "Yes" << endl;
    }
    else{
    	cout << "No" << endl;
    }
  
  	return 0;
}


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<bool> v(n,true);
  int h[n];
  rep(i,n) cin >> h[i];
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    if(h[a] >= h[b]) v[b] = false;
    if(h[b] >= h[a]) v[a] = false;
  }
  int ans =0 ;
  rep(i,n) {
    if(v[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3960
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a==1 &&b==1){
      System.out.println("Draw");
    }else if(a==1){
      System.out.println("Alice");
    }else if(b==1){
      System.out.println("Bob");
    }else if(a>b){
      System.out.println("Alice");
    }else if(a<b){
      System.out.println("Bob");
    }else{
      System.out.println("Draw");
    }
  }
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 3e3 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long R, C, K, a[N][N], dp[N][N][5];

long long fun(int r, int c, int cnt) {
    if (r > R || c > C) {
        return -INF;
    }
    if (r == R && c == C) {
        return cnt < 3 ? a[r][c] : 0;
    }
    long long &tmp = dp[r][c][cnt];
    if (tmp != -1) {
        return tmp;
    }
    tmp = 0;
    tmp = max(tmp, fun(r + 1, c, 0));
    tmp = max(tmp, fun(r, c + 1, cnt));
    if (cnt < 3) {
        tmp = max(tmp, a[r][c] + fun(r + 1, c, 0));
        tmp = max(tmp, a[r][c] + fun(r, c + 1, cnt + (a[r][c] > 0)));
    }
    return tmp;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> R >> C >> K;
    for (int i = 0; i < K; i++) {
        int x, y, v;
        cin >> x >> y >> v;
        a[x][y] = v;
    }
    memset(dp, -1, sizeof dp);
    cout << fun(1, 1, 0) << '\n';
    return 0;
}


Measured memory_bytes: 428600
import java.util.*;
import java.io.*;
class Main{
    public static void main(String[] args)throws IOException{
        Scanner sc=new Scanner(System.in);
        int num=sc.nextInt();
        int[] ary=new int[num];
        for(int i=0;i<num;i++)ary[i]=sc.nextInt();
        int maxnum=ary[0];
        int gt=maxnum/2;
        for(int i=1;i<num;i++){
            if(maxnum<=ary[i]){
                gt+=maxnum/2;
                maxnum=ary[i];
                gt+=maxnum/2;
            }else{
                gt+=ary[i];
            }
        }
        System.out.println(gt+"\n");
    }
}

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

int dp[101][10001]={0};

int main(){
	int n , w;
	cin >> n >> w;
	vector< pair<int,int> > v(n+1);
	for(int i=1;i<=n;++i){
		cin >> v[i].second >> v[i].first;  //v.first:????????????v.second:??????
	}
	sort(v.begin(), v.end());

	for(int i=1;i<n+1;++i){
		for(int j=0;j<=w;++j){
				if ((j-v[i].first)>=0){
							dp[i][j]=max(dp[i-1][j-v[i].first]+v[i].second , dp[i-1][j]);
						} else {
							dp[i][j]=dp[i-1][j];
						}
					}	
		}
	
	cout << dp[n][w] << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

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

    string s;
    cin >> s;
    if ((s[0] == s[1] && s[0] == s[2]) || (s[1] == s[2] && s[1] == s[3]))
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  bool s=false, e=false, n=false, w=false;
  for(int i=0;i<S.size();++i) {
    if(S[i]=='S') s = true;
    if(S[i]=='E') e = true;
    if(S[i]=='N') n = true;
    if(S[i]=='W') w = true;
  }
  if((s^n) || (e^w)) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}



Measured memory_bytes: 3628
def bfs(n)
  si, sj = $pos[n - 1]
  gi, gj = $pos[n]

  secs = {"#{si},#{sj}" => 0}
  q = [[si, sj]]

  mv = [[0, 1], [0, -1], [1, 0], [-1, 0]]
  while pos = q.shift
    ci, cj = pos
    return secs["#{ci},#{cj}"] if ci == gi && cj == gj

    mv.each do |mi, mj|
      ni = ci + mi
      next if ni < 0 || ni >= $h
      nj = cj + mj
      next if nj < 0 || nj >= $w

      next if secs["#{ni},#{nj}"] || $map[ni][nj] == 'X'

      secs["#{ni},#{nj}"] = secs["#{ci},#{cj}"] + 1
      q.push [ni, nj]
    end
  end
end

$h, $w, $n = gets.split(' ').map(&:to_i)

$map = []
$pos = {}
0.upto($h - 1) do |i|
  $map[i] = gets.chomp.split(//)
  0.upto($w - 1) do |j|
    case $map[i][j]
    when 'S'
      $pos[0] = [i, j]
    when 'X', '.'
    else
      $pos[$map[i][j].to_i] = [i, j]
    end
  end
end

ans = 0
1.upto($n) do |n|
  ans += bfs(n)
end
puts ans

Measured memory_bytes: 208056
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  string a,b;
  cin>>a>>b;
  if(a[0]=='H')
    cout<<b<<endl;
  else if(b[0]=='H')
    cout<<"D"<<endl;
  else
    cout<<"H"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>



using namespace std;

int n,q;
int v[(1<<18) + 1],w[(1<<18) + 1];
int dp[550][100001];
int inf = -1;
int vq,wq;

int dfs(int i, int weight){
    //cout << i << " " << weight << " " << dp[i][weight] << endl;
    int res=0;
    if(i < 550 && weight <= 100000){
        if(dp[i][weight] != inf) return dp[i][weight];
    }
    if(i == 0){
        res = 0;
    }
    else if(weight < w[i] ){
        res = dfs(i/2,weight);
    }
    else{
        res = max(dfs(i/2,weight),dfs(i/2,weight-w[i])+v[i]);
    }
    if (i < 550 && weight <= 100000) dp[i][weight] = res;
    return res;
}

int main(){
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> v[i] >> w[i] ;
    }
    for(int i=0;i<550;i++){
        for(int j=0;j<=100000;j++){
            dp[i][j] = inf;
        }
    }
    
    for(int j=0;j<512;j++){
        for(int k=0;k<=100000;k++){
            dfs(j,k);
        }
    }

    cin >> q;
    for(int j=0;j<q;j++){
        cin >> vq >> wq;
        cout << dfs(vq,wq) << endl;
    
    }
    return 0;
}

Measured memory_bytes: 220476