akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
 int main(){

	 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 <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

const long long INF = 1LL << 60;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<pair<ll, ll> > a(N);
  vector<pair<ll, ll> > c(M);
  
  rep(i, N){
    cin >> a[i].first >> a[i].second;
  }

  rep(i, M){
    cin >> c[i].first >> c[i].second;
  }

  ll m = 0, m_len = INF, len;
  rep(i, N){
    m = 0;
    m_len = INF;
    rep(j, M){
      len = abs(a[i].first - c[j].first) + abs(a[i].second - c[j].second);
      if (len < m_len){
        m_len = len;
        m = j + 1;
      }
    }
    print(m);
  }

}


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

#include <iomanip>

using namespace std;

vector<int> db;

int rec(int i, int K) {
  if (db[i] != -1) return db[i];
  if (i >= K) {
    db[i] = 0;
    return 0;
  }
  db[i] = rec(i*2,K)+1;
  return db[i];
}


int main() {
  int i, N, K, a, b, c;
  double ans = 0.0;
  cin >> N >> K;
  db.resize(max(N*2+10, K*2+10));
  fill(db.begin(), db.end(), -1);

  for (i = 1; i <= N; i++) {
    a = rec(i, K);
    b = 1 << a;
    ans += 1.0 / (N*b);
  }

  //cout << std::fixed;
  cout << std::setprecision(12) << ans << endl;
  //cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
def gcd(a,b): return a if b==0 else gcd(b,a%b)

n = int(input())
a = [int(x) for x in input().split()]
pref = [x for x in a]
suff = [x for x in a]
for i in range(1,n):
	pref[i] = gcd(pref[i-1],a[i])
for i in range(n-2,-1,-1):
	suff[i] = gcd(suff[i+1],a[i])

print(max([pref[-2],suff[1]]+[gcd(pref[i-1],suff[i+1]) for i in range(1,n-1)])) 

Measured memory_bytes: 102384
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int h,w;
	bool ans=true;
	cin >>h>>w;
	vector<string> a(h);
	cin >> a;
	map<char, int> dis;
	for(string i : a){
		for(char j:i){
			dis[j]++;
		}
	
	}
	int one = 0;
	int two = 0;
	repi(itr, dis) { //clog << itr->F << " " << itr->S << endl; 
	if(itr->S%2!=0){
		one++;
	}else if(itr->S %4 !=0){
		two++;
	}
	clog << one <<" "<< two << endl;
	if(h%2==0 and w%2==0){
		ans = (one == 0 and two == 0);
	}else if(h%2==1 and w%2==1){
		ans = (one == 1 and two <= (h / 2 + w / 2));
	}else if(h%2==1){
		ans = (one == 0 and two <= (w / 2));
	}
	else{
		ans = (one == 0 and two <= (h / 2));
	}
	}

	cout<<solve(ans)<<endl;
}

/*
5 3
ooxoo
xxtxx
ooxoo

4 5
ooxoo
ooxoo
ooxoo
ooxoo
*/

Measured memory_bytes: 3656
#include <stdio.h>
#include<string.h>
int main(void)
{
	char str[1201];
	char ko[27]={"abcdefghijklmnopqrstuvwxyz"};
	char o[27]={"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
	
	int i,j,suu;
	
	fgets(str,sizeof(str),stdin);
	suu=(int)strlen(str);
	
		for(i=0;i<suu;i++){
			for(j=0;j<26;j++){
				if(str[i]==ko[j]){
					/* i??????????°?????????¨?????????*/
					str[i]=o[j];
					break;
				}else if(str[i]==o[j]){
					str[i]=ko[j];
					break;
				}
			}
			printf("%c",str[i]);
		}
	return 0;
}

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

int main() {
	int N;
	int a[110];
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> a[i];

	sort(a, a + N, greater<int>());
	int Alice = 0;
	int Bob = 0;
	for (int i = 0; i < N; ++i) {
		if (i % 2 == 0) {
			Alice += a[i];
		}
		else {
			Bob += a[i];
		}
	}
	cout << Alice - Bob << endl;
}

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

using namespace std;

typedef long long ll;
const int MAX = 210;
const ll INF = 1e+8;

int N, M, R;
ll res = 1e+8;

vector<int> r(MAX);
vector<vector<ll> > G(MAX, vector<ll>(MAX, INF));
bool used[10];

void dfs(int c, int las, int dist);

int main() {

    cin >> N >> M >> R;
    int r_;
    for (int i = 0; i < R; i++) {
        cin >> r_; r_--; r[i] = r_;
    }
    for (int i = 0; i < N; i++) {
        G[i][i] = 0;
    }
    ll a, b, c;
    for (int i = 0; i < M; i++) {
        cin >> a >> b >> c;
        a--; b--;
        G[a][b] = min(G[a][b], c);
        G[b][a] = min(G[b][a], c);
    }

    // Warshall-Floyd
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }

    // dfs
    dfs(0, -1, 0);
    
    cout << res << '\n';

}

// dfs で順列を全通り試す
void dfs(int c, int las, int dist) {

    if (c == R) {
        if (res > dist) res = dist;
        return;
    }
    for (int i = 0; i < R; i++) {
        if (!used[i]) {
            used[i] = true;
            if (las == -1) dfs(c + 1, i, 0);
            else dfs(c + 1, i, dist + G[r[las]][r[i]]);
            used[i] = false;
        }
    }
}


Measured memory_bytes: 640
import sys
from collections import defaultdict, deque

