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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(v) (v).begin(),(v).end()

const int MOD = 1000000007;
const int N = 1000005;
const double PI =4*atan(1);
ll n;
string ch;
string sh="keyence";


int main(){
    ios::sync_with_stdio(0);
    //freopen("baklava.in","r",stdin);
    cin.tie(0);
    cout.tie(0);
    //start
    cin >> ch;
    n=ch.size();
    if(ch.substr(0,7)==sh){
    	cout << "YES";
    	return 0;
    }
    for(int i=1;i<7;i++){
    	if(ch.substr(0,i)+ch.substr(n-(7-i),7-i)==sh){
    		cout << "YES";
    		return 0;
    	}
    }
    if(ch.substr(n-7,7)==sh){
    	cout << "YES";
    	return 0;
    }
    cout << "NO";

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long int i,N,T,X = 0,t[200005];
	scanf("%lld %lld\n",&N,&T);
	for(i = 0;i < N; i++)
		scanf("%lld",&t[i]);
	if(N > 1)
	{
		for(i = 0;i < N - 1; i++)
		{
			if(t[i + 1] - t[i] >= T)
				X += T;
			else
				X += t[i + 1] - t[i];
		}
	}
		X += T;
		printf("%lld\n",X);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
const int INF = 100000000;
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};

int main(){
    int n;
    cin >> n;
    ll sum1 = 0, sum2 = 0;
    ll ans1 = 0, ans2 = 0;
    for(int i = 0; i < n; i++){
        ll a;
        cin >> a;
        sum1 += a;
        sum2 += a;
        if(i % 2){
            if(sum1 >= 0){
                ans1 += sum1 + 1;
                sum1 = -1;
            }
            if(sum2 <= 0){
                ans2 += abs(sum2) + 1;
                sum2 = 1;
            }
        }else{
            if(sum1 <= 0){
                ans1 += abs(sum1) + 1;
                sum1 = 1;
            }
            if(sum2 >= 0){
                ans2 += sum2 + 1;
                sum2 = -1;
            }
        }
    }
    cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  while(cin >> s){
    TSTART();
    int ind;
    for(ind = SZ(s)-1; ind >= 0; ind--){
      if(ind % 2 != 0)continue;
      bool isAnswer = true;
      REP(i,ind/2){
	DUMP(s[i]);DUMP(s[i+ind/2]);
	if(s[i] != s[i+ind/2]){
	  isAnswer = false;
	  break;
	}
      }
      if(isAnswer)break;
    }
    cout << ind << endl;
    TSTOP();
  }
  return 0;
}



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

ans = 10**9+7
for i in range(N+1):
  j = N-i
  cnt = 0
  while i > 0:
    cnt += i%6
    i //= 6
  while j > 0:
    cnt += j%9
    j //= 9
  ans = min(ans, cnt)
print(ans)

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

int main() {
    int a,b,c,tmp;
    cin >> a>>b>>c;

    if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }
    if (b > c) {
        tmp = b;
        b = c;
        c = tmp;
    }
    if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    cout << a <<" " << b << " " << c << endl;
    return 0;
}



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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define fout(x) cout << fixed << setprecision(10) << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
};

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

  int n, k;
  cin >> n >> k;
  vector<double> p(n);
  rep(i, n) cin >> p[i];
  vector<double> s(n + 1, 0);
  rep(i, n) p[i] = (1 + p[i]) / 2.0;
  rep(i, n) s[i + 1] += s[i] + p[i];
  double ans = 0;
  for(int i = 1; i + k < n + 1; ++i) {
    ans = max(ans, s[i + k] - s[i]);
  }
  ans = max(ans, s[k]);
  fout(ans);

  return 0;
}


Measured memory_bytes: 3456
while True:
    rec = str(input())
    if rec == "0":
        break
    A = 0
    B = 0
    for i in range(1, len(rec)):
        if rec[i] == "A":
            A += 1
        else:
            B += 1
    if A > B:
        A += 1
    else:
        B += 1
    print(A,B)


Measured memory_bytes: 5556
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 998244353
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
#define SUB(X,Y) ((X) = ((X) + MOD - (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, A[404], B[404];
i64 dp[2][404][404];
i64 C[404][404], pows[404];

i64 modpow(i64 a, int p = MOD - 2)
{
	if (p == 0) return 1;
	i64 tmp = modpow(a, p / 2);
	tmp = tmp * tmp % MOD;
	if (p % 2 == 1) tmp = tmp * a % MOD;
	return tmp;
}

