akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int w[] = {10, 50, 100, 500};

int main(void){
    bool f = true;
    vi has(4), pp(4);
    for(int p; cin >> p, p;){
        rep(i, 4) cin >> has[i];

        if(!f) cout << endl;
        f = false;

        int sum = 0;
        rep(i, 4) sum += w[i] * has[i];
        sum -= p;

        for(int i = 3; 0 <= i; i--){
            has[i] -= (sum / w[i]);
            sum %= w[i];
        }

        rep(i, 4){
            if(0 < has[i]){
                cout << w[i] << " " << has[i] << endl;
            }
        }
    }

	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll gcd (ll a, ll b){
    if (b==0) return a;
    return gcd(b, a%b);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin>>T;
    rep(i,0,T){
        ll A,B,C,D;
        cin>>A>>B>>C>>D;
        ll g=gcd(B+D,B);
        ll t;
        if(A<B){
            cout <<"No"<<"\n";
            continue;
        }
        if(B>D){
            cout <<"No"<<"\n";
            continue;
        }
        if(A%B>C){
            cout <<"No"<<"\n";
            continue;
        }
        if(B==D){
            cout <<"Yes"<<"\n";
            continue;
        }
        if(A>=-B+C+1){
            t=A%B-(-B+C+1)%B;
            t=(t+B)%B;
        }
        else{
            t=A%(D-B)-(-B+C+1)%(D-B);
            t=(t+D-B)%(D-B);
        }
        if(t-g*(t/g)-B+C+1>=0) cout <<"Yes"<<"\n";
        else cout <<"No"<<"\n";
    }
}

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

using namespace std;

#define f first
#define s second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define MOD 1000000007
#define EPS 1e-9
#define X real()
#define Y imag()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using point = pair<double, double>;
using Vector = complex<double>;

int main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	string s;
	cin >> n >> s;
	for(char& c : s)
		c = (c - 'A' + n) % 26 + 'A';
	cout << s << '\n';
    return 0;
}


Measured memory_bytes: 256
s = input()

l = len(s)

if l%2 ==1: #偶数にする
    s = s[:-1]
else:
    s = s[:-2]



for i in range(l):
    l = len(s)
    lh = int(l/2)
    if s[:lh] == s[lh:]:
        break
    s = s[:-2]
    
print(len(s))


Measured memory_bytes: 8824
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int gcd(int k, int l) {
    if(k%l == 0) {
        return(l);
    } else {
        return(gcd(l, k%l));
    }
}

int main() {
    ll K;
    int a, b, c, gcda;
    ll all = 0;

    cin >> K;

    for(a=1; a<=K; a++) {
        for(b=1; b<=K; b++) {
            for(c=1; c<=K; c++) {
                 gcda = gcd(a,b);
                 all += gcd(c, gcda);
            }
        }
    }

    cout << all;

}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

// {node, cost}
vector<PI> edges[100100];
li n;

bool black[100100];

inline void dfs(li now, li from, li d_from_root) {
    black[now] = (d_from_root % 2 == 0);
    for (auto && tmp : edges[now]) {
        li next = tmp.F;
        li cost = tmp.S;
        if (next == from) continue;
        dfs(next, now, d_from_root + cost);
    }
}

int main() {
    cin >> n;
    rep(i, n - 1) {
        li u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        edges[u].pb({v, w});
        edges[v].pb({u, w});
    }

    black[0] = false;
    dfs(0, -1, 0);

    rin{
        cout << black[i] << endl;
    }

    return 0;
}

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

#ifdef GCC
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#define log(x) cout << (x) << "\n"
#define loop(i, begin, end)for(__typeof(end) i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define rep(i, n) loop(i, 0, n)

using ll = long long;
using vll = vector<ll>;

int n;
vll a;

ll dp[100001][2];
int main() {
    cin >> n;
    a = vll(n+1, 0);
    rep (i, n) cin >> a[i];

    for (int i=0; i<=n; ++i) {
        dp[i][0]=0, dp[i][1]=0;
    }

    for (int i=n-1; i>=0; --i) {
        for (int inc=0; inc<=1; ++inc) {
            if (i==n-1 and !inc) dp[i][0] = 0;
            else if (inc) dp[i][inc] = max((i!=n-1)?-a[i]-a[i+1]+dp[i+1][0]:a[i], a[i]+dp[i+1][1]);
            else dp[i][inc] = max(dp[i+1][1], 2*a[i]-a[i+1]+dp[i+1][0]);
        }
    }

    log(dp[0][1]);
}