readline = sys.stdin.readline
n = int(readline())
ab = [None] * (n-1)
G = [list() for _ in range(n)]
for i in range(n-1):
    a, b = map(int, readline().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
    ab[i] = a, b
colors = defaultdict(int)
q = deque([0])
used = [0] * n
used[0] = 10**6
K = 0
while q:
    x = q.popleft()
    c = 1
    for y in G[x]:
        if used[y]:
            continue
        if used[x] == c:
            c += 1
        used[y] = colors[x, y] = colors[y, x] = c
        c += 1
        q.append(y)

print(max(colors.values()))
print('\n'.join(str(colors[i]) for i in ab))


Measured memory_bytes: 61152
N=int(input())
ans=N
for i in range(N+1):
    cnt=0
    t=i
    #print('===6===', i)
    while t>0:
        cnt+=t%6
        t//=6
    #print("cnt : {0}, t : {1}".format(cnt, t))
    j=N-i
    #print('====7===', i)
    while j>0:
        cnt+=j%9
        j//=9
    #print("cnt : {0}, t : {1}".format(cnt, t))
    #print(i, ans, cnt)
    ans = min(ans,cnt)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fo(i,n) for(i=0;i<n;++i)
#define forr(i,n) for(i=n-1;i>0;--i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

ll gcd(ll a,ll b){while(a&&b)a>b?a%=b:b%=a;return a+b;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

string s;
string t1 = "dreamer";
string t2 = "eraser";
string t3 = "dream";
string t4 = "erase";
bool flag = 0;
string previ;
int i;

int main(){
    cin>>s;
    fo(i,s.length()){
        if(s[i]=='e'){
            if((i+4)<s.length() && s[i+1]=='r' && s[i+2]=='a' && s[i+3]=='s' && s[i+4]=='e'){
                if((i+5)<s.length() && s[i+5]=='r'){
                    i = i + 5;
                }
                else
                    i = i + 4;
            }
            else{
                cout<<"NO"<<endl;
                return 0;
            }
        }
        else if(s[i]=='d'){
            if((i+4)<s.length() && s[i+1]=='r' && s[i+2]=='e' && s[i+3]=='a' && s[i+4]=='m'){
                if((i+10)<s.length() && s[i+5]=='e' && s[i+6]=='r' && s[i+7]==  'a' && s[i+8]=='s' && s[i+9]=='e' && s[i+10]=='r')
                    i = i + 10;
                else if((i+9)<s.length() && s[i+5]=='e' && s[i+6]=='r' && s[i+7]==  'a' && s[i+8]=='s' && s[i+9]=='e')
                    i = i + 9;
                else if((i+6)<s.length() && s[i+5]=='e' && s[i+6]=='r'){
                    i = i + 6;
                }
                else
                    i = i + 4;
            }
            else{
                cout<<"NO"<<endl;
                return 0;
            }
        }
        else{
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


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

#define se second
#define fi first
#define mk(a,b) make_pair(a,b)

typedef pair<int,int> pii;

int N;
vector<pii> V;

int main()
{
   cin >> N;
   for(int i = 0; i < N; i++)
   {
       int a, b;
       cin >> a >> b;
       V.push_back(mk(b, a));
   }

   sort(V.begin(), V.end());

   long long tmp = 0;
   for(int i = 0; i < N; i++)
   {
       tmp += V[i].se;
       if(tmp > V[i].fi)
       {
           cout << "No" << endl;
           return 0;
       }
   }

   cout << "Yes" << endl;
   return 0;
}


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

using namespace std;

int main()
{
  	ios::sync_with_stdio(false);
  	cin.tie(NULL);
  	
  	int i, a, b, c, a_, b_, c_;
  	
  	cin >> a >> b >> c;
  	
  	for(i=0; i<1000; i++){
      	if((a & 1) || (b & 1) || (c & 1)) break;
      	a_ = b + c >> 1; b_ = c + a >> 1; c_ = a + b >> 1;
      	a = a_; b = b_; c = c_;
    }
  	
  	if(i < 1000) cout << i << endl;
  	else cout << -1 << endl;
  	
  	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())
ab = [list(map(int,input().split())) for i in range(n-1)]
ans = 0
for i in range(1,n+1):
  ans += i*(n-i+1)
for a,b in ab:
  if a > b:
    a,b = b,a
  ans -= a*(n-b+1)
print(ans)

Measured memory_bytes: 103172
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int n,t_score=0,h_score=0;
    string t_card,h_card;
    cin >> n;
    REP(i,n){
        cin >>t_card >> h_card;
        if(t_card==h_card){
            h_score++;
            t_score++;
        }else if(t_card>h_card){
            t_score+=3;
        }else{
            h_score+=3;
        }
    }
    cout << t_score << " " << h_score << endl;
}


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

using namespace std;

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

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

    vector<int> cnt(n + 1);
    irep(i, n)
    {
        if (i <= 1) {
            cnt[i] = 0;
        } else {
            if (s[i - 1] == 'C' && s[i - 2] == 'A') {
                cnt[i] = cnt[i - 1] + 1;
            } else {
                cnt[i] = cnt[i - 1];
            }
        }
    }

    rep(i, q)
    {
        int l, r;
        cin >> l >> r;
        int result = cnt[r] - cnt[l - 1];
        if (cnt[l] > cnt[l - 1]) {
            result--;
        }
        cout << result << endl;
    }

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define INF            1e9
#define REP(i,n)       for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)      for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPI(i,ini,n)  for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPR(i,n)      for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)     for(lint i=(n);i>0;--i)
#define REPRI(i,ini,n) for(lint i=(ini)-1,i##_len=(n);i>=i##_len;--i)
#define REPC(i,obj)    for(auto i:obj)
#define R_UP(a,b)      (((a)+(b)-1)/(b))
#define ALL(obj)       (obj).begin(),(obj).end()
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
void subset_sum(const string::iterator&first, const string::iterator&last, map<pair<string, string>, lint>&result, pair<string, string> sum = make_pair("", ""))
{
	if (first == last)
	{
		result[sum]++;
		return;
	}
	subset_sum(first + 1, last, result, make_pair(sum.first + *first, sum.second));
	subset_sum(first + 1, last, result, make_pair(sum.first, sum.second + *first));
}
signed main()
{
	lint n = in();
	string s = in<string>();
	reverse(s.begin() + n, s.end());
	map<pair<string, string>, lint>mp1, mp2;
	subset_sum(s.begin(), s.begin() + n, mp1);
	subset_sum(s.begin() + n, s.end(), mp2);
	lint ans = 0;
	REPC(i, mp1)ans += i.second * mp2[make_pair(i.first.second, i.first.first)];
	cout << ans << endl;
}

Measured memory_bytes: 104192
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,i,count = 0;
    cin >> a;
    cin >> b;
    cin >> c;
    for (i = a; i <= b; i++){
    if (c%i == 0) ++count;
    }
    cout << count << endl;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define all(arr) arr.begin(), arr.end()
#define va vector<long long int> a 
#define vb vector<long long int> b
#define debug() for(ll l=0;l<50;l++){}
const ll M = 1e9+7;
const ll inf = 1e18+5;
const ll val = 10000020;
const ll INF=INT_MAX;
using namespace std;
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
ll bs(ll arr[], ll l, ll r, ll x){
	ll mid=0;
    if (r >= l){
		if (arr[mid] == x) return mid; 
        if (arr[mid] > x) return bs(arr, l, mid - 1, x); 
        return bs(arr, mid + 1, r, x); 
    }
    return -1;
}
ll cs(vector<ll> &a,ll x){
	return upper_bound(all(a),x)-a.begin();
}
ll power(ll x,ul y,ll p){
	ll res = 1;
	x = x % p;
	if(x == 0) return 0;
	while (y > 0){
		if (y & 1) res = (res*x) % p;
		y = y>>1;
		x = (x*x) % p;
		}
	return res;
}
ll arr[500000],st[500000];
void buildtree(int si,int ss,int se){
	if(ss==se){
		st[si]=arr[ss];
		return;
	}
	int mid=ss+(se-ss)/2;
	buildtree(2*si,ss,mid);
	buildtree(2*si+1,mid+1,se);
	st[si]=min(st[2*si],st[2*si+1]);
}
int query(int si,int ss,int se,int qs,int qe){
	if(qs>se || qe<ss) //completely outside
		return INF;
	if(ss>=qs && se<=qe)
		return st[si];
	int mid=ss+(se-ss)/2;
	int l=query(2*si,ss,mid,qs,qe);
	int r=query(2*si+1,mid+1,se,qs,qe);
	return min(l,r);
}
void update(int si,int ss,int se,int qi){
	if(ss==se){
		st[si]=arr[ss];
		return;
	}
	int mid=ss+(se-ss)/2;
	if(qi<=mid) update(2*si,ss,mid,qi);
	else update(2*si+1,mid+1,se,qi);
	st[si]=min(st[2*si],st[2*si+1]);
}
ll mm(ll a,ll b,ll mod){ 
    ll res = 0;
    a %= mod; 
    while(b){
        if (b & 1) res = (res + a) % mod; 
        a = (2 * a) % mod; 
        b >>= 1; // b = b / 2 
    } 
    return res; 
} 

void DFS_ITR(vector<vector<ll>>& adj,ll src,vector<ll>& a,vector<ll>& f,vector<ll>& d,ll day,vector<bool>& visited){
	vector<ll>s;
    s.push_back(src);
    vector<ll>s2;
    visited[src]=true;
    while(s.size()>0){
		ll u=s[s.size()-1];
        s.pop_back();
        for(auto c:adj[u]){
            if(!visited[c]){
                ll eat=min(a[src-1],f[c-1]);
                f[c-1]-=eat;
                if(f[c-1]==0 && d[c]==-1) d[c]=day;
                s.push_back(c);
                s2.push_back(c);
                visited[c]=true;
			}
		}
	}
    for(auto i:s2) visited[i]=false;
}
ll nCr(ll n, ll r){
    return (n*(n-1)*(n-2))/6;
}

void solve(){
	ll n;
	cin>>n;
	ll a[n],b[n]={0},sum=0;
	b[n-1]=a[n-1];
	for(ll i=0;i<n;i++){ cin>>a[i]; b[i]=a[i];}
	for(ll i=n-2;i>=0;i--) b[i]=(b[i+1]+b[i])%M;
	for(ll i=0;i<n-1;i++){
		sum=(sum+mm(a[i],b[i+1],M))%M;
	}
	cout<<sum<<"\n";
}
int main(){
	fast;
    ll t=1;
    //cin>>t;
    while(t--) solve();
	return 0;
}



Measured memory_bytes: 6736
import math


def matrix_mul(mx1, mx2):
    n = len(mx1)
    m = len(mx1[0])
    _m = len(mx2)
    l = len(mx2[0])
    if m != _m:
        print("[!] Invalid Matrix Size.")
        return - 1

    ans = [[None] * l for _ in range(n)]

    for i in range(n):
        for j in range(l):
            _e = 0
            for k in range(m):
                _e += mx1[i][k] * mx2[k][j]
            ans[i][j] = _e

    return ans


def roll(p1, p2, r: int):
    """r must be radian"""
    _tmp = [[p2[0] - p1[0]], [p2[1] - p1[1]]]
    rad = math.pi*r/180
    matrix = [[math.cos(rad), -math.sin(rad)], [math.sin(rad), math.cos(rad)]]
    _tmp = matrix_mul(matrix, _tmp)
    return [p1[0]+_tmp[0][0], p1[1]+_tmp[1][0]]


def print_point(p):
    print("%.8f %.8f" % (p[0], p[1]))


def koch_curve(p1, p2, d: int):
    """p1: start point, p2: end point, d: depth of recursive"""
    if d == 0:
        print_point(p2)
    else:
        s = [p1[0] + (p2[0] - p1[0])/3, p1[1] + (p2[1] - p1[1])/3]
        t = [p1[0] + (p2[0] - p1[0])*2/3, p1[1] + (p2[1] - p1[1])*2/3]
        u = roll(s, t, 60)
        koch_curve(p1, s, d - 1)
        koch_curve(s, u, d - 1)
        koch_curve(u, t, d - 1)
        koch_curve(t, p2, d - 1)


n = int(input())
p1, p2 = [0.0, 0.0], [100.0, 0.0]
print_point(p1)
koch_curve(p1, p2, n)



Measured memory_bytes: 5768
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {

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

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			if ((n | m) == 0)
				break;

			int[] t = new int[m + 1];
			for (int i = 1; i <= m; i++) {
				t[i] = scanner.nextInt();
			}
			int[][] p = new int[n][2];
			Deque<Integer> deque = new ArrayDeque<Integer>();
			List<Integer> list = new ArrayList<Integer>();
			int r = 10;
			while (list.size() < m) {
				if (r / 10 <= m && r % 10 == 0) {
					deque.offer(r / 10);
				}
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < 2; j++) {
						if (p[i][j] > 0) {
							t[p[i][j]]--;
						}
					}
				}
				for (int i = 0; i < n; i++) {
					if (p[i][0] > 0 && t[p[i][0]] <= 0) {
						list.add(p[i][0]);
						p[i][0] = p[i][1];
						p[i][1] = 0;
						if (p[i][0] > 0 && t[p[i][0]] <= 0) {
							list.add(p[i][0]);
							p[i][0] = 0;
						}
					}
				}
				loop: while (!deque.isEmpty()) {
					int umin = Integer.MAX_VALUE;
					int dmin = Integer.MAX_VALUE;
					int u = -1;
					int d = -1;
					for (int i = 0; i < n; i++) {
						if (p[i][0] == 0) {
							p[i][0] = deque.poll();
							break loop;
						} else if (p[i][1] == 0) {
							int a = t[p[i][0]] - t[deque.peek()];
							if (a >= 0) {
								if (umin > a) {
									umin = a;
									u = i;
								}
							} else {
								a *= -1;
								if (dmin > a) {
									dmin = a;
									d = i;
								}
							}
						}
					}
					if (u != -1) {
						p[u][1] = p[u][0];
						p[u][0] = deque.poll();
					} else if (d != -1) {
						p[d][1] = p[d][0];
						p[d][0] = deque.poll();
					} else {
						break;
					}
				}
				r++;
			}
			for (int i = 0; i < m; i++) {
				System.out.print(list.get(i));
				System.out.print(i == m - 1 ? '\n' : ' ');
			}

		}
	}
}

