akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int A,B,C;
    cin >> A >> B >> C;
    cout << min(B/A, C) << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

vector<ll> G[10101];
ll idx = 0;
vector<ll> res(10101);

void dfs(ll now, ll par, vector<ll> &c){
	res[now] = c[idx];
	idx++;
	REP(i, G[now].size()){
		if(G[now][i] == par) continue;
		dfs(G[now][i], now, c);
	}
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N-1){
    	ll a, b;
    	cin >> a >> b;
    	a--, b--;
    	G[a].push_back(b);
    	G[b].push_back(a);
    }
    vector<ll> c(N);
    REP(i, N) cin >> c[i];
    sort(c.rbegin(), c.rend());
    dfs(0, -1, c);
    ll sum = 0;
    REP(i, N-1) sum += c[i+1];
    cout << sum << endl;
    REP(i, N) cout << res[i] << " ";
    cout << endl;
    return 0;
}

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

using namespace std;

class Graph
{
public:
    int V;
    list<int> *adj;

    Graph(int V)
    {
        this->V = V;
        adj = new list<int>[V+1];
    }
    void addedge(int u,int v)
    {
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    void bfs(int s)
    {
        bool *visited = new bool[V +1];
        for(int i=0;i<V;i++) visited[i] =false;
        queue<int> Q;
        Q.push(s);
        while(!Q.empty())
        {
            int b = Q.front();
            Q.pop();
            for(list<int>::iterator i = adj[b].begin();i!=adj[b].end();i++)
            {
                if(!visited[*i])
                {
                    Q.push(*i);
                }
            }
        }
    }

    bool solve(int u,int v)
    {
        for(list<int>::iterator i = adj[u].begin();i!=adj[u].end();i++)
        {   int x = *i;
            for(list<int>::iterator j = adj[x].begin();j!=adj[x].end();j++)
            {
                if((*j) == v)
                    return true;
            }
        }
        return false;
    }



};

int main()
{
    int N,M;
    scanf("%d %d",&N,&M);
    Graph g(N);
    for(int i=0;i<M;i++)
    {
        int u,v;
        scanf("%d %d",&u,&v);
        g.addedge(u,v);
    }
    if(g.solve(1,N))
        printf("POSSIBLE\n");
    else
        printf("IMPOSSIBLE\n");

}


Measured memory_bytes: 15872
#include <stdio.h>



int main(){
    int i, j, k;
    int n, x, cnt;
    



    while(scanf("%d %d", &n, &x), n > 0){
        cnt = 0;
        
        for(i = 1; i <= n; ++i){
            for(j = i + 1; j <= n; ++j){
                for(k = j + 1; k <= n; ++k){
                    if(i + j + k == x){
                        ++cnt;
                    }
                }
            }
        }
        
        printf("%d\n", cnt);
    }
    
    
return 0;

}

Measured memory_bytes: 600
n, m = map(int, input().split())
e = [tuple(map(int, input().split())) for _ in range(m)]
d = [-float('inf')]*(n+1)
d[1] = 0
for _ in range(n):
    for i,j,c in e:
        d[j] = max(d[j], d[i]+c)
t = d[n]
for _ in range(n):
    for i,j,c in e:
        d[j] = max(d[j], d[i]+c)

if t < d[n]:
    print('inf')
else:
    print(d[n])

Measured memory_bytes: 3316
import collections

mod = 1000000007

def solve():
    n,m = map(int,input().split())
    x = list(map(int,input().split()))
    y = list(map(int,input().split()))
    X = int()
    for i in range(1,n):
        X += (x[i]-x[i-1])*i*(n-i)
        X %= mod
    Y = int()
    for i in range(1,m):
        Y += (y[i]-y[i-1])*i*(m-i)
        Y %= mod
    print((X*Y)%mod)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 19008
# -*- coding: utf-8 -*-
"""
Created on Sun Dec  2 18:42:44 2018
ABC084D
@author: maezawa
"""

n = int(10**5)
is_prime = [True]*(n+1)

is_prime[0] = False
is_prime[1] = False

for i in range(2, n//2):
    if is_prime[i] == True:
        for j in range(2*i,n+1,i):
            is_prime[j] = False

prime_numbers = set([i for i in range(n+1) if is_prime[i]])
similar = set([])

for i in prime_numbers:
    if (i+1) // 2 in prime_numbers:
        similar.add(i)
        
sim = [0]*(n+1)    
cnt = 0    
for i in range(n+1):
    if i in similar:
        cnt += 1
    sim[i]=cnt  

q = int(input())
for _ in range(q):
    l, r = list(map(int, input().split()))
    print(sim[r]-sim[l-1])
        
        
    

Measured memory_bytes: 5888
//By Don4ick 
//#define _GLIBCXX_DEBUG

#pragma GCC optimize("0")

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = 105;

using namespace std;

int n, m, a[N][N], dp[N][N][N][N];

int get(int x1, int y1, int x2, int y2)
{
	if (x1 != x2 && y1 != y2)
		assert(false);	
	return max(0, a[x2][y2] - a[x1 - 1][y2] - a[x2][y1 - 1] + a[x1 - 1][y1 - 1]);
}

int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie();
	//cout.tie();		

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	cin >> n >> m;
	int x = -1, y = -1;
	forn(i, n)
	{
		string s;
		cin >> s;
		for (int j = 0; j < (int)s.size(); j++)
		{		
			if (s[j] == 'E')
			{
				x = i, y = j + 1;
			}
			else if (s[j] == 'o')
			{
				a[i][j + 1] = 1;
			}
		}
	}
	forn(i, n)
		forn(j, m)
			a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
	//~solve
	int ans = 0;
	for (int l = 0; l <= x - 1; l++)
	{	
		for (int r = 0; r <= n - x; r++)
		{
			for (int u = 0; u <= y - 1; u++)
			{
				for (int d = 0; d <= m - y; d++)
				{
					if (l < x - 1 && x - l - 1 >= r + 1)
						dp[l + 1][r][u][d] = max(dp[l + 1][r][u][d], dp[l][r][u][d] + get(x - l - 1, max(d + 1, y - u), x - l - 1, min(m - u, y + d)));
					if (r < n - x && x + r + 1 <= n - l)
						dp[l][r + 1][u][d] = max(dp[l][r + 1][u][d], dp[l][r][u][d]	+ get(x + r + 1, max(d + 1, y - u), x + r + 1, min(m - u, y + d)));
					if (u < y - 1 && y - u - 1 >= d + 1)
						dp[l][r][u + 1][d] = max(dp[l][r][u + 1][d], dp[l][r][u][d] + get(max(r + 1, x - l), y - u - 1, min(x + r, n - l), y - u - 1));
					if (d < m - y && y + d + 1 <= m - u)
						dp[l][r][u][d + 1] = max(dp[l][r][u][d + 1], dp[l][r][u][d] + get(max(r + 1, x - l), y + d + 1, min(x + r, n - l), y + d + 1));
					ans = max(ans, dp[l][r][u][d]);
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 227968
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 500005
#define M 100000000
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (lli)(x.size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"Yes\n";
#define N cout<<"No\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;

void solve()
{

    lli d,t,s;
    cin>>d>>t>>s;
    // print2(d,(d/s))
    if(d<=(s*t))
    {
        Y
    }
    else
    {
        N
    }



}


int main()
{
    fast
    #ifndef ONLINE_JUDGE
     freopen("inputa.txt", "r", stdin);
     freopen("outputa.txt", "w", stdout);
    #endif    
     
     // test
     {
          solve();
          nl
     }
}
//a+b=a?b+2?(a&b)
//__builtin_popcnt(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";

Measured memory_bytes: 3640
n = int(input())
p = map(int,input().split())
p = list(p)

count = 0
for k in range(1,n-1):
    if p[k-1] < p[k]:
        if p[k] <= p[k+1]:
            count = count + 1
        elif p[k-1] == p[k+1]:
            count = count + 1
    elif p[k-1] >= p[k] and p[k] > p[k+1]:
        count = count + 1

print(count)


Measured memory_bytes: 3060
n = int(input())
li = list(map(int, input().split()))
dp = [0]*n
dp[1] = abs(li[0]-li[1])
for i in range(2, n):
	dp1 = dp[i-1] + abs(li[i]-li[i-1])
	dp2 = dp[i-2] + abs(li[i]-li[i-2])
	dp[i] = min(dp1, dp2)
print(dp[n-1])

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

int n, m, q;
const int maxn = 1e5 + 5;
vector<int> G[maxn];

int d[maxn], z[maxn], c[maxn];
int col[maxn];

bool vis[maxn][15];

void dfs(int u, int dis, int color){
    if(vis[u][dis])
        return;
    vis[u][dis] = true;
    if(col[u] == 0){
        col[u] = color;
    }
    if(dis == 0){
        return;
    }
    for(auto v : G[u]){
        dfs(v, dis - 1, color);
    }
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for(int i = 1;i <= m;i++){
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    cin >> q;
    for(int i = 1;i <= q;i++){
        cin >> z[i] >> d[i] >> c[i];
    }
    for(int i = q;i >= 1;i--){
        dfs(z[i], d[i], c[i]);
    }
    for(int i = 1;i <= n;i++){
        cout << col[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 9592
using System;
using System.Collections.Generic;
using System.Linq;

class Hello{
static void Main(){
    
List <string> slist=new List<string>();
string [] str;

long kaisu=long.Parse(Console.ReadLine());
str=Console.ReadLine().Split(' ');

slist.AddRange(str);

List<long> list = slist.ConvertAll(x => long.Parse(x));
Console.WriteLine("{0} {1} {2}",list.Min(),list.Max(),list.Sum());
}
}


Measured memory_bytes: 18684
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[200010];
int B[200010];
int X=0;

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
		X^=A[i];
	}
	DEB(X)END
	REP(i,N){
		B[i]=A[i]^X;
	}
	REP(i,N){
		cout<<B[i];
		if(i<N-1)cout<<" ";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 6736
def collatz(x):
    if x%2==0:
        return int(x/2)
    return 3*x +1



s = int(input())
stack = [s]
index = 1
while True:
    s = collatz(s)
    index += 1
    if s in stack:
        print(index)
        break
    stack.append(s)


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


int main() {
	
	int N;
	cin >> N;
	vector<int> a(N);
	for (auto &i : a) cin >> i;
	sort(a.begin(), a.end());
	cout << a.back() - a.at(0) << endl;
	
	return 0;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if(A+B==C+D){
    cout << "Balanced" << endl;
  }
  if(A+B > C+D) {
    cout << "Left" << endl;
  }
  if(A+B < C+D) {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n+1];
  a[0]=0;
  int count=0;
  for(int i=1;i<=n;i++)
    cin>>a[i];
  for(int i=1;i<=n;i=i+2)
  {
    if(a[i]%2==1)
      count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3588
fun combination2(m : Long) : Long{
    return m * (m - 1L) / 2L
}

fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val la = readLine()!!.split(" ").map(String::toLong)

    val lCumSum = mutableListOf(0L)
    for(i in 1..n){
        lCumSum.add(lCumSum[i - 1] + la[i - 1])
    }
    lCumSum.sort()
    var retValue = 0L
    var elm = lCumSum[0]
    var cntSame = 1L
    for(i in 1..n){
        if(lCumSum[i] == elm){
            cntSame++
            if(i == n) retValue += combination2(cntSame)
        }
        else{
            retValue += combination2(cntSame)
            elm = lCumSum[i]
            cntSame = 1L
        }
    }
    println(retValue)
}

Measured memory_bytes: 81256
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <vector>
#include <map>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 200005, mod = 1000000007;
int color[maxn], weight[maxn];
std::vector<int> con[maxn];
int min[maxn];
int fa[maxn];
std::map<int, int> map[maxn];
ll fac[maxn], ifac[maxn];

inline ll power(ll x, int k) {
	if(k < 0) k += mod - 1;
	ll res = 1;
	while(k) {
		if(k & 1) (res *= x) %= mod;
		(x *= x) %= mod;
		k >>= 1;
	}
	return res;
}

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

inline void merge(int x, int y) {
	/* debug("%d - %d\n", x, y); */
	x = find(x);
	y = find(y);
	fa[x] = y;
}

int main() {
	int n = read, x = read, y = read;
	weight[0] = 2000000000;

	for(int i = 1; i <= n; i ++) {
		read(color[i], weight[i]);
		con[color[i]].push_back(i);
		if(weight[i] < weight[min[color[i]]])
			min[color[i]] = i;
	}

	for(int i = 1; i <= n; i ++)
		fa[i] = i;

	int minc = 0, minc2 = 0;
	for(int c = 1; c <= n; c ++)
		if(weight[min[c]] < weight[min[minc]]) {
			minc2 = minc;
			minc = c;
		} else if(weight[min[c]] < weight[min[minc2]])
			minc2 = c;

	/* debug("%d %d\n", minc, minc2); */

	for(int c = 1; c <= n; c ++)
		for(int p : con[c])
			if(weight[p] + weight[min[c]] <= x)
				merge(p, min[c]);

	for(int c = 1; c <= n; c ++)
		for(int p : con[c]) {
			if(c != minc and weight[p] + weight[min[minc]] <= y)
				merge(p, min[minc]);
			if(c != minc2 and weight[p] + weight[min[minc2]] <= y)
				merge(p, min[minc2]);
		}

	for(int i = 1; i <= n; i ++)
		++ map[find(i)][color[i]];

	ll ans = 1;

	fac[0] = 1;
	for(int i = 1; i <= n; i ++)
		fac[i] = fac[i - 1] * i % mod;
	ifac[n] = power(fac[n], -1);
	for(int i = n; i; i --)
		ifac[i - 1] = ifac[i] * i % mod;

	for(int i = 1; i <= n; i ++)
		if(fa[i] == i) {
			int tot = 0;
			for(auto pr : map[i]) {
				tot += pr.second;
				(ans *= ifac[pr.second]) %= mod;
				/* debug("%d in %d\n", pr.second, i); */
			}
			(ans *= fac[tot]) %= mod;
		}

	printf("%lld\n", ans);
}


Measured memory_bytes: 34176
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
/*
ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=2000005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

ll nPk(ll n,ll k){
	return nCk(n,k)*F[k]%mod;
}*/

int n,m,x,res=0;
vvi a;

int main(){
	cin>>n>>m>>x;
	a=vvi(n,vi(m));
	for(int i=0;i<n;i++) for(int j=0;j<m;j++){
		char c;
		cin>>c;
		if(c=='#') a[i][j]++;
	}
	for(int i=0;i<1<<n;i++) for(int j=0;j<1<<m;j++){
		int t=0;
		for(int k=0;k<n;k++) for(int l=0;l<m;l++) if(i&1<<k&&j&1<<l) t+=a[k][l];
		if(t==x) res++;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

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

int main(void){
  string line;
  int ans = 0;
  while(cin>>line){
    string rev = line;
    reverse(rev.begin(),rev.end());
    if(line==rev) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				int n=sc.nextInt();
				int m=sc.nextInt();
				if(n+m==0) break;
				int[] t=new int[n+1];
				int[] h=new int[m+1];
				int tsum=0, hsum=0;
				for(int i=0; i<n; i++) {
					t[i]=sc.nextInt();
					tsum+=t[i];
				}
				for(int i=0; i<m; i++) {
					h[i]=sc.nextInt();
					hsum+=h[i];
				}
				int tnow=0, hnow=0;
				int change=1000000;
				int imin=0, jmin=0;
				for(int i=0; i<n; i++) {
					for(int j=0; j<m; j++) {
						tnow=tsum-t[i]+h[j];
						hnow=hsum-h[j]+t[i];
						if(tnow==hnow) {
							if(t[i]+h[j]<change) {
								imin=t[i];
								jmin=h[j];
								change=t[i]+h[j];
							}
						}
					}
				}
				if(change==1000000) {
					System.out.println(-1);
				}
				else {
					System.out.println(imin+" "+jmin);
				}
				
				
			}


		}
	}
}


Measured memory_bytes: 28952
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int n;
	int a[101] = {};
	int max = 0;
	while (cin >> n) {
		a[n]++;
		if (max < a[n])max = a[n];
	}
	for (int i = 0; i < 101; i++)if(max==a[i])cout << i << endl;
	return 0;
}

Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define mod (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}

void solve() {
    int h, w, n;
    cin >> h >> w >> n;
    if (h > w) swap(h, w);
    int sum = 0;
    rep(i, h) {
        if (sum >= n) {
            cout << i << endl;
            return;
        }
        sum += w;
    }
    cout << h << endl;
}


Measured memory_bytes: 892
#include <stdio.h>

int main()
{
	int N, K;
	scanf("%d %d", &N, &K);
	
	int str[100000];
	scanf("%s", str);
	
	N = N - K;
	int Ans = 1;
	
	
	while(N > 0){
		N = N - ( K - 1 );
		Ans ++;
	}
	
	printf("%d", Ans);
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        int num;
        int avg;
        int count;
        while(true){
            avg = 0;
            count = 0;
            num = sc.nextInt();
            if(num == 0){
                break;
            }
            int[] data = new int[num];
            
            for(int i = 0; i < num; i++){
                data[i] = sc.nextInt();
                avg += data[i];
            }
            avg /= num;
            
            for(int i = 0; i < num; i++){
                if(data[i] <= avg){
                    count++;
                }
            }
            System.out.println(count);
        }
    }
}


Measured memory_bytes: 58648
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define pb push_back
// #define mp make_pair
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 1000005
#define mid(l, r) l + (r - l) / 2
#define veci vector<int>
#define vecl vector<ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define umapi unordered_map<ll, ll>
#define umapc unordered_map<char, int>
#define endl "\n"
#define pui pair<int, pair<int,int> >
using namespace std;

vector<int> ans(N+1,N);
unordered_map<int,veci> mp;
int n,m;

void bfs() {

    queue<int> q;
    q.push(1);
    while(!q.empty()) {
        int size = q.size();
        while(size--) {
            int temp = q.front();
            q.pop();

            for(auto it : mp[temp]) {
                if(ans[it] == N) {
                    ans[it] = temp;
                    q.push(it);
                }
            }

        }
    }
}

void solve(){
    
    
    cin>>n>>m;

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

        mp[a].pb(b);
        mp[b].pb(a);
    }

    bfs();
    
    // rep(i,n+1) {
    //     cout<<ans[i]<<" ";
    // }

    bool check = true;
    for(int i=2; i<=n; i++) {
        if(ans[i] == N) {
            check = false;
            break;
        }
    }

    if(check == false) {
        cout<<"No";
    } else {
        cout<<"Yes"<<endl;
        for(int i=2; i<=n; i++) {
            cout<<ans[i]<<endl;
        }
    }



}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}



Measured memory_bytes: 17112
# https://atcoder.jp/contests/abc161/tasks/abc161_b

N, M = gets.split.map(&:to_i)
As = gets.split.map(&:to_i)
sum = As.reduce(&:+)
cond = As.count { |a| a >= (sum - 1) / (4 * M) + 1 } >= M
puts cond ? 'Yes' : 'No'


Measured memory_bytes: 14164
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	int a, b;
	cin >> a >> b;
	if (b < a)a--;
	cout << a << endl;
}


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

int main()
{
  int A, B, r = 0;
  std::cin >> A >> B;
  
  auto& x = A > B ? A : B;
  r += x;
  x--;
  
  r += A > B ? A : B;
  
  std::cout << r << std::endl;
}

Measured memory_bytes: 256
from sys import stdin
import math


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    A,B,H,M = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    hour_ = (H+M/60)/12*(2*math.pi)
    min_ = M/60*(2*math.pi)
    theta = hour_ - min_
    cnt = math.sqrt(A**2+B**2-2*A*B*math.cos(theta))
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 62420
#include <iostream>
#include <string>

using namespace std;

int main() {
	string str;
	char s, e;
	int n;

	cin >> str;

	s = str[0];
	e = str[str.size() - 1];
	n = str.size() - 2;
	
	cout << s << n << e << endl;

	return 0;
}

Measured memory_bytes: 256
// Problem : O - Matching
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_o
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 23

//Solution

int n,a[N][N],dp[1LL<<N];

void solve(){
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++) cin>>a[i][j];
    }
    dp[0] = 1;
    for(int mask=0;mask<(1LL<<n);mask++){
        int i = __builtin_popcountll(mask);
        for(int j=0;j<n;j++){
            if(a[i][j] && !((mask>>j)&1)){
                (dp[(mask)^(1LL<<j)] += dp[mask]) %= mod;
            }
        }
    }
    cout<<dp[(1LL<<n)-1];
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<typename T>
T mypow(T a, T n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = mypow(a, n/2);
    return res * res;
  }
  return a * mypow(a, n-1);
}

int main(){
  int d, n;
  cin >> d >> n;
  if(n == 100) n++;
  int ans = mypow(100, d) * n;
  cout << ans << endl;
}

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

int N, A[10'001], B[10'001], C[10'001];

int main(){
    cin >> N;
    for(int i=0;i<N-1;i++)    cin >> A[i] >> B[i];
    for(int i=0;i<N;i++)    cin >> C[i];

    sort(C, C+N);

    vector< vector<int> > G(N+1);

    for(int i=0;i<N;i++){
        G[ A[i] ].push_back(B[i]);
        G[ B[i] ].push_back(A[i]);
    }

    for(int i=1;i<=N;i++){
        sort(G[i].begin(), G[i].end());
    }

    vector<int> ans(N+1);

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

    for(int i=0;i<N-1;i++){
        int index;
        for(int j=1;j<=N;j++){
            if(G[j].size() == 1){
                index = j;
                break;
            }
        }
        if(!G[index].empty()){
            int tmp = G[index][0];
            G[index].erase(G[index].begin());
            vector<int>::iterator index2 = lower_bound(G[tmp].begin(), G[tmp].end(), index);
            G[tmp].erase(index2);
            ans[index] = C[i];
        }
    }

    for(int i=1;i<=N;i++){
        if(ans[i] == 0) ans[i] = C[N-1];
    }

    cout << accumulate(C, C+N, 0) - C[N-1] << endl;

    for(int i=1;i<=N;i++){
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

const int sz = 510;
bool cat[sz][sz];

int main(){
  memset(cat, false, sizeof(cat));
  string str;
  cin >> str;
  int n = str.size();
  REP(i,n+1) cat[i][0] = true;
  for(int w = 3; w <= n; w++){
    for(int i = 0; i < n - w + 1; i++){
      if(str[i] == 'm' && str[i+w-1] == 'w'){
        for(int j = i + 1; j < i + w - 1; j++){
          if(str[j] == 'e' && cat[i+1][j-i-1] && cat[j+1][i+w-j-2]){
            cat[i][w] = true;
          }
        }
      }
    }
  }
  cout << (cat[0][n] ? "Cat" : "Rabbit") << endl;
  
  return 0;
}

Measured memory_bytes: 1444
# -*- coding: utf-8 -*-
"""
A - Addition
https://atcoder.jp/contests/agc010/tasks/agc010_a

"""
import sys


def solve(N, A):
    odds = [a for a in A if a%2]
    if len(odds) % 2:
        return 'NO'
    return 'YES'


def main(args):
    N = int(input())
    A = [int(a) for a in input().split()]
    ans = solve(N, A)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 14112
def main():
    N, M = map(int, input().split())
    L = 0
    R = N
    for _ in range(M):
        l, r = map(int, input().split())
        if L < l:
            L = l
        if R > r:
            R = r
    ans = 0
    if L <= R:
        ans = R - L + 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>
#include <time.h>
#include <stdio.h>

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

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) a.begin(), a.end()

template<typename T>
void vdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		if (i == size - 1) {
			cout << da[i] << endl;
		}
		else {
			cout << da[i] << ' ';
		}
	}
}
template<typename T>
void vvdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		vdeb(da[i]);
	}
}

int main(){
	int n;
	cin >> n;
	vector<pair<string,int>> da(n);
	rip(i,n,0) cin >> da[i].first >> da[i].second;
	string x;cin >> x;
	int ans = 0;
	bool ju = false;
	rip(i,n,0){
		if(ju) ans += da[i].second;
		if(x == da[i].first) ju = true;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from bisect import bisect_right

def main():
    inf=float("inf")
    n=int(input())
    alst=[int(input()) for _ in range(n)]
    work=[inf]*n
    for i in range(n-1,-1,-1):
        j=bisect_right(work,alst[i])
        work[j]=alst[i]
    print(n-work.count(inf))

main()

Measured memory_bytes: 13840
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n, m;
int in[5001];
bool win[5001][5001];
bool used[5001];
vector<int> to[5001];
vector<int> ans;

void dfs(int x){
	used[x] = true;
	for(auto u : to[x]){
		if(!used[u]) dfs(u);
	}
	ans.push_back(x);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		to[a].push_back(b);
		win[a][b] = true;
		in[b]++;
	}
	for(int i = 1; i <= n; i++){
		if(in[i] == 0) dfs(i);
	}
	reverse(ans.begin(), ans.end());
	for(int i = 0; i < n; i++){
		cout << ans[i] << endl;
	}
	bool flag = false;
	for(int i = 1; i < n; i++){
		if(!win[ans[i - 1]][ans[i]]) flag = true;
	}
	cout << (flag ? 1 : 0) << endl;
	return 0;
}


Measured memory_bytes: 28344
import java.util.Scanner;

public class Main {

    public static int queryCount=0;
    public static void main(String[] args) {
	// write your code here
        Scanner scanner=new Scanner(System.in);
        int x=scanner.nextInt();
        int a=scanner.nextInt();
        int b=scanner.nextInt();
        System.out.println(x-a-(x-a)/b*b);
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
const int INF = 1 << 12;
int main()
{
	int map[21][21];
	int n, m,a,b,c,d;
	int x, y, xx, yy;
	char s;
	cin >> n;
	cin >> m;
	for (int i = 0; i <= n; i++){
		for (int i2 = 0; i2 <= n; i2++){
			map[i][i2] = INF;
		}
	}
	
	for (int i = 0; i < m; i++){
		cin >> a >> s >> b >> s >> c >> s >> d;
		map[a][b] = c;
		map[b][a] = d;
	}
	for (int k = 0; k <= n; k++){
		for (int i = 0; i <= n; i++){
			for (int i2 = 0; i2 <= n; i2++){
				map[i][i2] = min(map[i][i2],map[i][k] + map[k][i2]);
			}
		}
	}
	cin >> x >> s >> y >> s >> xx >> s >> yy;
	int ans = xx - (yy + map[x][y] + map[y][x]);
	cout << ans << endl;
}

Measured memory_bytes: 1160
#include <iostream>
		using namespace std;         
		string next(string in) {
        	if (in == "Sunny")
                return "Cloudy";
            else if (in == "Cloudy")
                return "Rainy";
            return "Sunny";
        }
         
        int main() {
          	string in;
          	cin >> in;
          	cout << next(in) << endl;
          	fflush(stdout);
        	return 0;
        }

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <random>
#include <cassert>
#include <limits>

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long long i = p; i < q; i++)
#define repd(i, p, q) for (long long i = p; i >= q; i--)
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> M;
typedef map<long, long> ML;
typedef map<long long, long long> MLL;
typedef pair<int, int> P;
typedef pair<long, long> PL;
typedef pair<long long, long long> PLL;
typedef int I;
typedef double D;
typedef long double LD;
typedef long L;
typedef long long LL;

int main()
{
    string a;
    cin >> a;
    LL counter = 0;
    LL ans = 0;
    for (LL i = a.length() - 1; i >= 0; i--)
    {
        if (a[i] == 'W')
        {
            counter++;
        }
        else
        {
            ans = ans + counter;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

	int sum = 0, maxi = 0;
	rep(i,n.size()){
		if(n[i] == '0') continue;
		sum += n[i] - '0';
		maxi = max<int>(maxi, sum - 1 + 9 * (n.size() - i - 1));
	}
	cout << max(maxi, sum) << endl;
}


Measured memory_bytes: 256
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
an = [a1, a2, a3]
n = int(input())
bn = []
counter = 0
for _ in range(n):
  bn.append(int(input()))
  
for i in bn:
  for j in an:
    if i in j:
      j[j.index(i)] = 0

for k in an:
  if k.count(0) == 3:
    print('Yes')
    exit()
    
for l in range(3):
  if an[0][l] == 0 and an[1][l] == 0 and an[2][l] == 0:
    print('Yes')
    exit()
    
if an[0][0] == 0 and an[1][1] == 0 and an[2][2] == 0:
  print('Yes')
  exit()
if an[0][2] == 0 and an[1][1] == 0 and an[2][0] == 0:
  print('Yes')
  exit()
  
print('No')


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
int main(int argc, char const *argv[])
{
   int N, K;
   cin >> N >> K;
   vector<int> h(N);
   for (int i = 0; i < N; i++)
   {
      cin >> h[i];
   }
   int cnt = 0;
   for (int i = 0; i < N; i++)
   {
      if(h[i] >= K)
      {
         cnt++;
      }
   }
   cout << cnt << endl;
   return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cstdlib>
#include<string>
#include<cmath>
using namespace std;

struct Dice{
  int num[6];
};

int main(){
    vector<int> number(6);
    Dice d1,d2;
    for(int i=0; i<6; i++){
        cin>>d1.num[i];
    }
    for(int i=0; i<6; i++){
        cin>>d2.num[i];
    }
    int r[3][4]={{1,2,6,5} , {1,3,6,4} , {2,3,5,4}};
    int dtop=d1.num[0];
    int n=d1.num[4],e=d1.num[2],s=d1.num[1],w=d1.num[3];
    int top=d2.num[0];
    int front=d2.num[1];
    if(top==d1.num[2]){
        w=dtop;
        dtop=e;
        e=7-w;
    }else if(top==d1.num[3]){
        e=dtop;
        dtop=w;
        w=7-e;
    }else{
        for(int j=0;j<4; j++){
            if(r[0][j]==top) break;
            n=dtop;
            dtop=s;
            s=7-n;
        }
    }

    int rnum=0;
    for(int j=0; j<3; j++){
        for(int k=0; k<4; k++){
            if(r[j][k]==top) break;
            if(k==3) rnum=j;
        }
    }

    for(int j=0; j<4; j++){
        if(front==s) break;
        int tmp=n;
        n=w;
        w=s;
        s=e;
        e=tmp;
    }
    if(e==d2.num[2] && w==d2.num[3]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main(){
	int m,n;
	cin>>n;
	m=0;
	vector<int>s(n);
	for(int i=0;i<n;i++){
		cin>>s.at(i);
		for(int j=0;j<30;j++){
			if(s.at(i)%2==0){
				s.at(i)/=2;
				m++;
				continue;
			}break;
		}
	}
	cout<<m<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int K = in.nextInt();
        StringBuilder s = new StringBuilder();
        for (int i = 0; i < K; i++) {
            s.append("ACL");
        }
        System.out.println(s.toString());
    }
}


Measured memory_bytes: 35752
def II(): return int(input())
N=II()
tbl=[0]*101
for i in range(1,N+1):
  i=str(i)
  tbl[int(i[0]+i[-1])]+=1
ans=0
for i in range(1,N+1):
  i=str(i)
  ans+=tbl[int(i[-1]+i[0])]
print(ans)
      

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

int n,res=0,a[100005];

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int Count=0;
    for(int i=1;i<=n;i++)
        if(a[i]==i)
            Count++;
        else
        {
            res+=(Count+1)/2;
            Count=0;
        }
    if(Count>0)
        res+=(Count+1)/2;
    cout<<res;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
 int n;
 cin>>n;
 if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
    cout<<"hon";
 else if(n%10==0||n%10==1||n%10==6||n%10==8)
    cout<<"pon";
    else if(n%10==3)
    cout<<"bon";
    return 0;
}


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int a,b,c;
	cin >> a >> b >> c;
	cout << (c>=a && c<=b ? "Yes" : "No") << endl;

	
//////////////////////////////////////////////
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))
m=int(input())
b=list(map(int, input().split()))
d={0:1}
for i in a:
    for j in list(d):
        d[j+i]=1
for i in b:
    if i in d:print('yes')
    else:print('no')


Measured memory_bytes: 5652
using System;
using System.Linq;

namespace arc075_b
{
    class Program
    {
        static int[] x;
        static int[] a;
        static bool can(long n)
        {
            int count = 0;
            for (int i = 0; i < x[0]; i++)
            {
                double d = (double)(a[i] - x[2] * n) / (x[1] - x[2]);
                count += Math.Max((int)Math.Ceiling(d), 0);
                if (count > n) return false;
            }
            return true;
        }
        static long Binary_search()
        {
            long low = 0;
            long high = a.Max() / x[2] + 10;
            long mid;
            while (Math.Abs(high - low) > 1)
            {
                mid = (low + high) / 2;
                if (can(mid)) high = mid;
                else low = mid;
            }
            return high;
        }
        static void Main(string[] args)
        {
            x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            a = new int[x[0]];
            for (int i = 0; i < x[0]; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }
            Console.WriteLine(Binary_search());
        }
    }
}

Measured memory_bytes: 15824
#include <stdio.h>

int main(){
  int l[11] = {}, i, dis, v1, v2;
  double t, al;

  while(1){
    dis = t =  0;
    for(i = 1;i <= 10;i++){
      if(scanf("%d,", &l[i]) == EOF) return 0;
      dis += l[i];
    }
    scanf("%d,%d", &v1, &v2);
    for(i = 1;i <= 10;i++){
      t += (double)l[i] / v1;
      al = t * (double)(v1 + v2);
      if(dis <= al) break;
    }
      printf("%d\n", i);
  }
}

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

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n);
  vector<int> b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  
  ll t = 0;
  
  rep(i, m) t += b[i];
  
  int j = m;
  int ans = 0;
  rep(i, n+1){
  	while(j > 0 && t > k){
      --j;
      t -= b[j];
    }
    if(t > k) break;
    ans = max(ans, i+j);
    if(i == n) break;
    t += a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4820
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

typedef struct {
  int index;
  int num;
} Rest;

int main() {
  map< string, vector< int > > m;
  map< string, int > order;

  int N;
  cin >> N;

  string city;
  int num;

  for (int i = 0; i < N; i++) {
    cin >> city;
    cin >> num;

    if (m.find(city) == m.end()) {
      vector< int > nums;
      nums.push_back(num);
      m[city] = nums;
    } else {
      m[city].push_back(num);
    }

    order[city + "_" + to_string(num)] = i + 1;
  }

  for (auto it = m.begin(); it != m.end(); ++it) {
    string city = it->first;
    vector< int > nums = it->second;

    sort(nums.begin(), nums.end(), greater< int >());

    for (auto num : nums) {
      cout << "" << order[city + "_" + to_string(num)] << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

// Input
#[allow(unused_macros)]
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
#[allow(unused_imports)]
use std::cmp::{min,max};

// Main
fn main(){
    input!{
        n: i64,
        k: i64,
        x: i64,
        y: i64,
    }
    println!("{}", x*min(n,k) + max(0,n-k)*y);
}


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

int main()
{
    int x;
    cin>>x;
    if(400<=x&& x<=599)
        cout<<8;
    else if(600<=x&&x<=799)
        cout<<7;
    else if(800<=x&&x<=999)
        cout<<6;
    else if(1000<=x&&x<=1199)
        cout<<5;
        else if(1200<=x&&x<=1399)
            cout<<4;
        else if(1400<=x&&x<=1599)
            cout<<3;
            else if(1600<=x&&x<=1799)
                cout<<2;
                else if(1800<=x&&x<=1999)
                    cout<<1;


                return 0;




}


Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans;
		if(B % A == 0) {
			ans = A + B;
		} else {
			ans = B - A;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 23764