akhauriyash/Code-Regression huggingface dataset:
import numpy as np

N = int(input())
X = [[] for _ in range(N)]
L = [[] for _ in range(N)]

for i in range(N):
    X[i], L[i] = map(int, input().split())
    
    
def indexSort(L):
    D = dict(zip(range(len(L)), L))
    E = sorted(D.items(), key=lambda x: x[1])
    F = [e[0] for e in E]
    return F

L1 = [x-l for x, l in zip(X, L)]
L2 = [x+l for x, l in zip(X, L)]


Ind = np.argsort(L2)

Remain = [Ind[0]]
i = 0
while i < len(Ind)-1:
    now = Remain[-1]
    After = Ind[i+1:]

    skip = 0
    for after in After:
        if L2[now] > L1[after]:
#            print(L2[now], L1[after])
            skip += 1
        else:
#            print(after)
            Remain.append(after)
            break
    i += 1 + skip  
print(len(Remain))

Measured memory_bytes: 32628
package main
import "fmt"
func main(){
    var a,b,c,d int
    fmt.Scan(&a,&b,&c,&d)
    var num, num_c, num_d, num_cd int
    num = b - a + 1
    cd := c * d / gcd(c,d)
    num_c = (num / c) + ((a - 1) % c +(num % c)) / c
    num_d = (num / d) + ((a - 1) % d +(num % d)) / d
    num_cd = (num / cd)+ ((a - 1) % cd +(num % cd)) / cd
    fmt.Println(num - num_c - num_d + num_cd)
}

func gcd(a, b int) int{
    if b == 0 {
        return a
    }
    return gcd(b, a % b)
}

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

typedef long long ll;

const int MAX_H = 100000;
const int MAX_W = 100000;

const int MAX_N = 200000;
const int MOD = 1000000007;

ll factorial[MAX_N+1];
ll inverse[MAX_N+1];

