akhauriyash/Code-Regression huggingface dataset:
w,h,n = map(int, input().split())
s = [[1 for i in range(w)] for j in range(h)]
b = [[1,2,3,4,5],[6,7,8,9,10]]
alist = []
for i in range(n):
    x,y,a = map(int, input().split())
    alist.append(a)
    if a == 1:
        for j in range(h):
            for k in range(0,x):
                s[j][k] = 0
    if a == 2:
        for j in range(h):
            for k in range(x,w):
                s[j][k] = 0
    if a == 3:
        for k in range(w):
            for j in range(0,y):
                s[j][k] = 0
    if a == 4:
        for k in range(w):
            for j in range(y,h):
                s[j][k] = 0
ans = 0
for i in range(h):
    ans = ans + s[i].count(1)
print(ans)

Measured memory_bytes: 9228
import sys
input = sys.stdin.readline
n = int(input())
f = [list(map(int,input().split()))for i in range(n)]
p = [list(map(int,input().split()))for i in range(n)]
ans = -float('inf')
for i in range(1,2**10):
    bin = format(i,'b').zfill(10)
    c = [0]*n
    for j in range(n):
        for k in range(10):
            if bin[k] == '1' and f[j][k] == 1:
                c[j] += 1
    r = 0
    for i in range(n):
        r += p[i][c[i]]
    ans = max(ans, r)
print(ans)


Measured memory_bytes: 41456
#define loop(i,j,k) for(long long i = j;i < k;i++)

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstdint>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

int main(void) {
    int n,v;
    map<int,int> m[2];
    cin >> n;
    loop(i,0,n) {
        cin >> v;
        m[i%2][v]++;
    }
    int mc[2] = {0,0},mi[2] = {-1,-1},sc[2] = {0,0};
    loop(i,0,2) {
        for(auto e:m[i]) {
            if(mc[i] <= e.second) {
                mc[i] = e.second;
                mi[i] = e.first;
            }
        }
        for(auto e:m[i]) {
            if(sc[i] <= e.second && e.first != mi[i]) {
                sc[i] = e.second;
            }
        }
    }
    if(mi[0] != mi[1])
        cout << n - (mc[0] + mc[1]) << endl;
    else
    {
        if(sc[0] > sc[1]) {
            cout << n - (sc[0] + mc[1]) << endl;
        }
        else {
            cout << n - (sc[1] + mc[0]) << endl;
        }
    }
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

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

    if(a+b==15)
        cout << "+" << endl;
    else if(a*b==15)
        cout << "*" << endl;
    else
        cout << "x" << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, N, *AB = map(int, read().split())

    dp = [INF] * (H + 1)
    dp[0] = 0

    for a, b in zip(*[iter(AB)] * 2):
        for i in range(H + 1):
            dp[i] = min(dp[i], dp[max(i - a, 0)] + b)

    print(dp[H])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 70556
import fractions

N=int(input())
t,a=1,1
for i in range(N):
    T,A=map(int,input().split())
    n=max(-(-a//A),-(-t//T))
    # n=max(fractions.ceil(a/A),fractions.ceil(t/T))
    t,a=n*T,n*A

print(t+a)


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
string p,t;
int n,m;
int ne[1000005];
int bmbc[256];
int bmgs[1000005];
int osuff[1000005];
vector<int>res;
void output(){
	for(int i=0;i<res.size();i++)
		cout<<res[i]<<endl;
}
void bf(){
	n=t.length();
	m=p.length();
	res.clear();
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(p[j]!=t[i+j])break;
			if(j==m-1)res.push_back(i);
		}
	}
	output();
}
void calcnext(){
	ne[0]=-1;
	for(int j=1;j<m;j++){
		int i=ne[j-1];
		while(i>=0&&p[i+1]!=p[j])i=ne[i];
		if(p[i+1]==p[j])ne[j]=i+1;
		else ne[j]=-1;
	}
}
void kmp(){
	n=t.length();
	m=p.length();
	res.clear();
	calcnext();
    int i,j,cnt;i=0;j=0;cnt=0;  
    while(i<=n){  
        if(i==n){if(j==m)res.push_back(i-m);break;}
        if(t[i]==p[j]){i++;j++;}
		else{
			if(j==0)i++;
			else j=ne[j-1]+1;
		}
        if(j>=m){
			res.push_back(i-m);
			j=ne[m-1]+1;
		}
    }  
	output();
}
void calcosuff(){
	int le,ri;
	osuff[m-1]=m;
	le=m-1;
	for(int i=m-2;i>=0;i--){
		if(i>le&&osuff[i+m-1-ri]<i-le)
			osuff[i]=osuff[i+m-1-ri];
		else{
			if(i<le)le=i;
			ri=i;
			while(le>=0&&p[le]==p[le+m-1-ri])le--;
			osuff[i]=ri-le;
		}
	}
//	for(int i=0;i<m;i++)cout<<osuff[i]<<" ";
}
void calcbmbc(){
	for(int i=0;i<256;i++)bmbc[i]=m;
	for(int i=0;i<m-1;i++)bmbc[p[i]]=m-i-1;
}
void calcbmgs(){
	calcosuff();
	for(int i=0;i<m;i++)bmgs[i]=m;
	int j=0;
	for(int i=m-2;i>=0;i--)
		if(osuff[i]==i+1)
			for(;j<=m-1-i;j++)
				if(bmgs[j]==m)bmgs[j]=m-i-1;
	for(int i=0;i<m-1;i++)bmgs[m-osuff[i]-1]=m-i-1;
}
void bm(){
	res.clear();
	n=t.length();
	m=p.length(); 
	calcbmbc();
	calcbmgs();
	for(int l=0;l<=n-m;){
		int k=m-1;
		while(k>=0&&p[k]==t[l+k])k--;
		if(k==-1){
			res.push_back(l);
			l+=bmgs[0];
		}else
			l+=max(bmgs[k],bmbc[t[l+k]]-m+k);
	}
	output();
}
int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>t>>p;
//	bf();
	kmp();
//	bm();
// anpanman	 gcagagag
	return 0;
}


