akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD) { return powm(a, m-2, m);}

int main()
{
	fastIO
	ll a,b,k;
	cin>>a>>b>>k;
	ll fa=max(a-k,0ll);
	k-=(a-fa);
	b=max(b-k,0ll);
	cout<<fa<<" "<<b;
	return 0;
}




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

#define MAX 100000
#define INFTY 100000000
#define WHITE 0
#define BLACK -1

typedef struct{
  int k;
  int *weight;
  int *num;
}LIST;

int n;
LIST M[MAX];

void difkstra()
{
  int i, u, v, minv, temp;
  int d[n], color[n];

  for( i=0; i<n; i++ )
    {
      d[i] = INFTY;
      color[i] = WHITE;
    }

  d[0] = 0;                  /*スタート地点を０に設定する*/              
  while(1)
    {
      minv = INFTY;          
      for( i=0; i<n; i++ )
	{
	  if( minv > d[i] && color[i] != BLACK )   
	    {
	      u = i;
	      minv = d[i];
	    }
	}
      if( minv == INFTY ) break;  /*全てのノードの色が黒になっていたら*/
      color[u] = BLACK;
      for( v=0; v<M[u].k; v++ )
	{
	  temp = M[u].num[v];    /*uが繋っているノードの番号をtempに代入*/
	  
	  if( color[temp] != BLACK )
	    {
	      if( d[temp] > d[u] + M[u].weight[v] )
		{
		  d[temp] = d[u] + M[u].weight[v];
		}
	    }
	}
    }

  for( i=0; i<n; i++ )
    {
      printf("%d %d\n", i, d[i]);
    }

}


int main()
{
  int i, j, u, k, v, c,unp;
  
  scanf("%d", &n);
  
  for( i=0; i<n; i++ )
    {
      scanf("%d%d", &unp, &M[i].k);
      M[unp].weight = (int *)malloc( M[i].k * sizeof(int));
      M[unp].num = (int *)malloc( M[i].k * sizeof(int));

      for( j=0; j<M[i].k; j++ )
	{
	  scanf("%d%d", &M[unp].num[j], &M[unp].weight[j]);
	}
    }

  difkstra();

  for( i=0; i<n; i++ )
    {
      free( M[i].weight );
      free( M[i].num );
    }

  return 0;
}
      




Measured memory_bytes: 5428
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int lot[30],n,m;
  for(int i=0; i<30; i++){lot[i] = i+1;}
  cin>>n>>m;
  while(m--){
    int a,b;
    scanf("%d,%d",&a,&b);
    int c = lot[a-1];
    lot[a-1] = lot[b-1];
    lot[b-1] = c;
  }
  for(int i=0; i<n; i++){cout<<lot[i]<<endl;}
  return 0;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    priority_queue<pair<int, int>> q;
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        q.push({b[i], i});
    }
    long long ans = 0;
    while (q.size() > 0) {
        int i = q.top().second;
        q.pop();
        if (b[i] < a[i]) {
            ans = -1;
            break;
        }
        if (b[i] > a[i]) {
            int d = b[(n + i - 1) % n] + b[(i + 1) % n];
            int c = (b[i] - a[i]) / d;
            if (c == 0) {
                ans = -1;
                break;
            }
            ans += c;
            b[i] -= c*d;
            q.push({b[i], i});
        }
    }
    cout << ans << endl;
}





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

int main() {
	int a,b,s1,s2,s3;
	cin>>a>>b;
	s1=a+b;
	s2=a-b;
	s3=a*b;
	cout<<max(max(s1,s2),s3);
	return 0;
}


Measured memory_bytes: 256
k,n=map(int,input().split())
home = input()
home = home.split()
for i in range(len(home)):
    home[i] = int(home[i])
d=[]
for i in range(len(home)):
    if i == len(home)-1:
        d.append(home[0]+k-home[i])
        break
    d.append(home[i+1]-home[i])
Max = max(d)
leng=len(home)
count=0
for i in range(len(d)):
    if d[i] == Max:
        break
d=0
while True:
    
    if count==leng-1:
        break
    j=i-1
    if i==0:
        d+=abs(home[leng-1]-(home[0]+k))
        count+=1
    else:
        d += abs(home[i]-home[i-1])
        count+=1
    i-=1
    if i == -1:
        i=leng-1
print(d)

Measured memory_bytes: 20276
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