Measured memory_bytes: 17208
import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from heapq import *

n, m, s = na()
uvab = nan(m)
cd = nan(n)
maxS = 5007
s = min(s, maxS)

g = [[] for _ in range(n)]
for i in range(m):
    u, v, a, b = uvab[i]
    u -= 1
    v -= 1
    g[u].append((v, (a, b)))
    g[v].append((u, (a, b)))

def dijkstra(g, x):
    dist = [[inf] * (maxS + 1) for _ in range(len(g))]
    dist[x][s] = 0
    q = []
    # proc = [False for _ in range(len(g))]
    heappush(q, (0, (x, s)))
    while len(q):
        p = heappop(q)
        a = p[1][0]
        cost = p[0]
        curS = p[1][1]
        # if proc[a]:
        #	  continue
        # proc[a] = True
        for b in g[a]:
            to = b[0]
            ncost = cost + b[1][1]
            nS = curS - b[1][0]
            if nS >= 0:
                if dist[to][nS] > ncost:
                    dist[to][nS] = ncost
                    heappush(q, (ncost, (to, nS)))
        
        c, d = cd[a]
        cost += d
        curS += c
        curS = min(curS, maxS)
        if dist[a][curS] > cost:
            dist[a][curS] = cost
            heappush(q, (cost, (a, curS)))
    
    return dist