Measured memory_bytes: 8832
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
using namespace std;
using ll = long long;
typedef pair <int, int> pii;

int main()
{

	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	string s;
	//long long n, A[1000000000];
	int n, m, q;
	//int   y[100001], z[100001], x[10001] = {};
	//pii y[100001];
	//pair<int, float> pii[100001];
	ll A[100001];
	cin >> a;
	cin >> b;
	if (a==1)
	{
		cout << 1 << endl;

	}
	else
	{
		cout << a-b+1 << endl;

	}

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int,input().split()))
sort_X = sorted(X)

mid_ls = [sort_X[N//2-1],sort_X[N//2]]

for i in range(N):
  if X[i] >= mid_ls[1]:
    print(mid_ls[0])
  else:
    print(mid_ls[1])

Measured memory_bytes: 30864
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let b: Vec<usize> = read_vec();

    let mut sum: usize = 0;
    sum += b[0];
    for i in 0..n-1 {
      if i == n - 2 {
        sum += b[i];
      } else {
        sum += min(b[i], b[i+1]);
      }
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <time.h>
#define int long long int
#define pb push_back
#define all(a) a.begin(), a.end()
#define scnarr(a, n) for (int i = 0; i < n; ++i) cin >> a[i]
#define vi vector<int>
#define si set<int>
#define pii pair <int, int>
#define sii set<pii>
#define vii vector<pii>
#define mii map <int, int>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace chrono;
/* -------------------------------Solution Sarted--------------------------------------*/
//Constants
const int MOD = 1000000007; // 1e9 + 7
const int MAXN = 1000005; // 1e6 +5

void solve(){
	string s, t;
	cin >> s >> t;
	int ans = 0;

	for(int i = 0; i < s.length(); ++i)
		if(s[i] != t[i])
			ans++;

	cout << ans << endl;
	
}

signed main()
{
	faster;
#ifndef ONLINE_JUDGE
	freopen("ip.txt", "r", stdin);
	freopen("op.txt", "w", stdout);
#endif
	// int t; cin >> t; while(t--)
		solve();
	return 0;
}


//Author : Ankit Raj
//Problem Link :

/*Snippets*/
/*
sieve - prime factorization using sieve and primes in range
zpower - pow with mod
plate - Initial template
bfs 
dfs
fenwik - BIT
binary_search
segment_tree
*/
	

Measured memory_bytes: 3800
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  map<int,int> m;
  REP(i,N){
    int K;
    cin>>K;
    REP(j,K){
      int A;
      cin>>A;
      m[A]+=1;
    }
  }
  int ans=0;
  for(auto e:m){
    if(e.second==N)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//公約数列挙
//昇順
vll div(ll n) {
  vll vec(1, 1);
  for (ll i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) vec.push_back(i);
  }
  if (sqrt(n) == (ll)sqrt(n)) {
    for (ll i = vec.size() - 2; i >= 0; i--) vec.push_back(n / vec[i]);
  }
  else {
    for (ll i = vec.size() - 1; i >= 0; i--) vec.push_back(n / vec[i]);
  }
  return vec;
}

vll comdiv(ll a, ll b) {
  if (a > b) swap(a, b);
  vll vec1 = div(a);
  vll vec2(0);
  for (ll i = 0; i < vec1.size(); i++) {
    if (b % vec1[i] == 0) vec2.push_back(vec1[i]);
  }
  return vec2;
}

//素数判定
bool is_prime(ll n) {
  if (n == 1) return false;
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  for (ll i = 3; i <= sqrt(n); i += 2) {
    if (n % i == 0) return false;
  }
  return true;
}

int main() {
  ll a, b;
  cin >> a >> b;
  vll v = comdiv(a, b);
  ll ans = 0;
  for (ll i = 0; i < v.size(); i++) {
    if (is_prime(v[i])) ans++;
  }
  cout << ans + 1 << endl;
}

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

int main()
{
    ll a[100000+9],n,s=0,i,p=0;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a[i];

    }
    sort(a,a+n,greater<int>());
    for(i=0; i<n; i++)
    {

        if(i%2==0)
        {
            s+=a[i];
        }
        else
        {
            p+=a[i];
        }
    }
    cout<<s-p<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string.h>

using namespace std;
typedef pair<long long int, long long int> P;

void solve()
{
	long long int N, K;
	cin >> N >> K;
	vector<long long int> x(N);
	vector<long long int> y(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> x[i] >> y[i];
	}
	long long int ans = 1LL << 62;
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < N; ++j)
		{
			for (int k = 0; k < N; ++k)
			{
				for (int l = 0; l < N; ++l)
				{
					if (x[i] >= x[j] || y[k] >= y[l])
					{
						continue;
					}
					int cnt = 0;
					for (int m = 0; m < N; ++m)
					{
						if (x[i] <= x[m] && x[m] <= x[j] && y[k] <= y[m] && y[m] <= y[l])
						{
							++cnt;
						}
					}
					if (cnt >= K)
					{
						ans = min(ans, 1LL * (x[j] - x[i]) * (y[l] - y[k]));
					}
				}
			}
		}
	}
	cout << ans << endl;
}

int main()
{
	solve();
	return(0);
}

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

int main() {
  int A, B;

  cin >> A;
  cin >> B;
  
  if (13 <= A) {
    cout << B;
  } else if (A <= 5) {
    cout << 0;
  } else {
    cout << B / 2;
  }
}

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

using namespace std;

#define Vi vector<int>
#define FOR(i,s,e) for (int i=s; i<e; i++)
#define ITER(v) v.begin(), v.end()

constexpr int N_MAX = 100;

int weight[N_MAX][N_MAX];

int mst(const int n) {
    bool ismember[n] = {false};
    Vi members;

    members.push_back(0);
    ismember[0] = true;
    int cost = 0;

    FOR(t,1,n) {
        int addcost = -1;
        int newmember = -1;
        for (const int i : members)
        FOR(j,0,n) {
            if (ismember[j]) { continue; }
            const int w = weight[i][j];
            if (w < 0) { continue; }
            if (addcost < 0 || addcost > w) {
                addcost = w;
                newmember = j;
            }
        }
        members.push_back(newmember);
        ismember[newmember] = true;
        cost += addcost;
        //cout << "#" << newmember << endl;
    }
    return cost;
}

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

    int n;
    cin >> n;

    FOR(i,0,n) {
        FOR(j,0,n) {
            cin >> weight[i][j];
        }
    }

    int cost = mst(n);
    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 3156
import sys
sys.setrecursionlimit(10000)

def main():
    A, B, C, D = map(int, input().split())
    while True:
        C -= B
        if C <= 0:
            print('Yes')
            exit()
        A -= D
        if A <= 0:
            print('No')
            exit()
    


if __name__ == "__main__":
    main()

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

void print(vector<int> a) {
    for (int i = 0; i < (int)a.size(); i++) {
        cout << a[i] << " \n"[i + 1 == (int)a.size()];
    }
}

bool isPrime(int x) {
    for (int i = 2; i * i <= x; i++) if (x % i == 0) return 0;
    return 1;
}

vector<int> solve(int n) {
    ll cur = 1;
    for (int pr = 2; cur <= 1e9; pr++) {
        if (!isPrime(pr)) continue;
        cur *= pr;

        if (pr == 2) continue;
        if (n >= 20000 - 1 && pr != 5) continue;
        vector<int> v;
        for (int i = 1; i <= 30000; i++) if (__gcd((ll)i, cur) != 1) v.push_back(i);

        for (int it = 0; it < 1e3; it++) {
            random_shuffle(v.begin(), v.end());
            int sum = 0;
            for (int i = 0; i < n; i++) sum += v[i];
            bool ok = 1;
            for (int i = 0; i < n; i++) ok &= __gcd(sum, v[i]) != 1;
            int g = v[0];
            for (int i = 0; i < n; i++) g = __gcd(g, v[i]);
            ok &= g == 1;
            if (ok) {
                v.resize(n);
                return v;
            }
        }
        /*vector<vector<int>> p(cur + 1, vector<int>(n + 1, -1));
        p[0][0] = 0;
        for (int i = 2; i <= min(cur, 30000); i++) {
            if (__gcd(i, cur) == 1) continue;
            for (int j = cur; j >= 0; j--) {
                for (int k = 0; k < n; k++) {
                    if (p[j][k] == -1) continue;
                    if (j + i <= cur) {
                        p[j + i][k + 1] = i;
                    }
                }
            }
        }
        if (p[cur][n] != -1) {
            vector<int> ans;
            while (cur != 0) {
                ans.push_back(p[cur][n]);
                cur -= p[cur][n];
                n--;
            }
            reverse(ans.begin(), ans.end());
            return ans;
        }*/
        /*ll left = cur;
        vector<int> vct;
        for (int i = 2; i <= 30000; i++) {
            if (__gcd((ll)i, cur) == 1) continue;
            if (vct.size() == n - 1) break;
            left -= i;
            vct.push_back(i);
        }
        if (left <= 0) {
            left %= cur;
            left += cur;
        }
        while (left <= vct.back()) left += cur;
        if (vct.back() < left && left <= 30000) {
            vct.push_back(left);
            return vct;
        }*/
    }
    assert(0);
}

int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif
    /*for (int n = 3; n <= 20000; n++) {
        cout << n << endl;
        solve(n);
    }
    return 0;*/

    int n;
    while (cin >> n) {
        print(solve(n));
    }
#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  int a, b, k;
  int count = 0;
  cin >> a >> b >> k;

  REPB(i,min(a,b)){
      if(a % i == 0 && b % i == 0) count++;
      if(count == k){
          cout << i << endl;
          return 0;
        }
    }
}

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

