akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

ll mod=pow(10,9)+7;

struct Combination{
    vec n,n_rev;

    Combination(int N){
        n.resize(N+1);
        n_rev.resize(N+1);
        n[0]=1;n_rev[1]=1;
        for(int i=1;i<=N;i++){
            n[i]=((ll)i*n[i-1])%mod;
        }
        for(int i=2;i<=N;i++){
            n_rev[i]=matpow(n[i],mod-2);
        }
    }

    //累乗(aのk乗)
    ll matpow(ll a,int k){
        ll dp=1,mt=a;
        while(k>0){
            if(k & 1)dp=(dp*mt)%mod;
            mt=(mt*mt)%mod;
            k/=2;
        }
        return dp;
    }

    ll comb(int N,int r){  
        if(r==0 || N==r)return 1;
        return (((n[N]*n_rev[r])%mod)*n_rev[N-r])%mod;
    }
};

int main(){
    int r1,c1,r2,c2;cin>>r1>>c1>>r2>>c2;
    Combination Comb(2000010);
    ll ans=Comb.comb(r1+c1,r1);
    for(int i=r1+1;i<=r2;i++){
        ans=(ans+Comb.comb(c2+i,i))%mod;
    }
    for(int j=c1+1;j<=c2;j++){
        ans=(ans+Comb.comb(r2+j,j))%mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 31488
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

int main (){
  int q,x;
  set<int> a,b;
  vector<int> result;

  cin >> q;

  for (int i = 0; i < q; i++){
    cin >> x;
    a.insert(x);
  }

  cin >> q;

  for (int i = 0; i < q; i++){
    cin >> x;
    b.insert(x);
  }
  set_union(begin(a),end(a),begin(b),end(b),inserter(result,end(result)));

  for_each(begin(result), end(result), [](int x) {
    cout << x << endl;
  });
  return 0;
}



Measured memory_bytes: 23712
import bisect

N=int(input())
A=[-int(input()) for i in range(N)]

B=[]
c=0
for a in A:
  p=bisect.bisect_right(B,a)
  if p==c:
    B.append(a)
    c += 1
  else:
    B[p]=a

print(len(B))


Measured memory_bytes: 7836
import sys, math
n = int(input())
s = list(input())
m = 10**9+7
store = 0
ans = 1

for i in range(2*n):
    if i % 2 == 0:
        if s[i] == "B":
            s[i] = "W"
        else:
            s[i] = "B"

for i in range(2*n):
    if s[i] == "W":
        store += 1
    else:
        if store <= 0:
            print(0)
            sys.exit()
        ans = ans % m * store
        store -= 1

if not store == 0:
    print(0)
    sys.exit()

print(ans*math.factorial(n) % m)

Measured memory_bytes: 5668
N=int(input().strip())
ab=[]
from collections import defaultdict
node=defaultdict(list)
edge={}
ans={}
for i in range(N-1):
    a,b=(map(int, input().strip().split()))
    edge[i]=(a,b)
    node[a].append(b)
    node[b].append(a)
from queue import Queue
q=Queue()
q.put(1)
K=0
col=defaultdict(set)
K=0
while not q.empty():
    i=q.get()
    nxt=[j for j in node[i] if j>i]
    c=1
    for n in nxt:
        while c in col[i]or c in col[n]:
            c+=1
        ans[(i,n)]=c
        col[i].add(c)
        col[n].add(c)
        K=max(K,c)
        q.put(n)
print(K)
for i in range(N-1):
    print(ans[edge[i]])

Measured memory_bytes: 91208
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int X;
	cin >> X;
	bool can = false;
	if (X == 3 || X == 5 || X == 7)can = true;
	if (can)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd
from bisect import bisect_right
n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
if k>A[n-1]:ans=-1
elif k==A[n-1]:ans=1
else:
    a=A[0]
    for i in range(1,n):
        a=gcd(a,A[i])
    m=A[bisect_right(A,k)]
    if (m-k)%a==0:
        ans=1
    else:
        ans=-1
if ans==1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 16108
//#pragma GCC optimize(2)
// Happy TLE and WA every day!
// by: zxb the vegetable chicken
#include<bits/stdc++.h>
#define mp              make_pair
#define rep(i,n)        for(int i = 0; i < n; i++)
#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF            0x7fffffff
#define INF             0x3f3f3f3f
#define LINF            4557430888798830399
#define END(s)          {cout<<s; return 0;}
#define CON(s)          {cout<<s; continue;}
#define BRE(s)          {cout<<s; break;}
#define pb              push_back
#define All(a)          a.begin(), a.end()  //with A in CAPITAL!!!
#define sz(a)           (int)a.size()
#define F               first
#define S               second
#define Time            clock()/CLOCKS_PER_SEC
//#define usingFiles
using namespace std;

typedef unsigned int ui;
typedef pair<int, int> pii;
typedef long long ll;

inline bool Read(int& x){
	x = 0;
	int c;
	int sign = 1;
	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;
	x = c ^ '0';
	while( (c = getchar()) >= '0' && c <= '9' ) x = (x<<3) + (x<<1) + (c ^ '0');
	x *= sign;
	return 1;
}

inline bool Write(int x){
	if(x >= 10) Write(x / 10);
	putchar(x % 10 + '0');
	return 1;
}

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;
const int Mod = 1000000007;

int M, N;
int a[1010];
int b[1010];

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	memset(a, 0, sizeof(a));
	memset(b, 0, sizeof(b));
	cin >> N >> M;
	rep(i, N) cin >> a[i];
	rep(j, M) cin >> b[j];
	sort(a, a + N), sort(b, b + M);
	reverse(a, a + N), reverse(b, b + M);
	rep(i, N - 1) if(a[i] == a[i + 1]){
		cout << "0\n";
		return 0;
	}
	rep(i, M - 1) if(b[i] == b[i + 1]){
		cout << "0\n";
		return 0;
	}
	int nowi = 0, nowj = 0;
	long long ans = 1;
	for(int x = M * N; x > 0; x--){
		if(a[nowi] == x && b[nowj] == x){
			nowi++, nowj++;
		} else if(a[nowi] == x && b[nowj] != x){
			ans *= nowj;
			ans %= Mod;
			nowi++;
		} else if(a[nowi] != x && b[nowj] == x){
			ans *= nowi;
			ans %= Mod;
			nowj++;
		} else {
			ans *= (nowi * nowj - (N * M - x));
			ans %= Mod;
		}
		if(ans == 0){
			cout << "0\n";
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = list(map(int,readline().split()))
ans = 0
j = 1
for i in range(N):
    if A[i] == j:
        j+=1
    else:
    	ans += 1
if j == 1:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 27928
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n"
#define dcml(n) fixed<<setprecision(n)

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; }
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; }
ll modPow(ll x,ll n,ll mod=MOD){
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod);
}
ll GetDigit(ll num){
    ll digit=0;
    while(num!=0){num/=10;digit++;}
    return digit;
}
using namespace std;
//-------------------------------------------
ld dist(pair<ld,ld> p1,pair<ld,ld> p2){
	ld dx=p2.first-p1.first;
	ld dy=p2.second-p1.second;
	return sqrt(dx*dx+dy*dy);
}
int main(void){
  ll N;cin>>N;
  vector<pair<ld,ld>> p(N);
  REP(i,N)cin>>p[i].first>>p[i].second;
  vi cn(N);REP(i,N)cn[i]=i;
  ld sumd=0;int c=0;
  do{
  	c++;
    ld d1=0;
    
    //REP(i,N)cout<<cn[i];
    //cout<<endl;
    REPS(i,N-1){
      ll idx1=cn[i-1];ll idx2=cn[i];
      d1+=dist(p[idx1],p[idx2]);
      //cout<<"("<<p[idx1].first<<","<<p[idx1].second<<")"<<"->";
      //cout<<"("<<p[idx2].first<<","<<p[idx2].second<<")+";
    }//cout<<"="<<d1<<endl;
    sumd+=d1;
  }while(next_permutation(ALLv(cn)));
  cout<<dcml(10)<<sumd/c;
}


Measured memory_bytes: 256
io = STDIN
n=io.gets.to_i
h=io.gets.split.map(&:to_i)
def check(n,h)
  return 'Yes' if n==1
  (0..n-1).each_cons(2) do |i,j|
    if h[i]==h[j]
    elsif h[i]+1==h[j]
      h[j]-=1
    elsif h[i]>h[j]
      return 'No'
    else
      h[j]-=1
    end
  end
  'Yes'
end
puts check(n,h)


Measured memory_bytes: 8580
//============================================================================
// Name : firstTrial.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 20;
long long int ero[N], cnt[N], late[N], ans[N];
int dist(int a, int b, int n){
	if(a < b)
		return b - a;
	return n - a + b;
}
int main(){
	int n, m;
	long long int cost = 0;
	scanf("%d%d", &m, &n);
	int last = -1;
	while(m--){
		int x;
		scanf("%d", &x);
		if(last != -1){
			cost += dist(last, x, n);
			ero[x] += dist(last, x, n) - 1;
			cnt[x]++;
			if(last != n)
				last++;
			else
				last = 1;
			if(last > x){
				late[last]--;
			}else{
				cnt[last]--;
			}
		}
		last = x;
	}

	long long int curEro = 0, curCnt = 0;
	for(int i = n; i > 0; i--){
		curEro += ero[i];
		curEro -= curCnt;
//		cout << curEro << ' ';
		ans[i] = curEro;
		curCnt += cnt[i];
		cnt[i] = 0;
		ero[i] = 0;
	}
//	cout << endl;
	long long int mx = 0;
	for(int i = n; i > 0; i--){
		curEro -= curCnt;
//		cout << curEro << ' ';
		mx = max(mx, ans[i] + curEro);
		curCnt += late[i];
		cnt[i] = 0;
		ero[i] = 0;
	}
//	cout << cost << endl;
	printf("%lld", cost - mx);
	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long k;
  cin>>k;
long long a,b;
cin>>a>>b;
long long ans=0;
for(long long i=1;i<=(b+3)/k;i++){
  if(k*i>=a&&k*i<=b){
    ans=1;
  }
}
if(ans==1){
  cout<<"OK"<<endl;
}
else{
  cout<<"NG"<<endl;
}
  return 0;
}

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

int main() {
  int H, W, x,y;
  string a;
  cin >> H >> W;
  x = W + 2;
  while (x >0){
    if (x == 1){
      cout << '#' << endl;
    }
    else cout << '#';
  x--;
  }
  
  for (int i = 0; i < H; i++){
    cin >> a;
    cout << '#' << a << '#' <<endl;
  }
  y = W + 2;
    while (y >0){
      if (y == 1){
        cout << '#' << endl;
      }
    else cout << '#';
      
  y--;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int a = sc.nextInt(), b = sc.nextInt();
        int max = Math.max(Math.max(a + b, a - b), a * b);
        System.out.println(max);
    }
}


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

using namespace std;

class Team{
public:
  int id, solved, penalty;
  Team(){}
  Team(int id, int solved, int penalty) : id(id), solved(solved), penalty(penalty) {}
  bool operator < (const Team& s) const {
    if(solved == s.solved){
      if(penalty == s.penalty) return id < s.id;
      return penalty < s.penalty;
    }
    return solved > s.solved;
  }
};

int T, P, R;
bool solved[50][10];
int cnt[50][10];
Team teams[50];

main(){
  while(cin >> T >> P >> R && (T|P|R)){
    fill(solved[0], solved[50], false);
    fill(cnt[0], cnt[50], 0);
    for(int i=0;i<T;i++) teams[i] = Team(i, 0, 0);
    for(int i=0;i<R;i++){
      int id, pid, time;
      string message;
      cin >> id >> pid >> time >> message;
      id--; pid--;
      if(message == "CORRECT" && !solved[id][pid]){
        solved[id][pid] = true;
        teams[id].solved++;
        teams[id].penalty += time + 1200 * cnt[id][pid];
      }else cnt[id][pid]++;
    }
    sort(teams, teams+T);
    for(int i=0;i<T;i++) cout << teams[i].id+1 << ' ' << teams[i].solved << ' ' << teams[i].penalty << endl;
  }
}

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

using namespace std;

bool ok(const string& S)
{
	const int L = S.size();
	for (int i = 0; i < L; i += 2) {
		if (string("RUD").find(S[i]) == string::npos) {
			return false;
		}
	}
	for (int i = 1; i < L; i += 2) {
		if (string("LUD").find(S[i]) == string::npos) {
			return false;
		}
	}
	return true;
}

int main()
{
	string S;
	cin >> S;
	if (ok(S)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 384
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    dp = [[0]*(N+1) for _ in range(N+1)]

    for w in range(1, N+1):
        for le in range(N):
            ri = le + w
            if N < ri:
                break
            if N % 2 == w % 2:
                # 先手番
                dp[le][ri] = max(dp[le + 1][ri] + A[le],
                                 dp[le][ri - 1] + A[ri - 1])
            else:
                # 後手番
                dp[le][ri] = min(dp[le + 1][ri] - A[le],
                                 dp[le][ri - 1] - A[ri - 1])

    print(dp[0][N])


if __name__ == '__main__':
    main()


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

using namespace std;

int n, p, q;
int x[100], y[100];

int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  int ans = n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j == i) {
        continue;
      }
      int p = x[i] - x[j];
      int q = y[i] - y[j];
      int cnt = n;
      for (int k = 0; k < n; k++) {
        for (int t = 0; t < n; t++) {
          if (t == k) {
            continue;
          }
          if (x[t] - x[k] == p && y[t] - y[k] == q) {
            cnt--;
          }
        }
      }
      ans = min(ans, cnt);
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#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 FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

Node* treeMinimum(Node *x) {
  while(x->left != NIL) x = x->left;
  return x;
}

Node* treeSuccessor(Node *x) {
  if (x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while (y != NIL && x == y->right) {
    x = y;
    y = y->parent;
    return y;
  }
}

void treeDelete(Node *z) {
  Node *y;
  Node *x;
  if (z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);
  if (y->left != NIL) {
    x = y->left;
  }
  else x = y->right;
  if (x != NIL) {
    x->parent = y->parent;
  }
  if (y->parent == NIL) {
    root = x;
  }
  else {
    if (y == y->parent->left) {
      y->parent->left = x;
    }
    else y->parent->right = x;
  }
  if (y != z) {
    z->key = y->key;
  }
  free(y);
}

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

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

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

void inorder(Node *u) {
  if (u == NIL) return;
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
}

void preorder(Node *u) {
  if (u == NIL) return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}

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


int main() {
  int n, x;
  string com;
  cin >> n;
  rep(i, n) {
    cin >> com;
    if (com == "insert") {
      cin >> x;
      insert(x);
    }
    else if (com == "print") {
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
    else if (com[0] == 'f') {
      cin >> x;
      Node *t = find(root, x);
      if (t != NIL) {
        cout << "yes" << endl;
      }
      else {
        cout << "no" << endl;
      }
    }
    else if (com == "delete") {
      cin >> x;
      treeDelete(find(root, x));
    }
  }

  
  return 0;
}


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

ll digSum(ll n) {
  ll ans = 0;
  while(n>0) {
    ans += n%10;
    n/=10;
  }
  return ans;
}

int main() {
  ll n; cin >> n;
  if(n%digSum(n)==0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
from collections import deque
inf = 10**18
mod = 10**9+7


# a^n
def power(a,n,mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


n = int(input())
a = list(map(int, input().split()))
a2 = [0]
for i in a:
    a2.append(a2[-1]+i)
def sumArea(l,r):
    return a2[r]-a2[l]

# a2に同じ数が何個あるか
dic = {}
for num in a2:
    if num in dic:
        dic[num]+=1
    else:
        dic[num]=1
ans = 0
for _,tmp in dic.items():
    if tmp != 1:
        ans += tmp*(tmp-1)//2
print(ans)



Measured memory_bytes: 114028
#include<stdio.h>

int selectionSort(int A[], int N){
	int i, j, t, sw=0, minj;
	for(i=0;i<N-1;i++){
		minj=i;
		for(j=i;j<N;j++){
			if(A[j]<A[minj]) minj=j;
		}
			t=A[i];
			A[i]=A[minj];
			A[minj]=t;
				if(i!=minj) sw++;
	}
	return sw;
}

int main(){
	int A[100], N, i, sw;
	
	scanf("%d", &N);
	for(i=0;i<N;i++){
		scanf("%d", &A[i]);
	}
		sw = selectionSort(A, N);
		
		for(i=0;i<N;i++){
			if(i>0) printf(" ");
			printf("%d", A[i]);
		}
		printf("\n");
		printf("%d\n", sw);
	return 0;
}


Measured memory_bytes: 2100
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		int N =nextInt();
		long K =nextLong();

		Pair[] p = new Pair[N];
		for(int i=0;i<N;i++){
			p[i]=new Pair(nextInt(),nextInt());
		}
		Arrays.sort(p,Pair.getComparator());

		long cnt=0;
		for(int i=0;i<N;i++){
			if(K<=cnt+p[i].V){
				System.out.println(p[i].N);
				return;
			}
			cnt+=p[i].V;
		}
	}

	public static class Pair {
		int N;
		int V;


		Pair(int N, int V) {
			this.N = N;
			this.V = V;
		}

		public int getN() {
			return N;
		}

		public int getV() {
			return V;
		}

		public static Comparator<Pair> getComparator() {
			return Comparator.comparing(Pair::getN);
		}
	}

	public static long[] disassemblyAlph(String s) {
		long[] alph = new long['z' - 'a' + 1];
		Arrays.fill(alph, 0);
		for (int i = 0; i < s.length(); i++) {
			alph[s.charAt(i) - 'a']++;
		}
		return alph;
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}

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

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int h,w,n;
	cin>>h>>w>>n;
	if(h==1){
		cout<<"1\n";
	}else if(w==1){
		cout<<"1\n";
	}
	else if(h>w){
		cout<<(n/h+(n%h!=0))<<'\n';
	}else{
		cout<<(n/w+(n%h!=0))<<'\n';
	}
	return 0;
}

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

using namespace std;

void DfsVisit(const int key, const vector<vector<int>> &adjacency,
    vector<bool> &passedMap, map<pair<int, int>, bool> &usedEdgeMap)
{
    passedMap[key] = true;
    for (const int neighbor : adjacency[key])
    {
        if (usedEdgeMap[{key, neighbor}] == false)
        {
            usedEdgeMap[{key, neighbor}] = usedEdgeMap[{neighbor, key}] = true;
        }
        if (passedMap[neighbor] == false)
        {
            DfsVisit(neighbor, adjacency, passedMap, usedEdgeMap);
        }
    }
}

int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> adjacency(N);
    map<pair<int, int>, bool> usedEdgeMap;
    for (int i = 0; i < M; ++i)
    {
        int X, Y, Z;
        cin >> X >> Y >> Z;
        // Zの値に関係なく，関係性の分かっている２カードをつなぐ
        adjacency[X - 1].push_back(Y - 1);
        adjacency[Y - 1].push_back(X - 1);
        usedEdgeMap[{X - 1, Y - 1}] = usedEdgeMap[{Y - 1, X - 1}] = false;
    }

    vector<bool> passedMap(N);
    for (int i = 0; i < N; ++i)
        passedMap[i] = false;

    // 形成したネットワークの連結部分数を数える
    int count = 0;
    for (int i = 0; i < N; ++i)
    {
        if (passedMap[i] == false)
        {
            DfsVisit(i, adjacency, passedMap, usedEdgeMap);
            ++count;
        }
    }
    cout << count;

    return 0;
}

Measured memory_bytes: 33792
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(S: str):
    print("x"*len(S))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <cstdio>
#include <utility>
#include <cmath>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n';)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;if((c=gcu())=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
	_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

template<int N>
struct sieve {
	bool s[N];
	int v[N], l = -1;
	sieve() : s(), v() {
		s[2] = true;
		for (int i = 3; i < N; i += 2)
			s[i] = true;
		for (int i = 9; i < N; i += 6)
			s[i] = false;
		for (int i = 6, e = sqrt(N); i <= e; i += 6) {
			for (int j : {i - 1, i + 1})
				if (s[j])
					for (int k = j * j; k < N; k += j)
						s[k] = false;
		}
		for (int i = 2; i < N; i++)
			if (s[i])
				v[++l] = i;;
	}
};

int main() {
	sieve<1000001> S;
	for (int n; (n = in);) {
		int c {};
		for (int i {}; S.v[i] <= n / 2; i++)
			if(S.s[n - S.v[i]])
				c++;
		outl(c);
	}
}


Measured memory_bytes: 7308
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod1 1000000007
#define mod2 1000000009

using namespace std;
using ll=long long;
int v[1000005];
class CAXBC {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int n;
        cin>>n;
        for (ll i=2;i<1000005;i++){
            if (v[i]==0){
                for (ll j=i;j<1000005;j+=i){
                    if (v[j]==0)
                        v[j]=i;
                }
            }
        }
        int count=0;
        for (int i=1;i<n;i++){
            int tmp=n-i,tmpAdd=1;
            while(tmp!=1){
                int div=v[tmp];
                int cnt=0;
                while (tmp%div==0){
                    cnt++;
                    tmp/=div;
                }
                tmpAdd*=(cnt+1);
            }
            count+=tmpAdd;
        }
        cout<<count;
	}
};


int main() {
	CAXBC solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 7508
#include <cstdio>
#include <cstring>
#include <bitset>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
const int maxn=2010;
const int maxk=10010;
bitset<10010> dp[2010];
pair<int,int> vis[2][10010];
char s[2010][10010],ans[1000010];
int len[2010],n,k,cnt,ncnt;
int main() {
    scanf("%d%d",&n,&k);
    for (int i=1;i<=n;i++) scanf("%s",s[i]),len[i]=strlen(s[i]);
    dp[n+1][0]=1;
    for (int i=n;i>=1;i--) 
        dp[i]=dp[i+1]|(dp[i+1]<<len[i]);
    // int cnt=0;
    for (int i=1;i<=n;i++) 
        if (dp[i+1][k-len[i]]) vis[0][++cnt]=make_pair(i,0);

    int ii=0;
    for (int i=0;i<k;i++) {
        char minc='z';
        for (int j=1;j<=cnt;j++) minc=min(minc,s[vis[ii][j].first][vis[ii][j].second]);
        ans[i]=minc;
        
        int minid=n+1;
        ncnt=0;
        for (int j=1;j<=cnt;j++) {
            int nid=vis[ii][j].first,nlen=vis[ii][j].second;
            if (s[nid][nlen]!=minc) continue;
            if (nlen+1==len[nid]) minid=min(minid,nid);
            else vis[ii^1][++ncnt]=make_pair(nid,nlen+1);
        }
        for (int j=minid+1;j<=n;j++) {
            if (k-len[j]-i-1>=0 && dp[j+1][k-len[j]-i-1]) vis[ii^1][++ncnt]=make_pair(j,0);
        }
        ii^=1;
        cnt=ncnt;
    }
    printf("%s\n", ans);
    return 0;
}



Measured memory_bytes: 21888
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type StackData struct {
	data interface{}
	next *StackData
}

type Stack struct {
	sp  *StackData
	top int
}

func NewStack() *Stack {
	return &Stack{top: 0}
}

func (s *Stack) Push(data interface{}) {
	s.sp = &StackData{data: data, next: s.sp}
	s.top++
}

func (s *Stack) Pop() interface{} {
	if s.top > 0 {
		item := s.sp.data
		s.sp = s.sp.next
		s.top--
		return item
	}
	return nil
}

func (s *Stack) Peek() interface{} {
	if s.top > 0 {
		return s.sp.data
	}
	return nil
}

func (s *Stack) IsEmpty() bool {
	if s.top == 0 {
		return true
	}
	return false
}

func (s *Stack) Size() int {
	return s.top
}

type Pair struct {
	p   int64
	num int64
}

func primeFactorize(n int64) *Stack {
	s := NewStack()
	for p := int64(2); p*p <= n; p++ {
		if n%p != 0 {
			continue
		}
		num := int64(0)
		for n%p == 0 {
			num++
			n /= p
		}
		s.Push(Pair{p: p, num: num})
	}
	if n != 1 {
		s.Push(Pair{n, 1})
	}
	return s
}

const MAX = 210000
const MOD = 1000000007

var fac, finv, inv [MAX]int64

func COMinit() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for i := int64(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
	}
}

func COM(n, k int64) int64 {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

var slice []Pair

func main() {
	sc.Split(bufio.ScanWords)

	N := int64(nextInt())
	// ans := int64(1)
	m := map[int64]int64{}
	for i := int64(2); i <= N; i++ {
		vec := primeFactorize(i)

		for !vec.IsEmpty() {
			p := vec.Pop().(Pair)
			m[p.p] += p.num
		}
	}

	slice = make([]Pair, 0, len(m))
	for k, v := range m {
		slice = append(slice, Pair{p: k, num: v})
	}

	fmt.Println(rec(0, 75))
}

func rec(p int64, mul int64) int64 {
	if p == int64(len(slice)) {
		if mul == 1 {
			return 1
		} else {
			return 0
		}
	}

	var res int64
	for i := int64(0); i < slice[p].num+1; i++ {
		if mul%(i+1) != 0 {
			continue
		}
		p++
		res += rec(p, mul/(i+1))
		p--
	}
	return res
}


Measured memory_bytes: 640
n=int(input())
L=list(map(int, input().split()))
L.sort()

ans=0
for c in range(n-1,1,-1):
    a=0
    b=c-1
    while(a<b):
        #cが一番長い
        if(L[a]+L[b]>L[c]):
            ans+=b-a
            b-=1
        else:
            a+=1
            
print(ans)


Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i = 0;i<n;i++)
    {
        cin>>arr[i];
    }
    int ans[n];
    ans[0] = 0;
    ans[1] = abs(arr[1]-arr[0]);
    for(int i = 2;i<n;i++)
    {
        ans[i] = min(abs(arr[i-1]-arr[i])+ans[i-1],abs(arr[i]-arr[i-2])+ans[i-2]);
    }
        cout<<ans[n-1];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 4364
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;


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

    int a, b;
    cin >> a >> b;

    string u;
    cin >> u;

    if (u == s) {
        a -= 1;
    }
    else if (u == t) {
        b -= 1;
    }
    cout << a << " " <<  b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <stdio.h>
#include <stdlib.h>
#include <list>

using namespace std;

const double pi = 3.14159265358979323846;
const int mod = 1000000007;

int main(){
  string s1;
  string s2;

  cin >> s1;
  cin >> s2;

  if(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0]) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
def make_divisors(n):
    #https://qiita.com/LorseKudos/items/9eb560494862c8b4eb56
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n = int(input())
cnt = 0
for i in range(1,n+1,2):
    if len(make_divisors(i))==8:
        cnt += 1
        #print(i)
print(cnt)

Measured memory_bytes: 9200
n = int(input())
s = input()
dp1 = {}
for i in range(10):
    dp1[str(i)] = -1
dp2 = {}
for i in range(10):
    for j in range(10):
        dp2[str(i) + str(j)] = -1

for i in range(n):
    if dp1[s[i]] == -1:
        dp1[s[i]] = i

for i in range(10):
    if dp1[str(i)] != -1:
        for j in range(dp1[str(i)]+1, n):
            if dp2[str(i)+str(s[j])] == -1:
                dp2[str(i)+str(s[j])] = j

dp3 = {}
for i in range(10):
    dp3[i] = [0] * (n+1)
for i in range(n):
    dp3[int(s[i])][i+1] = 1
for i in range(10):
    for j in range(n):
        dp3[i][j+1] += dp3[i][j]


ans = 0
for i in range(10):
    for j in range(10):
        t = dp2[str(i)+str(j)]
        for k in range(10):
            if t != -1: 
                if dp3[k][n] - dp3[k][t+1] >= 1:
                     ans += 1
print(ans)

Measured memory_bytes: 43100
#include <bits/stdc++.h>
#define loop for(;;)
typedef std::vector<long> LI;
template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   void solve() {
      long n; scan(n);
      if( n == 0 ) exit(0);
      LI xs(n); for(long& x : xs) scan(x);
      std::sort(xs.begin(), xs.end());
      long res = (1LL << 53);
      for(long i = 1; i < n; ++i) {
         res = std::min(res, xs[i] - xs[i-1]);
      }
      printf("%ld\n", res);
   }
};

int main() {
   loop std::shared_ptr<Solver>()->solve();
}

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

using namespace std;

vector<vector<int>> solve(int k){
	const int m = k - 1;
	vector<vector<int>> mat(m, vector<int>(m));
	for(int i = 0; i < m; ++i){
		for(int j = 0; j < m; ++j){ mat[i][j] = i * m + j + 1 + m; }
	}
	vector<vector<int>> solution;
	for(int i = 0, c = 1; i < k; ++i){
		solution.emplace_back();
		solution.back().push_back(0);
		for(int j = 1; j < k; ++j){
			solution.back().push_back(c++);
		}
	}
	for(int i = 1; i < k; ++i){
		const int s = i - 1;
		for(int j = 0; j < m; ++j){
			solution.emplace_back();
			solution.back().push_back(i);
			for(int p = 0; p < m; ++p){
				solution.back().push_back(mat[p][(s * p + j) % m]);
			}
		}
	}
	return solution;
}

int main(){
	ios_base::sync_with_stdio(false);
	const int k = 38;
	const auto solution = solve(k);
	cout << solution.size() << " " << k << endl;
	for(const auto& v : solution){
		for(int i = 0; i < k; ++i){
			if(i != 0){ cout << " "; }
			cout << v[i] + 1;
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  ll n, d;
  cin >> n >> d;
  ll d2;
  int ans = 0;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    d2 = x*x + y*y;
    if(d2 <= d*d) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  bool cards[4][13] = {};
  int n;
  char mark;
  int num;

  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> mark;
    cin >> num;
    switch(mark) {
      case 'S':
        cards[0][num - 1] = true;
        break;

      case 'H':
        cards[1][num - 1] = true;
        break;
      
      case 'C':
        cards[2][num - 1] = true;
        break;
      
      default:
        cards[3][num - 1] = true;
        break;
    }
  }

  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 13; ++j) {
      if (!cards[i][j]) {
        switch (i) {
          case 0:
            cout << "S " << (j+1) << endl;
            break;
          case 1:
            cout << "H " << (j+1) << endl;
            break;
          case 2:
            cout << "C " << (j+1) << endl;
            break;
          default:
            cout << "D " << (j+1) << endl;
            break;            
        }
      }
    }
  }
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second
#define _GLIBCXX_DEBUG

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
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; }

const double PI = 3.1415926535897932384;

// 1次元vectorの出力
template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}

