akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
typedef pair<P, int> PP;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	if (n == 0) return 1;
	if (n % 2) return (x * modpow(x * x % mod, n / 2) % mod + mod) % mod;
	return (modpow(x * x % mod, n / 2) + mod) % mod;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

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

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) 			a.begin(),a.end()
#define pb 				push_back
#define vi				vector<int>
#define vl 				vector<long long>
#define MOD 			1000000007
#define FOR(i,a,b) 		for(int i = a; i < b ; i++)
#define forn(i,n) 		for(int i = 0 ; i < n; i++)
#define br 				cout<<endl;
#define testc()			int t;cin>>t;while(t--)
#define ll				long long
#define printv(v)		FOR(i,0,v.size())cout<<v[i]<<' ';br;
#define f				first
#define s 				second
#define fast 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vb 				vector<bool>

using namespace std;




int main()
{
	string s;
	cin>>s;
	int win = 0;
	for(int i = 0 ; i < s.size() ; i++)
	{
		if(s[i] == 'o')
		{
			win++;
		}
	}
	int left = 15 - s.size();
	if(win + left >= 8)
		cout<<"YES";
	else
		cout<<"NO";
	br;
	
}

Measured memory_bytes: 256
#include<stdio.h>
using namespace std;

struct Node {
	int key;
	Node* parent = NULL, *left = NULL, *right = NULL;
};

class Tree {
private:
	Node * root = NULL;
	void In_rec(Node*);
	void Pre_rec(Node*);
public:
	void insert(Node*);
	void In();
	void Pre();
};

void Tree::insert(Node* z)
{
	Node* y{}, *x{ this->root };
	while (x != NULL)
	{
		y = x;
		if (z->key < x->key)
			x = x->left;
		else
			x = x->right;
	}
	z->parent = y;

	if (y == NULL)
		this->root = z;
	else if (z->key < y->key)
		y->left = z;
	else
		y->right = z;
	return;
}

void Tree::In()
{
	In_rec(this->root);
	printf("\n");
	return;
}

void Tree::In_rec(Node* n)
{
	if (n)
	{
		In_rec(n->left);
		printf(" %d", n->key);
		In_rec(n->right);
	}
	return;
}

void Tree::Pre()
{
	Pre_rec(this->root);
	printf("\n");
	return;
}

void Tree::Pre_rec(Node* n)
{
	if (n)
	{
		printf(" %d", n->key);
		Pre_rec(n->left);
		Pre_rec(n->right);
	}
	return;
}

int main()
{
	int n;
	char tmp[16];
	Tree tree;
	scanf("%d", &n);
	Node* node = new Node[n];

	for (int i = 0; i < n; i++)
	{
		scanf("%s", tmp);
		if (tmp[0] == 'i')
		{
			scanf("%d", &node[i].key);
			tree.insert(node + i);
		}
		else
		{
			tree.In();
			tree.Pre();
		}
	}



	delete[] node;
	return 0;
}


Measured memory_bytes: 17908
#include <iostream>
#include <algorithm>
#include <string>
#define M_NUM 1010
using namespace std;