int main(void){
	char a;
	scanf("%c",&a);
	if(a>='A'&&a<='Z'){
		printf("A\n");
	}else if(a>='a'&&a<='z'){
		printf("a\n");
	}	

	return 0;
}

Measured memory_bytes: 1588
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  int X;
  cin >> X;
  if(X >= 30) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl; 
  }
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  if (s == "Sunny") cout << "Cloudy" << endl;
  else if (s == "Cloudy") cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

c = [0]*(10**6 + 3)
for i in a:
    c[i] += 1

pairwise = True
for i in range(2,10**6+1):
    if sum(c[::i])>1:
        pairwise = False

g = 0
for i in a:
    g = gcd(g,i)
if g == 1:
    setwise = True
else:
    setwise = False

if pairwise == True:
    print("pairwise coprime")
    exit()
if setwise == True:
    print("setwise coprime")
    exit()
print("not coprime")

Measured memory_bytes: 126356
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

const long long MOD = 1000000007;
const int FACT_MAX = 5000000;
long long fact[FACT_MAX];
long long inv[FACT_MAX];
long long invfact[FACT_MAX];
long long nPr(int n, int r) { return (fact[n] * invfact[n - r]) % MOD; }
long long nCr(int n, int r) {
    return (((fact[n] * invfact[r]) % MOD) * invfact[n - r]) % MOD;
}
void initialize_fact() {
    fact[0] = 1;
    inv[0] = 0;
    inv[1] = 1;
    invfact[0] = 1;
    loop(i, 1, FACT_MAX) fact[i] = (i * fact[i - 1]) % MOD;
    loop(i, 2, FACT_MAX) inv[i] = MOD - ((MOD / i) * inv[MOD % i] % MOD);
    loop(i, 1, FACT_MAX) invfact[i] = (invfact[i - 1] * inv[i]) % MOD;
}