// 2次元vectorの出力
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

int main(void){
	int n; cin >> n;
	set<string> a;
	string s;
	Rep(n){
		cin >> s;
		a.insert(s);
	}
	cout << a.size() << endl;
}

Measured memory_bytes: 19220
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        boolean flag = false;
        for(int i = 0; i < num; i++){
            int a = Integer.parseInt(sc.next());
            if(a%2==0){
              if(a%3!=0 && a%5!=0){
                flag = true;
                //System.out.println(a + "aa");
              }
            }
        }
        if(flag == true)
          System.out.println("DENIED");
        else
          System.out.println("APPROVED");
    }
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    double a[n];
    double sum=0;
    for(int i =0;i<n;i++)
    {
        cin>>a[i];
        sum=sum+1/a[i];
    }
    cout<<1/sum<<endl;

}


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

using namespace std;



void solve() {
    string s; cin >> s;
    int n = s.size();
    int x = n&1;
    int y = s[0] == s[n-1];
    auto res = (x^y)?"First":"Second";
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		StringBuilder sb = new StringBuilder();
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			int a = scan.nextInt();
			String op = scan.next();
			int b = scan.nextInt();
			
			if (a < 0 || b < 0 || a > 20000 || b > 20000) {
				System.out.println("Error!");
			}
		
			if (op.equals("?"))
				break;
			if (op.equals("+")) {
				sb.append(a+b).append('\n');
			}
			if (op.equals("-")) {
				sb.append(a-b).append('\n');
			}
			if (op.equals("*")) {
				sb.append(a*b).append('\n');
			}
			if (op.equals("/")) {
				sb.append(a/b).append('\n');
			}
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 18032
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);

    const PS = arg.slice(1, M + 1);
    
    const map = {};
    const penaMap = {};
    
    let score = 0;
    let pena  = 0;
    
    for(let i=0; i<M; i++) {
        const P = parseInt(PS[i].split(" ")[0]);
        const S = PS[i].split(" ")[1];
        
        if(!map[P] && S === "WA") {
            if(penaMap[P]) {
                penaMap[P]++;
            } else {
                penaMap[P] = 1;
            }
        } else if(!map[P] && S ==="AC") {
            map[P] = "done";
            score++;
            pena += penaMap[P] ? penaMap[P] : 0;
        }
        
        // console.log(P)
        // console.log(JSON.stringify(map));
        // console.log(!map[P])
    }
    
    console.log(score + " " + pena);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 31132
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

