akhauriyash/Code-Regression huggingface dataset:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s = input().split()
    print(s[0][0].upper()+s[1][0].upper()+s[2][0].upper())
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39152
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int h[100'000];

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

    rep(i, n)
    {
        cin >> h[i];
    }

    int len = 0;
    int m = 0;
    for (int i = 1; i < n; i++) {
        if (h[i] <= h[i - 1]) {
            len++;
        } else {
            len = 0;
        }
        m = max(m, len);
    }
    cout << m << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

struct edge {
  ll to, cost;
  edge(ll to, ll cost) : to(to), cost(cost) {
  }
};

/* 負閉路があるとtrueを返す。O(EV) */
/* 負の辺があっても計算できる */
bool bellman_ford(int V,
                  int E,
                  vector<vector<edge>>& G,
                  vector<ll>& dist,
                  int s) {  // sは開始頂点
  dist[s] = 0;              // 開始点の距離は0
  for (int i = 0; i < V; i++) {
    for (int v = 0; v < V; v++) {
      for (int k = 0; k < G[v].size(); k++) {
        edge e = G[v][k];
        if (dist[v] != LINF && dist[e.to] > dist[v] + e.cost) {
          dist[e.to] = dist[v] + e.cost;
          if (i == V - 1)
            return true;  // n回目にも更新があるなら負の閉路が存在
        }
      }
    }
  }
  return false;
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M), c(M);
  rep(i, M) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
  }

  int V, E;
  V = N, E = M;

  vector<vector<edge>> G(V);
  for (int i = 0; i < E; i++) {
    ll from, to, cost;
    from = a[i], to = b[i], cost = -c[i];
    G[from].push_back(edge(to, cost));
  }
  vector<ll> dist(V, LINF);  // ここを0にすると全ての負閉路が検出できる

  bellman_ford(V, E, G, dist, 0);
  ll ans_1 = -dist[N - 1];
  bellman_ford(V, E, G, dist, 0);
  ll ans_2 = -dist[N - 1];

  if (ans_1 == ans_2)
    cout << ans_1 << endl;
  else
    cout << "inf" << endl;
}


Measured memory_bytes: 384
import copy
def main():
    A, B, K = map(int, input().split())
    alterK = copy.copy(K)
    K = K - A
    if K > 0:
        B = B - K
        if B <= 0:
            print('0 0')
            return
        else:
            print('0 ' + str(B))
            return
    else:
        print(str(A - alterK) + ' ' + str(B))
        return
main()

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