dist = dijkstra(g, 0)
for i in range(1, n):
    ans = inf
    for j in range(maxS):
        ans = min(ans, dist[i][j])
    print(ans)

Measured memory_bytes: 103056
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
ll N;
ll dp[64][3];
int bits[64];

int main() {
	cin >> N;

    fprintf(stderr, "%lld\n", N);
    rep(i, 64){
        bits[i] = N % 2;
        N >>= 1;
    }
    rep(i, 64){ fprintf(stderr, "%d", bits[i]); } fprintf(stderr, "\n");

    dp[63][0] = 1;
    dp[63][1] = 0;
    dp[63][2] = 0;
    for(int i = 62; i>=0; i--){
        if(bits[i] == 1){
            dp[i][2] = dp[i+1][2] * 3 + dp[i+1][1] * 2 + dp[i+1][0] * 0;
            dp[i][1] = dp[i+1][2] * 0 + dp[i+1][1] * 1 + dp[i+1][0] * 1;
            dp[i][0] = dp[i+1][2] * 0 + dp[i+1][1] * 0 + dp[i+1][0] * 1;
        }
        else{
            dp[i][2] = dp[i+1][2] * 3 + dp[i+1][1] * 1 + dp[i+1][0] * 0;
            dp[i][1] = dp[i+1][2] * 0 + dp[i+1][1] * 1 + dp[i+1][0] * 0;
            dp[i][0] = dp[i+1][2] * 0 + dp[i+1][1] * 1 + dp[i+1][0] * 1;
        }
        dp[i][2] %= 1000000007;
        dp[i][1] %= 1000000007;
        dp[i][0] %= 1000000007;
    }

    ll ret = (dp[0][2] + dp[0][1] + dp[0][0]) % 1000000007;
    cout << ret << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[100009],b[100009];
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    long long  n,i,j;
    cin >> n;
    for(i=0;i<n;i++)
        cin >> a[i] >> b[i];
    long long ans = 0LL;

    for(i=n-1;i>=0;i--)
    {
        a[i]+=ans;
        if(a[i]%b[i])
        {
            ans+=(b[i]-a[i]%b[i]);
        }
    }
    cout << ans << endl;

}


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

