akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n], b[n], G[52], g[52], r, A, B;
    long long Dv[51], Su=0;
    Dv[0] = 1;
    for (int i = 1; i <= 50; i++)
    {
        Dv[i] = Dv[i-1] * 2;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    for (int i = 1; i <= 50; i++)
    {
        G[i] = 1;
    }
    for (int i = 51; i >= 1; i--)
    {
        vector <int> D[52];
        G[i] = 0;
        r = 1;
        for (int y = 1; y <= 50; y++)
        {
            if (G[y] == 1)
            {
                for (int u = 1; u <= 50; u++)
                {
                    D[u].push_back(u%y);
                }
            }
        }
        for (int y = 0; y < n; y++)
        {
            for (int u = 0; u <= 50; u++)
            {
                g[u] = 1;
            }
            g[a[y]] = 0;
            vector <int> T;
            T.push_back(a[y]);
            for (int u = 0; u < T.size(); u++)
            {
                A = T[u];
                for (int j = 0; j < D[A].size(); j++)
                {
                    B = D[A][j];
                    if (g[B] == 1)
                    {
                        g[B] = 0;
                        T.push_back(B);
                    }
                }
            }
            if (g[b[y]] == 1)
            {
                r = 0;
                break;
            }
        }
        if (r == 0)
        {
            G[i] = 1;
            Su += Dv[i];
            if (i == 50)
            {
                cout << -1;
                return 0;
            }
        }
    }
    cout << Su;
    return 0;
}


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

int main() {
  int h,w;
  cin >> h >> w;
  vector<char> c(w);
  for (int i=0;i<h;i++) {
    for (int j=0;j<w;j++) {
      cin >> c.at(j);
      cout << c.at(j);
    }
    cout << endl;
    for (int j=0;j<w;j++) {
      cout << c.at(j);
    }
    cout << endl;
  }
}

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

int main(){
    //---------------
    // input section
    //---------------
    int n, m;
    std::cin >> n >> m;

    std::vector<std::string> vlvs;
    for(int i = 0; i < m; ++i){
        int k;
        std::cin >> k;
        std::string str(10, '0');
        for(int j = 0; j < k; ++j){
            int val;std::cin >> val;
            ++str.at(10 - val);
        }
        vlvs.push_back(str);
    }

    std::vector<int> p(m);
    for(int i = 0; i < m; ++i){
        std::cin >> p.at(i);
    }

    //--------------------
    // processing section
    //--------------------
    int count = 0;
    for(int i = 0; i < std::pow(2, n); ++i){
        bool flg = true;
        std::bitset<10> numBt(i);
        for(int j = 0; j < m; ++j){
            std::bitset<10> refBt(vlvs.at(j));
            refBt &= numBt;
            if(refBt.count() % 2 != p.at(j)){
                flg = false;
                break;
            }
        }
        
        if(flg){
            ++count;
        }
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports, non_snake_case)]
use proconio::{
    input, fastout,
    marker::{Chars, Bytes, Usize1}
};

#[fastout]
fn main() {
    input!{
        N: usize
    }
    let mut g = vec![1; N];
    for i in 1..N {
        for j in 2..(N-1)/i+1 {
            g[j*i] += 1
        }
    }
    println!("{}", g.iter().sum::<u64>() - 1);
}


Measured memory_bytes: 9920
using System;

class Problem_A
{
  public static void Main(string[] args)
  {
    var inputs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    int n = inputs[0], a = inputs[1], b = inputs[2];
    Console.WriteLine($"{n * a < b ? n * a : b}");
  }
}


Measured memory_bytes: 13268
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int A, B, C, X, ans;

int main()
{
	in >> A >> B >> C >> X;
	rep(i, A + 1)
	{
		rep(j, B + 1)
		{
			rep(k, C + 1)
			{
				if (500 * i + 100 * j + 50 * k == X) ++ans;
			}
		}
	}
	out << ans << std::endl;
	return 0;
}

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

