akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static void Main()
    {
        int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[][] As = Enumerable.Repeat(0, nm[0]).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
        int[][] Cs = Enumerable.Repeat(0, nm[1]).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();

        foreach (var a in As)
        {
            int min = int.MaxValue;
            int minInd = -1;
            for (int i = 0; i < Cs.Length; i++)
            {
                var c = Cs[i];
                var abs = Abs(c[0] - a[0]) + Abs(c[1] - a[1]);
                if (min > abs)
                {
                    min = abs;
                    minInd = i;
                }
            }
            Console.WriteLine(minInd + 1);
        }
    }
}


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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1000000007LL
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(i=a;i<=b;i++)

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

ll mypow(ll a, ll b) { if(b == 0) return 1; ll temp=mypow(a,b/2); temp=(temp*temp)%INF; if(b%2 == 1) temp=(a*temp)%INF; return temp; }
int mygcd(int a, int b) { if(b==0) return a; return mygcd(b,a%b); }
int cntBits(ll a) { int ret=0; while(a>0) { ret++; a/=2; } return ret; }

int ans[1010][1010];

int main()
{
	ios::sync_with_stdio(0);
	int tt=1,tcase; 
	//cin >> tt;
	rep(tcase,1,tt)
	{
		int h,w; cin >> h >> w;
		string s[h+2];
		for(int i=1;i<=h;i++) cin >> s[i];
		if(s[1][0]=='.') ans[1][1]=1;
		for(int i=1;i<=h;i++)
		{
			for(int j=1;j<=w;j++)
			{
				if(i==1 && j==1) continue;
				if(s[i][j-1]=='.')
				{
					ans[i][j]=(ans[i-1][j] + ans[i][j-1])%INF;
				}
			}
		}
		cout << ans[h][w] << "\n";
	}
	return 0;
}


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

