akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define N 1000005
typedef long long ll;
const ll LLINF=1ll<<60;
//const int mx=1e5+7;
//int n;
//bool visited[mx];
//vector<int> a(mx),b(mx);
//vector<int> g(mx);
// int deg[mx];
//vector<int> adj[mx];
//int sz[mx], par[mx];
//vector<int> ans;
//---dfs--
//vector<ll> val(mx,0);
// int sz=0;
// void dfs(int s, int p){
// 	par[s]=p;
// 	sz[s]=1;
// 	int maxx=0;
// 	for(int x: adj[s]){
// 		if(x!=p){
// 			dfs(x,s);
// 			sz[s]+=sz[x];
// 			maxx=max(maxx,sz[x]);
// 		}
// 	}
// 	maxx=max(maxx,n-sz[s]);
// 	//cout<<"mx "<<s<<" "<<maxx<<"\n";
// 	if(maxx<mn) mn=maxx, c1=s, c2=0;
// 	else if(maxx==mn) c2=s;
// 	//cout<<"mn "<<mn<<"\n";
// }
//---dfs---

//---primes---
// const int N = 1e7 + 10;

// bool prime[N];
 
// int spf[N];
 
// void calc(){
// 	for(int i = 2; i<1e4; i++){
// 		if(prime[i])
// 			continue;
// 		spf[i] = i;
// 		for(int j = i * i; j < N; j += i){
// 			prime[j] = 1;
// 			spf[j] = i;
// 		}
// 	}
// 	for(int i = 2; i < N; i++)
// 		if(!spf[i])
// 			spf[i] = i;
// }

// vector<pair<int,int>> getp(int x){
// 	int curr=x;
// 	vector<pair<int,int>> ans;
// 	while(curr>1){
// 		int a=spf[curr];
// 		int count=0;
// 		while(curr%a==0){ curr/=a; count++;}
// 		ans.push_back(make_pair(a,count));
// 	}
// 	return ans;
// }

// bool ispr(int n) {
// 	if(n==1) return false;
//     for (int i=2;i*i<=n;++i){
//         if(n%i==0){
//             return false;
//         }
//     }
//     return true;
// }
//---primes---

//---segment_tree---
// int upd(int t,int val,int l,int r,int y, int z){
// 	if(y<l||y>r) return tr[val];
// 	if(l==r) return tr[val]=z;
// 	int s=(l+r)/2;
// 	upd(t^1,2*val+1,l,s,y,z);
// 	upd(t^1,2*val+2,s+1,r,y,z);
// 	if(t) tr[val]=tr[2*val+1]|tr[2*val+2];
// 	else tr[val]=tr[2*val+1]^tr[2*val+2];
// 	return tr[val];
// }
//int query(){}
//---segment_tree---

// ll power(ll x,ll y){
//     ll res=1;
//     if(x==0) return 0;
//     while(y>0){
//         if(y&1) res = (res*x)%MOD ;  
//         y=y>>1;
//         x=(x*x)%MOD;   
//     } 
//     return res; 
// }

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int T=1;
	//cin>>T;
	while(T--){
		int x;
		cin>>x;
		cout<<1-x<<"\n";	
	}
}


Measured memory_bytes: 3644
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    H, N = MAP()
    A = LIST()

    print("Yes" if H - sum(A) <= 0 else "No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 53144
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

class UnionFind {
  int _numberOfSet;
  vector<int> tree, rank, _sizeOfSet;

public:
  UnionFind(const int &n) : _numberOfSet(n), tree(n), rank(n), _sizeOfSet(n, 1) { iota(all(tree), 0); }

  int root(const int &x) { return tree[x] == x ? x : tree[x] = root(tree[x]); }

  bool same(const int &a, const int &b) { return root(a) == root(b); }

  bool unite(int a, int b) {
    a = root(a), b = root(b);
    if (a == b) return false;
    if (rank[a] < rank[b]) swap(a, b);
    tree[b] = a;
    _sizeOfSet[a] += _sizeOfSet[b];
    if (rank[a] == rank[b]) rank[a]++;
    _numberOfSet--;
    return true;
  }

  int sizeOfSet(const int &x) { return _sizeOfSet[root(x)]; }

  int numberOfSet() { return _numberOfSet; }

  int size() { return tree.size(); }
};

signed main() {
  constexpr int K = 7;
  int n;
  while (cin >> n) {
    vector<int> a(n);
    cin >> a;
    vector<int> d(K);
    UnionFind uf(K);
    for (auto &&x : a) {
      d[x / 10]++, d[x % 10]++;
      uf.unite(x / 10, x % 10);
    }
    int os = 0;
    for (auto &&x : d) os += odd(x);
    bool ok = os <= 2;
    rep(i, K) rep(j, K) ok &= d[i] == 0 || d[j] == 0 || uf.same(i, j);
    cout << (ok ? "Yes" : "No") << endl;
  }
}



Measured memory_bytes: 3032
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<61;
int iinf=1<<30;
double pi=3.14159265358979323846;
double pi2=pi/2.0;
double eps=1e-8;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,0,-1,0};
int dw[4]={0,1,0,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<0)a=-a;
    if(b<0)b=-b;
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a,b,c,k;cin>>a>>b>>c>>k;
    int cnt=0;
    while(b<=a){
        cnt++;
        b*=2;
        
    }
    while(c<=b){
        cnt++;
    c*=2;
    }
    if(cnt<=k)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3648
