akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

struct shop {
    ll a, b;
    shop(ll a, ll b) : a(a), b(b) {}
    inline bool operator<(const shop &r) const {
        return a * (r.b + 1) > r.a * (b + 1);
    }
    ll time(const ll &t) { return (t + 1) * (a + 1) + b; }
};

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

    ll N, T;
    cin >> N >> T;

    vector<shop> shops1;
    vector<ll> shops0;
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        if(a == 0)
            shops0.push_back(b + 1);
        else
            shops1.push_back(shop(a, b));
    }

    sort(ALL(shops1));
    sort(ALL(shops0));

    rep(i, shops0.size() - 1) shops0[i + 1] += shops0[i];
    vector<ll> dp(30, inf);
    dp[0] = 0;
    for(auto sp : shops1) {
        for(int i = 30 - 1; i >= 0; i--) {
            if(dp[i] > T) continue;
            chmin(dp[i + 1], sp.time(dp[i]));
        }
    }
    ll ans = 0;
    rep(i, 30) {
        if(dp[i] > T) break;
        chmax<ll>(ans,
                  i + upper_bound(ALL(shops0), T - dp[i]) - shops0.begin());
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6512
try:
    xrange
except NameError:
    pass
else:
    range = xrange

def main():
    N = int(raw_input())
    for _ in range(N):
        line = raw_input().replace('-', '')
        size = len(line)
        res = line[0]
        i, p = 1, 0
        while i < size:
            if line[i] == '>':
                if p == len(res) - 1:
                    res = res + line[i + 1]
                p += 1
            elif line[i] == '<':
                if p == 0:
                    res = line[i + 1] + res
                else:
                    p -= 1
            i += 2
        print res
                    

if __name__ == '__main__':
    main()

Measured memory_bytes: 4248
coin = []
3.times do
  coin << gets.chomp.to_i
end

total = gets.chomp.to_i

count = 0
(0..coin[0]).each do |i|
  a = total - 500 * i
  break if a < 0
  (0..coin[1]).each do |j|
    b = a - 100 * j
    break if b < 0
    if b <= coin[2] * 50
      count += 1
    end
  end
end

puts count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ASC(v) sort(v.begin(), v.end());
#define DESC(v) sort(v.begin(), v.end(), greater<int>());
#define REVERSE(v) reverse(v.begin(), v.end());
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main() {
	ll A, B;
	cin >> A >> B;
	FOR(i, 1, 2000) {
		if (floor(i*0.08)==A && floor(i*0.1)==B) {
			cout << i << "\n";
			return 0;
		}
	}
	cout << -1 << "\n";
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int p=1;
	int A=0,B=0,C=0;
	char pai[3][10005],now='a';
    cin >> pai[0] >> pai[1] >> pai[2];
    while(p)
    {
    	switch(now)
		{
			case 'a':
				if(A==strlen(pai[0]))
				{
					cout << 'A';
					p=0;
					break;
				}
				else
				{
					now=pai[0][A];
					A++;
					break;
				}
			case 'b':
				if(B==strlen(pai[1]))
				{
					cout << 'B';
					p=0;
					break;
				}
				else
				{
					now=pai[1][B];
					B++;
					break;
				}
			case 'c':
				if(C==strlen(pai[2]))
				{
					cout << 'C';
					p=0;
					break;
				}
				else
				{
					now=pai[2][C];
					C++;
					break;
				}
		} 
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int a, b, c, d, e, f, g, h, i;
    d = 0;
    scanf("%d%d", &a, &b);
    c = b - a;
    while(c > 0){
        d = d + c;
        c = c - 1;
    }
    e = d - b;
    printf("%d", e);
}



Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string s;
int cnt[4];

bool check(int v){
	if(cnt[v*2]==0 && cnt[v*2+1]==0)return true;
	if(cnt[v*2]>0 && cnt[v*2+1]>0)return true;
	return false;
}


int main(void){
	cin >> s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='N')cnt[0]++;
		if(s[i]=='S')cnt[1]++;
		if(s[i]=='W')cnt[2]++;
		if(s[i]=='E')cnt[3]++;
	}
	if(check(0) && check(1))printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;
#define pai 3.141592653589793238462643383279




int main(){
  int x[5];
  rep(i, 5){
    cin >> x[i];
    if(x[i]==0){
      cout << i+1 << endl; break;
    }
  }
  
}

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

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

    if(a==1 && b==1)
        cout<<"Draw";
    else if(a == 1)
        cout<<"Alice";
    else if(b == 1)
        cout<<"Bob";
    else if(a>b)
        cout<<"Alice";
    else if(b>a)
        cout<<"Bob";
    else if(a == b)
        cout<<"Draw";

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORB(i,a,b) for(int i=a;i>=b;i--)
#define INT_MAXI 2147483647
#define INT_MINI -2147483648
#define REV(a) reverse(a.begin(),a.end())
#define NP(a) next_permutation(a.begin(),a.end())
 
typedef pair<int,int> pi;
typedef pair<ll,ll> pl; 
 
const int mod = 1e9 + 7;
 
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //cout<<"input"<<endl;freopen("input.txt","r",stdin);
    //cout<<"output"<<endl;freopen("output.txt","w",stdout);
    
    int n;
    int dt[2005];
    for(int i=0;i<=2000;i++)    dt[i] = 0;
 
    dt[0] = 1;
    dt[1] = dt[2] = 0;
    dt[3] = 1;
    cin >> n;
    for(int i = 4; i <= n; i++) {
        for(int j = 3; j <= i; j++) {
            dt[i] = (dt[i] + dt[i - j]) % mod;
        }
    }
    cout << dt[n] << endl;
    return 0;
    
    
    
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
    int a;
    string s;
    cin >> a;
    cin >> s;
    if (a >= 3200) {
        cout << s << "\n";
    } else {
        cout << "red" << "\n";
    }
}


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

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

