akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int N,K;
    int ans = 1;

    N = s.nextInt();
    K = s.nextInt();
    for(int i = 0; i < N ; i++){
      if(ans*2 <= ans + K){ans = ans*2;}
      else ans += K;
    }
    System.out.printf("%d",ans);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <math.h> 
#include <vector>
#include <algorithm>
#include <iomanip>      // std::setprecision
#include <map>

using namespace std;

int main()
{

	double N, sol = 0;
	char last_input = 0;
	std::cin >> N;
	for (int i = 0; i < N; i++)
	{
		char input;
		std::cin >> input;
		if (input != last_input)
		{
			sol++;
			last_input = input;
		}
	}
	std::cout << fixed << std::setprecision(0) << sol;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define P pair<lli,lli>

signed main(){

	lli n,p;
	cin>>n>>p;
	string s;
	cin>>s;

	reverse(s.begin(),s.end());

	if(p==2 || p==5){
		lli cnt=0;
		REP(i,0,n){
			lli num = s.at(i)-'0';
			if(num%p == 0)cnt+=(n-i);
		}
		cout<<cnt<<endl;
		return 0;
	}

	map<lli,lli> cnt;
	lli now=0;
	lli tenDiv = 1;
	cnt[0]++;

	REP(i,0,n){
		lli num = s.at(i)-'0';
		now += num*tenDiv;
		now %= p;
		cnt[now]++;
		tenDiv *= 10;
		tenDiv %= p;
	}

	lli ans = 0;
	for(auto e:cnt){
		if(DEBUG)cout<<"e.first="<<e.first<<" e.second="<<e.second<<endl;
		ans += (e.second)*(e.second-1)/2;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>
int main(void)
{
    int n,r;
    r=1;
    scanf("%d",&n);
    int a[n];
    a[0]=0;
    int b[n];
    for(int o=0;o<9;o++)
    {
        b[o]=0;
    }
    for(int p=1;p<n+1;p++)
    {
        scanf("%d",&a[p]);
        if(0<a[p] && a[p]<400)a[p]=1;
        else if(399<a[p] && a[p]<800)a[p]=2;
        else if(799<a[p] && a[p]<1200)a[p]=3;
        else if(1199<a[p] && a[p]<1600)a[p]=4;
        else if(1599<a[p] && a[p]<2000)a[p]=5;
        else if(1999<a[p] && a[p]<2400)a[p]=6;
        else if(2399<a[p] && a[p]<2800)a[p]=7;
        else if(2799<a[p] && a[p]<3200)a[p]=8;
        else if(3199<a[p])a[p]=9;
    }
    for(int q=1;q<9;q++)
    {
        for(int r=1;r<n+1;r++)
        {
            if(a[r]==q)
            {
                b[q-1]=1;
            }
        }
    }
    for(int t=1;t<n+1;t++)
    {
            if(a[t]==9)
            {
                b[8]+=1;
            }
    }
    int sum=b[0]+b[1]+b[2]+b[3]+b[4]+b[5]+b[6]+b[7];
    int max,min;
    if(sum==0)
    {
        min=1;
    }
    else
    {
        min=sum;
    }
    max=b[8]+sum;
    printf("%d %d",min,max);
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

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

    for (int i = 0; i < (1 << (s.size() - 1)); ++i) {
        int t = s[0] - '0';
        string exp = {s[0]};

        for (int j = 0; j < s.size() - 1; ++j) {
            if (i >> j & 1) {
                exp += "+";
                exp += s[j + 1];
                t += s[j + 1] - '0';
            }
            else {
                exp += "-";
                exp += s[j + 1];
                t -= s[j + 1] - '0';
            }
        }

        exp += "=7";
        if (t == 7) {
            cout << exp << endl;
            return 0;
        }
    }
    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);
		while(sc.hasNext()){
			int[] a=new int[8];
			for(int i=0;i<8;i++){
				a[i]=Integer.parseInt(sc.next(),2);
			}
			for(int i=0;i<8;i++){
				if(a[i]>0){
					if(i==7){
						System.out.println("C");
						break;
					}else if(a[i+1]==0){
						System.out.println("C");
						break;
					}else{
						if(a[i]==a[i+1]){
							if(i+2==8){
								System.out.println("A");
								break;
							}else{
								if(a[i]==a[i+2]){
									System.out.println("B");
									break;
								}else{
									System.out.println("A");
									break;
								}
							}
						}else if(a[i+1]==a[i]+a[i]*2){
							System.out.println("D");
							break;
						}else if(a[i]==a[i+1]*2){
							System.out.println("E");
							break;
						}else if(a[i+1]==a[i]+a[i]/2){
							System.out.println("F");
							break;
						}else{
							System.out.println("G");
							break;
						}
					}
				}
			}
		}
	}
}

Measured memory_bytes: 20148
N = int(input())
S = [input() for _ in range(N)]

MARCH = [0] * 5
for i in range(N):
    if S[i][0] == 'M' : MARCH[0] += 1
    if S[i][0] == 'A' : MARCH[1] += 1
    if S[i][0] == 'R' : MARCH[2] += 1
    if S[i][0] == 'C' : MARCH[3] += 1
    if S[i][0] == 'H' : MARCH[4] += 1
    
ans = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans += MARCH[i] * MARCH[j] * MARCH[k]
            
print(ans)
    


Measured memory_bytes: 9772
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
typedef long long ll;
const ll mod = 1e9 + 7;
ll f[maxn], g[maxn];
int c[maxn];

int main() {
    int N;
    scanf("%d", &N);
    f[0] = 1;
    for(int i = 1; i <= N; ++i) {
        scanf("%d", c + i);
        if(c[i] != c[i - 1]) {
            f[i] = (f[i - 1] + g[c[i]]) % mod;
            g[c[i]] = (g[c[i]] + f[i - 1]) % mod;
        }
        else f[i] = f[i - 1];
    }
    printf("%lld\n", f[N]);
    return 0;
}

Measured memory_bytes: 4096
<?php

list($n, $m) = explode(' ', trim(fgets(STDIN)));

for($i = 0; $i < $n; $i++) {
    $a[] = explode(' ', trim(fgets(STDIN)));
}

for($i = 0; $i < $m; $i++) {
    $b[] = trim(fgets(STDIN));
}

for ($i = 0; $i < $n; $i++) {
    $sum = 0;
    for ($j = 0; $j < $m; $j++) {
        $sum += ((int)$a[$i][$j] * (int)$b[$j]);
    }
    echo $sum .PHP_EOL;
}

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

a = []
for i in range(n):
    a.append(list(map(int, input().split())))

b = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for i in range(n):
    b[a[i][0] - 1][a[i][1] - 1][a[i][2] - 1] += a[i][3]

for i in range(4):
    for j in range(3):
        b[i][j].insert(0, "")
        print(*b[i][j])
    if i == 3:
        break
    print("####################")
    

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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define mk make_pair

typedef long long LL;
typedef pair<int,int> Interval;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){
    os << v.first <<" "<<v.second<<endl;
    return os;
}

