akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

struct ModInt {
  using M = ModInt;
  long long v;
  ModInt(long long _v = 0) : v(_v % MOD + MOD) { norm(); }
  M& norm() {
    v = (v < MOD) ? v : v - MOD;
    return *this;
  }
  M operator+(const M& x) const { return M(v + x.v); }
  M operator-(const M& x) const { return M(v + MOD - x.v); }
  M operator*(const M& x) const { return M(v * x.v % MOD); }
  M operator/(const M& x) const { return M(v * x.inv().v); }
  M& operator+=(const M& x) { return *this = *this + x; }
  M& operator-=(const M& x) { return *this = *this - x; }
  M& operator*=(const M& x) { return *this = *this * x; }
  M& operator/=(const M& x) { return *this = *this / x; }
  friend istream& operator>>(istream& input, M& x) {
    return input >> x.v, x.norm(), input;
  }
  friend ostream& operator<<(ostream& output, const M& x) {
    return output << x.v;
  }
  M pow(long long n) const {
    M x(v), res(1);
    while (n) {
      if (n & 1) res *= x;
      x *= x;
      n >>= 1;
    }
    return res;
  }
  M inv() const { return this->pow(MOD - 2); }
  // M inv() const {
  //   int x, y;
  //   extgcd(this->v, MOD, x, y);
  //   return *this + M(x);
  // }

  static long long MOD;
  static vector<M> fact, finv;
  static void build(int n) {
    fact.assign(n + 1, 1);
    for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i);
    finv.assign(n + 1, fact[n].inv());
    for (int i = n; i > 0; i--) finv[i - 1] = finv[i] * M(i);
  }
  static M comb(int n, int k) {
    if (n < k || k < 0) return M(0);
    return fact[n] * finv[n - k] * finv[k];
  }
  static M extgcd(int a, int b, int* x, int* y) {
    M d(a);
    if (b) {
      d = extgcd(b, a % b, y, x);
      *y -= (a / b) * *x;
    } else {
      *x = 1, *y = 0;
    }
    return d;
  }
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
long long ModInt::MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<vector<int>> o(120, vector<int>(n + 1, 0));
  vector<vector<int>> x(120, vector<int>(n + 1, 0));
  for (int b = 0; b < 120; b++) {
    for (int i = 0; i < n; i++) {
      o[b][i + 1] += o[b][i];
      x[b][i + 1] += x[b][i];
      if (a[i] >> min(60, b) & 1) {
        o[b][i + 1]++;
      } else {
        x[b][i + 1]++;
      }
    }
  }
  vector<ll> v(120);
  ll nxt = 0;
  for (int b = 0; b < 120; b++) {
    ll c = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] >> min(60, b) & 1) {
        c += x[b][i];
      } else {
        c += o[b][i];
      }
    }
    v[b] = (nxt + c) % 2;
    nxt = (nxt + c) / 2;
  }
  ModInt ans = 0;
  for (int b = 119; b >= 0; b--) {
    ans *= 2;
    ans += v[b];
  }
  cout << ans << endl;
}


Measured memory_bytes: 285036
n,m=map(int,input().split())
x=[0]*n
s=0
for i in range(m):
    a,b=map(int,input().split())
    if a==1:
        if x[b-1]==0:
            x[b-1]=1
        elif x[b-1]==-1:
            s+=1
    elif b==n:
        if x[a-1]==0:
            x[a-1]=-1
        elif x[a-1]==1:
            s+=1
if s>0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 10348
#include<iostream>
#include<utility>
#include<queue>
#define INF 10000000000
using namespace std;

typedef pair<int, int>P;

char maze[20][20];
int H,W;
int sx,sy,gx,gy;
int d[20][20];

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

int bfs(){
  int rel=1;
  queue<P> que;

  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++) d[i][j]=0;

  que.push(P(sx,sy));
  d[sx][sy]=1;
 
  while(que.size()){
    P p=que.front();
    que.pop();

    for(int i=0;i<4;i++){
      int nx=p.first+dx[i],ny=p.second+dy[i];
      if(0<=nx&&nx<H&&0<=ny&&ny<W&&maze[nx][ny]!='#'&&d[nx][ny]==0){
	que.push(P(nx,ny));
	d[nx][ny]=1;
	rel++;
      }
    }
  }
  return rel;
}

void solve(){
  int res=bfs();
  cout<<res<<endl;
}