const int POW_MAX = 5000000;
long long pow25[POW_MAX];
long long pow26[POW_MAX];

void init() {
    pow25[0] = 1;
    pow26[0] = 1;
    loop (i, 1, POW_MAX) {
        pow25[i] = (pow25[i-1] * 25) % MOD;
        pow26[i] = (pow26[i-1] * 26) % MOD;
    }
}

void solve(long long K, std::string S) {
    initialize_fact();
    init();

    long long ans = 0;
    rep(k, K+1) {
        ans = (ans + (((nCr(k+S.size()-1, S.size()-1) * pow25[k]) % MOD) * pow26[K-k]) % MOD) % MOD;
    }
    cout << ans << endl;
}

int main() {
    long long K;
    scanf("%lld", &K);
    std::string S;
    std::cin >> S;
    solve(K, S);
    return 0;
}


Measured memory_bytes: 200636
#include<iostream>

int main(void){
	using namespace std;

	int time1, time2, moku, kekka, kai;
	while(1){
		kekka = 0;
		cin >> moku;
		if(moku == 0){
			break;
		}
		cin >> kai;
		for(int i = 0;i < kai;i++){
			cin >> time1;
			cin >> time2;
			kekka = kekka + (time2 - time1);
		}
		if(moku <= kekka){
			cout << "OK" <<endl;
		}else{
			cout << moku - kekka << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
n = int(input())
aa = list(map(int, input().split()))
balls = {}
ai = {}
for i in range(len(aa)):
    if aa[i] == 1:
        ai[i + 1] = 1
    else:
        ai[i + 1] = 0


for i in range(n, 0, -1):
    parity = 0
    k = 1
    while k * i <= n:
        if k * i in balls:
            parity ^= 1
        k += 1
    if parity != ai[i]:
        balls[i] = True

print(len(balls))
if len(balls) > 0:
    print(' '.join(map(str, balls)))





Measured memory_bytes: 45848
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();

		if (D==25) {
			System.out.println("Christmas");
		} else if (D==24) {
			System.out.println("Christmas Eve");
		} else if (D==23) {
			System.out.println("Christmas Eve Eve");
		} else if (D==22) {
			System.out.println("Christmas Eve Eve Eve");
		}
	}

}


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

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),k=nxt();
    vector <int> v(n,0);
    for(int i=0;i<k;i++)
    {
        int d=nxt();
        while(d--)
        {
            int x=nxt();
            v[x-1]++;
        }
    }
    int x=0;
    for(auto i:v)
        if(i==0)
            x++;
        cout<<x<<endl;
    
    
    return 0;   
}




 
 


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


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

    int H,W;
    cin >> H >> W;
    char C[H][W];
    rep(i,H){
        rep(j,W){
            cin >> C[i][j];
        }
    }
    int x;
    rep(i,2*H){
        rep(j,W){
            x=i/2;
            cout << C[x][j];
        }
        cout << endl;
    }


}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<ctime>
#include<queue>
#include<cmath>
#include<climits>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
    int f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define MAXN 5000