int main()
{
    int N, M;
    cin >> N >> M;
    int X[M];
    for (int i = 0; i < M; i++)
    {
        cin >> X[i];
    }

    if (N >= M)
    {
        cout << 0 << endl;
        return 0;
    }

    sort(X, X + M);
    int diff[M] = {};
    for (int i = 1; i < M; i++)
    {
        diff[i] = X[i] - X[i - 1];
    }

    sort(diff, diff + M);
    int ans = 0;
    for (int i = 0; i < M - N + 1; i++)
    {
        ans += diff[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
s = input()
list_s = list(s)

max_count = 0
interim = 0

while list_s != []:
  for c in list_s:
    if c == 'A' or c =='T' or c == 'C' or c == 'G':
      interim += 1
    else:
      break
  if max_count < interim:
    max_count = interim
  list_s.pop(0)
  interim = 0
  
print (max_count)

Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if(a==5&&b==5&&c==7||a==5&&b==7&&c==5||a==7&&b==5&&c==5)
    cout<<"YES";
else
    cout<<"NO";
    return 0;
}




Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
using namespace std;
int main(void){
    long long x,y;
    cin>>x>>y;
    int ans=0;
    while(x<=y){
        x*=2;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main() {
	ll x[50] = {};
	ll y[50] = {};
	ll s = (ll)1 << 62;

	ll n, K; cin >> n >> K;
	rep(i, 0, n)cin >> x[i] >> y[i];
	rep(i, 0, n) {
		rep(j, 0, n) {
			rep(k, 0, n) {
				rep(l, 0, n) {
					ll cnt = 0;
					rep(g, 0, n) {
						if (x[i] <= x[g] && x[g] <= x[j] && y[k] <= y[g] && y[g] <= y[l]) {
							cnt++;
						}
					}
					if (cnt >= K) {
						s = min(s, abs(x[i] - x[j]) * abs(y[k] - y[l]));
					}
				}
			}
		}
	}

	cout << s << endl;

	return 0;
}

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

int main() {
    int N,K,Q;
    cin >> N >> K >> Q;
    vector<int> A(Q);
    for ( int i = 0; i < Q; ++i){
        cin >> A.at(i);
    }
    
    map<int,int> B;
    for ( int i = 0; i < Q; ++i){
        B[A.at(i)-1] = B[A.at(i)-1] + 1;
    }
    // B[i] i番目の人の正解数
    
    for ( int i = 0; i < N; ++i){
        int p = K - Q;
        p = p + B[i];
        if ( p > 0 ){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>

int main (void){
    int x=0;
    int y=0;
    int flag=1;

    do{
    	fflush(stdout);
    	scanf("%d %d",&x,&y);
        if((x==0)&&(y==0)){
        	flag--;
        	break;
        }

        if(x<=y){
            printf("%d %d\n",x,y);
        }else if(y<x) {
            printf("%d %d\n",y,x);
        }
    }while(flag);
}


Measured memory_bytes: 2044
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

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

auto sum = 0LL;
    for (int i = 0; i < n; ++i) {
        string x;
        double u;
        cin >> u >> x;
        if (x == "JPY") {
            sum += large(round(u * 1e8));
        }
        if (x == "BTC") {
           sum += large(round(u * 380'000 * 1e8));
        }
    }

    auto whole = sum / 100'000'000LL;
    auto fract = sum % 100'000'000LL;
    printf("%lld.%08lld\n", whole, fract);

    return 0;
}


Measured memory_bytes: 3712
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }

////////////////////////////////////////////////////////////////

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = pow(10, 9) + 7;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};


////////////////////////////////////////////////////////////////

int main(void) {
	double N;
	cin >> N;

	int ans = ceil(N / 2);

	cout << ans << endl;

}


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

typedef map<string, int>::iterator mitr;

map<string, int> cnt;

int main(int argc, char** argv)
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=0; i<n; i++)
	{
		string s;
		cin>>s;
		cnt[s] ++;
	}
	int maxcnt = -1;
	for(mitr it=cnt.begin(); it!=cnt.end(); it++)
		if(it -> second > maxcnt)
			maxcnt = it -> second;
	for(mitr it=cnt.begin(); it!=cnt.end(); it++)
		if(it -> second == maxcnt)
			cout<<it -> first<<endl;
	return 0;
}

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

ans = 1
tt, xx, yy = 0, 0, 0
for i in range(n):
    t, x, y = map(int, input().split())
    keep = abs(xx - x) + abs(yy - y) - (t - tt)
    if (keep > 0) | (keep % 2 != 0):
        ans *= 0
    tt, xx, yy = t, x, y
print(['No', 'Yes'][ans])


Measured memory_bytes: 9072
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////


int main() {

	ll N;
	cin >> N;

	ll A[MAX];
	repn(i, N) cin >> A[i];

	ll sum[MAX] = {};
	repn(i, N) sum[i] = sum[i - 1] + A[i];

	ll ans = INF;

	for(ll c=2; c<=N-2;c++) {//cはCの一番大きなindex
		ll ge = 0;
		ll jo = c;
		while (jo > ge + 1) {
			ll m = (ge + jo) / 2;
			if (sum[m] * 2 < sum[c]) { ge = m; }
			else { jo = m; }
		}

		ll b = ge;
		if (sum[c] - sum[ge] * 2 > sum[jo] * 2 - sum[c]) { b = jo; }


		ge = c;
		jo = N;
		while (jo > ge + 1) {
			ll m = (ge + jo) / 2;
			if ((sum[m] - sum[c]) * 2 < sum[N] - sum[c]) { ge = m; }
			else {jo = m;}
		}

		ll d = ge;
		if (sum[N] + sum[c] > sum[jo] + sum[ge]) { d = jo; }


		ll p = sum[b];
		ll q = sum[c] - sum[b];
		ll r = sum[d] - sum[c];
		ll s = sum[N] - sum[d];
		ll v = max(p, max(q, max(r, s))) - min(p, min(q, min(r, s)));

		
		ans = min(v, ans);
	}

	cout << ans;
	
	system("PAUSE");
}

Measured memory_bytes: 12024
#include<bits/stdc++.h>
using namespace std;
double dp[3001][3001];
double solve(vector<double>& arr,int N,int i,int x)
{
  
  	if(x==0)
    {
      return 1;
    }
  if(i==0)
    return 0;
  if(dp[i][x]> -0.9)
    return dp[i][x];
  
  
    return dp[i][x]=arr[i]*solve(arr,N,i-1,x-1) + (1-arr[i])*solve(arr,N,i-1,x);
}

int main()
{
  int N;
  cin>>N;
  vector<double> arr(N+1);
  for(int i=1;i<=N;i++)
    cin>>arr[i];
  memset(dp,-1,sizeof dp);
  int x=(N+1)/2;
  cout<<fixed<<setprecision(10)<<solve(arr,N,N,x);
  
  return 0;
}

Measured memory_bytes: 74376
#include <stdio.h>
#include <string.h>

int main(void)
{
	char n[1010];
	int num1[100], num2[100], up[100];
	int i, j, max;
	int roop1, roop2, ch;
	int carry;
	
	scanf("%d", &roop1);
	
	for (roop2 = 0; roop2 < roop1; roop2++){
		//ツ　ツ配ツ療アツ渉可甘コツ可サ
		memset(num1, 0, sizeof(num1));
		memset(num2, 0, sizeof(num2));
		memset(up, 0, sizeof(up));
		max = 0;
		
		scanf("%s", n);
		ch = strlen(n);
		if (ch > 80){
			scanf("%s", n);
			goto error;
		}
		max = ch;
		i = 0;
		for (j = (ch - 1); -1 < j; j--){
			num1[i] = (n[j] - '0');
			// printf("%dツ：ツ：%dツ＼n", i, num1[i]);
			i++;
		}
		
		scanf("%s", n);
		ch = strlen(n);
		if (ch > 80){
			goto error;
		}
		
		if (max <= ch) { max = ch; }
		i = 0;
		for (j = (ch- 1); -1 < j; j--){
			num2[i] = (n[j] - '0');
			// printf("%dツ：ツ：%dツ＼n", i, num2[i]);
			i++;
		}
		

		for(i = 0; i < 80; i++){
			num1[i] = num1[i] + num2[i];
			num1[i + 1] += num1[i] / 10;
			num1[i] %= 10;
		}
		
		if (num1[max] == 0){
			max--;
		}
		if (num1[80] == 0){
			for (i = max; -1 < i; i--){
				printf("%d", num1[i]);
			}
			printf("\n");
		}
		else {

error:
			printf("overflow\n");
		}
	}
	
	return (0);
}

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

int main() {
    int m;
    cin >> m;
    long a = 0, b = 0;
    for(int i = 0; i < m; i++) {
        long d, c;
        scanf("%ld%ld", &d, &c);
        a += c, b += d * c;
    }
    cout << a - 1 + (b - 1) / 9 << endl;
    return 0;
}


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

int main(){
    int w,h,x,y,r;
    cin >>w>>h>>x>>y>>r;
    int count=0;
    if(x<r||x>w-r)
    count++;
    if(y<r||y>h-r)
    count++;
    if(count>0)
    puts("No");
    else
    puts("Yes");
}


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



int main(){
  long long N, M, i, Sum = 0;
  cin >> N;
  vector<long long> A(N);
  vector<long long> NumBuka(N, 0);
  
  for(i = 0; i < N - 1; i++) cin >> A.at(i);
  
  for(i = 0; i < N - 1; i++){
    
    NumBuka.at(A.at(i) - 1)++;
  }
  
  for(i = 0; i < N; i++){
    cout << NumBuka.at(i) << endl;
  }

  return 0;
}

Measured memory_bytes: 6428
N, M = map(int, input().split())
sc_list = []
for i in range(M):
    sc = list(map(int, input().split()))
    sc_list.append(sc)
ans = -1
for i in range(10**N):
    tmp = str(i)
    if len(tmp)==N:
        flag = True
        for j in sc_list:
            if int(tmp[j[0]-1])!=j[1]:
                flag = False
        if flag:
            ans = int(tmp)
            break
print(ans)

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

const lli MOD = 998244353;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;


int main() {
	array<int, 3>arr;
	cin >> arr[0] >> arr[1] >> arr[2];
	sort(arr.begin(), arr.end());
	if (arr[0] == arr[1] && arr[0] == 5 && arr[2] == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	
	return 0;
}


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

using namespace std;

typedef long long int Int;

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

int main(void)
{
    Int n;
    Int one,two;
    cin>>n;

    one = 1;
    two = 1;
    for(int i = 0;i < n;i++)
    {
	Int t,a;
	cin>>t>>a;

	Int n = max((one+t-1)/t,(two+a-1)/a);
	
	one = n*t;
	two = n*a;
    }

    cout<<one+two<<endl;

    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,E,T;
ll X[202020];
template<class V,int NV> class SegTree_1 {
public:
	vector<V> val;
	static V const def=1LL<<60;
	V comp(V l,V r){ return min(l,r);};
	
	SegTree_1(){val=vector<V>(NV*2,def);};
	V getval(int x,int y,int l=0,int r=NV,int k=1) {
		if(r<=x || y<=l) return def;
		if(x<=l && r<=y) return val[k];
		return comp(getval(x,y,l,(l+r)/2,k*2),getval(x,y,(l+r)/2,r,k*2+1));
	}
	void update(int entry, V v) {
		entry += NV;
		val[entry]=v;
		while(entry>1) entry>>=1, val[entry]=comp(val[entry*2],val[entry*2+1]);
	}
};

SegTree_1<ll,1<<20> st1,st3;

ll R[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>E>>T;
	
	
	x=0;
	X[N+1]=E;
	for(i=1;i<=N;i++) cin>>X[i];
	
	st1.update(0,0);
	st3.update(0,-2*X[1]);
	for(i=1;i<=N;i++) {
		while(2*(X[i]-X[x+1])>T) x++;
		
		R[i]=min(3*X[i]+st3.getval(0,x), X[i]+T+st1.getval(x,i));
		st1.update(i,R[i]-X[i]);
		st3.update(i,R[i]-(X[i]+2*X[i+1]));
		
	}
	
	cout<<R[N]+E-X[N]<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

int count(int N) {
  int i,count=0;
  
  for(i=N;i>0;i/=10) {
    count++;
  }
  
  return count;

}

int main() {
  int N,i,sum=0;
  
  cin >> N;
  
  for(i=1;i<=N;i++) {
    if(count(i)%2==1) sum++;
  }
  
  cout << sum;
  
  return 0;
}

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

int grid[10][1000], n, m, k;

vector<int> get(int x, int y) {
	vector<int> ans(m);
	
	for(int c = 0; c < m; c++) {
		for(int r = x; r < y; r++) {
			ans[c] += grid[r][c];
		}
	}
	
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> m >> k;
	
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		for(int j = 0; j < m; j++) {
			grid[i][j] = s[j] - '0';
		}
	}
	
	int ans = n*m;
	
	for(int s = 0; s < (1<<(n-1)); s++) {
		vector<vector<int>> rows;
		vector<int> hor = {0};
		
		for(int i = 0; i < n - 1; i++) {
			if(s >> i & 1) {
				hor.push_back(i+1);
			}
		}
		
		hor.push_back(n);
		
		for(int i = 1; i < (int) hor.size(); i++) {
			rows.push_back(get(hor[i-1], hor[i]));
		}
		
		int cur = __builtin_popcount(s);
		
		bool bad = false;
		for(auto& v : rows) {
			for(int x : v) {
				if(x > k) {
					bad = true;
				}
			}
		}
		if(bad) continue;
		
		vector<int> sum(rows.size());
		
		for(int i = 0; i < m; i++) {
			bool need = false;
			
			for(int j = 0; j < (int) rows.size(); j++) {
				if(sum[j] + rows[j][i] > k) {
					need = true;
				}
			}
			
			if(need) {
				cur++;
				for(int j = 0; j < (int) rows.size(); j++) {
					sum[j] = rows[j][i];
				}
			} else {
				for(int j = 0; j < (int) rows.size(); j++) {
					sum[j] += rows[j][i];
				}
			}
		}
		
		ans = min(ans, cur);
	}
	
	cout << ans << endl;
	
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
class fenwick {
	vector<int> t;
	public:
		fenwick() {
			t.resize(500001);
		}
		void add(int p, int v) {
			for(; p < (int)t.size(); p += p & -p) {
				t[p] += v;
			}
		}
		int query(int p) {
			int ret = 0;
			if(p < 0) {
				return 0;
			}
			for(; p; p -= p & -p) {
				ret += t[p];
			}
			return ret;
		}
};
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n, q;
	string s;
	cin >> n >> s >> q;
	vector<fenwick> A;
	A.resize(26);
	for(int i = 0; i < n; ++i) {
		A[s[i] - 'a'].add(i + 1, 1);
	}
	while(q--) {
		int type;
		cin >> type;
		if(type == 1) {
			int i;
			char c;
			cin >> i >> c;
			A[s[i - 1] - 'a'].add(i, -1);
			A[c - 'a'].add(i, 1);
			s[i - 1] = c;
		}
		if(type == 2) {
			int l, r;
			cin >> l >> r;
			int ans = 0;
			for(int i = 0; i < 26; ++i) {
				if(A[i].query(r) - A[i].query(l - 1) > 0) {
					++ans;
				}
			}
			cout << ans << '\n';
		}
	}
	return 0;
}


Measured memory_bytes: 51740
/*
	Created by Faisal Ahmed
*/

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;

int temp[200010];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	ll a, b;
	
	cin >> a >> b;
	
	ll d = (a * b) / __gcd(a, b);
	
	cout << d << endl;
	
	return 0;
} 

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



#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;
int a,b,c,d;
int k1,k2;

int main(){
  cin >> a >> b;
  int kotae = a;
  if(a>b) kotae --;
  cout << kotae << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[200010];
int main(){
      long long n,m,i,ans=0;
      cin>>n;
      for(i=1;i<=n;i++){
          scanf("%lld",&a[i]);
          a[i]-=i;
      }
      sort(a+1,a+n+1);
      m=a[(n-1)/2+1];
      for(i=1;i<=n;i++)
        ans+=abs(m-a[i]);
      cout<<ans<<endl;
      return 0;
}

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

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    string s,t;
    cin >> s >> t;
    int a[26][26];
    for(int i = 0; i < 26; i++){
        for(int j = 0; j < 26; j++){
            a[i][j] = 0;
        }
    }
    for(int i = 0; i < s.size(); i++){
        int x = s[i] - 'a',y = t[i] - 'a';
        a[x][y]++;
    }
    bool can = true;
    for(int i = 0; i < 26; i++){
        int cnt = 0;
        for(int j = 0; j < 26; j++){
            if(a[i][j] > 0) cnt++;
        }
        if(cnt > 1) can = false;
    }
    for(int i = 0; i < 26; i++){
        int cnt = 0;
        for(int j = 0; j < 26; j++){
            if(a[j][i] > 0) cnt++;
        }
        if(cnt > 1) can = false;
    }
    
    if(can) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 776
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

// https://atcoder.jp/contests/abc167/tasks/abc168_a
func main() {

	data := readLines()

	a, _ := strconv.Atoi(data[0][0])
	b, _ := strconv.Atoi(data[0][1])
	h, _ := strconv.Atoi(data[0][2])
	m, _ := strconv.Atoi(data[0][3])

	// Aが指している角度を算出
	// 単身は 360° / 12*60分 で 回る
	aKakudo := (float64(360) / float64(12*60)) * float64(h*60+m)
	// Bが指している角度を算出
	// 長身は 360° / 60分 で 回る
	bKakudo := float64(360 / 60 * m)

	kakudoDelta := math.Abs(aKakudo - bKakudo)

	kakudo := kakudoDelta
	if kakudoDelta == 180 {
		// 針が伸びているときは短針 + 長針
		fmt.Println(a + b)
		return
	} else if kakudoDelta > 180 {
		// 三角形の１つの角度は 180未満(逆をとる
		kakudo = 360 - kakudoDelta
	}
	// 余弦定理を適応する
	// a^2 = b^2+c^2 -2bccosA
	ans := math.Sqrt(math.Pow(float64(a), 2) + math.Pow(float64(b), 2) - float64(2)*(float64(a)*float64(b)*math.Cos(kakudo*math.Pi/180)))
	fmt.Println(ans)
}

func readLines() [][]string {
	var result [][]string
	for i := 0; ; i++ {
		line, e := readLine()
		if e != nil {
			break
		}
		result = append(result, strings.Split(line, " "))
	}
	return result
}

func readLine() (string, error) {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			return "", e
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf), nil
}


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

using Graph = vector<vector<int>>;
vector<int> color;
//int judge = -1;

bool dfs(const Graph &G, int v, int c) {
  color[v] = c;
  for (auto nv : G[v]) {
    if (color[nv] == -c) continue;
    else if (color[nv] == c) {
      //judge = 1;
      return false;
    }
    else {
      if(!dfs(G, nv, -c)) return false;
    }
  }
  return true;
}

int main() {
  int64_t N, M;
  cin >> N >> M;
  
  Graph G(N);
  
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  color.assign(N, 0);
  
  if (dfs(G, 0, 1)) {
    int64_t count_1 = 0;
    for (int i = 0; i < N; i++) {
      if (color[i] == 1)
        count_1++;
    }
    
    int64_t a = count_1 * (N - count_1) - M;
    cout << a << endl;
  }
  else {
    int64_t b = N * (N - 1) / 2 - M;
    cout << b << endl;
  }
}
    

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  char p;
  cin>>p;
  if(p=='a'||p=='i'||p=='u'||p=='e'||p=='o'){

  cout<<"vowel"<<endl;

  }else{

  cout<<"consonant"<<endl;

  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int d[] = {1,0,-1,0,1};

int main(){
  int h,w;
  cin>>h>>w;
  char C[1010][1010];
  for(int i=1; i<=h; i++){
    for (int j=1; j<=w; j++) cin >> C[i][j];
  }
  int V[1010][1010] = {0};

  queue<pii> Q;
  for(int i=1; i<=h; i++){
    for (int j=1; j<=w; j++){
      if (C[i][j] == '#'){
        V[i][j] = 1;
        Q.push(make_pair(i,j));
      }
    }
  }

  while(!Q.empty()){
    int tmp_h = Q.front().first;
    int tmp_w = Q.front().second;
    Q.pop();
    rep(i,4){
      if (V[tmp_h+d[i]][tmp_w+d[i+1]] == 0 && tmp_h+d[i] >= 1 && tmp_h+d[i] && tmp_h+d[i] <= h
        && tmp_w+d[i+1] >= 1 && tmp_w+d[i+1] <= w){
        V[tmp_h+d[i]][tmp_w+d[i+1]] = V[tmp_h][tmp_w] + 1;
        Q.push(make_pair(tmp_h+d[i], tmp_w+d[i+1]));
      }
    }
  }
  int ans = -1;
  for(int i=1; i<=h; i++){
    for (int j=1; j<=w; j++){
      ans = max(ans, V[i][j]);
    }
  }
  cout << ans - 1 << endl;
}


Measured memory_bytes: 16168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;

int main(void){
    ll k,a,b;
    cin>>k>>a>>b;
    if(b-a<=2){
        cout<<k+1<<endl;
    }
    else{
        ll x=k-(a-1);
        ll ans=a;
        if(x%2==1){
            x--;
            ans++;
        }
        ans+=(b-a)*x/2;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3620
import sys

la = list(map(int, input().split()))
lb = list(map(int, input().split()))
t = int(input())


dis = abs(la[0] - lb[0])

if la[1] - lb[1] > 0:
    if dis / (la[1] - lb[1]) <= t:
        print("YES")
        sys.exit()
print("NO")


Measured memory_bytes: 9188
fun main(args : Array<String>) {
    val input = readLine()!!.split(" ").map(String::toInt)
    val d = input[0]
    var n = input[1]

    var x = 0
    if (n == 100) {
        n++
    }
    if (d == 0) {
        x = n
    } else if (d == 1) {
        x = 100 * n
    } else {
        x = 10000 * n
    }

    println(Integer.toString(x))
}


Measured memory_bytes: 37872
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define maxn 15
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,l[maxn];

int main(){
	scanf("%d",&n);
	for(int i = 1;i <= n;i++) scanf("%d",&l[i]);
	sort(l + 1,l + n + 1);
	for(int i = 1;i < n;i++) l[i] += l[i - 1];
	if(l[n] < l[n - 1]) puts("Yes");
	else puts("No");
	return 0;
}


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

using namespace std;

int main(void){
    long long a,b,k;

    cin >> a >> b >> k;

    a -= k;
    if(a < 0){
        b += a;
        a = 0;
    }

    if(b < 0)
        b = 0;

    cout << a << " " << b << endl;

    return 0;
}

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

struct edge {
    int from, to;
    int cost;
};

struct vert {
    vector<edge> edges;
};

void dijkstra(
        const vector<vert>& verts,
        int initPoint,
        vector<long long>& dist,
        vector<long long>& prev
        ) {
    typedef pair<long long, int> P;
    priority_queue<P, vector<P>, greater<>> q;
    vector<bool> done(verts.size(), false);
    q.push(P(0, initPoint));
    dist[initPoint] = 0;
    prev[initPoint] = initPoint;
    while (!q.empty()) {
        auto info = q.top(); q.pop();
        int current = info.second;

        if (done[current]) continue;
        done[current] = true;
        for (const auto& e: verts[current].edges) {
            if (done[e.to]) continue;
            if (dist[e.to] > dist[current] + e.cost) {
                dist[e.to] = dist[current] + e.cost;
                prev[e.to] = current;
                q.push(P(dist[e.to], e.to));
            }
        }
    }
}

int main() {
    int V, E, r;
    cin >> V >> E >> r;
    vector<long long> dist(V, 1000000000);
    vector<long long> prev(V, -1);
    vector<vert> verts(V);
    for (int i = 0; i < E; ++i) {
        int from, to, cost;
        cin >> from >> to >> cost;
        verts[from].edges.push_back(edge{from: from, to: to, cost: cost});
    }
    dijkstra(verts, r, dist, prev);
    for (int i = 0; i < V; ++i) {
        if (prev[i] == -1) cout << "INF" << endl;
        else cout << dist[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 17528
fir=0
sec=0
thi=0

for a in range(0,10):
        a=input()
        if a >= fir:
                sec,thi = fir,sec
                fir = a
        elif a >= sec:
                thi = sec
                sec = a
        elif a >= thi:
                thi = a

print fir
print sec
print thi

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

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

    int count=0;
    rep(i, s.size()) {
        if (s.at(i) != t.at(i))
            count++;
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3916
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int):
    print(YES if M==N else NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

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

  int ans1 = 0, ans2 = 0, ans3 = 0;

  if(s[0] == 'A') ans1++;

  int size = s.length();

  int flag = 0;

  for(int i = 2; i < size - 1; i++){
    if(s[i] == 'C'){
      if(flag){
        ans2 = 0;
      }else{
        flag = 1;
        ans2++;
      }
    }
  }

  for(int i = 1; i < size; i++){
    if(s[i] >= 'A' && s[i] <= 'Z'){
      ans3++;
    }
  }
  if(ans2 > 0 && ans3 > 1) ans3 = 0;

  if(ans1 && ans2 && ans3)cout << "AC";
  else cout << "WA";

}


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

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

int main(){
  int N;
  cin >> N;
  using mint = modint<(int)1e9+7>;
  mint s = 0, d = 0;
  for(int i = 0; i < N; ++i){
    long long a;
    cin >> a;
    s += a;
    d += a*a;
  }
  s *= s;
  s -= d;
  s /= 2;
  cout << s << endl;
}


Measured memory_bytes: 3632
#include <vector>
#include <map>
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;

int n, maxw;
ll dp[100005];

int main() {
    cin >> n >> maxw;
    for (int i=1; i <= 100000; i++) dp[i]=1e9+1;
    for (int i=0; i < n; i++) {
        int w, v;
        cin >> w >> v;
    
        for (int i=100000; i >= v; i--) {
            dp[i] = min(dp[i], dp[i-v]+w);
        }
    }

    int res = 100000;
    while (dp[res] > maxw) res--;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3880
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;

	if(a>=(b+c))
	{
		  cout<<"0"<<endl;
	}
	else{

		 cout<<((b+c)-a)<<endl;
    }
    return 0;
   }


Measured memory_bytes: 256
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define f first
#define s second
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define fast 
#define f first
#define s second
#define endl "\n"
#define pie 3.1415926535

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(a>0 && c>0){
        c = c-b;
        if(c<=0)
            break;
        a = a-d;
//        cout << a <<" " <<c <<endl;
    }
    int flag;
    int ans = (a>0)?1:0;
    if(ans==1)
        cout << "Yes";
    else
        cout << "No";
        
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

static const long long MOD = 1000000007;
static const long long INF = 1<<31;

int ans;
int n, k;
int c[105];

int main(void) {
    cin >> n >> k;
    rep(i, 0, k) {
        int d;
        cin >> d;
        rep(i, 0, d) {
            int a;
            cin >> a;
            c[a]++;
        }
    }

    rep(i, 1, n+1)if (c[i]==0) ans++;

    

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3636
import sys
import heapq
input = sys.stdin.readline
def main():
    n,k = map(int, input().split())
    sushi = [tuple(map(int, input().split())) for _ in range(n)]
    sushi = sorted(sushi, key=lambda x: x[1], reverse=True)
    species = set()
    val = 0
    dup = []
    # dの大きい順に計算する
    for t,d in sushi[:k]:
        # ネタが被った寿司の点を持っておく(この部分を他のネタの寿司と入れ替える)
        if t in species:
            dup.append(d)
        species.add(t)
        val += d
    ans = val + len(species)**2

    for t,d in sushi[k:]:
        if len(dup)==0:
            break
        # 同じネタはすでに最大になるように選んでいるのでパス
        # 種類は減らない
        if t in species:
            continue
        species.add(t)
        removal = dup.pop()
        val += d - removal
        ans = max(ans, val + len(species)**2)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20044
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<chrono>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds; 
#define lli long long int
#define fr(i,a,b) for(lli i=a;i<b;i++)
#define bfr(i,a,b) for(lli i=a;i>=b;i--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
#define tc int t;cin>>t;while(t--)
#define mod 1000000007LL
#define mod2 998244353LL
#define all(vec) vec.begin(),vec.end()  
#define ld long double
#define pb push_back
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 


int main()
{
   
                        
     fio
     
      lli n;
      cin>>n;
      lli a[n];
      fr(i,0,n)cin>>a[i];

      lli ans=0;
      fr(i,0,n)
      fr(j,i+1,n)
      fr(k,j+1,n)
      if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k])
      {if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[k]+a[j]>a[i]){//cout<<i+1<<" "<<j+1<<" "<<k+1<<'\n';
  ans++;}}

      cout<<ans<<'\n';




      






     





    
        


   

     
     




     

     
     


     

     
     
     

     
      
     





      


            
    
        
      









    

    
     
     



     



     


     
    
     




      
     

     
              


return 0;}    


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

struct process{
    string name;
    int time;
};

// main
int main(){
   // 入力
    int n, quantum;
    cin >> n >> quantum;

    deque< process > process_que, finished_process;

    for (int i = 0; i < n; i++){
        process p; // first: process name, second: rest time
        cin >> p.name >> p.time;
        process_que.push_back(p);
    }

    int current_time = 0;

    while( !process_que.empty() ){
        // プロセスの時間が quantum で処理しきれたら，finished_processにpushする
        if ( (process_que.front().time - quantum) <= 0){
            current_time += process_que.front().time;
            finished_process.push_back( process{process_que.front().name, current_time} );
            process_que.pop_front();

        // プロセスの時間が quantum で処理しきれなかったら，process_queの後ろに後ろにpushし，先頭からpopする．
        }else if ((process_que.front().time - quantum) > 0){
            current_time += quantum;
            process_que.front().time = process_que.front().time - quantum;
            process_que.push_back( process_que.front() );
            process_que.pop_front();
        }
    }

    while( !finished_process.empty() ){
        cout << finished_process.front().name << " " << finished_process.front().time << "\n";
        finished_process.pop_front();
    }
    return 0;
}





Measured memory_bytes: 6232
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)
int INF=1e9;
const long long mod=1e9+7;

int main(){
  int x;
  cin>>x;
  if(x<1200){
    cout<<"ABC"<<endl;
  }
  else{
    cout<<"ARC"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int M,N;
char A[50][50],B[50][50];
int main(){
  cin >> N >> M;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cin >> A[i][j];
    }
  }
  for(int i=0;i<M;i++){
    for(int j=0;j<M;j++){
      cin >> B[i][j];
    }
  }
  for(int i=0;i<=N-M;i++){
    for(int j=0;j<=N-M;j++){
      int count=0;
      for(int k=i;k<=i+M-1;k++){
        for(int l=j;l<=j+M-1;l++){
          if(A[k][l]==B[k-i][l-j]) count++;
          //cout << count << endl;
        }
      }
      if(count==M*M){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;
int n;

int main() {
	scanf("%d", &n);
	double maxT = 0;
	for(int i = 1; i <= n; i++) {
		for(int j = 2; j <= n; j++) {
			if(pow(i * 1.0, j) <= (double)n && pow(i * 1.0, j) > maxT) maxT = pow(i, j);
		}
	}
	if(n == 1) puts("1");
	else printf("%.0lf\n", maxT);
}

Measured memory_bytes: 384
#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <climits>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <deque>
#include <list>
#include <map>
#include <set>
using namespace std;

/*** typedef ***/
typedef long long LL;
typedef unsigned int ui;
typedef unsigned long long ULL;
typedef pair < int , int > ii;
typedef pair < LL  , LL  > ll;
typedef vector <int>  vint;
typedef vector <bool> vbool;
typedef vector <long> vlong;

/*** define ***/
#define sz(x)			((int)x.size())
#define tin(x)			scanf("%d",&x)
#define all(x)			x.begin(),x.end()
#define Set(b,a)		memset(b,a,sizeof b)
#define print1(x)		printf("Case %d:",x++)
#define tin2(x,y)		scanf("%d%d",&x,&y)
#define tin3(x,y,z)		scanf("%d%d%d",&x,&y,&z)
#define loop(i,i0,in)	for(int i=i0 ; i<in ; i++)
#define rep(i,n)		for(int i=0 ; i<(n) ; i++)
#define _rep(i,n)		for(int i=n-1 ; i>=0 ; i--)
#define _loop(i,in,i0)	for(int i=in-1 ; i>=i0 ; i--)
#define Fore(it, x)		for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
     
int main()  
{  
#ifdef Online_Judge
	freopen("a.in","r",stdin);
#endif
	LL n;
	cin >> n;
	cout << n*n*n << endl;
	return 0;
}

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

import sys
sys.setrecursionlimit(300000)

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(N: int, A: "List[int]"):
    A.sort()
    for i in range(1, len(A)):
        if A[i] == A[i - 1]:
            print(NO)
            return
    print(YES)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 28044
#b
n,k =map(int, input().split())
sp = [input().split() for _ in range(k*2)]
get = []
for i in range(1,len(sp),2):
    for j in range(len(sp[i])):
        get.append(sp[i][j])
result = list(set(get))
print(n-len(result))

Measured memory_bytes: 9660
#include <iostream>
#include <math.h>

bool judge_prime(int num)
{
    if (num == 2 || num == 3) {
        return true;
    }


    for (int i = 2; i <= sqrt(num); i++) {

        if (num % i == 0) {
            return false;
        }
    }
    return true;
}


int main()
{

    int num;
    std::cin >> num;

    int list[num];
    for (int i = 0; i < num; i++) {
        std::cin >> list[i];
    }

    int result = 0;
    for (int i = 0; i < num; i++) {
        if (judge_prime(list[i])) {
            result++;
        }
    }
    std::cout << result << std::endl;
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,n;
  cin >> x >> n;
  vector<int> a(102);
  for(int i=0;i<n;i++){
    int q;
    cin >> q;
    a[q] ++;
  }
 if(a[x]==0) {
    cout << x << endl;
  }
  else{
    for(int i=1;i<100;i++){
      if(x-i>=0){
        if(a[x-i]==0) {
          cout << x-i << endl;
          break;
        }
      }  
      if(x+i<=101){
        if(a[x+i]==0) {
          cout << x+i << endl;
          break;
        }
      }
    }
  }
   return 0;   
}

Measured memory_bytes: 3624
import sys
input = sys.stdin.readline
import math

mod = 10**9+7

N = int(input())
As = {}
Empty = 0
for _ in range(N):
    x, y = map(int, input().split())
    g = math.gcd(x, y)
    if g == 0:
        Empty += 1
        continue
    x, y = x//g, y//g
    if y < 0 or (y==0 and x < 0):
        y = -y
        x = -x
    if (x, y) in As:
        As[(x, y)] += 1
    else:
        As[(x, y)] = 1

ans = 1
for (x, y), num in As.items():
    if (-y, x) in As:
        ans = (ans * (pow(2, num, mod) + pow(2, As[(-y, x)], mod) - 1)) % mod
    elif not (y, -x) in As:
        ans = (ans * pow(2, num, mod)) % mod

print((ans-1+Empty)%mod)

Measured memory_bytes: 46196
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <unordered_map>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int odd = 0;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 1) {
			odd++;
		}
	}
	if (odd % 2 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

int main() {
	// your code goes here
	string a, b;
	cin>>a>>b;
	if(b.substr(0, b.length()-1) == a) {
	    cout<<"Yes"<<endl;
	} else {
	    cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

ll N;
ll T[1000];
ll A[1000];

int main(){
    cin>>N;
    rep(i,N) cin>>T[i]>>A[i];

    repn(i,N-1){
        ll m=max((T[i-1]-1)/T[i],(A[i-1]-1)/A[i])+1;
        T[i]*=m;
        A[i]*=m;
    }

    ll ans=T[N-1]+A[N-1];
    cout<<ans<<endl;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int z = scan.nextInt();
		int nx = 0;
		while (x >= y+2*z) {
			x = x - z - y;
			nx++;
		}
		System.out.println(nx);
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int e,m;

  while(cin >> e && e>0){
      m=e;
    for(int z=0; pow(z,3)<=e; z++){
      int pz = pow(z,3);
      for(int y=0; pz+pow(y,2)<=e; y++){
        int x = e - (pz+pow(y,2));
          if(x+y+z<m)
            m=x+y+z;
        }
      }
    cout << m << endl;
  }
}

Measured memory_bytes: 3272