int main(){
  char s;

  while(1){
    cin>>W>>H;
    if(W+H==0)break;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin>>maze[i][j];
	if(maze[i][j]=='@'){
	  sx=i;
	  sy=j;
	}
      }
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define ll long long int
#define pb() push_back()
#define INF 1000000000
using namespace std;

const int mod = 1e9+7;
int main(){
	ll x;
	double y;
	cin>>x>>y;
	ll res = (x*(y*100))/100;
	cout<<  res;
		return 0;
}


Measured memory_bytes: 3684
#include <stdio.h>

#define MOD_BY 1000000007

int add(int a, int b) {
	return a + b - (a + b >= MOD_BY ? MOD_BY : 0);
}

int sub(int a, int b) {
	return b == 0 ? a : add(a, MOD_BY - b);
}

int mul(int a, int b) {
	int r = 0;
	while (b > 0) {
		if (b & 1) r = add(r, a);
		a = add(a, a);
		b >>= 1;
	}
	return r;
}

int N;
char S[114514];

int mizuhasu[26];

int main(void) {
	int i;
	int asumisu;
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%114513s", S) != 1) return 1;
	for (i = 0; i < N; i++) {
		int tomatu = S[i] - 'a';
		if (0 <= tomatu && tomatu < 26) mizuhasu[tomatu]++;
	}
	asumisu = 1;
	/* その文字をどこから取るか or 取らない */
	for (i = 0; i < 26; i++) asumisu = mul(asumisu, add(mizuhasu[i], 1));
	printf("%d\n", sub(asumisu, 1)); /* 「全部取らない」の分1を引く */
	return 0;
}


Measured memory_bytes: 1832
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>

using namespace std;

int H, W, N;

bool flg = true;

int cnum = 0;

void output(const vector<int> &vi, int j)
{
    if (j == W)
    {
        if (flg)
        {
            for (int k = 0; k < W; k++)
            {
                if (k == 0) printf("%d", vi[k]);
                else printf(" %d", vi[k]);
            }
            printf("\n");
        }
        else
        {
            for (int k = W - 1; 0 <= k; k--)
            {
                if (k == W - 1) printf("%d", vi[k]);
                else printf(" %d", vi[k]);
            }
            printf("\n");
        }
        flg = !flg;
        cnum = 0;
    }
    else
    {
        cnum = j;
    }
}


int main()
{
    if (scanf("%d%d%d", &H, &W, &N) < 3) return 0;

    int a;

    vector<int> vi(W);

    int bk = 0;

    int i = 0;

    while (i < N || bk > 0)
    {
        int j;

        if (bk > 0)
        {
            int tmp = bk;
            int bbk = bk;
            while (tmp > 0)
            {
                for (j = cnum; j <= cnum + bbk; j++)
                {
                    if (W <= j)
                    {
                        bk = bbk - j + cnum;
                        bbk = bk;
                        cnum = 0;
                        output(vi, j);
                        j = 0;
                        break;
                    }
                    else if (j == cnum + bbk)
                    {
                        cnum = j;
                        break;
                    }
                    else
                    {
                        bk = 0;
                    }

                    vi[j] = i;
                    tmp--;
                }
            }

            if (scanf("%d", &a) < 1) return 0;

            if (j == cnum + bk)
            {
                cnum = j;
                for (j = cnum; j <= cnum + a; j++)
                {
                    if (W <= j)
                    {
                        bk = a - j + cnum;
                        cnum = bk;
                        output(vi, j);
                        break;
                    }
                    else if (j == cnum + a)
                    {
                        cnum = j;
                        break;
                    }
                    else
                    {
                        bk = 0;
                    }

                    vi[j] = i + 1;
                }
            }
        }
        else
        {
            if (scanf("%d", &a) < 1) return 0;

            for (j = cnum; j <= cnum + a; j++)
            {
                if (W <= j)
                {
                    bk = a - j + cnum;
                    cnum = bk;
                    output(vi, j);
                    break;
                }
                else if (j == cnum + a)
                {
                    cnum = j;
                    break;
                }
                else
                {
                    bk = 0;
                }
                vi[j] = i + 1;
            }
        }

        i++;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int mod = 100000;
int dp[1 << 20][3], dp_prev[1 << 20][3];
int x[409], H, W; string S;
int power[20];
int main() {
	power[0] = 1; for (int i = 1; i < 20; i++)power[i] = power[i - 1] * 2;
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> S;
		for (int j = 0; j < W; j++) {
			if (S[j] == 'J')x[i * W + j] = 1;
			if (S[j] == 'O')x[i * W + j] = 2;
			if (S[j] == 'I')x[i * W + j] = 3;
			if (S[j] == '?')x[i * W + j] = 0;
		}
	}
	if (x[0] == 0 || x[0] == 1)dp_prev[0][1] += 1;
	if (x[0] == 0 || x[0] == 2)dp_prev[0][0] += 1;
	if (x[0] == 0 || x[0] == 3)dp_prev[0][0] += 1;
	for (int i = 1; i < H * W; i++) {
		int mass = i % W;
		for (int j = 0; j < power[W - 1]; j++) {
			int L = 0, R = 0;
			if ((j / power[mass]) % 2 == 1) {
				L = j - power[mass];
				R = L + power[mass - 1];
				if (x[i] == 0 || x[i] == 1) {
					if (mass != W - 1) { dp[L][1] += dp_prev[j][0] + dp_prev[j][1]; dp[L][1] %= mod; }
					if (mass == W - 1) { dp[L][0] += dp_prev[j][0] + dp_prev[j][1]; dp[L][0] %= mod; }
				}
				if (x[i] == 0 || x[i] == 2) {
					dp[L][0] += dp_prev[j][0]; dp[L][0] %= mod;
					dp[R][0] += dp_prev[j][1]; dp[R][0] %= mod;
				}
			}
			else {
				L = j;
				R = j + power[mass - 1];
				if (x[i] == 0 || x[i] == 1) {
					if (mass != W - 1) { dp[L][1] += dp_prev[j][0] + dp_prev[j][1]; dp[L][1] %= mod; }
					if (mass == W - 1) { dp[L][0] += dp_prev[j][0] + dp_prev[j][1]; dp[L][0] %= mod; }
				}
				if (x[i] == 0 || x[i] == 2) {
					dp[L][0] += dp_prev[j][0]; dp[L][0] %= mod;
					dp[R][0] += dp_prev[j][1]; dp[R][0] %= mod;
				}
				if (x[i] == 0 || x[i] == 3) { dp[L][0] += dp_prev[j][0] + dp_prev[j][1]; dp[L][0] %= mod; }
			}
		}
		for (int j = 0; j < power[W - 1]; j++) {
			dp_prev[j][0] = dp[j][0]; dp_prev[j][1] = dp[j][1];
			dp[j][0] = 0; dp[j][1] = 0;
		}
	}
	int C = 1; for (int i = 0; i < H*W; i++) if (x[i] == 0) C = C * 3 % mod;
	int sum = 0; for (int i = 0; i < power[W - 1]; i++) { sum += dp_prev[i][0] + dp_prev[i][1]; sum %= mod; }
	cout << (C + mod - sum) % mod << endl;
	return 0;
}

Measured memory_bytes: 19628
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    string S;
    cin >> S;
    if (S.substr(0, 4) == "YAKI"){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}




Measured memory_bytes: 256
class Dice:
    def __init__(self,dim=list(range(1,7))):
        self.dim = dim

    def roll(self,direction):
        if direction == "N":
            buff = self.dim[0]
            self.dim[0] = self.dim[1]
            self.dim[1] = self.dim[5]
            self.dim[5] = self.dim[4]
            self.dim[4] = buff

        if direction == "E":
            buff = self.dim[3]
            self.dim[3] = self.dim[5]
            self.dim[5] = self.dim[2]
            self.dim[2] = self.dim[0]
            self.dim[0] = buff

        if direction == "W":
            buff = self.dim[0]
            self.dim[0] = self.dim[2]
            self.dim[2] = self.dim[5]
            self.dim[5] = self.dim[3]
            self.dim[3] = buff

        if direction == "S":
            buff = self.dim[0]
            self.dim[0] = self.dim[4]
            self.dim[4] = self.dim[5]
            self.dim[5] = self.dim[1]
            self.dim[1] = buff

lst = list(map(int,input().split()))

D = Dice(lst)
q = int(input())
for i in range(q):
    top_front = [int(x) for x in input().split()]
    for op in 'EEENEEENEEESEEESEEENEEEN':
        if D.dim[0] == top_front[0] and D.dim[2] == top_front[1]:
            print(D.dim[4])
            break
        D.roll(op)


Measured memory_bytes: 5616
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

ll dp[100010][4] = {};

int main() {
	string s;
	cin >> s;
	int n = s.size();
	
	for (int i = n; i >= 0; i--) {
		for (int j = 3; j >= 0; j--) {
			if (i == n) {
				dp[i][j] = (j == 3 ? 1 : 0);
			}
			else {
				dp[i][j] = dp[i + 1][j] * (s[i] == '?' ? 3LL : 1LL);

				if (j < 3 && (s[i] == '?' || s[i] == "ABC"[j])) {
					dp[i][j] += dp[i + 1][j + 1];
				}

				dp[i][j] %= MOD;
			}
		}
	}

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


Measured memory_bytes: 3584
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = long.Parse(input.ReadLine());
        
        var al = new int[100];
        FillArray(al, 999);

        for(int i=0; i<n; i++) {
            var dic = new Dictionary<char, int>();
            foreach(var a in input.ReadLine()) {
                if(dic.ContainsKey(a)) dic[a]++;
                else dic[a] = 1;
            }

            for(char j='a'; j<='z'; j++) {
                if(dic.ContainsKey(j)) al[j-'a'] = Math.Min(al[j - 'a'], dic[j]);
                else al[j - 'a'] = 0;
            }
        }

        var sb = new StringBuilder();
        for (char j = 'a'; j <= 'z'; j++) {
            for(int i=0; i<al[j - 'a']; i++) {
                sb.Append(j);
            }
        }

        return sb;
    }

    static void SetArray<T>(T[] array, Func<T, int, T> f) {
        for (int i = 0; i < array.Length; i++)
            array[i] = f(array[i], i);
    }
    static void FillArray<T>(T[] array, T value) {
        for (int i = 0; i < array.Length; i++)
            array[i] = value;
    }
    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13152
A, B = map(int, input().split())
S = input().rstrip()
if len(S) == A + B + 1 and S[A] == '-':
    for s in (S[:A]+S[A+1:]):
        if s in list(map(str, range(0, 10))):
            continue
        else:
            print('No')
            exit(0)
    print('Yes')
    exit(0)
print('No')
exit(0)

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

void fnInput(vector<int>& rvnCard)
{
  int nCardSiz;
  cin >> nCardSiz;

  for (int i = 0; i < nCardSiz; i++)
    cin >> rvnCard[i];

  sort(begin(rvnCard), end(rvnCard), greater<int>() );
}

int fnGameExec(const vector<int>& cnrvnCard)
{
  int nAlcePnt = 0, nBobPnt = 0;

  for (int i = 0; i < cnrvnCard.size(); i++)
  {
    if (i % 2 == 0)
      nAlcePnt += cnrvnCard[i];
    else
      nBobPnt  += cnrvnCard[i];
  }

  int nDiffPnt = nAlcePnt - nBobPnt;
  return nDiffPnt;
}

int main()
{
  vector<int> vnCard(100);
  fnInput(vnCard);
  cout << fnGameExec(vnCard) << endl;

  return 0;
}


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

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int N=gi();
	    String A=gs();
	    String B=gs();
	    String C=gs();
	    int k=0;
	    for (int i=0; i<N;i++) {
	    	char a=A.charAt(i);
	    	char b=B.charAt(i);
	    	char c=C.charAt(i);
	    	if(a==b && b==c) {
	    		
	    	} else if(a==b || b==c || c==a) {
	    		k+=1;
	    	} else {
	    		k+=2;
	    	}
	    }
//	    if (N<100) {
//	 
//	    } else {
//
//	    }
	    System.out.println(k);
	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35632
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x, y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x, y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;

ll mode=pow(10,9)+7;
bool cmp(pair<ll,ll> x, pair<ll, ll> y){
    return x.S<y.S;
}
//ll n,k,m;


int main(){ 
    
  //  #ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
  //  #endif
    
    ios::sync_with_stdio(0);
    cin.tie(0);
	
	ll n;
	cin>>n;
	ll a[n];
	for (int i=0;i<n;i++) cin>>a[i];
	ll aa=0;
	for (int i=0;i<n;i++){
		if (a[i]==aa+1){
			aa++;
		}
	}
	if (aa!=0) cout<<n-aa<<endl;
	else cout<<"-1"<<endl;
	
	
    return 0;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())
x = list(map(int, input().split()))
pl, mi = 0, 0
recp, recm = [], []
for i in range(n):
    if x[i] >= 0:
        pl += 1
        recp.append(x[i])
    else:
        mi += 1
        recm.append(x[i])

num = float("inf")
recm = recm[:: -1]
for i in range(pl + 1):
    if i == 0:
        if k <= mi:
            num = min(num, abs(recm[k - 1]))
        else:
            continue
    else:
        if k - i == 0:
            num = min(num, recp[k - 1])
        elif 0 < k - i <= mi:
            num = min(num, recp[i - 1] + 2 * abs(recm[k - i - 1]))
            num = min(num, 2 * recp[i - 1] + abs(recm[k - i - 1]))

print(num)

Measured memory_bytes: 14480
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#N, L = map(int, input().split())
s = str(input())

ans = ""
for i in range(len(s)) :
  if s[i] == "0" or s[i] == "1" :
    ans += s[i]    
  else :
    if len(ans) != 0 :
      ans = ans[0:-1]

print (ans)


Measured memory_bytes: 38384
N = gets.chomp.to_i
mat = readlines.map{|n| n.chomp.split(" ").map(&:to_i)}
sorted = mat.sort{|a,b| a[1]<=>b[1]}
sum = 0
ans = "Yes"
sorted.each do |pair|
    sum += pair[0]
    if not sum <= pair[1]
        ans = "No"
        break
    end
end

puts ans

Measured memory_bytes: 33912
#include<bits/stdc++.h>
using namespace std;
long ans=0;
int main(){
  int n;cin>>n;
  int k;cin>>k;
  vector<long> a(n),plus(n+1,0),minus(n+1,0);
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]>0)ans+=a[i];
    plus[i+1]=plus[i];
    minus[i+1]=minus[i];
    if(a[i]>0)plus[i+1]+=a[i];
    else minus[i+1]+=a[i];
  }
  long p=1e15,m=-1e15;
  for(int i=0;i<n+1-k;i++){
    p=min(p,plus[i+k]-plus[i]);
    m=max(m,minus[i+k]-minus[i]);
  }
  ans-=min(abs(p),abs(m));
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int N,Ma,Mb,A[50],B[50],C[50],dp[401][401];
int main()