int main() {

    string a,b,c;

    cin >> a >> b >> c;

    int d,e,f;

    d = static_cast<int>(a[0]);
    e = static_cast<int>(b[0]);
    f = static_cast<int>(c[0]);

    char g,h,i;

    g = static_cast<char>(d-32);
    h = static_cast<char>(e-32);
    i = static_cast<char>(f-32);

    cout << g << h << i << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int[][] A = new int[H][W];
		int[][] diff = new int[H][W];
		for(int i = 0; i < H; i++)
			for(int j = 0; j < W; j++)
				A[i][j] = sc.nextInt();
		for(int i = 0; i < H; i++)
			for(int j = 0; j < W; j++)
				diff[i][j] = Math.abs(A[i][j]-sc.nextInt());
		int M = 80*2*(H+W);
		boolean[][][] dp = new boolean[H][W][M];
		dp[0][0][diff[0][0]] = true;
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				for(int k = 0; k < M; k++) {
					if(dp[i][j][k]) {
						if(i+1 < H) {
							dp[i+1][j][k+diff[i+1][j]] = true;
							dp[i+1][j][Math.abs(k-diff[i+1][j])] = true;
						}
						if(j+1 < W) {
							dp[i][j+1][k+diff[i][j+1]] = true;
							dp[i][j+1][Math.abs(k-diff[i][j+1])] = true;
						}
					}
				}
			}
		}
		for(int i = 0; i < M; i++) {
			if(dp[H-1][W-1][i]) {
				System.out.println(i);
				break;
			}
		}

	}

}

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

using namespace std;
typedef long long ll;

const int N = 200'010;
char t[N];

int main() {
    scanf("%s", t);
    int n = strlen(t);
    for (int i = 0; i < n; i++) {
        if (t[i] == '?') t[i] = 'D';
    }
    printf("%s\n", t);
}


