akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<long long,long long>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define eb emplace_back

const int MOD1=1000000007;
const int MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const int dx[]={0,1,0,-1,1,-1,1,-1};
const int dy[]={1,0,-1,0,1,1,-1,-1};

#define unless(a) if(!(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(n);i++)
#define bitrep(i,s,n) for(int i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}
long long cutup(long long a,long long b){return (a+b-1)/b;}
long long popcnt(long long a){return __builtin_popcountll(a);}
template<class T,class U> inline bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template<class T,class U> inline bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}

struct edge{long long to,cost;};
struct edge2{long long from,to,cost;};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin>>n;
    vl A(n);
    rep(i,n)cin>>A[i];
    if(accumulate(all(A),0LL)==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(n%3!=0){
        cout<<"No"<<endl;
        return 0;
    }
    if(count(all(A),0)==n/3){
        set<ll> s;
        rep(i,n){
            s.insert(A[i]);
        }
        Yes(s.size()==2);
        return 0;
    }
    map<ll,ll> m;
    rep(i,n){
        m[A[i]]++;
    }
    if(m.size()==3){
        ll a=m[A[0]];
        vl N;
        rbf(p,m){
            if(p.second!=a){
                Yes(0);
                return 0;
            }else{
                N.eb(p.first);
            }
        }
        ll b=0;
        rep(i,3){
            b=b^N[i];
        }
        Yes(b==0);
        return 0;
    }
    cout<<"No"<<endl;
}

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

typedef long long LL;

int n;

int main(){
	LL x,y;
	x=1LL, y=1LL;
	cin >> n;
	for(int i=1;i<=n;i++){
		LL u,v;
		cin >> u >> v;
		LL tu = (x+u-1)/u;
		LL tv = (y+v-1)/v;
		LL tx = max(tu,tv);
		x = u*tx;
		y = v*tx;
	}
	cout << x+y << endl;
	return 0;
}


Measured memory_bytes: 256
cards = [input() for i in range(3)]

now = 0
index =[0,0,0]
dic={"a":0,"b":1,"c":2}

while True:
    if index[now] == len(cards[now]):
        break
    idx = index[now]
    index[now] += 1
    now = dic[cards[now][idx]]
    

print("ABC"[now])

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

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

	int A = count(S.begin(), S.end(), 'a');
	int B = count(S.begin(), S.end(), 'b');
	int C = count(S.begin(), S.end(), 'c');

	if (A == B && B == C) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using lint=long long;
using namespace std;

int main()
{
	lint N,K;
	lint x[100010]={};
	lint ans=1e18;
	
	cin >> N >> K;
	for(lint i=0;i<N;i++)
		cin >> x[i];
	
	for(lint i=0;i<N-K+1;i++)
	{
		lint l=x[i];
		lint r=x[i+K-1];
		if((l>=0 && r>=0) || (l<=0 && r<=0))
			ans=min(ans,max(abs(l),abs(r)));
		else
			ans=min(ans,min(abs(l),abs(r))+abs(l-r));
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

long long fac[100010], finv[100010], inv[100010];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 100010; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    ll n,k;
    cin>>n>>k;

    COMinit();
    for(int i=1;i<=k;i++){
        ll ans=COM(n-k+1,i);
        ans=(ans*COM(k-1,i-1))%MOD;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 5952
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Node{
  int key;
  struct Node *parent,*left,*right;
};
struct Node *root, *NIL;

void insert(int k){

  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;

  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key <x->key){
      x=x->left;
    }
    else {
      x=x->right;
    }
  }
  z->parent = y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key < y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}
void inorder(struct Node *u){
  if(u==NIL){
    return;
  }

  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
struct Node * findkey(struct Node *u,int k){
  while(u != NIL && k!= u->key){
    if(k < u->key){
      u=u->left;
    }
    else {
      u=u->right;
    }
  }
      return u;
    }

int main(){
  int n,i=0,x;
  char com[7];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);

    if(com[0]=='f'){
      scanf("%d",&x);

      struct Node *t = findkey(root,x);
      if(t==NIL){
        printf("no\n");
      }
      else {
        printf("yes\n");
      }
    }
    else if(strcmp(com,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }
    else if (strcmp(com,"print")==0){
       inorder(root);
       printf("\n");
       preorder(root);
       printf("\n");
     }

  }
  return 0;
}

Measured memory_bytes: 19364
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)


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