void solve(long long N, std::string S, std::string T){
  for(long long i = 0; i < N; i++){
    cout << S[i] << T[i];
  }

  cout << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
    solve(N, S, T);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
using namespace std;	
typedef long long int lli;

lli n,k,l,m,t,a,b,s,r,c,temp1,temp2,x,y,temp,q,d,mod=1e9+7,w;

lli arr[500005];
lli fenwick[500005];
lli ans[500005];

lli getParent(lli n)
{
	return (n&(n-1));	
}

lli getNext(lli n)
{
	lli tc = (~n)+1;
	
	lli val = (tc&n);
	
	lli retVal =  val+n;
	
	return retVal;
}

lli prefSum(lli r)
{
	lli sum=0;
	lli node=r;
	
	while(node!=0)
	{
		sum += fenwick[node];
		node = getParent(node);
	}
	
	return sum;
}

lli update(lli index , lli val)
{
	if(index>n)return 0;
	
	fenwick[index]+=val;
	return update(getNext(index),val);
}

map<lli,lli> lastSeen;

void leftRangeUpdate(lli curLeft)
{
	if(lastSeen.find(arr[curLeft-1])==lastSeen.end())
	{
		update(curLeft,1);
		
		lastSeen.insert({arr[curLeft-1],curLeft-1});
	}
	else
	{
		update(lastSeen[arr[curLeft-1]]+1,-1);
		
		update(curLeft,1);
		
		lastSeen[arr[curLeft-1]]=curLeft-1;
	}
}

multimap<pair<lli,lli>,lli,greater<pair<lli,lli>>> queries;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>q;
    
    for(int i=0;i<n;i++)cin>>arr[i];
    
    for(int i=1;i<=q;i++)
    {
		cin>>l>>r;    	
		queries.insert({{l-1,r-1},i});
    }
    
    lastSeen.insert({arr[n-1],n-1});
    
    update(n,1);
    
    lli curLeft=n-1;
    
    for(auto x:queries)
    {
    	while(x.first.first!=curLeft)
		{
			leftRangeUpdate(curLeft);
			curLeft--;
		}
		
		ans[x.second]=prefSum(x.first.second+1);
    }
    
    for(int i=1;i<=q;i++)
    {
    	cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 78132
a,b,c=map(int,input().split())
amari = []
flag = True
i = 0
FLAG = False
while flag:
  check = b*i+c
  if check % a ==0:
    FLAG = True
    flag = False
  else:
    if 0 == amari.count(check % a):
      amari.append(check%a)
    else:
      flag = False
  i = i + 1
if FLAG:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 9084
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define SIZE(x) ((int)(x).size())
#define UQ(v) v.erase(unique(v,begin(),v,end()),v.end());
ll INF = 1LL <<30;
#define pb push_back 
int dxy4[5] = { 0,1,0,-1,0 };
int dxy8[9] = { 0,1,1,0,-1,1,-1,-1,0 };
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
ll mod7 = 1000000007;
ll mod9 = 1000000009;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i,x,n) for(int i=x;i<n;++i)
//vector< vector<int> > v (max1, vector<in t>(max2) );


int main() {
	int n;
	cin >>n;
	vector<int>s;
	string str;
	int sum = 0;
	cin >> str;
	rep(i, n) {
		if (str[i] == 'E') {
			s.pb(1);
			sum++;
		}
		else {
			s.pb(0);
		}
		//cout << s[i];
	}
	int ans = n,f=0;
	rep(i, n) {
		if (f) {
			sum++;
		}
		if (s[i]) {
			sum--;
			f = 0;
		}
		else {
			f = 1;
		}
		ans = min(ans, sum);
		//cout << ans << " ";
	}
	

	cout << ans << endl;
	
	int nn;
	cin >> nn;
	
	return 0;
}

Measured memory_bytes: 2812
def hyoji(l):
    for i in range(len(l)):
        if i != len(l)-1:
            print(l[i], end = ' ')
        else:
            print(l[i])

n = int(input())
A = list(map(int, input().split()))

c = 0
for j in range(len(A)):
    min_n = j
    for k in range(j + 1, len(A)):
        if A[k] < A[min_n]:
            min_n = k
    if min_n != j:
        A[j], A[min_n] = A[min_n], A[j]
        c += 1
hyoji(A)
print(c)


Measured memory_bytes: 5604
import bisect
from bisect import bisect_left

n = int(input()) #n行の入力をリストに入れる
l = []
l = list(map(int, input().split( )))

l.sort()
result =0
for i in range(n-2):
    a =l[i]
    for j in range(i+1,n-1):
        b=l[j]
        k = bisect_left(l,a+b)
        result += k-j-1

print(result)




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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  string s ; 
  cin >> s ; 
  string ans = "keyence" ;
  
  rep(i,7){
    string S = "";
    rep(j,s.size()){
      if(j<=i ||  i + s.size()-7 <j ) S = S + s.at(j) ;
    }
 
    if(S == ans ){
      cout <<"YES" ;
      return 0 ;
    }
  }
  
  cout << "NO" ;
  


}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cassert>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    
    vector<int> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    
    vector<int> c = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    
    struct State {
        int len = -1;
        vector<int> v = vector<int>(10);
        
        bool operator <(const State& rhs) const {
            if (len != rhs.len) {
                return len < rhs.len;
            } else {
                auto w = v;
                auto rhs_w = rhs.v;
                
                reverse(w.begin(), w.end());
                reverse(rhs_w.begin(), rhs_w.end());
                
                return w < rhs_w;
            }
        }
    };
    
    vector<State> dp(n + 1);
    
    dp[0].len = 0;
    
    for (int i = 0; i < n; i++) {
        if (dp[i].len == -1) {
            continue;
        }
        
        for (int j = 0; j < m; j++) {
            if (i + c[a[j]] <= n) {
                State nxt = dp[i];
                nxt.len++;
                nxt.v[a[j]]++;
                
                dp[i + c[a[j]]] = max(dp[i + c[a[j]]], nxt);
            }
        }
    }
    
    for (int i = 9; i >= 1; i--) {
        for (int j = 0; j < dp[n].v[i]; j++) {
            cout << i;   
        }
    }
    cout << endl;
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//アナグラムになっているなら　ソートしたら同じ文字になる
int main() {
  //入力
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s.at(i);

  //処理
  rep(i,n) sort(s.at(i).begin(),s.at(i).end()); //各文字列についてソート
  sort(s.begin(),s.end()); //全ての文字列についてソート

  long long ans = 0; //int型に収まらない場合もある
  long long cnt = 1;
  //連続する同じ文字列を数える
  rep(i,n-1){
    if(s.at(i)==s.at(i+1)){
      cnt++;
    }else{
      ans+=cnt*(cnt-1)/2; //同じ文字列がn個続く　それから2個をとる組み合わせ
      cnt = 1;
    }
  }
  ans+=cnt*(cnt-1)/2;
  cout << ans << endl;
}