int main()
{
	C[0][0] = 1;
	for (int i = 1; i <= 400; ++i) {
		C[i][0] = 1;
		for (int j = 1; j <= 400; ++j) {
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
		}
	}
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%d%d", A + i, B + i);

	int t = 0;
	for (int i = 0; i <= 400; ++i)
		for (int j = 0; j <= 400; ++j) dp[t][i][j] = 0;
	dp[t][0][0] = MOD - 1;

	int S = 0;
	for (int i = 0; i < N; ++i) S += A[i];
	i64 Sinv = modpow(S);

	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= 400; ++j)
			for (int k = 0; k <= 400; ++k) dp[1 - t][j][k] = dp[t][j][k];
		pows[0] = 1;
		pows[1] = A[i] * Sinv % MOD;
		for (int j = 2; j <= 400; ++j) pows[j] = pows[j - 1] * pows[1] % MOD;
		for (int j = 0; j <= 400; ++j)
			for (int k = 0; k <= 400; ++k) {
				if (dp[t][j][k] == 0) continue;
				for (int l = 0; l < B[i]; ++l) {
					SUB(dp[1 - t][j + A[i]][k + l], dp[t][j][k] * C[k + l][k] % MOD * pows[l]);
				}
			}
		t = 1 - t;
	}

	i64 ret = 0;
	for (int i = 1; i <= 400; ++i) {
		i64 x = S * modpow(i) % MOD;
		for (int j = 0; j <= 400; ++j) {
			ADD(ret, dp[t][i][j] * modpow(x, j + 1));
		}
	}
	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<ll,ll>

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin >> N;
    ll ans = 1;
    ll cnt = 0; // 現在おいてある石の数
    rep(i,N){
        int x;
        cin >> x;
        if(x < cnt*2 + 1){
            ans *= (cnt+1);
            ans %= mod;
            continue;
        }
        cnt++;
    }
    while(cnt > 0){
        ans *= cnt;
        ans %= mod;
        cnt--;
    }
    cout << ans << endl;
}

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

int main() {
  int n,k;cin>>n>>k;
  int dn[10];rep(i,10)dn[i]=0;
  int di;
  rep(i,k) {
    cin>>di;
    dn[di]=1;
  }
  
  int x=n;
  while (true) {
    bool flg=true;
    for (char c:to_string(x)) {
      di=c-'0';
      if (dn[di]==1) {
        flg=false;
        break;
      }
    }
    if (flg) {
      cout<<x;
      return 0;
    }
    x++;
  }
}


Measured memory_bytes: 256
import math
from decimal import Decimal
a,b,x = list(map(int,input().split()))
A = a**2
if A*b == x:
  print(0)
elif A*b/2 <= x:
  c = Decimal(x/A)
  d = (b-c)*2
  print(90-(math.degrees(math.atan(Decimal(a/d)))))
else:
  s = Decimal(x/a)
  d = Decimal(s*2/b)
  print(90-(math.degrees(math.atan(Decimal(d/b)))))