const int maxn = 7368793;
bool dp[maxn];

int main()
{
    int m,n;

    while(cin >> m >> n){

        //cout << "ok" << endl;
        if(!m&&!n) break;
        memset(dp,0,sizeof(dp));
        int cnt = m;
        while(n--){
            while(dp[cnt]) ++cnt;
            for(int j = cnt;j < maxn;j+=cnt) dp[j] = 1;
        }
        while(dp[cnt]) ++cnt;

        printf("%d\n",cnt);
    }

    return 0;
}


Measured memory_bytes: 10336
#include<bits/stdc++.h>
using namespace std;
int main(){

  int K;
  int N;
  
  cin >> K >> N;
  
  vector<int> A(N);
  
  for(int i = 0;i < N;++i){
    cin >> A[i];
  }
  
  vector<int> B(N);
  
  for(int i = 0;i < N;++i){
    if(i == 0){
      B[i] = A[i] + (K - A[N - 1]);
    }
    else{
      B[i] = A[i] - A[i - 1];
    }
  }
  
  sort(B.begin(),B.end());
  
  cout << K - B[N - 1] << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

using namespace std;
char flag[52][52];
int red[52];
int blue[52];
int white[52];
int N,M;
int kotae;
int kotaee;

int main(){
	kotaee = 99999999;
	cin >> N >> M;
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			cin >> flag[i][j];
			if(flag[i][j] == 'R')red[i]++;
			else if(flag[i][j] == 'W')white[i]++;
			else if(flag[i][j] == 'B')blue[i]++;
		}
	}
	for(int i=0;i<=N-2;i++){
		for(int j=i+2;j<N;j++){
			kotae = 0;
			for(int ii=0;ii<=i;ii++){
				kotae += M-white[ii];
			}
			for(int ii=j;ii<N;ii++){
				kotae += M-red[ii];
			}
			for(int ii=i+1;ii<j;ii++){
				kotae += M-blue[ii];
			}
			kotaee = min(kotaee,kotae);
		}
	}
	cout << kotaee << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    string ans = "No";

    if(n <= 81){
        if(n % 9 == 0) n /= 9;
        else if(n % 8 == 0) n /= 8;
        else if(n % 7 == 0) n /= 7;
        else if(n % 6 == 0) n /= 6;
        else if(n % 5 == 0) n /= 5;
        else if(n % 4 == 0) n /= 4;
        else if(n % 3 == 0) n /= 3;
        else if(n % 2 == 0) n /= 2;
        
        if(n <= 9) ans = "Yes";
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int N = intRead();
        int ans = N % 28;
        bool flag = false;
        for (int i = 0; i <= 7; i++)
        {
            for (int j = 0; j <= 4; j++)
            {
                if (ans == (4 * i) + (7 * j))
                {
                    flag = true;
                    break;
                }
            }
        }
        Console.WriteLine(flag ? "Yes" : "No");
        return;
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }

}


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

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

		int n;
		
		boolean flag = false;
		
		n = scan.nextInt();
		
		int a[][];
		
		a = new int[n][7];
		
		for(int j = 0; j < n; j++){
			for(int i = 1; i < 7; i++){	
				a[j][i] = scan.nextInt();
			}
		}
		
		for(int i = 0; i < n-1; i++){
			for(int j = i+1; j < n; j++){
				if(flag) break;
				flag = dice(a[i], a[j]);
			}
		}
		if(flag){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}
		
	}
	public static boolean dice(int a[], int b[]){
	int h = 0;
		boolean flag = false;
	

		for(int i = 0; i < 6; i++){
			for(int j = 0; j < 4; j++){
				if(flag == true)break;
					h = a[2];
					a[2] = a[3];
					a[3] = a[5];
					a[5] = a[4];
					a[4] = h;
					flag = Arrays.equals(a,b);

			}
			if(i == 0 || i == 4){
				h = a[1];
				a[1] = a[3];
				a[3] = a[6];
				a[6] = a[4];
				a[4] = h;
			}else{
				h = a[1];
				a[1] = a[2];
				a[2] = a[6];
				a[6] = a[5];
				a[5] = h;
			}
		}
		
		return flag;
	}
	
}