// 繰り返し２乗法による冪乗(x^n)計算 O(log(n))
int exponentiation(ll x, int n) {
	int res = 1;
	while (0 < n) {
		if (n & 1) {
			res = x * res % MOD;
		}
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}

// 組み合わせ nCr の計算 O(1)
ll combination(int n, int r) {
	if (n - r == 0 || r == 0) return 1;
	static bool flag = true;
	if (flag) {
		// 階乗と階乗の逆数の初期化 O(n)
		factorial[0] = 1; inverse[0] = 1;
		for (int i=1; i<=MAX_N; i++) {
			factorial[i] = factorial[i-1] * i % MOD;
			inverse[i] = exponentiation(factorial[i], MOD-2);
		}
		flag = false;
	}
	return factorial[n] * inverse[n-r] % MOD * inverse[r] % MOD;
}

int main() {
	int H, W, A, B;
	cin >> H >> W >> A >> B;

	int ans = 0;
	for (int x=B+1; x<=W; x++) {
		ans += combination(x+H-A-2, x-1) * combination(W-x+A-1, A-1) % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
#
#　　　　　　　　　　　　　　,. -─────────‐- .、
#　　　　　　　　　　　　 ／／￣￣＼　　　　　　／￣￣＼＼
#　　　　　　　　　　　／　　　　　　　　　　　　　　　　　　　　 ＼
#　　　　　　　　　 ／　　　　　　　　::::::::::::::::::::::::::::::::　　　　　　　＼
#　　　　　　　　／ 　　／ ／￣＼＼::::;;;;;;;;;;;;;;;;;:::::／／￣＼＼　　＼
#　　　　　　 ／　　　　|　 |.　┃　.|　| ::::;;;;;;;;;;;;;::::｜ |.　┃　.|　|　　　 ＼　　　　　　　　　　　　　　　　　　　　　
#　　　　　／ 　　　　　＼ ＼＿／／　::::::::::::::::::　＼＼＿／／　　　　　 ＼　　　　
#　　　 ／　　　　　..／￣￣＼　／　　　::｜::　　　＼　／￣￣＼..　　　　　＼
#　　 / 　 　 　 　 :::::　　　　　　|　　　　　 |　　　　　 |　　　　　　 :::::　　　　　 ヽ.　　　
#　　| 　　　　　　　　　　　　　　|　　　　　 |　　　　　 |　　　　　　　　　　　　　　|.
#　　| 　　　　　　　　　　　　　　＼＿＿／＼＿＿／ 　　　　　　　　　　　　　　|　　　　　　　　　　　　　　　　　
#　　| 　　　　　　　　　　　　　　　｜　　　　　　　｜　　　　　　　　　　　　　　　|
#　　| 　　　　　　　　　　　　　　　｜r─‐┬──､|　　　　　　　　　　　　　　　 |
#　　ヽ　　　　　　　　　　　　　　　 |/　　　|　　 　｜　　　　　　　　　　　　　　/
#　　　 ＼　　　　　　　　　　　　　 ＼　　　　　　／　　　　　　　　　　　　　／
#　　　　　＼ 　　　　　　　　　　　　　￣￣￣￣　　　　　　　　　　　　　／
#
#
import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [input() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S = ST()
    x, y = MI()
    to_x_y = [[], []]
    deleted = False
    for i,s in enumerate(S):
        if s == "T":
            S = S[i:]
            deleted = True
            break
        else:
            x -= 1
    if not deleted:
        S=""
    toY = False
    contin = False
    #run length 
    for i, s in enumerate(S):
        if s == "F":
            if contin:
                to_x_y[toY][-1] += 1
            else:
                to_x_y[toY].append(1)
                contin = True
        else:
            toY = not toY
            contin = False

    #print((x,y),*to_x_y,sep="\n")

    #xについてdp
    now_x = set([0])
    for distanse in to_x_y[0]:    
        next_x = set()
        for i, X in enumerate(now_x):
            next_x.add(X + distanse)
            next_x.add(X - distanse)
        now_x = next_x
    
    #yについてdp
    now_y = set([0])
    for distanse in to_x_y[1]:    
        next_y = set()
        for i, Y in enumerate(now_y):
            next_y.add(Y + distanse)
            next_y.add(Y - distanse)
        now_y = next_y

    #print(now_x,now_y)
    print("YNeos"[x not in now_x or y not in now_y::2] )


if __name__ == '__main__':
    main()

Measured memory_bytes: 48988
/************************************************************
	> File Name: d.cpp
	> Author: TSwiftie
	> Mail: 2224273204@qq.com 
	> Created Time: Sun 31 May 2020 08:11:26 PM CST
************************************************************/
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#include <ext/rope>
#define int long long
#define lowbit(x) (x&-x)
#define SZ(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int INF = 0x3f3f3f3f;
const LL INF_ll = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int N = 1e5+10;
int fac[N][2],cnt;
signed main(void){
	IOS;
	int n;
	cin >> n;
	for(int i = 2;i*i <= n;++i)
		if(n%i==0){
			++cnt;
			fac[cnt][0] = i;
			while(n%i==0) ++fac[cnt][1],n/=i;
		}
	if(n!=1){
		++cnt;
		fac[cnt][0] = n;
		fac[cnt][1] = 1;
	}
	int ans = 0;
	for(int i = 1;i <= cnt;++i){
		int st = 0;
		while(st*(st+1)/2 <= fac[i][1]) ++st;
		--st;
		ans += st;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

const int N = 105;

string s[N];

int main() {
	int n, l;
	cin >> n >> l;
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
	}
	sort(s, s + n);
	for (int i = 0; i < n; ++i) {
		cout << s[i];
	}
	return 0;
}



Measured memory_bytes: 256
"""
重さと価値がそれぞれw_i,v_iであるようなn個の品物がある.
これらの品物の中から, 重さの総和がWを超えないように選んだ時の,
価値の総和の最大値を求めよ.
1<=n<=100, 1<=w_i<=10^7, 1<=v_i<=100, 1<=limit_w<=10^9
"""
#-------------------------------------------------------------------------------

#入力
INF = 2000000000
"""
メモ : Pythonでは無限大を表す float('inf') があるが, 処理がかなり重たいので
       代わりにsum(v)より真に大きい 2*10^9 を INFとする.
       (https://atcoder.jp/contests/dp/tasks/dp_e において,PyPyを使用して,
        前者だと1060ms, 後者だと570msで2倍近く差が出ている.)
"""
n ,limit_w = map(int, input().split())
w = [0]*n
v = [0]*n
for i in range(n):
    w[i], v[i] = map(int, input().split())
sum_v = sum(v)
dp = [INF for i in range(sum_v + 1)]
# dp[i][j]には重さが入る.
# dp[i][j]=(i番目までの品物から価値がちょうどｊになるための重さの最小値)

# ここからメイン
dp[0] = 0
for i in range(n):
    for j in range(sum_v ,-1,-1):
        if j >= v[i]:
            dp[j] = min(dp[j], dp[j - v[i]] + w[i])

# n個まで使って,重さがlimit_wを超えないで価値が最大のものを求める.
ans = 0
for i in range(sum_v + 1):
    if dp[i] <= limit_w:
        ans = i
print(ans)


Measured memory_bytes: 45168
import math

A, B, H, M = map(int, input().split(" "))

degree_h = ((H + M / 60) * 30) % 360
degree_m = ((H * 60 + M) * 6) % 360

deg = (
    min(abs(degree_h - degree_m), 360 - abs(degree_h - degree_m)) * 2 * (math.pi / 360)
)

print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(deg)))


Measured memory_bytes: 9504
#include<bits/stdc++.h>
#define mod 1000000007
#define f first
#define s second

using namespace std;

/*int gcd(int a,int b){
	if(b == 0)
		return a;
	return gcd(b,a%b);
}*/

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

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

    
    ll n;
    cin>>n;

    ll ans = ((n-1) * (n))/2;

    cout<<ans;
	return 0;
}

Measured memory_bytes: 256
/*
Author: Deep Chaklasiya
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update> data_set;
#define fbo find_by_order
#define ook order_of_key




#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define piiii       pair<pii,pii>
#define viiii       vector<pair<pii,pii>>
#define mi          map<int,int>
#define mii         map<pii,int>
#define piii           pair<int,pair<int,int> >
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define ef else if





int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }
bool mod(double a,double b) {return a/b - floor(a/b);}

int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}

int logb(int base, int x) {
    return (log(x) / log(base));
}


template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}

void set_min(int &m,int a){
    if(m==-1||m>a)m=a;
}


signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int i,j,x,n,m,k,t;
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && b!=c) cout<<"Yes";
    else if(b==c && b!=a) cout<<"Yes";
    else if(a==c && a!=b) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,T = list(map(int,input().split()))
t = list(map(int,input().split()))
t_stop = []
for i in range(N):
    t_stop.append(t[i]+T)
cum_flow = T*N
for i in range(N-1):
    cum_flow -= max(t_stop[i] - t[i+1],0)
print(cum_flow)


Measured memory_bytes: 31044
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

mod = 10**9+7

n = int(input())
g = [[] for _ in range(n)]

pow2 = [0 for _ in range(n+1)]
pow2[0] = 1
for i in range(n):
    pow2[i+1] = pow2[i]*2 % mod

for _ in range(n-1):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

depth = [-1]*n
ko_all = [0 for _ in range(n)]
ko_only = [0 for _ in range(n)]

depth[0] = 0
stack = [0]

while stack:
    v = stack.pop()
    if any(depth[w] == -1 for w in g[v]):
        stack.append(v)
    for w in g[v]:
        if depth[w] == -1:
            depth[w] = depth[v] + 1
            stack.append(w)
        elif depth[w] > depth[v]:
            ko_all[v] += ko_all[w] + 1
            ko_only[v] += pow2[ko_all[w]+1]-1


cnt = 0

for i in range(n):
    tmp = pow2[n-1]-1-(pow2[n-1-ko_all[i]]-1) - ko_only[i]
    tmp %= mod
    cnt += tmp
    cnt %= mod


def inv(a, mod):
    r = [1, 0, a]
    w = [0, 1, mod]
    while w[2] != 1:
        q = r[2]//w[2]
        r_new = [r[0]-q*w[0], r[1]-q*w[1], r[2]-q*w[2]]
        r = w
        w = r_new
    x, y = w[0], w[1]    # a*x+y*mod = 1
    return (mod+x % mod) % mod


print(inv(pow2[n], mod)*cnt % mod)


Measured memory_bytes: 90712
#include <stdio.h>
#include <string.h>
#include <ctype.h>
   
int main(void){
   
  char T[1000];
  char W[10];
  int count = 0;
  register int i;
   
  scanf("%s",W);
  for(i = 0;i < strlen(W);i++){
    W[i] = tolower(W[i]);
  }
  while(1){
    scanf("%s",T);
    if(strcmp(T,"END_OF_TEXT") == 0){
      break;
    }
    for(i = 0;i < strlen(T);i++){
      T[i] = tolower(T[i]);
    }
    if(strcmp(T,W) == 0){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 552
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
  long n;
  cin >> n;

  long a[n];
  long res[n];
  for (long i = 0; i < n; i++)
  {
    cin >> a[i];
    res[a[i]-1] = i+1;
  }

  for (long i = 0; i < n; i++)
  {
    if(i != 0){
      cout << " ";
    }
    cout << res[i];
  }
  cout << endl;
  

}

Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
using namespace std;
int a[100][100];
bool l=false;
void solve(int n, int m, int xg, int yg, int c,int h,int w) {
	if (m + 1 < w&&a[n][m + 1] == c) {
		a[n][m + 1] = 1000;
		if (n == xg&&m+1 == yg) {
			l = true; return;
		}
		solve(n, m+1, xg, yg, c, h, w);
	}
	if (m - 1 >= 0 && a[n][m - 1] == c) {
		a[n][m - 1] = 1000;
		if (n == xg&&m - 1 == yg) {
			l = true; return;
		}
		solve(n, m-1, xg, yg, c, h, w);
	}
	if (n + 1 < h && a[n+1][m] == c) {
		a[n+1][m] = 1000;
		if (n+1 == xg&&m == yg) {
			l = true; return;
		}
		solve(n+1, m, xg, yg, c, h, w);
	}
	if (n - 1 >= 0 && a[n-1][m] == c) {
		a[n-1][m] = 1000;
		if (n-1 == xg&&m  == yg) {
			l = true; return;
		}
		solve(n-1, m, xg, yg, c, h, w);
	}
}
int main() {
	int w, h;
	while (cin >> w >> h&&w != 0 && h != 0) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++)
				a[i][j] = 0;
		}
		int xs, ys, xg, yg,n;
		cin >> ys >> xs;
		cin >> yg >> xg;
		xs--; ys--; xg--; yg--;
		cin >> n;
		for (int i = 0; i < n; i++) {
			int c, d, x, y;
			cin >> c >> d >> y >> x;
			x--;
			y--;
			if (d == 0) {
				for (int j = 0; j < 2; j++) {
					for (int z = 0; z < 4; z++) 
						a[x + j][y + z] = c;
				}
			}
			else {
				for (int j = 0; j < 4; j++) {
					for (int z = 0; z < 2; z++)
						a[x + j][y + z] = c;
				}
			}
		}
		int k = a[xs][ys];
		a[xs][ys] = 1000;
		l = false;
		solve(xs, ys, xg, yg, k,h,w);
		if (l) cout << "OK" << endl;
		else cout << "NG" << endl;
	}
}

Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	static long[][] dp;
    static int ind=1;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int n=gi();
	    int m=gi();
        long k=gi();
        long[] A = new long[n];
        long[] B=new long[m];

        for (int i=0; i< n;i++) {
        	A[i]=gl();
        }
        for (int i=0; i< m;i++) {
        	B[i]=gl();
        }
        long t=k;
        long s=0;
        long max=0;
        int ai=-1;
        int bi=0;
        for (int i=0; i< n;i++) {
        	if(t>=A[i]) {
        		t-=A[i];
        		s++;
        		ai=i;
        	} else {
        		break;
        	}
        }
        for (int i=0; i< m;i++) {
        	if(t>=B[i]) {
        		t-=B[i];
        		s++;
        		bi=i+1;
        	} else {
        		break;
        	}
        }
        max=s;

        while(ai>=0) {
        	t+=A[ai];
        	ai--;
        	s--;
        	while(bi<m) {
        		if(t>=B[bi]) {
        			t-=B[bi];
        			bi++;
        			s++;
        		} else {
        			break;
        		}
        	}
        	if(s>max) {
        		max=s;
        	}
        	if(bi>=m) break;
        }


        System.out.println(max);
	}

	// 文字列として入力を取得
	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: 63144
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s, t;
  cin >> n >> s >> t;
  for (int i = 0; i < n; ++i) {
    if (s.substr(i) == t.substr(0, n-i)) {
      cout << i+n << endl;
      return 0;
    }
  }
  cout << n*2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
using namespace std;

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

	if (A< 1200) {
		cout << "ABC" << endl;
	}

	else if (1200 <= A && A < 2800) {
		cout << "ARC" << endl;
	}

	else if (2800 <= A ){
		cout << "AGC" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
a,b,N,M = map(int,input().split())
n = N
m = M
while m != 0:
  mt = n%m
  n = m
  m = mt
g = N*M//n
mass = g//N + g//M - 1
bq = b // g
br = b % g
bsc = mass * bq
bsc += br // N
bsc += br // M
aq = (a-1) // g
ar = (a-1) % g
asc = mass * aq
asc += ar // N
asc += ar // M
print(b-a-bsc+asc+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;cin>>s>>t;
  ll ans=1001,sl=s.length(),tl=t.length();
  for(ll i=0;i+tl<=sl;++i) {
    ll tmp=0;
    string ss=s.substr(i,tl);
    for(ll j=0;j<tl;++j) if(t[j]!=ss[j]) tmp++;
    ans=min(ans,tmp);
  }
  print(ans);
  return 0;
}

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

int main(){
  string N;
  cin >> N;
  if(N[0]==N[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
		   
  
  return 0;

}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define MP make_pair
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define fst first
#define snd second

#define INF 1000000

int t(int x) { return x*(x+1)*(x+2)/6; }

int dp[1000010];

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

  Vi one, two, odd;
  for (int i = 1; t(i) <= 1000000; i++) {
    one.push_back(t(i));
    if (t(i)%2) odd.push_back(t(i));
  }

  for (int a : one) {
    for (int b : one) {
      two.push_back(a+b);
    }
  }
  sort(ALL(two));

  REP(i, 1000001) dp[i] = INF;
  dp[0] = 0;
  REP(i, 1000000) {
    for (int a : odd) {
      if (i+1-a >= 0)
	dp[i+1] = min(dp[i+1-a]+1, dp[i+1]);
    }
  }  

  while (1) {
    int n;
    cin >> n;
    if (n == 0) break;

    if (n == *lower_bound(ALL(one), n)) {
      cout << 1;
    } else if (n == *lower_bound(ALL(two), n)) {
      cout << 2;
    } else {
      bool flag = false;
      for (int a : one) {
	if (n - a == *lower_bound(ALL(two), n - a)) {
	  flag = true;
	  break;
	}
      }
      if (flag) {
	cout << 3;
      } else {
	for (int a : two) {
	  if (n - a == *lower_bound(ALL(two), n - a)) {
	    flag = true;
	    break;
	  }
	}
	cout << (flag ? 4 : 5);
      }
    }

    cout << ' ' << dp[n] << endl;

  }    
  return 0;
}

Measured memory_bytes: 5260
// @prefix atcoder
// @description atcoder template

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n;

signed main()
{
	cin >> n;
	cout << (n-1)/2 + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF 1000000007
#define MOD 1000000007
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//--GLOBAL---------------------------------


//--MAIN-----------------------------------
void Main() {

    ll N; cin>>N;

    vector<ll> A(N);
    rep(i,N) cin>>A[i];

    ll ans[N+1]={};

    ll mai[N+1]={};
    ll sum[N+1]={};

    unordered_map<ll,ll> mp;

    rep(i,N){
        ++mp[A[i]];
    }
    for(auto x: mp){
        ++mai[x.second];
    }
    ll syurui=mp.size();
    ll ct=0;
    reps(i,1,N+1){
        sum[i]=sum[i-1]+syurui;
        syurui-=mai[i];
    }

    rep(i,N){
        ll K=i+1;
        /*bis*/ ll low= -1 , high= N+1 ; // min-1, max+1
        while( abs(high-low)>1 ){ ll mid=(high+low)/2;
            ( sum[mid]>=mid*K ? low : high ) = mid;
        }// if ok, okdir = mid
        ans[i]=low;
    }

    rep(i,N){
        cout<< ans[i] <<"\n";
    }

}   
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 23368
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int A=Integer.parseInt(sc.next());
int B=Integer.parseInt(sc.next());
int C=Integer.parseInt(sc.next());
int K=Integer.parseInt(sc.next());
for(int i=0;i<K;i++){
if((A*2+B+C>=A+B*2+C)&&(A*2+B+C>=A+B+C*2)){
A*=2;
}else if((A+B*2+C>=A*2+B+C)&&(A+B*2+C>=A+B+C*2)){
B*=2;
}else if((A+B+C*2>=A*2+B+C)&&(A+B+C*2>=A+B*2+C)){
C*=2;
}
}
System.out.println(A+B+C);
}}

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