int main()
{
    int K = 0;
    int temp = 0;
    cin >> K;

    long long r = 0;
    for (int a = 1; a < K + 1; a++)
    {
        for (int b = 1; b < K + 1; b++)
        {
            temp = gcd(a, b);
            for (int c = 1; c < K + 1; c++)
            {
                r += gcd(temp, c);
            }
        }
    }

    cout << r << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

template <class T>
void chmax(T &a, T b) {
    if (b > a) a = b;
}

constexpr int W = (int)1e+5;

int dp[1 << 8][W + 1];//それ以下の重さで実現できる最大価値

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

    int n;
    cin >> n;

    vector<int> v(n + 1), w(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> v[i] >> w[i];
    }

    if (n >= 1 << 9) {
        for (int k = 0; k < 1 << 8; k++) {
            int i = 1;
            for (int h = 0; h < 9; h++) {
                for (int j = W; j >= w[i]; j--) {
                    chmax(dp[k][j], dp[k][j - w[i]] + v[i]);
                }
                i *= 2;
                i += (k >> (7 - h) & 1);
            }
        }
    }

    int q;
    cin >> q;

    while (q--) {
        int i0, L;
        cin >> i0 >> L;

        int i = i0;
        int h0 = 0;
        int l = 0;

        if (i < 1 << 9) {
            for (int h = 1;; h++) {
                i /= 2;
                if (i == 0) {
                    h0 = h;
                    l = -1;
                    break;
                }
            }
        } else {
            for (int h = 1;; h++) {
                i /= 2;
                if (i < 1 << 9) {
                    h0 = h;
                    l = i - (1 << 8);
                    break;
                }
            }
        }

        int r = 0;
        if (i0 < 1 << 9) {
            for (int k = 0; k < 1 << h0; k++) {
                int i = i0, v1 = 0, w1 = 0;
                for (int h = 0; h < h0; h++) {
                    if (k >> h & 1) {
                        v1 += v[i];
                        w1 += w[i];
                    }
                    i /= 2;
                }
                if (w1 > L) continue;
                chmax(r, v1);
            }
        } else {
            for (int k = 0; k < 1 << h0; k++) {
                int i = i0, v1 = 0, w1 = 0;
                for (int h = 0; h < h0; h++) {
                    if (k >> h & 1) {
                        v1 += v[i];
                        w1 += w[i];
                    }
                    i /= 2;
                }
                if (w1 > L) continue;
                chmax(r, dp[l][L - w1] + v1);
            }
        }

        cout << r << '\n';
    }

    return 0;
}

Measured memory_bytes: 105092
S = list(input())
N = len(S)
pre = "R"
ans = {}
cntr = 1
cntl = 0
z = 0
anskey = []
res = [0]*N
for i in range(1,N):
  if S[i] == "R" and "L" not in pre:
    pre = pre + S[i]
    cntr += 1
  elif S[i] == "L":
    pre = pre + S[i]
    cntl += 1
  elif S[i] == "R" and "L" in pre:
    anskey.append(pre)
    ans[pre] = (cntr,cntl)
    pre = "R"
    cntr = 1
    cntl = 0
anskey.append(pre)
ans[pre] = (cntr,cntl)
for key in anskey:
  (x,y) = ans[key]
  if (x+y)%2 == 0:
    res[z+x-1] = (x+y)//2
    res[z+x] = x+y -res[z+x-1]
  else:
    if x%2 == 0:
      res[z+x-1] = x//2 + y//2
      res[z+x] = x+y-res[z+x-1]
    else:
      res[z+x-1] = (x+1)//2 + y//2
      res[z+x] = x+y - res[z+x-1]
  z = z+x+y
restr = (str(x) for x in res)
print(" ".join(restr))

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

using namespace std;