/**
 * Sergey Kopeliovich (burunduk30@gmail.com)
 */

#include <bits/stdc++.h>

using namespace std;

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

int main() {
	string s;
	cin >> s;
	puts(s.substr(0, 4) == "YAKI" ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF=1e9+7;
struct edge{
    int to, cap, cost, rev;
};

int V;
vector<edge> g[202];
int h[202];
int dist[202];
int prevv[202], preve[202];

void add_edge(int from, int to, int cap, int cost){
    edge e;
    e.to=to, e.cap=cap, e.cost=cost, e.rev=g[to].size();
    g[from].push_back(e);
    e.to=from, e.cap=0, e.cost=-cost, e.rev=g[from].size()-1;
    g[to].push_back(e);
}
  
int min_cost_flow(int s, int t, int f){
    int res=0;
    fill(h, h+V, 0);
    while(f>0){
        priority_queue<P, vector<P>, greater<P>> que;
        fill(dist, dist+V, INF);
        dist[s]=0;
        que.push(P(0, s));
        while(!que.empty()){
            P p=que.top(); que.pop();
            int v=p.second;
            if(dist[v]<p.first) continue;
            for(int i=0; i<g[v].size(); i++){
                edge &e=g[v][i];
                if(e.cap>0 && dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
                    dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
                    prevv[e.to]=v;
                    preve[e.to]=i;
                    que.push(P(dist[e.to], e.to));
                }
            }
        }
        for(int v=0; v<V; v++) h[v]+=dist[v];
        if(dist[t]==INF) return -1;
        int d=f;
        for(int v=t; v!=s; v=prevv[v]){
            d=min(d, g[prevv[v]][preve[v]].cap);
        }
        f-=d;
        res+=d*h[t];
        for(int v=t; v!=s; v=prevv[v]){
            edge &e=g[prevv[v]][preve[v]];
            e.cap-=d;
            g[v][e.rev].cap+=d;
        }
    }
    return res;
}

int main()
{
    int n; cin>>n;
    int ind[101];
    for(int i=0; i<n; i++){
        int p; cin>>p; p--;
        ind[p]=i;
    }
    V=2*n+2;
    int s=V-1, t=V-2;
    for(int i=0; i<n; i++){
        add_edge(s, i, 1, 0);
        add_edge(i+n, t, 1, 0);
        for(int j=0; j<n; j++){
            if(i==j) continue;
            add_edge(i, j+n, 1, abs(ind[i]-j)*(i+1));
        }
    }
    cout<<min_cost_flow(s, t, n)<<endl;
    return 0;
}


Measured memory_bytes: 3484
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define twin(s) s?cout << "Yay!" << endl:cout << ":(" << endl
#define Endl endl


signed main(void){
    int N;
    int A[114514];
    int M;
    int x[114514],y[114514];
    int z=0;
    priority_queue<int, vector<int>, greater<int>> Q;
    priority_queue<int> q;
    cin >> N;
    REP(i,N){
        cin >> A[i];
        if(A[i]>0){
            Q.push(A[i]);
        }else if(A[i]<0){
            q.push(A[i]);
        }else{
            z++;
        }
    }
    REP(i,z){
        if((Q.size())<=(q.size())){
            Q.push(0);
        }else{
            q.push(0);
        }
    }
    
    int mode=1;
    int a,b;
    REP(i,N-1){
        if((Q.size())<=(q.size())){
            mode=1;
        }else{
            mode=-1;
        }
        
        if(i==N-2){
            //mode=1;
        }
        //cout << Q.size() << " " << q.size() << "  ";
        //cout << mode << "   ";
        
        if(Q.empty()){
            a=q.top();q.pop();
            b=q.top();q.pop();
        }else if(q.empty()){
            a=Q.top();Q.pop();
            b=Q.top();Q.pop();
        }else{
            a=Q.top();Q.pop();
            b=q.top();q.pop();
        }
        //cout << a << " " << b << endl;
        int calc=a-b;
        x[i]=a;y[i]=b;
        if(calc*mode<0){
            calc*=-1;
            swap(x[i],y[i]);
        }
        
        if(mode==1){
            Q.push(calc);
        }else{
            q.push(calc);
        }
        M=calc;
    }
    cout << M << endl;
    REP(i,N-1){
        cout << x[i] << " " << y[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;

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

  int cnt = 0;
  while(true) {

    bool exist_odd = false;

    for (int i = 0; i < n ; i++) {
      if ( a[i] % 2 != 0 ) exist_odd = true;
    }


    if (exist_odd) break;

    for (int i = 0; i < n ; i++) a[i] /= 2;

    cnt++;
    
  }

  cout << cnt << endl;

}

Measured memory_bytes: 256
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

def kruskal(es, V):
    es.sort(key=lambda x:x[2])
    uf = UnionFind(V)
    res = 0
    for e in es:
        if not uf.same(e[0], e[1]):
            uf.unite(e[0], e[1])
            res += e[2]
    return res

def resolve():
    n = I()
    es = []
    for i in range(n):
        a = LI()
        for j in range(n):
            if a[j]!=-1:
                es.append((i, j, a[j]))

    ans = kruskal(es, n)
    print(ans)

if __name__ == '__main__':
    resolve()



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

using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a))
#define mp make_pair
#define All(a) (a).begin(), (a).end()
template <typename T=long long>
inline T IN(){T x; cin>>x; return(x);}
inline void CIN(){}
template <class Head,class... Tail>
inline void CIN(Head&& head,Tail&&... tail){
    cin>>head;
    CIN(move(tail)...);
}
#define CINT(...) int __VA_ARGS__;CIN(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CIN(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CIN(__VA_ARGS__)
#define Yes(a) cout<<(a?"Yes":"No")<<"\n"
#define YES(a) cout<<(a?"YES":"NO")<<"\n"
 
typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int,V,greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int N;
vector<int> A,B,C;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>N;
	A.resize(N); B.resize(N); C.resize(N);
	REP(i,N) A[i]=IN();
	REP(i,N) B[i]=IN();
	REP(i,N) C[i]=IN();
	sort(All(A)); sort(All(C));
	ll res=0;
	FOREACH(b,B){
		ll tmp=1;
		tmp*=lower_bound(All(A),b)-A.begin();
		tmp*=C.end()-upper_bound(All(C),b);
		res+=tmp;
	}
	cout<<res<<"\n";
	return 0;
}

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

int main() {
  int n,l;
  cin >> n >> l;
  vector<pair<int,bool>> a(n);
  int ans = 0;
  rep(i,n){
    int t;
    t=l+i;
    ans+=t;
    if(t<0){
      t*=-1;
      a.at(i).second=true;
    }
    a.at(i).first=t;
   // cout << t << endl;
  }
  sort(a.begin(),a.end());
  a[0].second ? cout << a[0].first+ans : cout << ans-a[0].first;
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
const int N=1e5+5;
map<int,int> a;
int main()
{
    ios::sync_with_stdio(false);
    ll n,i,x,ans=0;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
    {
    	scanf("%lld",&x);
    	ans+=a[i-x];
    	a[i+x]++;
	}
    printf("%lld\n",ans);
    return 0; 
}

Measured memory_bytes: 20676
#include <stdio.h>

#define MAX 250

int main() {
	int n, i, parent, left, right;
	int A[MAX + 1];

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &A[i + 1]);
	}

	for (i = 1; i <= n; i++) {
		parent = i / 2;
		left = i * 2;
		right = left + 1;
		printf("node %d: key = %d, ", i, A[i]);
		if (parent > 0)
			printf("parent key = %d, ", A[parent]);
		if (left <= n)
			printf("left key = %d, ", A[left]);
		if (right <= n)
			printf("right key = %d, ", A[right]);
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2080
awk 'NR==1{
    n = $1
    k = $2
    q = $3
}
NR>1{
    a[$1]++;
}
END {
    for (i = 1; i <= n; ++i) {
        if (k - q + a[i] <= 0) {
            print "No"
        } else {
            print "Yes"
        }
        delete a[i]
    }
}'


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

amin=min(a)
amax=max(a)

smin=(amax**2)*n
for y in range(amin,amax+1):
    ssum=0
    for i in range(n):
        ssum=ssum+(a[i]-y)**2
    smin=min(smin,ssum)

print(smin)    


Measured memory_bytes: 38896
local mod = 1000000007

local function bmul(x, y)
  return (x * y) % mod
end

local function badd(x, y)
  return (x + y) % mod
end

local function bsub(x, y)
  return x < y and x - y + mod or x - y
end

local n, k = io.read("*n", "*n")
local plus = {}
local minus = {}
for i = 1, n do
  local a = io.read("*n")
  if 0 <= a then
    table.insert(plus, a)
  else
    table.insert(minus, -a)
  end
end
table.sort(plus)
table.sort(minus)
if n == k then
  local ans = 1
  for i = 1, #plus do
    ans = bmul(ans, plus[i])
  end
  for i = 1, #minus do
    ans = bmul(ans, mod - minus[i])
  end
  print(ans)
  os.exit()
elseif #plus == 0 and k % 2 == 0 then
  local ans = 1
  for i = 1, k do
    ans = bmul(ans, mod - minus[#minus + 1 - i])
  end
  print(ans)
  os.exit()
elseif #plus == 0 and k % 2 == 1 then
  local ans = 1
  for i = 1, k do
    ans = bmul(ans, mod - minus[i])
  end
  print(ans)
  os.exit()
end
local ans = 1
local ppos, mpos = #plus, #minus
if k % 2 == 1 then
  ans = plus[#plus]
  k = (k - 1) // 2
  ppos = #plus - 1
else
  k = k // 2
end
do
  for i = 1, k do
    if ppos < 2 then
      ans = bmul(ans, bmul(minus[mpos], minus[mpos - 1]))
      mpos = mpos - 2
    elseif mpos < 2 then
      ans = bmul(ans, bmul(plus[ppos], plus[ppos - 1]))
      ppos = ppos - 2
    else
      local t1 = minus[mpos] * minus[mpos - 1]
      local t2 = plus[ppos] * plus[ppos - 1]
      if t1 < t2 then
        ans = bmul(ans, (t2 % mod))
        ppos = ppos - 2
      else
        ans = bmul(ans, (t1 % mod))
        mpos = mpos - 2
      end
    end
  end
  print(ans)
end


Measured memory_bytes: 6968
# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <unordered_set>
# include <unordered_map>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define MP make_pair
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define STRING(x) string x;cin>>x;
# define STR(x) STRING(x);
# define DOUBLE(x) double x;cin>>x;
# define DBL(x) DOUBLE(x); 
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl
# define INIT(a) memset(a,-1,sizeof a)
# define CLR(a) memset(a,0,sizeof a)
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
//const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const int M = 1000000007;
template<class T> void debug(T a) { for ( auto i : a )cout << i << endl; }

struct edge { int to, cap, rev; edge(int to, int cap, int rev) :to(to), cap(cap), rev(rev) {} };
vector<edge> G[1200];
bool used[1200];
void add_edge(int from,int to,int cap)
{
	G[from].push_back(edge(to, cap, G[to].size()));
	G[to].push_back(edge(from, 0, G[from].size() - 1));
}

int dfs(int v, int t, int f)
{
	if ( v == t )return f;
	used[v] = true;
	FOR(i, G[v].size())
	{
		edge &e = G[v][i];
		if ( !used[e.to] && e.cap > 0 )
		{
			int d = dfs(e.to, t, min(f, e.cap));
			if ( d > 0 )
			{
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t)
{
	int flow = 0;
	while ( true )
	{
		CLR(used);
		int f = dfs(s, t, INF);
		if ( f == 0 )return flow;
		flow += f;
	}
}
int gcd(int a, int b)
{
	if ( a < b )swap(a, b);
	if ( b == 0 )return a;
	return gcd(b, a%b);
}
int main()
{
	while ( true )
	{
		int m, n;
		cin >> m >> n;
		if ( !m&&!n )break;
		int s = m + n, t = s + 1;
		vi b, r;
		FOR(i, 1200)G[i].clear();
		FOR(i, m)
		{
			INT(x);
			b.push_back(x);
			add_edge(s, i, 1);
		}

		FOR(i, n)
		{
			INT(x);
			r.push_back(x);
			add_edge(m + i, t, 1);
		}

		FOR(i, m)
		{
			FOR(j, n)
			{
				if ( gcd(b[i], r[j]) != 1 )
				{
					add_edge(i, j + m, 1);
				}
			}
		}
		cout << max_flow(s, t) << endl;

	}


}

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

using namespace std;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef pair<db, db> pdd;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef unsigned long long ull;

#define F          first
#define S          second
#define pnl        printf("\n")
#define sz(x)      (int)x.size()
#define sf(x)      scanf("%d",&x)
#define pf(x)      printf("%d\n",x)
#define all(x)     x.begin(),x.end()
#define rall(x)    x.rbegin(),x.rend()
#define rep(i, n)  for(int i = 0; i < n; ++i)

const db eps = 1e-9;
const db pi = acos(-1);
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1000 * 1000 * 1000 + 7;

int n, m;
char s[3030], t[3030];
int dp[3003][3003];

int solve(int i, int j) {
    if (i == n || j == m) return 0;
    int &ret = dp[i][j];
    if (~ret) return ret;
    ret = max(solve(i + 1, j), solve(i, j + 1));
    if (s[i] == t[j]) ret = max(ret, solve(i + 1, j + 1) + 1);
    return ret;
}

void printAns(int i, int j) {
    if (i == n || j == m) return;
    int &ret = dp[i][j];
    if (ret == solve(i + 1, j)) {
        printAns(i + 1, j);
    } else if (ret == solve(i, j + 1)) {
        printAns(i, j + 1);
    } else {
        printf("%c", s[i]);
        printAns(i + 1, j + 1);
    }
    return;
}

int main() {
    scanf("%s%s", s, t);
    n = strlen(s);
    m = strlen(t);
    memset(dp, -1, sizeof dp);
    solve(0, 0);
    printAns(0, 0);
    cout << endl;
    return 0;
}


Measured memory_bytes: 35968
def main():
    n, m = map(int, input().split())
    ab_list = [list(map(int, input().split())) for _ in range(n)]
    ab_list.sort(key=lambda x: x[0])
    ans = 0

    for ab in ab_list:
        a, b = ab[0], ab[1]
        if b <= m:
            ans += a * b
            m -= b
        else:
            ans += a * m
            break

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 93620
n,k=map(int,input().split())
a=list(map(int,input().split()))
from collections import Counter
cc=Counter(a)
l=[]
for i in cc:
    l.append([cc[i],i])
l.sort(key=lambda x: -x[0] )
#print(l)
su=0
for i in range(min(k,len(l))):
    su+=l[i][0]
print(n-su)


Measured memory_bytes: 45748
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int min(int A,int B){
    if(A<=B){
        return A;
    }else{
        return B;
    }
};

int main(){
    char S[100000];
    int i;
    int count_one=0;
    int count_zero=0;
    scanf("%s",&S);

    for(i=0;i<strlen(S);i++){
        if(S[i]=='0'){
            count_zero+=1;
        }else if(S[i]=='1'){
            count_one+=1;
        }
    }
    
    printf("%d\n",min(count_one,count_zero)*2);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}




ll sum_(ll x,ll y){
  return (y-x-1)*(y-x)/2;
}

int main(){
  chrono::system_clock::time_point start, end;
  start = chrono::system_clock::now();
  mt19937 mt(1);
  uniform_real_distribution<double> rnd(0.00,1.00);

  ll D;
  cin >> D;
  vector<ll> c(26);
  FOR(i,0,26) cin >> c[i];
  vector<ll> last(26,0),s(26);
  vector<vector<ll>> S;
  vector<ll> t_(D);

  FOR(i,0,D){
    FOR(j,0,26){
      cin >> s[j];
    }
    S.push_back(s);
  }

  ll ans = 0;

  //FOR(i,0,D) cin >> t_[i];
  
  FOR(i,0,D){

    //FOR(j,0,26) cin >> s[j];
    ll score=-INF,res;
    ll sc = 0;
    FOR(j,0,26){
      sc -= c[j]*(i+1-last[j]);
    }
    FOR(j,0,26){
      ll sc_j = c[j]*(i+1-last[j]) + s[j];
      if(sc+sc_j >= score){
        score = sc + sc_j;
        res = j;
      }
    }
    last[res] = i+1;
    //cout << res+1 << endl;
    t_[i] = res+1;
    ll t = res+1;
    ans += S[i][t-1];
    last[t-1] = i+1;
    FOR(j,0,26){
      ans -= c[j] * (i+1 - last[j]);
    }
    //cout << ans << endl;
  }



  vector<set<ll>> use(26);//日にち
  FOR(i,0,26){
    use[i].insert(0);
    use[i].insert(D+1);
  }
  FOR(i,0,D){
    use[t_[i]-1].insert(i+1);
  }



  while(1){
    end = chrono::system_clock::now();
    double time = static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0);
    if(time >= 1960.0)break;

    ll d,q,b;
    //cin >> d >> q;
    d = (mt() % D) + 1;
    q = (mt() % 26) + 1; 


    b = t_[d-1];
    t_[d-1] = q;
    
    ll deff = S[d-1][q-1]-S[d-1][b-1];
    use[b-1].erase(d);
    use[q-1].insert(d);

    auto br = use[b-1].upper_bound(d);
    auto bl = use[b-1].upper_bound(d);
    bl--;

    auto qr = use[q-1].upper_bound(d);
    auto ql = use[q-1].upper_bound(d);
    ql--;ql--;

    deff += (sum_(*bl,d)+sum_(d,*br))*c[b-1];
    deff += sum_(*ql,*qr)*c[q-1];

    deff -= (sum_(*ql,d)+sum_(d,*qr))*c[q-1];
    deff -= sum_(*bl,*br)*c[b-1]; 

    //ans += deff;

    if(deff > 0){
      ans += deff;
    }else{
      t_[d-1] = b;
      use[b-1].insert(d);
      use[q-1].erase(d);
    }


    //cout << ans << endl;
  }

  FOR(i,0,D){
    cout << t_[i] << endl;
  }

}



Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  
  int M1=0;
  for(int j=0;j<N;j++){
    M1=max(M1,A.at(j));
  }
  
  vector<int> B(N);
  for(int k=0;k<N;k++){
    B.push_back(A.at(k));
  }
  
  int M2=0;
  sort(B.begin(),B.end());
  for(int l=0;l<B.size()-1;l++){
    M2=max(M2,B.at(l));
  }
  
  for(int k=0;k<N;k++){
    if(M1==A.at(k)){
      cout << M2 << endl;
    }else{
      cout << M1 << endl;
    }
  }
   
}

Measured memory_bytes: 3952
n, a, b, c, d = map(int, input().split())

string = input()

if "##" in string[a-1:c] or "##" in string[b-1:d]:
    print("No")

elif c < d:
    print("Yes")

else :
    if "..." in string[b-2:d+1]:
        print("Yes")

    else :
        print("No")



Measured memory_bytes: 3572
s_dic = {}
for _ in range(int(input())):
    s = input()
    if not s in s_dic.keys():s_dic[s] = 1
    else:s_dic[s] += 1
for _ in range(int(input())):
    t = input()
    if t in s_dic.keys():s_dic[t] -= 1
print(max(0,max(s_dic.values())))

Measured memory_bytes: 3060
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  int a,b,c,x,y,ans=1000000000,e;
  cin>>a>>b>>c>>x>>y;
  for(int i=0;i<=max(x,y);i++){
    e=c*2*i+a*max(0,x-i)+b*max(0,y-i);
    ans=min(ans,e);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <set>
#include <vector>

#define MAX_N (100000)
#define MAX_M (100000)

using namespace std;

int is_bipartite(const vector<vector<int>> &adj_lists, int cur,
                 vector<int> &gs) {
  int ret = 1;
  for (int nxt : adj_lists[cur]) {
    if (gs[nxt] == 0) {
      gs[nxt] = -gs[cur];
      if (!is_bipartite(adj_lists, nxt, gs)) {
        ret = 0;
        break;
      }
    } else {
      if (gs[nxt] == gs[cur]) {
        ret = 0;
        break;
      }
    }
  }
  return ret;
}

// read editorial
int main(int argc, char *argv[]) {
  // read inputs
  int n, m, as[MAX_M], bs[MAX_M];
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &as[i], &bs[i]);
    as[i]--;  // NOTE : modified input
    bs[i]--;  // NOTE : modified input
  }

  // create adjacency lists
  vector<vector<int>> adj_lists(n, vector<int>());
  for (int i = 0; i < m; i++) {
    const int a = as[i], b = bs[i];
    adj_lists[a].push_back(b);
    adj_lists[b].push_back(a);
  }

  // check whether the graph is bipartite
  vector<int> gs(n, 0);
  gs[0] = 1;
  const int b = is_bipartite(adj_lists, 0, gs);
  if (b) {
    int cnt_b = 0, cnt_w = 0;
    for (int g : gs) {
      if (g > 0) {
        cnt_b++;
      } else {
        cnt_w++;
      }
    }
    // printf("cnt_b = %d, cnt_w = %d\n", cnt_b, cnt_w);
    printf("%ld\n", (long) cnt_b * cnt_w - m);
  } else {
    printf("%ld\n", (long) (long) n * (n - 1) / 2 - m);
  }

  return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
using namespace std;
int ck(int N,long long mask){
	int c=-1;
	long long k=1;
	for(int i=0;i<N;i++,k<<=1)
		if(mask&k){
			if(c>=0)c=-2;
			if(c==-1)c=i;
		}
	return c;
}
int main(){
	for(int N,M,Q;cin>>N>>M>>Q,N;){
		vector<long long>v0(M);
		vector<long long>v1(M);
		string prev(M,'0');
		{
			long long mask=0,k=1;
			for(int i=0;i<N;i++,k<<=1)mask|=k;
			for(int i=0;i<M;i++)v0[i]=v1[i]=mask;
		}
		for(;Q--;){
			string s,t;
			cin>>s>>t;
			long long mask0=0,mask1=0,k=1;
			for(int i=0;i<N;i++,k<<=1)(s[i]=='0'?mask0:mask1)|=k;
			for(int i=0;i<M;i++)
				if(!(prev[i]^t[i]))
					v0[i]&=mask0;
				else
					v1[i]&=mask1;
			prev=t;
		}
		for(int j=0;j<M;j++){
			int i=0,c[3]={ck(N,v0[j]),ck(N,v1[j]),ck(N,v1[j]&v0[j])};
			for(;i<3;i++)if(c[i]>=0){putchar(c[i]<10?c[i]+'0':c[i]-10+'A');break;}
			if(i==3)putchar('?');
		}
		puts("");
	}
}

Measured memory_bytes: 1216
#include<stdio.h>
int main(void)
{
	int n,a,b,c,d,m,l,x,y,x1,y1,x2,y2;
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	x1=n/a;
	y1=n/c;
	m=n%a;
	l=n%c;
	if(m>=1){
		x2=x1+1;
		x=b*x2;
	}
	else{
		x=x1*b;
		}
	if(l>=1){
		y2=y1+1;
		y=y2*d;
	}
	else{
		y=y1*d;
	}
	if(x<y){
		printf("%d\n",x);
	}
	else{
		printf("%d\n",y);
	}
	return 0;
}


Measured memory_bytes: 2732
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

int d[] = {500, 100, 50, 10, 5, 1};
void solve(){
    int n;
    cin >> n;
    ll ans = 0;
    ans += 1000 * (n/500);
    n%=500;
    ans += 5 * (n/5);
    cout << ans << endl;

}
int main(int argv, char **argc){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string a;
    cin >> a;
    if(a[0] == 'A'){
        cout << 'T' << endl;
    } else if (a[0] == 'C'){
        cout << 'G' << endl;
    } else if (a[0] == 'G'){
        cout << 'C' << endl;
    } else{
        cout << 'A' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/**
 *      ABC 42 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-20 06:56:58
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N, L; cin >> N >> L;
    string S[N] = {};
    for (auto i = 0; i < N; ++i) {
        cin >> S[i];
    }
    sort(S, S + N);
    for (auto i = 0; i < N; ++i) {
        cout << S[i];
    }
    return 0;
}

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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define N 100000

int a[N];
ll pre[N], suf[N];

int main()
{
    canhazfast();

    int n;
    ll sa = 0;

    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i], sa += a[i];
    pre[1] = a[0];
    for (int i = 1; i < n; ++i) pre[i+1] = pre[i-1]+a[i];
    suf[n-1] = a[n-1];
    for (int i = n-2; i >= 0; --i) suf[i] = suf[i+2]+a[i];
    for (int i = 0; i < n; ++i) cout << 2*(pre[i]+suf[i])-sa << ' ';
    cout << '\n';

    return 0;
}


Measured memory_bytes: 3328
N = int(input().strip())
L = [int(str) for str in input().split()]

L.sort()

ans = 0

for a in range(N - 2):
    c = a + 1
    for b in range(a + 1, N - 1):
        while c < N - 1 and L[c + 1] < L[a] + L[b]:
            c += 1
        ans += c - b

print(ans)

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

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

int main() {

  int N;
  cin >> N;

  long long T;
  cin >> T;

  long long ans = T;
  for(int i = 1;i < N;i++) {
    cin >> T;
    long long g = gcd(ans,T);
    ans = ans / g * T;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
  int n,s=0,p=99; cin>>n;
  int a[n],b[n],c[n];
  rep(i,n) cin>>a[i],a[i]--;
  rep(i,n) cin>>b[i];
  rep(i,n-1) cin>>c[i];
  for(int t:a){
    s+=b[t];
    if(p==t-1) s+=c[p];
    p=t;
  }
  cout<<s;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
#define int long long
using namespace std;
int ka[214514],inv[214514];
void setkaijo(int n){
	ka[0]=1;
	for(int i=1;i<=n;i++){
		ka[i] = ka[i-1] * i;
		ka[i] %= inf;
	}
}
int modpow(int x,int k){
	// x ^ k mod inf
	int p2[55],res=1;
	p2[0]=1;p2[1]=x%inf;
	for(int i=2;i<=50;i++){
		p2[i]=p2[i-1]*p2[i-1];
		p2[i] %= inf;
	}
	for(int i=1;i<=50;i++){
		if(k%2==1){
			res *= p2[i];
			res %= inf;
		}
		k /= 2;
	}
	return res;
}
void setinv(int n){
	for(int i=1;i<=n;i++){
		inv[i] = modpow(ka[i],(ll)inf-2);
	}
}
int comb(int n,int k){
	if(k==0 || k==n)return 1;
	int res = (ka[n] * inv[k]) % inf;
	res = (res*inv[n-k]) % inf;
	return res;
}
signed main(){
	int n,m,k;
	cin>>n>>m>>k;
	setkaijo(210000);
	setinv(210000);
	int ans = 0;
	for(int i=1;i<n;i++){
		int tmp = i;
		tmp *= (n-i) * m * m;
		tmp %= inf;
		tmp *= comb(n*m-2,k-2);
		tmp %= inf;
		ans += tmp;
		ans %= inf;
	}
	for(int i=1;i<m;i++){
		int tmp = i;
		tmp *= (m-i) * n * n;
		tmp %= inf;
		tmp *= comb(n*m-2,k-2);
		tmp %= inf;
		ans += tmp;
		ans %= inf;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<functional>
#include<stdio.h>
using namespace std;

long long unsigned int N;
long long int H;
long long unsigned int a[100000], b[100000];

int main(){
    cin >> N;
    cin >> H;
    for(int i = 0; i < N; i++)
        scanf("%lld %lld", &a[i], &b[i]);

    sort(a, a+N, greater<int>());
    sort(b, b+N, greater<int>());

    int cnt = 0;
    for(int i = 0; b[i] >= a[0] && i < N; i++){
        H -= b[i];
        cnt++;
        if(H <= 0) break;
    }
    while(H > 0){
        H -= a[0];
        cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef  long long ll;
using    namespace std;
#define  pb        push_back
#define  ff        first
#define  ss        second
#define  mk        make_pair
#define  all(v)    v.begin(),v.end()
#define  allr(v)   v.rbegin(),v.rend()
#define  sz        size()
#define  Tanmoy    ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0)

const int MAX=1e9+10;
const int MOD=1e9+7;
//for(ll i=0; i<n; i++)    **I Want To Be The Best**

int main()
{
    Tanmoy;

    ll n,k,x=1;
    cin>>n>>k;

    for(ll i=0; i<n; i++){
        if(x<k)x*=2;
        else x+=k;
    }
    cout<<x;

  return 0;
}



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


int main()
{
	int n;
	cin>>n;
	if(n==25)cout<<"Christmas"<<endl; 
	else if(n==24)cout<<"Christmas Eve"<<endl; 
	else if(n==23)cout<<"Christmas Eve Eve"<<endl; 
	else if(n==22)cout<<"Christmas Eve Eve Eve"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    List<List<Integer>> t = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      t.add(new ArrayList<>());
    }
    for (int i = 0; i < N-1; i++) {
      int a = sc.nextInt();
      a--;
      int b = sc.nextInt();
      b--;
      t.get(a).add(b);
      t.get(b).add(a);
    }
    
    if (N == 1) {
      System.out.println(K);
      return;
    }
    
    int[] child = new int[N];
    for (int i = 0; i < N; i++) {
      child[i] = -1;
    }
    LinkedList<Integer> q = new LinkedList<>();
    q.offer(0);
    while (!q.isEmpty()) {
      int p = q.poll();
      child[p] = 0;
      for (int c : t.get(p)) {
        if (child[c] == -1) {
          child[p]++;
          q.offer(c);
        }
      }
    }
    int[] power = new int[K+1];
    power[K] = 1;
    power[K-1]--;
    
    power[K-1]++;
    if (K-1-child[0] < 0) {
      System.out.println(0);
      return;
    }
    power[K-1-child[0]]--;
    
    for (int i = 1; i < N; i++) {
      if (child[i] > 0) {
        power[K-2]++;
        if (K-2-child[i] < 0) {
          System.out.println(0);
          return;
        }
        power[K-2-child[i]]--;
      }
    }
    
    //System.out.println(Arrays.toString(power));
    
    int num = 0;
    for (int i = K; i >=0; i--) {
      num += power[i];
      power[i] = num;
    }
    
    long ans = 1;
    for (int i = 2; i <= K; i++) {
      while (power[i]-- > 0) {
        ans *= i;
        ans %= 1_000_000_007;
      }
    }
    
    //System.out.println(Arrays.toString(child));
    //System.out.println(Arrays.toString(power));
    System.out.println(ans);
  }
}

Measured memory_bytes: 107500
import math

H = int(input())
W = int(input())
N = int(input())

blacks = 0
if H > W:
    n_columns = min(math.ceil(N / H), W)
    blacks += H * n_columns
    if blacks < N:
        n_rows = math.ceil((N - blacks) / (W - n_columns))
    else:
        n_rows = 0
    print(n_columns + n_rows)
else:
    n_rows = min(math.ceil(N / W), H)
    blacks += W * n_rows
    if blacks < N:
        n_columns = math.ceil((N - blacks) / (H - n_rows))
    else:
        n_columns = 0
    print(n_columns + n_rows)

Measured memory_bytes: 3064
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

N, M = nm()
K = []
S = []
for _ in range(M):
    tmp = nl()
    K.append(tmp[0])
    S.append(tmp[1:])
P = nl()
ans = 0
for state in range(1 << N):
    isOn = [True if (state >> i) % 2 == 1 else False for i in range(N)]
    isOK = True
    for i, li in enumerate(S):
        sum = 0
        for s in li:
            if isOn[s-1]:
                sum += 1
        if not sum % 2 == P[i]:
            isOK = False
            break
    if isOK:
        ans += 1
print(ans)


Measured memory_bytes: 9236
n = int(input())
g = [[] for _ in range(n+1)] #1-index
for i in range(n):
    u, k, *v = map(int, input().split())
    for j in v:
        g[u].append(j)

#-------------------------------------------
def dfs(v): #未訪問の点vから潜っていく
    global time
    seen[v] = 1 #訪問済にする
    time += 1
    d[v] = time
    if g[v]:
        for next_v in g[v]:
            if seen[next_v] == 1: continue
            dfs(next_v) #再帰
    
    time += 1
    f[v] = time
    
#-------------------------------------------
seen = [0]*(n+1) #1-index
seen[0] = 1
seen[1] = 1 
d = [0]*(n+1)
f = [0]*(n+1)
time = 0

dfs(1) #深堀り

for i in range(1,n+1): #孤立点対応
    if seen[i] == 0:
        dfs(i)

for i in range(1,n+1):
    print(i, d[i], f[i])



Measured memory_bytes: 5672
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  if(a > b || (n == 1 && a != b)){
    cout << 0 << endl;
    return 0;
  }
  ll r = (ll)b*(n-1)+a;
  ll l = (ll)a*(n-1)+b;
  cerr << r << " " << l << endl;
  ll ans = r - l+1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<cctype>
using namespace std;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0] << endl;
}


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

namespace ABC113C
{
    static class MainClass
    {

        public static void Main(string[] args)
        {


            string[] input1 = Console.ReadLine().Split(' ');

            int N = int.Parse(input1[0]);
            int M = int.Parse(input1[1]);


            int[][] PY = new int[M][];
            for (int i = 0; i < M; i++)
            {
                string[] input2 = Console.ReadLine().Split(' ');
                int[] pandy = new int[4];

                pandy[0] = int.Parse(input2[0]);//県
                pandy[1] = int.Parse(input2[1]);//年
                pandy[2] = i; //もとのindex
                pandy[3] = 0; //市の中の順番
                PY[i] = pandy;
            }

            //PY.ToList().Sort((a, b) => a[0] - b[0]);//県でソート

       
            List<int[]> dst = PY.ToList().OrderBy(a => a[0]).ThenBy(a => a[1]).ToList() ;
        

            List<int> grp = dst.GroupBy(a => a[0]).Select(c => c.Count()).ToList();

            int diff = 0;

            for (int i = 0; i < M;i++){
                if(i!=0){
                    if(dst[i][0] != dst[i-1][0]){
                        diff = diff + grp[0];
                        grp.RemoveAt(0);
                    }
                }

                dst[i][3] = int.Parse(string.Format("{0,10}",i - diff + 1));
            }

            List<string> ans = dst.ToList().OrderBy(a => a[2]).ToList().Select(a => string.Format("{0:D6}", a[0]) + String.Format("{0:D6}",a[3])).ToList();

            foreach(var items in ans){
                Console.WriteLine(items);
            }            
            return;

        }


    }

}






Measured memory_bytes: 45708