Measured memory_bytes: 2560
//https://atcoder.jp/contests/abc139/tasks/abc139_b
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <numeric>
#include <functional>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <complex>

using namespace std;

#define REP(i,m,n) for(int i=m;i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define ALL(x) (x).begin(),(x).end()

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

int main(){

	int n, m, sum = 1;
	cin >> n >> m;

	rep(i,20){
		if(sum < m) {
			sum += n-1;
		} else {
			cout << i << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
main()
{
  int n;
  scanf("%d", &n);
  int a[n];
  for(int i=0; i<n; i++)
    scanf("%d", &a[i]);
  
  int k=1, c=0;
  for(int i=0; i<n; i++){
    if(a[i] == k)
      k++;
    else
      c++;
  }
  if(k==1) printf("-1");
  else printf("%d", c);
  return 0;
}

Measured memory_bytes: 896
/* ex3_4
   seira3 */

#include<stdio.h>
#include<stdlib.h>

int main(void){
    int N; //変数宣言
    scanf("%d",&N); //Nに入力
    int count=0; //カウンターを宣言
    for(int i=1;i<10;i++){ //iで割り切れてかつ商が1から9におさまるならcountに1を足す
        if(0<N/i&&10>N/i&&N%i==0){
            count++;
        }
    }
    if(count==0){ //countに一回も足されなかった時はNo
        printf("%s\n","No");
    }
    else{ //それ以外はYes
        printf("%s\n","Yes");
    }
    return 0;
}

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

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

	for (int i = 0; i < n; i++) {
		for (int j = l[i]; j <= r[i]; j++) {
			count++;
		}
	}

	cout << count << endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    ll N;
    ll M;
    cin >> N >> M;
    bool flag[N];
    int cou[N];
    rep(i, N){
        flag[i] = false;
    }
    ll a;
    string s;
    rep(i, M){
        cin >> a >> s;
        a--;
        if (!flag[a]) {
            if (s == "AC") {
                flag[a] = true;
            } else {
                cou[a]++;
            }
        }
    }
    int ans = 0;
    rep(i, N){
        if (flag[i]) ans++;
    }
    cout << ans << " ";
    ans = 0;
    rep(i, N){
        if (flag[i]) {
            ans += cou[i];
        }
    }
    cout << ans << endl;
}


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

int digits(ll n) {
    int cnt = 0;
    while (n) {
        cnt++;
        n /= 10;
    }
    return cnt;
}

int main() {
    ll N;
    cin >> N;
    ll ans = (1 << 20);
    for (ll i = 1; i * i <= N; i++) {
        if (N % i != 0) continue;
        ans = min(ans, (ll)max(digits(i), digits(N / i)));
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
const ll mod = 1e9 + 7;
ll perform(int n){
  vector<ll> coords;
  for(int i=0;i<n;i++){
    ll x; cin >> x; coords.push_back(x);
  }
  ll ans = 0;
  for(int i=0;i<n-1;i++){
    ll r = coords[i+1]-coords[i];
    r = r * (i+1) * (n-i-1);
    ans = ans + r;
    ans %= mod;
  }
  return ans;
}

int main(){
  int n,m; cin >> n >> m;
  ll ans = perform(n) * perform(m) % mod;
  cout << (ans + mod) % mod << "\n";
}


Measured memory_bytes: 2020
#include <bits/stdc++.h>
using namespace std;
int n,a[110],ans=1;
int main()
{
    cin>>n;
	for (int i=1;i<=n;i++)
	  cin>>a[i];
	for (int i=2;i<=n;i++)
	{
		bool fla=false;
	    for (int j=1;j<i;j++)
		  if (a[j]>a[i]) {fla=true;break;}
		if (!fla) ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
a,b,h,m = map(int,input().split())
import math
t =abs(30*h + 0.5*m - 6*m)
angle = min(t, 360-t)

l = a**2 + b** 2 -2*a*b*math.cos(angle*3.14159265358979323846/180)
print(l**0.5)


Measured memory_bytes: 9496
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int nums[N], dp[N];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n,k;
	cin >> n >> k;
	for(int i = 0; i < n; ++i){
		cin>>nums[i];
	}
	dp[0] = 0;
	for(int i = 1; i < n; ++i){
		dp[i] = INT_MAX;
		for(int j = i-1; j >= 0 && j >= i-k; --j)
			dp[i] = min(dp[i], dp[j] + abs(nums[i] - nums[j]));
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
x, y = map(int, input().split())
t = (4*x-y)/2
k = (y-2*x)/2
a = t.is_integer()
b = k.is_integer()
if a == True and b == True and t >= 0 and k >= 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
n, x = map(int, input().split())
L = [[1, 1]]
for i in range(1, n+1):
    L.append([L[i-1][0] * 2 + 3, L[i-1][1] * 2 + 1])
def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= 1 + L[n-1][0]:
        return f(n-1, x-1)
    else:
        return L[n-1][1] + 1 + f(n-1, x-2-L[n-1][0])
print(f(n, x))


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

int main() {

    int h1, h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    cout << (h2 * 60 + m2) - (h1 * 60 + m1) - k << endl;

    return 0;
}


Measured memory_bytes: 3624
S = input()

WALL = 0
ACTIVATE = 1
CHANCE, BINGO = 2, 3

nBC = 0
score = 0
state = WALL
for c in reversed(S):
	if c == 'A' and (state == BINGO or state == ACTIVATE):
		state = ACTIVATE
	elif c == 'B' and state == CHANCE:
		state = BINGO
	elif c == 'C':
		if state == CHANCE:
			nBC = 0
		state = CHANCE
	else:
		state = WALL
	
	if state == WALL:
		nBC = 0
	elif state == ACTIVATE:
		score += nBC
	elif state == BINGO:
		nBC += 1

print(score)


Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
#define PI  acos(-1)
#define pb  push_back
#define ins insert
#define INF 1000000000000000007 //1e18+7
#define mk  make_pair
#define lb(v,x) lower_bound(all(v),x)
#define ub(v,x)  upper_bound(all(v),x)
#define ff  first
#define ss  second
#define rev reverse
#define endl "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a) (ll)a.size()
#define double long double
#define minpq  priority_queue <ll,vector<ll>,greater<ll> > 
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define fill(x,y)  memset(x,y,sizeof(x))
#define all(x)   (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bp(n)  __builtin_popcountll(n)
#define mxt(a)  *(max_element(a.begin(),a.end()))
#define mnt(a)  *(min_element(a.begin(),a.end())
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define trav(a, x) 	  for(auto &a : x)
#define re(i,n)       for(ll i=0;i<n;++i) 
const double eps=1e-7;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int dx[8]={+1, +1, +1, 0, 0, -1, -1, -1};
int dy[8]={+1, 0, -1, +1, -1, +1, 0, -1};
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
ll sqr(ll x) { return x * x;} 
template <typename T> T gcd(T a,T b){ if(a==0) return b; return gcd(b%a,a); }
template <class T> inline void chmax(T &x,T y){ x = max((x), (y));}
template <class T> inline void chmin(T &x,T y){ x = min((x), (y));}
template <class T> T abs(T x) { return x>0 ? x : -x;}
template <typename T> T powm(T a,T b, ll m){T cnt=1; while(b>0){ if(b%2==1) cnt=(cnt*a)%m; b/=2; a=(a*a)%m; }return cnt%m;}
typedef pair<ll,ll>  pii;
typedef vector<pii>  vpii;
typedef vector<ll>   vll;
typedef vector<int>  vii;
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
const int mod = 998244353;	
const int N = 1005;
void prec(){
	
}
void run(){
	int a;
	cin>>a;
	cout<<a+sqr(a)+a*sqr(a)<<endl;	
}	
int main()
{
    cin.sync_with_stdio(0);cin.tie(0);
	cin.exceptions(cin.failbit);
    int tc=1;
    //cin>>tc;
    prec();
    re(i,tc)
    	run();
    return 0; 
}


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

long long ans;
int x,y,a,b,c;
int P[100010],Q[100010],R[100010];
int p[100010],q[100010],r[100010];
int l1,l2,l3,r1,r2;

int main()
{
	scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	for(int i=1;i<=a;i++) scanf("%d",&P[i]);
	for(int i=1;i<=b;i++) scanf("%d",&Q[i]);
	for(int i=1;i<=c;i++) scanf("%d",&R[i]);
	sort(P+1,P+1+a);
	sort(Q+1,Q+1+b);
	sort(R+1,R+1+c);
	for(int i=1;i<=a;i++) p[i]=P[a-i+1];
	for(int i=1;i<=b;i++) q[i]=Q[b-i+1];
	for(int i=1;i<=c;i++) r[i]=R[c-i+1];
	l1=l2=l3=0;
	r1=x;
	r2=y;
	for(int i=1;i<=x+y;i++)
	{
		if(l3==c)
		{
			for(int j=l1+1;j<=r1;j++) ans+=p[j];
			for(int j=l2+1;j<=r2;j++) ans+=q[j];
			break;
		}
		if(l1==r1)
		{
			if(q[l2+1]>=r[l3+1])
			{
				l2++;
				ans+=q[l2];
			}
			else
			{
				l3++;
				ans+=r[l3];
				r2--;
			}
		}
		else if(l2==r2)
		{
			if(p[l1+1]>=r[l3+1])
			{
				l1++;
				ans+=p[l1];
			}
			else
			{
				l3++;
				ans+=r[l3];
				r1--;
			}
		}
		else
		{
			if(p[l1+1]>=r[l3+1]&&p[l1+1]>=q[l2+1])
			{
				l1++;
				ans+=p[l1];
			}
			else if(q[l2+1]>=r[l3+1])
			{
				l2++;
				ans+=q[l2];
			}
			else
			{
				l3++;
				ans+=r[l3];
				if(p[r1]<q[r2]) r1--;
				else r2--;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6172
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int l=s.length();
    for(int i=0;i<l;i++)
    {
        s[i]='x';
    }
    for(int i=0;i<l;i++)
    {
       cout<< s[i];
    }
    return 0;
}


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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    if (s.back() == '2' || s.back() == '4' || 
    	s.back() == '5' || s.back() == '7' || s.back() == '9')
    	cout << "hon\n";
    else if (s.back() == '3') cout << "bon\n";
    else cout << "pon\n";
}

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

int main()
{
	int a, b, i, j, k;

	string s, t;

	cin >> s;
	cin >> t;

	a = s.size();
	b = t.size();

	s += s;

	for (i = 0; i < a; ++i) {
		k = 0;
		for (j = 0; j < b; ++j) {
			if (s.at(i + j) == t.at(j)) { ++k; }
		}
		if (k == b) { cout << "Yes" << endl; goto xyz; }
	}
	cout << "No" << endl;
  xyz:;
}


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

#define  int        long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

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

int32_t main()
{
    fast
    int n,ans;
    cin>>n;
    int a[n+1];
    f(i,1,n)
        cin>>a[i];
    sort(a+1,a+n+1);
    ans+=a[n];
    int k=1;
    int j=n-1;
    while(k<n-1)
    {
        k++;
        ans+=a[j];
        if(k>=n-1)
            break;
        ans+=a[j];
        j--;
        k++;
    }
    cout<<ans;
}

Measured memory_bytes: 5172
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

class Eratosthenes {
    vector<int> plist;

public:
    Eratosthenes(int sz)
        : plist(sz, -1) {
        for (int i = 2; i < sz; i++) {
            if (plist[i] == -1) {
                for (int j = i; j < sz; j += i) {
                    if (plist[j] == -1) {
                        plist[j] = i;
                    }
                }
            }
        }
    }
    bool isPrime(int n) {
        return plist[n] == n;
    }
    vector<int> factor(int n) {
        vector<int> res;
        while (n > 1) {
            res.push_back(plist[n]);
            n /= plist[n];
        }
        return res;
    }
};

#include <set>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    vector<int> a(n);
    REP(i, 0, n) {
        cin, a[i];
    }
    int sz = 1000010;
    Eratosthenes prime(sz);
    vector<int> cnt(sz, 0);
    REP(i, 0, n) {
        int aa = a[i];
        auto v = prime.factor(aa);
        set<int> used;
        for (auto p : v) {
            if (!used.count(p)) {
                cnt[p]++;
            }
            used.insert(p);
        }
    }
    bool pairwise = true;
    REP(i, 0, sz) {
        pairwise &= (cnt[i] < 2);
    }

    if (pairwise) {
        print("pairwise coprime");
        return 0;
    }

    int g = a[0];
    REP(i, 1, n) {
        g = gcd(g, a[i]);
    }
    if (g == 1) {
        print("setwise coprime");
    } else {
        print("not coprime");
    }

    return 0;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

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

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

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

const ll INF = 1LL << 50;

struct edge{int to;ll cost;};

int V;
vector<edge> G[100005];
ll d[100005];

void dfs(int v,int p,ll dist){
    d[v] = dist;
    for(auto g:G[v]){
        if(g.to == p) continue;
        dfs(g.to,v,dist + g.cost);
    }
}

int main() {
    int n;cin >> n;
    V = n;

    REP(i,n-1){
        int u,v,w;cin >> u >> v >> w;
        u--;v--;
        edge e1;e1.to=v;e1.cost=w;
        G[u].push_back(e1);
        edge e2;e2.to=u;e2.cost=w;
        G[v].push_back(e2);
    }

    int q,k;
    cin >> q >> k;

    dfs(k-1,-1,0);

    vector<P_ii> xy(q);
    REP(i,q) {
        cin >> xy[i].first >> xy[i].second;
        xy[i].first--;
        xy[i].second--;
    }

    REP(i,q) pl(d[xy[i].first]+d[xy[i].second])

    return 0;
}



Measured memory_bytes: 16768
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

void solve(ll N, vector<ll> a) {
  sort(a.begin(),a.end(),std::greater<>());
  int score = 0;
  for(int i = 0; i != N; ++i) {
    score += (i%2 ? -a[i] : a[i]);
  }
  cout << score << endl;
}

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  solve(N, move(a));
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	long long int a, b, c;
	cin >> a >> b >> c;
	long long int x, y;
	cin >> x >> y;
	long long int ans = 10000000000000000;
	for (int i = 0; i <= 100000; i++) {
		long long int  k = 0;
		int amarix = max(k, x - i);
		int amariy = max(k,y - i);
		ans = min(ans, 2 * c * i + a * amarix + b * amariy);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <math.h>
#include <bits/stdc++.h>
#include <deque>
#include <string>
#include <vector>
#include <algorithm>
#define ll long long int
//#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
#define vali 1000000000000000000
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin >> t;
    if(t>=400 && t<=599)
    cout<<"8"<<endl;
    else if(t>=600 && t<=799)
    cout<<"7"<<endl;
    else if(t>=800 && t<=999)
    cout<<"6"<<endl;
    else if(t>=1000 && t<=1199)
    cout<<"5"<<endl;
    else if(t>=1200 && t<=1399)
    cout<<"4"<<endl;
    else if(t>=1400 && t<=1599)
    cout<<"3"<<endl;
    else if(t>=1600 && t<=1799)
    cout<<"2"<<endl;
    else
    cout<<"1"<<endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int> 
#define pb emplace_back
#define all(x) (x).begin(), (x).end()
#define deb(x) cout << #x << " - " << x << endl;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll MOD = 1e9 + 7;
const ll INF = 1<<29;
const ll MAX_N = 1e6 + 7;
using namespace std;

int cmp(string a,string b){
    reverse(a.begin(),a.end());
    if (a==b) return 1;
    else return 0;
}

int main()
{
    IOS;
    string s; cin>>s;
    int n=s.length();
    if(cmp(s,s)==1){
        string l=s.substr(0,0+(n-1)/2);
        if(cmp( l,s.substr(0,0+(n-1)/2) )==1){
            l=s.substr( ((n+3)/2)-1,n-1 );
            if(cmp(l , s.substr( ((n+3)/2)-1,n-1) )==1){
                cout<<"Yes";
            }
            else "No";
        }
        else cout<<"No";
    }
    else cout<<"No";
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1

typedef struct Node{
	int p,l,r;
}Node;

Node T[MAX];
int n,D[MAX];

int rec(int u,int p);
void print(int u);

int main(void){
	int i,j,d,v,c,l,r;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
	T[i].p = NIL;
	T[i].l = NIL;
	T[i].r = NIL;
	}
	
	for(i = 0;i < n;i++){
	scanf("%d %d",&v,&d);
		for(j = 0;j < d;j++){
		scanf("%d",&c);
		if(j == 0) T[v].l = c;
		else T[l].r = c;
		l = c;
		T[c].p = v;
		}
	}
	for(i = 0;i < n; i++){
	if(T[i].p == NIL)r = i;
	}
	
	rec(r,0);
	
	for(i = 0;i < n; i++)print(i);
	
	return 0;
	
}

int rec(int u,int p){
	D[u] = p;
	if(T[u].r != NIL) rec(T[u].r,p);
	if(T[u].l != NIL) rec(T[u].l,p+1);
}

void print(int u){
	int i,c;
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].p);
	printf("depth = %d, ",D[u]);
	
	if(T[u].p == NIL)printf("root, ");
	else if(T[u].l == NIL)printf("leaf, ");
	else printf("internal node, ");
	
	printf("[");
	
	for(i = 0, c = T[u].l;c != NIL;i++,c = T[c].r){
	if(i)printf(", ");
	printf("%d",c);
	}
	printf("]\n");
	
}


Measured memory_bytes: 6464
import math


class Solution:
    def solve(self, n: int) -> int:

        maxDivisor = int(math.sqrt(n) + 0.5)

        for i in range(1, maxDivisor + 1):
            if n % i == 0:
                p = i

        q = n // p

        return p+q-2


if __name__ == '__main__':

    # standard input
    n = int(input())

    # solve
    solution = Solution()
    print(solution.solve(n))


Measured memory_bytes: 3060
import sys
import numpy as np
import numba
from numba import njit
from numba.types import Omitted
i4 = numba.int32
i8 = numba.int64

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

@njit((i8[:, :], i8), cache=True)
def main(S, K):
    H, W = S.shape
    ans = H + W + 100
    for s in range(1 << H - 1):
        cost = 0
        T = S.copy()
        for i in range(H - 1):
            if s & 1 << i:
                T[i + 1] += T[i]
            else:
                cost += 1
        if np.any(T > K):
            continue
        cumsum = np.zeros(H, np.int64)
        for w in range(W):
            if np.any(cumsum + T[:, w] > K):
                cumsum[:] = 0
                cost += 1
            cumsum += T[:, w]
        ans = min(ans, cost)
    return ans

H, W, K = map(int, readline().split())
S = np.empty((H, W), np.int64)
for h in range(H):
    S[h] = np.array(list(readline().rstrip().decode()))

print(main(S, K))

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

int n;
long long a[200010];
long long ans;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	ans = 1e18+9;
	for(int i=1; i<=n; ++i)
		cin >> a[i];
	for(int i=2; i<=n; ++i)
		a[i] += a[i-1];
	for(int i=3; i<n; ++i){
		int j = upper_bound(a+1, a+n+1, a[i-1]/2) - a;
		int k = upper_bound(a+1, a+n+1, a[i-1]+(a[n]-a[i-1])/2) - a;
		ans = min(ans, max({a[j], a[i-1]-a[j], a[k]-a[i-1], a[n]-a[k]}) - min({a[j], a[i-1]-a[j], a[k]-a[i-1], a[n]-a[k]}));
//		if(j >= 2){
			ans = min(ans, max({a[j-1], a[i-1]-a[j-1], a[k]-a[i-1], a[n]-a[k]}) - min({a[j-1], a[i-1]-a[j-1], a[k]-a[i-1], a[n]-a[k]}));
//			if(k >= i+1){
				ans = min(ans, max({a[j-1], a[i-1]-a[j-1], a[k-1]-a[i-1], a[n]-a[k-1]}) - min({a[j-1], a[i-1]-a[j-1], a[k-1]-a[i-1], a[n]-a[k-1]}));
//			}
//		}else if(k >= i+1){
			ans = min(ans, max({a[j], a[i-1]-a[j], a[k-1]-a[i-1], a[n]-a[k-1]}) - min({a[j], a[i-1]-a[j], a[k-1]-a[i-1], a[n]-a[k-1]}));
//		}
//		cout << i << " " << j << " " << k << " " << ans << "\n";
	}
	cout << ans << "\n";
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int i,j;
	string s;
//	char c;
	
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]==a[1]&&a[1]==a[2])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
//////////////////////////////////////////////////////
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  
  vl snuke;
  ll digit = 1;
  rep(i,15) {
    rep(j,9) snuke.push_back((j+2)*digit - 1);
    digit *= 10;
  }

  ll irregular = 1099;
  int denominator = 19;
  digit = 100;
  
  rep(i,12) {
    ll num = irregular;
    int tmp = denominator;
    
    rep(j,9) {
      if (num/digit >= tmp) break;
      
      rep(k,9) snuke.push_back(num + digit*k);
      num += digit * 10;
      ++tmp;
    }

    (irregular *= 10) += 9;
    denominator += 9;
    digit *= 10;
  }

  irregular = 101 * 1e12 - 1;
  rep(i,9) {
    snuke.push_back(irregular);
    irregular += 1e12;
  }

  sort(all(snuke));

  rep(i,n) cout << snuke[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
using namespace std;
int main(void){
    int N;
    cin>>N;
    int P[N];
    for(int i=0;i<N;i++){
        cin>>P[i];
    }
    int a=0,b=0;
    sort(P, P + N, greater<int>());
    for(int i=0;i<N;i++){
        if(i%2==0){
            a+=P[i];
        }
        else {
            b+=P[i];
        }
    }
    cout<<a-b<<endl;;
}


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

ll N;
ll A[200000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i,N) cin >> A[i];
    ll sum = 0;
    rep(i,N) sum += A[i];
    ll hoge = 0;
    rep(i,N) {
        if ((hoge+A[i])*2 >= sum) {
            ll x1 = sum-hoge;
            ll d1 = x1-hoge;
            hoge += A[i];
            ll x2 = sum-hoge;
            ll d2 = hoge-x2;
            cout << min(d1,d2) << endl;
            return 0;
        }
        hoge += A[i];
    }
}

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

int n, A[1001000];
int G[110];

int insertionSort(int g) {
    int cnt = 0;
    for(int i=g;i<n;i++){
        int v = A[i];
        int j = i-g;
        while(j>=0&&A[j]>v){
            A[j+g]=A[j];
            j -= g;
            cnt++;
        }
        A[j+g]=v;
    }
    return cnt;
}
void shellSort(){
    int cnt = 0;
    int g=1;
    int m=0;
    while(g<=n){
        G[m++]=g;
        g=g*3+1;
    }
    for(int i=m-1;i>=0;i--){
        cnt += insertionSort(G[i]);
    }
    cout<<m<<endl;
    for(int i=m-1;i>=0;i--){
        cout << G[i] << ((i == 0) ? "\n" : " ");
    }
    cout<<cnt<<endl;
    for(int i=0;i<n;i++){
        cout<<A[i]<<endl;
    }
}

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


Measured memory_bytes: 6996
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long 
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e7+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
int main() 
{

	  ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    string s;
    int n , m , k;
    cin>>n; 
    int rem=0;
    int i=1;
    while(i*1000<n){
      i++;
    }
    cout<<i*1000-n;
  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rev(v) (v.rbegin())
using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const int N = 2e5 + 5;

struct DP {
	int n, y; };

vector<int> g[N];
vector<DP> dp[N];
i64 pow2[N];
int lvl[N], siz[N], onlvl[N];

vector<DP> tmp;
int n;

static i64 inv(i64 x) {
	i64 ant = 1, e = MOD - 2;

	for (; e > 0; e/= 2) {
		if (e % 2 == 1)
			ant = ant * x % MOD;
		x = x * x % MOD; }

	return ant; }

static void precomp(int u, int far = -1) {
	siz[u] = 1;
	onlvl[lvl[u]]+= 1;
	for (auto v: g[u]) if (v != far) {
		lvl[v] = lvl[u] + 1;
		precomp(v, u);
		siz[u]+= siz[v]; } }

static void dfs(int u, int far = -1) {
	vector<int> arb;
	i64 total, prod_no;

	for (auto v: g[u]) if (v != far) {
		arb.push_back(v);
		dfs(v, u); }

	sort(begin(arb), end(arb), [&](const int &a, const int &b) {
		return dp[a].size() > dp[b].size(); });

	if (arb.size() == 0) {
		dp[u].push_back({1, 1});
		return; }

	if (arb.size() == 1) {
		swap(dp[arb[0]], dp[u]);
		dp[u].push_back({1, 1});
		return; }

	for (int i = 0; i < dp[arb[1]].size(); ++i) {
		tmp[i] = {0, 0};
		prod_no = 1;

		for (int j = 0; j < arb.size() && dp[arb[j]].size() > i; ++j)
			prod_no = prod_no * rev(dp[arb[j]])[i].n % MOD;

		for (int j = 0; j < arb.size() && dp[arb[j]].size() > i; ++j)
			tmp[i].y = (tmp[i].y + ((prod_no * inv(rev(dp[arb[j]])[i].n)) % MOD) * rev(dp[arb[j]])[i].y) % MOD;
		tmp[i].y = (tmp[i].y + MOD) % MOD;

		total = 1;
		for (int j = 0; j < arb.size() && dp[arb[j]].size() > i; ++j)
			total = (total * (rev(dp[arb[j]])[i].n + rev(dp[arb[j]])[i].y)) % MOD;

		tmp[i].n = (total - tmp[i].y + MOD) % MOD; }

	swap(dp[u], dp[arb[0]]);
	for (int i = 0; i < dp[arb[1]].size(); ++i)
		rev(dp[u])[i] = tmp[i];
	dp[u].push_back({1, 1}); }

int main() {
#ifdef HOME
	freopen("marbles.in", "r", stdin);
	freopen("marbles.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	i64 sum(0);

	cin >> n;
	for (int t, i = 1; i <= n; ++i) {
		cin >> t;
		g[t].push_back(i);
		g[i].push_back(t); }

	pow2[0] = 1;
	for (int i = 1; i < N; ++i) {
		pow2[i] = pow2[i - 1] * 2;
		pow2[i] = pow2[i] < MOD ? pow2[i] : pow2[i] - MOD; }

	tmp.resize(n + 1);
	precomp(0);
	dfs(0);

	for (int i = 0; i < dp[0].size(); ++i)
		sum = (sum + rev(dp[0])[i].y * pow2[n + 1 - onlvl[i]]) % MOD;
	cout << sum << endl;

	return 0; }


Measured memory_bytes: 55916
import sys
from math import ceil

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    a_s = LI()
    big = 0
    sum_ = 0
    for i in a_s:
        if big > i:
            sum_ += big - i
        else:
            big = i
    print(sum_)

if __name__ == '__main__':
    main()


Measured memory_bytes: 32456
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
 
using namespace std;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;

	cin >> N;

	vector<int> A(N);

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

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

	bool checker = false;

	for(int i = 1; i < N; i++) {
		if(A[i - 1] == A[i]) {
			checker = true;
			break;
		}
	}

	if(checker) {
		cout << "NO" << endl;
	} else {
		cout << "YES" << endl;
	}
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
    int i, j;
    int h, w;
    
    while(scanf("%d %d", &h, &w), h > 0 && w > 0){
        for(i = 0; i < h; ++i){
            for(j = 0; j < w; ++j){
                putchar('#');
            }
            
            putchar('\n');
        }
        
        putchar('\n');
    }
    
    return 0;
}


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
int factorial(int n);
int factorial(int n)
{
    if(n==1)
    {
        return 1;
    }
    else
    {
        return n*factorial(n-1);
    }

}

bool is_prime(ll n) {
    // Assumes that n is a positive natural number
    // We know 1 is not a prime number
    if (n == 1) {
        return false;
    }

    ll i = 2;
    // This will loop from 2 to int(sqrt(x))
    while (i*i <= n) {
        // Check if i divides x without leaving a remainder
        if (n % i == 0) {
            // This means that n has a factor in between 2 and sqrt(n)
            // So it is not a prime number
            return false;
        }
        i += 1;
    }
    // If we did not find any factor in the above loop,
    // then n is a prime number
    return true;
}
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
typedef unsigned long long  ull;

int check(int x,vector <int> a,int n)
{  int county=0;
  map <int,int> mapa;
    for(int i=0;i<n;i++)
    {
        mapa.insert(pair<int,int>(a[i],0));
    }
    for(int i=0;i<n;i++)
    {
        mapa[a[i]]++;
    }
   // cout<<mapa[1]<<mapa[2]<<mapa[3]<<mapa[4]<<mapa[5]<<endl;
    for(int i=0;i<a.size();i++)
    {   mapa[a[i]]--;
        if(mapa[abs(a[i]-x)]>0)
        {
            county++;


            mapa[abs(a[i]-x)]--;
        }


    }
    return county;
}

typedef unsigned int ui;

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

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

}
ll ans=0;
for(int i=0;i<n-1;i++)
{
    if(a[i]>a[i+1])
    {
        ans=ans+a[i]-a[i+1];
        a[i+1]=a[i];
    }
}
cout<<ans<<endl;



}


Measured memory_bytes: 4436
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ll inf = 1LL << 60;
const ld pi = (acos(-1));
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll func(pair<ll,ll> x){
  int le=0;
  int ri=0;
  while(x.first){
      x.first/=10;
      le++;
    }
  while(x.second){
    x.second/=10;
    ri++;
  }
  return max(le,ri);
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n; cin >> n;
  int ans=10000007;
  vector<pair<ll,ll>> A;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0) A.push_back(make_pair(i,n/i));
  }
  for(auto& a:A){
    int res=func(a);
    ans=min(res,ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
def main():
    T = int(input())
    for _ in range(T):
        N = int(input())
        A = list(map(int, input().split()))
        S = input()
        L = max(A).bit_length()
        s = [0]*L

        def check(x):
            for i in range(L-1, -1, -1):
                if (x >> i) % 2:
                    x ^= s[i]
            return(x == 0)

        def update(x):
            for i in range(L-1, -1, -1):
                if (x >> i) % 2:
                    x ^= s[i]
            id = x.bit_length() - 1
            if id >= 0:
                s[id] = x

        res = 0
        L2 = 0
        for i in range(N-1, -1, -1):
            k = int(S[i])
            if k:
                if check(A[i]):
                    continue
                else:
                    res = 1
                    break
            else:
                L2 = max(L2, A[i].bit_length())
                update(A[i])
        print(res)
main()


Measured memory_bytes: 9152
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{ 
	ll a,b,n;
	cin>>a>>b>>n;
	if(n < b - 1){
		cout<<(a*n)/b<<endl;
	}
	else {
		ll val = (a+b-1)/b;
		// cout<<val<<endl;
		cout<<a - val + (val*b - a)/b<<endl;
	}
	return 0;	
} 


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

bool is_nine(char* str){

  for(int i=0; i<100 ; i++){
    if(str[i] == '9')
      return true;
  }
  return false;
}

int main(){
  char str[100];
  scanf("%s", str);

  if(is_nine(str)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  
  
  return 0;
}


Measured memory_bytes: 256