#define NIL -1
#define N 100005

struct Node{ int p, l, r; };

Node T[N];
int n, D[N], H[N];

void preorder(int u){
	if (NIL == u) return;
	printf(" %d", u);
	preorder(T[u].l);
	preorder(T[u].r);
}

void inorder(int u){
	if (NIL == u) return;
	inorder(T[u].l);
	printf(" %d", u);
	inorder(T[u].r);
}

void postorder(int u){
	if (NIL == u) return;
	postorder(T[u].l);
	postorder(T[u].r);
	printf(" %d", u);
}


int main()
{
	int i, root;

	cin >> n;
	for (int i = 0; i < n; ++i) T[i].p = NIL;

	for (int i = 0; i < n; ++i){
		int u, l, r; cin >> u >> l >> r;
		T[u].l = l;
		T[u].r = r;
		if (NIL != l) T[l].p = u;
		if (NIL != r) T[r].p = u;
	}

	for (int i = 0; i < n; ++i) if (NIL == T[i].p) root = i;

	printf("Preorder\n");
	preorder(root);
	printf("\n");

	printf("Inorder\n");
	inorder(root);
	printf("\n");

	printf("Postorder\n");
	postorder(root);
	printf("\n");

	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N;
  cin >> N;
  cout << (N % 1000 == 0 ? 0 : 1000 - N % 1000) << endl;
  return 0;
}