{
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	scanf("%d%d%d",&N,&Ma,&Mb);
	for(int i=0;i<N;i++)
		scanf("%d%d%d",&A[i],&B[i],&C[i]);
	
	for(int i=0;i<N;i++)
	{
		//dp[A[i]][B[i]]=dp[A[i]][B[i]]==-1?C[i]:min(dp[A[i]][B[i]],C[i]);
		for(int j=400;j-A[i]>=0;j--)
			for(int k=400;k-B[i]>=0;k--)
			{
				
				int pj=j-A[i],pk=k-B[i];
				if(dp[pj][pk]!=-1)
				{	int t=dp[j][k],s=dp[pj][pk]+C[i];
					dp[j][k]=t==-1?s:min(t,s);
				}
			}
	}
	int res=5000;
	for(int i=1;Ma*i<=400&&Mb*i<=400;i++)
	{
		for(int p=0;p<N;p++)
			if(dp[Ma*i][Mb*i]!=-1)
				res=min(res,dp[Ma*i][Mb*i]);
	}
	printf("%d\n",res==5000?-1:res);
	return 0;
}


Measured memory_bytes: 896
from collections import deque

priority = {"*":1,"/":1, "+":0, "-":0, "(":-1, ")":-1}

n = int(input())
for i in range(n):
    s = input()
    out = []
    ope = deque([])
    for j in range(len(s)):
        inp = s[j]
        if inp == "=":
            while len(ope):
                out.append(ope.pop())
            break
        elif inp.isdecimal():
            if len(out) and s[j - 1].isdecimal():
                tmp = out.pop()
                out.append(tmp*10 + int(inp))
            else:
                out.append(int(inp))
        elif inp == "(":
            ope.append(inp)
        elif inp == ")":
            while True:
                tmp = ope.pop()
                if tmp == "(":
                    break
                out.append(tmp)
        elif priority[inp] == 1:
            while len(ope) and priority[ope[-1]] >= 1:
                tmp = ope.pop()
                out.append(tmp)
            else:
                ope.append(inp)
        elif priority[inp] == 0:
            while len(ope) and priority[ope[-1]] >= 0:
                tmp = ope.pop()
                out.append(tmp)
            else:
                ope.append(inp)
    ans = deque([])
    for k in range(len(out)):
        if out[k] == "+":
            a = ans.pop()
            ans[-1] += a
        elif out[k] == "-":
            a = ans.pop()
            ans[-1] -= a
        elif out[k] == "*":
            a = ans.pop()
            ans[-1] *= a
        elif out[k] == "/":
            a = ans.pop()
            b = ans.pop()
            ans.append(int(b/a))
        else:
            ans.append(out[k])
    print(ans[0])



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