N = int(input())
def dfs(s): # 文字列 s で始まる七五三数の個数
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0 
    # s 自体が七五三数なら +1 
    for c in '753':
        ret += dfs(s + c)
    return ret
print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく

#文字列をどんどん分岐しながら延ばすときにもdfsは使える
#準七五三数を全列挙し、それぞれについて判定

Measured memory_bytes: 3316
from collections import Counter, defaultdict

h, w, n = map(int, input().split())
blacks = defaultdict(int)

for a, b in (map(int, input().split()) for _ in range(n)):
    for y in range(max(0, a - 3), min(a, (h - 2))):
        for x in range(max(0, b - 3), min(b, (w - 2))):
            blacks[(y, x)] += 1

print((h - 2) * (w - 2) - len(blacks))

c = Counter(blacks.values())
for i in range(1, 10):
    print(c[i] if i in c else 0)


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

using namespace std;

#define llint long long int
#define REP(i,s,l) for(llint i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main() {

    double gakumen;
    string kahei;
    double sum=0;
    double price = 0;

    int person;
    cin >> person ;

    REP(i,0,person){
        cin >> gakumen;
        cin >> kahei;
        if(kahei == "JPY") price = gakumen*1.0;  
       else price = gakumen* 380000.0; 

       //cout << price << endl;
       sum += price;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Pi acos(-1)
using namespace std;
int  main()
{
    long double r,area,circum;
    cin>>r;
    area=r*r*Pi;
    circum=2*Pi*r;
    cout<<fixed<<setprecision(6)<<area<<" "<<circum<<endl;
    return 0;
}



Measured memory_bytes: 3284
(def dream  (reverse "dream"))
(def erase (reverse "erase"))
(def eraser (reverse "eraser"))
(def dreamer (reverse "dreamer"))
(defn daydream [S]
  (cond
    (empty? S) "YES"
    (= (take 5 S) erase) (daydream (drop 5 S))
    (= (take 5 S) dream) (daydream (drop 5 S))
    (= (take 6 S) eraser) (daydream (drop 6 S))
    (= (take 7 S) dreamer) (daydream (drop 7 S))
    :else "NO"))
 (println (daydream (reverse (read-line))))

Measured memory_bytes: 92720
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  string s[3];
  rep(i,3)cin >> s[i];
  int stemp[3]={};
  int temp=0;
  bool flag=true;
  while(flag){
    for(char c='a';c<='c';c++){
      if(s[temp][stemp[temp]]==c){
        stemp[temp]++;        
        temp=0+c-'a';
      }
    }
    if(s[temp].size()<=stemp[temp])flag=false;
  }
  cout << (char)(temp+'A') << endl;
return 0;}

Measured memory_bytes: 256
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
  if a[i]<=x:
    if a[i]+a[i+1]<=x:
      continue
    else:
      ans+=a[i+1]-(x-a[i])
      a[i+1]=x-a[i]
  else:
    ans=a[i]-x
    a[i]=x
    ans+=a[i+1]
    a[i+1]=0
print(ans)
    

Measured memory_bytes: 19908
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int, int>pii;
int main()
{
	int num;
	scanf("%d", &num);
	vector<pii>z;
	for (int i = 1; i < 5000; i++)z.push_back(make_pair(i * 6 + 2, i * 6 + 4));
	for (int i = 1; i < 2500; i++)z.push_back(make_pair(i * 12 + 3, i * 12 + 9));
	for (int i = 0; i < 2500; i++)z.push_back(make_pair(i * 12 + 6, i * 12 + 12));
	vector<int>v;
	if (num == 3)
	{
		v.push_back(2);
		v.push_back(5);
		v.push_back(63);
	}
	else
	{
		v.push_back(2);
		v.push_back(4);
		v.push_back(3);
		v.push_back(9);
		num -= 4;
		if (num % 2 == 1)v.push_back(30000), num--;
		for (int i = 0; i < num / 2; i++)
		{
			v.push_back(z[i].first);
			v.push_back(z[i].second);
		}
	}
	for (int i = 0; i < v.size(); i++)printf("%d\n", v[i]);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int N;
	cin >> N;
	for(int n = 1;n <= N;n++){
		ll cnt = 0;
		for(int x = 1;x * x <= n;x++){
			for(int y = 1;y <= n - x * x && y <= x;y++){
				for(int z = 1;z <= n - x * x - y * y && z <= y;z++){
					if(x * x + y * y + z * z + x * y + y * z + z * x == n){
						if(x == y && y == z)cnt++;
						else if(x != y && y != z)cnt += 6;
						else if(x != y || y != z)cnt += 3;
					}
				}
			}
		}
		cout << cnt << endl;
	}
}