int main()
{

    int n;
    cin>>n;

    vector<int>V;
    int i,s,x;

    for(i=0;i!=n-1;i++)
    {
        cin>>x;
        V.push_back(x);
    }

    s = V[n-2];

    for(i=n-3;i>=0;i--)
        s += min(V[i],V[i+1]);

    s += V[0];

    cout<<s;

    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define rep2(i,x,n) for(int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vvl = vector<vl>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k; 
ll INF = 10000000000000000;



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

Measured memory_bytes: 3632
N,A,B,C=map(int,input().split())
l=[int(input()) for _ in range(N)]
dist=[A,B,C]
ans=float("inf")
for i in range(pow(4,N)):
    bit=[0]*N
    num=i
    x=[[],[],[]]
    cnt=0
    for j in range(N-1,-1,-1):
        bit[j]=num//pow(4,j)
        num=num%pow(4,j)
    #print(bit.count(1),bit.count(2),bit.count(3))
    if (bit.count(1)>0)and(bit.count(2)>0)and(bit.count(3)>0):
        #print(bit)
        for j in range(N):
            if bit[j]>0:
                x[bit[j]-1].append(l[j])
        for j in range(3):
            cnt=cnt+(len(x[j])-1)*10
            num=sum(x[j])
            cnt=cnt+abs(num-dist[j])
        ans=min(cnt,ans)
print(ans)


Measured memory_bytes: 74184
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define yokuwaruprime (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int64 goal,ans;
  cin>>goal;
  if(goal%11!=0){
  if(1<=goal%11 && goal%11<=6){
    ans=2*(goal-(goal%11))/11+1;
  }else{
    ans=2*(goal-(goal%11))/11+2;
  }
  }else{
    ans=goal*2/11;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String R;
    if(N>=30){
      R = "Yes";
    }else{
      R = "No";
    }
    System.out.println(R);                     
  }
}

Measured memory_bytes: 35720
//code by PARTH_4399 for competitive programming
#include<bits/stdc++.h>
using namespace std;
#define l long // -2^31 to +2^31-1 (upper limit ~ 2*(10^9))
#define ul unsigned long // 0 to +2^32-1
#define ll long long // -2^63 to +2^63-1 (upper limit ~ 9*(10^18))
#define ull unsigned long long // 0 to +2^64-1
#define mod(x, m) ((((x)%(m))+(m))%(m))
#define vi vector<int>
#define pi pair<int,int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
//const double pi=acos(-1.0); // cout<<fixed<<setprecision(n)<<pi; - for n decimal digits, use <iomanip.h>
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//code
	string s;
	ll int n=0,count=0,i;
	cin>>s;
	//cout<<int(s[s.length()-1]-48);
	if(s.length()%2==1)
	{
		count += (int(s[s.length()-1]-48));
	}
	s[s.length()-1]='0';
	for(i=0;i<s.length();i++)
	{
		n = n*10 + (int(s[i])-48);
	}
	if(n<100)
	{
		if(n<10)
		count += n;
		else
		count += 9;
	}
	else if(n<10000)
	{
		if(n<1000)
		count += (9 + n - 99);
		else
		count += (9 + 900);
	}
	else if(n<1000000)
	{
		if(n<100000)
		count += (9 + 900 + n - 9999);
		else
		count += (9 + 900 + 90000);
	}
	cout<<count;
	return 0;
}

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

int compare_large_number(std::string number,std::string other);

int main(int argc, char const *argv[]) {

    std::string A,B;
    std::cin >> A >> B;


    int compare_result = compare_large_number(A,B);
    if(compare_result > 0)
        std::cout << "GREATER" << '\n';
    else if(compare_result < 0)
        std::cout << "LESS" << '\n';
    else
        std::cout << "EQUAL" << '\n';


    return 0;
}

int compare_large_number(std::string number,std::string other)
{
    if(number.length() > other.length())
        return 1;
    if(number.length() < other.length())
        return -1;

    for(int word_index = 0 ; word_index < number.length() ; word_index ++ )
    {
        if(number[word_index] > other[word_index])
            return 1;
        if(number[word_index] < other[word_index])
            return -1;
    }

    return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val Array(s, t) = io.StdIn.readLine().split(' ')
  val Array(a,b) = io.StdIn.readLine().split(' ').map(_.toInt)
  val u = io.StdIn.readLine()

  val ans = if (u == s) s"${a-1} $b" else s"$a ${b-1}"
  println(ans)
}

Measured memory_bytes: 25528
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
#define mk make_pair
using namespace std;
#define int long long
int n,a,b,t[1000000];
bool ch(int x){
  int u=0;
  r(i,n)if(t[i]-x*b>0){
    int tt=t[i]-b*x;
    u+=tt/(a-b);
    if((tt)%(a-b))u++;
  }
  if(u<=x)return 1;
  else return 0;
}
main(){
  cin>>n>>a>>b;
  int l=0,rr=1000000000;
  r(i,n)cin>>t[i];
  while(l<rr){
    int mid=(rr+l)/2;
    if(ch(mid))rr=mid;
    else l=mid+1;
  }
  cout<<rr<<endl;
}

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

int main(){
	long long x,k,d;
	cin>>x>>k>>d;
	if(x<0)x=-x;
	long long s=x/d;
	if(s>k)printf("%lld\n",x-k*d);
	else {
		if((k-s)%2==0)printf("%lld\n",x-s*d);
		else printf("%lld\n",-(x-s*d-d));
	}
}

Measured memory_bytes: 3744
S = input()

n = len(S)
m = 2019

S_ = S[::-1]

x = 1
total = 0
modlis = [0 for i in range(m)]

ans = 0
for i in range(n):
    modlis[total] += 1
    #print("S_[i]:", S_[i])
    #print("int(S_[i])*x:", int(S_[i])*x)
    #print("total:", total)
    total += int(S_[i])*x
    #print("total:", total)
    total %= m
    #print("total:", total)
    ans += modlis[total]
    #print("x:", x)
    x = x * 10 % m
    #print("x:", x)

print(ans)

Measured memory_bytes: 9372
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a, b, c = LI()
for i in range(a, a*b+1, a):
    if i % b == c:
        print('YES')
        break
else:
    print('NO')

Measured memory_bytes: 65400
#include <stdio.h>

int main(void) {
  int i, j, k = 0, t;
  int N, A[100], minj; 

  scanf("%d", &N);

  for (i = 0 ; i < N ; i++) 
    scanf ("%d", &A[i]);

  for (i = 0 ; i < N-1 ; i++) {
    minj = i;
    for (j = i ; j < N ; j++) {
      if (A[j] < A[minj])
        minj = j;
    }
    t = A[i];
    A[i] = A[minj];
    A[minj] = t;
    if (i != minj)
      k++;
  }

  for (i = 0 ; i < N ; i++){
    if (i > 0)
      printf(" "); 
    printf ("%d", A[i]);
  }
  putchar ('\n');
  printf ("%d\n", k);

  return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <functional>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n, m;
	while (cin >> n >> m, n){
		vector<pair<int, int> > dp;
		for (int i = 0; i < n; i++){
			int d, p;
			cin >> d >> p;
			dp.push_back(make_pair(p, d));
		}
		sort(dp.begin(), dp.end(), greater<pair<int, int> >());
		int ret = 0;
		for (int unsigned i = 0; i < dp.size(); i++){
			for (int j = 0; j < dp[i].second; j++){
				if (m >0){
					m--;
				}
				else {
					ret += dp[i].first;
				}
			}
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 1328
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] arr = new int[m][2];
        for (int i=0; i<m; i++) {
            arr[i][0] = sc.nextInt() - 1;
            arr[i][1] = sc.nextInt() - 1;
        }

        UnionFind uf = new UnionFind(n);
        for (int i=0; i<m; i++) {
            uf.unite1(arr[i][0], arr[i][1]);
        }

        Set<Integer> set = new HashSet<>();
        for (int i=0; i<n; i++) {
//            System.out.println(uf.parent[i]);
            set.add(uf.find(i));
        }

//        System.out.println(set);
        System.out.println(set.size() - 1);

    }

    class UnionFind {

        int[] parent, rank, size;

        void init(int n) {
            parent = new int[n];
            rank = new int[n];
            for (int i=0; i<n; i++) {
                parent[i] = i;
                rank[i] = 0;
            }
        }

        UnionFind(int n) {
            parent = new int[n];
            size = new int[n];
            for (int i=0; i<n; i++) {
                parent[i] = i;
                size[i] = 1;
            }
        }

        public int find(int x) {
            if (x==parent[x]) return x;
            return parent[x] = find(parent[x]);
        }

        //    結合して木のサイズを更新
        public void unite1(int x, int y) {
            if (!same(x, y)) {
                parent[find(x)] = find(y);
            }
        }

        //    結合して木の深さを更新
        public void unite2(int x, int y) {
            x = find(x);
            y = find(y);
            if (x==y) return;
            if (rank[x] < rank[y]) {
                parent[x] = y;
            } else {
                parent[y] = x;
                if (rank[x]==rank[y]) rank[x]++;
            }
        }

        public boolean same(int x, int y) {
            return find(x) == find(y);
        }

        public int size(int x) {
            return size[find(x)];
        }


    }


}



Measured memory_bytes: 62280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int a,b,c,d;
int main()
{
	cin>>a>>b>>c>>d;
	if(a>=d) re(d)
	if(a+b>=d) re(a)
	re(a-(d-(a+b)))
	return 0;}

Measured memory_bytes: 3636
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String nl = System.getProperty("line.separator");
		StringBuilder p = new StringBuilder(3000);
		StringBuilder d = new StringBuilder("....");
		StringBuilder s = new StringBuilder("####");
		Scanner r = new Scanner(System.in);
		int h, w, i, j, ww;
		String t;
		for (i = 0; i < 6; ++i) {
			d.append(d);
			s.append(s);
		}
		ww = d.length();
		while ((h = r.nextInt()) + (w = r.nextInt()) > 0) {
			while (w > ww) {
				d.append(d);
				s.append(s);
				ww += ww;
			}
			p.append(s.substring(0,w));
			p.append(nl);
			t = d.substring(0, w - 2);
			for (i = 2; i < h; ++i) {
				p.append('#');
				p.append(t);
				p.append('#');
				p.append(nl);
			}
			p.append(s.substring(0,w));
			p.append(nl);
			p.append(nl);
		}
		System.out.print(p);
	}
}

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