using namespace std;

typedef long long ll;
const int MAX = 100005;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	COMinit();
	ll n,k;
	cin>>n>>k;
	vector<ll> arr(n);
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	sort(arr.begin(),arr.end());
	ll ans=0;
	for(int i=k-1;i<n;i++)
	{
		ll x=i;
		ans+=arr[i]*COM(x,k-1)%MOD;
		ans%=MOD;
		ans+=MOD;
		ans%=MOD;
	}
	for(int i=0;i<n-k+1;i++)
	{
		ll x=n-i-1;
		ans-=arr[i]*COM(x,k-1)%MOD;
		ans%=MOD;
		ans+=MOD;
		ans%=MOD;
	}
	// for(int i=0;i<n;i++)
	// {
	// 	for(int j=i+k-1;j<n;j++)
	// 	{
	// 		ll x=j-i-1;
	// 		ans+=(COM(x,k-2)%MOD*(arr[j]-arr[i])%MOD);
	// 		ans%=MOD;
	// 	}
	// }
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  string stone;
  cin >> N >> stone;
  int red = 0;
  for (int i = 0; i < N; i++) {
    if (stone[i] == 'R') {
      red++;
    }
  }
  int ans = 0;
  for (int i = 0; i < red; i++) {
    if (stone.at(i) == 'W') {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  double L;
  cin >> L;
  L /= 3;
  cout << fixed << setprecision(10) << L * L * L << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  int m1, d1;
  cin >> m1 >> d1;
  int m2, d2;
  cin >> m2 >> d2;
  cout << (m1 != m2) << '\n';
  return 0;
}

Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert
#define aer(v) (v).erase((v).begin(),(v).end()) 
#define fh(x,v) for(auto x:v)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int a[5],k;

main(){
	rep(i,5)cin>>a[i];
	cin>>k;
	rep(i,5)rep(j,5){
		if(abs(a[i]-a[j])>k){
			dump(":(");
			return 0;
		}
	}
	dump("Yay!");
}






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

def tobase4(num):
    ans = ''
    while num>0:
        ans += str(num%4)
        num //= 4
    return ans[::-1]

def check(s):
    if '1' in s and '2' in s and '3' in s and '0' not in s:
        return True
    return False

def conv(s):
    s = s.replace('2','5')
    s = s.replace('3','7')
    s = s.replace('1','3')
    return s

res = 0
for i in range(10**9):
    s = tobase4(i)
    if not check(s):
        continue
    s = conv(s)
    s = int(s)
    #print(s)
    if n < s:
        break
    #print(s)
    res += 1
print(res)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		if(x==0) {
			System.out.println(1);
		}else if(x==1) {
			System.out.println(0);
		}

	}

}


