akhauriyash/Code-Regression huggingface dataset:
/*************************************************\
           In the name of almighty ALLAH
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

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

#define     ikarus_101  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef     long long             ll;
typedef     long double           ld;
typedef     unsigned long long    ull;
typedef     vector<ll>            vll;
typedef     pair<ll,ll>           pll;
typedef     vector<pll>           vpl;
typedef     map<ll,ll>            mll;
typedef     multiset<ll>          msl;
typedef     multimap<ll,ll>       Mll;
using pqboro=priority_queue<ll,vll,less<ll>>;
using pqchoto=priority_queue<ll,vll,greater<ll>>;

#define    all(str)       str.begin(),str.end()
#define    sajo(str)      sort(str.begin(),str.end())
#define    rev(str)       reverse(str.begin(),str.end())
#define    usajo(str)     sort(str.rbegin(),str.rend())
#define    vin(a)         for(auto &it : a) cin>>it
#define    vout(a)        for(auto it:a) cout<<it<<' ';cout<<nn
#define    pb             push_back
#define    eb             emplace_back
#define    mkp(x,y)       make_pair(x,y)
#define    F              first
#define    S              second
#define    yes            cout<<"YES"<<nn
#define    no             cout<<"NO"<<nn
#define    nn             "\n" ///endl
#define    rep(i,n)       for (i=0;i<n;++i )
#define    rep1(i,n)      for (i=1;i<=n;++i )

#define    min3(a,b,c)    min(a,min(b,c))
#define    max3(a,b,c)    max(a,max(b,c))
#define    sqr(x)         ((x)*(x))
#define    pi             2*acos(0.0)
#define    gcd(a,b)       __gcd(a,b)
#define    lcm(a,b)       (a/gcd(a,b))*b
#define    mem(a,b)       memset(a,b,sizeof (a))
#define    dec(x)         cout<<fixed<<setprecision(x)
#define    none(n)         __builtin_popcountll(n)

template < typename T > string toString ( T Number ) { stringstream ss ; ss << Number ; return ss.str() ; }
template < typename T > ll toll ( T str ) { stringstream ss ; ss << str ; ll num ; ss >> num ; return num ; }
ll power(ll n , ll k) { if(k == 0) return 1 ; if(k&1) return n*sqr(power(n,k/2)) ; else return sqr(power(n,k/2)); }

const   int  N   =   2e6+7;
const   int  M   =   1e9+7;
const   ll  inf  =   0x7f7f7f7f7f7f7f7f;
const   int dx[] =   {+1,+2,+2,+1,-1,-2,-2,-1};
const   int dy[] =   {-2,-1,+1,+2,+2,+1,-1,-2};

int main() {//ikarus_101

    //ll n,m,i,j,k,x;


    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ct=0;
    while(b <= a)
    {
        b *= 2;
        ++ct;
    }
    while(c <= b)
    {
        c*= 2;
        ++ct;
    }
    if(ct <= k) puts("Yes");
    else puts("No");











    return 0;
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;

int main() {
	double n, m, d;
	cin >> n >> m >> d;
	if (d == 0) {
		cout << (m - 1) / n;
	}
	else {
		printf("%8f",(m - 1) * 2 * (n - d) / (n * n));
	}
}

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

using namespace std;

int main(){
  int m;
  cin>>m;
  while(m--){
    int ia;
    int y,n;
    cin>>ia>>y>>n;
    int ans=0;
    while(n--){
      int k;
      double a;
      int t;
      cin>>k>>a>>t;
      if(k){
	int tmp=ia;
	for(int i=0;i<y;i++){
	  tmp=tmp*(1+a)-t;
	}
	ans=max(ans,tmp);
      }else{
	int r=0,b=ia;
	for(int i=0;i<y;i++){
	  r+=b*a;
	  b-=t;
	}
	ans=max(ans,r+b);
      }
    }
    cout<<(int)ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
a, b = map(int, input().split())
Fin = (True if a == 0 and b == 0 else False)
printer = []
while not Fin:
    printer.append([min(a, b), max(a, b)])
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        Fin = True
for i in range(len(printer)):
    print(printer[i][0], printer[i][1])


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

using namespace std;

int main(){
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if(s.compare(u) == 0)
        a--;
    else
        b--;
    cout << a << " " << b << endl;
    
}

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

int main(){
  string s;
  cin >> s;
  string t = "YAKI";
  
  bool flag = 1;
  if (s.size() < 4) cout << "No" << endl;
  else{
    for(int i = 0; i < 4; i++){
      if(s.at(i) != t.at(i)) flag = 0;
    }
         if(flag == 1) cout << "Yes" << endl;
         else cout << "No" << endl;
  }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j].first << " " << x[i][j].second << ' ';
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int dy[] = {1,0,-1,0};
int dx[] = {0,1,0,-1};

int h,w,k;
vector<string> s;
vector<vector<bool>> v(334, vector<bool>(334,false));
vector<vector<int>> ans(334, vector<int>(334, -1));

void dfs(const vector<vector<P>> &g, int y, int x, int dl, int rl, int num) {
    if (y < 0 || y >= dl || x < 0 || x >= rl) return;
    if (v[y][x]) return;
    v[y][x] = true;
    ans[y][x] = num;
    rep(i,4) {
        int ny = y+dy[i]; int nx = x+dx[i];
        dfs(g,ny,nx,dl,rl,num);
    }
    return;
}

int main(int argc, char const *argv[]) {
    cin>>h>>w>>k;
    s.resize(h);
    rep(i,h) cin>>s[i];

    vector<vector<P>> g(h, vector<P>(w, P(9,9)));
    vector<bool> a(w);
    rep(j,w) {
        bool ok = true;
        rep(i,h) {
            if (s[i][j] == '#') ok = false;
        }
        a[j] = ok;
    }

    int r = w;
    for (int j = w-1; j >= 0; --j) {
        int lim = h;
        bool flag = false;
        for (int i = h-1; i >= 0; --i) {
            if (s[i][j] == '#') {
                flag = true;
                g[i][j].first = lim;
                g[i][j].second = r;
                lim = i;
            }
        }
        if (flag) r = j;
    }

    rep(j,w) {
        rep(i,h) {
            if (s[i][j] == '#') {
                int dl = g[i][j].first;
                int rl = g[i][j].second;
                /*
                cout << i << ' ' << j << endl;
                cout << dl << ' ' << rl << endl;
                cout << "--------------------------" << endl;
                */
                dfs(g,i,j,dl,rl,k--);
            }
        }
    }

    print(ans,h,w);
    
    return 0;
}