Measured memory_bytes: 5076
def main():
    n = int(input())
    A = list(map(int, input().split()))
    count = 0
    plus = '-1'
    A = [A[i + 1] - A[i] for i in range(n - 1)]
    for a in A:
        if plus == '-1':
            if a > 0:
                plus = True
            elif a < 0:
                plus = False
            else:
                pass
        elif plus:
            if a < 0:
                plus = '-1'
                count += 1
            else:
                pass
        else:
            if a > 0:
                plus = '-1'
                count += 1
            else:
                pass
    print(count + 1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 63468
n=int(input())
n2=n*2
key=[0,0]
for i in range(1,int(n2**0.5)+3):
  if n2%i==0:
    if i*(i+1)==n2:
      key=[i,i+1]
      break
if key==[0,0]:
  print('No')
  exit()
print('Yes')
a,b=key
print(b)
ans=[[0]*a for _ in range(b)]
cnt=1
for i in range(b):
  for j in range(a):
    if j<i:
      ans[i][j]=ans[j][i-1]
    else:
      ans[i][j]=cnt
      cnt+=1
for x in ans:
  print(len(x),' '.join(map(str,x)))

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

int main() {
  char x;
  cin >> x;
  string vowel = "aiueo";
  for (int i = 0; true; i++) {
    if (vowel.at(i) == x) {
      cout << "vowel" << endl;
      break;
    }
    if (i == 4) {
      cout << "consonant" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, k;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  cout << n-k+1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
 
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	bool sameFlag = false;
	if (a + b == c) { sameFlag = true; }
	else if (b + c == a) { sameFlag = true; }
	else if (c + a == b) { sameFlag = true; }
	cout << (sameFlag == true ? "Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void trace(int a[],int N){
  int k;
  for(k=0;k<N;k++){
      if(k>0){
         printf(" ");
      }
    printf("%d",a[k]);
    }
  printf("\n");
}

void insertionsort(int a[],int N){
  int i,j,v;
  for(i=1;i<N;i++){
    v=a[i];
    j=i-1;
    while(j>=0&&a[j]>v){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=v;
    trace(a,N);
  }
}

int main(void)
{
  int N,i,j,a[100];

  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }
  trace(a,N);
  insertionsort(a,N);
      
  return 0;
}

    
  

Measured memory_bytes: 1744
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    ll n;
    cin >> n;
    vector<double> p(n);
    REP(i, n){
        cin >> p[i];
    }
    
    vector<vector<double>> dp(n + 5, vector<double>(n + 5));
    dp[0][0] = 1.0;
    REP(i, n){
        for(ll j = 0; j <= i; j++){
            dp[j + 1][i - j] += dp[j][i - j] * p[i];
            dp[j][i - j + 1] += dp[j][i - j] * (1.0 - p[i]);
        }
    }
    
    double ans = 0.0;
    for(ll i = (n + 1) / 2; i <= n; i++){
        ans += dp[i][n - i];
    }
    printf("%.10lf\n", ans);
}


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

int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if (a == 0) {
        cout << 1 << endl;
    } else if (b == 0) {
        cout << 2 << endl;
    } else if (c == 0) {
        cout << 3 << endl;
    } else if (d == 0) {
        cout << 4 << endl;
    } else if (e == 0) {
        cout << 5 << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
n,m = map(int,input().split())

ans = [0]*n
ans[0] = 1

misnot = 0

if m == 0:
  misnot=1

s = [0]*m
c = [0]*m
for i in range(m):
  s[i],c[i] = map(int,input().split())

flag = 0
if misnot == 0:
  if n == 1:
    for i in range(m-1):
      if c[0]!=c[i+1]:
        flag=-1
        break
    if flag == 0:
      print(c[0])
    else: 
      print(-1)

  if n == 2:
    for i in range(m):
      ans[s[i]-1]=c[i]
    for i in range(m):
      if ans[s[i]-1]!=c[i]:
        flag=-1
        break
    if ans[0] == 0:
      print(-1)
    elif flag == 0:
      print(ans[0]*10+ans[1])
    else: 
      print(-1)

  if n == 3:
    for i in range(m):
      ans[s[i]-1]=c[i]
    for i in range(m):
      if ans[s[i]-1]!=c[i]:
        flag=-1
        break
    if ans[0]==0:
      print(-1)
    elif flag == 0:
      print(ans[0]*100+ans[1]*10+ans[2])
    else: 
      print(-1)
else:
  if n == 1:
    print(0)
  elif n == 2:
    print(10)
  elif n == 3:
    print(100)


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

int main() {
    long n;
    cin >> n;
    int i;
    long int a[n], su, cnt, cnt2, cnt3, cnt4;
    cnt = cnt2 = cnt3 = cnt4 = 0;
    for(i=0; i<n; i++){
        cin >> a[i];
    }
    su = 0;
    for(i=0; i<n; i++){
        su += a[i];
        if(a[0]>=0){
            if(i%2 == 0){
                if(su <= 0){
                    cnt += 1 - su;
                    su = 1;
                }
            }else{
                if(su >= 0){
                    cnt += su +1;
                    su = -1;
                }
            }
        } else {
            if(i%2 == 0){
                if(su >= 0){
                    cnt += su + 1;
                    su = -1;
                }
            }else{
                if(su <= 0){
                    cnt += 1 - su;
                    su = 1;
                }
            }
        }
    }
    su = 0;
    for(i=0; i<n; i++){
        su += a[i];
        if(a[0]>0){
            if(i%2 == 0){
                if(su <= 0){
                    cnt2 += 1 - su;
                    su = 1;
                }
            }else{
                if(su >= 0){
                    cnt2 += su +1;
                    su = -1;
                }
            }
        } else {
            if(i%2 == 0){
                if(su >= 0){
                    cnt2 += su + 1;
                    su = -1;
                }
            }else{
                if(su <= 0){
                    cnt2 += 1 - su;
                    su = 1;
                }
            }
        }
    }
    su = 0;
    for(i=0; i<n; i++){
        su += a[i];
        if(a[0]<=0){
            if(i%2 == 0){
                if(su <= 0){
                    cnt3 += 1 - su;
                    su = 1;
                }
            }else{
                if(su >= 0){
                    cnt3 += su +1;
                    su = -1;
                }
            }
        } else {
            if(i%2 == 0){
                if(su >= 0){
                    cnt3 += su + 1;
                    su = -1;
                }
            }else{
                if(su <= 0){
                    cnt3 += 1 - su;
                    su = 1;
                }
            }
        }
    }
    su = 0;
    for(i=0; i<n; i++){
        su += a[i];
        if(a[0]<0){
            if(i%2 == 0){
                if(su <= 0){
                    cnt4 += 1 - su;
                    su = 1;
                }
            }else{
                if(su >= 0){
                    cnt4 += su +1;
                    su = -1;
                }
            }
        } else {
            if(i%2 == 0){
                if(su >= 0){
                    cnt4 += su + 1;
                    su = -1;
                }
            }else{
                if(su <= 0){
                    cnt4 += 1 - su;
                    su = 1;
                }
            }
        }
    }
    cout << min(min(cnt, cnt2), min(cnt3, cnt4)) << endl;
    return 0;
}

Measured memory_bytes: 1024
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    N = i_input()
    t0,a0 = 1,1

    for i in range(N):
        t1,a1 = i_map()
        f0 = t0//t1
        if t0%t1 != 0:
            f0 += 1
        f1 = a0 // a1
        if a0%a1 != 0:
            f1 += 1
        f = max(f0, f1)
        t0, a0 = t1*f, a1*f
    print(t0+a0)

if __name__=="__main__":
    main()


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b,x; cin >> x >> a >> b;
  x-=a;
  int ans = x%b;
  cout << ans << endl;
  
  return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll x,y;
    cin >>x>>y;
    ll tmp=y/x;
    ll ans=0;
    while(tmp>0){
        ans++;
        tmp/=2;
    }
    cout <<ans <<endl;
    return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(200000)
N = int(input())
A = list(map(int,input().split()))
dp = [-1]*(N+2)
dp[0] = 0
dp[1] = abs(A[1] - A[0])


def rec(i):
  if dp[i] != -1:
    return dp[i]
  dp[i] = min(rec(i-1) + abs(A[i-1] - A[i]), rec(i-2) + abs(A[i-2] - A[i]))
  return dp[i]

print(rec(N-1))

Measured memory_bytes: 94204
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 210;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

int n, l, a[MAXN];;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> l;
    FOR(i,1,n) a[i] = l + i - 1;
    int s = 0;
    FOR(i,1,n) s += a[i];
    int res = 1000000000;
    int vt = 0;
    FOR(i,1,n) {
        if (res > abs(s - (s - a[i]))) {
            res = abs(s - (s - a[i]));
            vt = s - a[i];
        }
    }
    cout << vt;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll d;
    cin >> d;
    for (int i = 0; i < d; i++) {
        cout << i % 26+1 << endl;
    }
}

Measured memory_bytes: 3632
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

r = int(input())
g = int(input())
print(g*2-r)


Measured memory_bytes: 3956
#include<cstdio>
#include<string>
main(){
	char ch;
	int a[26];
	int num;
	int i;

	for(i=0;i<26;i++){
		a[i] = 0;
	}

	while(scanf("%c",&ch) != EOF){
		if(isupper(ch)){
			ch = tolower(ch);
		}
		num = ch - 'a';
		a[num]++;
	}
	for(i=0;i<26;i++){
		ch = (char)(i+'a');
		printf("%c : %d\n",ch,a[i]);
	}
	return 0;
}

Measured memory_bytes: 980
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Product solver = new Product();
		solver.readInput();
		solver.solve();
		solver.writeAnswer();
	}


	static class Product {

		private int input_a;
		private int input_b;

		private String answer;

		private Scanner scanner;
		public Product() {
			this.scanner = new Scanner(System.in);
		}
		public void readInput() {
			this.input_a = scanner.nextInt();
			this.input_b = scanner.nextInt();
		}
		public void solve() {
			Integer m = input_a * input_b;
			if(m%2 == 0) {
				answer = "Even";
			} else {
				answer = "Odd";
			}
		}
		public void writeAnswer() {
			System.out.println(answer);
		}
	}
}


Measured memory_bytes: 25300
#include<bits/stdc++.h>
#define  INF 1100000000
#define	 MOD 1000000007
using namespace std;


int main(){
	int N, M, ans;
	int a[1100];
	while(1){
		cin >> N >> M;
		if(N==0 && M==0) break; 
		for(int i=0;i<N;i++){
			cin >> a[i];
		}
		ans = -1;
		for(int i=0;i<N;i++){
			for(int j=i+1;j<N;j++){
				if(a[i] + a[j] > ans && a[i] + a[j] <= M){
					ans = a[i] + a[j];
				}	
			
			}
		
		}
		if(ans != -1){
			cout << ans << endl;
		}else{
			cout << "NONE" << endl;
		}
	}
	
	return 0;
	
}


Measured memory_bytes: 3088
(* O(1) *)
let a, b, c = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let m = max a @@ max b c
let ec = List.filter (fun n -> n mod 2 = 0) [a; b; c] |> List.length
let x = m + if (ec = 1 || ec = 2) && m mod 2 = 2 - ec then 1 else 0
let _ = Printf.printf "%d\n" @@ (3 * x - (a + b + c)) / 2

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <algorithm>

using namespace std;

int main() {
	int N, M;
	vector<int> D, T;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int t;
		cin >> t;
		D.push_back(t);
	}
	sort(D.begin(), D.end());
	cin >> M;
	for (int i = 0; i < M; i++) {
		int t;
		cin >> t;
		T.push_back(t);
	}
	sort(T.begin(), T.end());
	int k = 0;
	bool flag = true;
	for (int i = 0; i < M;) {
		if (T[i] == D[k]) {
			i++;
			k++;
			if ((int)T.size() == i) break;
			if ((int)D.size() == k) {
				flag = false;
				break;
			}
		}
		else {
			k++;
			if ((int)D.size() == k) {
				flag = false;
				break;
			}
		}
	}
	if (flag) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 2548
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    string s;
    cin >> s;
    vector<ll> ptr(s.size(), 0);

    ll s0(0), s1(0);
    rep(i,0,s.size())
    {
        if (s[i] == '0') s0++; 
        if (s[i] == '1') s1++; 
    }

    cout << 2*min(s0, s1) << endl;

    return 0;
}