Measured memory_bytes: 35672
N, K = gets.split.map(&:to_i)

H = Hash.new(0)
N.times{ 
  a, b = gets.split.map(&:to_i)
  H[a] += b
}

sum = 0
H.sort.each do |k,v|
  sum += v
  if sum >= K
    puts k
    exit
  end
end

Measured memory_bytes: 9992
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using i64 = int64_t;
using u64 = uint64_t;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

constexpr int64_t MOD = 1'000'000'007LL;

#define INT(NAME) int NAME; cin>>NAME;
#define INT64(NAME) int64_t NAME; cin>>NAME;
#define VECTOR(NAME, TYPE, SIZE) std::vector<TYPE> NAME((SIZE));\
    for(int xxxx_i=0; xxxx_i<SIZE; xxxx_i++) cin>>NAME[xxxx_i];
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)    

void solve() {
    INT(N)
    INT(X); X--;
    INT(Y); Y--;
    VECTOR(count, int, N-1);

    for(int i=0; i<N-1; i++) {
        for (int j=i+1; j<N; j++) {
            int k = min(
                abs(i-j),
                abs(i-X) + abs(j-Y) + 1
            );
            count[k-1]++;
        }
    }
    for (int n : count) cout<<n<<endl;
}

int main() {
    solve();

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    
    
    static void PRINT(int x,int y){
        for(int i=0;i<x;i++){
            for(int j=0;j<y;j++){
                System.out.print("#");
            }
            System.out.println("");
        }
        System.out.println("");
    }
    
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0&&W==0)break;
            else PRINT(H,W);
        }
        sc.close();
    }
    
}