Measured memory_bytes: 3596
#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 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(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(snip_i, n) cin >> a.at(snip_i);
	int ans = 1001001001;
	for(int i = -100; i <= 100; i++){
		int add = 0;
		rep(j, n){
			add += (i - a.at(j)) * (i - a.at(j));
		}
		ans = min(ans, add);
	}
	cout << ans << endl;
	return 0;
}

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

#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define pfis(a) printf("%d ",a);
#define pfls(a) printf("%lld ",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(int i=a;i<b;i++)
#define pb(a) push_back(a);
#define mp(a,b) make_pair(a,b)
#define ll long long
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>

const ll mod=1e9+7;

void solve()
{
    int n,k;
    sfi(n)
    sfi(k)


    int arr[n];
    f(i,0,n)
    	sfi(arr[i])

    sort(arr,arr+n);

    int sum=0;

    f(i,0,k)
    {
    	sum+=arr[i];
    }
    pfin(sum)

    return;
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    solve();
    
    return 0;
}

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

int main() {
	string s;
	cin >> s;
	int n = 0;
	int m = 0;
	for (int i=0; i<s.size(); i++) {
		if (s[i] == '0') n++;
		else m++;
	}
	int c = min(n,m);
	cout << 2 * c << endl;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

typedef unsigned long long ullong;

ullong power(ullong x, ullong n, ullong M)
{
    ullong result = 1;
    if (n > 0)
    {
        result = power(x, n / 2, M);
        if(n  % 2 == 0)
            result = (result * result) % M;
        else
            result = (((result * result) % M) * x) % M;
    }
    return result;
}

int main()
{
    int x, n;
    cin >> x >> n;
    cout << power(x, n, 1000000007) << endl;
}


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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  cout << string(ty-sy, 'U') + string(tx-sx, 'R');
  cout << string(ty-sy, 'D') + string(tx-sx+1, 'L');
  cout << string(ty-sy+1, 'U') + string(tx-sx+1, 'R');
  cout << "DR";
  cout << string(ty-sy+1, 'D') + string(tx-sx+1, 'L');
  cout << 'U' << endl;
}

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

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;

#define trav(a, A) for (auto & a : A)

const int INF = 1e9;
const ll INFLL = 1e18;

int main ()
{
    ios_base::sync_with_stdio (0);
    cin.tie (0);
    int i, j, n, w;
    string s, t;
    cin >> s >> t;
    vector <vi> dp (s.size () + 1, vi (t.size () + 1, 0));
    for (i = 1; i <= s.size (); ++i)
    {
        for (j = 1; j <= t.size (); ++j)
        {
            if (s[i - 1] == t[j - 1])
                dp[i][j] = max (dp[i][j], dp[i - 1][j - 1] + 1);
            else
                dp[i][j] = max (dp[i - 1][j], dp[i][j - 1]);
        }
    }
    vector <char> pilha;
    for (i = s.size (), j = t.size (); i > 0 && j > 0;)
        if (dp[i-1][j] == dp[i][j]) --i;
        else if (dp[i][j - 1] == dp[i][j]) --j;
        else pilha.push_back (s[--i]), --j;
    while (pilha.size ())
    {
        cout << pilha.back ();
        pilha.pop_back ();
    }
    cout << '\n';

    return 0;
}


Measured memory_bytes: 35584
#include <stdio.h>

typedef long long ll;

const ll MAXS = 2000;
const ll MOD = (ll)1e9 + 7;

ll dp[MAXS];

