akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
    int key;
    struct node *right, *left, *p;
};

typedef struct node Node;

Node *NIL, *T;

void insert(Node *z){
    Node *y = NIL;
    Node *x = T;

    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }
        else{
            x = x->right;
        }
    }
    z->p = y;

    if(y == NIL){
        T = z;
    }
    else if(z->key < y->key){
        y->left = z;
    }
    else y->right = z;
}

void inorder(Node *i){
    if(i == NIL) return;
    inorder(i->left);
    printf(" %d", i->key);
    inorder(i->right);
}

void preorder(Node *i){
if(i == NIL) return;
printf(" %d", i->key);
preorder(i->left);
preorder(i->right);
}

int find(int k){
    Node *y = NIL;
    Node *x = T;

    while(x != NIL){
        y = x;
        if(k < x->key){
            x = x->left;
        }
        else if(k > x->key){
            x = x->right;
        }
        else return 1;
    }
    return 0;
}

int main(void){
    int nm, i, inp, finm;
    char wd[10];
    Node *z;

    scanf("%d", &nm);
    for(i = 0; i < nm; i++){
        scanf("%s", wd);
        if(strcmp(wd,"insert") == 0){
            scanf("%d", &inp);
            z = (Node *)malloc(sizeof(Node));
            z->key = inp;
            z->left = NIL;
            z->right = NIL;
            insert(z);
        }
        else if(strcmp(wd, "print") == 0){
            inorder(T);
            printf("\n");
            preorder(T);
            printf("\n");
        }
        else if(strcmp(wd, "find") == 0){
            scanf("%d", &finm);
            if(find(finm) == 0) printf("no");
            else if(find(finm) == 1) printf("yes");
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 20496
n, m = map(int, input().split())
ps = []
for i in range(m):
    p, s = input().split()
    ps.append([int(p), s])
flag = [False for _ in range(n)]
ac = [0 for _ in range(n)]
wa = [0 for _ in range(n)]
i = 0
sumac = 0
sumwa = 0

for i in range(m):
    p = ps[i][0]
    s = ps[i][1]
    if s == "WA" and ac[p - 1] == 0:
        wa[p - 1] += 1
    elif s == "AC" and ac[p - 1] == 0:
        ac[p - 1] += 1
        sumac += 1
        sumwa += wa[p - 1]

print(str(sumac) + " " + str(sumwa))

Measured memory_bytes: 74104
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

vector<int> adj[100001];
int ans[100001];
queue<int> q;

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int n, m; cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v; cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    q.push(1);
    while (!q.empty()) {
        int x = q.front(); q.pop();

        for (int nx : adj[x]) {
            if (!ans[nx]) {
                q.push(nx);
                ans[nx] = x;
            }
        }
    }

    for (int i = 2; i <= n; i++) {
        if (!ans[i]) {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";
    for (int i = 2; i <= n; i++) {
        cout << ans[i] << '\n';
    }


    return 0;
}


Measured memory_bytes: 10452
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,a[200005],x;
map<ll,ll>m;
int32_t main(){
CODE_START;
cin>>n;
for(ll i=1;i<n;i++)
{
    cin>>x;
    m[x]++;
}
for(ll i=1;i<=n;i++)
    cout<<m[i]<<endl;
}


Measured memory_bytes: 16168
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1234567890
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	int a,b,c,tot=0;
	scanf("%d%d%d",&a,&b,&c);
	if(a<b) swap(a,b);
	if(a<c) swap(a,c);
	if(b<c) swap(b,c);
	//cout<<a<<" "<<b<<" "<<c<<endl;
	if((a-b)%2==1&&(a-c)%2==1) tot=(a-b)/2+(a-c)/2+1;
	else if((a-b)%2==0&&(a-c)%2==0) tot=(a-b)/2+(a-c)/2;
	else tot=(a-b)/2+(a-c)/2+2;
	printf("%d",tot);
	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;
    int turn=0;
    int s=0;
    while (s==0){
        if(turn==0){
            C=C-B;
            if (C<=0){
                cout << "Yes" << endl;
                s=1;
                
            }
            else{
                turn=1;
            
            }
        if(turn==1){
            A=A-D;
            if (A<=0){
                cout << "No" << endl;
                s=1;
                
            }
            else{
                turn=0;
                
            }
        }    
        }
    }
}


Measured memory_bytes: 3636
dp = [[0]*(1001) for _ in xrange(10)]
dp[0][0] = 1
for i in xrange(101):
    si1 = 1001-i
    for k in xrange(9, 0, -1):
        dp_k = dp[k]; dp_k1 = dp[k-1]
        for j in xrange(si1):
            dp_k[i+j] += dp_k1[j]
while 1:
    n, s = map(int, raw_input().split())
    if n==0:
        exit(0)
    print dp[n][s]

Measured memory_bytes: 6516
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    string s; cin >> s;
    sort(s.begin(), s.end());

    bool ok = true;
    ok &= (s[0] == s[1]);
    ok &= (s[2] == s[3]);
    ok &= (s[0] != s[2]);
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

int main() {
	int score;
	int sum[2];

	for (int i = 0; i < 2; ++i) {
		sum[i] = 0;
		for (int j = 0; j < 4; ++j) {
			cin >> score;
			sum[i] += score;
		}
	}
	cout << max(sum[0], sum[1]) << endl;

	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n;
	cin >> n;
	map<int, int> a;
	bool f = true;
	int ans = 0;
	while (f) {
		if (a[n] != 0) {
			break;
		}
		else {
			ans++;
			a[n] += 1;
			if (n % 2 == 0) {
				n = n / 2;
			}
			else {
				n = 3 * n + 1;
			}
		}
	}
	cout << ans+1 << endl;

	return 0;
}



Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        var a = int.Parse(str[0]);
        var b = int.Parse(str[1]);
        var c = int.Parse(str[2]);

        int ans = b + c - a;
        if (ans < 0) ans = 0;

        Console.Write(ans);
    }
}

Measured memory_bytes: 13140
import math
 
N = int(input())

b =[""]*N
 
cn =ord("a")
 
for i in range(N):
    s = list(input())
    s.sort()
    b[i] ="".join(s)
 
b.sort()
c = 0
ans =0
 
for i in range(N-1):
    if b[i]==b[i+1]:
        c +=1
    else:
        if c !=0:
            ans=ans + math.factorial(c+1)/(math.factorial(2)*math.factorial(c+1-2))
            c = 0
 
 
if c !=0:
    ans = ans + math.factorial(c+1)/(math.factorial(2)*math.factorial(c+1-2))
    
 
print(int(ans))


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

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

    for (int i = 1; i <= n; i++){
        int x = i;
        if (x % 3 == 0){
            printf(" %d", i);
        }
        else{
            while (x){
                if (x % 10 == 3){
                    printf(" %d", i);
                    break;
                }
                x /= 10;
            }
        }
    }
    printf("\n");
    return 0;
}




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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define endl "\n"