int main() {
	char day[M_NUM];
	int num;

	scanf("%d", &num);

	int d[M_NUM];
	int cnt = 0;
	bool flag[M_NUM] = { false };

	
	for (int i = 0;i < num;i++) {
		scanf("%d", &d[i]);
	}
	
	for (int i = 0;i < num;i++) {
		for (int j = i+1;j < num;j++) {
			if (flag[j]) continue;
			if (d[i] == d[j]) {
				cnt++;
				flag[j] = true;
			}
				
		}
	}

	printf("%d\n", num-cnt);

	return 0;

}



Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	long INF = (long) (1e19);

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long k = sc.nextLong();
		INF = k + 1;
		long[] f = new long[m + 1];
		f[0] = 1;
		char[][] s = new char[n][];
		for (int i = 0; i < n; ++i) {
			s[i] = sc.next().toCharArray();
		}
		for (int j = 0; j < m; ++j) {
			for (int i = 0; i < n; ++i) {
				if (j + s[i].length > m)
					continue;
				f[j + s[i].length] = add(f[j + s[i].length], f[j]);
			}
		}
		if (f[m] < k) {
			System.out.println("-");
			return;
		}
		boolean[][] cap = new boolean[n][m + 1];
		for (int i = 0; i < n; ++i) {
			cap[i][0] = true;
		}
		StringBuilder ans = new StringBuilder();
		long[] g = new long[m + 1];
		g[0] = 1;
		boolean[][] h = new boolean[n][];
		for (int i = 0; i < n; ++i) {
			h[i] = new boolean[s[i].length + 1];
			if (s[i].length <= m) {
				h[i][0] = true;
			}
		}
		for (int T = 0; T < m; ++T) {
			char c = '*';
			long sum = 0;
			boolean flag = false;
			for (int i = 0; i < 26; ++i) {
				c = (char) ('a' + i);
				long tmp = 0;
				for (int u = 0; u < n; ++u) {
					for (int v = 1; v <= Math.min(s[u].length, T + 1); ++v) {
						if (h[u][v - 1] && s[u][v - 1] == c) {
							tmp = add(tmp, mul(g[T + 1 - v], f[m - (T + 1) - (s[u].length - v)]));
						}
					}
				}
				if (add(tmp, sum) >= k) {
					k -= sum;
					flag = true;
					break;
				}
				sum = add(sum, tmp);
			}
			if (!flag)
				throw new AssertionError();
			ans.append(c);
			if (k == 0)
				break;
			for (int i = 0; i < n; ++i) {
				for (int j = h[i].length - 1; j >= 1; --j) {
					h[i][j] = s[i][j - 1] == c && h[i][j - 1];
				}
			}
			for (int i = 0; i < n; ++i) {
				h[i][0] = T + s[i].length + 1 <= m;
			}
			for (int i = 0; i < n; ++i) {
				if (h[i][s[i].length]) {
					g[T + 1] = add(g[T + 1], g[T + 1 - s[i].length]);
				}
			}
		}
		System.out.println(ans);
	}

	long add(long a, long b) {
		if (a + b < 0 || a + b >= INF) {
			return INF;
		} else {
			return a + b;
		}
	}

	long mul(long a, long b) {
		if (a * b < 0 || a * b >= INF) {
			return INF;
		} else {
			return a * b;
		}
	}

	void solve(ArrayList<Integer>[] g, int h, int w) {
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define dbg(x) cerr<<#x<<" : "<<x<<endl

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
clock_t time_p=clock();
void timer(){time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}

template <typename Arg1> ostream& operator << (ostream& out, const vector<Arg1> &a) {out<<"[ ";for(const auto &x:a)out<<x<<" ";return out<<"]";}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,c,k;
    cin>>n>>c>>k;
    vi t(n);
    rep(i,n) cin>>t[i];

    sort(t.begin(), t.end());
    ll ans = 0;
    ll time = 0, cur=0;
    rep(i,n){
        if(time<t[i]){
            ans++;
            time = t[i] + k;
            cur = 1;
        } else {
            if(cur<c){
                cur++;
            } else {
                ans++;
                time=t[i]+k;
                cur=1;
            }
        }
    }
    cout<<ans<<endl;

    timer();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
typedef long long ll;
typedef complex<int> P;

const int NMAX = 1<<16;
vector<int> a;

void ini(){
	for(int i=0; i*i < NMAX ;i++) a.push_back(i*i);
	return;
}

int dfs(int num, int i2, int k){
	if(k==0){
		if(num == 0) return 1;
		return 0;
	}
	int res = 0;
	for(int i=i2; i<a.size() && num>=a[i] ;i++){
		res += dfs(num-a[i], i, k-1);
	}
	return res;
}

bool solve(){
	int n;
	cin>> n;
	if(!n) return false;
	
	cout<< dfs(n,0,4)<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	ini();
	while(solve());
	return 0;
}

 

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,t) for(int i=s;i<t;i++)
const ll mod=1e9+7;
void add(ll &a,ll b)
{
    a+=b;
    if(a>=mod)a-=mod;
}
int num1[66],num2[66];
ll dp[66][2][2][2];int isused[66][2][2][2];
ll dfs(int now,int fi,int l1,int l2)
{
    if(now<0)return 1;
    if(isused[now][fi][l1][l2])return dp[now][fi][l1][l2];
    dp[now][fi][l1][l2]=0,isused[now][fi][l1][l2]=1;
    int k1=l1?num1[now]+1:2,k2=l2?num2[now]+1:2;
    rep(i,0,k1)rep(j,0,k2)
    {
        if(fi&&i!=j)continue;
        if(i<j)continue;
        add(dp[now][fi][l1][l2],dfs(now-1,fi&&!i,l1&&(i==num1[now]),l2&&(j==num2[now])));
    }
    return dp[now][fi][l1][l2];
}
ll solve(ll x1,ll x2)
{
    memset(isused,0,sizeof(isused));memset(num1,0,sizeof(num1));memset(num2,0,sizeof(num2));
    int k1=0,k2=0;
    while(x1)num1[k1++]=x1%2,x1/=2;
    while(x2)num2[k2++]=x2%2,x2/=2;
    return dfs(max(k1,k2)-1,1,1,1);
}
int main()
{
    ll n,m;scanf("%lld%lld",&n,&m);
    printf("%lld\n",(solve(m,m)-solve(m,n-1)+mod)%mod);
}

Measured memory_bytes: 256
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)
INF = 10**10

(N, M) = reads()

edges = [[] for _ in range(N)]

for _ in range(M):
    (L, R, D) = reads()
    (L, R) = (L-1, R-1)
    edges[L].append((R, D))
    edges[R].append((L, -D))

visited = [False] * N
place = [None] * N