int main(void)
{
	ll s, i, j;

	scanf("%lld", &s);

	dp[0] = 1;

	for (i = 1; i <= s; i++)
		for (j = 3; j <= s; j++)
			if (i >= j)
				dp[i] = (dp[i] + dp[i - j]) % MOD;

	printf("%lld", dp[s]);
	return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-6;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

int n;
double l;

int main(){
	ios::sync_with_stdio(0);
	cout<<syosu(9);
	cin>>n>>l;
	deque<pdd> deq;
	double sx=0,sy=0,t,v;
	cin>>t>>v;
	deq.push_back({0,0});
	cout<<t<<endl;
	sx+=v;
	sy+=t*v;
	deq.push_front({-sx,-sy});
	for(int i=1;i<n;i++){
		cin>>t>>v;
		sx+=v;
		sy+=t*v;
		pdd p;
		double L=l-sx;
		while(deq.back().first-eps>L){
			p=deq.back();
			deq.pop_back();
		}
		pdd tmp=deq.back();
		double lx=tmp.first,ly=tmp.second,rx=p.first,ry=p.second;
		deq.push_back({L,(ry-ly)*(L-lx)/(rx-lx)+ly});
		cout<<(deq.back().second+sy)/l<<endl;
		while(deq.size()>1){
			tmp=deq.front();
			deq.pop_front();
			p=deq.front();
			lx=tmp.first,ly=tmp.second,rx=p.first,ry=p.second;
			if((ly+sy)/(lx+sx)>(ry+sy)/(rx+sx)-eps){
				deq.push_front(tmp);
				break;
			}
		}
		deq.push_front({-sx,-sy});
	}
}

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

int main()
{
  int a, b, c;
  int ans = 0;
  int maxv = 0;
  int odd = 0;

  cin >> a >> b >> c;

  maxv = max(a, max(b, c));

  ans += (maxv - a) / 2 + (maxv - b) / 2 + (maxv - c) / 2;

  if ( (maxv - a) % 2 == 1){
    odd++;
  }
  if ( (maxv - b) % 2 == 1) {
    odd++;
  }
  if ( (maxv - c) % 2 == 1) {
    odd++;
  }

  if ( odd == 1 ) {
    ans += 2;
  } else if ( odd == 2 ) {
    ans += 1;
  }

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf 10000000000000000ll
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define eps 1e-9
#define endl "\n"
/*ll gcd(ll a,ll b)
{
    if(a==0){return b;}
    return gcd(b%a,a);
}
ll modexp(ll x,ll y,ll p)
{
    ll res=1;x%=p;
    while(y>0)
    {   if(y%2==1){res=(res*x)%p;}
        y=y>>1;x=(x*x)%p;
    }return res;
}*/


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;cin>>n;
    vi d(n);
    rep(i,0,n-1)
    {
        cin>>d[i];
    }
    sort(all(d));
    int ans=d[n/2]-d[n/2-1];
    cout<<ans<<"\n";


    return 0;

    /*check for long long or int*/
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  long long m = 100000;
  while(n--){
    m *= 1.05;
    m = ((long long)m/1000+(m%1000?1:0))*1000;
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 1156
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.special import perm
# from scipy.special import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

########
class Edge:
    def __init__(self, from_edge, to_edge, cost):
        self.from_edge = from_edge
        self.to_edge = to_edge
        self.cost = cost

def bellman_ford(start, edges, node_num):
    dist = [INF] * node_num
    dist[start] = 0
    flag = False
    for i in range(node_num):
        for edge in edges:
            if dist[edge.to_edge] > dist[edge.from_edge] + edge.cost:
                dist[edge.to_edge] = dist[edge.from_edge] + edge.cost
                if i == N-1 and edge.to_edge == (node_num - 1):
                    flag = True
    return dist, flag


N, M = l_inpl()
edges = []

for _ in range(M):
    ai, bi, ci = l_inpl()
    edges.append(Edge(ai-1, bi-1, -ci))

dist, flag = bellman_ford(0, edges, N)
# print(dist)
if flag:
    print("inf")
else:
    print(-dist[N-1])


Measured memory_bytes: 47336
import java.util.Scanner;

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

        int X = sc.nextInt();
        int A = sc.nextInt();

        if(X < A){
            System.out.println("0");
        }else{
            System.out.println("10");
        }
    }
}

Measured memory_bytes: 23764
#include <cstdio>
#include<iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstring>
#include <string.h>
#include<vector>
#include <set>
#include <vector>
#include <iterator>
using namespace std;
typedef long long int ll;
const int MAX_N = 999999 + 5;

int prime[MAX_N + 1];
int is_prime[MAX_N + 1];
void sieve(int n)
{
    int p = 0;
    for (int i = 0; i <= n ;i++)
    {
        is_prime[i] = true;
    }
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++)
    {
        if (is_prime[i])
        {
            //cout << "**" << endl;
            prime[i] = ++p;
            for (int j = 2 * i; j <=  n; j += i)
                is_prime[j] = false;
        }
        else prime[i] = p;
    }
    return ;
}
int main()
{
    int a;
    sieve(999999);
    while (~scanf("%d", &a))
    {
        printf("%d\n", prime[a]);
    }
    return 0;
}