Measured memory_bytes: 2944
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int dp[110][100010];


signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, W; cin >> N >> W;
    int w[110], v[110];
    rep(i, N) cin >> w[i] >> v[i];
    rep(i, N) {
        rep(j, W + 1) {
            dp[i + 1][j] = dp[i][j];
            if (j - w[i] >= 0) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
        }
    }
    cout << dp[N][W] << endl;

    return 0;
}


Measured memory_bytes: 79360
#include<stdio.h>

int main()
{
  int n;
  int a[100001];
  int i;
  int s=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]%2==1) s++;
  }
  if(s%2==0){
    printf("YES");
  }
  else{
    printf("NO");
  }
  return 0;
}


Measured memory_bytes: 2124
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;


Node root;


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = 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(Node u){

  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}

void preorder(Node u){

  if(u != NIL){

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

int main(){
  int i,m,x;
  char com[20];
  
  scanf("%d",&m);

  for(i = 0 ; i < m ; i++){
    scanf("%s",com);
    if(com[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    }

    else if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }

  }

  return 0;
}

Measured memory_bytes: 24040
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef pair<int, pii> pip;
 
 
 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;

vector<vector<int> > ans;


void calc(int n, vi v){
	if(n == 0){
		ans.pb(v);
		return;
	}
	for(int i = 1; i <= n; i++){
		if(v.size() == 0 || v.back() >= i){
			v.pb(i);
			calc(n-i, v);
			v.pop_back();
		}
	}
}

int main(){
	int n;
	while(cin >> n && n){
		ans.clear();
		vi v;
		calc(n, v);
		sort(all(ans));
		reverse(all(ans));
		for(int i = 0; i < ans.size(); i++){
			for(int j = 0; j  <ans[i].size(); j++){
				if(j != 0){
					cout<<" ";
				}
				cout<<ans[i][j];
			}
			cout<<endl;
		}
	}
}

Measured memory_bytes: 1796
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

const int INF = 1001001001;
int n;
vector<int> to[1005];

vector<int> bfs(int sv) {
    vector<int> dist(n,INF), pre(n,-1);
    queue<int> q;
    dist[sv] = 0;
    q.push(sv);
    while (!q.empty()) {
        int v = q.front(); q.pop();
        for (int u : to[v]) {
            if(dist[u] != INF) continue;
            pre[u] = v;
            dist[u] = dist[v] + 1;
            q.push(u);
        }
    }

    pair<int, int> best(INF, -1);
    rep(v,n) {
        if (v == sv) continue;
        for (int u : to[v]) {
            if (u == sv) {
                best = min(best, make_pair(dist[v],v));
            }
        }
    }
    if(best.first == INF) return vector<int>(n+1);
    int v = best.second;
    vector<int> res;
    while(v != -1){
        res.push_back(v);
        v = pre[v];
    }
    return res;
}

int main(){
    int m;
    cin >> n >> m;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
    }

    vector<int> ans(n+1);
    rep(s, n){
       auto now =  bfs(s);
       if(now.size() < ans.size()) ans = now;
    }
    if(ans.size() == n + 1){
        cout << -1 << endl;
        return 0;
    }
    cout << ans.size() << endl;
    for (int v: ans){
        cout << v+1 << endl;
    }
    
}

Measured memory_bytes: 3648
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)

let list_of_string s = range 0 (String.length s) |> List.map (fun i -> s.[i])