using namespace std;

int n,a[200005],cnt[200005];
long long f[2][200005];
long long sum;

int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
		cnt[a[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(f[0][a[i]])
			continue;
		if(cnt[a[i]]==0)
			f[0][a[i]]=0;
		else	
			f[0][a[i]]=(long long)cnt[a[i]]*(cnt[a[i]]-1)/2;
		if(cnt[a[i]]==1 || cnt[a[i]]==0)
			f[1][a[i]]=0;
		else
			f[1][a[i]]=(long long)(cnt[a[i]]-1)*(cnt[a[i]]-2)/2;
		sum+=f[0][a[i]];
	}
	for(int i=1;i<=n;++i)
	{
		cout<<sum-f[0][a[i]]+f[1][a[i]]<<endl;
	}
	return 0;
}

Measured memory_bytes: 6272
# -*- coding: utf-8 -*-

import math

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	a,b= map(int, io().split())
	
	return math.ceil((a+b)/2)

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

Measured memory_bytes: 2940
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
#include<math.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
int  main(){
  ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
    ll h,w,i,j,k;
    cin>>h>>w;
    char s[h][w];
    ll dp[h][w];


    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        cin>>s[i][j];
        dp[i][j]=INT_MAX;
    }
  }
    ll x,y;
    ll a[2]={1,0};
    ll b[2]={0,1};
    //dp[0][0]=(s[0][0]=='.')?0:1;

    if(s[0][0]=='.') dp[0][0]=0;
    else dp[0][0]=1;

    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        for(k=0;k<2;k++){
          x=i+a[k];
          y=j+b[k];
          int sum=0;
          if(x>=h||y>=w)
            continue;
          if(s[i][j]=='.'&&s[x][y]=='#')
            sum=1;
          dp[x][y]=min(dp[i][j]+sum,dp[x][y]);
        }
      }
    }
    cout<<dp[h-1][w-1]<<endl;
  }


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
	int n, m;
	
	while (cin >> n >> m, n, m){
		bool num[510][510] = {false};
		int a, b;
		
		for (int i = 0; i < m; i++){
			cin >> a >> b;
			num[a][b] = true;
			num[b][a] = true;
		}
		
		bool member[510] = {false};
		for (int i = 2; i <= n; i++){
			if (num[1][i]){
				member[i] = true;
				for (int j = 2; j <= n; j++){
					if (num[i][j])  member[j] = true;
				}
			}
		}
		
		int count = 0;
		for (int i = 2; i <= n; i++){
			if (member[i])  count++;
		}
		cout << count << endl;
	}
	return (0);
}