#define INF 0x3f3f3f3f
int main(){
	int a[3];
	for(int i=0;i<3;i++)
		a[i]=read();
	sort(a,a+3);
	printf("%d\n",a[2]*10+a[1]+a[0]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
int a(int n){
	if(n==0)return 1;
	else return 2*a(n-1)+3;
}
int p(int n){
	if(n==0)return 1;
	else return 2*p(n-1)+1;
}

int f(int n,int x){
	if(n==0) return 1;
	else if(x==1)return 0;
	else if(2<=x&&x<=a(n-1)+1) return f(n-1,x-1);
	else if(x==a(n-1)+2) return p(n-1)+1;
	else if(a(n-1)+3<=x&&x<=2*a(n-1)+2)  return p(n-1)+1+f(n-1,x-a(n-1)-2);
	else if(x==2*a(n-1)+3)return 2*p(n-1)+1;
}

signed main(){
	int n,x;
	cin>>n>>x;
	cout<<f(n,x)<<endl;

	// string s="P";
	// rep(i,n){
	// 	s='B'+s+'P'+s+'B';
	// }
	// cout<<s<<endl;
	// int cnt=0;
	// rep(i,x){
	// 	cnt+=s[i]=='P';
	// }		
	// cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 3532
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
ld eps = 1e-9;

int main() {
	ld d; cin >> d;
	ld ans = d*sqrt(2);
	for (int i = 0; i < d+eps; ++i) {
		ld x = sqrt(d*d - i*i);
		ans = max(ans, ld(i) + 1);
	}
	cout << setprecision(22) << fixed<<ans << endl;
	return 0;
}

Measured memory_bytes: 3292
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        line = Console.ReadLine().Trim().Split(' ');
        var b = Array.ConvertAll(line, int.Parse);
        Console.WriteLine(getAns(a, b, n));
    }
    static long getAns(int[] a, int[] b, int n)
    {
        var count = 0L;
        for (int i = 0; i < n; i++)
        {
            var t = Min(a[i], b[i]);
            a[i] -= t;
            b[i] -= t;
            count += t;
            t = Min(a[i + 1], b[i]);
            a[i + 1] -= t;
            b[i] -= t;
            count += t;
        }
        return count;
    }
}


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

int main(){
	int N=6, a[N],/* b[N],*/ i, j;
	
	for(i=0; i<N; i++){
		cin >> a[i];
	}
	
	int count[5]={0};
	for(i=0; i<N; i++){
		for(j=1; j<=4; j++){
			if(a[i]==j)	count[j]++;
		}
	}
	
	if(count[1]<=2 && count[2]<=2 && count[3]<=2 && count[4]<=2){
		cout << "YES" << endl;
	}
	else	cout << "NO" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const i64 mod = 1e9+7;
i64 fact(i64 x) { return x == 0 ? 1 : x * fact(x - 1) % mod; }

i64 n, m;
int main() {
  cin >> n >> m;
  i64 ans = 0;
  if (abs(n - m) == 0) {
    ans = 2 * fact(n) * fact(m) % mod;
  } else if (abs(n - m) == 1) {
    ans = fact(n) * fact(m) % mod;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1792
import fractions
N, M = map(int, input().split())
S = input()
T = input()
ans = (N * M) // fractions.gcd(N, M)
n = N // fractions.gcd(N, M)
m = M // fractions.gcd(N, M)
for i in range(min(N // n, M // m)):
    tmpn = S[n * i]
    tmpm = T[m * i]
    if tmpn != tmpm:
        ans = -1
        break

print(ans)


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

struct data{
  int a,b,c,id;

  bool operator < (const data& p) const{
    if(a!=p.a)return a<p.a;
    if(b!=p.b)return b<p.b;
    if(c!=p.c)return c<p.c;
    return false;
  }
};

string t[5][5];
bool u[5][5];

double ans=0;
int target;

bool used[10];
double mem[10];
double calc(int x){
  if(used[x])return mem[x];
  used[x]=true;

  double A=1;

  for(int i=8;i>8-x;i--)A*=(double)i;

  for(int i=1;i<=x;i++)A/=(double)i;

  for(int i=1;i<=x;i++)
    A*=0.25;

  for(int i=1;i<=(8-x);i++)
    A*=0.75;

  return mem[x]=A;
}

bool eq(data a,data b){
  if(a<b)return false;
  if(b<a)return false;
  return true;
}

double func(vector<data> vec,int k,bool debug=false){
  if(k<0)return 0;
  int size=vec.size();

  if(size<=k+1)return 1.0;

  for(int i=0;i<size;i++)
    vec[i].a=vec[i].b=vec[i].c=0;
  
  for(int i=0;i<size;i++){
    for(int j=0;j<size;j++){

      int ai=vec[i].id+1;
      int aj=vec[j].id+1;
      if(ai>=aj)continue;

      int vi=t[ai][aj][1]-'0';
      int vj=t[ai][aj][3]-'0';
      
      vec[i].b+=(vi-vj);
      vec[j].b+=(vj-vi);

      vec[i].c+=vi;
      vec[j].c+=vj;

      if(vi>vj)vec[i].a+=3;
      else if(vi<vj)vec[j].a+=3;
      else vec[i].a++,vec[j].a++;
    }
  }



  bool flag=true;
  for(int i=0;i<size;i++)
    if( !eq(vec[i],vec[0]) )flag=false;
  if(flag)return ( (double)(k+1) / (double)size);
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());

  if(debug){
    for(int i=0;i<size;i++){
      cout<<vec[i].a<<' '<<vec[i].b<<' '<<vec[i].c<<' '<<vec[i].id<<endl;
    }
    cout<<endl;
  }

  vector<data> divi[4];
  int C=0,tc;

  for(int i=0;i<size;i++){
    if(i>0&&!eq(vec[i],vec[i-1]))C++;
    divi[C].push_back(vec[i]);
    if(vec[i].id==target)tc=C;
  }

  int sum=0;
  for(int i=0;i<tc;i++)
    sum+=(int)divi[i].size();
  
  if(sum>k)return 0.0;
  return func( divi[tc], k-sum);
}

int cc=0;
void check(double p){
  vector<data> vec(4);
  for(int i=0;i<4;i++)vec[i].id=i;
  /*
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      cout<<t[i][j]<<' ';
    }
    cout<<endl;
  }
  cout<<endl;

  cout<<func(vec,1)<<endl;
  cout<<endl;  cout<<endl;
  cc++;
  */
  ans+=p*func(vec,1, (cc==2) );
}

void dfs(int y,int x,double p){

  if(y==4){
    check(p);
    return;
  }
  if(x==5){
    dfs(y+1,1,p);
    return;
  }
  if(y>=x){
    dfs(y,x+1,p);
    return;
  }





  if(u[y][x]){

    for(int i=0;i<=8;i++){
      for(int j=0;j<=8;j++){
        t[y][x][1]= ('0'+i);
        t[y][x][3]= ('0'+j);
        dfs(y,x+1,p*calc(i)*calc(j));
      }
    }

  }else{
    dfs(y,x+1,p);
  }

}

int main(){
  int Tc;
  cin>>Tc;
  while(Tc--){
    for(int i=0;i<5;i++){
      string s;
      cin>>s;
      for(int j=0;j<5;j++){
        t[i][j]=s.substr(j*5,4);
      }
    }    
    for(int i=1;i<5;i++)
      if(t[i][0][0]=='*')target=i-1;
    memset(u,false,sizeof(u));

    for(int i=1;i<5;i++)
      for(int j=1;j<5;j++)
        if(t[i][j][1]=='_')
          u[i][j]=true;

    ans=0;
    dfs(1,1,1);

    printf("%.10f\n",ans);
  }
  
  return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

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

    int N;
    cin>>N;
    vector<int> xs(N);
    rep(i, N) cin>>xs[i];

    ll m = INT_MAX;
    rep(i, 100 + 1) {
        ll hp = 0;
        for (auto x : xs) {
            hp += (ll)pow(x - i, 2);
        }
        chmin(m, hp);
    }
    cout<<m<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
//    cout << a/b << " " << a%b << " " << (double)a/(double)b << endl; 
    printf("%d %d %.5f",a/b, a%b, (double)a/(double)b );
    
}

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

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b){
        cout << c << endl;
    }else if(b == c){
        cout << a << endl;
    }else{
        cout << b << endl;
    }
}


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

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


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;
const int mod = 1e9 + 7;
ll power(ll a, ll b)
{
    ll ans = 1 % mod;
    while (b > 0)
    {
        if (b & 1)
        {
            ans = ans * a % mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}
ll cac(ll n)
{
    if (n == 1)
        return 0;
    else
    {
        ll ans = ((power(10, n) - power(9, n) - power(9, n) + power(8, n)) % mod + mod) % mod;
        return ans;
    }
}
void run_case()
{
    ll n;
    cin >> n;
    ll ans = cac(n);
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

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

const int INF = 0x3f3f3f3f;
const int MAXN = 3123;

int n;
long long int values[MAXN];
long long int pd[MAXN][MAXN];
bool stat[MAXN][MAXN];

long long int rec(int l, int r)
{
	if(l==r)
		return values[l];

	if(stat[l][r])
		return pd[l][r];

	stat[l][r] = true;
	return pd[l][r] = max(values[l] - rec(l+1,r), values[r] - rec(l,r-1));
}

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

	cout << rec(0, n-1) << endl;

	return 0;
}

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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans;

    long long s = 100;
    if (a>=k) {
        ans = k;
    } else {
        if (a+b>=k) {
            ans = a;
        } else {
            ans = a - (k - a - b);
        }
    }
    cout << ans << endl;
}

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

int main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string str; cin >> str; int rock = 0, paper = 0, ans = 0;
	for(auto ch: str) {
		if(ch == 'g') {
			if(paper < rock) ++paper, ++ans;
			else ++rock;
		} else {
			if(paper < rock) ++paper;
			else ++rock, --ans;
		}
	}

	cout << ans << endl;
}

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

int main(){
  unsigned long long X = 0, happy = 0;
  unsigned long long a;
  cin >> X;

  happy += (X / 500) * 1000;

  a = X - (X / 500) * 500;

  happy += (a / 5) * 5;

  cout << happy << endl;
}

Measured memory_bytes: 256
package main

import (
        "fmt"
)

func main() {
        var a [5]int
        var k int
        for i := 0; i < 5; i++ {
                fmt.Scanf("%d", &a[i])
        }
        fmt.Scanf("%d", &k)
        var f bool
        f = true
        for i := 0; i < 5; i++ {
                for j := i+1; j < 5;j++ {
                        f = f && ((a[j]-a[i]) <= k)
                }
        }

        if f {
                fmt.Println("Yay!")
        } else {
                fmt.Println(":(")
        }
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int a, b, c; cin>>a>>b>>c;
  TorF(a+b+c >=	22 , "bust", "win");
  return 0;
}




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

#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define vll vector<ll>
#define pll pair<ll , ll>
#define vpll vector<pair<ll, ll> >
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define N 100001
#define HOLE 1000000007

ll fn(ll x,ll rn[])
{
      if(rn[x]==x) return x;
      else return rn[x]=fn(rn[x],rn);
}

void un(ll x,ll y,ll rn[],ll sz[])
{
      x=fn(x,rn);
      y=fn(y,rn);
      if(x==y) return;
      if(sz[x]<sz[y]) swap(x,y);
      sz[x]+=sz[y];
      rn[y]=x;
      return;
}

ll power(ll x,ll y)
{
      ll res = 1; // Initialize result

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x)%HOLE;

        // n must be even now
        y = y >> 1; // y = y/2
        x = (x * x)%HOLE; // Change x to x^2
    }
    return res;
}

vector <ll> adjl[N];
ll marked[N]={0};
vector <ll> order;

void dfs (ll x){

    if(marked[x])
        return;
    marked[x]=1;

    REP(i,0,adjl[x].size()){

    }

    return;
}

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

      ll q=1;
      //cin>>q;
      while(q--)
      {
            ll n;
            cin>>n;

            vector<pair<ll,ll> > a[n];


            int flag=0;
            REP(i,0,n)
            {
                ll m;
                cin>>m;
                REP(j,0,m){
                    ll x,y;
                    cin>>x>>y;
                    a[i].PB(MP((x-1),y));
                }
            }



            ll tot=1;
            tot=tot<<n;
            int maxhon=0;

            REP(i,0,tot){
                flag=0;
                REP(j,0,n){
                    ll x=(i&(1<<j))>>j;
                    if(x == 0)
                        continue;

                    //cout<<i<<"   "<<j<<"   "<<x<<endl;

                    REP(k,0,a[j].size()){
                        int y=(i&(1<<a[j][k].first))>>a[j][k].first;
                        int z=a[j][k].second;
                        if(y!=z){
                            flag=1;
                            //cout<<i<<" "<<j<<" "<<k<<"    "<<a[j][k].first<<" "<<z<<" "<<y<<endl;
                            break;
                        }
                    }
                    if(flag){
                        break;
                    }

                }

                if(!flag){
                    //cout<<i<<endl;
                    int tempsum=0;
                    REP(j,0,n){
                        tempsum+=(i&(1<<j))>>j;
                    }
                    maxhon=max(maxhon,tempsum);
                }
            }

            cout<<maxhon<<endl;
      }

return 0;
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main()
{
    int num_1 , num_2 ;
    string color_1 , color_2 , x;
    cin>>color_1>>color_2;
    cin>>num_1>>num_2 ;
    cin>>x;
    if(x==color_1)
        cout<<num_1-1<<" "<<num_2;
    else
        cout<<num_1<<" "<<num_2-1;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N;

int main(){
    cin>>N;
    int a[N];
    rep(i,N){
        cin>>a[i];
    }
    if(N%2==0){
        for(int i=N-1;i>0;i-=2){
            cout<<a[i]<<" ";
        }
        for(int i=0;i<N-1;i+=2){
            cout<<a[i]<<" ";
        }
        out("");
    }
    else{
        for(int i=N-1;i>=0;i-=2){
            cout<<a[i]<<" ";
        }
        for(int i=1;i<N-1;i+=2){
            cout<<a[i]<<" ";
        }
        out("");
    }
}

Measured memory_bytes: 2944
import java.util.*;
// import java.io.*;
// import java.time.*;

public class Main {
    static StringBuilder sb;

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

        int num = sc.nextInt();

        ArrayList<Integer> array = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            array.add(sc.nextInt());
        }

        int query = sc.nextInt();

        for (int i = 0; i < query; i++) {
            int key = sc.nextInt();
            int tmp = BinarySearch(array, key);
            if (tmp < 0) sb.append(num).append("\n");
            else sb.append(tmp).append("\n");
        }

        System.out.print(sb);
        
        sc.close();
    }

    public static int BinarySearch(List<Integer> list, int key) {
        int lower = -1;
        int middle = -1;
        int upper = list.size();

        while (upper > lower + 1) {
            middle = lower + (upper - lower) / 2;
            if (list.get(middle) > key - 1) upper = middle;
            else lower = middle;
        }

        return upper;
    }
}