int main() {
  int N;
  cin >> N;
  
  int dig = 0;
  int NN = N;
  for (int i = 0; i < 11; i++) {
    dig += (NN % 10);
    NN /= 10;
  }
  
  if (N % dig == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";


int main() {
    ll D;
    cin>>N>>D;
    mat X(N,vec(D,0));
    rep(i,N){
        rep(j,D) cin>>X[i][j];
    }
    vec d2(170,0);//1-indexed;
    rep(i,170){
        d2[i] = i*i;
    }
    ll ans = 0;
    rep(i,N){
        rep(j,i){//j<i
            ll dist = 0;
            rep(k,D) dist += abs(X[i][k]-X[j][k])*abs(X[i][k]-X[j][k]);
            rep(k,170){
                if(dist == d2[k]) ++ans;
                if(dist < d2[k]) break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int arr[200005];
int main()
{
   int n,i,t,k;
   int so=0;
   scanf("%d%d",&n,&k);
   for(i=0;i<n;i++)
   {
        scanf("%d",&t);
        arr[t-1]++;
   }
   sort(arr,arr+n);
 for(i=0;i<n;i++)
   {
        if(arr[i]!=0)break;
        so++;
   }
   t=n-so-k;
   int sum=0;
   for(int j=0;j<t;j++)
   {
       sum+=arr[i++];
   }
   printf("%d\n",sum);
   return 0;
}


Measured memory_bytes: 896
A=list(input().split())
Max=101
numstack=[0]*Max
top=0
def pop():
  if isEmpty():
    print('error')
  global top
  global numstack
  top-=1
  return numstack[top+1]

def push(x):
  if isFull():
    print('error')
  global top
  top+=1
  global numstack
  numstack[top]=x

def isEmpty():
  return top==0

def isFull():
  return top==Max-1

for i in range(len(A)):
  if A[i]=='+':
    push(pop()+pop())
  elif A[i]=='-':
    push(-pop()+pop())
  elif A[i]=='*':
    push(pop()*pop())
  else:
    push(int(A[i]))
print(numstack[1])


Measured memory_bytes: 5604
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    string s, t; cin >> s >> t;

    vector<vi> dp(s.size()+1, vi(t.size()+1, 0));
    string ans = "";

    rep (i, s.size()) {
        rep (j, t.size()) {

            if (s[i] == t[j]) dp[i+1][j+1] = dp[i][j] + 1;
            else dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
        }
    }

    int i = s.size(), j = t.size();
    while (i > 0 && j > 0) {

        if (dp[i][j] == dp[i-1][j]) i--;
        else if (dp[i][j] == dp[i][j-1]) j--;
        else {
            i--; j--;
            ans = s[i] + ans;
        }
    }

    cout << ans << endl;

    return 0;
}

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

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

 	for(int i = 0; i < s.size(); i++) {
 		s.at(i) = s.at(i) + n;
 		if((int)s.at(i) > 90) s.at(i) -= 26;
 	}

 	cout << s << endl;

 	return 0;
}

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

int main() {
  int N, sum, lower{100001};
  cin >> N;
  for (int A = 1; A <= N / 2; ++A) {
    sum = 0;
    for (int i = A; i > 0; i /= 10) sum += (i % 10);
    for (int i = N - A; i > 0; i /= 10) sum += (i % 10);
    if (lower > sum) lower = sum;
  }
  cout << lower << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

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

int main(){
	int s,a,b;
	cin>>s;
	if(s==1){
		cout<<"Hello World"<<endl;
	}else{
		cin>>a>>b;
		cout<<a+b<<endl;
	}

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

typedef struct pp
{
    char name[10];
    int time;
}pp;

pp a[100000];
int time = 0;
int n;
int q;
int head = 0;
int tail = 0;

void enqueue(pp b)
{
    a[tail] = b;
    tail++;
    if(tail == n+1)
        tail = 0;
}

pp dequeue()
{
    pp b = a[head];
    if( ++head == n+1 )
        head = 0;
    return b;
}

int empty()
{
    return head == tail;
}

int main()
{
    pp temp;
    scanf("%d",&n);
    scanf("%d",&q);
    int i = 0;

    for( ; i < n ; i++ )
    {
        scanf("%s",&a[i].name);
        scanf("%d",&a[i].time);
        enqueue(a[i]);
    }

    while(!empty())
    {
        temp = dequeue();
        if( temp.time > q )
        {
            time += q;
            temp.time -= q;
            enqueue(temp);
        }
        else{
            time += temp.time;
            printf("%s ",temp.name);
            printf("%d\n",time);
        }
    }

    return 0;
}







Measured memory_bytes: 3348
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

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;
    }
}
int main(void)
{
    int N;
    cin >> N;
    string s;
    cin >> s;
    int cntE[N + 1];
    int cntW[N + 1];
    fill(cntE, cntE + N + 1, 0);
    fill(cntW, cntW + N + 1, 0);
    for (int i = 0; i < N; i++)
    {
        if (s[i] == 'W')
        {
            cntW[i + 1] = cntW[i] + 1;
            cntE[i + 1] = cntE[i];
        }
        else
        {
            cntE[i + 1] = cntE[i] + 1;
            cntW[i + 1] = cntW[i];
        }
    }
    int ans = 3000000;
    for (int i = 1; i <= N; i++)
    {
        //cout << cntW[i] << " " << cntE[i] << endl;
        int tmp = cntW[i - 1] + cntE[N] - cntE[i];
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6112
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  long n, k;
  std::vector<std::array<long, 2>> xs;
  Solver() {
    S002 reader;
    reader >= n >= k >n>= xs;
  }
  void solve() {
    std::sort(xs.begin(), xs.end());
    long sum = 0;
    for(auto x : xs) {
      sum += x[1];
      if( k <= sum ) {
        printf("%ld\n", x[0]);
        break;
      }
    }
  }
  ~Solver() { fprintf(stderr, "--end--\n"); }
};
 
int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;

int main() {

    ll n;
    cin >> n;

    ll nums[n];

    map<ll, ll> cnt;

    for (int i = 0; i < n; i++){
        cin >> nums[i];
        if (cnt.find(nums[i]) == cnt.end() ) {
            cnt[nums[i]] = 1;
        } else {
            cnt[nums[i]]++;
        }
    }

    bool square = false;
    ll squareIndex = 0, squareValue = 0;

    for ( auto it = cnt.begin(); it != cnt.end(); ++it  )
    {
        // std::cout << it->first << '\t' << it->second << std::endl;

        if (it->second >= 4 && it->first > squareIndex){
            square = true;
            squareValue = it->first;
        }
    } 


    // at this point we would've found square ... find rect
    // decide which area is bigger, 

    bool top1 = false, top2 = false;
    ll top1Value = 0, top2Value = 0;
    

    for ( auto it = cnt.begin(); it != cnt.end(); ++it  )
    {
        // std::cout << it->first << '\t' << it->second << std::endl;

        // check top1
        if (!top1 && it->second >= 2){
            top1 = true;
            top1Value = it->first;
        }

        if (!top2 && it->second >= 2){
            top2 = true;
            top2Value = it->first;
        }

        if (top1 && top2 && it->second >= 2){
            if (it->first > top1Value && it->first > top2Value){
                ll top1Rem = it->first - top1Value;
                ll top2Rem = it->first - top2Value;
                if (top1Rem > top2Rem){
                    top1Value = it->first;
                } else {
                    top2Value = it->first;
                }
            }
            else if (it->first > top1Value){
                top1Value = it->first;
            }
            else if (it->first > top2Value){
                top2Value = it->first;
            }
        }
    } 

    ll squareResult = 0;

    // cout << " squareResult : " << squareResult << " top1Value : " << top1Value << " top2Value : " << top2Value << endl;

    if (square){
        squareResult = squareValue * squareValue;
    } 

    ll answer = max(squareResult, top1Value * top2Value);

    cout << answer << endl;

    // area of 4's if exist against area of 

    return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
char f[120][120]={0},ans[120][120]={0};
int main(){
    int h=0,w=0;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>f[i][j];
            ans[2*i][j]=f[i][j];
            ans[2*i+1][j]=f[i][j];
        }
    }
    for(int i=0;i<2*h;i++){
        for(int j=0;j<w;j++){
            cout<<ans[i][j];
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int gcd(int x, int y)
{
    int t;
    if(x < y) swap(x, y);
    while(y)
        t = x % y, x = y, y = t;
    return x;
}


int main(){
	int m,n;
	while(cin>>m>>n){
        cout<<gcd(m, n)<<endl;
	}
}

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

lli n;

int main(void){
    cin >> n;
    if(n%2 == 1) cout << 0 << endl;
    else{
        n/=2;
        lli a, b;
        a = n;
        b = 0;
        lli j = 5;
        while(j <= n){
            b+=n/j;
            j*=5;
        }
        cout << min(a, b) << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
using namespace std;
int main(){
int a;
int b;
cin>>a>>b;
if(a<6)
    cout<<"0";
    if(a>=6 && a<13)
        cout<<b/2.0;
    if(a>=13)
       cout<<b;
  return 0;

}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for A - Addition
	var N int
	fmt.Scanf("%d", &N)
	var A int
	var count int
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A)
		if A%2 != 0 {
			count++
		}
	}

	if count%2 != 0 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}

}


Measured memory_bytes: 6328
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/
#include <bits/stdc++.h>
using namespace std;
#define printshosu(a) cout << fixed << setprecision(15) << a << endl;
int main(){
  int N;
  cin >>N;
  if(N%2==0){
    printshosu(1.0/2.0);
  }else{
    printshosu((N/2+1.0)/N);
  }
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var h = sc.ArrayInt(N);
        var dp = new int[N + 2];
        for (int i = 1; i < N; i++) {
            var one = dp[i-1] + Abs(h[i] - h[i-1]);
            var two = int.MaxValue;
            if (i >= 2) {
                two = dp[i - 2] + Abs(h[i] - h[i - 2]);
            }
            dp[i] = Min(one, two);
            
        }
        WriteLine(dp[N-1]);
    }
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 16864
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi = vector<int>;
using vl= vector<ll>;
using vs=vector<string>;

ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a);}
ll max(ll a, ll b) {if (a > b) return a; else return b;}
ll min(ll a, ll b) {if (a < b) return a; else return b;}
ll power(ll a,ll b) {long long res = 1; while (b > 0) {if (b & 1)res = res * a;a = a * a;b >>= 1;} return res;}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcase=1;
    
    for(int p=0;p<testcase;p++){
	ll n=0,sum=0;
	cin>>n;
	ll array[n]={0};
	
	for(int i=0;i<n;i++)
		{cin>>array[i];
}
sort(array,array+n,greater<ll>());
sum+=array[0];
ll i=0;
for( i=1;i<n/2;i++)
{
    sum+=array[i]*2;
  
}
if(n%2!=0)
sum+=array[i];

cout<<sum;

}
    return 0;
}


Measured memory_bytes: 5184
N = int(input())
A = list(map(int,input().split()))

sumA = sum(A)
ans = 0
for i in range(len(A)-1):
    sumA -= A[i]
    tmp1 = A[i] % (10**9 + 7)
    tmp2 = sumA % (10**9 + 7)
    ans += tmp1 * tmp2
    ans %= (10**9 + 7)
    
print(ans)

Measured memory_bytes: 105264
n=int(input())
s={}
for _ in range(n):
    i=input()
    if i in s:
        s[i]+=1
    else:
        s[i]=1
m=int(input())
for _ in range(m):
    j=input()
    if j in s:
        s[j]-=1
ans=max(s.values())
if ans<0:
    print(0)
else:
    print(ans)

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
int upcal(int a, int b)
{
    if (a <= 0) {
        return 0;
    } else {
        int ret = a / b;
        if (a % b) ret++;
        return ret;
    }
}

signed main()
{
    Int(n);
    int2(a, b);
    vi data(n);

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

    int l = 0, r = 1000000000;
    while ( r - l > 1 ) {
        int mid = (l + r) / 2;
        int sum = 0;
        //cout << mid << " ";
        rep(i, n) {
            //cout << upcal(data[i] - mid * b, a) << " ";
            sum += upcal(data[i] - mid * b, a - b);
        }
        //cout << sum << endl;
        if (sum <= mid) {
            //cout << "true" << endl;
            r = mid;
        } else {
            //cout << "false" << endl;
            l = mid;
        }
    }

    cout << r << endl;

    return 0;
}



Measured memory_bytes: 1024
package main

import "fmt"

func check(s, t string) bool {
OUTER:
	for num_rot := 0; num_rot < len(s); num_rot++ {
		for i := range s {
			if s[i] != t[(i+num_rot)%len(t)] {
				continue OUTER
			}
		}
		return true
	}
	return false
}

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	if check(s, t) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}
	

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

int main() {
	int k;
	cin >> k;
	vector<int> a(k);
	rep(i,k) cin >> a[i];
	reverse(a.begin(), a.end());
	ll l = 2;
	ll r = 3;
	rep(i,k) {
		l = dup(l, a[i]) * a[i];
		r = dup(r, a[i]) * a[i];
		if (r - l <= 1) {	
			cout << -1 << endl;
			return 0;
		}
	}
	cout << l << " " << r-1 << endl;
}

Measured memory_bytes: 3780
using System;

	class A{
			public static void Main(){

			string[] x = Console.ReadLine ().Split (' ');


			int l = int.Parse(x [0] )* int.Parse(x [1]);
		int m = int.Parse(x [0] )*2 + int.Parse(x [1])*2;		

			Console.WriteLine (l + " " + m);
			}
	}

Measured memory_bytes: 9092
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>
#include <functional>
#include <cmath>

#define INF 1000000000
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    sort(p.begin(), p.end());

    int ans = 0;
    for(int i = 0; i < k; i++){
        ans += p[i];
    }
    cout << ans << endl;
}


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