Measured memory_bytes: 1420
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple

ll M = 998244353;
double ep = 1e-6;

int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	ll h; cin>>h;
	double j = (double)log(h)/(double)log(2);
	//cout<<j<<endl;
	//if( fabs(j-(ll)j) <= ep ) j = j + 1.00;
	ll k=j; k++;
	ll ans = pow(2,k) - 1;
	cout<<ans;
	
	
	
	return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		
		long X = sc.nextLong();
		
		long i = 0, j = 0;
		boolean flag = false;
		for(i = 0; i < 200; i++) {
			for(j = 0; j < 200; j++) {
				if((long)Math.pow(i, 5) + (long)Math.pow(j, 5) == X) {
					flag = true;
					break;
				}
			}
			if(flag)break;
		}
		
		if(flag)System.out.println(j+" "+(-i));
		
		if(!flag) {
			for(i = 0; i < 200; i++) {
				for(j = 0; j < 200; j++) {
					if((long)Math.pow(i, 5) - (long)Math.pow(j, 5) == X) {
						flag = true;
						break;
					}
				}
				if(flag)break;
			}
			System.out.println(i+" "+j);
		}
		sc.close();
	}
}

Measured memory_bytes: 38744
#include<cstdio>
#include<string>
#include<map>
using namespace std;