Measured memory_bytes: 10948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int A, B;
    cin >> A >> B;
    for (int i = 0; i <= 1000; i++) {
        if ((int)(i * 0.08) == A && (int)(i * 0.1) == B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
//
// Created by Hideaki Imamura on 2020-03-18.
//
# include <bits/stdc++.h>

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

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

ll A, B;

ll gcd(ll a, ll b) {
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

int main() {
    cin >> A >> B;

    ll C = gcd(A, B);
    ll res = 1;
    for (ll i = 2; i * i <= C; ++i) {
        if (C % i == 0) res++;
        while (C % i == 0) C /= i;
    }
    if (C != 1) res++;
    cout << res << endl;

    return 0;
}

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

namespace ConsoleApp3
{
    internal class Class2
    {
        private static void Main(string[] args)
        {
            var abx = Console.ReadLine();

            if (abx.Last() == 's')
            {
                Console.WriteLine(abx + "es");
            }
            else
            {
                Console.WriteLine(abx + "s");
            }
        }
    }
}

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

int main() {
	int n, num;
	double t, a, h, mn = 100100;
	cin >> n >> t >> a;
	for (int i = 1; i <= n; i++) {
		cin >> h;
		if (mn > fabs((t - h * 0.006) - a)) {
			mn = fabs((t - h * 0.006) - a);
			num = i;
		}
	}

	cout << num << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n;
    cin >> n;
    ll t, a;
    cin >> t >> a;
    rep(i, n - 1){
        ll s, b, ts, ab;
        cin >> s >> b;
        ll times = max((t - 1) / s + 1, (a - 1) / b + 1);
        t = s * times;
        a = b * times;
    }
    cout << t + a << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int dicea[7],diceb[7],dicec[7],temp;
  int i,j,k,flag=0;
  //サイコロ入力のターン!!
  for(i=1;i<7;i++){
    scanf("%d",&dicea[i]);
  }
  for(i=1;i<7;i++){
    scanf("%d",&diceb[i]);
    dicec[i]=diceb[i];
  }
  //上下比較
  for(i=1;i<7;i++){
    if(dicea[1]==diceb[i] && dicea[6]==diceb[7-i]){
      flag=1;
      if(i==3 || i==4){
	if(i==4)j=3;
	else j=0;
	diceb[2]=dicec[1];
	diceb[3]=dicec[2+j];
	diceb[4]=dicec[5-j];
	diceb[5]=dicec[6];
      }
      if(i==5 || i==2){
	if(i==2)j=1;
	else j=0;
	diceb[2]=dicec[1];
	diceb[3]=dicec[3+j];
	diceb[4]=dicec[4-j];
	diceb[5]=dicec[6];
      }
      if(i==6){
	diceb[3]=dicec[4];
	diceb[4]=dicec[3];
      }
      break;
    }
  }
  //捜索
  if(flag==1){
    flag=0;
    for(i=0;i<4;i++){
      temp=diceb[2];
      diceb[2]=diceb[3];
      diceb[3]=diceb[5];
      diceb[5]=diceb[4];
      diceb[4]=temp;
      if(dicea[2]==diceb[2] &&
	 dicea[3]==diceb[3] &&
	 dicea[4]==diceb[4] &&
	 dicea[5]==diceb[5]){
	flag=1;
	break;
      }
    }
  }
  if(flag==1)printf("Yes\n");
  else printf("No\n");
  return(0);
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
 
P project(P a,P b,P c){
  b-=a,c-=a;
  return a+b*real(c/b);
}
 
int main(){
  int n;
  double ax,ay,bx,by,cx,cy;
  cin>>ax>>ay>>bx>>by>>n;
  while(n--){
    cin>>cx>>cy;
    P p=project(P(ax,ay),P(bx,by),P(cx,cy));
    printf("%.8f %.8f\n",p.real(),p.imag());
  }
  return 0;
}

Measured memory_bytes: 1256
#include <stdio.h>

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int N;
    cin >> N;
    int arr[101] = {0};
    int tmp[101] = {0};

    for (int i = 0; i < N; i++) {
        cin >> tmp[i];
        arr[tmp[i]] = 1;
    }

    int counter = 0;
    for (int i = 0; i <= 100; i++) {
        if (arr[i] > 0) {
            counter++;
        }
    }

    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

N, X = map(int,readline().split())

T = [0] * (N + 1) # レベルiバーガーの厚さ
P = [0] * (N + 1) # レベルiバーガーのパティの数

T[1] = 5
P[1] = 3

for i in range(2, N + 1):
  T[i] = T[i - 1] * 2 + 3
  P[i] = P[i - 1] * 2 + 1

# Nバーガー,X枚目
stack = [[N,X]]
ans = 0

while stack:
  n, x = stack.pop()
  if n == 1:
    ans += min(x - 1,3)
    continue
  if x <= 1: # 1枚目の場合はパティなし
    continue
  if x < 1 + T[n - 1]: # 一つ目のレベルn - 1バーガーに収まる場合
    stack.append([n - 1, x - 1])
  elif x <= 1 + T[n - 1]:
    ans += P[n - 1]
  elif x == 2 + T[n - 1]:
    ans += P[n - 1]
    ans += 1
  elif x < 2 + T[n - 1] * 2:
    ans += P[n - 1]
    ans += 1
    stack.append([n - 1, x - (T[n - 1] + 2)])
  else:
    ans += P[n - 1] * 2
    ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

int main() {
    int n; cin >> n;
    int t[110000], x[110000], y[110000];
    t[0] = x[0] = y[0] = 0;
    for (int i = 0; i < n; i++) cin >> t[i+1] >> x[i+1] >> y[i+1];

    bool can = true;
    for (int i = 0; i < n; i++) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist%2 != dt%2) can = false;

    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 100005
#define fi(a, b, c, d) for(int a = b; i < c; i += d)
#define fl(a, b, c, d) for(ll a = b; i < c; i += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
 priority_queue <int, vector<int>, greater<int> > pq;

int main() {
	scanf("%lld %lld %lld %lld %lld", &N, &M, &A, &B, &C);
	for(int i = 0; i < A; i++) {
		scanf("%lld", &arr[i]);
	}
	for(int i = 0; i < B; i++) {
		scanf("%lld", &arr1[i]);
	}
	sort(arr, arr + A);
	sort(arr1, arr1 + B);
	reverse(arr, arr + A);
	reverse(arr1, arr1 + B);
	for(int i = 0; i < N; i++) {
		pq.push(arr[i]);
	}
	for(int i = 0; i < M; i++) {
		pq.push(arr1[i]);
	}
	for(int i = 0; i < C; i++) {
		scanf("%lld", &data[i]);
		if(data[i] > pq.top()) {
			pq.pop();
			pq.push(data[i]);
		}
	}
	ll sum = 0;
	while(!pq.empty()) {
		sum += pq.top();
		pq.pop();
	}
	printf("%lld\n", sum);


	return 0;
}
/*
	Powered by Buggy Plugin
*/




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

using namespace std;

void test_case()
{
    int n;
    cin>>n;
    int data[n];
    memset(data,0,sizeof(data));
    int temp;
    for(int i=1;i<n;i++){
        cin>>temp;
        data[temp]++;
    }


    for(int i=1;i<n;i++){
        printf("%d\n",data[i]);
    }
    printf("0\n");
}

int main()
{
        test_case();

    return 0;
}


Measured memory_bytes: 4476
#include<stdio.h>

int main(void){
  int comNum;
  int zyousi[200001];
  int bukaNum[200001]={0};
  int i;
  
  if(scanf("%d",&comNum));
  
  for(i=2;i <= comNum;i++){
    if(scanf("%d ",&zyousi[i]));
    bukaNum[zyousi[i]] += 1;
  }

  
  for(i=1;i<=comNum;i++){
    printf("%d\n",bukaNum[i]);
  }
 
  return 0;
}

Measured memory_bytes: 3296
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>

using namespace std;


/* define */
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define REP(i, n) for ( int i = 0; i < (n) ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1000000007;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */

int main() {
	int d, g, p[10], c[10], ans = (int)1e9;
	cin >> d >> g;
	REP(i, d) cin >> p[i] >> c[i];
	REP(i, 1 << d) {
		int s = 0, num = 0, max = 0;
		REP(j, d) {
			if (i >> j & 1) {
				s += 100 * (j + 1) * p[j] + c[j];
				num += p[j];
			}
			else max = j;
		}
		if (s < g) {
			int s1 = 100 * (max + 1);
			int need = (g - s + s1 - 1) / s1;
			if (need < p[max]) {
				num += need;
				s += s1 * need;
			}
		}
		if (s >= g) ans = min(ans, num);
	}
	cout << ans << endl;
	return 0;
}

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

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


Measured memory_bytes: 256
#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 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;
  cin >> n;
  vector<int> tp(n), ap(n);
  vector<pair<int, int>> vp(n);
  rep(i, n){
    int a, b;
    cin >> a >> b;
    tp.at(i) = a; ap.at(i) = b;
    vp.at(i) = make_pair(a+b, i);
  }
  sort(vp.rbegin(), vp.rend());
  ll ansa = 0, ansb = 0;
  rep(i, n){
    if(i % 2 == 0) ansa += tp.at(vp.at(i).second);
    else ansb += ap.at(vp.at(i).second);
  }
  cout << ansa - ansb << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
using namespace std;
int main() {
  long long h;
  long long n;
  cin >> h;
  cin >> n;
  long long A[100000+1];
  long long sum=0;
  for(long long i=0; i<n; i++){
    cin >> A[i];
    sum+=A[i];
  }
  if(h-sum <=0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


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

const ll maxn=100+5, maxw=1e5+5, inf=0x3f3f3f3f3f3f3f3f;
ll N, W, v[maxn], w[maxn], dp[maxn][maxw];

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

    cin>>N>>W;
    rep(i,1,N+1) cin>>w[i]>>v[i];
    rep(i,1,N+1) {
        memcpy(dp[i], dp[i-1], sizeof dp[i]);
        rep(j,w[i],W+1) dp[i][j]=max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
    }
    cout<<dp[N][W]<<"\n";
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch RemainderMinimization2019 | diff RemainderMinimization2019.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address RemainderMinimization2019.cpp && ./a.out

/*
 
 7/7/2019
 
 5:07-
 
 */

LL L,R;

LL f(LL x) {
  if(x<0) return 0;
  return x/2019+1;
}
void solve() {
  map<LL,LL> cnt;
  REP(r,2019) {
    LL x=f(R-r)-f(L-1-r);
    if(x>0)cnt[r]=x;
  }
//  dumpc(cnt);
  map<LL,vector<pair<LL,LL>>> pairs;
  REP(a,2019) pairs[a*a%2019].emplace_back(a,a);
  REP(b,2019)REP(a,b) pairs[a*b%2019].emplace_back(a,b);
  LL res=-1;
  FORR(kvp,pairs) FORR(p,kvp.second) {
    LL a,b; tie(a,b)=p;
    if(cnt.count(a)==0||cnt.count(b)==0) continue;
    cnt[a]--,cnt[b]--;
    if(cnt[a]>=0&&cnt[b]>=0) {
      res=kvp.first;
      goto fin;
    }
    cnt[a]++,cnt[b]++;
  }
fin:
  assert(res!=-1);
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>L>>R;
  solve();
  
  return 0;
}


Measured memory_bytes: 44672
//  @ /\/\ BESH //

#include <bits/stdc++.h>
#define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCase    int T; cin>>T; while(T--)
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,s,e) for(int i=s;i<=e;i++)
#define endl '\n'
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define pb push_back


using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 100001;
const int mod = 1000000007;


int main(){
        int n;
        ll k;
        cin>>n>>k;
        ll a[n];
        fr(i,n){cin>>a[i]; a[i] %= k;}
        ll pf[n+1];
        pf[0] = 0;
        fro(i,1,n)pf[i] = (pf[i-1] + a[i-1])%k;

        ll ans = 0;
        unordered_map< ll , ll > M;

        for(int i = 0; i <= n; i++){
            if(i >= k){
                M[pf[i-k]]--;
            }
            pf[i] = (pf[i] - (i%k) + k)%k;
            ans += M[pf[i]];
            M[pf[i]]++;
        }


        cout<< ans << endl;
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
	int N;
	cin >> N;
	mint ans = 1;
	for (int i = 1; i <= N; ++i) {
		ans *= i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3600
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    int ans = 1;
    for(int i=0;i<n;i++){
        if(ans*2>ans+k)ans += k;
        else ans *= 2;
    }
    cout << ans << endl;
}

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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int h,n;
    cin>>h>>n;

    int sum = 0;

    for(int i = 0; i < n; i++) {
        int x;
        cin>>x;
        sum += x;
    }

    if(sum >= h) {
        cout<<"Yes"<<endl;
    } else cout<<"No"<<endl;


    

}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main() {
  int n, x, result;
 
  cin >> n >> x;
  while(n != 0 || x != 0) {
    result=0;
    for(int i=1; i <= n-2; i++) {
      for(int j=i+1; j <= n-1; j++) {
        for(int k=j+1; k <= n; k++) {
          if(i+j+k == x) result++;
        }
      }
    }
    cout << result << endl;
    cin >> n >> x;
  }
 
  return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

int main()
{
  vector<int64_t> a;
  int64_t n;

  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

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

  cout
      << a.front()
      << " "
      << a.back()
      << " "
      << accumulate(a.begin(), a.end(), 0LL)
      << endl;

  return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
typedef long long ll;
ll dp[105][100005];
ll w[maxn],v[maxn];
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,W;
    cin>>n>>W;
    rep(i,1,n)cin>>w[i]>>v[i];

    rep(i,1,n){
        rep(j,0,w[i])dp[i][j]=dp[i-1][j];
        rep(j,w[i],W)
        dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
    }   
    debug(dp[2][3]);
    debug(dp[1][3]);
    cout<<dp[n][W]<<endl;
}
/* 
拿W 最大的价值
dp[i][w]:拿到第i个，价值小于等于w的最大拿法的价值
dp[i][w]=max(dp[i-1][w],dp[i-1][w-w[i]]+v[i]);
dp[w]:价值小于等于w的最大拿法的价值。 
 */

Measured memory_bytes: 82176
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int x,k,d;
	cin>>x>>k>>d;
	int ans=x%d;
	if(ans<0) ans+=d;
	int ans1=ans-d;
	if((abs(x-ans)/d)%2==k%2&&(abs(x-ans)/d)<=k)
	{
		cout<<abs(ans)<<endl;
		return 0;
	}
	if((abs(x-ans1)/d)%2==k%2&&(abs(x-ans1)/d)<=k)
	{
		cout<<abs(ans1)<<endl;
		return 0;
	}
	if(x>0)
	{
		cout<<abs(x-k*d)<<endl;
		return 0;
	}
	else
	{
		cout<<abs(x+k*d)<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#define max(x, y) (x) > (y) ? (x):(y) 

using namespace std;

int main(void)
{
	int N, L, sum = 0, temp, min=9999;
	cin >> N >> L;
	for (int i = 1; i <= N; i++) {
		temp = L + i - 1;
		sum += temp;
		if (temp >= 0 && min > 0 && min > temp)min = temp;
		else if (temp <= 0 && min > 0 && min > -temp)min = temp;
		else if (temp >= 0 && min < 0 && -min > temp)min = temp;
		else if (temp <= 0 && min < 0 && -min > -temp)min = temp;
	}
	sum -= min;
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
lis = [-1 for i in range(26)]
for i in range(n):
  s = list(str(input()))
  li = [0 for _ in range(26)]
  for j in range(len(s)):
    li[ord(s[j])-ord("a")] += 1
  for h in range(26):
    if lis[h] == -1:
      lis[h] = li[h]
    else:
      lis[h] = min(lis[h],li[h])
ans = ""
for i in range(26):
  ans += chr(97+i) * max(lis[i],0)
print(ans)

Measured memory_bytes: 3064
//#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>

//Some constants don't work
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef INT_MIN
#define INT_MIN -2147483648
#endif
//short hand tricks
typedef long long ll;

using namespace std;

int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(false);
    int animals, legs;
    cin >> animals >> legs;
    //animals = x+y
    // 2x+4y = legs
    //max legs is 4*animals
    //min legs is 2*ANIMALS
    if(legs%2==0 && legs<=4*animals && legs>=animals*2) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;
int n,nr4,nr2,x,nr1;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        if(x%4==0) nr4++;
        else if (x%2==0) nr2++;
        else nr1++;
    }
    if(nr2)
    {
        if(nr1<=nr4) cout<<"Yes";
        else cout<<"No";
        return 0;
    }

    if(nr1<=nr4+1) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256