using namespace std;

#define int long long
#define ar array



int32_t main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);

  int n;
    cin >> n;
    vector<int> arr(n);
    for(int i = 0;i < (int)n; i++){
      cin >> arr[i];
    }
    sort(arr.begin(), arr.end());
  int cnt = 0;
  for(int i = 0;i < n;i++){
    for(int j = i+1;j < n;j++){
      if(arr[i]!=arr[j]){
        int sum = arr[i]+arr[j];
        for(int k = j+1;k < n;k++){
          if(arr[k]!=arr[i] && arr[k]!=arr[j] && arr[k]>=min(arr[i],arr[j]) && arr[k]<sum) cnt++; 
        }
      }
    }
  }
  cout << cnt << "\n";    
    
  return 0;
}


Measured memory_bytes: 3652
/*#include<stdio.h>
#include<string.h>
//int lcs(char *,char *);

int main(){
	char S1[20],S2[20];
	int i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",S1);
		scanf("%s",S2);
		int c[1000][1000];
    int max=0;
    int l1,l2,a,b;
    l1=strlen(S1)+1;
    l2=strlen(S2)+1;
    for(a=0;a<l1;a++)c[0][a]=0;
    for(a=0;a<l2;a++)c[a][0]=0;

    for(a=1;a<l1;a++){
    	for(b=1;b<l2;b++){
    		if(S1[a-1]==S2[b-1])c[a][b]=c[a-1][b-1]+1;
    		else if(c[a-1][b]>=c[a][b-1])c[a][b]=c[a-1][b];
    		else c[a][b]=c[a][b-1];
    	}
    }

		//max=lcs(S1,S2);
		printf("%d\n",c[l1-1][l2-1]);
	}
	return 0;
}

int lcs(char *x,char *y){
	int c[1000][1000];
	int i,j,m,n;
	m=strlen(x);
	n=strlen(y);
	int max=0;
  x=strcat(" ",x);
  y=strcat(" ",y);
  for(i=1;i<=m;i++)c[i][0]=0;
	for(j=1;j<=n;j++)c[0][j]=0;

	for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
			if(x[i]==y[j]){
				c[i][j]=c[i-1][j-1]+1;
			}
			else{
				if(c[i-1][j]>c[i][j-1]) c[i][j]=c[i-1][j];
				else c[i][j]=c[i][j-1];
			}
			if(max<c[i][j]) max=c[i][j];
		}
	}
	return max;
}*/
#include<stdio.h>
#include<string.h>
int main()
{
  int q,i,j;
  char S1[1001],S2[1001];
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%s",S1);
    scanf("%s",S2);
    printf("%d\n",LCS(S1,S2));
  }
  return 0;
}