Measured memory_bytes: 34224
#include<iostream>
#include<complex>
using namespace std;
int main(){
	int n,a[4],x[4],y[4];
	cin>>n;for(int i=0;i<4;i++)cin>>a[i];
	int ans=10000000;
	for(int i=1;i<n;i++){
		for(int j=0;j<4;j++){
			x[j]=(a[j]-1)%i;
			y[j]=(a[j]-1)/i;
		}
		if(ans>abs(x[1]-x[0])+abs(y[1]-y[0])+abs(x[3]-x[2])+abs(y[3]-y[2]))
			ans=abs(x[1]-x[0])+abs(y[1]-y[0])+abs(x[3]-x[2])+abs(y[3]-y[2]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*
*/
//約数の列挙
vector<ll> divisor(ll n){
    vector<ll> res;//約数を格納する列
    for(ll i= 1;i*i <= n;i++){
        if(n % i == 0){
           res.push_back(i);
           if(i != n/i) res.push_back(n/i);
         }
    }
    return res;
}

int main() {
  ll N;
  cin >> N;
  vector<ll> res = divisor(N);//Nの約数の列
  ll ans = 0;
  for(int i = 0;i<res.size();i++){
      ll m = res[i]-1;
      if(m != 0 && N/m == N%m) ans += m;
  }
  cout << ans << endl;

}

Measured memory_bytes: 384
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    ll n,k;
    cin >> n >> k;
    ll h[n];
    inrep(n,h);
    
    rsort(h,h+n,ll);
    rep(i,0,k){
	if(i >= n)break;
	h[i] = 0;
    }
    
    ll cnt = 0;
    rep(i,0,n)cnt += h[i];
    P(cnt);
		  
    return  0;
}


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

using ll = long long;
using ull = unsigned long long;

#define newline '\n'

map<ll, int> primecount;

void primeFactors(ll n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        ++primecount[2];
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            ++primecount[i];
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        ++primecount[n];
}

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

    ll n;
    cin >> n;
    primeFactors(n);
    //cout << "done with prime factors\n" << flush;

    int ops = 0;
    for (pair<ll, int> pp: primecount) {
        //ll p = pp.first;
        int cnt = pp.second;
        int i = 1;

        while (true) {
            ++ops;
            if (cnt - i <= i) {
                break;
            }
            cnt -= i;
            ++i;
        }
    }

    cout << ops << newline;

    return 0;
}


Measured memory_bytes: 3672
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [0] * n
c = ['Y'] * n
c[0] = 'N'
x = 0
y = 1
while x != k:
    c[y-1] = 'N'
    x += 1
    y = a[y-1]
    b[x-1] = y
    if c[y-1] == 'N':
        break
if x != k:
    y = b.index(a[y-1])
    k -= x
    k %= (x-y)
    c = b[y:x]
    print(c[k-1])
else:
    print(y)

Measured memory_bytes: 32284
import math

N = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

c = 0
d = 0
if sum(a) > sum(b):
    print('No')
else:
    for i in range(N):
        c += max(0, a[i]-b[i])
        d += max(0, (b[i]-a[i])//2)
    if c > d:
        print('No')
    else:
        print('Yes')


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

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();

		int[][] iab = new int[N][3];
		for(int i=0;i<N;i++) {
			iab[i][0] = i;
			iab[i][1] = sc.nextInt();
			iab[i][2] = sc.nextInt();
		}
		Arrays.sort(iab, (a,b)->Integer.compare(a[1], b[1]));
		long sum = 0;
		for(int i=0;i<N;i++) {
			sum += iab[i][2];
			if(sum >= K) {
				System.out.println(iab[i][1]);
				return;
			}
		}
	}
}