Measured memory_bytes: 109528
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long x, y;
	cin >> x >> y;
	long long ans = 0;
	while(y >= x){
		y /= 2;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
void print(char str[],int length,int begin)
{
	for(int i = 0;i < length;i++)
	{
		cout << str[(begin + i) % length];
	}
	cout << endl;
}
int main()
{
	char inputStr[200] = {'\0'};
	int length = 0;
	int index = 0;

	while (true)
	{
		cin >> inputStr;
		if(strcmp(inputStr,"-") == 0)
			break;
		index = 0;
		length = strlen(inputStr);
		int m,h;
		cin >> m;
		for(int i = 0;i < m;i++)
		{
			cin >> h;
			index = (index + h) % length;
		}
		print(inputStr, length, index);
	}
	return 0;
}


Measured memory_bytes: 3068
N = input()
K = int(input())
L = len(N)

dp =[[[ 0 for _ in range(2)] for _ in range(5)] for _ in range(len(N)+1)]
# dp[i][j][flg] i+1桁目までで0以外の個数がj個
# flg = 1 -> N 以下が確定している

dp[0][1][1] = int(N[0])-1
dp[0][1][0] = 1
dp[0][0][1]=1
for i in range(1,L):
  for j in range(4):
    b = i-1 # hitotumae
    now = int(N[i])
    ## N上限に張り付いてる方
    if now == 0:
      dp[i][j][0] += dp[b][j][0]
    else:
      dp[i][j][1] += dp[b][j][0]
      dp[i][j+1][1] += dp[b][j][0] * (now-1)
      dp[i][j+1][0] += dp[b][j][0]
    ## 張り付いてない方
    dp[i][j][1] += dp[b][j][1]
    dp[i][j+1][1] += dp[b][j][1] * 9
  

print(dp[L-1][K][0] + dp[L-1][K][1])


Measured memory_bytes: 9136
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#include<unordered_map>
#define ll long long int
using namespace std;

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int a, b, h, m;
	cin >> a >> b >> h >> m;

	double angle1 = acos(-1) * (h * 60 + m) / (360.0);
	double angle2 = acos(-1) * m / 30.0;
	double angle = abs(angle1 - angle2);

	double distsq = a * a + b * b - 2 * a * b * cos(angle);
	double dist = sqrt(distsq);
	printf("%0.10lf", dist);

	return 0;
}