def walk(i):
    if visited[i]:
        return (place[i], place[i])
    visited[i] = True
    (m, M) = (INF, -INF)
    for (j, d) in edges[i]:
        if visited[j] and place[j] != place[i] + d:
            # print("v = ", visited)
            # print("p = ", place)
            print("No")
            exit()
        place[j] = place[i] + d
        (x, y) = walk(j)
        (m, M) = (min(m, x), max(M, y))
    return (m, M)

for i in range(N):
    if not visited[i]:
        place[i] = 0
        (m, M) = walk(i)
        if M - m > 10**9:
            # print("(m, M) = ", (m, M))
            print("No")
            exit()

print("Yes")




Measured memory_bytes: 131816
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int N, K;
    cin >> N >> K;
    vi sums(N+1, 0);
    rep(i, N) {
        int a;
        cin >> a;
        sums[i+1] = sums[i] + a;
    }

    vi A;
    rep(l, N) {
        rep(r, l) {
            int t = sums[l+1]-sums[r];
            A.pb(t);
        }
    }
    /*rep(i, A.size()) cout << A[i] << " ";
    cout << endl;*/

    int t = pow(2, 40);
    int res = 0;
    while(t>0) {
        int cnt = 0;
        vi temp;
        rep(i, A.size()) {
            if(A[i]&t) {
                cnt++;
                temp.pb(A[i]);
            }
        }
        //cout << cnt << endl;
        if(cnt>=K) {
            res += t;
            swap(temp, A);
        }
        t>>=1;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 6516
def abs(num)
  num > 0 ? num : -num
end
INF = 1.0 / 0
N = gets.to_i
arr = gets.split.map(&:to_i)
sum = []
sum[0] = arr[0]
for i in 1...N do
  sum[i] = sum[i-1] + arr[i]
end
i = 1
j = 0
k = 2
ans = INF
while i < N - 2
  j += 1 while abs(sum[i] - 2 * sum[j]) > abs(sum[i] - 2 * sum[j+1])
  k += 1 while abs(sum[N-1] + sum[i] - 2 * sum[k]) > abs(sum[N-1] + sum[i] - 2 * sum[k+1])
  pqrs = [sum[j], sum[i]-sum[j], sum[k]-sum[i], sum[N-1]-sum[k]]
  gap = pqrs.max - pqrs.min
  ans = gap if gap < ans
  i += 1
end
puts ans

Measured memory_bytes: 21988
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main() {
	s64 H, W;
	cin >> H >> W;

    u64 Ch, Cw;
    cin >> Ch >> Cw;
    Ch--; Cw--;

    u64 Dh, Dw;
    cin >> Dh >> Dw;
    Dh--; Dw--;

    vector<vector<bool>> HW(H, vector<bool>(W));

    for(s64 i=0; i<H; i++) {
        for(s64 j=0; j<W; j++) {
            char c;
            cin >> c;
            HW[i][j] = (c == '.');
        }
    }
    
    vector<vector<u64>> M(H, vector<u64>(W, UINT64_MAX));
    M[Ch][Cw] = 0;

    deque<pair<u64, u64>> F;
    F.push_back(make_pair(Ch, Cw));

    while(!F.empty()) {
        s64 Fh = F.front().first;
        s64 Fw = F.front().second;
        F.pop_front();

        for(s64 i=-2; i<3; i++) {
            for(s64 j=-2; j<3; j++) {
                s64 h = Fh + i;
                s64 w = Fw + j;

                if(h < 0 || w < 0) continue;
                if(h >= H || w >= W) break;
                if(!HW[h][w]) continue;

                if(abs(i) + abs(j) > 1) { // warp
                    if(M[h][w] > M[Fh][Fw] + 1) {
                        M[h][w] = M[Fh][Fw] + 1;
                        F.push_back(make_pair(h, w));
                    }
                } else { // walk
                    if(M[h][w] > M[Fh][Fw]) {
                        M[h][w] = M[Fh][Fw];
                        F.push_front(make_pair(h, w));
                    }
                }
            }
        }
    }

    if(M[Dh][Dw] == UINT64_MAX) {
        cout << -1 << endl;
    } else {
        cout << M[Dh][Dw] << endl;
    }

    return 0;
}


Measured memory_bytes: 11860
#include<iostream>
#include<stack>
using namespace std;
int main(){

  stack<int> st;
  int num;
  while(cin>>num){
    if(num==0){
      cout<<st.top()<<endl;
      st.pop();
    }else{
      st.push(num);
    }
  }
  return 0;
}

Measured memory_bytes: 1196
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

n = readint()
a = readints()


money = 1000
kabu = 0
for i in range(n-1):
    if a[i]<a[i+1]:
        b = money//a[i]
        kabu += b
        money -= b*a[i]
    else:
        money += kabu*a[i]
        kabu = 0

print(money + kabu*a[-1])




Measured memory_bytes: 61964
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<17;

bool check(LL A,LL B,LL x){
    if(x%2){
        LL a,b;
        a=b=(x+1)/2;
        if(A<=(x+1)/2) a++;
        if(B<=(x+1)/2) b++;
        return A*B>a*b;
    }
    else{
        LL a[2],b[2];
        if(A<=x/2){
            a[0]=x/2+1;
            a[1]=x/2+2;
        }
        else if(A==x/2+1){
            a[0]=x/2;
            a[1]=x/2+2;
        }
        else{
            a[0]=x/2;
            a[1]=x/2+1;
        }
        if(B<=x/2){
            b[1]=x/2+1;
            b[0]=x/2+2;
        }
        else if(B==x/2+1){
            b[1]=x/2;
            b[0]=x/2+2;
        }
        else{
            b[1]=x/2;
            b[0]=x/2+1;
        }
        return A*B>max(a[0]*b[0],a[1]*b[1]);
    }
}


int main(){
    int Q;
    cin >> Q;
    while(Q--){
        LL a,b;
        cin >> a >> b;
        LL l=0LL,r=a+b;
        while(r-l>1){
            LL m=(l+r)/2;
            if(check(a,b,m)) l=m;
            else r=m;

        }
      	cout << l << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main() {
	int a,b,x,y;
	char op;
	for( y =0; y <=100;y++){
	cin>> a >> op >> b ;
    if(op=='+'){
		x=a+b;
		cout<<x<<endl;
	}else if(op=='-'){
		x=a-b;
		cout<<x<<endl;
	}else if(op=='*'){
		x=a*b;
		cout<<x<<endl;
	}else if(op=='/'){
		x=a/b;
		cout<<x<<endl;
	}else if(op=='?'){}}
	return 0;
} 



Measured memory_bytes: 3100
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>


using namespace std;

using ll = long long;

int main(){
    int N;cin >> N;
    vector<int> vec;
    for(int i = 0;i < N;i++){
        int b;cin >> b;
        vec.push_back(b);
    }
    if(vec.front() != 0){
        cout<<-1<<endl;
        return 0;
    }
    int now = vec.back();
    ll ans = 0;
    for(int i = N-2;i >= 0;i--){
       // cout<<i<<endl;
    //    if(i == 0)continue;
        if(now == vec.at(i) || now - 1 == vec.at(i) || now < vec.at(i)){
            if(now <= vec.at(i)){
                ans += now;
            }else{
                ans++;
            }
            now = vec.at(i);
        }else{
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1400
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}
#[allow(unused_imports)]
use input::*;

fn main() {
    let (n, t): (usize, usize);
    input!(n, t);
    let v = input_vector::<usize>();
    let mut ans = 0;
    let mut sub = 0;
    for i in 1..n {
        ans += t;
        if v[i] - v[i - 1] < t {
            sub += v[i - 1] + t - v[i];
        }
    }

    p(ans - sub + t);
}


Measured memory_bytes: 8444
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    l = [int(input()) for _ in range(5)]
    r = INF
    for i in range(5):
        if l[i] % 10 == 0:
            continue
        r = min(r, l[i] % 10)
    if r != INF:
        ans = sum([math.ceil(i / 10) * 10 for i in l]) - 10 + r
    else:
        ans = sum(l)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 12256
#include<iostream>
#include<algorithm>

using namespace std;
int main() {
    int N;
    cin >> N;
    int mi = 1221201201;
    for(int i = 1; i < N; i++) {
        int tmp = 0;
        int a = i;
        int b = N - i;
        while(a != 0) {
            tmp += a % 10;
            a /= 10;
        }
        while(b != 0) {
            tmp += b % 10;
            b /= 10;
        }

        mi = min(tmp,mi);

    }
    cout << mi << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  int w[110]; rep(i, n) cin >> w[i];
  int ans = 1e+6;
  rep(i, n) {
      int s1 = 0, s2 = 0;
      rep(j, i + 1) s1 += w[j];
      Rep(j, i + 1, n) s2 += w[j];
      ans = min(ans, abs(s1 - s2));
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)
#define ERROR return puts("Impossible"), 0

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T>
inline void chkmax(T&a, T b) { a = a > b ? a : b; }

int c[110];
int mx;

int main() {
#ifdef LOCAL
	FILE("");
#endif

	int n = ri;
	for(int i = 1; i <= n; i++) {
		int x = ri;
		++c[x];
		chkmax(mx, x);
	}

	int mi = (mx + 1) >> 1;
	for(int i = mx; i > mi; --i) {
		if(c[i] < 2) ERROR;
		n -= c[i];
	}
	if(c[mi] != 1 + (mx & 1) || n != c[mi]) ERROR;
	puts("Possible");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string str;
cin>>str;

int q;
cin>>q;
vector<pair<int,pair<int,char> > > ans;
for(int i=0;i<q;i++)
{
    int x;
    cin>>x;
    if(x==1)
    {
        ans.pb({1,{1,1}});
    }
    else
    {
    int u;
    char v;
    cin>>u>>v;
    ans.pb({2,{u,v}});
    }
}
string agee="";
string peeche="";
int r=0;
for(int i=q-1;i>=0;i--)
{
    int x=ans[i].ff;
    if(x==1)
    {
        r+=1;
        r%=2;
        continue;
    }
    else
    {int x=ans[i].ss.ff;
    char ch=ans[i].ss.ss;
        if(r==0)
        {
            if(x==1)
            {
                agee+=ch;
            }
            else
            {
            string res="";
            res+=ch;
            res+=peeche;
            peeche=res;
            }
        }
        else
        {
            if(x==1)
            {
                 string res="";
            res+=ch;
            res+=peeche;
            peeche=res;
            }
            else
            {
                agee+=ch;
            }
        }

    }
}
if(r)
{
    reverse(str.begin(),str.end());
}
string res=agee;
res+=str;
res+=peeche;
str=res;
cout<<str<<endl;
    return 0;
}


Measured memory_bytes: 8512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    char a[n+1][n+1];
    char b[m+1][m+1];
    getchar();
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)
        cin>>a[i][j];
    }
     for(int i=0;i<m;i++){
        for(int j=0;j<m;j++)
        cin>>b[i][j];
    }
     /* for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)
        cout<<a[i][j];
        cout<<endl;
    }
     for(int i=0;i<m;i++){
        for(int j=0;j<m;j++)
        cout<<b[i][j];
            cout<<endl;
    }*/
    int flag=0;
    for(int i=0;i<n-m+1;i++){
    for(int j=0;j<n-m+1;j++){
        flag=0;
        for(int s=0,k=i;s<m;s++,k++){
            for(int t=0,d=j;t<m;t++,d++){
                if(b[s][t]!=a[k][d]){
                    flag=1;
                    break;
                }
            }
            if(flag==1){
                break;
            }
        }
        if(flag==0){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100001

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
LL dup(LL a,LL b){if(a%b==0)return a/b;else return a/b+1;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
int POW(int a,int n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return (int)ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){return *(LL*)a-*(LL*)b;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int rcmp(const void* a,const void* b){return *(LL*)b-*(LL*)a;}

int main(){
  LL N,K,i,min=-1,mid=0,max=LNF/2,ans=0,a;
  scanf("%lld%lld",&N,&K);
  LL A[N],F[N],cos=-K;
  FOR(i,0,N)scanf("%lld",&A[i]);
  FOR(i,0,N)scanf("%lld",&F[i]);
  qsort(A,N,sizeof(LL),lcmp);qsort(F,N,sizeof(LL),rcmp);
  while(max-min>1){
    mid=(max+min)/2,a=0;
    FOR(i,0,N)if(A[i]*F[i]>mid)a+=dup(A[i]*F[i]-mid,F[i]);
    if(a>K)min=mid;else max=mid;
  }

  printf("%lld\n",max);
	return 0;
}


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


using namespace std;

const int INF = 1e9;

int main () {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
  
    string a, b, c; cin >> a >> b >> c;
    queue<char> qa, qb, qc;
    int n = a.size(), m = b.size(), l = c.size();
    for (int i = 0; i < n; ++i)
        qa.push(a[i]);
    for (int i = 0; i < m; ++i)
        qb.push(b[i]);
    for (int i = 0; i < l; ++i)
        qc.push(c[i]);
    
    bool aa = true, bb = false, cc = false;
    char curr = 'a';
    while (true) {
        if (aa) {
            if (qa.empty()) {
                cout << 'A' << '\n'; return 0;
            }
            curr = qa.front();
            qa.pop();
            if (curr == 'b') {
                aa = false; bb = true;
            }else if(curr == 'c') {
                aa = false; cc = true;
            }
        }else if(bb) {
            if (qb.empty()) {
                cout << 'B' << '\n'; return 0;
            }
            curr = qb.front();
            qb.pop();
            if (curr == 'a') {
                aa = true; bb = false;
            }else if(curr == 'c') {
                cc = true; bb = false;
            }
        }else {
            if (qc.empty()) {
                cout << 'C' << '\n'; return 0;
            }
            curr = qc.front();
            qc.pop();
            if (curr == 'b') {
                bb = true; cc = false;
            }else if(curr == 'a') {
                aa = true; cc = false;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3624
import java.util.*;
 
class Main {
    public static void main(String[] args) {
    	
    	Scanner sc = new Scanner(System.in);
    	DiceCtrl dc = new DiceCtrl();
    	
    	int n = sc.nextInt();
    	for(int i = 0; i < 6; i++) {
    		dc.numList[i] = sc.nextInt();
    	}
    	for(int i = 0; i < n - 1; i++) {
    		for(int j = 0; j < 6; j++) {
    			dc.numList2[j] = sc.nextInt();
    		}
    		dc.diceCheck();
    	}
    	System.out.println(dc.result);
    }
}

class DiceCtrl {
	public int[] numList = new int[6];
	public int[] numList2 = new int[6];
	private int tmp = 0;
	public String result = "Yes";
	
	void ctrlE() {
		tmp = numList[0];
		numList[0] = numList[3];
		numList[3] = numList[5];
		numList[5] = numList[2];
		numList[2] = tmp;
	}
	void ctrlN() {
		tmp = numList[0];
		numList[0] = numList[1];
		numList[1] = numList[5];
		numList[5] = numList[4];
		numList[4] = tmp;
	}
	void ctrlS() {
		tmp = numList[0];
		numList[0] = numList[4];
		numList[4] = numList[5];
		numList[5] = numList[1];
		numList[1] = tmp;
	}
	void ctrlW() {
		tmp = numList[0];
		numList[0] = numList[2];
		numList[2] = numList[5];
		numList[5] = numList[3];
		numList[3] = tmp;
	}
	void ctrlR() {
		tmp = numList[1];
		numList[1] = numList[2];
		numList[2] = numList[4];
		numList[4] = numList[3];
		numList[3] = tmp;
	}
	void diceCheck() {
		for(int i = 0; i < 4; i++) {
			if(boolCheck()) {
				break;
			}
			ctrlN();
			for(int j = 0; j < 4; j++) {
				if(boolCheck()) {
					break;
				}
				ctrlR();
			}
		}
		for(int i = 0; i < 4; i++) {
			if(boolCheck()) {
				break;
			}
			ctrlW();
			for(int j = 0; j < 4; j++) {
				if(boolCheck()) {
					break;
				}
				ctrlR();
			}
		}
		if(Arrays.equals(numList, numList2)) {
			result = "No";
		}
	}
	boolean boolCheck() {
		if(numList[0] == numList2[0] &&
		   numList[1] == numList2[1] &&
		   numList[2] == numList2[2] &&
		   numList[3] == numList2[3] &&
		   numList[4] == numList2[4] &&
		   numList[5] == numList2[5]) {
			return true;
		} else {
			return false;
		}
	}
}

Measured memory_bytes: 28436
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		
		while(scan.hasNext()){
			int w = scan.nextInt();
			int i = 1;
			StringBuffer sb = new StringBuffer();
			sb.setLength(0);
			while(w != 1){
				if(w % 2 == 1){
					sb.append(i).append(' ');
				}
				w /= 2;
				i = i << 1;
			}
			sb.append(i);
			String s = sb.toString();
			System.out.printf("%s\n", s);
		}
	}
}

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

int main() {
  int ans=1;
  int k,l;
  ll n=0;
  cin >> n >> k;
  l = k;
    while(n/k!=0){
      k = k*l;
      ans++;
    }
  cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << (x) << std::endl
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF() { return std::numeric_limits<T>::max() / 16; }
std::mt19937 mt{std::random_device{}()};
template <typename T, typename A>
std::ostream& operator<<(std::ostream& os, const std::vector<T, A>& v)
{
    os << "[";
    for (const auto& p : v) { os << p << ","; }
    return (os << "]\n");
}
int main()
{
    int N;
    std::cin >> N;
    std::vector<std::vector<int>> g(N);
    for (int i = 0, a, b; i < N - 1; i++) { std::cin >> a >> b, a--, b--, g[a].push_back(b), g[b].push_back(a); }
    using P = std::pair<int, bool>;
    std::queue<P> q;
    q.push({0, false});
    q.push({N - 1, true});
    int B = 1, W = 1;
    std::vector<bool> used(N, false);
    used[0] = used[N - 1] = true;
    while (not q.empty()) {
        const auto p = q.front();
        q.pop();
        const int s = p.first;
        (p.second ? W : B)++;
        for (const int to : g[s]) {
            if (not used[to]) {
                used[to] = true;
                q.push({to, p.second});
            }
        }
    }
    std::cout << (B > W ? "Fennec" : "Snuke") << std::endl;
    return 0;
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int A, B, res;
  rd(A);A += (-1);
  rd(B);B += (-1);
  wt_L(A*B);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// {
//   int A, B, res;
//   rd(A--,B--);
//   wt(A*B);
// }


Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;
#define  F                     first                 
#define  S                     second
#define  endl                  "\n"

const ll   N     =  3e+5+5;
const ll   MAX   =  1e6+5;
const ll   mod   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll n,ans=0,a[N],lcm;

ll fastModInv(ll x){
    ll res=1;
    ll y=mod-2;
    while(y){
        if(y&1)res=(res*x)%mod;
        y>>=1;x=(x*x)%mod;
    }
    return res;
}


int prime[MAX]; 
unordered_map<int, int> max_map; 
  
// Function to return a^n 
int power(int a, int n) 
{ 
    if (n == 0) 
        return 1; 
    int p = power(a, n / 2) % mod; 
    p = (p * p) % mod; 
    if (n & 1) 
        p = (p * a) % mod; 
    return p; 
} 
  
// Function to find the smallest prime factors 
// of numbers upto MAX 
void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (int i = 2; i < MAX; i++) { 
        if (prime[i] == 0) { 
            for (int j = i * 2; j < MAX; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
} 
  
// Function to return the LCM modulo M 
ll lcmModuloM(const ll* ar, ll n) 
{ 
  
    for (int i = 0; i < n; i++) { 
        int num = ar[i]; 
        unordered_map<int, int> temp; 
  
        // Temp stores mapping of prime factor to 
        // its power for the current element 
        while (num > 1) { 
  
            // Factor is the smallest prime factor of num 
            int factor = prime[num]; 
  
            // Increase count of factor in temp 
            temp[factor]++; 
  
            // Reduce num by its prime factor 
            num /= factor; 
        } 
  
        for (auto it : temp) { 
  
            // Store the highest power of every prime 
            // found till now in a new map max_map 
            max_map[it.first] = max(max_map[it.first], it.second); 
        } 
    } 
  
    ll ans = 1; 
  
    for (auto it : max_map) { 
  
        // LCM is product of primes to their highest powers modulo M 
        ans = (ans * power(it.F, it.S)) % mod; 
    } 
  
    return ans; 
}

int main(){
	fastio;
	sieve();
 	cin>>n;
 	for(int i = 0; i < n; i++){
 		cin>>a[i];
 	}
 	lcm = lcmModuloM(a,n);
 	//cout<<lcm<<endl;
 	for(int i = 0; i < n; i++){
 		ans = (ans+lcm*fastModInv(a[i]))%mod;
 	}
 	cout<<ans<<endl;
 }

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)

int a[110];

int main(){
    int N, x; cin >> N >> x;
    int sum = 0, ans = 0;
    rep(i, N){
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a+N);
    int k = 0;
    while(x >= a[k]){
        x = x - a[k];
        k++;
        if(k == N){
            if(x == 0) break;
            else { k--; break;}
        }
    }
    cout << k << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int N, K;
	scanf("%d %d", &N, &K);
	int x[N];
	for (int i = 0; i < N; ++i) scanf("%d", &x[i]);
	int zero = distance(x, lower_bound(x, x + N, 0));
	int flag = x[zero] == 0;
	int min = 300000010;
	if(zero  >= K - flag) min = -1*x[zero + flag - K];
	for (int i = K - 1; i < N && i < zero + K - 1; ++i){
		if(x[i] <= 0) continue;
		if(x[i]*2 - x[i - K + 1] < min) min = x[i]*2 - x[i - K + 1];
	}
	if(zero <= N - K && x[zero + K - 1] < min) min = x[zero + K - 1];
	for (int i = N - K; i >= 0 && i > zero - K + 1 + flag; --i){
		if(x[i] >= 0) continue;
		if(-2*x[i] + x[i + K - 1] < min) min = -2*x[i] + x[i + K - 1];
	}
	printf("%d\n", min);
	return 0;
}

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

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


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int S, W;
  cin >> S >> W;
  if(S>W)
  {
    cout << "safe" << endl;
  }
  else
  {
    cout << "unsafe" << endl;
  }
  return 0;
}


Measured memory_bytes: 3588
// 13/09/2020  @ 17:30:30
// *****************************************************************
// *****************************************************************
#include <bits/stdc++.h>
// *****************************************************************
// *****************************************************************
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
#define fr(i,n) for(llu i=0;i<n;i++)
#define fl(j,a,b) for(llu j=a;j<=b;j++)
#define Pi 3.1415926535897932384626
#define mod 1e9+7
#define MID(a,b) ((a + b) >> 1)
#define MAX(a,b) ((a) > (b) ? (a): (b))
#define MIN(a,b) ((a) < (b) ? (a) :(b))
#define pb push_back
#define mp make_pair
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define printer(a, n) fr(i,n) cout << a[i] << " ";
// *****************************************************************
// *****************************************************************
typedef long long unsigned int llu;
typedef long long int ll;
// *****************************************************************
// *****************************************************************
using namespace std;
// *****************************************************************
// *****************************************************************

                   // Dream it. Wish it. Do it.

                         // tannatsri //

              // Without tact you can learn nothing.

// *****************************************************************
// *****************************************************************
bool rev(ll a, ll b) {
    return a > b;
}
// *****************************************************************
void solution() {
    int x;
     cin >> x;
     if(x) cout << 0;
     else cout << 1;


}
// *****************************************************************
int main() {
    IOS;
    #ifndef ONLINE_JUDGE
        freopen("C:/Users/Mr.Tanishq/Desktop/noc/input.txt", "r", stdin);
        freopen("C:/Users/Mr.Tanishq/Desktop/noc/output.txt", "w", stdout);
        freopen("C:/Users/Mr.Tanishq/Desktop/noc/error.txt", "w", stderr);
    #endif
    // *****************************************************************
    // *****************************************************************
    int t = 1;
    // cin >> t;
    while(t--) {

       solution();
       cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
	char pix[102][102];
	int h, w;
	int i, j;
	
	scanf("%d %d", &h, &w);
	for (i = 0; i < h; i++) {
		scanf("%s", pix[i]);
	}
	
	for (i = 0; i < w + 2; i++) {
		printf("#");
	}
	puts("");
	for (i = 0; i < h; i++) {
		printf("#%s#\n", pix[i]);
	}
	for (i = 0; i < w + 2; i++) {
		printf("#");
	}
	puts("");
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            int r = sc.nextInt();
            if(n == 0 && r == 0) break;
            int[] x = new int[n];
            int[] y = new int[n];
            int p,c;
            for(int i =0 ; i< n; i++){
                x[i] = n-i;
                y[i] = x[i];
            }
            for(int i = 0; i < r; i++){
                p = sc.nextInt();
                c = sc.nextInt();
                for(int j = 0; j<c; j++){
                    x[j] = y[p-1+j];
                }
                for(int j = c; j < p+c-1; j++){
                    x[j] = y[j-c];
                }
                for(int j = 0; j<n; j++){
                    y[j] = x[j];
                }
            }
            System.out.println(x[0]);
        }

        sc.close();
    }
}


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

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  long long N, K, Q, A;
  cin >> N >> K >> Q;
  vector<long long> player(N, 0);
  for(long long i = 0; i < Q; i++) {
    cin >> A;
    player[A - 1]++;
  }

  for(long long i = 0; i < N; i++) {
    if(K - (Q - player[i]) <= 0) {
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3964
/*
 
 * This code is written by Sanskar Agarwal
 
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

#define ll long long
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define VPLL vector<PLL>
#define VPII vector<PII>
#define PQ priority_queue<PLL,VPLL, greater<PLL> > 
#define PQI priority_queue<PII,VPII,greater<PII> >
#define S second
#define F first
#define PB push_back

int n;
double p[3000];
double dp[3000][3000];

double solve(int x,int heads)
{
    if(x==0&&heads!=0)
        return 0;
    if(x==0&&heads==0)
        return dp[x][heads]=1;
    if(dp[x][heads]!=-1)
        return dp[x][heads];

    return dp[x][heads]=(solve(x-1,heads-1)*p[x-1]+solve(x-1,heads)*(1-p[x-1]));
}

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

    cin>>n;
    for(int i=0;i<n;i++) {
        cin>>p[i];
    }
    for(int i=0;i<3000;i++)
        for(int j=0;j<3000;j++)
            dp[i][j]=-1;
    double prob=0;
    for(ll i=(n/2)+1;i<=n;i++) {
        prob+=solve(n,i);
    }
    cout << fixed << setprecision(20) << prob;

    return 0;
}


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

int main() {
  int n, q;
  llong k;
  cin >> n >> k >> q;
  vector<int> win(n);
  rep(i, q) {
    int a;
    cin >> a;
    a--;
    win[a]++;
  }
  rep(i, n) {
    if (k - q + win[i] <= 0)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
import itertools

def main():
    n, _ = map(int, input().split())
    d = [int(s) for s in input().split()]
    p = [i not in d for i in range(10)]

    print(solve(n, p))

def solve(n, p):
    def check(i):
        if i == 0:
            return True
        if not p[i % 10]:
            return False
        return check(i // 10)

    for i in itertools.count(n):
        if check(i):
            return i

main()


Measured memory_bytes: 3060
n = int(input())
ans = 0
def calc(x):
    x -= 1
    if x <= 0:
        return 0
    elif n // x == n % x:
        return x
    return 0

for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0:
        ans += calc(n // i) + calc(i)
print(ans)

Measured memory_bytes: 9448
#include<stdio.h>
#include<string.h>
int main(void)
{
char a[11], b[11], c[11];
int len1, len2, len3;

scanf("%s %s %s", a, b, c);
len1 = strlen(a);
len2 = strlen(b);
len3 = strlen(c);
  if(a[len1 - 1] == b[0] && b[len2 - 1] == c[0]){
    printf("YES\n");
  } else if(a[len1 - 1] != b[0] || b[len2 - 1] != c[0]){
    printf("NO\n");
  }
  return 0;
}


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

int main(){
int N;
int A[210];

cin >> N;

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

int res = 0;

while(true){
  bool flag = false;
  
  for(int i = 0;i<N;i++){
    if(A[i] % 2 != 0){
      flag = true;
    }
  }
  
  if(flag){
    break;
  }
  
  for(int i = 0;i<N;i++){
    A[i] /= 2;
  }
  res++;
}
  cout << res << endl;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if (a < b) cout << "a < b" << endl;
    if (a > b) cout << "a > b" << endl;
    if (a == b) cout << "a == b" << endl;
    return 0;
}


Measured memory_bytes: 3060