int N;
vector<P> p(105);
ll dp[105][105];
queue<P> que;
ll rec(int l = 0, int r = N){
    if(r - l <= 1)return 0;
    if(r - l == 2){
        return p[l].first * p[l].second * p[r-1].second;
    }
    ll &ret = dp[l][r];
    if(ret != INF)return ret;
    for(int i = l + 1; i <= r - 1; i++){
        ll rr = rec(l, i) + rec(i, r) + (p[l].first * p[i].first * p[r-1].second);
      que.push(P(i, rr));
        chmin(ret, rr);
    }
    return ret;
}

int main(){
    cin >> N;
    rep(i, N){
        ll a, b;
        cin >> a >> b;
        p[i] = P(a, b);
    }
    rep(i, 105)rep(j, 105)dp[i][j] = INF;
    ll res = rec();

  //cout << p[1].first << " " << p[1].second << " " << p[2].second << endl;
    cout << res << endl;
}


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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

string s,t, u;
int a, b;

int main(){
  cin >> s >> t >> a >> b >> u;
  if(s == u){
    cout << a - 1 <<" "<< b <<endl;
  }else{
    cout << a << " " << b - 1 <<endl;
  }
}

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

int N;
int a[110];

int main()
{
    cin >> N;

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

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

    int al = 0, bo = 0;

    for (int i = 0; i < N; i++)
    {
        if (i % 2 == 0)
            al += a[i];
        else
            bo += a[i];
    }

    cout << al - bo << endl;

    return 0;
}


Measured memory_bytes: 256
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) for _ in range(D)]

last = [0 for _ in range(26)]

value = 0
for i in range(D):
  day = i + 1
  value += s[i][t[i]-1]
  last[t[i]-1] = day
  for j in range(26):
    value -= c[j] * (day - last[j])
  print(value)

Measured memory_bytes: 9196
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Abhijeetkns
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CExceptionHandling solver = new CExceptionHandling();
        solver.solve(1, in, out);
        out.close();
    }

    static class CExceptionHandling {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            ArrayList<Integer> list = new ArrayList<>();
            int n = in.nextInt();
            for (int i = 0; i < n; i++) list.add(in.nextInt());
            ArrayList<Integer> list1 = new ArrayList<>(list);
            int max1 = Collections.max(list);
            Collections.sort(list);
            //out.println(list);
            int max2 = list.get(n - 2);

            for (int i = 0; i < n; i++) {
                int ele = list1.get(i);
                if (ele < max1) out.println(max1);
                else {
                    out.println(max2);
                }
            }
        }

    }
}



Measured memory_bytes: 96428
k = int(input())
a,b = map(int,input().split())

# if b-a >= k or a%k == 0 or b%k == 0 :
#     print('OK')
# else:
#     print('NG')
count = 0
for i in range(a,b+1):
    if i%k == 0:
        count += 1
        break
if count == 1:
    print('OK')