int main()
{
	int a, b;
	char op;

	cin >> a >> op >> b;

	while (op != '?')
	{
		int c;

		if (op == '+')
			c = a + b;
		if (op == '-')
			c = a - b;
		if (op == '*')
			c = a * b;
		if (op == '/')
			c = a / b;

		cout << c << endl;
		cin >> a >> op >> b;
	}

	return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<algorithm>
using namespace std;
int a[5005];
int main(){
	int i,j,n,k,s,temp,ans,Min;
	cin>>n>>k;
	for(i=0;i<n;){
		cin>>temp;
		if(temp>=k) n--;
		else a[i++]=temp;
	}
	sort(a,a+n);
	Min=n;
	for(i=n-1;i>=0;i--){
		s=0;
		for(j=i;j>=0;j--)
			if(s+a[j]>=k)Min=min(Min,j);
			else s+=a[j];
	}
	cout<<Min;
	return 0;
}

Measured memory_bytes: 256
let () = Scanf.scanf "%d %d\n" (fun n m ->
  let as_ = Array.init n (fun i -> Scanf.scanf "%s\n" (fun a -> (i, a))) in
  let bs = Array.init m (fun i -> Scanf.scanf "%s\n" (fun b -> (i, b))) in
  let bs' = Array.to_list bs in
  Array.to_list as_
  |> List.exists (fun (i, a) ->
    Array.init n (fun j -> j)
    |> Array.to_list
    |> List.filter (fun j ->
        try String.sub a j m = snd (bs.(0)) with
        | _ -> false)
    |> List.exists (fun j ->
        List.for_all (fun (k, b) ->
          try String.sub (snd (as_.(i + k))) j m = b with
          | _ -> false) bs'))
  |> (function true -> print_endline "Yes" | false -> print_endline "No"))

Measured memory_bytes: 640
#099_D
from collections import Counter
n, c = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(c)]
C = [list(map(int, input().split())) for _ in range(n)]
C0, C1, C2 = [], [], []
for i in range(n):
    for j in range(n):
        if (i + j) % 3 == 0:
            C0.append(C[i][j]-1)
        elif (i + j) % 3 == 1:
            C1.append(C[i][j]-1)
        else:
            C2.append(C[i][j]-1)
C0 = Counter(C0)
C1 = Counter(C1)
C2 = Counter(C2)

ans = 10 ** 10
for i in range(c):
    for j in range(c):
        if i == j:
            continue
        for k in range(c):
            if i == k or j == k:
                continue
            tmp = 0
            for col, num in C0.items():
                tmp += D[col][i] * num
            for col, num in C1.items():
                tmp += D[col][j] * num
            for col, num in C2.items():
                tmp += D[col][k] * num
            
            ans = min(tmp, ans)
            
print(ans)

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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)2
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 9999999999999999
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 100005
#define mxnn 2000005
int arr[mxn],dp[mxn];
int32_t main(){
sp;
int n;
cin >>n;
int arr[n+1];
for(int i = 1;i<=n;i++) cin >>arr[i];
dp[2] = abs(arr[2]-arr[1]);
for(int i = 3;i<=n;i++) dp[i] = min(dp[i-2]+abs(arr[i]-arr[i-2]),dp[i-1]+abs(arr[i]-arr[i-1]));
cout<<dp[n];
return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int a, b;
char op;

int main(void){
    
    scanf("%d %c %d", &a, &op, &b);
    printf("%d\n", (op == '+') ? a + b : a - b);
    
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm;

void main() {
    int n,k;
    scan(n,k);

    auto w = new int[][][](2, k, k);
    auto b = new int[][][](2, k, k);

    foreach (i ; 0 .. n) {
        char ci;
        int xi, yi;
        scan(xi, yi, ci);

        auto e = ((xi / k % 2) + (yi / k % 2)) % 2;

        if (ci == 'W') {
            w[e][xi%k][yi%k]++;
        }
        else {
            b[e][xi%k][yi%k]++;
        }
    }

    foreach (e ; 0 .. 2) {
        foreach (i ; 0 .. k) {
            foreach (j ; 1 .. k) {
                w[e][i][j] += w[e][i][j-1];
                b[e][i][j] += b[e][i][j-1];
            }
        }

        foreach (j ; 0 .. k) {
            foreach (i ; 1 .. k) {
                w[e][i][j] += w[e][i-1][j];
                b[e][i][j] += b[e][i-1][j];
            }
        }
    }

    debug {
        writefln("%(%(%s %)\n%)", w[0]);
        writeln;
        writefln("%(%(%s %)\n%)", w[1]);
        writeln;
        writefln("%(%(%s %)\n%)", b[0]);
        writeln;
        writefln("%(%(%s %)\n%)", b[1]);
        writeln;
    }

    int ans;

    foreach (i ; 0 .. k) {
        foreach (j ; 0 .. k) {
            int t = w[0][k-1][k-1] - w[0][k-1][j] - w[0][i][k-1] + w[0][i][j]*2;
            int s = w[1][i][k-1] + w[1][k-1][j] - w[1][i][j]*2;
            int r = b[1][k-1][k-1] - b[1][k-1][j] - b[1][i][k-1] + b[1][i][j]*2;
            int u = b[0][i][k-1] + b[0][k-1][j] - b[0][i][j]*2;

            int d = t + s + r + u;
            ans = max(ans, d);
            ans = max(ans, n - d);
        }
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 19324
from heapq import heappop, heappush, heapify
from collections import defaultdict

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

d = defaultdict(list)
for _ in range(N):
    s, t, c = tuple(map(int, input().split()))
    d[c].append((s, t))
stc = list()
for c, lst in d.items():
    if len(lst) == 1:
        s, t = lst[0]
        stc.append((s, t, c))
        continue
    lst.sort()
    s0, t0 = lst[0]
    i = 1
    while i < len(lst):
        s1, t1 = lst[i]
        if t0 == s1:
            t0 = t1
            if i == len(lst) - 1:
                stc.append((s0, t0, c))
        else:
            stc.append((s0, t0, c))
            s0 = s1
            t0 = t1
        i += 1

heapify(stc)
end = []
ans = 0
while len(stc) > 0:
    s, t, c = heappop(stc)
    if len(end) > 0:
        endtime = heappop(end)
        if endtime >= s:
            heappush(end, endtime)
    heappush(end, t)
    ans = max(ans, len(end))
print(ans)

Measured memory_bytes: 25164
#include<bits/stdc++.h>
#define ll long long int
#define CON 100010
//#define MOD 1e9+7
const long long mod=1e9+7;
const int INF=1001001001;
const ll inf=1e9+7;
using namespace std;
int main() 
{
	int N;
	cin>>N;
	vector<ll> H(N+2,INF);
	for(int i=0;i<N;i++)
	{
		cin>>H[i];
	}
	int pre=-999;
	for(int i=0;i<N;i++)
	{
		if(pre<=H[i]-1)
		{
			pre=H[i]-1;
		}
		else if(pre<=H[i])
		{
			pre=H[i];
		}
		else
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=100+3;

int A[N][N];
int dp[N/2][N][N/2][N];
char s[N][N];
int x,y,n,m,ans,a,b;

int cal(int u,int d,int l,int r){
	if (u>d||l>r) return 0;
	return A[d][r]-A[d][l-1]-A[u-1][r]+A[u-1][l-1];
}
void upd(int &x,int y){
	if (y>x) x=y;
}

int main(){
	n=IN(),m=IN();
	For(i,1,n+1) scanf("%s",s[i]+1);
	For(i,1,n+1) For(j,1,m+1) if (s[i][j]=='E') x=i,y=j;
	if (x-1>n-x){
		For(i,1,n+1) For(j,1,m+1) if (i<n-i+1) swap(s[i][j],s[n-i+1][j]);
		x=n-x+1;
	}
	if (y-1>m-y){
		For(i,1,n+1) For(j,1,m+1) if (j<m-j+1) swap(s[i][j],s[i][m-j+1]);
		y=m-y+1;
	}
	For(i,1,n+1) For(j,1,m+1){
		A[i][j]=A[i-1][j]+A[i][j-1]-A[i-1][j-1]+(s[i][j]=='o');
		if (s[i][j]=='E') x=i,y=j;
	}
	memset(dp,200,sizeof(dp));
	dp[0][0][0][0]=0;
	for (int u=0;u<=x-1;u++)
		for (int d=0;d<=n-x;d++)
			for (int l=0;l<=y-1;l++)
				for (int r=0;r<=m-y;r++)
					if (dp[u][d][l][r]>=0){
						if (u+1<=x-1&&x-u-1>=d+1){
							upd(dp[u+1][d][l][r],dp[u][d][l][r]+cal(x-u-1,x-u-1,max(y-l,r+1),min(y+r,m-l)));
						}
						if (d+1<=n-x&&x+d+1<=n-u){
							upd(dp[u][d+1][l][r],dp[u][d][l][r]+cal(x+d+1,x+d+1,max(y-l,r+1),min(y+r,m-l)));
						}
						if (l+1<=y-1&&y-l-1>=r+1){
							upd(dp[u][d][l+1][r],dp[u][d][l][r]+cal(max(x-u,d+1),min(x+d,n-u),y-l-1,y-l-1));
						}
						if (r+1<=m-y&&y+r+1<=m-l){
							upd(dp[u][d][l][r+1],dp[u][d][l][r]+cal(max(x-u,d+1),min(x+d,n-u),y+r+1,y+r+1));
						}
						upd(ans,dp[u][d][l][r]);
					}
	printf("%d\n",ans);
}

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

int d[1000], c[1000];
int dp[1001][1001];
int main() {
	int n, m; scanf("%d%d", &n, &m);
	rep(i, n)scanf("%d", &d[i]);
	rep(i, m)scanf("%d", &c[i]);
	memset(dp, 0x3f, sizeof(dp));
	dp[0][0] = 0;
	for (int i = 1; i <= m; i++)for (int j = 0; j <= n; j++) {
		if (!j)dp[i][j] = dp[i - 1][j];
		else dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - 1] + c[i - 1] * d[j - 1]);
	}
	printf("%d\n", dp[m][n]);
}

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

using namespace std;

#define boost ios::sync_with_stdio(0);cin.tie(0);
#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)a.size()
#define lb lower_bound
#define ub upper_bound
#define vi vector<int >
#define pii pair<int, int>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SQ(a) (a)*(a)
#define ll long long
#define lli long long int
#define ull unsigned long long
#define endl '\n'
#define Pi(a) printf("%d\n",a);
#define debug2(a,b) printf("%d\t%d\n",a,b);
#define debug1(a) printf("%d\n",a);
#define Si(a) scanf("%d",&a);
#define mod 1000000007
#define w(n) while(n--)



int main()
{
	//freopen ("f.in","r",stdin);
 	//freopen ("f.out","w",stdout);
	boost
	//code
	int n,a,b;
	cin >> n >> a >> b;
	int dist = b-a;
	if(dist%2){
		cout << "Borys\n";
	}
	else{
		cout << "Alice\n";
	}
	return 0;
}	
/*
-> check for array out of bounds & array declaired before size input(runtime error)
-> check for int overflow, use ll
-> check for corner cases like 0
-> check for j++ in while loop for every case
-> use boost except for interactive problems
*/

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

flag = True

x = h[0] - 1

for i in range(1, n):
    if h[i] < x:
        flag = False
        break
    elif h[i] == x:
        pass
    else:
        x = h[i] - 1
    
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 85508
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e17;
const ll N = 2e6+100;
const ll bits = 35;
const ll mod = 1e9+7;
const ld pi = 3.14159265358979323846;

char arr[N];
 

int main(){
    FASTIO;
    PRECISION;

    string s;
    ll q;
    ll chance = 0;
    cin>>s>>q;
    ll fptr=2e5+100,eptr;
    for(ll i=0;i<s.size();i++){
        arr[i+fptr]=s[i];
        eptr = i+fptr;
    }
    fptr--;
    eptr++;
    ll t,f;
    char c;

    while(q--){
        cin>>t;

        if(t==1){
            chance^=1LL;
        }else{
            cin>>f>>c;

            if(chance){
                if(f==1){
                    arr[eptr]=c;
                    eptr++;
                }else{
                    arr[fptr]=c;
                    fptr--;
                }
            }else{
                if(f==2){
                    arr[eptr]=c;
                    eptr++;
                }else{
                    arr[fptr]=c;
                    fptr--;
                }
            }
        }
    }
    fptr++;
    eptr--;

    if(!chance){
        for(int i=fptr;i<=eptr;i++){
            cout<<arr[i];
        }
    }else{
        for(int i=eptr;i>=fptr;i--){
            cout<<arr[i];
        }
    }
    cout<<"\n";

}


Measured memory_bytes: 1104
#include <bits/stdc++.h>
#define rep0(i,b) for(int i=0 ; i< b ;i++)
#define rep1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007
# define M_PI     3.14159265358979323846

using namespace std;


int main()
{
  int k,a,b;
  cin >>k>>a>>b;


for(int i=a ; i<=b ; i++){
  if (i%k ==0){
    cout<<"OK";
    return 0;
  }
}

cout<<"NG";

  return 0 ;
}


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

int main() {
  int N;
  cin >> N;
  int a, b, c, d;
  a = N / 1000;
  b = (N - a * 1000) / 100;
  c = (N - a * 1000 - b * 100) / 10;
  d = N - a * 1000 - b * 100 - c * 10;
  int x, y;
  x = (a == b) && (b == c);
  y = (b == c) && (c == d);
  if (x || y) {
      cout << "Yes" << endl;
    }
  
  else {
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
  int N,i;
  long ans=0,in,high;
  scanf("%d\n",&N);
  scanf("%ld",&high);
  for(i=0;i<N-1;i++){
	scanf("%ld",&in);
	if(high>in){
		ans+=(high-in);
	}else{
		high=in;
	}
  }
  printf("%ld\n",ans);
  return 0;
}

Measured memory_bytes: 1720
#include <bits/stdc++.h>
using namespace std;
long long A[3];
int main()
{
	scanf("%lld %lld %lld", &A[0], &A[1], &A[2]);
	sort(A, A+3);
	if(A[0]%2==0 || A[1]%2==0 || A[2]%2==0)printf("0\n");
	else printf("%lld\n", A[0]*A[1]);
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	static int A,B,C;
	//static String ans;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		A=sc.nextInt();
		B=sc.nextInt();

		C=sc.nextInt();
		int a[]=new int[101];
		for(int i=1;i<=100;i++) {
			if(A%i==0&&B%i==0)a[i]=i;
		}
		Arrays.sort(a);
		System.out.println(a[101-C]);
	}
}


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

int zal[2000010], bfs[500010], mx=1e7;

int main() {
	string S, T;
	cin >> S >> T;
	string z=T+S;
	for(int i=0; i+1<T.size(); ++i){
		z += S[i%S.size()];
	}
	zal[0]=z.size();
	int i=1, j=0;
	while(i<T.size()+S.size()){
		while(i+j<z.size()){
			if(z[i+j]!=z[j]) break;
			++j;
		}
		zal[i]=j;
		if(j==0){
			++i;
			continue;
		}
		int k=1;
		while(k<j && i+k<T.size()+S.size()){
			if(k+zal[k]>=j) break;
			zal[i+k]=zal[k];
			++k;
		}
		i += k, j -= k;
	}
	deque<int> dq;
	for(int i=0; i<S.size(); ++i){
		if(zal[i+T.size()]<T.size()){
			bfs[i]=0;
			dq.emplace_back(i);
		}
		else{
			bfs[i]=mx;
		}
	}
	while(!dq.empty()){
		int nx=(dq.front()+S.size()-T.size()%S.size())%S.size();
		if(bfs[nx]>bfs[dq.front()]+1){
			dq.emplace_back(nx);
			bfs[nx]=bfs[dq.front()]+1;
		}
		dq.pop_front();
	}
	int ans=0;
	for(int i=0; i<S.size(); ++i) ans=max(ans, bfs[i]);
	if(ans==mx) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define f first
#define s second
 
ll dp[100100];
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.in", "r", stdin);
        //freopen("output.out", "w", stdout);
	int n, w;
	cin >> n >> w;	
	int a[n], b[n];
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = w - a[i]; j >= 0; j--){
			dp[j + a[i]] = max(dp[j] + b[i], dp[j + a[i]]);
		}
	}
	ll ans = 0;
  	for(int i = 1; i <= w; i++){
    	ans = max(ans, dp[i]);
    }
  	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int main() {
  int S;
  cin >> S;
  int L = S / 100, R = S % 100;
  if (1 <= L && L <= 12) {
    if (1 <= R && R <= 12) {
      cout << "AMBIGUOUS";
    } else {
      cout << "MMYY";
    }
  } else {
    if (1 <= R && R <= 12) {
      cout << "YYMM";
    } else {
      cout << "NA";
    }
  }
  return 0;
}

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

#define maxN 100005
#define mod 1000000007
vector<long long> v[maxN];
vector<vector<long long>> dp(maxN,vector<long long>(2,0));

inline long long add(long long x,long long y){ x+=y; if(x>=mod) x-=mod; return x; }
inline long long mul(long long x,long long y){ return (x%mod*y%mod)%mod; }

void dfs(long long x,long long p)
{
    long long fl=1;
    long long black=1,white=1;
    for(auto u:v[x])
    {
        if(u==p) continue;
        fl=0;
        dfs(u,x);
        black=mul(black,dp[u][1]);
        white=mul(white,dp[u][0]);
    }

    if(fl)
    {
        dp[x][0]=2;
        dp[x][1]=1;
    }
    else
    {
        dp[x][0]=add(black,white);
        dp[x][1]=white;
    }
}

int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    long long n=0;
    cin>>n;
    for(long long i=0;i<n-1;i++)
    {
        long long x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    dfs(1,0);

    cout<<dp[1][0];
    return 0;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, n) for (int i = (n)-1; i >= 0; i--)
#define pp(v) cout << #v << "=" << (v) << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)

int main() {
  // input
  int n,q; cin >> n >> q;
  string s; cin >> s;
  vector<int> l(n),r(n);
  rep(i,q) {
    cin >> l[i] >> r[i];
  }

  // 'AC'の個数の累積和(cumulative sum)を求める
  // cs[n]はn文字読んだ時に含まれる'AC'の数
  // cs[0] = cs[1] = 0
  vector<int> cs(n+1); // 0文字読んだ場合が含まれるので要素数はn+1
  rep(i,n+1) {
    if (i < 2) continue;
    if (s[i-2] == 'A' && s[i-1] == 'C') {
      cs[i] = cs[i-1] + 1;
    } else {
      cs[i] = cs[i-1];
    }
  }

  // 各質問
  rep(i,q) {
    // lからrまで走査
    int lp = l[i], rp = r[i];
    cout << cs[rp] - cs[lp] << endl;
  }
}


Measured memory_bytes: 2176
import numpy as np
A = np.array(sum((input().split() for _ in range(3)), []), dtype=np.int8)
N = int(input())
for _ in range(N):
    np.multiply(A, A != int(input()), out=A)
A.resize(3, 3)
print("YNeos"[np.trace(A) and np.trace(np.rot90(A)) and A.sum(axis=0).all() and A.sum(axis=1).all()::2])

Measured memory_bytes: 18488
n = int(input())
k = 1
kotae = []
kotae2 = []

if n != 0:
    while n != 0:
        if n % ((-2) ** k) == 0:
            kotae.append(0)
        else:
            kotae.append(1)
            n = n - ((-2) ** (k - 1))
        k = k + 1

    for i in kotae[::-1]:
        kotae2.append(str(i))

    print("".join(kotae2))
else:
    print(0)

Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;

void solve()
{
	int N;
	cin >> N;
	vector<pair<int, int>> ps(N);
	vector<int> ds(N);
	for (int i = 0; i < N; i++)
		cin >> ps[i].second;
	for (int i = 0; i < N; i++)
		cin >> ps[i].first;
	for (int i = 0; i < N; i++)
	{
		ds[i] = (ps[i].second - ps[i].first);
	}
	sort(ds.begin(), ds.end());

	int l = 0, r = N - 1;
	bitset<100010> used;
	while (l < r)
	{
		if (ds[l] >= 0)
			break;
		if (ds[r] < 0)
		{
			cout << -1 << endl;
			return;
		}
		int x = min(ds[r], -ds[l]);
		ds[r] -= x;
		ds[l] += x;
		used[l] = used[r] = 1;
		if (ds[l] < 0)
		{
			r--;
		}
		else
		{
			l++;
		}
		//cout << l << ' ' << r << endl;
	}

	if (ds[r] < 0)
	{
		cout << -1 << endl;
		return;
	}

	cout << used.count() << endl;
}

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


Measured memory_bytes: 1408
w = list(input())
w.sort()
array = []
allset = list(set(w))
allset.sort()
index = 0
lettercount = 0
bad_letter = 0
indexs = []

for i in range(len(w) - 1):
    if w[i] != w[i+1]:
        indexs.append(i+1)
indexs.append(len(w))

for i in indexs:
    if i % 2 != 0:
        bad_letter += 1

print("No") if bad_letter > 0 else print("Yes")




Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
 
 
ll dp[100001];
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    ll n, k, tmph;
    vector<ll> h;
    cin >> n >> k;
    rep(i, n){
        cin >> tmph;
        h.push_back(tmph);
    }
 
    dp[0] = 0;
 
    rep(i, n-1){
        if(i==0) dp[i+1] = dp[i] + abs(h[i+1]-h[i]);
        else {
            ll resmin = inf;
            ll end = k;
            if(i-k < 0) end = i+1;
            rep(j, end){
                resmin = min(dp[i-j] + abs(h[i+1] - h[i-j]), resmin);
            }
            dp[i+1] = resmin;
        }
    }
 
    cout << dp[n-1] << endl;
 
    return 0;
}

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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define RFOR(i, k, j) for (int i = k - 1; i >= j; i--)
#define RREP(i, j) RFOR(i, j, 0)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) { a = b; return 1; }
    return 0;
}

template <class T> bool chmin(T &a, const T &b) {
    if (b < a) { a = b; return 1;}
    return 0;
}

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x; 
    return is;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    vi a(n), b(n), c(n - 1);
    cin >> a;
    cin >> b;
    cin >> c;

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

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import Counter


def solve(V):
    n = len(V)
    ac = Counter(V[::2]).most_common(2)
    bc = Counter(V[1::2]).most_common(2)
   
    if ac[0][0] != bc[0][0]:
        return n - ac[0][1] - bc[0][1]
    else:
        if len(bc) == 1 or len(ac) == 1:
            return n // 2
        else:
            return n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])