Measured memory_bytes: 7296
# -*- coding: utf-8 -*-
n,m = list(map(int,input().split()))
for i in range(n):
    if i == 0:
        a = set(list(map(int,input().split()))[1:])
        continue
    else:
        b = set(list(map(int,input().split()))[1:])
        a = a&b
print(len(a))


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





long long mod = 1000000007;






long long gcd(long long A,long long B) {
  A = abs(A);
  B = abs(B);
  
  if (A > B) {
    swap(A,B);
  }
  if (B % A == 0) {
    return A;
  }
  
  return gcd(A,B%A);
  
}


int main() {
  
  vector<long long> n2(210000);
  n2[0] = 1;
  
  for (int i=1; i<205000; i++) {
    n2[i] = n2[i-1] * 2;
    n2[i] %= mod;
    
  }
  
  
  long long N,FF;
  cin >> N;
  
  vector<long long> A(N),B(N);
  
  long long allzero = 0;
  long long rzero = 0;
  long long lzero = 0;
  long long mi = 0;
  long long pl = 0;
  long long ans = 1;
  
  
  for (int i=0; i<N; i++) {
    cin >> A[i] >> B[i];
    if (A[i] == 0 && B[i] == 0) {
      allzero++;
      continue;
    }
    if (A[i] == 0) {
      lzero++;
      continue;
    }
    if (B[i] == 0) {
      rzero++;
      continue;
    }
    FF = gcd(A[i],B[i]);
    if (A[i] < 0) {
      FF *= -1;
    }
    A[i] /= FF;
    B[i] /= FF;
    if (B[i] < 0) {
      mi++;
    }
    else {
      pl++;
    }
  }
  
  vector<vector<long long>> AB(N,vector<long long>(2,0));
  
  for (int i=0; i<N; i++) {
    AB[i][0] = A[i];
    AB[i][1] = B[i];
    if (AB[i][1] < 0) {
      AB[i][2] = 99;
      swap(AB[i][0],AB[i][1]);
      AB[i][0] *= -1;
    }
  }
  sort(AB.begin(),AB.end());
  
  
  
  vector<vector<long long>> daa(pl+mi,vector<long long>(4));
  long long aaaa = pl+mi;
  long long anow = 0;
  for (int i=0; i<N; i++) {
    if (AB[i][0] == 0 || AB[i][1] == 0) continue;
    if (AB[i][2] == 99) {
      if (anow != 0) {
        if (AB[i][0] == daa[anow-1][0] && AB[i][1] == daa[anow-1][1]) {
          daa[anow-1][3]++;
          aaaa--;
          continue;
        }
      }
          daa[anow][0] = AB[i][0];
          daa[anow][1] = AB[i][1];
          daa[anow][3] = 1;
          anow++;
    }
    else {
      if (anow != 0) {
        if (AB[i][0] == daa[anow-1][0] && AB[i][1] == daa[anow-1][1]) {
          daa[anow-1][2]++;
          aaaa--;
          continue;
        }
      }
          daa[anow][0] = AB[i][0];
          daa[anow][1] = AB[i][1];
          daa[anow][2] = 1;
          anow++;
    }
  }
  
  long long bai;
  

  bai = n2[lzero] + n2[rzero] - 1;
  bai %= mod;
  
  ans *= bai;
  ans %= mod;
  
  
  for (int i=0; i<aaaa; i++) {
    bai = n2[daa[i][2]];
    bai += n2[daa[i][3]];
    bai--;
    bai %= mod;
    
    ans *= bai;
    ans %= mod;
  }
  
  ans += allzero;
  ans %= mod;
  
  ans += mod;
  ans--;
  ans %= mod;
  
  cout << ans << endl;
  
  
}


Measured memory_bytes: 33016
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  int tate=0;
  long long ans=6;
  int i=2;
  if(s[0]==t[0]){
    ans=3;
    i=1;
    tate=1;
    }
  while(i<n){
    if(s[i]==t[i]){
      if(tate==1){ ans=2*ans%1000000007;}
      i++;
      tate=1;
      }
    else{
      if(tate==1){ans=2*ans%1000000007;}
      else {ans=3*ans%1000000007;}
      i+=2;
      tate=0;
      }
  }
  cout <<ans<<endl;
  return 0;
  }



  