else:
    print('NG')

Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int H, W, K;
  cin >> H >> W >> K;

  vector<vector<int>> A(H+1, vector<int>(W+1));
  REP(i, K){
    int x, y, v;
    cin >> x >> y >> v;
    A[x-1][y-1] = v;
  }

  vector<vector<vector<int>>> dp(H+1, vector<vector<int>>(W+1, vector<int>(4, -INF)));
  dp[0][0][0] = 0;
  dp[0][0][1] = A[0][0];

  REP(i, H+1) REP(j, W+1){
    if(i+1 < H && A[i+1][j] != 0){
      REP(k, 4){
        chmax(dp[i+1][j][1], dp[i][j][k]+A[i+1][j]);
      }
    }
    if(j+1 < W && A[i][j+1] != 0){
      REP(k, 3){
        chmax(dp[i][j+1][k+1], dp[i][j][k]+A[i][j+1]);
      }
    }
    if(i+1 <= H){
      REP(k, 4){
        chmax(dp[i+1][j][k], dp[i][j][k]);
      }
    }if(j+1 <= W){
      REP(k, 4){
        chmax(dp[i][j+1][k], dp[i][j][k]);
      }
    }
  }

  int ans = -INF;
  REP(i, 4){
    chmax(ans, dp[H][W][i]);
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 707128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1e9+7;

int main()
{
	ll n;
	cin>>n;
	vector<ll> arr(2*n+1,1);
	arr[0]=0;
	arr[1]=0;
	for(ll i=2;i*i<=2*n;i++)
	{
		if(arr[i]==1)
		{
			for(ll j=i*i;j<=2*n;j+=i)
			{
				arr[j]=0;
			}
		}
	}
	ll i=n;
	while(arr[i]==0)
	{
		i++;
	}
	cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){

        int n;
        string s;
        vector<string> v;

        cin >> n ;
        for(int i=0; i<n; i++){
                cin >> s;
                v.push_back(s);
        }

        cout << "AC x " + to_string(count(v.begin(), v.end(), "AC")) << endl;
        cout << "WA x " + to_string(count(v.begin(), v.end(), "WA")) << endl;
        cout << "TLE x " + to_string(count(v.begin(), v.end(), "TLE")) << endl;
        cout << "RE x " + to_string(count(v.begin(), v.end(), "RE")) << endl;
}

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

int main(void){
    string s;
    while(true){
        cin >> s;
        if(s == "0"){
            break;
        }
        int sum = 0;
        for(int i = 0; i < s.size(); i++){
            // TODO: 文字コードを数値に変換する
            int n= s[i] -'0';
            //cout << "'" << s[i] << "'" << n << endl;
            sum += n;
            
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 3164
<?php
fscanf(STDIN, "%d%d%d%d", $a,$b,$c,$k);
$ans = 0;
$aa = min($a, $k);
$ans += $aa;
$k -= $a;

$bb = min($b,$k);
$k -= $bb;

$cc = min($c, $k);
$ans -= $cc;
$k -= $cc;

echo $ans;
?>

Measured memory_bytes: 16000
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

ll a[103];

int main(){
	int n=ci();
	rep(i,1,n) a[i]=ci();
	ll ans = 1e18;
	rep(p,1,100){
		ll sum = 0;
		rep(i,1,n) sum += (a[i]-p)*(a[i]-p);
		ans = min(ans,sum);
	}
	printf("%lld\n",ans);
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

bool pair_comp(pair<ll, ll> &a, pair<ll, ll> &b) {
  return a.second < b.second;
}

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

  vector<pair<ll, ll>> a(n);
  for (ll i = 0; i < n; ++i) {
    ll x;
    cin >> x;
    a[i] = pair<ll, ll>(i, x);
  }
  sort(a.begin(), a.end(), pair_comp);

  for (ll i = 0; i < n-1; ++i) {
    cout << a[i].first+1 << " ";
  }
  cout << a[n-1].first+1 << endl;
  
  return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int times(int A,int K){
  if(A>=K){
    return 0;
  }
  else{
    int count=0;
    bool flag=true;
    while(flag){
      A=2*A;
      count=count+1;
      if(A>=K){
        flag=false;
      }
    }
    return count;
  }
}
double two(int n){
  if(n==0){
    return 1;
  }
  else{
    double ans=1;
    for(int i=0;i<n;i++){
      ans=ans*2;
    }
    return ans;
  }
}
      
int main(){
  int N,K;
  cin>>N>>K;
  vector<double>k(N);
  vector<double>p(N);
  for(int i=0;i<N;i++){
    k.at(i)=two(times(i+1,K));
  }
  double sum=0;
  for(int i=0;i<N;i++){
    p.at(i)=double(1/k.at(i));
    sum=sum+p.at(i);
  }
  cout<<fixed<<setprecision(10)<<sum/N<<endl;
}

Measured memory_bytes: 1792
k = int(input())
s = input()
s_len = len(s)

if s_len <= k:
    print(s)
else:
    i = 0
    s_list = list(s)
    result = []
    while i < k:
        result.append(s_list[i])
        i += 1
    print(''.join(result) + "...")


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

/*[check]8min
数列をなるべく同じにする

*/
int main()
{
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp-i);}
    sort(a.begin(), a.end());

    ll sum = 0;
    rep(i, n) sum += abs(a[i]-a[n/2]);
    cout << sum << endl;
}



Measured memory_bytes: 1400
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;


int main()
{
    int n;
    cin >> n;
    vector<int> l(2*n);
    for (int i = 0; i < 2 * n; i++)
        cin >> l[i];

    sort(l.begin(), l.end());
    int cnt = 0;
    int i = 0;
    while (i < 2 * n)
    {
        cnt += min(l[i], l[i + 1]);
        i += 2;
    }
    cout << cnt << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD1 = 1000000007;
const ll MOD2 = 1000000021;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int N, M;
ll dist[100000];
ll dist2[100000];
vector<pl> e[100000];
vector<bool> use[100000];

ll mod_pow (ll x, ll y, ll MOD) {
    ll ret = 1;
    while (y) {
        if (y&1) ret = ret * x % MOD;
        x = x * x % MOD;
        y /= 2;
    }
    return ret;
}

void dfs(int v, int par) {
    for (int i = 0; i < e[v].size(); i++) {
        pl p = e[v][i];
        if (p.first == par) continue;
        if (dist[p.first] != linf) continue;
        use[v][i] = true;
        if (p.second > 0) {
            dist[p.first] = dist[v] * p.second % MOD1;
            dist2[p.first] = dist2[v] * p.second % MOD2;
        } else {
            dist[p.first] = dist[v] * mod_pow(-p.second,MOD1-2,MOD1) % MOD1;
            dist2[p.first] = dist2[v] * mod_pow(-p.second,MOD2-2,MOD2) % MOD2;
        }
        dfs(p.first, v);
    }
}

int main() {
    cin >> N >> M;
    rep(i,M) {
        ll a, b, x;
        cin >> a >> b >> x;
        a--; b--;
        e[a].push_back(pl(b, x));
        use[a].push_back(false);
        e[b].push_back(pl(a, -x));
        use[b].push_back(false);
    }
    fill(dist, dist+N, linf);
    rep(i,N) {
        if (dist[i] != linf) continue;
        dist[i] = 1;
        dist2[i] = 1;
        dfs(i, i);
    }
    rep(i,N) {
        rep(j,e[i].size()) {
            if (use[i][j]) continue;
            if (e[i][j].second > 0) {
                if (dist[i]*e[i][j].second%MOD1 != dist[e[i][j].first]) {
                    cout << "No" << endl;
                    return 0;
                }
                if (dist2[i]*e[i][j].second%MOD2 != dist2[e[i][j].first]) {
                    cout << "No" << endl;
                    return 0;
                }
            } else {
                if (dist[i]*mod_pow(-e[i][j].second,MOD1-2,MOD1)%MOD1 != dist[e[i][j].first]) {
                    cout << "No" << endl;
                    return 0;
                }
                if (dist2[i]*mod_pow(-e[i][j].second,MOD2-2,MOD2)%MOD2 != dist2[e[i][j].first]) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
}


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


using namespace std;

int main(){
    int N,K;
    int sum = 0;
    long long ans = 0;
    cin >> N >> K;
    vector<int> H(N);
    for(int i = 0; i < N; i++){
        cin >> H.at(i);
    }

    if(K >= N) cout << 0 << endl;
    else{
        sort(H.begin(),H.end(), greater<int>());
        for(int i = K ; i < N; i++){
            ans += H.at(i);
        }

        cout << ans << endl;
    }
}

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

int main() {
  int N;
  cin >> N;
  int x[N], y[N], h[N];
  for (int i=0 ; i<N ; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }
  for (int cx=0 ; cx<=100 ; cx++) {
    for (int cy=0 ; cy<=100 ; cy++) {
      int res;
      for (int i=0 ; i<N ; i++) {
        if (h[i] > 0) res = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
      }

      bool flag = true;
      for (int i=0 ; i<N ; i++) {
        if (max(res - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]) flag = false;
      }

      if (flag) {
        cout << cx << " " << cy << " " << res << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#include<cmath>
#include <algorithm> 
#include <unordered_map>

using namespace std;

long long tri(vector<long long>arr, long long n)
{
	long long count = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++)
				if (
					arr[i] + arr[j] > arr[k]
					&& arr[i] + arr[k] > arr[j]
					&& arr[k] + arr[j] > arr[i]) {
					set<long long>st;
					st.insert(arr[i]);
					st.insert(arr[j]);
					st.insert(arr[k]);
					if (st.size() == 3) {
						count++;
					}
				}			
		}
	}
	return count;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long n;
	cin >> n;
	vector<long long>arr;
	for (int i = 0; i < n; i++) {
		long long t;
		cin >> t;
		arr.push_back(t);
	}
	sort(arr.begin(), arr.end());
	cout << tri(arr, n);
	return 0;
}

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

using namespace std;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

const int mod = 1e9 + 7;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * x % mod;
            x = x * x % mod;
            n >>= 1;
    }
    return res;
}

void solve() {
    int N;
    cin >> N;
    string S; cin >> S;
    int L = S.size();
    vector<vector<int>> dp(N + 1, vector<int>(N + 1));
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= N; j++) {
            if (j + 1 <= N) {
                dp[i + 1][j + 1] += 2 * dp[i][j];
                dp[i + 1][j + 1] %= mod;
            } 
            dp[i + 1][max(0, j - 1)] += dp[i][j];
            dp[i + 1][max(0, j - 1)] %= mod;
        }
    }
    cout << (dp[N][L] * mod_pow(mod_pow(2, L, mod), mod - 2, mod)) % mod << endl;


}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 98176
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,k = map(int,readline().split())
if k == 1:
  print(0)
  exit()
  
a = [0]+[int(i) for i in readline().split()]
for i in range(1,n+1):
  a[i] = a[i-1]+a[i]
  
a = [(ai-i)%k for i,ai in enumerate(a)]
#print(a)
from collections import Counter,deque
c = Counter({a[0]:1})
d = deque([a[0]])
ans = 0
cnt = 1
for j,aj in enumerate(a[1:]):
  ans += c[aj]
  d.append(aj)
  c.update({aj:1})
  cnt += 1
  if cnt >= k:
    p = d.popleft()
    c.update({p:-1})
  
print(ans)

Measured memory_bytes: 94868
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r =
            new BufferedReader(new InputStreamReader(System.in), 1);
        String is = r.readLine();
        String[] sp = is.split(" ");
        if(sp.length > 3)
            return;
        int a = Integer.parseInt(sp[0]);
        int b = Integer.parseInt(sp[1]);
        int c = Integer.parseInt(sp[2]);
        if(a<b){
            if(b<c){
                System.out.println("Yes");
            }else
                System.out.println("No");
        }else
            System.out.println("No");
      }
}

Measured memory_bytes: 24428
import sys
from collections import deque

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

"""左右で文字列集合を分割する。abc bac のように、左側、右側のそれぞれでは
文字が重複しないようにして作る。"""

def f(N, i=1):
    # i 以上の整数を使う
    if N == 1:
        return deque(), deque()
    if N % 2 == 0:
        A, B = f(N // 2, i + 1)
        A.append(i)
        B.append(i)
        return A, B
    else:
        A, B = f(N - 1, i + 1)
        A.append(i)
        B.appendleft(i)
        return A, B

N = int(read()) + 1

A, B = f(N)
S = A + B
print(len(S))
print(*S)

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

int main() {
	string s; cin >> s;
	for (int i = 0; i < 4; ++i) cout << s[i];
	cout << ' ';
	for (int i = 4; i < s.size(); ++i) cout << s[i];
	cout << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import os
import math
import random

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

EPS = 0.0000001
lower = -EPS
upper = 1 + EPS

denom = det(a, b, c)

if denom != 0:
    t = det(d, b, c) / denom
    u = det(a, d, c) / denom
    v = det(a, b, d) / denom

    if t < lower:
        print('HIT')

    # hit barrier
    elif lower < t < upper and lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
        print('MISS')

    else:
        print('HIT')
else:
    print('HIT')

Measured memory_bytes: 11812
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10
    N,K = LMIIS()
    P = list(map(lambda x: int(x)-1,input().split()))
    C = LMIIS()
    score_sets = []
    used = [False]*N
    tmp = P[0]
    for i in range(N):
        if not used[i]:
            tmp = i
            score_set = []
            while not used[tmp]:
                used[tmp] = True
                tmp = P[tmp]
                score_set.append(C[tmp])
            score_sets.append(score_set)
        
    ans = -INF
    for score_set in score_sets:
        # 合計が最大になる区間を探す
        len_set = len(score_set)
        sum_score_set_real = sum(score_set)
        sum_score_set = max(0,sum_score_set_real)


        
        for i in range(len_set):
            cum_sum_1 = 0
            for j in range(i,min(len_set, i+K)):
                cum_sum_1 += score_set[j]
                num_move = j-i+1
                tmp_max = cum_sum_1 + (K - num_move) // len_set * sum_score_set
                ans = max(ans, tmp_max)

        for i in range(1,len_set-1):
            cum_sum_2 = sum_score_set_real
            for j in range(i,min(len_set-1-(K-i),len_set-1)):
                cum_sum_2 -= score_set[j]
            for j in range(max(i,len_set-1-(K-i)),len_set-1):
                cum_sum_2 -= score_set[j]
                num_move = len_set - (j-i+1)
                tmp_max = cum_sum_2 + (K - num_move) // len_set * sum_score_set
                ans = max(ans,tmp_max)






        
                
    print(ans)

    
main()


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

string S,T;
int s[33];
bool used[33];
signed main() {
    cin>>S>>T;
    for(int i=0;i<S.length();i++){
        if(s[S[i]-'a'+1]==0){
            if(used[T[i]-'a'+1]){
                cout<<"No"<<endl;
                return 0;
            }
            s[S[i]-'a'+1]=T[i]-'a'+1;
            used[T[i]-'a'+1]=true;
        }else if(s[S[i]-'a'+1]!=T[i]-'a'+1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 776
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
    string str; cin >> str;
    int sum = 0;
    REP(i, 3) {
        int tmp = 0;
        if (str[i] == 'o') tmp = 1;
        else tmp = 0;
        sum += tmp;
    }
    cout << 700 + 100 * sum << '\n';
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli m, ans = 0;
    lli n;
    cin >> n >> m;
    rep(i,m){
        lli a;
        cin >> a;
        ans += a;
    }
    cout << (ans > n ? -1 : n-ans) << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
 
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
const int MAX = 1000000;
const int MOD = 1000000007;
 
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
 
int main(){
  int n;
  cin >> n;
  vector<int>p(n),p2(n);
  rep(i, 0, n)cin >> p[i];
  int mx = 200200, cnt=0;
  rep(i, 0, n){
    chmin(mx,p[i]);
    p2[i] = mx; 
  }
  rep(i,0,n){
    if(i==0){
      cnt++;
      continue;
    }else{
      if(p2[i-1]>=p[i]){
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}

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

x = {i:0 for i in range(50000)}
i = 1
while True:
  #print(N)
  x[N] += 1
  if x[N] == 2:
    print(i)
    break
  else:
    if N%2==0:
      N = N//2
    else:
      N = 3*N+1
  i += 1

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

int main(){

  int a, b, c;
  cin >> a >> b >> c;
  if((a == b && b != c) || (a == c && a != b) || (b == c && b != a)){
    cout << "Yes";
  }else{
    cout << "No";
  }

  cout << endl;

  return 0;
}

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

int main(){
	
  string s, t;
  cin >> s >> t;
  
  vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1, 0));
  
  for(int i = 1; i <= s.size(); i++){
  	for(int j = 1; j <= t.size(); j++){
    	if(s[i-1] == t[j-1]){
        	dp[i][j] = 1 + dp[i-1][j-1];
        }
       	else{
       		dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        } 
    }
  }
  
  
   // Create a character array to store the lcs string 
   string res = ""; 
   
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = s.size(), j = t.size(); 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (s[i-1] == t[j-1]) 
      { 
          res = s[i-1] + res; // Put current character in result 
          i--; j--;    // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (dp[i-1][j] > dp[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
  cout << res << endl;
}


Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  vector<long long> h;
  set<int> s;
  long long hi;
  for(int i=0; i<n; i++){
    cin >> hi;
    h.push_back(hi);
    s.insert(i);
  }
  int a, b;
  for(int i=0; i<m; i++){
    cin >> a >> b;
    if(h[a-1]<h[b-1]) s.erase(a-1);
    else if(h[a-1]>h[b-1]) s.erase(b-1);
    else{s.erase(a-1); s.erase(b-1);}
  }
  cout << s.size();
  return 0;
}

Measured memory_bytes: 8800
/*************************************************************************
    > File Name: C.cpp
    > Author: Roundgod
    > Mail: wcysai@foxmail.com 
    > Created Time: 2018-05-23 14:41:27
 ************************************************************************/

#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll n,k,a[MAXN];
int main()
{
    scanf("%lld",&n);
    for(ll i=0;i<n;i++)
        scanf("%lld",&a[i]);
    for(ll i=1;i<n;i++)
        if(a[i]-a[i-1]>1) 
        {
            puts("-1");
            return 0;
        }
    if(a[0]!=0) 
    {
        puts("-1");
        return 0;
    }
    ll ans=0;
    for(ll i=1;i<n;i++)
        if(a[i]!=a[i-1]+1) ans+=a[i-1];
    ans+=a[n-1];
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 1792
antenas = []
for i in range(5):
    antenas.append(int(input()))
    
k = int(input())

flag = False
for antena1 in reversed(antenas):
    for antena2 in antenas:
        if antena1 - antena2 > k:
            flag = True
if flag:
    print(":(")
else:
    print("Yay!")

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

int main(){
  int a,b;
  string s;
  while(true){
  cin >> a >> s >> b;
  if(s =="+"){
    cout << a+b << endl;
  }
  else if(s == "-"){
    cout << a-b << endl;
  }
  else if(s =="*"){
    cout << a*b << endl;
  }
  else if(s == "/"){
    cout << a/b << endl;
  }
  else{return 0;}
}
  return 0;
}



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

#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template<typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template<typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << "\n";
    }
}

void solve() {
    ll n;
    cin >> n;
    v a = ga(n);

    vector<pair<pll, ll>> elements;
    map<ll, ll> freq, leftmostindex;

    for (auto x : a) {
        freq[x]++;
        leftmostindex[x] = n + 1;
    }

    for (ll i = 0; i < n; i++) {
        amin(leftmostindex[a[i]], i);
    }

    elements.reserve(freq.size());
    for (auto x : freq) {
        elements.emplace_back(x, leftmostindex[x.first]);
    }

    sort(all(elements));

    ll sum = 0, idx = sz(elements) - 1;
    v printed(n, 0);

    while (idx >= 0) {
        sum += elements[idx].first.second;

        ll next = idx - 1;
        while (next >= 0 && elements[next].second > elements[idx].second) {
            next--;
        }

        ll val1 = elements[idx].first.first;
        ll val2 = next >= 0 ? elements[next].first.first : 0;
        ll diff = val1 - val2;
        ll add = sum * diff;

        for (ll k = next + 1; k < idx; k++) {
            sum += elements[k].first.second;
            add += elements[k].first.second * (elements[k].first.first - val2);
        }

        printed[leftmostindex[val1]] = add;
        idx = next;
    }

    pa(printed);
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

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

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

	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'e' || c == 'o' || c == 'u') {
		cout << "vowel";
	}
	else cout << "consonant";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    i64 N;
    cin >> N;

    i64 K = LINF;
    rep(i, 5) {
        i64 x; cin >> x;
        chmin(K, x);
    }

    i64 p = (N + K - 1) / K;
    print(p + 4);


    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    int[] xs, ys;
    long[] hs;
    foreach (_; 0..N) {
        auto xyh = readln.split.to!(int[]);
        xs ~= xyh[0];
        ys ~= xyh[1];
        hs ~= xyh[2];
    }
    foreach (y; 0..101) {
        foreach (x; 0..101) {
            long h;
            foreach (i; 0..N) {
                if (hs[i] != 0) {
                    h = hs[i] + abs(x - xs[i]) + abs(y - ys[i]);
                    break;
                }
            }
            foreach (i; 0..N) {
                if (hs[i] != max(0, h - abs(x - xs[i]) - abs(y - ys[i]))) goto ng;
            }
            writeln(x, " ", y, " ", h);
            ng:
        }
    }
}

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

int main(void) {
	string n;
	cin >> n;
	for (int i = 0; i < 3; i++) {
		if (n[i] == '1') n[i] = '9';
		else if (n[i] == '9') n[i] = '1';
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define REP(i, N) for (int (i) = 0; i < N; ++(i))

int main()
{
    int nums[3];
    int K;
    cin >> nums[0] >> nums[1] >> nums[2] >> K;

    REP(i, K) {
        if (nums[0] >= nums[1] && nums[0] >= nums[2])
            nums[0] *= 2;
        else if (nums[1] >= nums[0] && nums[1] >= nums[2])
            nums[1] *= 2;
        else
            nums[2] *= 2;
    }
    int sum = 0;
    REP(i, 3) sum += nums[i];
    
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll modpow(ll b, ll i){
  ll s=1;
  while(i){
    if(i%2) s=(s*b)%MOD;
    b=(b*b)%MOD; i/=2;
  }
  return s;
}
ll nCr(ll n, ll r){
  ll m1=1,m2=1;
  for(int i=0; i<r; i++){
    m1=(m1*(n-i))%MOD; m2=(m2*(r-i))%MOD;
  }
  return (m1*modpow(m2,MOD-2))%MOD;
}
int main(){
  int n,a,b; cin >>n >>a >>b;  
  cout <<(modpow(2,n)-nCr(n,a)-nCr(n,b)-1+2*MOD)%MOD;
return 0;}

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

int main() {
    int n;
    cin>>n;
    for(int x=1;x<=n; x++){
		if(x%3==0||x%10==3||(x/10)%10==3||(x/100)%10==3||(x/1000)%10==3){
	       cout<<" "<<x;
	   }
   }cout<<endl;
}
			
     

         
            



Measured memory_bytes: 3016
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	if (!b)return T(1);
	if (b & 1)return mypow(a, b - 1) * a;
	T memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int main(){
	int x;
	std::cin>>x;
	REP(i,1000){
		if(x*i%360==0){
			std::cout<<i<<std::endl;
			return 0;
		}
	}
	return 0;
}


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

int main(){
	int a[3];
	//array inputing
	for(int i=0;i<3;i++) cin>>a[i]; 
	//sorting (insertion)
	for(int j=0;j<2;j++){
		for(int i=0;i<2;i++){
			if(a[i]>a[i+1]){
				//swaping
				int t=a[i];
				a[i]=a[i+1];
				a[i+1]=t; 
			}
		}
	}
	//outputing
	for(int i=0;i<3;i++){
		cout<<a[i];
		(i==2)?cout<<'\n':cout<<' ';
	}
} 


Measured memory_bytes: 3092
S = input()
ans0 = 0
ans1 = 0
N = len(S)
for i in range(N):
    if i%2 == 0:
        if S[i] == "0":
            ans1 += 1
        else:
            ans0 += 1
    else:
        if S[i] == "1":
            ans1 += 1
        else:
            ans0 += 1        
print(min(ans0, ans1))


Measured memory_bytes: 3188