map<string, int> m;
int n;
int t[50];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        char s[101];
        scanf("%s %d", s, &t[i]);
        string str1 = s;
        m[str1] = i;
    }
    
    char x[101];
    scanf("%s", x);
    string str2 = x;
    int ans = 0;
    for (int i = m[str2] + 1; i < n; i++) ans += t[i];
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
    int n;
    cin>>n;
    string s,t;
    string ans="";
    cin>>s>>t;
    for(int i=0;i<n;i++)
        ans+=s[i],ans+=t[i];
    cout<<ans<<"\n";
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

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

ll lcm(ll a, ll b)
{
	ll gc = gcd(a,b);
	a = a/gc;
	a = a*b;
	return a;
}

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

    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    ll xx = b/c;
    ll yy = (a-1)/c;
    xx = xx-yy;

    ll xx2 = b/d;
    ll yy2 = (a-1)/d;
    xx2 = xx2-yy2;
    xx = xx+xx2;

    ll lc = lcm(c,d);
    ll xx3 = b/lc;
    ll yy3 = (a-1)/lc;
    xx3 = xx3-yy3;
    xx = xx-xx3;

    cout << b-a+1-xx << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#include <vector>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

// gcd
LL gcd(LL a, LL b) {
	while(b){
		auto t=a%b;
		a=b;
		b=t;
	}
	return a;
}
bool f(LL a,LL b, LL c, LL d)
{
	if(a<b){
		//cerr << "a" << endl;
		return false;
	}

	if(b>d){
		//cerr << "b" << endl;
		return false;
	}

	LL r;
	if(a<=c)
	{
		r=a;
	}
	else{
		LL k=(a-c)/b;
		if((a-c)%b){
			k++;
		}
		r=a-k*b;
	}
	//cerr << r << endl;
	if(r<0){
		//cerr << "c" << endl;
		return false;
	}

	LL t=gcd(d,b);
	if(d%b==0){
		//cerr << "d" << endl;
		return true;
	}
	LL l=(c-r)/t+1;
	//cerr << t << ", " << l << ", " << r+l*t << endl;
	if(r+l*t>=b){
		//cerr << "e" << endl;
		return true;
	}
	//cerr << "f" << endl;
	return false;
}