Measured memory_bytes: 94472
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
int main() {
	ll n,k;
	cin>>n>>k;
	int cnt = 0;
	for(int i=1;i<=n;i++){
		ll x,y;
		cin>>x>>y;
		if((x*x+y*y)<=k*k) cnt++;
	}
	cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define INF 1023456789
#define sacnf scanf
#define scnf scanf
#define scnaf scanf
#define CRLF <<'\n';
#define ALL(v) v.begin,v.end()
#define SIZE(v) (int)v.size()
#define PRPAIR(x) x.first << x.second
#define DEBUG(x) do { std::cerr <<(x)<<'\n'; } while (0)
#define rep(i,a,b) for(int i=(a);i!=(int)b-((a)>(b));(a)>(b)?--i:++i)
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> pip;
typedef vector<int> vi;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int c=0,m=0;;
    rep(i,0,s.length()){
        if (s[i] == 'R'){
            c++;
            m=max(m,c);
        }else
            c=0;
    }
    cout << m;

}


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

int main(){
    while(true){
        string a, b;
        cin >> a;
        cin >> b;
        if(a == "0")
            break;
        
        int hit = 0;
        int blow = 0;
        for(int i=0;i<4;++i){
            if(a[i] == b[i]) hit++;
        }
        for(int i=0;i<4;++i){
            for(int j=0;j<4;++j){
                if(i == j) continue;
                if(a[i] == b[j]) blow++;
            }
        }
        cout << hit << " " << blow << endl;
    }
}