Measured memory_bytes: 3628
N = int(input())
inp = list(map(lambda x: float(x), input().split(" ")))

dp = [[0]*(N+1) for i in range(N+1)]
dp[0][0] = 1.0

for i in range(N):
    for j in range(i+1):
        dp[i+1][j] += dp[i][j]*(1-inp[i])
        dp[i+1][j+1] += dp[i][j]*inp[i]

print(sum(dp[N][(N//2+1):N+1]))

Measured memory_bytes: 254088
#include <stdio.h>
#include <string.h>
int main(void)
{
    char s[6];
    int i, j = 0;
    scanf("%s", s) ;
    if((s[2]==s[3])&&(s[4]==s[5]))
        j++;
    if(j==1)
        puts("Yes");
    else
        puts("No") ;
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define MOD 1000000007
#define MX 105

char s[MX];

int main()
{
    scanf("%s",s);
    //YAKI
    if (s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
        printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int INF = 1001001;

int main(){
  int n, m, a, b;
  cin >> n >> m;
  vector<P> req(m);
  for(int i=0; i<m; ++i){
    cin >> a >> b;
    --a; --b;
    req[i] = make_pair(a,b);
  }
  sort(req.begin(),req.end());
  int minb = INF;
  int x = 0;
  int ans = 0;
  for(int i=0; i<n-1; ++i){
    for(int j=x; j<m; ++j){
      //cout << j << "req: " << req[j].first << '&' << req[j].second << endl;
      if(req[j].first != i) break;
      minb = min(minb, req[j].second);
      ++x;
    }
    //cout << i << ':' << minb << endl;
    if(minb == i+1){
      ++ans;
      //cout << "ans++" << endl;
      minb = INF;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4064
using namespace std;
#include<vector>
#include<iostream>
#include<algorithm>
#include<queue>

int C[10000];
int res[10000];
int visited[10000];
int ranks[10000];

vector<int> G[10000];

int main() {
    int N;
    cin >> N;
    int a, b;
    for (int i = 0; i < N-1; i++) {
        cin >> a >> b;
        a--; b--;
        ranks[a]++; ranks[b]++;
        
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }

    sort(C,C+N);

    for (int i = 0; i < N; i++) {
        int minrank = 100000;
        int minnode = -1;
        for (int j = 0; j < N; j++) {
            if (ranks[j] < minrank) {
                minrank = ranks[j];
                minnode = j;
            }
        }
        res[minnode] = C[i];
        ranks[minnode] = 1000000;
        for (int j = 0; j < G[minnode].size(); j++) {
            ranks[G[minnode][j]]--;
        }
    }

    long long score = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < G[i].size(); j++) {
            score += min(res[i],res[G[i][j]]);
            for (int k = 0; k < G[G[i][j]].size(); k++) {
                if (G[G[i][j]][k] == i) {
                    G[G[i][j]].erase(G[G[i][j]].begin()+k);
                }
            }
        }
    }

    cout << score << "\n";
    for (int i = 0; i < N; i++) {
        printf("%d ",res[i]);
    }
    printf("\n");
}

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

int main() {
    int n;
    cin >> n;
    vector<tuple<int, int, int>> robots(n);
    for (int i = 0; i < n; ++i) {
        cin >> get<1>(robots.at(i)) >> get<2>(robots.at(i));
        get<0>(robots.at(i)) = get<1>(robots.at(i)) + get<2>(robots.at(i));
    }
    sort(robots.begin(), robots.end());
    ll mostRight = -1 * 1e10;
    int ans = 0;
    int x, l;
    for (int j = 0; j < n; ++j) {
        x = get<1>(robots.at(j));
        l = get<2>(robots.at(j));
        if (mostRight > x - l) ans++;
        else mostRight = x + l;
    }
    cout << n - ans << endl;
}


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

int h, w;
string s[8];
int cnt;
int main()
{
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        cin >> s[i];
        for (int j = 0; j < w; j++)
        {
            if (s[i][j] == '#')
            {
                cnt++;
            }
        }
    }
    if (cnt == h + w - 1)
    {
        cout << "Possible" << endl;
    }
    else
    {
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

void solve(){
    int N;
    cin>>N;
    vi V(N);
    vi C(N);
    F0R(i,N){
        cin>>V[i];
    }
    F0R(i,N){
        cin>>C[i];
    }
    int ans=0;
    F0R(i,N){
        if(V[i]-C[i]>0){
            ans+=(V[i]-C[i]);
        }
    }
    out(ans);

}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

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

using namespace std;

int main() {
    int n, *a;
    cin >> n;
    a = new int[n];
    int i;
    for (i = 0; i < n; i++) 
        cin >> a[i];
    
    sort(a, a+n, greater<int>());

    int alice = 0, bob = 0;
    for (i = 0; i < n; i += 2)
        alice += a[i];
    for (i = 1; i < n; i += 2)
        bob += a[i];
    cout << alice - bob << endl;
    
    return 0;
}

Measured memory_bytes: 256