bool g(LL a,LL b, LL c, LL d)
{
	for(int i=0;i<10000;i++){
		//cerr << a << endl;
		if(a<b){
			return false;
		}
		a-=b;
		if(a<=c){
			a+=d;
		}
	}
	return true;
}
int main() {
#if 0
	std::mt19937 engine(1234);
    std::uniform_int_distribution<> dist(1, 9);
	for(int t=0;t<100000;t++){
		LL a,b,c,d;
		a=dist(engine);
		b=dist(engine);
		c=dist(engine);
		d=dist(engine);
		if(g(a,b,c,d)!=f(a,b,c,d)){
			cerr << "aaa" << a << ", " << b << ", " << c << ", " << d << endl;
			return 0;
		}
	}
#endif
	//cerr << f(6,5,1,9) << endl;
	int T;
	cin >> T;
	for(int t=0;t<T;t++){
		LL a,b,c,d;
		cin >> a >> b >> c >> d;
		if(f(a,b,c,d)){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
 char S[11];
 char T[11];
 scanf("%s %s",S,T);
 int A,B;
 scanf("%d %d",&A,&B);
 char U[11];
 scanf("%s",U);
 if(strcmp(S,U)==0){
     printf("\n%d %d\n",A-1,B);
 }else{
     printf("\n%d %d\n",A,B-1);
 }
 return 0;
}


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

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int c[n], s[n], f[n];
  for (int i = 1; i <= n - 1; i++) {
    cin >> c[i] >> s[i] >> f[i];
  }

  for (int i = 1; i <= n - 1; i++) {
    int t = s[i]; // 初期値
    for (int j = i; j <= n - 1; j++) {
      t = t + c[j]; // iからi+1へ移動
      if (j != n - 1) {
        t = max(t, s[j + 1]); // 待機
        while (t % f[j + 1] != 0) {
          t++;
        }
      }
    }
    cout << t << endl;
  }
  cout << 0 << endl;

  return 0;
}

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

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

    cout << (s == "ABC" ? "ARC" : "ABC") << endl;

    return 0;
}


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