let lowers = list_of_string "abcdefghijklmnopqrstuvwxyz"

let () =
  let s = read_line () |> list_of_string in
  match List.filter (fun c -> List.filter ((==) c) s = []) lowers with
    | [] -> printf "None\n"
    | (x::_) -> printf "%c\n" x


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

int main()
{
    int n,i;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    int t[n+1];
    t[0]=0;
    t[1]=abs(a[1]-a[0]);
    for(i=2;i<n;i++)
    {t[i]=min(abs(a[i]-a[i-1])+t[i-1],abs(a[i]-a[i-2])+t[i-2]);
       // cout<<t[i]<<endl;
    }
    cout<<t[n-1]<<endl;
}

Measured memory_bytes: 4304
#include<stdio.h>
char str[100]="CODEFESTIVAL2016",sca[100];
int res;
int main()
{
    scanf("%s",sca);
    for(register int i=0;i<16;i++)
        if(str[i]!=sca[i]) res++;
    printf("%d\n",res);
    return 0;
}

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b, k;
  cin >> a >> b >> k;

  int i = 0;
  while (true)
  {
    a /= 2;
    b += a;
    i++;
    if (i >= k)
    {
      break;
    }
    b /= 2;
    a += b;
    i++;
    if (i >= k)
    {
      break;
    }
  }
  cout << a << " " << b << "\n";
  return 0;
}


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