int LCS(char *S1,char *S2)
{
  int c[1001][1001],i,j,x,y;
  x=strlen(S1)+1;
  y=strlen(S2)+1;
  for(i=1;i<x;i++)c[0][i]=0;
  for(i=0;i<y;i++)c[i][0]=0;

  for(i=1;i<x;i++){
    for(j=1;j<y;j++){
      if(S1[i-1]==S2[j-1])c[i][j]=c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1])c[i][j]=c[i-1][j];
      else c[i][j]=c[i][j-1];
    }
  }
  return c[x-1][y-1];
}



Measured memory_bytes: 5768
_ = input()
data_list = [int(e) for e in input().split()]
cnt = 0
end_flag = False
for i in range(10000):
    for i in range(len(data_list)):
        if data_list[i] % 2 == 0:
            data_list[i] /= 2
        else:
            end_flag = True
            break
    if end_flag == True:
        break
    else:
        cnt += 1
print(cnt)

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

double dst(double a, double b, double c, double d) {
	return sqrt((c - a) * (c - a) + (d - b) * (d - b));
}

double det(double a, double b, double c, double d, double e, double f) {
	return abs((c-a)*(f-b)-(d-b)*(e-a));
}

int main() {
	double a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	double l1 = dst(a, b, c, d);
	double l2 = dst(a, b, e, f);
	double l3 = dst(c, d, e, f);
	double ar = det(a, b, c, d, e, f);
	double R = ar / (l1 + l2 + l3);

	double lo = 0.0, hi = R;

	rep(tt, 100) {
		double m = (lo + hi) / 2;
		double ml = max({l1, l2, l3}) * (1.0 - m / R);
		if (ml > m * 2) {
			lo = m;
		} else {
			hi = m;
		}
	}

	printf("%.9f\n", lo);

	return 0;
}

Measured memory_bytes: 256