Measured memory_bytes: 3880
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n,k,q;
  cin >> n >> k >> q;
  vector<LL> pts(n, k-q);
  REP(i,q) {
    int x;
    cin >> x;
    --x;
    ++pts[x];
  }
  REP(i,n) {
    if(pts[i]>0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
 #include <math.h>
 #include <string>
 using namespace std;
 
 int main(){
    int N, M;
    int a[52], b[52];
    int i,j;
    int ans[52];
    bool fin = false;

    cin >> N >> M;
    for (i=0; i<M; i++){
        cin >> a[i] >> b[i];
        }

    for (i=0; i<N+1; i++) ans[i]=0;

    for (i=0; i<M; i++){
        ans[a[i]]++;
        ans[b[i]]++;
        }

    for (i=1; i< N+1; i++)
        cout << ans[i] << endl;

    return 0;
 }
 


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int h,i;
	string str;
	getline(cin,str);
	for(i=0;i<str.size();i++){
	if(islower(str[i])){
		str[i]+='A'-'a';
		cout<<str[i];
	}
	else if(isupper(str[i])){
	str[i]+='a'-'A';
	cout<<str[i];
	}
	else{
	cout<<str[i];
	}
	}
	cout<<endl;
return 0;
}

Measured memory_bytes: 3096
a,b,k=map(int,input().split())
cnt=k
while(k>0):
    if a %2==1:
        a-=1
        b+=a//2
        a//=2
        cnt-=1
        # print(a,b,k)
    else:
        b += a // 2
        a//=2
        cnt -= 1

    if cnt==0:
        print(a,b)
        break
    if b %2==1:
            b -= 1
            a += b // 2
            b//=2
            cnt -= 1
            # print(a,b,k)
    else:
        a += b // 2
        b//=2
        cnt -= 1

    if cnt==0:
        print(a,b)
        break


Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
// make pair, tuple
// __gcd(int, int);
// bool isPrime(int n){
//       if(n <= 1)return false;
//       if(n <= 3)return true;
//       if(n % 2 == 0 || n % 3 == 0)return false;
//       for(int i = 5;i * i <= n;i += 6){
//             if(n % i == 0 || n % (i + 2) == 0)return false;
//       }
//       return true;
// }
// int countSubString(string s, string temp){
//       int ans = 0;
//       size_t f = s.find(temp);
//       while(f != string::npos){
//             ans++;
//             f = s.find(temp, f + 1);
//       }
//       return ans;
// }
// 
// #Count leading & trailing zero of an integer bits
// __builtin_clz(n);
// __builtin_clzll(n);
//
// #Count 1s bits of an integer
// __builtin_popcount(n);
// __builtin_popcountll(n);
//
// #Error checking
// assert(n == 3);
// 
// #Error Printing
// cerr << "Some thing";
typedef long long int ll;

int main(){
    ll a,b,c,d;cin >> a >> b >> c >> d;
    ll sum = (b / c) - ((a - 1) / c) + ((b / d) - ((a - 1) / d));
    ll lcm = (c * d) / __gcd(c, d);
    sum -= b / lcm - ((a - 1) / lcm);
    cout << (b - a + 1LL) - sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>

template <class T>
inline void read(T &x)
{
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

long long a, b, c;

int main()
{
    std::cin >> a >> b >> c;
    puts(c - a - b > 0 && (c - a - b) * (c - a - b) > 4 * a * b ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
s=input()
t=input()
n=len(s)
m=len(t)
ans=-1
for i in range(n-m+1):
    sum=0
    for j in range(m):
        if s[i+j]==t[j] or s[i+j]=='?':
            sum+=1
    if sum==m:
        ans=i
if ans==-1:
    print('UNRESTORABLE')
else:
    s=s[:ans]+t+s[ans+m:]
    b=s.replace('?','a')
    print(b)

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

int N, M;
vector<vector<int>> S(10);
vector<int> P(10);
int ans = 0;

int main() {
    cin >> N >> M;

    S.resize(M);
    for (int i = 0; i < M; i++) {
        int k; cin >> k;
        S[i].resize(k);
        for (int j = 0; j < k; ++j) {
			cin >> S[i][j];
			S[i][j]--;
		}
    }

    P.resize(M);
    for (int i = 0; i < M; i++) cin >> P[i];

    // 組み合わせ全探索
    for (int bit = 0; bit < (1 << N); bit++) {
        bitset<10> combo(bit);
        bool flag = true;
        for (int i = 0; i < M; i++) {
            int sum = 0;
            for (int j = 0; j < S[i].size(); j++) {
                int s = S[i][j];
                if (combo.test(s)) sum++;
            }
            if (sum % 2 != P[i]) flag = false;
        }
        if(flag) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1.0);

int main(){
    int a,b,x;
    scanf("%d%d%d",&a,&b,&x);
	if(a*a*b>=(x<<1)){
        printf("%.8f\n",atan((double)a*b*b/(x*2))*180/pi);
    }else{
        printf("%.8f\n",atan((double)(2*b-2.0*x/(a*a))/a)*180/pi);
    }
}


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

typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)

int dp[10001];

void solve() {
	int h, n;
	cin >> h >> n;
	
	fill(dp, dp + h + 1, mod);
	dp[0] = 0;

	rep(i, n) {
		int a, b;
		cin >> a >> b;

		rep(j, h) {
			dp[min(j + a, h)] = min(dp[min(j + a, h)], dp[j] + b);
		}
	}
	cout << dp[h] << endl;
}

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

	solve();

	return 0;
}

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

int main() {
  int Ans=0;
  string A; cin >>A;
  int num=0;
  REP(i,3){

    if (A.at(i)=='R'){
      num+=1;
    }else{
      num=0;
    }
    Ans=max(Ans,num);
  }
  //int B; cin >>B;
  cout << Ans << '\n';
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <iomanip>
#include <stdio.h>
using namespace std;
int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double ans;
    double pi = 3.141592653589793238462643383279;
    if(a*b*a>2*x) ans = 90.0 - atan((2*x/a/b/b))*180/pi;
    else ans = atan((2*(a*b-x/a)/a/a))*180/pi;
    //cout << (double)(2*(a*b-x/a)/a/a)<<endl;
    //cout << setprecision(10)<<ans << endl;
    printf("%2.10f\n", ans);
}

Measured memory_bytes: 888
// Problem : B - Box and Ball
// Contest : AtCoder - AtCoder Grand Contest 002
// URL : https://atcoder.jp/contests/agc002/tasks/agc002_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
    return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
    mem(isprime,true);
    for(ll p=2;p*p<=n;p++)
    {
        if(isprime[p]==true)
        {
            for(ll i=p*p;i<=n;i+=p)
                isprime[i]=false;
        }
    }
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
void solve()
{
 	ll n,m;
 	cin>>n>>m;
 	vector<ll> num(n+1,0);
 	vector<ll> red(n+1,0);
 	rep(i,1,n+1)
 	{
 		red[i]=0;
 		num[i]=1;
 	}   
 	red[1]=1;
 	rep(i,0,m)
 	{
 		ll x,y;
 		cin>>x>>y;
 		if(red[x])
 		{
 			red[y]=1;
 		}
 		num[x]-=1;
 		num[y]+=1;
 		if(num[x]==0)
 		{
 			red[x]=0;
 		}
 	}
 	ll sum=accumulate(all(red),0);
 	cout<<sum;
 	
}
int main()
{
    ll inpoup = 0;
    if(inpoup==1)
    {
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    IOS
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var input1 = Console.ReadLine().Split(" ");
            int x = int.Parse(input1[0]);
            int n = int.Parse(input1[1]);
            List<int> p = new List<int>();
            if (n > 0)
            {
                var input2 = Console.ReadLine().Split(" ");
                p = input2.Select(x => int.Parse(x)).ToList();
                p.Sort();
            }


            try
            {
                IEnumerator<(int, int)> pattern(int x)
                {
                    int count = 0;
                    while (true)
                    {
                        yield return (x - (count), (x + count));
                        if (count == x) yield break;
                        count++;
                    }
                }

                var pat = pattern(x);
                while (pat.MoveNext())
                {
                    if (!p.Contains(pat.Current.Item1))
                    {
                        Console.WriteLine(pat.Current.Item1);
                        return;
                    }

                    if (!p.Contains(pat.Current.Item2))
                    {
                        Console.WriteLine(pat.Current.Item2);
                        return;
                    }
                }
            }
            catch (Exception e)
            {
                Console.Write(e);
            }
        }
    }
}


Measured memory_bytes: 28320
S = input()
T = input()

ans = 0

for i in range(len(S) - len(T) + 1):
    ansi = 0
    for j in range(len(T)):
        if S[i+j] == T[j]:
            ansi += 1

    ans = max(ans, ansi)

print(len(T) - ans)

Measured memory_bytes: 9108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int x,y,z; cin >> x >> y >> z;
    cout << (x-z)/(y+z) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    n = II()
    s = IS()
    cnt = 0
    rgb = {'R': [], 'G': [], 'B': []}
    for i in range(n):
        rgb[s[i]].append(i)
    dd = 0
    for i in range(n-1):
        for k in range(i+2, n):
            if (i+k)%2==0:
                j = (i+k)//2
                if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
                    dd += 1
    all = len(rgb['R']) * len(rgb['G']) * len(rgb['B'])
    ans = all - dd
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 68324
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <cstring>
#include <fstream>

using namespace std;

const long long int MOD = 1000000007;
vector <int> A;
long long int used[100005];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, t;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> t;
		A.push_back(t);
	}

	if (A[0] != 0)
	{
		cout << 0 << '\n';
		return 0;
	}
	memset(used, 0, sizeof(used));

	long long int res = 3;
	used[0] = 1;

	for (int i = 1; i < n; i++)
	{
		if (A[i] == 0)
		{
			res = (((res%MOD) * ((3LL - used[A[i]]) % MOD)) % MOD) % MOD;
			res %= MOD;
			used[A[i]]++;
		}
		else
		{
			res = ((res%MOD) * ((used[A[i] - 1] - used[A[i]]) % MOD) % MOD) % MOD;
			res %= MOD;
			used[A[i]]++;
		}
	}

	cout << res << '\n';

	return 0;
}

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

int main() {
  
  int h, n;
  cin >> h >> n;
  vector<int> vec(n);
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    vec.at(i) = x;
  }
  int ans = 0;
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for(int i = 0; i < n; i++){
    h -= vec.at(i);
    if(h <= 0){
      ans = 1;
      break;
    }
  }
  
  if(ans == 1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  
  
  
  
  
}

Measured memory_bytes: 3764
N=gets.to_i
D=gets.split.map(&:to_i).sort
M=gets.to_i
T=gets.split.map(&:to_i).sort
#p D
#p T
i=0;j=0
T.each{|t|
  while(D[i]!=t)
    i+=1
    if(i==N)
      puts "NO"
      exit
    end
  end
#  p [i,t,D[i]]
  i+=1

}
puts "YES"

Measured memory_bytes: 33352
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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












int main(){
    string s;
    cin >> s;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
        cout << "Bad" << endl;
    }
    else{
        cout << "Good" << endl;
    }
}