Measured memory_bytes: 29080
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c, d; cin >> a >> b >> c >> d;
    int res = max(0, min(b, d) - max(a, c));

    cout << res << endl;

    return 0;
}


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


int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r,b;
    r = b = 0;
    for(int i=0;i<n;i++) {
        if (s[i] == 'R') {
            r++;
        } else {
            b++;
        }
    }
    if (r > b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N , K = map(int,(input().split()))
 
sums = 0
nums = [0] * (10 ** 5 + 1) 
con = 0
ans = 0
 
for i in range(N):
  a,b = map(int,(input().split()))
  nums[a] += b
  
for i in range(len(nums)):
  con += nums[i]
  if K > con:
    continue
  elif K <= con:
    ans = i
    break

    
print(ans)

Measured memory_bytes: 5748
#pragma GCC target("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>

#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>
#define deb(x)		cout << #x << " " << x << endl

using namespace std;
using ll  = long long;
using lld = long double;

const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;

const int N = 105 , V = 200005;

#define int ll

int dp[N][V];
int ar[N];
int w[N] , v[N];
inline void relax(int & a , int b){
    a = min(a , b);
}



signed main(){

#ifndef ONLINE_JUDGE
	//freopen("in.txt" , "r" , stdin);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);

    fo(i , N) fill(dp[i] , dp[i] + V , oo);
    
    int n , cap;
    cin >> n >> cap;
    fo(i , n) cin >> w[i] >> v[i];

    //dp[i][j] = min weight required to form a value <= j using first i items
    
    int max_v = 0;
    dp[0][0] = 0;
    fo(i , n){
        fo(j , V){
            max_v = max(max_v , v[i]);
            relax(dp[i + 1][j + v[i]] , dp[i][j] + w[i]); 
            relax(dp[i + 1][j] , dp[i][j]);
        }
    }


    int ans = 0;
    fo(i , n + 1) fo(j , V) if(dp[i][j] <= cap && dp[i][j]) ans = max(ans , j);
    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 167676
cnt500 = int(input())
cnt100 = int(input())
cnt50 = int(input())
X = int(input())

all_set = set([])

for a in range(cnt500+1):
    tmp500 = a*500
    if tmp500 > X:
        break
    all_set.add((tmp500, 0, 0))
    for b in range(cnt100+1):
        tmp100 = b*100
        if tmp100 > X:
            break
        all_set.add((tmp500, tmp100, 0))
        for c in range(cnt50+1):
            tmp50 = c*50
            if tmp50 > X:
                break
            all_set.add((tmp500, tmp100, tmp50))

all = []
for a in all_set:
    all.append(sum(a))
print(all.count(X))

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

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

	if(n < m)
		for (int i = 0; i < m; ++i)
		{
			cout << n;
		}
	else
		for (int i = 0; i < n; ++i)
		{
			cout << m;
		}

	return 0;
}

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

int main()
{
    int n , x ;
    while(1)
    {
        cin >> n >> x ;
        int c = 0 ;
        if(n == 0 && x == 0) break ;
        for(int i = 1 ; i <= (n - 2) ; i++)
        {
            for(int j = i + 1 ; j <= (n - 1) ; j++)
            {
                for(int k = j + 1 ; k <= n ; k++)
                {
                    if((i + j + k) == x)
                    {
                        c++ ;
                    }
                }
            }
        }
        cout << c << endl ;
    }
    return 0 ;
}


Measured memory_bytes: 3108
r, g, b, n = map(int, input().split())
ans = 0

for i in range(n // r + 1):
  for j in range(n // g + 1):
    if (n - (i * r) - (j * g) )% b == 0 and 0 <= (n - (i * r) - (j * g) )//b<= n//b :
      ans += 1

      
print(ans)

Measured memory_bytes: 40684
#include<bits/stdc++.h>
#define L long long
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define aa first
#define bb second
#define xx aa.aa
#define yy aa.bb
#define zz bb
#define mp make_pair
#define mpp(a,b,c) mp(mp(a,b),c)
using namespace std;
int n,x,y,z;
vector<pii> w;
L p,q,a[100010],b[100010];
priority_queue<int> f;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k,l;
	scanf("%d%d%d",&x,&y,&z);
	n=x+y+z;
	for(i=1;i<=n;i++)
	  {
	   scanf("%d%d%d",&j,&k,&l);
	   p+=j;
	   w.pb(mpp(k-l,k-j,l-j));
	  }
	sort(w.begin(),w.end());
	for(i=1;i<=n;i++)
	  {
	   q+=w[i-1].zz;
	   f.push(-w[i-1].zz);
	   if(i>z)
	     {
		  q+=f.top();
		  f.pop();
		 }
	   a[i]=q;
	  }
	while(!f.empty())
	  f.pop();
	q=0;
	for(i=n;i>0;i--)
	  {
	   q+=w[i-1].yy;
	   f.push(-w[i-1].yy);
	   if(n-i>=y)
	     {
		  q+=f.top();
		  f.pop();
		 }
	   b[i]=q;
	  }
	q=-1e18;
	for(i=z;n-i>=y;i++)
	  q=max(q,a[i]+b[i+1]);
	p+=q;
	printf("%lld\n",p);
	return 0;
}


Measured memory_bytes: 3828
#include <stdio.h>
int main(){
	int n;
	while(1){
	    int l,r;
		int a[11][11];
		scanf("%d",&n);
		if(!n) break;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++) scanf("%d",&a[i][j]);
		}
		for(int i=0;i<n+1;i++){
			l=r=0;
			for(int j=0;j<n;j++){
				l+=a[i][j];
				r+=a[j][i];
			}
			a[i][n]=l;
			a[n][i]=r;
		}
		for(int i=0;i<n+1;i++){
			for(int j=0;j<n+1;j++) printf("%5d",a[i][j]);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1044
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	int q;
	cin >> q;
	for (int query = 0; query < q; ++query)
	{
		ll a, b;
		cin >> a >> b;
		if (a > b)
		{
			swap(a, b);
		}

		ll ans = 0;

		if (a == 1 && b == 1)
		{
			ans = 0;
		}
		else
		{

			ll c = a*b - 1;
			ll x = sqrt(c) + 100;

			while (x*x>c)
			{
				x--;
			}






			ans = x * 2;

			if (x == c / x)
			{
				ans--;
			}

			if (x >= a)
			{
				ans--;
			}

			// BEGIN CUT HERE
//			cerr << "a=" << a << " b=" << b << " c=" << c << " x=" << x << " c/x=" << c/x << " ans=" << ans << endl;
			// END CUT HERE



		}




		cout << ans << endl;
	}




	return 0;
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

void solve(){
   int n,k;
   cin >> n >> k;
   map<int,int>m;

   f(i,0,k){
      int t,a;
      cin >> t;
      f(j,0,t) cin >> a , m[a] = 1;
   }
   int ans = 0;
   f(i,1,n+1) if(!m[i]) ans++;
   cout << ans;
}

int32_t main(){
   fast;
   int t = 1;
//   cin >> t;
   while(t--)  solve();   
}

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

int main() {
	int x;
	cin >> x;
	int a[1000] = { 1 };
	int s = 1;
	for (int i = 2;i < 35;i++) {
		int c = i;
		for (int j = 2;c < 1001;j++) {
			c *= i;
			a[s] = c;
			s++;
		}
	}
	int i = 0;
	sort(a, a+(s-1));
	while (1) {
		if (x == 1) {
			cout << 1;
			break;
		}
		if (a[i] > x) {
			cout << a[i - 1];
			break;
		}
		i++;
	}
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;

	vector<double> p(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
		p[i] = (p[i] + 1) / 2.0;
	}

	double sum = accumulate(p.begin(), p.begin() + K, 0.0);
	double ans = sum;
	for (int i = 0; i < N - K; i++) {
		sum += p[i + K] - p[i];
		chmax(ans, sum);
	}

	cout << fixed << setprecision(10) << ans << "\n";

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
#define rep(i,n) for(ll i=0;i<(n);i++)
ll ans, n;
ll a, b;
int main() {
	cin >> n;
	ll mi = 1e15;
	bool f = 0;
	for (ll i = 0; i < n; i++) {
		cin >> a >> b;
		ans += b;
		if (a > b) {
			f = 1;
			mi = min(mi, b);
		}
	}
	if (!f)cout << 0 << endl;
	else cout << ans - mi << endl;
	return 0;
}

Measured memory_bytes: 256
S = []
H = []
C = []
D = []
for i in (S, H, C, D):
        for k in range(1, 13+1):
            i.append(k)


for u in range(0, int(input())):
    x, y = (i for i in input().split())
    if x == "S":
        S.remove(int(y))
    elif x == "H":
        H.remove(int(y))
    elif x == "C":
        C.remove(int(y))
    else:
        D.remove(int(y))
if len(S) > 0:
    for s in range(0, len(S)):
        print("S",S[s])
if len(H) > 0:
    for h in range(0, len(H)):
        print("H",H[h])
if len(C) > 0:
    for c in range(0, len(C)):
        print("C",C[c])
if len(D) > 0:
    for d in range(0, len(D)):
        print("D",D[d])

Measured memory_bytes: 7792
#include<stdio.h>
int main(void) 
{
  int a,b;
  scanf("%d %d",&a,&b);
  
  if( a > b)
    printf("a > b\n");
 
  else if( a < b)
    printf("a < b\n");
 
  else
    printf("a == b\n");
 
  return 0;
}

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

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

  long long N;
  cin >> N;
  N--;
  vector<int> a;
  while (true) {
    a.emplace_back(N % 26);
    N /= 26;
    N--;
    if (N < 0) {
      break;
    }
  }
  reverse(begin(a), end(a));
  string ans;
  for (auto i : a) {
    cout << char(i + 'a');
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3632
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

use std::iter::Iterator;

fn main() {
    input!{
        X: i64, 
    }

    let gohayku = X / 500;

    let amarigo = X % 500;

    let goen = amarigo / 5;

    let ans = gohayku * 1000 + goen * 5;

    println!("{}", ans);
    
}


Measured memory_bytes: 4352
N = int(input())
A = list(map(int, input().split()))
dict1 = {}
for i in range(N):
  if A[i] not in dict1.keys():
    dict1[A[i]] = 0
  else:
    dict1[A[i]] += 1
value1 = []
for value in dict1.values():
  value1.append(value)
value2 = sorted(value1, reverse = True)
if len(value2) != 1:
  if value2[0] - value2[1] >= sum(value2[1:]):
    print(N - (value2[0] * 2))
  else:
    if(sum(value2[0:]) % 2 == 0):
      print(len(value2))
    else:
      print(len(value2) - 1)
else:
  print(1)

Measured memory_bytes: 18272
n = int(input())
count = 0
for i in range(1, n+1):
    for j in range(i+1, n+1):
        if i*j < n:
            count += 2
        else:
            break
for i in range(1, n+1):
    if i**2 < n:
        count += 1
    else:
        break
print(count)

Measured memory_bytes: 67856
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vp red(n), blue(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        red[i] = P(a, b);
    }
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        blue[i] = P(a, b);
    }
    sort(all(blue));
    auto comp = [](P a, P b) { return a.se > b.se;};
    sort(all(red), comp);
    vb used(n, false);
    int cnt = 0;
    rep(i, n) {
        rep(j, n) {
            if (!used[j] && red[j].fi < blue[i].fi && red[j].se < blue[i].se) {
                used[j] = true;
                cnt++;
                break;
            }
        }
    }
    cout << cnt << endl;
}

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

int gcd(int x, int y)
{
	return !y ? x : gcd(y, x % y);
}

int main()
{
	int n;
	scanf("%d", &n);
	printf("%d\n", 360 / gcd(360, n));
	return 0;
}

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

int main() {
    long long n;
    cin >> n;
    long long a[n];
    long long s[n+1];
    for(int i=0;i<n+1;i++) s[i]=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        s[a[i]]++;
    }
    long long total=0;
    for(int i=0;i<n+1;i++){
        if(s[i]>=2){
            total+=s[i]*(s[i]-1)/2;
        }
    }
    for(int i=0;i<n;i++){
        long long ans=total;
        if(s[a[i]]>=2){
            ans=ans-s[a[i]]*(s[a[i]]-1)/2+(s[a[i]]-1)*(s[a[i]]-2)/2;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	int v[20];
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	int c[20];
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	int a[20];
	for (int i = 0; i < n; i++) {
		a[i] = v[i] - c[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] > 0) {
			ans += a[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define printii(x)  for(auto it=x.begin();it!=x.end();it++) cout<<*it.F<<' '<<*it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
vi nc,nmc;

ll power(ll x, unsigned ll y, unsigned ll m=MOD) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 
  

ll modInverse(ll a, ll m=MOD) 
{ 
    return power(a, m-2, m);
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,k;
    cin>>n>>k;
    nc.resize(n+5);
    nmc.resize(n+5);
    nc[0] = 1;
    nmc[0] = 1;
    for(ll i=1;i<=n+4;i++){
        nc[i] = (((nc[i-1]*(n-i+1))%MOD)*modInverse(i));
        nmc[i] = (((nmc[i-1]*(n-i))%MOD)*modInverse(i));
        nc[i]%=MOD;
        nmc[i]%=MOD;
    }
    ll ans = 1;
    ll i;
    for(i=1;i<=min(n-1,k);i++){
        ans = ans + (nc[i]*nmc[n-i-1])%MOD;
        ans%=MOD;
    }
    if(ans<0){
    	ans+=MOD;
    }
    cout<<ans;

    return 0;
}







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

int main() {
  int n, a, y, z;
  cin >> n;
    y = 0;
  z = 400;
  while (n > 0 ){
    cin >> a;
    y = 0;    
    while( a % 2 == 0){
          a = a / 2;
          y++;}
     if ( z > y){z = y;} 
    n = n - 1;
  }
  cout << z << endl;
}


Measured memory_bytes: 256
def main()
  h, w = gets.split.map(&:to_i)
  matrix = h.times.map{ gets.chomp.chars }

  diffs = [[1, 0], [-1, 0], [0, 1], [0, -1]]
  [*0...h].product([*0...w]) do |x, y|
    next if matrix[x][y] == '.'
    return 'No' if  diffs.map{|(dx, dy)| [x + dx, y + dy]} \
                        .select{|(nx, ny)| 0 <= nx && nx < h && 0 <= ny && ny < w} \
                        .all?{|(nx, ny)| matrix[nx][ny] == '.'}
  end
  'Yes'
end

puts main()

Measured memory_bytes: 2172
# coding: utf-8
from collections import deque

k = int(input())
queue = deque([1,2,3,4,5,6,7,8,9])

for i in range(k):
    a = queue.popleft()
    if a % 10 != 0:
        queue.append(10 * a + (a%10) - 1)
    queue.append(10 * a + (a%10))
    if a % 10 != 9:
        queue.append(10 * a + (a%10) + 1)

print(a)

Measured memory_bytes: 11908
def fact(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr

A,B = map(int,input().split())
print(len( (set(fact(A))|set([1])) & (set(fact(B))|set([1])) ))

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



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

   ll n,k;
   cin>>n>>k;
   ll a[n],b[n];
   ll ans = 0;
   for(int i=0;i<n;i++){
       cin>>a[i]>>b[i];
       if((a[i] | k) <= k) ans += b[i]; 
   }
   //cerr<<ans<<endl;
   for(int bit = 0; bit < 33; bit++){
       ll ret = 0;
       if(!(k&(1LL<<bit))) continue;
       for(int i=0;i<n;i++){
           bool pos = true;
           for(int j=bit+1;j<33;j++){
               if(!(k&(1LL<<j)) && (a[i]&(1LL<<j))){
                   pos = false;
                   break;
               }
           }
           if(pos && a[i]<=k && !(a[i]&(1LL<<bit))){
               ret += b[i];
           }
       }
       ans = max(ans,ret);
      // cerr<<bit<<" "<<ans<<endl;
   }
   cout<<ans<<endl;

   
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cctype>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
using namespace std;

inline char gc() {
//	static char buf[100000],*p1,*p2;
//	return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	return getchar();
}

template<class T>
int read(T &ans) {
	ans=0;char ch=gc();T f=1;
	while(!isdigit(ch)) {
		if(ch==EOF) return -1;
		if(ch=='-') f=-1;
		ch=gc();
	}
	while(isdigit(ch))
		ans=ans*10+ch-'0',ch=gc();
	ans*=f;return 1;
}

template<class T1,class T2>
int read(T1 &a,T2 &b) {
	return read(a)!=EOF&&read(b)!=EOF?2:EOF;
}

template<class T1,class T2,class T3>
int read(T1 &a,T2 &b,T3 &c) {
	return read(a,b)!=EOF&&read(c)!=EOF?3:EOF;
}

typedef long long ll;
const int Maxn=110000;
const int inf=0x3f3f3f3f;
const int mod=1000000007;

int n,k,vis[Maxn],a[Maxn];

int work(int x) {
	if(~vis[x]) return vis[x];
	vis[x]=0;
	for(int i=1;i<=n;i++)
		if(x>=a[i]&&!work(x-a[i])) return vis[x]=1;
	return 0;
}

signed main() {
//	freopen("test.in","r",stdin);
	read(n,k);memset(vis,-1,sizeof(vis));
	for(int i=1;i<=n;i++) read(a[i]);
	puts(work(k)?"First":"Second");
	return 0;
}



Measured memory_bytes: 5248
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int f(int n){
    if (n%10 == 0){
        return 0;
    }
    else return 10-n%10;
}
int main() {
    int a,b,c,d,e,t = 0,s = 0;
    int m = -1;
    cin >> a >> b >> c >> d >> e;
    vector<int> n({a,b,c,d,e});
    rep(i,n.size()){
        if(f(n[i]) > m){
            m = f(n[i]);
            t = n[i];
        }
    }
 //cout << t << "\n";
    rep(i,n.size()){
      s += n[i]+f(n[i]);
    }
  	s -= f(t);
    cout << s << endl;
}


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

using namespace std;

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

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  for (auto &x : X) cin >> x;

  int ans = 1e9;
  for (int p = 1; p <= 100; p++) {
    int cost = 0;
    for (auto x : X) {
      cost += (x - p) * (x - p);
    }
    chmin(ans, cost);
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
# 1,2 .. n 社員番号
# 上司は部下より社員番号が小さい
# 入力は上司の社員番号

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

x = [0] * (n+1)
for i in a:
  x[i] += 1

for i in range(1,n+1):
  print(x[i])

Measured memory_bytes: 32228
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int main() {
	int n, l, m, r, A[100] = {}, i,key,cnt;
	while (~fscanf(stdin, "%d", &n), n) {
		l = cnt = 0, r = n - 1;
		for (i = 0; i < n; i++) fscanf(stdin, "%d", &A[i]);
		fscanf(stdin, "%d", &key);
		while (l <= r) {
			m = (l + r) / 2;
			cnt++;
			if (A[m] > key) r = m-1;
			else if (A[m] < key) l = m+1;
			else break;
		}
		P(d, cnt);
	}
	return 0;
}

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

using namespace std;

bool search(const vector<int>& a, int m, int index, int sum) {
  if (sum == m) return true;
  if (index == (int)a.size()) return false;

  bool res = search(a, m, index + 1, sum + a[index]);
  res |= search(a, m, index + 1, sum);
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int m;
    cin >> m;
    if (search(a, m, 0, 0)) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
  return 0;
}


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

using namespace std;

const int N = 2010;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;

int a[N];
int dp[N], dp2[N];

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

	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	for (int j = 0; j < n; ++j) {
		dp[j] = a[j];
	}
	long long ans = INF;
	for (int i = 0; i <= n; ++i) {
		long long at = (i) * 1ll * x;
		for (int j = 0; j < n; ++j) {
			at += dp[j];
		}
		for (int j = 0; j < n; ++j) {
			dp2[j] = min(dp[(j+n-1)%n], a[j]);
		}
		for (int j = 0; j < n; ++j) {
			dp[j] = dp2[j];
		}
		ans = min(ans, at);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());

		int m = a * b;
		if (m % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}

		sc.close();

	}

}

Measured memory_bytes: 35588
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}


int main(){
		ll n,k;
		cin>>n>>k;
		ll ans = 0;

		for(ll i = k - 1 ; i <= n ; i++){
			ll rem = n-i-1;
			ll first = (i*(i+1))/2;
			ll last = (rem*(rem+1))/2;
			last = (n*(n+1))/2 - last;
			//cout<<first<<" "<<last<<endl;
			ans = (ans + last - first + 1 + mod)%mod;
		}
		cout<<ans<<endl;
}

//0 1 2 3

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define ll long long int
#define pii pair<int,int>
using namespace std;

int main()
{
    int n,mx=0;
    cin>>n;
    ll ans=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        mx=max(mx,x);
        ans+=max(0,mx-x)*1LL;
    }
    cout<<ans;
    return 0;
}


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

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if (abs(c-a)<=d||(abs(b-a)<=d&&abs(c-b)<=d)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

const ll LINF=1e18;

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> A(n),F(n);
    for(ll i=0;i<n;i++) cin >> A[i];
    for(ll i=0;i<n;i++) cin >> F[i];

    sort(A.begin(),A.end());
    sort(F.rbegin(),F.rend());
    // 2分探索
    ll l=-1,r=LINF;
    while(r-l>1){ // 探索区間幅が1になるまで
        ll m=(r+l)>>1; //1bit 右シフト
        ll cnt=0;
        for(ll i=0;i<n;i++){
            if(A[i]*F[i]>m){
                cnt+=ceil((double)(A[i]*F[i]-m)/F[i]); // A[i]について必要な修行回数
                //if((A[i]*F[i]-m)%F[i]) cnt++; //ceilなしならこれが必要
            }
        }
        if(cnt>k) l=m; // kより改善する必要があれば基準を大きく
        else r=m; // kより改善する必要が無ければ基準を小さく
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

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

	long long int hiro = 0;
	for (int i = 0; i < n - 1; i++){
		hiro += min((x[i+1] - x[i]) * a,b);
	}
	cout << hiro << endl;
return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define test(t) int t ; cin>>t ; while(t--)
string s;
int main(){
    cin >> s;
    int ans = 0;
    for(int i = 0 ; i < s.size() ; ++i){
        if(s[i] == '+'){
            ans++;
        }else if(s[i] == '-'){
            ans--;
        }
    }
    cout << ans ;
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <string.h>
using namespace std;
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n=0,a[4]={0};
  cin>>n;
  string ch;
  for(int i=0;i<n;i++)
  {
    cin>>ch;
    if(ch=="AC")
      a[0]++;
    else if(ch=="WA")
      a[1]++;
    else if(ch=="TLE")
      a[2]++;
    else
      a[3]++;
  }
  cout<<"AC"<<" "<<"x"<<" "<<a[0]<<endl;
  cout<<"WA"<<" "<<"x"<<" "<<a[1]<<endl;
  cout<<"TLE"<<" "<<"x"<<" "<<a[2]<<endl;
  cout<<"RE"<<" "<<"x"<<" "<<a[3]<<endl;
  return 0;
}

Measured memory_bytes: 3248
from itertools import count
a,b,c=map(int,input().split())

if a%2 or b%2 or c%2:
  print(0)
else:
  for i in count(1):
    a,b,c=(b+c)/2,(a+c)/2,(a+b)/2
    if a==b==c:
      print(-1)
      break
    elif a%2 or b%2 or c%2:
      print(i)
      break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 1;
  rep(i, n) {
    ans = min(ans*2, ans+k);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#define INF 1e9+10
using namespace std;
map <char,int>leta;
map <char,int>letb;
string s,t;
int num=1,sn[200005],tn[200005],yes=1;
int main(){
    cin>>s;
    cin>>t;
    for(int i=0;i<s.size();i++){
        if(!leta[s[i]])
            leta[s[i]]=num++;
        sn[i]=leta[s[i]];
    }
    num=1;
    for(int i=0;i<t.size();i++){
        if(!letb[t[i]])
            letb[t[i]]=num++;
        tn[i]=letb[t[i]];
    }
    for(int i=0;i<s.size();i++){
        if(sn[i]!=tn[i]||s.size()!=t.size()){
            yes=0;
            break;
        }
    }
    if(yes)
        printf("Yes");
    else
        printf("No");

}


Measured memory_bytes: 4980
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if(x == 1) {
      System.out.println(x);
      return;
    }
    int ans = 0;
    for(int i = 2; Math.pow(i, 2) <= x; i++) {
      for(int j = 2; Math.pow(i, j) <= x; j++) {
        if(ans < Math.pow(i, j)) {
          ans = (int)Math.pow(i, j);
        }
      }
    }
    System.out.println(ans);
  }

}


Measured memory_bytes: 23124
'use strict'
function main(input) {
  input = input.trim().split('\n')
  const N = Number(input.shift())
  input = input[0].split(' ').map(n => Number(n))
  let ans = 0
  for (let i = 0; i < N; i++) {
    ans += input[i] - 1
  }
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n,l,t;
	cin>>n;
	set<long long int> s;
	for(long long int i=2;i*i<=n-1;i++){
		if((n-1)%i==0){
			s.emplace(i);
			s.emplace((n-1)/i);
		}
	}
	for(long long int i=2;i*i<=n;i++){
		if((n%i)==0){
			t=n;
			while(t>=i){
				if(t%i==0)
				t=t/i;
				else t=t%i;
			}
			if(t==1)
			s.emplace(i);
			t=n;l=n/i;
			while(t>=l){
				if(t%l==0)
				t=t/l;
				else t=t%l;
			}
			if(t==1)
			s.emplace(l);
		}
	}
	s.emplace(n);
	if(n>2)
	s.emplace(n-1);
	cout<<s.size()<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//#include<stdint.h>
#include<malloc.h>
#include<x86intrin.h>

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

int main(){
    int a,b,W;
    
    scanf("%d %d %d",&W,&a,&b);
    if(a>b){
        a^=b^=a^=b;
    }
    
    if(a+W > b)
        puts("0");
    else
        printf("%d\n",b-(a+W));

    return 0;
}

Measured memory_bytes: 128