Measured memory_bytes: 256
import java.util.Scanner;

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

        int wordNum = text1.length();
        int diffCount=0;

        for(int i=0;i<wordNum;i++){
            if(text1.charAt(i) != text2.charAt(i)){
                diffCount +=1;
            }
        }
        System.out.println(diffCount);
    }
}

Measured memory_bytes: 42372
#include<stdio.h>

int main(){

    int N,M;
    scanf("%d%d", &N, &M);

    int i,j;
    int H[100000+1] = {0};
    int flag[100000+1] = {0};
    int ans=0;
    int A,B;
    for( i = 1; i <= N; i++ ){
        scanf("%d", &H[i]);
    }

    for( i = 1; i <= M; i++ ){
        scanf("%d%d", &A, &B);

        if( H[A] == H[B] ){
            flag[A]++;
            flag[B]++;
        }
        if( H[A] < H[B] ){
            flag[A]++;
        } 
        if( H[A] > H[B] ){
            flag[B]++;
        }

    }
    
    for( i = 1; i <= N; i++ ){
        if( flag[i] == 0 ) ans++;
    }

    printf("%d\n", ans);





    return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll dp[44][1<<17][2];
void modAdd(ll &a, ll b){
	a += b;
	a %= MOD;
}

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

	ll n, x, y, z;cin >> n >> x >> y >> z;
	ll tmp = 0;
	tmp |= (1 << (x - 1));
	tmp |= (1 << (x + y - 1));
	tmp |= (1 << (x + y + z- 1));

	dp[0][0][0] = 1;
	REP(i, n){
		REP(j, (1<<17)){
			REP(k, 2)if(dp[i][j][k]){
				REP(ii, 10){
					ll nxt = ((1LL << 17) - 1) & ((j << (ii + 1)) + (1LL << ii));
					ll pla = k;
					if((nxt & tmp) == tmp)pla = 1;
					modAdd(dp[i+1][nxt][pla], dp[i][j][k]);
				}
			}
		}
	}

	ll ans = 0;
	REP(i, 1<<17)modAdd(ans, dp[n][i][1]);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 84224
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 105;

int n, tot, A[MAXN], B[MAXN];

int main() {
    scanf("%d", &n);

    for (int i = 0; i < n - 1; i++) {
        scanf("%d", &B[i]);
    }

    A[0] = B[0];
    A[n - 1] = B[n - 2];

    for (int i = 1; i < n - 1; i++) {
        A[i] = min(B[i - 1], B[i]);
    }

    for (int i = 0; i < n; i++) {
        tot += A[i];
    }

    printf("%d\n", tot);

    return 0;
}

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

int main()
{
  string s;
  cin >> s;
  int length = s.length();
  deque<char> ans;
  for (int i = 0; i < length; i++)
  {
    if (s[i] == '0')
      ans.push_back(s[i]);
    else if (s[i] == '1')
      ans.push_back(s[i]);
    else
    {
      if (!ans.empty())
        ans.pop_back();
    }
  }
  for (auto it = ans.begin(); it != ans.end(); it++)
    cout << *it ;
  return 0;
}


Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n)cin >> a[i];
  ll res = linf;
  rep(i, (1 << (n-1))){
    ll tmp = 0;
    vector<bool> v = vector<bool>(n, false);
    v[0] = true;
    vector<ll> h = a;
    int count = 0;
    rep(j, n - 1){
      if((i >> j) % 2 == 1){
        v[j+1] = true;
        count++;
      }
    }
    if(count != k - 1)continue;
    ll pmaxi = h[0];
    FOR(j, 1, n){
      if(v[j]){
        ll need = pmaxi + 1;
        int curr = j+1;
        while(curr < n && !v[curr]){
          need = max(need, h[curr]);
          curr++;
        }
        h[j] = max(need, h[j]);
        tmp += h[j] - a[j];
      }
      pmaxi = max(pmaxi, h[j]);
    }
    res = min(tmp, res);
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int S, W;
    cin >> S >> W;
    if (S <= W)
        cout << "unsafe";
    else
        cout << "safe";
    cout << endl;
    return 0;
};


Measured memory_bytes: 3132
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	if a+b > c+d {
		fmt.Println("Left")
	} else if a+b < c+d {
		fmt.Println("Right")
	} else {
		fmt.Println("Balanced")
	}
}

Measured memory_bytes: 512
N=input()
K=int(input())