const ll N = 1e6 + 7;
const double PI = acos(-1);
ll mod = 998244353;


int32_t main()
{
	
	IOS
	
	string str;
	cin>>str;
	map<char, int> mp;
	for(int i=0;i<4;i++)
		mp[str[i]]++;
	auto it = mp.begin();
	if(mp.size() == 2 && it->second == 2)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
/*input
2
ip cc
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}


int main(){
	IOS;
	int a,b;
	cin>>a>>b;
	if(a<=9&&b<=9) cout<<a*b;
	else cout<<-1;
	return 0;
}


Measured memory_bytes: 256
import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;

// https://atcoder.jp/contests/abc164/tasks/abc164_c
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

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

		Set<String> linkedHashSet = new LinkedHashSet<String>();
		for(int i=0;i<n;i++) {
			linkedHashSet.add(sc.next());
		}
		sc.close();

		System.out.println(linkedHashSet.size());

	}
}


Measured memory_bytes: 69156
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,w;cin>>n>>w;
  vector<int> weight(n),value(n);
  int maxvalue=0;
  for(int i=0;i<n;i++){
    cin>>weight.at(i);
    cin>>value.at(i);
    maxvalue=max(maxvalue,value.at(i));
  }
  maxvalue=maxvalue*n;
  vector<vector<int>>dp(n+1,vector<int>(3*maxvalue,1000000007));
  dp.at(0).at(0)=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<2*maxvalue;j++){
      dp.at(i+1).at(j)=dp.at(i).at(j);
      if(j-value.at(i)>=0)dp.at(i+1).at(j)=min(dp.at(i+1).at(j),dp.at(i).at(j-value.at(i))+weight.at(i));
    }
  }
  int res=0;
  for(int i=0;i<3*maxvalue;i++){
    if(dp.at(n).at(i)<=w)res=i;
  }
  cout <<res<<endl;
}

Measured memory_bytes: 122780
process.stdin.resume();
process.stdin.setEncoding('utf8');

const reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
});

reader.on('line', s => {
  let h = BigInt(s);
  let n = 0n;

  while (h !== 1n) {
    h /= 2n;
    n += 1n;
  }

  console.log(`${2n ** (n + 1n) - 1n}`);

  process.exit(0);
});

Measured memory_bytes: 30852
#include <iostream>
using namespace std;
 
int main() {
    int r, g, b, n, sum, ans = 0;
    cin >> r >> g >>  b >>  n;
    for(int i = 0; i <= n/r; ++i){
        for(int j = 0; j <= n/g; j++){
            sum = n - (i*r+j*g);
            if(sum < 0) {
                break;
            } else if(sum%b == 0) {
                ans++;
            }
        }
    }
 
    cout << ans << '\n';
}

Measured memory_bytes: 256
def main():
    from collections import deque

    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1

    g = tuple(set() for _ in range(N))
    for v in range(N):
        if v > 0:
            g[v].add(v - 1)
        if v < N - 1:
            g[v].add(v + 1)

    g[X].add(Y)
    g[Y].add(X)

    ctr = [0] * N
    for v in range(N):
        dist = [-1] * N

        q = deque()
        q.append((v, 0))

        while q:
            v, d = q.popleft()
            if ~dist[v] and dist[v] < d: continue
            dist[v] = d
            for u in g[v]:
                if ~dist[u]: continue
                dist[u] = d + 1
                q.append((u, d + 1))

        for d in dist:
            ctr[d] += 1

    print(*map(lambda x: x // 2, ctr[1:]), sep='\n')


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n;
ll s[e5];
ll b[e5];
ll ans = 0;

int main(){
  cin >> n;
  for(ll i = 0;i < n;i++) cin >> s[i];
  for(ll i = 1;i <= n;i++){
    ll mem1 = 0;
    ll mem2 = 0;
    unordered_set<ll> r;
    unordered_set<ll> l;
    for(ll j = 0,k = n-1;k >= i;j+=i,k-=i){
      r.insert(j);
      l.insert(k);
      if(r.count(k) || l.count(j)) continue;
      mem1 += s[j];
      mem2 += s[k];
      ans = max(ans,mem1+mem2);

    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 10568
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
#define pb push_back
typedef vector<int> vi;
#define mod 1000000007
#define maxn 3005
double dp[maxn][maxn];
vector<double>p(maxn);
int n;
double head_tail(int i,int h_count)
{ if(i==n&&h_count<=n/2)
  return 0.0;
  if(i==n)
  return 1.0;
  if(dp[i][h_count]!=-1.0)
  return dp[i][h_count];
  
  dp[i][h_count]=p[i]*head_tail(i+1LL,h_count+1LL)+(1.0-p[i])*head_tail(i+1LL,h_count);
  return dp[i][h_count];
}
int32_t main() {
    fill_n(&dp[0][0],maxn*maxn,-1.0);
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>p[i];
    cout<<setprecision(10)<<p[0]*head_tail(1,1)+(1.0-p[0])*head_tail(1,0);
    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N, M, C;
int ans = 0;
int B[25];


int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> C;
    for(int i = 1; i <= M; i++) cin >> B[i];
    while(N--) {
        int val = C;
        for(int i = 1; i <= M; i++) {
            int A;
            cin >> A;
            val += A * B[i];
        }
        if(val > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#define Maxn 100010
using namespace std;
int n,x,a[Maxn] = {0};
int main()
{
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        cin>>x;
        a[x]++;
        a[x+1]++;
        a[x-1]++;
    }
    sort(a,a+Maxn);
    cout<<a[Maxn-1]<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>

using namespace std;

int main(){


int a,b;

cin>>a>>b;

if(a<b) cout<<"a < b"<<endl;
else if(a>b) cout<<"a > b"<<endl;
else if(a==b) cout<<"a == b"<<endl;

return 0;

}

Measured memory_bytes: 1156
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	ll A=in<ll>(),B=in<ll>(),N=in<ll>();
	if(A<=B){
		ll V=min(B-1LL,N);
		out(A*V/B);
	}
	else{
		ll maxV=0;
		for(ll i=1;i<=min(A,N);i++){
			ll V = A*i/B-A*(i/B);
			maxV = max(maxV,V);
		}
		out(maxV);
	}
	return 0;
}


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

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int x,y;
    x = a + b;
    y = c + d;
    if (x > y){
        cout << "Left";
    }
    if (x < y){
        cout << "Right";
    }
    if (x == y){
        cout << "Balanced";
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n;
	char s[100];
	char t[100];
	scanf("%d", &n);
	
	scanf("%s", s);
	scanf("%s", t);



	 for (int i = 0; i < n;i++) {
		 putchar(s[i]);
		 putchar(t[i]);
	 }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ph 1000006
#define mod 1000000007
#define pf pop_front
#define pob pop_back
int main()
{
    string s,t;
    cin>>s>>t;

    string p;

    if(s.size()==t.size())
        cout<<"No\n";
    else
    {
    p=t.substr(0,s.size());

    if(p==s)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b){ return a < b ? a : b;}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for(i=1;i<=n;i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;

  while(head != tail){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t>0) enqueue(u);
    else{
      printf("%s %d\n", u.name, elaps);
    }
  }
  return 0;
}

Measured memory_bytes: 10752
class Node:
    def __init__(self):
        self.key, self.left, self.right, self.parent = 0, None, None, None

class BST:
    def __init__(self):
        self.root = None
    
    def insert(self, key):
        x, y = self.root, None
        z = Node()
        z.key = key
        while x != None:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        z.parent = y
        if y == None:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z
    
    def preOrder(self, r = -1):
        if r == -1: r = self.root
        if r == None:   return
        print("", r.key, end = '')
        self.preOrder(r.left)
        self.preOrder(r.right)
    
    def inOrder(self, r = -1):
        if r == -1: r = self.root
        if r == None:   return
        self.inOrder(r.left)
        print("", r.key, end = '')
        self.inOrder(r.right)

tree = BST()
for _ in range(int(input())):
    s = input()
    if s[0] == 'i':
        tree.insert(int(s[7:]))
    else:
        tree.inOrder()
        print("")
        tree.preOrder()
        print("")


Measured memory_bytes: 105468
import sys


def LI():
    return list(map(int, input().split()))


A, B = LI()
S = input()
ans = "Yes"
for i in range(A):
    if S[i] == "-":
        ans = "No"
        break
if S[A] != "-":
    ans = "No"
for i in range(A+1, A+B+1):
    if S[i] == "-":
        ans = "No"
        break
print(ans)


Measured memory_bytes: 9132
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int a[100100];
vector<int> vec;
int n;
int main()
{
	cin >> n;
	for(int i=0;i<n;i++)cin >> a[i];
	int cnt=1;
	for(int i=1;i<n;i++)
	{
		if(a[i]!=a[i-1])
		{
			cnt++;
			continue;
		}
		else
		{
			vec.pb(cnt);
			cnt=1;
		}
	}
	vec.pb(cnt);
	int ans=1;
	//for(int i=0;i<vec.size();i++)cout << vec[i] << endl;
	if(vec.size()<3)
	{
		ans=0;
		for(int i=0;i<vec.size();i++)
		{
			ans+=vec[i];
		}
	}
	for(int i=2;i<vec.size();i++)
	{
		ans=max(ans,vec[i-2]+vec[i-1]+vec[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1800
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  G=[[]*n for _ in range(n)]
  vp=[]

  for _ in range(n-1):
    a,b=LI()
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)
    vp.append((a,b))

  k=0
  d={}
  cs=[0]*n

  used=[False]*n
  used[0]=True
  q=collections.deque()
  q.append(0)
  while q:
    v=q.popleft()
    k=max(k,len(G[v]))
    cur=1
    for u in G[v]:
      if used[u]:
        continue
      if cur==cs[v]:
        cur+=1
      cs[u]=d[(u,v)]=d[(v,u)]=cur
      cur+=1
      used[u]=True
      q.append(u)

  print(k)
  for a,b in vp:
    print(d[(a,b)])

main()
# print(main())


Measured memory_bytes: 61760
# coding: utf-8
# Your code here!
'''
n=int(input())
s=input()
k=int(input())
'''
a,b,c=map(int,input().split())
'''
a=[int(i) in range(n)]
a=[0]*n
for i in range(n):
    a.append(int(i))
'''
if (a<=c and c<=b) or (b<=c and c<=a):
    ans='Yes'
else:
    ans='No'
print(ans)

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10**8)

N,M = map(int,input().split())
src = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)]
Q = int(input())
qs = [tuple(map(int,input().split())) for i in range(Q)]

es = [[] for i in range(N)]
for a,b in src:
    es[a].append(b)
    es[b].append(a)

cs = [0] * N
depth = [-1] * N

def rec(v,d,c,pv):
    if d <= depth[v]: return
    depth[v] = d
    if cs[v]==0:
        cs[v] = c
    if d==0: return
    for to in es[v]:
        if to==pv: continue
        rec(to,d-1,c,v)

for v,d,c in qs[::-1]:
    rec(v-1,d,c,-1)

print(*cs, sep='\n')

Measured memory_bytes: 127876
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 10000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

void BFS(vvll &num,vll &cnt,int n,queue<int> &q){
	int d = cnt.at(n) ;
	for(int i=0;i<10;i++){
		if(cnt.at(i)>d+num.at(n).at(i)){
			cnt.at(i) = d+num.at(n).at(i) ;
			q.push(i) ;
		}
	}
	if(q.empty()) return ;
	n = q.front() ;
	q.pop() ;
	BFS(num,cnt,n,q) ;
}

int main(){
	ll h,w ;
	cin >> h >> w ;
	vvll num(10,vll(10)) ;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			cin >> num.at(i).at(j) ;
		}
	}
	vll one(10,INF) ;
	for(int i=0;i<10;i++){
		vll cnt(10,INF) ;
		cnt.at(i) = 0 ;
		queue<int> q ;
		BFS(num,cnt,i,q) ;
		one.at(i) = cnt.at(1) ;
	}
	ll ans = 0 ;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			ll a ; cin >> a ;
			if(a==-1) continue ;
			ans += one.at(a) ;
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 256
N = int(input())

bit1 = 380000.0

ans = 0

for i in range(N):
    S = input().split()
    if S[1] == 'JPY':
        ans += float(S[0])
    elif S[1] == 'BTC':
        ans += (float(S[0]) * bit1)

print(ans)

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

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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

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

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      mut xys: [(i64, i64); n],
    }
    xys.sort();
    let mut ans = n+1;
    if n == 1 {
        return println!("{}", 1);
    }

    for i in 0..n {
        for j in i+1..n {
            let p = xys[j].0 - xys[i].0;
            let q = xys[j].1 - xys[i].1;
            // debug!(p, q);

            let mut cnt = 0;
            for i in 0..n {
                let (x, y) = xys[i].clone();
                if let Ok(v) = xys.binary_search(&(x-p, y-q)) {
                } else {
                    cnt += 1;
                }
            }
            ans = min(ans, cnt);
        }
    }
    println!("{}", ans);
}


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

using namespace std;
typedef long long ll;
#define tr(container, it) \
	for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c,x) ((c).find(x) != (c).end())   //O(log n) 
#define contains(c,x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define Ichar(_x) char _x;scanf("%c",&_x);
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define inc(a,b,x)(x)>a && (x)<b	
#define incE(a,b,x)(x)>=a && (x)<=b	
#define fileio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
const double pi = 3.14159265358979323846;

template<typename T>
long long C(T n, T r) {
	if (n < 0 || r < 0)return 0;
	if (r > n / 2) r = n - r;
	long long ans = 1;
	for (T i = 1; i <= r; ++i) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


ll a[100000];
int main()
{
	Ill(n); ll mx = 0, t,s,mxx=0;
	for (int i = 0; i < n; ++i)
	{
		scanf("%lld", &a[i]);
	}
	sort(a, a + n);
	int i = n - 1;
//	for (int i = n-1; i >0; --i)
//	{
		double absmi = LONG_MAX;
		double half = a[i] / 2.0;
		ll num;
		
		int pos = lower_bound(a, a + n, half) - a;
		if(pos!=0 )
		{
			num = abs(a[pos-1] - half) > abs(a[pos ] - half) ? a[pos] : a[pos-1];
		}
		else { num=a[0]; }


//	}
	std::cout << a[n-1] <<" " <<num;
	
}





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

int main()
{
    string o, e;
    cin >> o >> e;
    string ans;
    int cnt = 0;
    while(cnt < o.size() + e.size()){
        ans += o[cnt/2];
        cnt++;
        if(cnt >= o.size() + e.size()) break;
        ans += e[cnt/2];
        cnt++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

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

int main(){ L n,r,l,d,t,x,i,pt=0,w=0,wt=0,m; cin>>n>>r>>l;
    vector<L> tp(n,0),p(n,0);
    priority_queue<P> que;
    for(i=0;i<n;i++){
        que.push(P(i,0));
    }
    P q;
    for(i=0;i<r;i++){
        cin>>d>>t>>x;
        d--;
        p[d] += x;
        tp[w] += t-pt;
        que.push(P(p[d],-d));
        while( (q = que.top()).first != p[-q.second] ) que.pop();
        wt = q.first;
        w = -q.second;
        pt = t;
    }
    tp[w] += l-pt;
    w = 0;m = 0;
    for(i=0;i<n;i++){
        if(tp[i] > m){
            m = tp[i];
            w = i;
        }
    }
    cout << w+1 << endl;
    return 0;
}

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

using namespace std;
const int N = 1e6;

int n, h;
int a[N], b[N], c[N], d[N], vis[N], in[N], out[N], fa[N];

int read(void) {
    int s = 0, w = 0;
    char c = getchar();
    while (c < '0' || c > '9') w |= c == '-', c = getchar();
    while (c >= '0' && c <= '9') s = s * 10 + c - 48, c = getchar();
    return w ? -s : s;
}

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

bool check(void)
{
	for (int i=-h;i<0;++i) 
		if (in[i+h] > out[i+h]) return 0;
	for (int i=1;i<=h;++i)
	    if (in[i+h] < out[i+h]) return 0;
	for (int i=-h;i<=h;++i)
	    if (in[i+h] != out[i+h]) vis[get(i+h)] = 1;
	    else if (in[i+h] +out[i+h] == 0) vis[get(i+h)] = 1;
	for (int i=-h;i<=h;++i)
		if (vis[get(i+h)] == 0) return 0;
	return 1;
	
}

int main(void)
{
	n = read(), h = read();
	for (int i=0;i<=1000;++i) fa[i] = i;
	for (int i=1;i<=n;++i)
	{
		a[i] = read(); b[i] = read();
		c[i] = read(); d[i] = read();
		int x = c[i] == 0 ? h-a[i] : h+c[i];
		int y = d[i] == 0 ? h+b[i] : h-d[i];
		out[x] ++, in[y] ++;
		fa[get(x)] = get(y);
	}
	if (check()) cout << "YES";
	else cout << "NO";
	return 0;
}

Measured memory_bytes: 14592
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    aa = MII()
    bb = MII()
    ra = rb = 0
    for a,b in zip(aa,bb):
        if a>b: ra += a-b
        if b>a: rb += (b-a)//2
    if rb >= ra: print('Yes')
    else: print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 4596
count = int(input())
line = [i for i in input()]
x = 0
emp = []
result = 0
for j in range(count):
    if line[j] == "I":
      x += 1
    else:
      x -= 1
    emp.append(x)  
for j in range(len(emp)):
    if result < emp[j]:
        result = emp[j]
print(result)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  int n,x;
  cin>>n>>x;
  int cnt=1,tmp=0;
  int l[100];
  rep(i,n) cin>>l[i];

  rep(i,n){
    tmp+=l[i];
    if(tmp<=x) cnt++;
    else break;
  }

  cout<<cnt<<endl;

}

Measured memory_bytes: 256
from collections import defaultdict


def is_valid(xs):
    d = defaultdict(lambda: 0)
    for x in xs:
        d[x] += 1

    if len(xs) % 2 == 0:
        for v in range(1, len(xs), 2):
            if d[v] != 2:
                return False
    else:
        if d[0] != 1:
            return False
        for v in range(2, len(xs), 2):
            if d[v] != 2:
                return False

    return True


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

if is_valid(xs):
    print(2 ** (n // 2) % 1000000007)
else:
    print(0)

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

using namespace std;

typedef long long int Int;

Int sum[100];

int main(void)
{
    Int n,m;
    vector<Int> t;

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


    cin>>m;
    for(int i = 0;i < m;i++)
    {
	Int p,x;
	cin>>p>>x;
	p--;
	for(int j = 0;j < n;j++)
	{
	    if(j == p)
		sum[i] += x;
	    else
		sum[i] += t[j];
	}
    }

    for(int i = 0;i < m;i++)
    {
	cout<<sum[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int a,b;
int main(){
    scanf("%d%d",&a,&b);
    if(a>0)puts("Positive");          
    else if(b>=0)puts("Zero");          
    else if((a&1)^(b&1))puts("Positive");  
    else puts("Negative");
    return 0;
}


Measured memory_bytes: 128
//AtCoDeerandElectionReport.cpp (C)
#include <iostream>
#include <string>
using namespace std;

int main(){
  int N,T[1100],A[1100];
  cin >> N;
  for(int i = 0; i < N; i++) cin >> T[i] >> A[i];
  long long a,b,x;
  a = T[0], b = A[0];
  for(int i = 0; i < N-1; i++){
    if(T[i+1] >= a&&A[i+1] >= b) a = T[i+1], b = A[i+1];
    else if((a+T[i+1]-1)/T[i+1] >= (b+A[i+1]-1)/A[i+1]){
      x = (a+T[i+1]-1)/T[i+1];
      a = T[i+1]*x;
      b = A[i+1]*x;
    }else{
      x = (b+A[i+1]-1)/A[i+1];
      a = T[i+1]*x;
      b = A[i+1]*x;
    }
  }
  long long pA = a + b;
  printf("%lld\n",pA );
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n)	cin >> a[i];
	ll diff = 0;
	diff = a[0] - a[1];
	for (int i = 2; i < n; i += 2) {
		diff += (a[i % n] - a[(i + 1) % n]);
	}
	vector<ll> ans(n);
	ll cur = 0;
	ans[0] = (diff + a[0]) / ll(2);
	for (int i = n - 1; i > 0; --i) {
		ans[i] = a[i] - ans[(i + 1) % n];
	}
	rep(i, n)	cout << ll(2) * ans[i] << " ";
	return 0;
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  ll mx[2]={};
  ll A[N];
  for(ll i=0;i<N;i++){
    cin>>A[i];
    if(mx[0] < A[i]){
      mx[1]=mx[0];
      mx[0]=A[i];
    }else if(mx[1]<A[i]){
      mx[1]=A[i];
    }
  }
  for(ll i=0;i<N;i++){
    cout<<(A[i]==mx[0]? mx[1]:mx[0])<<endl;
  }
  return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main()
{
	int n, m, x;
	int c[12];
	int a[12][12];

	cin >> n >> m >> x;
	for(int i=0; i<n; i++){
		cin >> c[i];
		for(int j=0; j<m; j++){
			cin >> a[i][j];
		}
	}
	
	int cost, maxcost=100000000;
	int sum[12];
	int flag, exist=0;

	for (int bit = 0; bit < (1<<n); ++bit){
		//初期化
		cost = 0;
		for(int j=0; j<m;j++){
			sum[j] = 0;
		}
		flag = 1;

        for (int i = 0; i < n; i++) {
            if (bit & (1<<i)) { // i が S に入っているなら足す
				cost += c[i];
                for(int j=0; j<m; j++){
					sum[j] += a[i][j];
				}
            }
        }

		for(int j=0; j<m;j++){
			if(sum[j] < x){
				flag = 0;
				break;
			}
		}
		if(flag == 1){
			exist = 1;
		}

		if(flag == 1 && (cost < maxcost))
			maxcost = cost;
    }

	if(exist)
		cout << maxcost;
	else
		cout << -1;

}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;


int main() {
  int r, d;
  cin >> r >> d;
  ll x;
  cin >> x;
  for (int i = 2001; i <= 2010; i++) {
    x = r * x - d;
    cout << x << endl;
  }
  return 0;
}

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

int n;
vector<long long> sushi;

void generate(int a, int b, int c, long long cur, int len){
	if(a+b+c == len){
		if(1 && a && b && c)
			sushi.push_back(cur);
		return;
	}
	generate(a+1,b,c,cur*10+3,len);
	generate(a,b+1,c,cur*10+5,len);
	generate(a,b,c+1,cur*10+7,len);
}

int main() {
	cin>>n;
	for(int i = 3;i<=9;i++)	generate(0, 0, 0, 0, i);
	sort(sushi.begin(), sushi.end());
	int idx = lower_bound(sushi.begin(), sushi.end(), n) - sushi.begin();
	if(sushi[idx] == n) idx++;
	cout<<idx;
	return 0;
}

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

const int N = 3e5+5;
int a[N];
int n;

ll pre[N];
vector<int> v;

bool poss(int mid, int k) {
    auto it = upper_bound(v.begin(),v.end(),mid);
    int num = distance(it,v.end());
    num += pre[distance(v.begin(),it)-1]/mid;
    return num >= k;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    map<int,int> mp;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    for (auto p: mp)
        v.push_back(p.second);
    sort(v.begin(),v.end());
    for (int i = 0; i < v.size(); i++) {
        pre[i] = v[i];
        if (i > 0) pre[i] += pre[i-1];
    }
    for (int k = 1; k <= n; k++) {
        int lo = 0, hi = n+1;
        while (lo + 1 < hi) {
            int mid = (lo+hi)/2;
            if (poss(mid,k)) {
                lo = mid;
            }
            else hi = mid;
        }
        cout << lo << '\n';
    }
}



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

int main(){
    int n;
    cin >> n;
    n = n%10;

    if((n == 2)||(n == 4)||(n == 5)||(n == 7)||(n == 9)){
        cout << "hon" << endl;
    }
    else if((n == 0)||(n == 1)||(n == 6)||(n == 8)){
        cout << "pon" << endl;
    }
    else{
        cout << "bon" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    string s = "";
    string ans[] = {"Yes", "No"};
    int flag = 0;

    cin>>s;
        
    if (s[2] != s[3]){
        flag = 1;
    }
    if (s[5] != s[4]){
        flag = 1;
    }

    cout<<ans[flag]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,m;
string s[55],w[55];

int main(){
	cin >> n >> m;
	REP(i,0,n) cin >> s[i];
	REP(i,0,m) cin >> w[i];
	
	REP(i,0,n-m+1){
		REP(j,0,n-m+1){
			bool f=true;
			REP(k,0,m) REP(l,0,m) if(s[i+k][j+l]!=w[k][l]) f=false;
			if(f){cout << "Yes" << endl; return 0;}
		}
	}

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


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

int main() {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> X(N + 1), Y(N + 1);
  for (int i = 0, a, b; i < M && cin >> a >> b; i++) {
    if (a == 1) X.at(b) = 1;
    if (b == N) Y.at(a) = 1;
  }
  string ans = "IMPOSSIBLE";
  for (int i = 0; i < N + 1; i++) if (X.at(i) && Y.at(i)) ans = "POSSIBLE";
  cout << ans << "\n";
}

Measured memory_bytes: 1792
import sys
from io import StringIO
import unittest
import math

def resolve():
    inp = input()
    li = list(map(lambda x: int(x), inp.split(" ")))
    a = li[0]
    b = li[1]
    k = li[2]
    g = math.gcd(a, b)

    for i in range(g,0,-1):
        if g%i == 0:
            k -= 1
        if k == 0:
            print(i)
            break
            
resolve()

Measured memory_bytes: 75492
#include<iostream>
using namespace std;
string ins[12];
int ve[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
void nuri(int x,int y){
    ins[x][y]='0';
    for(int i=0;i<4;i++){
        int nx=x+ve[i][0],ny=y+ve[i][1];
        if(0<=nx&&nx<12&&0<=ny&&ny<12&&ins[nx][ny]=='1')nuri(nx,ny);
    }
}
int main(){
    for(;;){
        for(int i=0;i<12;i++){
            if(!(cin>>ins[i]))return 0;
        }
        int ans=0;
        for(int i=0;i<12;i++){
            for(int j=0;j<12;j++){
                if(ins[i][j]=='1'){
                    nuri(i,j);
                    ans++;
                }
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 0
import itertools as it

N, M = map(int, input().split())
ab = tuple(set(map(int, input().split())) for _ in range(M))

P = it.permutations(range(1, N + 1), N)

res = 0
for p in P:
    if p[0] == 1:
        for i in range(N - 1):
            if not(set({p[i], p[i + 1]}) in ab):
                break
        else:
            res += 1

print(res)

Measured memory_bytes: 41052
a,b,c,d=[int(i) for i in input().split()]
if b<=c or d<=a:
    print(0)
elif a<=c and b<=d:
    print(b-c)
elif a>=c and b>=d:
    print(d-a)
elif a<=c and b>=d:
    print(d-c)
else:
    print(b-a)

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

int main(){
  int N;
  cin>>N;
  vector<int> a(N);
  for(int &i:a)
    cin>>i;
  int k=4000000;
  for(int i=-100;i<=100;i++){
    int l=0;
    for(int j:a)
      l+=pow(j-i,2);
    k=min(k,l);
  }
  cout<<k<<endl;
}

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

#define int long long
#define ll unsigned long long
#define pb push_back
#define mp make_pair
#define veci vector<int>
#define pii pair<int,int>
#define reset(a, b) memset(a, b, sizeof(a))
#define rep(i,b) for(int i=0; i<b; i++)
#define repi(i,a,b) for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define fi first 
#define se second
#define all(v) v.begin(),v.end()

int mod=1e9+7;

int powerm(int x,int y, int M){ int res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
int  power(int x,int y){ int res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
bool isprime(int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int T;
    T=1;
//    cin>>T;
while(T--){
    int n;
    cin>>n;
    
    veci dp(n+1, 0);
    
    repi(i,1,n){
        for(int j=i; j<=n; j+=i){
            dp[j]++;
        }
    }
    int ans=0;
    repi(i,1,n){
        ans+=i*dp[i];
    }
    cout<<ans<<endl;
}
    
    return 0;
}

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

int main()
{
  const int d_max = 1000;
  const int c_max = 1000;
  const int n_max = 1000;
  const int INF = d_max * c_max * n_max + 1;

  int n, m;
  cin >> n >> m;

  int d[n+1], c[m+1];

  for(int i = 0; i < n; i++) cin >> d[i];
  for(int i = 0; i < m; i++) cin >> c[i];

  int dp[n][m];

  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= m; j++){

      if(i == 0 && j == 0) dp[i][j] = 0;

      else if(i == 0) dp[i][j] = 0;

      else if(i > j) dp[i][j] = INF;

      else if(dp[i][j - 1] < dp[i-1][j-1] + c[j-1]*d[i-1]) dp[i][j] = dp[i][j-1];

      else dp[i][j] = dp[i-1][j-1] + c[j-1]*d[i-1];

    }
  }

  cout << dp[n][m] << endl;

  return 0;

}



Measured memory_bytes: 6176