Measured memory_bytes: 1232
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

a, b, k = map(int, input().split())

div_a = make_divisors(a)
div_b = make_divisors(b)

# 内包表記と三項演算子の合わせ技（可読性が最悪なので絶対にやってはいけない）
common_div = [a for a in div_a if a in div_b] if len(div_a) > len(div_b) else [b for b in div_b if b in div_a] 

# print('Aの約数：{}'.format(div_a))
# print('Bの約数：{}'.format(div_b))
# print('A, Bの公約数のリスト：{}'.format(common_div))
print(common_div[::-1][k-1])

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<algorithm>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
#define f(n) for(long long int i=0;i<n;i++)
#define g(n) for(long long int j=0;j<n;j++)
#define ff(a,n) for(long long int i=a;i<n;i++)
#define gg(a,n) for(long long int j=a;j<n;j++)
#define t(a) long long int a;cin>>a
#define test(te) t(te); while(te--)
#define all(a) a.begin(),a.end()
#define ent "\n"
#define pri(a,n) f(n){cout<<a[i]<<" ";}cout<<ent
#define cas(i) "Case #"<<i+1<<": "
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007  
#define ll long long 
#define lli long long int
#define op std::ios_base::sync_with_stdio(false);cin.tie(NULL)
//using namespace boost::multiprecision;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
using namespace std;