Measured memory_bytes: 256
#ITP1_6_B

card = [[False for i in range(13)] for j in range(4)]
suit = ["S", "H", "C", "D"]

n = int(input())
for i in range(n):
    si, sn = input().split()
    card[suit.index(si)][int(sn) - 1] = True

for i in range(4):
    for j in range(13):
        if card[i][j] == False:
            print(suit[i], j + 1)
            


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MAXN = 150 + 10;
const LL inf = 1ll << 60;

LL dp[MAXN][MAXN];
bool vis[MAXN][MAXN];
int r[MAXN], s[MAXN], a[MAXN];
int n, A, B;

int main() {
  while (scanf("%d%d%d", &n, &A, &B) == 3) {
    for (int i = 0; i < n; ++ i) scanf("%d%d", r + i, a + i);
    s[n] = 0;
    for (int i = n - 1; i >= 0; -- i) s[i] = a[i] + s[i + 1];
    memset(vis, 0, sizeof(vis));
    vis[n][0] = 1; dp[n][0] = -inf;
    for (int i = n - 1; i >= 0; -- i) {
      for (int j = 0; j <= s[0]; ++ j) {
        dp[i][j] = inf;
        if (j >= a[i]) { // take i
          int lim = s[i + 1] - (j - a[i]);
          for (int k = 0; k <= lim; ++ k) vis[i][j] |= vis[i + 1][k];
          if (vis[i][j]) {
            LL res(-inf);
            for (int k = lim + 1; k <= s[0]; ++ k) {
              if (vis[i + 1][k]) res = max(res, - dp[i + 1][k] + 1 - r[i]);
            }
            dp[i][j] = min(dp[i][j], res);
          }
        }
        // pass i
        bool flag(0);
        for (int k = j; k <= s[0]; ++ k) flag |= vis[i + 1][k];
        if (!flag) continue; vis[i][j] |= flag;
        LL res(inf);
        for (int k = j; k <= s[0]; ++ k) if (vis[i + 1][k]) {
          res = min(res, dp[i + 1][k] + 1 + r[i]);
        }
        dp[i][j] = min(dp[i][j], max(res, 1ll));
      }
    }
    for (int ret = s[0]; ret >= 0; -- ret) {
      if (dp[0][ret] <= A - B && vis[0][ret]) {
        printf("%d %d\n", ret, s[0] - ret);
        break;
      }
    }
  }
  return 0;
}

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

int gcd(int a,int b){
  if(a < b) swap(a,b);
  if(b == 0) return a;
  return gcd(b,a%b);
}

int lcm(int a,int b){ // lcm = a*b / gcd
  return a / gcd(a,b) * b; // a*bにおいてgcdだけ重複掛けしてる
}