def rec(N,K):
    if K==0:
        return 1#N以下の数で、0以外の数が０、すなわち残りの桁が全て０になるパターン

    if len(N)<K:
        return 0
    
    lsb=int(N[-1])

    if len(N)==1:
        return lsb
   
    return rec(N[:-1],K-1)*(lsb)+rec(str(int(N[:-1])-1),K-1)*(9-lsb)+rec(N[:-1],K)
    
print(rec(N,K))

Measured memory_bytes: 3064
import itertools
n=int(input())
cnt=list(itertools.permutations(range(n)))
p=list(map(int,input().split()))
q=list(map(int,input().split()))
for i in range(n):
    p[i]-=1
    q[i]-=1
p=tuple(p)
q=tuple(q)
f=0
for i in range(n):
    if p[i]>q[i]:
        f=1
        break
    elif p[i]<q[i]:
        f=2
        break
    else:
        continue
ans=0
c=0
if f==0:
    print(0)
elif f==1:
    for i in range(len(cnt)):
        if cnt[i]==q:
            c=1
            continue
        if c==1 and cnt[i]!=p:
            ans+=1
        elif c==1 and cnt[i]==p:
            print(ans+1)
            break
elif f==2:
    for i in range(len(cnt)):
        if cnt[i]==p:
            c=1
            continue
        if c==1 and cnt[i]!=q:
            ans+=1
        elif c==1 and cnt[i]==q:
            print(ans+1)
            break
#print(cnt)
    

Measured memory_bytes: 8052
import java.util.*;

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

		while(true){
			int n = sc.nextInt();
			if(n == 0) break;

			int ans = 0;
			for(int i=1;i<=n;i++){
				int sum = 0;
				for(int j=i;sum<n;sum+=j++);
				if(sum == n) ans++;
			}

			System.out.println(ans-1);
		}
	}
}