int main() {
    int n;

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

    H[0]--;
    for(int i = 1; i < n; i++) {
        if(H[i] - H[i - 1] > 0) {
            H[i]--;
        } else if(H[i] - H[i - 1] < 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
 
typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;
 
using namespace std;
 
int main(int argc, const char* argv[]) {
  u64 n, ans;
  u64 a[5] = {0};
  u64 bn = UINT64_MAX;
  cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

  for(int i = 0; i < 5; i++) {
    if(bn > a[i]) {
      bn = a[i];
    }
  }
  
  if(n % bn == 0) {
    ans = n / bn;
  } else {
    ans = n / bn + 1;
  }
  
  cout << ans + 4 << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll v):v(normS(v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll u[]={a,1,0},v[]={b,0,1};
		while(*v){
			ll t=*u/ *v;
			rep(i,3) swap(u[i]-=t*v[i],v[i]);
		}
		if(u[0]<0) rep(i,3) u[i]=-u[i];
		x=u[1],y=u[2];
		return u[0];
	}
	ModInt inv() const{
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<998244353>;

mint solve(string s){
	int N = s.size();

	bool allsame = 1;
	rep(i,N-1){
		if(s[i]!=s[i+1]) allsame = 0;
	}
	if(allsame){
		return 1;
	}
	if(N==3 && s[0]!=s[1] && s[0]!=s[2] && s[1]!=s[2]){
		return 3;
	}

	mint dp[3][3] = {};
	rep(i,N){
		if(i==0){
			rep(j,3) dp[j][j] = 1;
			continue;
		}
		mint ndp[3][3] = {};
		rep(j,3) rep(k,3){
			rep(x,3) if(x!=k){
				int nj = (j+x)%3;
				int nk = x;
				ndp[nj][nk] += dp[j][k];
			}
		}
		rep(j,3) rep(k,3) dp[j][k] = ndp[j][k];
	}
	mint res = 1;
	rep(i,N-1) res *= 3;
	int sum = 0;
	rep(i,N) sum += s[i]-'a';
	sum%=3;
	rep(k,3) res -= dp[sum][k];
	bool adj = 0;
	rep(i,N-1){
		if(s[i]==s[i+1]) adj = 1;
	}
	if(!adj) res += 1;
	return res;
}
int main(){
	string s;
	cin>>s;
	cout<<solve(s)<<endl;
}

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

int
main(int argc, char *argv[])
{
	vector<int> v;
	int k, n, t;

	scanf("%d %d", &k, &n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &t);
		v.push_back(t);
	}

	//std::sort(v.begin(), v.end());

	/*cout << "After sort" << std::endl;
	for (int i = 0; i < n; i++) {
		printf("%d", v[i]);
	}*/
	int maxa = 0;
	for (int i = 0; i < n - 1; i++) {
		int a = v[i + 1] - v[i];
		if (a > maxa) maxa = a;
	}
	int a = v[0] + k - v[n-1];
	if (a > maxa) maxa = a;
	printf("%d", k - maxa);

	system("pause");
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <cmath>         // sqrt
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll, string> Tlls;

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b)
{
  // Eucledean algorithm
  while (a)
  {
    if (a < b)
    {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

// Least Common Multiple 最小公倍数
ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

// key: value of prime factor素因数分解
// value: number of prime factor
map<ll, ll> prime_factorization(ll n)
{
  map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

// 約数リスト約数の列挙
vector<ll> get_divisors(const ll n)
{
  vector<ll> divs;
  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++)
  {
    if (n % i == 0)
    {
      divs.push_back(i);
      if (i != n / i)
      {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

int main()
{
  ll N;
  string s;
  ll ans = 0;
  set<string> S;
  cin >> N;
  rep(i, N)
  {
    cin >> s;
    S.insert(s);
  }
  ans = S.size();
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 19128
#include<bits/stdc++.h>
#define ll long long
#define mod (ll)1000000007
using namespace std;

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

    if(n%2)
        cout<<"No\n";
    else{
        bool ok = true;
        for(int i = 0; i < n/2; i++){
            if(s[i]!=s[i+n/2])
                ok = false;
        }

        if(!ok)
            cout<<"No\n";
        else
            cout<<"Yes\n";

    }
    return 0;
}


Measured memory_bytes: 256
mod = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for i in range(N):
    ans += A[i]
    ans %= mod
ans = ans**2%mod

for i in range(N):
    ans -= A[i]**2
    ans %= mod

ans *= pow(2,mod-2,mod)
ans %= mod
print(ans)

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

int main() {
  string s;
  cin >> s;
  int a = 0;
  int z = s.size() - 1;
  while(a < z){
    if(s[a]== 'A'){
      break;
    }
    a++;
  }
  while(a < z){
    if(s[z]== 'Z'){
      break;
    }
    z--;
  }
  cout << z - a +1 << endl;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  int64_t ga, sa, ba, gb, sb, bb;
  std::cin >> ga >> sa >> ba >> gb >> sb >> bb;

  int64_t tmp = n;

  if (sb <= sa && bb <= ba) {
    const auto i = n / ga;
    const auto calc = n - ga * i + gb * i;
    tmp = std::max(tmp, calc);
  } else {
    for (int64_t i = 0; i <= n / ga; i++) {
      if (gb <= ga && i != 0) {
        break;
      }
      const int64_t calc = n - ga * i + gb * i;
      const int64_t least = n - ga * i;

      if (sa < sb && ba < bb) {
        for (int64_t j = 0; j <= least / sa; j++) {
          const int64_t least2 = least - sa * j;
          int64_t calc2 = calc + sb * j - sa * j;
          const auto po = least2 / ba;
          calc2 += po * bb - po * ba;
          tmp = std::max(tmp, calc2);
        }
      } else if (sa < sb && bb <= ba) {
        const auto j = least / sa;
        int64_t calc2 = calc + sb * j - sa * j;
        tmp = std::max(tmp, calc2);
      } else if (sb <= sa && ba < bb) {
        const auto po = least / ba;
        int64_t calc2 = calc + po * bb - po * ba;
        tmp = std::max(tmp, calc2);
      } else {
        tmp = std::max(tmp, calc);
      }
    }
  }
  n = tmp;

  if (sa <= sb && ba <= bb) {
    const auto i = n / gb;
    const auto calc = n - gb * i + ga * i;
    tmp = std::max(tmp, calc);
  } else {
    for (int64_t i = 0; i <= n / gb; i++) {
      if (ga <= gb && i != 0) {
        break;
      }
      const int64_t calc = n - gb * i + ga * i;
      const int64_t least = n - gb * i;

      if (sb < sa && bb < ba) {
        for (int64_t j = 0; j <= least / sb; j++) {
          const int64_t least2 = least - sb * j;
          int64_t calc2 = calc + sa * j - sb * j;
          const auto po = least2 / bb;
          calc2 += po * ba - po * bb;
          tmp = std::max(tmp, calc2);
        }
      } else if (sb < sa && ba <= bb) {
        const auto j = least / sb;
        int64_t calc2 = calc + sa * j - sb * j;
        tmp = std::max(tmp, calc2);
      } else if (sa <= sb && bb < ba) {
        const auto po = least / bb;
        int64_t calc2 = calc + po * ba - po * bb;
        tmp = std::max(tmp, calc2);
      } else {
        tmp = std::max(tmp, calc);
      }
    }
  }

  std::cout << tmp << std::endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  int sum = 0;
  vector<int> v(n), c(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  for(int i = 0; i < n; i++){
    cin >> c[i];
  }
  for(int i = 0; i < n; i++){
    if(v[i]-c[i]>0){
      sum += v[i]-c[i];
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.*;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        int res = C - (A - B);

        System.out.println(res < 0 ? 0 : res);
    }
}



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

signed main() {
  int a; cin >> a;
  string s; cin >> s;
  if (a < 3200) {
    cout << "red" << endl;
  } else {
    cout << s << endl;
  }
}


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

using namespace std;

#define MOD 1000000007

#define ll long long

#define FOR(i, a, b) for (int i=a; i<(b); i++)

#define FORd(i, a, b) for (int i=a; i<(b); --i) 

int n;

int main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cin >> n;

    if (n == 0) cout <<1;

    else cout << 0;

    return 0; 

}

Measured memory_bytes: 3644
# include <iostream>
# include <cstdio>
# include <cmath>
# include <cstring>
# include <string>
# include <cstdlib>
# include <algorithm>
# include <stack>
# include <queue>
# include <vector>
# define maxx (103)
# define Pi (3.14159265358979)
# define inf (2147483647)
using namespace std;
int read() {
	int x=0,f=1;
	char ch;
	while(ch<'0'||ch>'9')  {
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		x=x*10+ch-'0';
		ch=getchar();
	}
	return f*x;
}
int main() {

	int a,b;
	a=read();
	b=read();
	
	if(a+b==15){
		cout << "+";
	}else if(a*b==15){
		cout << "*";
	}else{
		cout << "x";
	}

	return 0;
}

Measured memory_bytes: 256
S = input()
if S=="SUN":
  print(7)
elif S=="MON":
  print(6)
elif S=="TUE":
  print(5)
elif S=="WED":
  print(4)
elif S=="THU":
  print(3)
elif S=="FRI":
  print(2)
elif S=="SAT":
  print(1)

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


number EXTGCD(number a, number b, number &x, number &y) {
    number g = a; x = 1; y = 0;
    if (b != 0) g = EXTGCD(b, a % b, y, x), y -= (a / b) * x;
    return g;
}


pair<ll, ll> ChineseRem(const vll &b, const vll &m) {
    ll r = 0, M = 1;
    for (int i = 0; i < (int)b.size(); ++i) {
        ll p, q;
        ll d = EXTGCD(M, m[i], p, q); // p is inv of M/d (mod. m[i]/d)
        if ((b[i] - r) % d != 0) return make_pair(0, -1);
        ll tmp = ((b[i] - r) / d) * p % (m[i] / d);
        r += M * tmp;
        M *= m[i] / d;
    }
    r %= M;
    if (r < 0) r += M;
    return make_pair(r, M);
}

int main() {
    int N, M, D;
    cin >> N >> M >> D;
    vll A(M);
    rep(i, M) cin >> A[i];

    bool ok = true;
    rep(i, D) {
        vll b, m;
        rep(j, M) {
            int R; cin >> R;
            if (R != -1) b.push_back(R), m.push_back(A[j]);
        }
        if (b.empty()) continue;

        auto tmp = ChineseRem(b, m);

        if (tmp.second == -1) ok = false;
        if (N < tmp.first) ok = false;

        N = N - (N - tmp.first) % tmp.second;
    }
    if (ok) cout << N << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 3200