signed main(){

  int a,b,c,d; cin >> a >> b >> c >> d;
  a--;
  int g = lcm(c,d);
  int res1 = b - b/c - b/d + b/g;
  int res2 = a - a/c - a/d + a/g;
  //cout << res1 << " " << res2 << endl;
  cout << res1 - res2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	int n;
	cin>>n;
	int a,b,ca,cb;
	cin>>a>>b;
	ca=a,cb=b;
	for (int i=1;i<n;i++){
		cin>>a>>b;
		if ( (ca+a-1)/a*b>=cb ){
			ca=(ca+a-1)/a*a;//cout<<ca;
			cb=(ca+a-1)/a*b;//cout<<ca;
		}
		else {
			ca=(cb+b-1)/b*a;//cout<<ca;
			cb=(cb+b-1)/b*b;//cout<<cb;
		}
	}
	cout<<(ca+cb);
	re 0;
}



Measured memory_bytes: 256
n,m,x = map(int, input().split())
inf = 10**9
result = inf
A=[]
C=[]
for _ in range(n):
	books=list(map(int, input().split()))
	C.append(books[0])
	A.append(books[1:])
for i in range(1<<n):
	cnt = 0
	rikaido = [0]*m
	for j in range(n):
		if (i>>j)&1:
			for k in range(m):
				rikaido[k]+=A[j][k]
			cnt += C[j]
		else:
			pass
	if min(rikaido)>=x:
		result = min(result, cnt)
if result == inf:
	print(-1)
else:
	print(result)

Measured memory_bytes: 9232
using System;
namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i < 10001; i++)
            {
                var x = int.Parse(Console.ReadLine());
                if (x == 0)
                {
                    
                    break;
                }
                else
                    Console.WriteLine("Case {0}: {1}", i, x);
            }

        }
    }
    
}



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

int main(){
    string s; cin>>s;
    int ans=0;

    for(int i=0; i<s.size()/2; i++){
        int j=s.size()-i-1;
        if(s[i] != s[j]) ans++;
    }

    cout<<ans<<endl;

    return 0;
}

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

int main(){
	string w;
	int n;
	cin >> n;
	cin >> w;
	set<string> s;
	s.insert(w);
	for (int i = 1; i<n; i++){
		char last = w[(int) w.length() - 1];
		cin >> w;
		if (last != w[0]) {cout<< "No"; return 0;}
		if (s.count(w) != 0) {cout << "No"; return 0;}
		s.insert(w);
	}
	cout << "Yes";
	
}


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

typedef long long ll;

/*
const ll M = 1000000007;
vector<ll> fac(3001);
vector<ll> ifac(3001);
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
*/


ll lcm(ll a,ll b){
 
  ll r, x, tmp;
  x = a * b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;
}

ll gcd(ll a ,ll b){
    if(a==0){return b;}
    else if(b==0){return a;}
    else{
    ll tmp,r;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
    }
}

bool sosu(ll p){
    bool ans = true;
    double psqrtd = pow(p, 0.5);
    ll psqrt = psqrtd;
    for(ll i = 2; i <= psqrt; i++){
        if(p%i==0)ans = false;
    }
    if(p==1)ans = false;
    return ans;
}



int main(void){
    ll n,k,q;
    cin >> n >> k >> q;
    int a[q],ans[n+1];
    for(ll i=0;i<=n;i++)ans[i]=0;
    for(ll i=0;i<q;i++)cin >> a[i];
    for(ll i=0;i<q;i++)ans[a[i]]++;
    for(ll i=1;i<=n;i++){
        if(k-(q-ans[i])>0)cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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

long gcd(long a, long b){
  if (a < b) {
      a ^= b;
      b ^= a;
      a ^= b;
  }
  return b ? gcd(b, a % b) : a;
}

long lcm(long a, long b) {
  return a * b / gcd(a, b);
}

int main() {
  long a,b;
  cin >> a >> b;
  cout << lcm(a,b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <numeric>
#include <vector>

#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

void comb_3(vector<int>& A,int start, int end, int index, int x, int& ans){
  if(index == 3){
    if(accumulate(A.begin(), A.end(), 0) == x){
      ++ans;
    }
    return;
  }
  for(int i = start; i <= end; ++i){
    A[index] = i;
    comb_3(A, i+1, end+1, index+1, x, ans);
  }
}

int main() {

  while(1){
    int n, x;
    cin >> n >> x;

    if(n == 0 && x == 0) break;

    vector<int> A(3);
    int ans = 0;
    comb_3(A, 1, n-2, 0, x, ans);

    cout << ans << endl;
  }

  return 0;
}



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

int main() {
  string a;
  cin >> a;
  if(a[0] == a[1] && a[1] == a[2] || a[1] == a[2] && a[2] == a[3])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main(){

  char S[100];
  char T[100];

  scanf("%s %s", S, T);

  int len = 0;
  len = strlen( S );


  int i = 0, res = 0;
  for( i = 0; i < len; i++ ){
    if( S[i] != T[i] ){
      res = 1;
    }
  }

  if( res == 0 ){
    printf("Yes \n");
  }
  else{
    printf("No \n");
  }

  return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 200000;
int n, k;
int a[N], f[N];

bool ok(int score) {
    int need = 0;
    for(int i = 0; i < n; ++i) {
        int mx = score/f[i];
        need += max(0LL, a[i] - mx);
    }
    return need <= k;
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    sort(a, a+n);
    sort(f, f+n, greater<int>());

    int l = -1, r = 1000000000000;

    while(r-l > 1) {
        int mid = (l+r)/2;
        if(ok(mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }

    cout << r << endl;
    
    return 0;
}


Measured memory_bytes: 3328