Measured memory_bytes: 12000
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String k = sc.next();
    int ans = 1;
    long nk = Long.parseLong(k);
    if(nk == 1) {
      ans = Integer.parseInt(String.valueOf(s.charAt(0)));
    } else {
      int len = s.length();
      if(nk <= len) {
        int n1 = (int)nk;
        for(int j = n1 - 1; j >= 0; j--) {
          int t = Integer.parseInt(String.valueOf(s.charAt(j)));
          if(t != 1) ans = t;
        }
      } else {
        for(int j = len - 1; j >= 0; j--) {
          int t = Integer.parseInt(String.valueOf(s.charAt(j)));
          if(t != 1) ans = t;
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23892
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,n,s) for(int i=s;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

int main(){
  ll n,i;
  cin >> n;
  map<string,int> mp;

  ll ans = 0;
  for(i=0;i<n;i++){
    string s;
    cin >> s;
    sort(s.begin(),s.end());

    if(mp[s] > 0) {
      ans += mp[s];
    }
    mp[s]++;
  }

  cout << ans << endl; 
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define re register ll
#define F(x,y,z) for(re x=y;x<=z;x++)
#define FOR(x,y,z) for(re x=y;x>=z;x--)
typedef long long ll;
#define I inline void
#define IN inline ll
#define C(x,y) memset(x,y,sizeof(x))
#define STS system("pause")
I read(ll &res){
	res=0;re g=1;register char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')g=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		res=(res<<3)+(res<<1)+(ch^48);
		ch=getchar();
	}
	res*=g;
}
const ll INF=1e18+9;
ll s[101010];
ll n,m,v,p,a[101000],goal,pos,cnt,num,ans;
int main(){
	read(n);read(m);read(v);read(p);s[0]=0;
	F(i,1,n)read(a[i]);
	sort(a+1,a+1+n);a[n+1]=INF;
	F(i,1,n)s[i]=s[i-1]+a[i];
	F(i,1,n){
		//cout<<endl;
		goal=a[i]+m;pos=upper_bound(a+1,a+1+n+1,goal)-a-1;
		//cout<<pos<<" ";
		if(n-pos>=p)continue;
		num=min(n-p+1,pos);
		cnt=(v-i+1-n+num)*m-goal*(num-i+1)+s[num]-s[i-1];
		//cout<<cnt;
		if(cnt>0)continue;
		ans=n-i+1;break;
		//cout<<goal<<" "<<pos<<endl;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    List<List<int[]>> graph = new ArrayList<>();
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());
    int a,b;
    for(int i=0;i<n;i++)graph.add(new LinkedList<>());
    
    for(int i=0;i<m;i++){
      a = Integer.parseInt(sc.next())-1;
      b = Integer.parseInt(sc.next())-1;
      graph.get(a).add(new int[]{b,i});
      graph.get(b).add(new int[]{a,i});
    }
    boolean[] isVisited = new boolean[n];
    Queue<Integer> queue = new ArrayDeque<>();
    int res = 0;
    for(int i=0;i<m;i++){
      Arrays.fill(isVisited,false);
      queue.add(0);
      isVisited[0] = true;
      while(queue.size()> 0){
        
        int to = queue.poll();
        
        for(int[] nxt: graph.get(to)){
          if(nxt[1]==i || isVisited[nxt[0]])continue;
          isVisited[nxt[0]] = true;
          queue.add(nxt[0]);
        }
      }
      for(int j=0;j<n;j++){
        if(!isVisited[j]){
          res++;
          break;
        }
      }
    }
    System.out.println(res);
                       
  }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define ll              long long 
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define Mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define sort(x)         sort(all(x))
#define umii            unordered_map<int,int>
#define lli             list<int>             
#define gcd(m,n)        __gcd(m,n)   
#define mib             map<int,bool>

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define deb(...)
#endif

void fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
}
 
//////////////////////////////code//////////////////////////////
ll power(ll x, ll y, ll p=Mod) 
{ 
    ll res = 1;    
  
    x = x % p; 
  
    while (y > 0) 
    { 
        
        if (y & 1) 
            res = (res*x) % p; 
  
     
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
int32_t main()
{
  fast();
  
  int n,k;
  cin>>n>>k;
  
  int dp[k+1];
  
  for(int i=k;i>=1;i--)
  {
  	 int ans = (power(k/i,n));
  	 
  	 ans%=Mod;
  	 
  	 for(int j=2*i;j<=k;j+=i)
  	  ans = (ans%Mod - dp[j]%Mod + Mod)%Mod;
  	  
  	  dp[i]=ans;
  	 // deb(i,ans);
  }
  
  int sum=0;
  
  for(int i=1;i<=k;i++)
  {
   dp[i]=(i%Mod * dp[i]%Mod)%Mod;
   sum = (sum%Mod + dp[i]%Mod)%Mod;
  }
   
  cout<<sum;

}

Measured memory_bytes: 4380
import Data.Maybe
import Data.List

main = do
 a1 <- map (read::String->Int) . words<$> getLine 
 a2 <- map (read::String->Int) . words<$> getLine 
 a3 <- map (read::String->Int) . words<$> getLine 
 _ <- (read::String->Int) <$> getLine
 bb <- map (read::String->Int) . lines <$>getContents
 let aa = concat[a1,a2,a3]
 let indexies = map (1+) .catMaybes $ map (f aa) bb
 --print indexies
 if g indexies then putStr "Yes" else putStr "No"


f :: [Int] -> Int  -> Maybe Int
f aa x = findIndex (x==) aa

g :: [Int] -> Bool
--g indexies = all $ map (-1>) [1,2,3] 
g indexies = or [and $ map (elem_ indexies) [1,2,3] , 
	  and $map (elem_ indexies) [4,5,6] ,
      and $map (elem_ indexies) [7,8,9] ,
      and $map (elem_ indexies) [1,5,9] ,
      and $map (elem_ indexies) [3,5,7] ,
      and $map (elem_ indexies) [1,4,7] ,
      and $map (elem_ indexies) [2,5,8] ,
      and $map (elem_ indexies) [3,6,9] ]
      
elem_ :: [Int] -> Int -> Bool
elem_ x y = elem y x

Measured memory_bytes: 508
(defun split (lst count)
    (values (subseq lst 0 count) (nthcdr count lst)))

(defmacro lst-sum (lst)
    `(reduce #'+ ,lst))

(defun calc-abs (f-lst b-lst)
    (abs (- (lst-sum f-lst) (lst-sum b-lst))))

(defun solve (n lst)
    (let ((min-number 10000))
        (dotimes (i n)
            (multiple-value-bind (f-lst b-lst) (split lst i)
                (cond ((< (calc-abs f-lst b-lst) min-number)
                          (setq min-number (calc-abs f-lst b-lst))))))
        (print min-number)))

(let ((n (read))
         (lst '()))
    (dotimes (i n)
        (push (read) lst))
    (solve n lst))


Measured memory_bytes: 15332
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
#define yn(x) puts((x ? "Yes" : "No"))
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  ;
  cin >> N >> M;
  va.resize(N);
  rep(i, 0, N - 1) { cin >> va[i]; }
}
void solve() {
  int sm = 0;
  for (auto x : va) {
    sm += x;
  }
  int ok = 0;
  int b = sm / (4 * M);
  if (sm % (4 * M) == 0) {
    b--;
  }

  for (auto x : va) {
    if (x > b) {
      ok++;
    }
  }
  cout << (ok >= M ? "Yes" : "No") << endl;
  ;
  ;
}
signed main() {
  cout << setprecision(12);
  input();
  solve();
  return 0;
}


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

using namespace std;

int main() {
  int n;
  long long a, b;
  cin >> n >> a >> b;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  auto f = [&](long long K) {
    long long x = 0;
    for (long long e : h) {
      x += max(0LL, (e - b * K + a - b - 1) / (a - b));
    }
    return x <= K;
  };
  long long ok = 1000000000;
  long long ng = 0;
  while (abs(ok - ng) > 1) {
    long long mid = (ok + ng) / 2;
    if (f(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  cout << ok << endl;
  return 0;
}


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

void output(int a, int b){
        cout << a << " " << b << "\n";
}
int main(int argc, char *argv[]){
        int a,b;
        while(1){
                cin >> a >> b;
                if (a == 0 && b == 0) break;
                if (a < b) {
                        output(a,b);
                } else {
                        output(b,a);
                }
        }
}

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

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

	for(int i = n - 1;i >= 0 ;i--)
	{
		if(a[i-1] > a[i]) a[i-1]--;
		if(a[i-1] > a[i])
		{
			f = 1;
			break;
		}
	}
	if(f == 0)
		cout << "Yes" <<endl;
	if(f == 1) 
		cout << "No" << endl;
}

Measured memory_bytes: 640
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

a,b = I()
if b >= a:
    print(a)
else:
    print(a-1)

Measured memory_bytes: 10028
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
int main(){
    int a,b,k;
    cin>>a>>b>>k;
    int i=min(a,b),cnt=0,ans;
    while(cnt!=k){
        if(a%i==0&&b%i==0){
            ans=i;
            ++cnt;
        }
        --i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
//https://atcoder.jp/contests/dp/tasks/dp_s
//shauryakr
#include<bits/stdc++.h>
using namespace std;
string k;
int d, n;
const long long int mod = 1e9+7;
long long int dp[10010][105][2];
long long int solve(int ind, int rem, int constraint)
{
    if(ind == n)
    {
        if(rem == 0)
            return 1;
        return 0;
    }

    if(dp[ind][rem][constraint] != -1)
        return dp[ind][rem][constraint];

    long long int ans = 0;
    if(constraint)
    {
        for(int i=0; i<=(k[ind]-'0'); i++)
        {
            ans += solve(ind+1, (rem + i)%d, (i==(k[ind]-'0'))?1:0);
            if(ans >= mod)
                ans -= mod;
        }
    }
    else
    {
        for(int i=0; i<=9; i++)
        {
            ans += solve(ind+1, (rem+i)%d, 0);
            if(ans >= mod)
                ans -= mod;
        }
    }

    dp[ind][rem][constraint] = ans;
    return ans;
}

int main()
{
    cin >> k>> d;
    n = k.length();
    memset(dp, -1, sizeof dp);
    cout << (solve(0, 0, 1) + mod - 1)%mod << endl;
}

Measured memory_bytes: 17536
f :: Int->[Char]->Int
f m s | s /= "" && m < read(s) = 0
f m s = ret + sum(map (f m) as) where 
    ret = if and $ map (\a->elem a s) "357" then 1 else 0
    as = map (:s) "357"
main :: IO ()
main = do
    n <- getLine
    putStrLn $ show (f (read n) "")



Measured memory_bytes: 1020
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int i;
	int t[10];
	for(i=0;i<10;i++) scanf("%d", t+i);

	sort(t, t+10);
	printf("%d\n%d\n%d\n", t[9], t[8], t[7]);
}

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

int N, cnt;

void dfs(ll n, bool three, bool five, bool seven) {
	if (n > N) return ;
	if (three && five && seven) cnt++;

	dfs(10 * n + 3, true, five, seven);
	dfs(10 * n + 5, three, true, seven);
	dfs(10 * n + 7, three, five, true);
}

int main() {
	cin.tie(0)->sync_with_stdio(false);

	cin >> N;
	dfs(0, false, false, false);
	cout << cnt << '\n';
	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    while(b<=a)
    {
        b*=2;
        k--;
    }
    while(c<=b)
    {
        c*=2;
        k--;
    }
    if(k<0)cout<<"No";
    else cout<<"Yes";
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int n;
  cin >> n;
  vll a(n);
  rep(i,n) cin >> a.at(i);
  vi b(n);
  rep(i,n) {
    if(a[i]%2==1) b[i] = 0;
    else {
      a[i] /= 2;
      if(a[i]%2==1) b[i] = 1;
      else b[i] = 2;
    }
  }
  int cnt0 = 0;
  int cnt2 = 0;
  rep(i,n) {
    if(b[i]==0) cnt0++;
    if(b[i]==2) cnt2++;
  }
  if(cnt0<=cnt2) cout << "Yes" << endl;
  else if(cnt0==cnt2+1 && cnt0+cnt2==n) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 1408
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 210000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int main(){
	init_C(2100000);
	int a,b;scanf("%d%d",&a,&b);
	int t=a+b;
	if(t%3){
		printf("0\n");return 0;
	}
	a-=t/3;
	b-=t/3;
	long long ret=Comb(a+b,a);
	printf("%lld\n",ret);
}

Measured memory_bytes: 55424
N,M = (int(i) for i in input().split()) 
edge = []
for _ in range(N):
    edge.append([False] * N) 
for _ in range(M):
    a,b =  (int(i) - 1 for i in input().split())  
    edge[a][b] =True
    edge[b][a] = True


COUNT = 0
def func(choose,choosen,count):
    new_count = count
    if len(choose) == 0:
        can_move =True
        for i in range(len(choosen) - 1):
            can_move = can_move and edge[choosen[i]][choosen[i+1]]
        if can_move:
            #print('sex')
            return count + 1
        return count
    for i in range(len(choose)):
        new_choosen = choosen + [choose[i]]
        new_count = func(choose[:i] + choose[i + 1:],new_choosen,new_count)
    return new_count

a = func([i for i in range(1,N)],[0],0)
print(a)


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


#define ll long long int
#define ld long double
#define mod 998244353
#define big 1e18+10
#define small -big
#define pb push_back
#define endl "\n"


template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}

map<ll, ll> mp;

ll bin(ll a) {
    
    if(a == 0) return 0;
    
    ll low = 1;
    ll high = 100;
    ll ans = 1;
    
    while(low <= high) {
        ll mid = (low + high) / 2;
        
        if(mid * (mid + 1) / 2 <= a) {
            ans = mid;
            low = mid + 1;
        }
        else {
            high = mid - 1;
        }
    }
    
    return ans;
}

void solve() {
    
    
   ll n;
   cin >> n;
   
   for(ll i = 2; (i * i) <= n; i++) {
       if(n % i == 0) {
           while(n % i == 0) {
               mp[i]++;
               n /= i;
           }
       }
   }
   
   if(n > 1) mp[n]++;
   
   ll ans = 0;
   
   for(auto it : mp) {
       ll freq = it.second;
       
       //trace(freq, bin(freq));
       ans += bin(freq);
   }
   
  cout << ans << endl;
}



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

    int t=1;
   // cin >> t;

    while(t--){  
   
         solve();
    }


    return 0;
        
}


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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  for (int i=A; i<=B; i++) {
    if (i < A+K || i > B-K) {
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*

fun main(args: Array<String>) = IO().exec {
    val n = int()
    val p = Array(n){Pair(int()-1, it)}
    val q = IntArray(n)
    for (i in q.indices) q[p[i].first] = p[i].second
    var ret = 0
    var cnt = 1
    for (i in 0 until n-1) if (q[i+1] > q[i]) cnt++ else {
        ret = Math.max(ret, cnt)
        cnt = 1
    }
    ret = Math.max(ret, cnt)
    println(n - ret)
}

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = PrintWriter(System.out)
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = System.`in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun string(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun long(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun double(): Double {
        return string().toDouble()
    }
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}

Measured memory_bytes: 54644
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef long double ld;
typedef string st;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const ll N=200005;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 
  ll n,w,h;
  cin>>n>>w>>h;
  ll ans=0;
  for(ll i=0;i<n;i++)
  {
    for(ll j=0;j<n;j++)
    {
      ll x1=i+w-1;
      ll y1=j+h-1;
      if(x1>=0&&x1<n&&y1>=0&&y1<n) ans++;
    }
  }
  cout<<ans;
} 
// Never give up, and be confident in what you do. There may be tough times, but the difficulties which you face will make you more determined to achieve your objectives and to win against all the odds
// O Krishna, the mind is restless

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <math.h>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    if(n==1){
        cout << "Hello World"<< endl;
        return 0;
    }else if(n==2){
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
        return 0;
    }
}

Measured memory_bytes: 256