Measured memory_bytes: 1184
//  Created by conan1024hao on 2019/11/19.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;
    cin>>n;
    vector<int>l(n);
    for(int i=0;i<n;i++)
        cin>>l[i];
    bool abc=1;
    for(int i=0;i<n;i++){
        int sum=0;
        for(int j=0;j<n;j++){
            if(j!=i)
                sum+=l[j];
        }
        if(sum<=l[i])
            abc=0;
    }
    if(abc==0)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	string a, s, c;
	cin >> a >> s >> c;
	cout << a[0] << s[0] << c[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio() ios_base::sync_with_stdio(false)
#define rmod(x, y) ((((x)%(y))+(y))%(y))
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
template<typename T, typename R = null_type, typename C = less<T>>
tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update> ordered_set(){
    return tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update>();
}

const int maxn = 53, maxs = 50*50 +5;
int n, tar, a[maxn];
ll dp[maxn][maxs][maxn];

int main(){
	scanf("%d %d", &n, &tar);
	for(int i = 1; i<= n; i++) scanf("%d", &a[i]);
	dp[0][0][0] = 1;
	for(int i = 1; i<=n; i++){
		for(int s = 0; s<maxs; s++){
			for(int c = 0; c<=i; c++){
				dp[i][s][c] = dp[i-1][s][c];
				if (c>0 && s>=a[i]) dp[i][s][c] += dp[i-1][s-a[i]][c-1];
			}
		}
	}
	ll ans = 0;
	for(int i = 1; i<=n; i++){
		ans+= dp[n][i*tar][i];
	}
	printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 52480
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int maxn=1e5+111;
int main(){
    int k,a,b;
    scanf("%d%d%d",&k,&a,&b);
    int num=b/k-(a-1)/k;
    if(num) puts("OK");
    else puts("NG");
    return 0;
}

Measured memory_bytes: 3668
fun main(args: Array<String>) {
    val List = readLine()!!.split(" ").map(String::toInt)
    val A     = List[0]
    val B     = List[1]
    if(A > B) {
        println(A + A - 1)
    } else if(A < B) {
        println(B + B - 1)
    } else if(A == B) {
        println(A + B)
    }
}

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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

// ========================================================================= //

const int N = 55;

int n;
int a[N];

int main() {
    ios::sync_with_stdio(false);

    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    sort(a + 1, a + n + 1);
    if (a[1] == 0) {
        cout << "0\n";
        return 0;
    }
    for (int i = 1; i < n - 1; ++i)
        if (a[i] == a[i+2]) {
            cout << "0\n";
            return 0;
        }
    if (n >= 2 && a[n-1] == 12) {
        cout << "0\n";
        return 0;
    }

    if (n == 23) {
        cout << "1\n";
        return 0;
    }
    int ans = 0;
    for (int m = 0; m < 1 << n; ++m) {
        static vector<int> ts;
        int cans = 222;
        int prv = 0;
        for (int i = 1; i <= n; ++i)
            if (m & (1 << (i-1))) {
                cans = min(cans, a[i] - prv);
                prv = a[i];
            }
        for (int i = n; i >= 1; --i)
            if (!(m & (1 << (i-1)))) {
                cans = min(cans, 24 - a[i] - prv);
                prv = 24 - a[i];
            }
        cans = min(cans, 24 - prv);
        ans = max(ans, cans);
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int i,n,a[10000],b[10000],A,B;
	A=0;B=0;
	scanf("%d",&n);
	while(n!=0)
	{
		for(i=0;i<n;i++)
		{
			scanf("%d%d",&a[i],&b[i]);
			if(a[i]>b[i])
			A=A+a[i]+b[i];
			else if(a[i]<b[i])
			B=B+a[i]+b[i];
			else
			{
				A=A+a[i];B=B+b[i];
			}
		}
		printf("%d %d\n",A,B);
		A=0;B=0;
		scanf("%d",&n);
	}
	return(0);
}

Measured memory_bytes: 676
#include<bits/stdc++.h>
using namespace std;
long long n;
int ans;
void check(long long x) {
	long long nn=n;
	while(nn%x==0) nn/=x;
	if(nn%x==1) ans++;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(long long i=1;i*i<=n-1;i++)
		if((n-1)%i==0) {
			if(i>1) ans++;
			if(i*i!=n-1) ans++;
		}
	for(long long i=1;i*i<=n;i++)
		if(n%i==0) {
			if(i>1) check(i);
			if(i*i!=n) check(n/i);
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c=1,d=1,i,Count=0;
    cin>>a>>b;
    for(i=0;;i++)
    {
        Count++;
        if(c>=a)
        {
            if((c-1)>=a)
            {
                cout<<Count-1<<endl;
                break;
            }
            else
            {
                cout<<Count<<endl;
                break;
            }
        }
        c=c*b;
    }
    return 0;
}


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

int main() {
  long long n,k;
  cin>>n>>k;
  vector<long long>a(n);
  for(long long i=0;i<n;i++){
    cin>>a.at(i);
  }
  vector<long long>s;
  vector<long long>ord(n+1,-1);
  long long v=1;
  while(ord.at(v)==-1){
    ord.at(v)=s.size();
    s.push_back(v);
    v=a.at(v-1);
  }
  long long c=s.size()-ord.at(v);
  long long l=ord.at(v);
  if(k<l){
    cout<<s.at(k)<< endl;
  }
  else{
    cout<<s.at(l+(k-l)%c)<< endl;
  }
}
    

Measured memory_bytes: 8468
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); i++)

using namespace std;
using ll = int64_t;

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

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


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

using namespace std;

long long comb(int n, int r) {
    long long ans = 1;
    for (int i = 0; i < r; i++) ans = ans*(n - i)/(i + 1);
    return ans;
}

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

    sort(a.begin(), a.end(), greater<int>());

    vector<int> b(n);
    b[0] = a[0];
    for (int i = 1; i < n; i++) b[i] = abs(2*a[i] - b[0]);
    int ans = 1, diff = b[1];
    for (int i = 2; i < n; i++) {
        if (b[i] < diff) {
            ans = i;
            diff = b[i];
        }
    }

    cout << a[0] << ' ' << a[ans] << endl;
    return 0;
}

Measured memory_bytes: 1024