Measured memory_bytes: 4192
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

const size_t N = 1e5 + 5;

char s[N];
int nxtL[N], preR[N], ans[N];

int main() {
    scanf("%s", s);
    int n = strlen(s);
    {
        int cur = n;
        for (int i = n - 1; i >= 0; --i) {
            if (s[i] == 'L') {
                cur = i;
            }
            nxtL[i] = cur;
        }
    }
    {
        int cur;
        for (int i = 0; i < n; ++i) {
            if (s[i] == 'R') {
                cur = i;
            }
            preR[i] = cur;
        }
    }
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') {
            int j = nxtL[i];
            if ((j - i) & 1) {
                ++ans[j - 1];
            } else {
                ++ans[j];
            }
        } else {
            int j = preR[i];
            if ((i - j) & 1) {
                ++ans[j + 1];
            } else {
                ++ans[j];
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        printf("%d ", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    set<int>s;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    if(n%2) cout<< "0";
    else cout<< a[n/2]-a[n/2-1];
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  sort(ALL(s));
  cout << (s == "abc" ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[10]={0,0,0,0,0,0,0,0,0,0};
int main()
{
	string n;
	cin>>n;
	if(n[0]==n[1]&&n[1]==n[2]||n[1]==n[2]&&n[2]==n[3])
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256