int main() {
  vector<int> v;
  int tmp;
  for (int i=0; i<3; i++) {
    cin >> tmp;
    v.push_back(tmp);
  }
  sort(v.begin(), v.end());

  for (vector<int>::iterator it=v.begin(); it!=v.end(); ++it) {
    if (it != v.begin()) {
      cout << " ";
    }
    cout << *it;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <cmath>
using namespace std;
#define MAXA 1001
#define MAXB 1001
#define MAXH 1000000001
#define MAXW 405
#define INF 5000
#define MAXN 100001
#define MAXM 10001
#define MAXP 1000001
#define MOD 1000000007
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
int N, M;
int A[MAXM];


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

    int sum = 0;

    for(int i = 0;i < M;i++){
        sum += A[i];
    }



    if(sum <= N){
        printf("%d\n", N - sum);
    }else{
        printf("-1\n");
    }
    return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

const int INF = TEN(9);

int main() {
    int N; cin >> N;
    V<int> A(N, INF);
    rep(i, N-1) {
        int x; cin >> x;
        chmin(A[i], x);
        chmin(A[i+1], x);
    }
    int ans = 0;
    rep(i, N) ans += A[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
from collections import defaultdict, Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""
dicで各要素の数を保持
"""
N = ir()
A = lr()
Q = ir()
counter = Counter(A)
dic = defaultdict(int)
for k, v in counter.items():
    dic[k] = v

total = sum(A)
answer = []
for _ in range(Q):
    b, c = lr()
    num = dic[b]
    total -= num * b
    total += c * num
    dic[b] = 0
    dic[c] += num
    answer.append(total)

print('\n'.join(map(str, answer)))


Measured memory_bytes: 35704
S=list(str(input()))
a=[]
b=[]

count = 1
direction=S[0]
for i in range(1,len(S)):
  if S[i]== direction:
    count += 1
  else:
    a.append(S[i-1])
    b.append(count)
    direction=S[i]
    count=1
a.append(S[-1])
b.append(count)
m=max(b)+1
dp=[0]*m
for i in range(1,m):
  dp[i] += dp[i-1]+i
ans=0
for i in range(1,len(a)):
  if a[i-1]=='<' and a[i]=='>':
    ans+=dp[max(b[i-1],b[i])] + dp[min(b[i-1],b[i])-1]
  
if a[0]=='>':
  ans+=dp[b[0]]
if a[-1]=='<':
  ans+=dp[b[-1]]
print(ans)

Measured memory_bytes: 30384
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, m;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> m;

  vector<vector<int>> c(n + 1);
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    c[a].push_back(b);
    c[b].push_back(a);
  }

  bool f = false;
  REP(i, c[1].size()) {
    int d = c[1][i];
    REP(j, c[d].size()) {
      if(c[d][j] == n) f = true;
    }
  }

  cout << (f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 12016
#include<iostream>
using namespace std;
int main(){
  int x,y,h,w,n,size,money=0;
  while(1){
    cin >> n;
    if(n==0){
      break;
    }
    money=0;
    for(int i=0;i<n;i++){
      cin >> x >> y >> h >> w;
      size=x+y+h;

      if(size<=60 && w<=2){
	money+=600;
      }
      else if(size<=80 && w<=5){
	money+=800;
      }
      else if(size<=100 && w<=10){
	money+=1000;
      }
      else if(size<=120 && w<=15){
	money+=1200;
      }
      else if(size<=140 && w<=20){
	money+=1400;
      }
      else if(size<=160 && w<=25){
	money+=1600;
      }
    }
    cout << money << endl;
  }
  return (0);
}

Measured memory_bytes: 1160
#include <cstdio>

int main() {
  int N, M, P;
  while (true) {
    scanf("%d %d %d", &N, &M, &P);
    if (N == 0 && M == 0 && P == 0) break;
    int sum = 0, won_X = 0;
    for (int i=1;i<=N;i++) {
      int X;
      scanf("%d", &X);
      sum += X;
      if (i == M) won_X = X;
    }
    printf("%d\n", (won_X > 0 ? (sum*(100-P)/won_X) : 0));
  }
  return 0;
}

Measured memory_bytes: 2680
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	int N;
	cin >> N;
	N %= 1000;
	if(N==0) cout << 0 << endl;
	else cout << 1000 - N << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<ld,ld>
#define x first
#define y second
#define pb push_back
#define N 100000
#define LOGN 16
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<(a[0]*a[1])/2;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
// #include <stdio.h>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    int p[M];
    vector<string> S(M);
    int i;

    vector<int> AC(N, 0);
    vector<int> WA(N, 0);
  
    
    for (i = 0; i < M; i++){
        cin >> p[i];
        cin >> S[i];
    }

    // cout << "@" << p[M-2] << " " << S[M-2] << endl;

    for (i = 0; i < M; i++){
        if (S[i] == "AC"){
            AC[p[i] - 1] = 1;
        }else{
            if (AC[p[i] - 1] == 0){
                WA[p[i] - 1]++;
            }
        }
    }

    int ACnum = 0;
    int WAnum = 0;

    for (i = 0; i < N; i++){
    // cout << AC[i] << " " << WA[i] << " ";
       ACnum += AC[i];

       if (AC[i] == 1){
          WAnum += WA[i];
       }
    }
   
   cout << ACnum << " " << WAnum << endl;


    return 0;
}

Measured memory_bytes: 6912
while True:
    n1=input()
    if n1=="0":
        break
    n2=input()
    n3=input()
    l1=len(n1)
    l2=len(n2)
    l3=len(n3)

    if n1=="0":
        break
    else:
        a1=n1.count("A",1)
        b1=n1.count("B",1)
        if n2[:1]=="A":
            a1+=1
        if n2[:1]=="B":
            b1+=1
        print(a1,b1)
        
        a2=n2.count("A",1)
        b2=n2.count("B",1)
        if n3[:1]=="A":
            a2+=1
        if n3[:1]=="B":
            b2+=1
        print(a2,b2)
        
        a3=n3.count("A",1)
        b3=n3.count("B",1)
        if a3>b3:
            a3+=1
        if a3<b3:
            b3+=1
        print(a3,b3)
        


Measured memory_bytes: 5556
S=input()
Q=int(input())
sousa=[list(map(str,input().split())) for i in range(Q)]
counter=0
up=''
down=''
for i in sousa:
    if i[0]=='1':
#         S=S[::-1]
        counter+=1
    if i[0]=='2':
        if counter%2==0:
            if i[1]=='1':
                up=i[2]+up
            if i[1]=='2':
                down=down+i[2]
        else:
            if i[1]=='1':
                down=down+i[2]
            if i[1]=='2':
                up=i[2]+up   
                
S=up+S+down
if counter%2==1:
    S=S[::-1]

print(S)

Measured memory_bytes: 41464
N, M = map(int, input().split())
food = [1 for i in range(M + 1)]
food[0] = 0
for i in range(N):
    k, *a = map(int, input().split())
    for j in range(1, M+1):
        if j not in a:
            food[j] = 0
# print(food)
print(sum(food))


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  VECINT CS(9);
  REP(i,9) cin>>CS[i];
  int max_a1 = min(CS[0],CS[1]);
  max_a1 = min(max_a1,CS[2]);
  REP(a1,max_a1+1) {
    int b1 = CS[0]-a1;
    int b2 = CS[1]-a1;
    int b3 = CS[2]-a1;
    int a2 = CS[3]-b1;
    int a3 = CS[6]-b1;
    if (CS[4]==a2+b2 && CS[5]==a2+b3 && CS[7]==a3+b2 && CS[8]==a3+b3) {
      OUT("Yes");
      return 0;
    }
  }
  OUT("No");

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
const int maxn=100+10;
const int INF=1<<21;
int n;
int cost[maxn][maxn];
int mincost[maxn];
int vis[maxn];
void prim(int s)
{
    fill(mincost,mincost+n,INF);
    memset(vis,0,sizeof(vis));
    mincost[s]=0;
    int res=0;
    while(true)
    {
        int v=-1;
        for(int u=0; u<n; u++)
        {
            if(!vis[u]&&(v==-1||mincost[u]<mincost[v])) v=u;
        }
        if(v==-1) break;
        vis[v]=1;
        res+=mincost[v];
        for(int i=0; i<n; i++)
        {
            if(cost[v][i]!=-1)   mincost[i]=min(mincost[i],cost[v][i]);
        }

    }
    printf("%d\n",res);




}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            scanf("%d",&cost[i][j]);
        }
    }
    prim(0);

    return 0;
}

Measured memory_bytes: 3244
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var d = new Dictionary<string, int>();
        var q = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < q; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var c = int.Parse(line[0]);
            var c2 = line[1];
            if (c == 0)
            {
                var c3 = int.Parse(line[2]);
                d[c2] = c3;
            }
            else if (c == 1) Console.WriteLine(d.ContainsKey(c2) ? d[c2] : 0);
            else if (d.ContainsKey(c2)) d.Remove(c2);
        }
    }
}



Measured memory_bytes: 35512
n = int(input())
flag = False
limit = 1000000000000000000
a = [int(item) for item in input().split()]
ans = 1
for i in a:
    if(i == 0):
        flag = True
        break
for i in a:
    ans = ans*i
    if(ans > limit):
        break
if(flag):
    print(0)
elif(ans > limit):
    print(-1)
else:
    print(ans)

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

typedef long long ll;

const int MOD = 1000000007;

int main() {
  int n, m;
  ll x=0, y=0, tmp;
  cin >> n >> m;
  for (int i=1; i<=n; i++) {
    scanf("%lld", &tmp);
    x += tmp * (2*i - n - 1) % MOD;
    x %= MOD;
  }
  for (int i=1; i<=m; i++) {
    scanf("%lld", &tmp);
    y += tmp * (2*i - m - 1) % MOD;
    y %= MOD;
  }

  cout << x * y % MOD << endl;
  return 0;
}


Measured memory_bytes: 256
#0:中央 1:南 2:東 3:西 4:北 5:裏側
class Dice():
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.order = "NNNNWNNNWNNNENNNENNNWNNN"

    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5

    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == "E":
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == "N":
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == "S":
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == "W":
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
    
    def query(self,top_num,front_num):
        self.save_data =[i for i in range(6)]

        for i in range(len(self.number)):
            self.save_data[i] = self.number[i]

        ret = -1
        
        for i in range(len(self.order)):
            self.roll(self.order[i])
            if self.number[0] == top_num and self.number[1] == front_num:
                ret = self.number[2]
                break

        for i in range(len(self.number)):
            self.number[i] = self.save_data[i]
        
        return ret
    def get_Top(self):
        return self.number[0]
    
    def equals(self,another):
        ret = False
        for i in range(len(self.order)):
            self.roll(self.order[i])
            FLG = True
            for k in range(6):
                if self.number[k] != another.number[k]:
                    FLG =False
                    break
            if FLG :
                return True
        return ret
diceA = Dice()
diceB = Dice()
table = list(map(int,input().split()))
diceA.setNumber(table[0],table[1],table[2],table[3],table[4],table[5])
table = list(map(int,input().split()))
diceB.setNumber(table[0],table[1],table[2],table[3],table[4],table[5])

if diceA.equals(diceB):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5624
n = int(input())
a = input()
b = input()
c = input()
ans = 0
for i in range(n):
    if a[i]==b[i]==c[i]:
        continue
    elif a[i]!=b[i] and b[i]!=c[i] and c[i]!=a[i]:
        ans += 2
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3064
x = input().split()
N = int(x[0])
K = int(x[1])

p = input().split()
p = [int(l) for l in p]

L = [p[i]*(p[i]+1)/(2*p[i]) for i in range(N)]

S = [0]
x = 0
for i in range(N):
    x += L[i]
    S.append(x)

E = []
if K > 1:
    for i in range(N-K+1):
        E.append(S[i+K]-S[i])
    print(max(E))
else:
    print(max(L))

Measured memory_bytes: 28228
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 15 00:43:39 2020

@author: liang
"""

N = int(input())
H = [int(x) for x in input().split()]

ans = 0
for i in range(max(H)):
    count = 0
    flag = False
    for j in range(N):
        if i < H[j]:
            if flag == False:
                count += 1
            flag = True
        else:
            flag = False
    ans += count
print(ans)

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
int main(){
 
    int N;
    cin>>N;
    if(N>=3){
    vector<char>S(N);
    for(int i=0;i<N;i++)
    {cin>>S[i];}
    
    
    
    long long numR=0;
    long long numG=0;
    long long numB=0;
    for(int i=0;i<N;i++)
    {
        if(S[i]=='R'){numR++;}
        if(S[i]=='G'){numG++;}
        if(S[i]=='B'){numB++;}
       
    }
  
    
    long long sum=0;sum=numR*numG*numB;
    long long dame=0;
    for(int i=1;i*2+1<=N;i++)
        
    {for(int j=1;j<=N-2*i;j++)
    {vector<char>rev={S[j-1],S[j+i-1],S[j+2*i-1]};
        sort(rev.begin(),rev.end());
        vector<char>sam={'R','G','B'};
         sort(sam.begin(),sam.end());
        if(rev==sam){dame++;}
    }
        
        
        }
    
    
        cout<<sum-dame<<endl;}
    else{cout<<0<<endl;}
    
    }

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
  int k;
  int a,b;
  
  cin >> k;
  cin >> a >> b;
  
  int i = 1;
  while((i*k)<a)
  {
    i++;
  }
  if((i*k)<=b)
    printf("OK");
  else
    printf("NG");
}


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

void strInit(char str[]);//str[]を0で初期化
void extIntStr(char str[],int data[]);//str[]から数値(int)を抽出しdata[]に順次格納
void incsort(int data[],int len);//data[]を昇順ソート
void decsort(int data[],int len);//data[]を降順ソート
void printIntArray(int data[],int len);//data[]をprint
int* inputArray(int n);//文字列を受け取り数値を抽出、n個の数値(int)を格納した配列のポインタをreturn
int* cpyArray(int data[],int len);//配列(int)を複製した配列のポインタをreturn

//don't forget free(data);

int main(){
    int n;
    scanf("%d ",&n);
    int *data;
    int max=0;
    int count=0;
    data = inputArray(n);
    for(int i=0;i<n-1;i++){
        if(data[i]>=data[i+1])count++;
        if(max<count)max=count;
        if(data[i]<data[i+1])count=0;
    }
    printf("%d",max);
}

//temp##############################################

void strInit(char str[]){
    int len=strlen(str);
    for(int i=0;i<len;i++){
        str[i]=0;
    }
}

void extIntStr(char str[],int data[]){
    int length=strlen(str);
    str[length-1]=' ';
    char buff[12];
    int j,index;
    index=j=0;
    for(int i=0;i<length;i++){
        if(str[i]!=' '){
            buff[j++]=str[i];
        }else{
            data[index++]=atoi(buff);
            strInit(buff);
            j=0;
        }
    }
}

void incsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]>data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void decsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]<data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

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

int* inputArray(int n){
    int *data;
    data=(int*)malloc(sizeof(int)*n);
    char *get;
    get=(char*)malloc(sizeof(char)*11*n+1);
    fgets(get,11*n+1,stdin);
    extIntStr(get,data);
    free(get);
    return data;
}

int* cpyArray(int data[],int len){
    int *cp;
    cp=(int*)malloc(sizeof(int)*len);
    for(int i=0;i<len;i++){
        cp[i]=data[i];
    }
    return cp;
}

//temp##############################################


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

int f(int n){
	int sum = 0;
	while(n>0){
		sum += n%10;
		n /= 10;
	}
	return sum;
}

int main(){
	int n;
	cin >> n;
	int ans = 1e9;
	for(int a = 1; a < n;++a){
		int b = n - a;
		ans = min(ans,f(a)+f(b));
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	int n;cin>>n;
	vector<double> v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	double ans=v[0];
	for(int i=1;i<n;i++){
		ans=(ans+v[i])/2;
	}
	cout << setprecision(15) <<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=2e5+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,k,a[N],b[N],l[N],r[N],st[N],top=0;
ll s[N],f[N];
int tr[N<<2],tag[N<<2];
#define ls (o<<1)
#define rs (o<<1|1)
void modify(int o,int v) {
    tr[o]=tag[o]=v;
}
void down(int o) {
    if(!tag[o]) return;
    modify(ls,tag[o]);modify(rs,tag[o]);tag[o]=0;
}
void update(int o,int l,int r,int L,int R,int v) {
    if(L>R) return;
    if(L<=l&&r<=R) return modify(o,v);
    down(o);
    int mid=(l+r)>>1;
    if(L<=mid) update(ls,l,mid,L,R,v);
    if(R>mid) update(rs,mid+1,r,L,R,v);
}
int query(int o,int l,int r,int p) {
    if(l==r) return tr[o];
    down(o);
    int mid=(l+r)>>1;
    if(p<=mid) return query(ls,l,mid,p);
    return query(rs,mid+1,r,p);
}
ll query(int x) {
    int p=query(1,1,top,x);
    if(!p) return 0;
    return f[p]+(st[l[p]]-st[x]+k)%k;
}
int main() {
    cin>>n>>k;
    for(int i=1;i<=n;i++) {
        a[i]=gi();b[i]=gi();s[i]=s[i-1]+a[i];
        if(b[i]==2) l[i]=0,r[i]=k-1;
        else {
            l[i]=(-2ll*s[i-1]%k+k)%k,r[i]=(-2ll*s[i]%k+k)%k;
            if(2ll*a[i]>k) return puts("-1"),0;
        }
        st[++top]=l[i];st[++top]=r[i];
    }
    sort(st+1,st+top+1);top=unique(st+1,st+top+1)-st-1;
    for(int i=1;i<=n;i++) {
        l[i]=lower_bound(st+1,st+top+1,l[i])-st;
        r[i]=lower_bound(st+1,st+top+1,r[i])-st;
    }
    for(int i=n;i;i--) {
        f[i]=query(l[i]);
        if(l[i]>r[i]) update(1,1,top,r[i]+1,l[i]-1,i);
        else update(1,1,top,1,l[i]-1,i),update(1,1,top,r[i]+1,top,i);
    }
    ll ans=Inf;
    for(int i=1;i<=top;i++) ans=min(ans,query(i));
    printf("%lld\n",ans+2ll*s[n]);
    return 0;
}


Measured memory_bytes: 11904
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 25 18:20:35 2020
"""

import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
N, K = map(int,input().split())
#A = np.array(list(map(int,input().split())))
A = list(map(int,input().split()))

dp = [True for i in range(K + A[-1] + 1)]
for i in range(K):
    if dp[i]:
        for a in A:
            dp[i + a] = False

#    print(i, dp[i],A+i,dp[A+i])
#print(dp)

if dp[K]:
    ans = 'Second'
else:
    ans = 'First'
print(ans)

Measured memory_bytes: 14280
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
double simulate(const int N, const vector<vector<int>> &G, const int T) {
  vector<double> P(N, 0);
  for (int i = N - 2; i >= 0; i--) {
    double sum = 0.0;
    double mx = 0.0;
    int d = G[i].size();
    for (int j : G[i]) {
      sum += P[j];
      mx = max(mx, P[j]);
    }
    if (i == T) {
      if (d > 1) {
        P[i] = (sum - mx) / (d - 1) + 1;
      } else {
        P[i] = sum + 1;
      }
    } else {
      P[i] = sum / d + 1;
    }
  }
  return P[0];
}
signed main() {
  int N, M; cin >> N >> M;
  vector<vector<int>> G(N);
  REP(i,M) {
    int s, t; cin >> s >> t;
    s--; t--;
    G[s].push_back(t);
  }
  double mn = 1e18;
  REP(i,N-1) {
    mn = min(mn, simulate(N, G, i));
  }
  cout.setf(ios::fixed); cout.precision(10);
  cout << mn << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int k=1;
int n,a[10005];
int main(){
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        if(a[i+1]>a[i]) k++;
        
    }
    cout<<k;
    
    
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] colors = new int[9];
        
        while (n-- > 0) {
            int rate = sc.nextInt();
            int colorNumber = getColor(rate);
            colors[colorNumber]++;
        }
        
        int min = 0;
        int max = 0;
        for (int i = 0; i < 8; i++) {
            if (colors[i] > 0) min++;
        }
        
        max = min + colors[8];
        
        if (min == 0) {
            min = 1;
        }
        
        System.out.println(min + " " + max);
    }
    
    public static int getColor(int rate) {
        if (rate < 400) {
            return 0;
        } else if (rate < 800) {
            return 1;
        } else if (rate < 1200) {
            return 2;
        } else if (rate < 1600) {
            return 3;
        } else if (rate < 2000) {
            return 4;
        } else if (rate < 2400) {
            return 5;
        } else if (rate < 2800) {
            return 6;
        } else if (rate < 3200) {
            return 7;
        }
        return 8;
    }
}


Measured memory_bytes: 22736
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct tree{
    size_t n,r,md;
    vector<vector<int>> e;
    vector<int> pa,d;
    explicit tree(int n_){
        n=n_;
        e.resize(n);
    }
    void add(int a,int b){
        e[a].emplace_back(b);
        e[b].emplace_back(a);
    }
    int r_dfs(int i,vector<int>&X,int p=-1,int D=0){
        pa[i]=p;d[i]=D;md=max(md,(size_t)D);++D;
        for(auto j:e[i]) if(j!=p) X[i]^=r_dfs(j,X,i,D);
        return X[i]+1;
    }
    int r_i(int r_,vector<int>&X){
        pa.resize(n);d.resize(n);r=r_;md=0;
        return r_dfs(r,X);
    }
};

class DGameOnTree {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,x,y;
        in>>n;
        tree t(n);
        fr(i,n-1){
            in>>x>>y;
            --x,--y;
            t.add(x,y);
        }
        vector<int> X(n);
        t.r_i(0,X);
        out<<(X[0]?"Alice":"Bob")<<endl;
    }
};

int main() {
    DGameOnTree solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
auto rd=read<int>;
const int N=3e5+5;
int n, l, x[N], t[N];
bool less[N], more[N];
int main() {
	long long ans=0;
	n=rd(), l=rd()*2;
	for(int i=1; i<=n; ++i) x[i]=rd()*2;
	for(int i=1; i<=n; ++i) {
		t[i]=rd();
		ans+=(t[i]-1)/l+1;
		t[i]%=l;
		if(t[i]==0) t[i]=l;
		less[i]=t[i]<=x[i];
		more[i]=t[i]>l-x[i];
	}
	ans+=more[n];
	for(int i=1, left=0, rtl=0; i<n; ++i) {
		bool use=false;
		if(!more[i]) {
			if(left) --left, --ans, use=true;
			else if(rtl) ++left, --rtl, use=true;
		}
		(use?rtl:left)+=less[i];
	}
	printf("%lld\n", ans*l);
	return 0;
}


Measured memory_bytes: 3200
from operator import mul
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]


def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m


def main():
    X, Y = map(int, input().split())

    if (X + Y) % 3 != 0 or 2*X - Y < 0 or 2*Y - X < 0:
        print(0)
        return
    
    n = (2 * X - Y) // 3
    m = (2 * Y - X) // 3
    
    M = 1000000007
    res = 1
    for i in range(1, n+m+1):
        res = res * i % M
    for i in range(1, n+1):
        res = res * mod_inv(i,M) % M
    for i in range(1, m+1):
        res = res * mod_inv(i,M) % M
    
    print(res)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 67288
N,X = map(int,input().split())
A = list(map(int,input().split()))

ans = sum(A)
costs = A[:]
for i in range(1,N):
    cost = i*X
    if cost >= ans: break
    for j in range(N):
        costs[j] = min(costs[j], A[(j-i)%N])
        cost += costs[j]
    ans = min(ans, cost)

print(ans)

Measured memory_bytes: 42220
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin >> a;
    if(a>=10 && a<=99)
    {
        if(a==19 || a==29 || a==39 || a==49 || a==59 || a==69 || a==79 || a==89 || a==91 || a==99)
        {
            cout << "Yes";
        }
        else
            cout << "No";

        }


    return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int Sum(const string&s){
  int n = (int)s.size();
  int sum = 0;
  for(int i = 0; i < n; ++i)sum += s[i] - '0';
  return sum;
}

int main(){
  int a,b,c; cin >> a >> b >> c;
  cout << set<int>({a,b,c}).size() << endl;
}


Measured memory_bytes: 3524
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

ll dp[100010][101][2];

ll solve(string &k, int d) {
  dp[0][0][0] = 1;
  ll size = k.length();

  int now;
  rep(i, size) rep(j, d) {
    now = k[i] - '0';

    rep(l, 10) {
      if (l < now) {
        dp[i + 1][(l + j) % d][1] += (dp[i][j][0] + dp[i][j][1]) % MOD;
        dp[i + 1][(l + j) % d][1] %= MOD;
      } else if (l == now) {
        dp[i + 1][(l + j) % d][0] += dp[i][j][0];
        dp[i + 1][(l + j) % d][0] %= MOD;
        dp[i + 1][(l + j) % d][1] += dp[i][j][1];
        dp[i + 1][(l + j) % d][1] %= MOD;
      } else {
        // l > now
        dp[i + 1][(l + j) % d][1] += dp[i][j][1];
        dp[i + 1][(l + j) % d][1] %= MOD;
      }
    }
  }

  return (dp[size][0][0] + dp[size][0][1] - 1 + MOD) % MOD;
}

int main() {
  string k;
  int d;

  cin >> k >> d;
  cout << solve(k, d) << endl;
}


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

int main() {
  int N;
  cin >> N;

  // ここにプログラムを追記
  int A=50;
  for (int i=0; i<N; ++i) {
    int x;
    cin >> x;
    int y=0;
    while (x%2 == 0) {
      ++y;
      x /= 2;
    }
    if (y<A) {
      A = y;
    }
  }
  cout << A;
}


Measured memory_bytes: 256
from math import gcd
from collections import defaultdict





MOD = 10**9+7
# mを法とするときのa^n
def modpow(a,n):
    res = 1
    t = a
    while n:
        if n%2:
            res = (res*t)%MOD
        t = (t*t)%MOD
        n //= 2
    return res

def solve(fish):
    def helper(a,b):
        if a == 0 and b == 0:
            return (0, 0, 0)
        elif a == 0:
            return (1, 1, 0)
        elif b == 0:
            return (-1, 0, 1)

        g = gcd(a,b)
        sign = 1 if a*b > 0 else -1
        return (sign, abs(a//g), abs(b//g))

    counter = defaultdict(int)
    for a,b in fish:
        counter[helper(a,b)] += 1

    goods = 1

    for (a,b,c),s in tuple(counter.items()):
        if a == 0:
            continue

        t = counter[(-a,c,b)]
        if t == 0:
            goods *= modpow(2,s)
        elif a > 0:
            goods *= modpow(2,s)+modpow(2,t)-1
        goods %= MOD

    goods += counter[(0,0,0)]-1
    goods %= MOD
    return goods

def naive(fish):
    from itertools import combinations, product
    bad_pair = []
    for i,j in combinations(range(len(fish)), 2):
        if fish[i][0]*fish[j][0] + fish[i][1]*fish[j][1] == 0:
            bad_pair.append((i,j))

    cnt = 0
    for s in product(range(2), repeat=len(fish)):
        cnt += all(s[i]+s[j] < 2 for i,j in bad_pair)
    return cnt-1

if __name__ == '__main__':


    N = int(input())
    fish = tuple(tuple(map(int,input().split())) for _ in range(N))
    print(solve(fish))

    # from random import randint

    # N = 4
    # for _ in range(10000):
    #     fish = [(randint(-5,5),randint(-5,5)) for _ in range(N)]
    #     if solve(fish) != naive(fish):
    #         print(fish)
    #         print(solve(fish))
    #         print(naive(fish))

Measured memory_bytes: 116060