if __name__ == "__main__":
    n = int(input())
    l = input()

    print(solve(l.split(" ")))

Measured memory_bytes: 16808
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//const ll INF = 1e18;
//const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
using P = pair<ll, ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((ll)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((ll)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

ll N;
ll Main() {
    cin >> N;
    ll m = N%1000;
    ll ans = 1000-m;
    if (ans==1000) {
        cout << "0" << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}
 
int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3644
N, K= map(int, input().split())
answer = 0
n_list = [0]*(N+1)
n_list[0] = 0
for i in range(1,N+1):
    n_list[i] = n_list[i-1]+i

for k in range(K,N+1):
    large = n_list[N]-n_list[N-k]
    small = n_list[k-1]

    answer += large-small+1
answer += 1
print(answer % 1000000007) 


Measured memory_bytes: 19244
#include<bits/stdc++.h>
using namespace std;
int main(){
  int c[3][3];
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      cin >> c[i][j];
  int a[3]={}, b[3]={};
  bool f = true;
  for(int i=0;i<3;i++)
    b[i] = c[0][i];
  for(int i=1;i<3;i++)
  	a[i] = c[i][0] - b[0];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      if(c[i][j] != a[i]+b[j]) f = false;
    }
  }  
  cout << (f ? "Yes" : "No") <<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n, a = 0, b = 0, o = 0, ab = 0;
	char delim;
	string type;
	while( cin >> n >> delim >> type ){
		if ( type == "A" ) a++;
		else if ( type == "B" ) b++;
		else if ( type == "AB" ) ab++;
		else if ( type == "O" ) o++;
	}
	cout << a << endl << b << endl << ab << endl << o << endl;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s; cin >> s;

  rep(i, 2) {
    if (s[i] != s[i+1]) {
      cout << "Yes\n";
      return (0);
    }
  }

  cout << "No\n";

  return (0);
}


Measured memory_bytes: 3652
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String L = sc.nextLine();
        
        switch(L){
            case "SSS":
                System.out.println("0");
                break;
            case "SSR":
                System.out.println("1");
                break;
            case "SRS":
                System.out.println("1");
                break;
            case "RSS":
                System.out.println("1");
                break;
            case "RRS":
                System.out.println("2");
                break;
            case "RSR":
                System.out.println("1");
                break;
            case "SRR":
                System.out.println("2");
                break;
            case "RRR":
                System.out.println("3");
                break;
        }
    }
}









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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  string Ans = "Yes";
  
  if (N % 2 == 1) {
    Ans = "No";
  } else {
    for (int i = 0; i < N/2; i++) {
      if (S.at(i) != S.at(i + N/2)) {
        Ans = "No";
      }
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;
int main() {
 string s;
    cin >> s;
    int z =0, o=0, c = 0;

    int n = s.size();
    for (size_t i = 0; i < n-1; i++)
    {
        if(s[i] == s[i+1]) {
            c++;
            if(s[i+1] == '0') {
                s[i+1] = '1';
            } else {
                s[i+1] = '0';
            }
            // cout << i;
        }
        // cout << endl;
    }
    cout << c << endl;
}


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if (s < t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
  int N, K; cin >> N >> K;
  vector<int> cnt(N+1, 0);
  for (int i = 0; i < K; i++) {
    int d; cin >> d;
    for (int j = 0; j < d; j++) {
      int a; cin >> a;
      cnt.at(a)++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (cnt.at(i) == 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://abc070.contest.atcoder.jp/tasks/abc070_d>
問題文============================================================
 N 頂点の木が与えられます。
 木とはグラフの一種であり、頂点の数を N とすると、辺の数が N−1 本である閉路のない連結グラフです。
 i(1≦i≦N−1) 番目の辺は 頂点 ai と 頂点 bi を距離 ci で結びます。
 
 また、Q 個の質問クエリと整数 K が与えられます。
 
 j(1≦j≦Q) 番目の質問クエリでは、頂点 xj から 頂点 K を経由しつつ、
 頂点 yj まで移動する場合の最短経路の距離を求めてください。

=================================================================

解説=============================================================

 頂点Kを始点としたdijkstra
 ans := dist[x] + dist[y]
================================================================
*/
struct edge{
    int u,v,cost;
    edge(){}
    edge(int u,int v,int cost):u(u),v(v),cost(cost){}
};
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<vector<edge>> G(N);
    for(int i = 0; i < N-1;i++){
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        G[a].push_back(edge(a,b,c));
        G[b].push_back(edge(b,a,c));
    }
    int Q,K; cin >> Q >> K;
    K--;
    vector<ll> dist(N,LINF);
    queue<int> q;
    dist[K] = 0; q.push(K);
    while(!q.empty()){
        int n = q.front(); q.pop();
        for(auto e:G[n]){
            if(dist[e.v] > dist[e.u] + e.cost){
                dist[e.v] = dist[e.u] + e.cost;
                q.push(e.v);
            }
        }
    }
    
    while(Q--){
        int x,y; cin >> x >> y;
        x--; y--;
        cout << dist[x] + dist[y] << endl;
    }
    return 0;
}


Measured memory_bytes: 9140
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

A, B, C, K = map(int, input().split())

ans = 0
if K <= A:
    print(K)
    quit()
K -= A
ans = A
if K <= B:
    print(ans)
    quit()
K -= B

ans -= (1 * K)
print(ans)

Measured memory_bytes: 9228
n = int(input())
a = [[0 for j in range(9)] for i in range(9)]
for i in range(1,n+1):
	if str(i)[-1] == "0":
		continue
	a[int(str(i)[0])-1][int(str(i)[-1])-1] += 1

s = 0

for i in range(9):
	for j in range(9):
		if i == j:
			s += a[i][j]**2
		else:
			s += a[i][j] * a[j][i]
print (s)

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

bool match(char x, char y) {
	return (x == '?' || y == '?' || x == y);
}

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

void Main() {
	string A, B, C; cin >> A >> B >> C;
	int a = A.size(), b = B.size(), c = C.size();
	int off = 50000;
	string ab(100000, 1);
	string ac(100000, 1);
	string bc(100000, 1);

	rep(i, a) rep(j, b) ab[i-j+off] &= match(A[i], B[j]);
	rep(i, a) rep(j, c) ac[i-j+off] &= match(A[i], C[j]);
	rep(i, b) rep(j, c) bc[i-j+off] &= match(B[i], C[j]);
	
	int ans = 6000;
	for (int i = -4000; i <= 4000; i++) {
		for (int j = -4000; j <= 4000; j++) {
			if (ab[i+off] && ac[j+off] && bc[j-i+off]) {
				int L = min({0, i, j});
				int R = max({a, i + b, j + c});
				chmin(ans, R - L);
			}
		}
	}
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


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

using namespace std;

void solve()
{
    int n, w;
    cin >> n >> w;

    int maxSize = n * 1e3;
    vector<long long> dp(maxSize + 1, 1e9 + 7);
    int a, b;

    dp[0] = 0;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a >> b;
        for(int j = maxSize; j >= b; --j)
            dp[j] = min(dp[j], dp[j - b] + a);
    }

    for(int i = maxSize; i >= 0; --i)
        if(dp[i] <= w)
        {
            cout << i << '\n';
            return;
        }
}

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //srand (time(0));

    solve();
}






Measured memory_bytes: 1024
#include "bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const int INF = 1 << 30;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	int N, M; cin >> N >> M;
	vector<vector<int>> A(M);
    rep(i, N) {
        int a, b; cin >> a >> b;
        if (a <= M)A[a - 1].push_back(b);
    }

    priority_queue<int> pq;
    int ans = 0;
    rep(i, M) {
        rep(j, A[i].size()) {
            pq.push(A[i][j]);
        }
        if (!pq.empty()) {
            ans += pq.top();
            //cout << ans << endl;
            pq.pop();
        }
    }
    cout << ans;



}

Measured memory_bytes: 5504
x,k,d=(int(x) for x in input().split())
x=abs(x)
if x>k*d:
    print(x-k*d)
else:
    ki=x//d
    kj=x-d*ki
    if (k-ki)%2==0:
        print(kj)
    else:
        print(d-kj)

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

int main(void) {
  int N, M;
  cin >> N >> M;
  int ans = 0;
  long long sum = 0;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }
  for (int i = 0; i < N; i++) {
    if (A[i] * 4 * M >= sum) {
      ans++;
    }
  }
  cout << (ans >= M ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int r = int.Parse(input[0]);
        int d = int.Parse(input[1]);
        int x = int.Parse(input[2]);
        for (int i = 0; i < 10; i++)
        {
            x = r * x - d;
            Console.WriteLine(x);
        }
    }
}


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

int main(){
	int a,b,k;
	cin >> a >> b >> k;
	
	int count = 0;
	vector<int> cd;
	REP(i,100){
		if(a % i == 0 && b % i == 0){
			cd.push_back(i);
		}
	}
	
	reverse(cd.begin(),cd.end());
	
	cout << cd[k-1] << endl;
    return 0;
}



Measured memory_bytes: 256
import Control.Monad
main = do
    (n:t:_)<-map read.words<$>getLine::IO [Int]
    ans<-map head.filter (\(_:u:_)->u<=t) <$> replicateM n (map read.words<$>getLine)::IO[Int]
    case ans of
        [] -> putStrLn "TLE"
        _ -> print $ minimum ans


Measured memory_bytes: 1020
import java.util.*;

public class Main {
	public static int[] pre, in, post;
	public static int position, count;

	public static void reconstruct(int left, int right) {
		if (left >= right) return;
		int root = pre[position++];
		int middle = 0;
		while (in[middle] != root) middle++;
		reconstruct(left, middle);
		reconstruct(middle + 1, right);
		post[count++] = root;
	}
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		pre = new int[n];
		in = new int[n];
		post = new int[n];
		for (int i = 0; i < n; i++) pre[i] = scanner.nextInt();
		for (int i = 0; i < n; i++) in[i] = scanner.nextInt();
		position = 0;
		count = 0;
		reconstruct(0, n);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append(post[i]);
			sb.append(i != n - 1 ? " " : "\n");
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 26268
def main():
    N,K=map(int,input().split())
    h=[0 for i in range(0,N)]
    for i in range(0,N):
        h[i]=int(input())
    h.sort()
    ans=10**9
    for i in range(0,N-K+1):
        test=h[i+K-1]-h[i]
        if test<ans:
            ans=test
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 7496
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int[] p;
	static int[] q;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		boolean[] s = new boolean[n];
		int count1 = 0;
		int count2 = 0;
		int[] array = new int[n];
		for (int i = 0; i < m; i++) {
			int tmp = sc.nextInt() - 1;
			if (sc.next().charAt(0) == 'A') {
				if (!s[tmp]) {
					++count1;
					s[tmp] = true;
				}
			} else {
				if (!s[tmp]) {
					++array[tmp];
				}
			}
		}
		for (int i = 0; i < n; i++) {
			if (s[i]) {
				count2 += array[i];
			}
		}
		System.out.println(count1 + " " + count2);
	}
}


Measured memory_bytes: 65540
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;

static const int MOD = 1000000007;
 
int main() {
 
  int n;
  cin >> n;
 
  vi a(n / 2 + 1); 
  vi b(n); 
 
 
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  
 
  int k;
 
  if (n % 2 == 0) {
    for (int i = 0; i < n; ++i) {
      if (b[i] % 2 == 0) {
        cout << 0;
        return 0;
      }
      a[b[i] / 2]++;
      if (a[b[i] / 2] > 2) {
        cout << 0;
        return 0;
      }
    }
    for (int i = 0; i < n / 2; ++i) {
      if (a[i] != 2) {
        cout << 0;
        return 0;
      }
    }
  } else {
    for (int i = 0; i < n; ++i) {
      if (b[i] % 2 == 1) {
        cout << 0;
        return 0;
      }
      if (++a[b[i] / 2] > 2) {
        cout << 0;
        return 0;
      }
    }
  }
 
  if (n % 2 == 1) {
    if (a[0] == 2) {
      cout << 0;
      return 0;
    }
  }
 
 
  long long ans = 1;
  for (int i = 0; i < n / 2; i ++) {
    ans *= 2;
    ans %= MOD;
  }
 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 896
package main 

import (
        "fmt"
)

func main (){
        var a int
        fmt.Scan(&a)
        if a <= 111{
                fmt.Println(111)
        } else if a <= 222 {
                fmt.Println(222)
        } else if a <= 333 {
                fmt.Println(333)
        } else if a <= 444 {
                fmt.Println(444)
        } else if a <= 555 {
                fmt.Println(555)
        } else if a <= 666 {
                fmt.Println(666)
        } else if a <= 777 {
                fmt.Println(777)
        } else if a <= 888  {
                fmt.Println(888)
        } else if a <= 999  {
                fmt.Println(999)
        }
}


Measured memory_bytes: 512
#include<cstdio>
#include<functional>
#include<algorithm>
#define M 2000000000
using namespace std;
int main(void)
{
	int nn[50001],syu[20];
	int i,j,n,m;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++) scanf("%d",&syu[i]);
	for(i=0;i<=n;i++) nn[i]=M;
	nn[0]=0;
	for(i=0;i<m;i++){
		for(j=0;j<=n;j++){
			if(j+syu[i]>n) break;
			if(nn[j]!=M){
				nn[syu[i]+j]=min(nn[syu[i]+j],nn[j]+1);
			}
		}
	}
	printf("%d\n",nn[n]);
	return 0;
}

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

using namespace std;

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

#define int long long
#define tie() ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f(i,from,to) for(int i = from ; i <to ; i++)
#define mem(a , v) memset(a , v , sizeof a)
#define all(v) v.begin() , v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define what_is(x) cerr << #x << " is : " << x <<endl

const int INF = 1e9 + 7;
const int sz = 1e5 + 20;
const int N =1e5 + 20;
/***************************************************************/

int r , s , p;


int value(char c)
{
    if(c == 'r')
        return r;
    if(c == 'p')
        return p;
    return s;
}


char cut(char c)
{
    if(c == 's')
        return 'r';
    if(c == 'p')
        return 's';
    return 'p';
}



void solve()
{
    int n,k;
    cin >> n >> k >> r >> s >> p;

    string play;
    cin >> play;

    char ans[n] ;
    int sum = 0;
    mem(ans , '-');

    f(i , 0 , n)
    {
        if(i < k)
            ans[i] = cut(play[i]) , sum += value(ans[i]);
        else
        {
            if(ans[i - k] != cut(play[i]))
                ans[i] = cut(play[i]) , sum += value(ans[i]);
        }
    }

    cout << sum << endl;
    return;
}


int32_t main()
{
    int t = 1;
    //cin>>t;
    while(t--)
        solve();
}


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

int main() {
    // input
    int N;
    cin >> N;
    vector<int> a(N + 1);
    a[0] = 0;
    for (int i = 1; i <= N; ++i) {
        cin >> a[i];
    }

    // solve
    int tmp = 1, ans = 0;
    for (int i = 1; i <= N; ++i) {
        if (tmp == 2) break;
        ans++;
        tmp = a[tmp];
    }

    // output
    cout << (ans == N ? -1 : ans) << endl;

    return 0;
}


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

int main(){
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(x+r<=W&&x-r>=0&&y+r<=H&&y-r>=0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1156