int main(int argc, char const *argv[])
{
    op;
    t(a);
    t(b);
    cout<<a*b;
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		int w = sc.nextInt();
		if(w>=s){
		   System.out.println("unsafe");
		}else
		System.out.println("safe");
	}
}


Measured memory_bytes: 35792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
#define N 100005
int n,a[N],cnt,ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
        if(a[i]^i) ans+=cnt+1>>1,cnt=0;else cnt++;
    ans+=cnt+1>>1;
    printf("%d\n",ans);
    return 0;
}

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

#define N	60

using namespace std;


int main()
{
	int n , K;
	int x1[N] , x2[N] , d1[N] , y1[N] , y2[N] , d2[N];
	int x_copy[N * 2] , y_copy[N * 2] , d_copy[N * 2];
	long long int ans = 0;

	cin >> n >> K;

	for (int i = 0; i < n; i++)
	{
		cin >> x1[i] >> y1[i] >> d1[i] >> x2[i] >> y2[i] >> d2[i];
	}

	int a = 0;
	//ソートのために１つの配列にまとめる
	for (int i = 0; i < n; i++)
	{
		x_copy[a] = x1[i];
		x_copy[a + 1] = x2[i];

		y_copy[a] = y1[i];
		y_copy[a + 1] = y2[i];

		d_copy[a] = d1[i];
		d_copy[a + 1] = d2[i];

		a += 2;
	}

	//ソート
	sort(x_copy , x_copy + a);
	sort(y_copy , y_copy + a);
	sort(d_copy , d_copy + a);

	//コピー配列は小さい体積でできており、その中にいる魚の数を数える
	for (int i = 0; i < a - 1; i++)
	{
		for (int j = 0; j < a - 1; j++)
		{
			for (int k = 0; k < a - 1; k++)
			{
				int cnt = 0;
				for (int l = 0; l < n; l++)
				{
					//lは大元の配列を表していて、i,j,kほ各容積の縦・横・高さを表す
					if (x1[l] <= x_copy[i] && x_copy[i + 1] <= x2[l] &&
						y1[l] <= y_copy[j] && y_copy[j + 1] <= y2[l] &&
						d1[l] <= d_copy[k] && d_copy[k + 1] <= d2[l])
					{
						cnt++;
					}
				}
				//カウント変数が最低限の魚の数より多い
				if (cnt >= K)
				{
					ans += (long long)(x_copy[i + 1] - x_copy[i]) * (y_copy[j + 1] - y_copy[j]) * (d_copy[k + 1] - d_copy[k]);
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main()
{
    string str;
    int len,arr[26]={0};
    bool flag = true;
    cin>>str;
    len = str.length();
    for(int i = 0;i<len;i++)
        arr[str[i]-'a']++;
    int x = 25;
    while(arr[x]!=0)
        x--;
    for(int i  = 0;i<=x;i++)
        if(!arr[i]){
                flag = false;
            cout<<(char)(i+(int)'a');
            break;
        }
        if(flag)
            cout<<"None";

    return 0;
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS

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

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (4e18) + 9;
const int MOD = (1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { r, d, l, u };
int dx[] = { 0, 1, 0,-1 };
int dy[] = { 1, 0,-1, 0 };

//enum diR { d, r, u, l , dr, ur, dl, ul };
int dX[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dY[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiou"; //and sometimes "aeiouy"

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
//convert index from 2D matrix to 1D array. (Zero-indexed)
int ord(int r, int c, int nCol) { return (nCol*r) + c + 1; }
//convert index from 1D array to 2D matrix . (One-indexed)
ii rord(int n, int nCol) {
	int r = n%nCol, c = n / nCol;
	if (n%nCol == 0) c--, r = nCol;
	return ii(r, c);
}

ll poww(ll num, ll p, ll md = MOD) {
	num %= md;
	ll ret = 1;
	while (p > 0) {
		if (p & 1) ret = (ret * num) % md;
		num = (num * num) % md;
		p >>= 1;
	}
	return ret;
}

ll nCr(ll n, ll r) {
	if (n < r)
		return 0;
	if (r == 0)
		return 1;
	return n * nCr(n - 1, r - 1) / r;
}

const int N = 1e5 + 10;
int dp[N][4], a[N], b[N], c[N], n;
int solve(int idx, int chose) {
	if (idx >= n) return 0;
	int& ret = dp[idx][chose];
	if (~ret) return ret;
	if (chose == 0)
		return ret = max(max(a[idx] + solve(idx + 1, 1), b[idx] + solve(idx + 1, 2)), c[idx] + solve(idx + 1, 3));
	else if (chose == 1)
		return ret = max(c[idx] + solve(idx + 1, 3), b[idx] + solve(idx + 1, 2));
	else if (chose == 2)
		return ret = max(a[idx] + solve(idx + 1, 1), c[idx] + solve(idx + 1, 3));
	else
		return ret = max(a[idx] + solve(idx + 1, 1), b[idx] + solve(idx + 1, 2));
}


int main()
{
#ifndef ONLINE_JUDGE

#else
	//freopen("pyramid.in", "r", stdin);
#endif
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	lop(i, n) cin >> a[i] >> b[i] >> c[i];
	mem(dp, -1);
	cout << solve(0,0) << endl;



	return 0;
}


Measured memory_bytes: 8064
#include <stdio.h>

int main (){
	
	char str[20];
	scanf ("%[^\n]", &str);
	
	for (int i = 0; i < 19; i++){
		if (i==5 || i ==13){
			printf(" ");
			continue;
		}
		
		printf ("%c", str[i]);
	}
	
	
	
	return 0;
}

Measured memory_bytes: 1596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

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

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

  if (n == 25) {
    cout << "Christmas" << endl;
  } else if (n == 24) {
    cout << "Christmas Eve" << endl;
  } else if (n == 23) {
    cout << "Christmas Eve Eve" << endl;
  } else if (n == 22) {
    cout << "Christmas Eve Eve Eve" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, k int
	_, _ = fmt.Scanf("%d %d %d", &a, &b, &k)

	aDivisor := make([]int, 0)
	bDivisor := make([]int, 0)

	kth := 0


	for i := 1; i <= a; i++ {
		if a % i == 0 {
			aDivisor = append(aDivisor, i)
		}
	}

	for i := 1; i <= b; i++ {
		if b % i == 0 {
			bDivisor = append(bDivisor, i)
		}
	}

	for i := len(aDivisor) - 1; i >= 0; i-- {
		if in(aDivisor[i], bDivisor) {
			kth++
			if kth == k {
				fmt.Println(aDivisor[i])
				break
			}
		}
	}
}

func in(n int, arr []int) bool {
	for _, i := range arr {
		if i == n {
			return true
		}
	}
	return false
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
typedef long long ll;

const int mod = 1000000007;
int dp[10001][2][101] = {};

int main(){
    string s;
    int d;
    cin >> s >> d;
    int n = s.length();
    dp[0][0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 2; j++){
            for(int k = 0; k <= d; k++){
                for(int l = 0; l <= 9; l++){
                    if(j == 0 && l > s[i]-'0')  continue;
                    int ni = i+1;
                    int nj = j|(l<s[i]-'0');
                    int nk = (k+l)%d;
                    dp[ni][nj][nk] += dp[i][j][k];
                    dp[ni][nj][nk] %= mod;
                }
            }
        }
    }
    cout << ((ll)dp[n][0][0]+dp[n][1][0]-1+mod)%mod << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

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

    int a, b, c, d;

    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


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

typedef struct Node {
  int key;
  struct Node *prev, *next;
} Node;

Node *nil;

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int key){
/*  printf("insert %d\n", key);*/
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  nil->next->prev = x;
  x->next = nil->next;
  nil->next = x;
  x->prev = nil;
}

void delete(int key){
/*  printf("delete %d\n", key); */
  Node *cur = nil->next;
  while(cur->key != key && cur != nil){
    cur = cur->next;
  }
  if(cur->key == key){
    cur->prev->next = cur->next;
    cur->next->prev = cur->prev;
    free(cur);
  }
}

void deleteFirst(){
  Node *tmp = nil->next;
  nil->next = tmp->next;
  tmp->next->prev = nil;
  free(tmp);
}

void deleteLast(){
  Node *tmp = nil->prev;
  tmp->prev->next = nil;
  nil->prev = tmp->prev;
  free(tmp);
}

void printList(){
  Node *cur = nil->next;
  int isf = 0;
  while(cur != nil){
    if(isf++ > 0)printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

int main(){
  init();
  int n, key;
  char str[20];

  scanf("%d",&n);

  for(int i = 0; i < n; i++){
    scanf("%s%d", str, &key);
    if(str[0] == 'i'){
      insert(key);
    }else if(str[0] == 'd'){
      if(strlen(str) > 6){
        switch(str[6]){
          case 'F':
            deleteFirst();
            break;
          case 'L':
            deleteLast();
            break;
        }
      }else{
        delete(key);
      }
    }
  }
  printList();
  return 0;
}



Measured memory_bytes: 32928
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>
#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

//#define solvsh
//#define multi
#ifdef solvsh

const int MAXN = 3e2 + 1e2;

const int M = 54;

vector<int> g;

bool bit(int num, int i){
    return (num >> i) & 1;
}

void add_row(int row){

    g.push_back(row);


    for (int i = 20; i >= 0; --i){
        if (bit(row, i)){

        }
    }


    sort(all(g));
    while (g.back() == 0)
        g.pop_back();
}

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> v;
    for (int i = 0; i < n; ++ i){
        int curr;
        cin >> curr;
        v.push_back(curr);
    }

}

#else

void solve(){
    ll n,m;
    cin >> n >>m;

    for (int i  = 0; i < m; ++ i){
        ll curr;
        cin >> curr;
        n -= curr;
    }

    n = max(-1ll, n);
    cout << n;

}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        cout << "Case #" << (i++) << ": ";
        solve();
        cout << endl;
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif

}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

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

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

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int a, b, h;
  std::cin >> a >> b >> h;
  std::cout << (a + b) * h / 2 << "\n";
}


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (long i = 0; i < (n); ++i)

using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(long N, vector<long> t, vector<long> x, vector<long> y) {
  t.insert(t.begin(), 0);
  x.insert(x.begin(), 0);
  y.insert(y.begin(), 0);
  rep(i, N) {
    long dt = t[i + 1] - t[i];
    long dx = abs(x[i + 1] - x[i]);
    long dy = abs(y[i + 1] - y[i]);
    if (dt < (dx + dy) || (dt - dx - dy) % 2) {
      cout << NO << endl;
      return;
    }
  }
  cout << YES << endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long N;
  cin >> N;
  vector<long> t(N);
  vector<long> x(N);
  vector<long> y(N);
  for(int i = 0 ; i < N ; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  solve(N, move(t), move(x), move(y));
  return 0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

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

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

const int maxn = 1e5+5;

int A[maxn];
LL sum[maxn];
LL N,M;
map<int,int> mp;


int main()
{
    scanf("%lld %lld",&N,&M);
    _rep(i,1,N){
        scanf("%d",&A[i]);
        A[i]%=M;
        sum[i] = (sum[i-1] + A[i])%M;
        //cout << sum[i] << endl;
        mp[sum[i]]++;
    }


    int L = 0;
    LL n = M;
    LL ans = 0;
    while(L <= N){
        ans += mp[M-n];

        //cout << "M-n:"<<M-n<<" mp[M-n]:"<<mp[M-n]<<endl;
        //cout << "sum[L+1]" << sum[L+1] << endl;
        mp[sum[L+1]]--;
        n = (M - sum[L+1])%M;
        if(n == 0) n = M;
        L++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4352
n = int(input())
a = list(map(int, input().split()))
mod = pow(10, 9) + 7
b = [0] * (n + 1)
for i in range(n):
    b[i + 1] = a[i] + b[i]
ans = 0
for i in range(n - 1):
    ans += (b[n] - b[i + 1]) * a[i]
    ans %= mod
print(ans)

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

int main() {
  
  int r, d, x;
  cin >> r >> d >> x;;
  
  REP(i,10) {
    x = r * x - d;
    cout << x << endl;
  }
  
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
/*#define mod 1000000007
//#define int long long int
#define INF 1e9+100
#define pair<int,int> pii
#define ff first
#define ss second
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
#define fi(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define pb push_back
#define  debug(x)  cout<<#x<<" "<<x<<endl;*/
int main()
{
	int n,i,j,k;
	cin>>n;
	int a[n+3];
	int val;
	for(i=0;i<n;i++) cin>>a[i];
	for(i=0;i<n;i++)
	{
		j=i-1;
		val=a[i];
		while(j>=0 and a[j]>val)
		{
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=val;
		for(k=0;k<n-1;k++) cout<<a[k]<<" ";
		cout<<a[n-1];
		cout<<endl;
	}
}



Measured memory_bytes: 3100
Module Module1

    Sub Main()
        Dim inParameter() As String
        Dim ret As Integer
        Dim N As Integer
        Dim R As Integer

        inParameter = Console.ReadLine.Split(" "c)
        N = CType(inParameter(0), Integer)
        R = CType(inParameter(1), Integer)

        If N >= 10 Then
            ret = R
        Else
            ret = R + 100 * (10 - N)
        End If

        Console.WriteLine(ret.ToString)
    End Sub

End Module


Measured memory_bytes: 13140
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
string a,b;
int i;

int main(void){
    cin >> a >> b;
    i = stoi(a+b);
    for(int j=1;j<500;j++)if(j*j==i){cout << "Yes"; return 0;}
    cout << "No";
    return 0;
}

Measured memory_bytes: 256