akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#define ll long long
ll x,k,d;
ll ans;
int main(){
	scanf("%lld%lld%lld",&x,&k,&d);
	ll w=(std::abs(0-x))/d;
//	printf("%lld\n",w);
	if(w<k){
		if(x<=0)x+=w*d;
		if(x>0)x-=w*d;
		k-=w;
		if((k&1)==0)ans=std::abs(x);
		else {
			if(x<=0)x+=d;
			else x-=d;
			ans=std::abs(x);
		}
	}
	else {
	//	printf("in\n");
		if(x<=0)x+=k*d,ans=std::abs(x);
		if(x>0)x-=k*d,ans=std::abs(x);
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 1732
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
Cs = list(map(int, input().split()))

total = 0
prev = None
for A in As:
  total = total + Bs[A-1]
  if prev and prev + 1 == A:
    total = total + Cs[prev-1]
  prev = A

print(total)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int lef[200010],rig[200010],dfn[200010],rak[200010],idx,qzh[200010],N,M;
int qxx[400010][2],tt[200010],nn;
void ad(int u,int v){
	qxx[++nn][0]=v;
	qxx[nn][1]=tt[u];
	tt[u]=nn;
}
void dfs(int u,int fa){
	++idx;dfn[u]=idx;rak[idx]=u;lef[u]=idx;
	for(int i=tt[u];i;i=qxx[i][1]){
		int v=qxx[i][0];
		if(v==fa)	continue;
		dfs(v,u);
	}
	rig[u]=idx;
}
int main(){
	scanf("%d%d",&N,&M);
	for(int i=1,a,b;i<N;i++){
		scanf("%d%d",&a,&b);
		ad(a,b);ad(b,a);
	}
	dfs(1,0);
	for(int i=1,a,b;i<=M;i++){
		scanf("%d%d",&a,&b);
		qzh[lef[a]]+=b;
		qzh[rig[a]+1]-=b;
	}
	for(int i=2;i<=N;i++)	qzh[i]+=qzh[i-1];
	for(int i=1;i<=N;i++)	printf("%d%c",qzh[dfn[i]]," \n"[i==N]);
	return 0;
}

Measured memory_bytes: 19456
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}


ll a,b,c,d,n;
vector<ll>v;
map<ll,ll>m;
string s[3],s2;
void input(){
    cin>>s[0]>>s[1]>>s[2];
}
void src(){
    char ss[3];
    ss[0]=s[0][0];
    ss[1]=s[1][0];
    ss[2]=s[2][0];
    cout<<(char)toupper(ss[0])<<(char)toupper(ss[1])<<(char)toupper(ss[2]);
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

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


Measured memory_bytes: 3088
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <cstdlib>

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pi;

const ll MOD = 1e9+7;

static long gcd(long a, long b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
/*
long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}*/

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

map< ll, ll > prime_factor(ll n) {//素因数分解
    map< ll, ll > ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

ll calcNumOfCombination(ll n, ll r){
    ll num = 1;
    for(ll i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}

int bubblesort(vector<int> array,int size){//バブルソート　転倒数
    int kaisu = 0;
    for(int i = 0; i < size; i++){
        for(int j = i + 1; j < size; j++){
            if(array[i] > array[j]){
                int number = array[i];
                array[i] = array[j];
                array[j] = number;
                kaisu++;
            }
        }
    }
    return kaisu;
}

ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = (sum * i)%MOD;
    }
    return sum;
}

int main() {
   double a,b,x;
   cin >> a >> b >> x;
   double k = x / (a * a);
    double result;
   if(k<=b/2){
       double l = (2*a * k) / b;
        result = atan2(b,l) * 180.0 / M_PI;
   }else{
       double l = (2 * a * k) / a - b;
       result = 90.0 -(atan2(a,b-l) * 180.0 / M_PI);

   }
    printf("%.10lf",result);



}



Measured memory_bytes: 256
#include <stdio.h>

int main(){

	int a=0,b=0;

	while (scanf("%d%d", &a, &b) !=EOF){
		
		if (a + b < 10){
			printf("1\n");
		}else if(a + b < 100){
			printf("2\n");
		}else if (a + b < 1000){
			printf("3\n");
		}else if (a + b < 10000){
			printf("4\n");
		}else if (a + b < 100000){
			printf("5\n");
		}else if (a + b < 1000000){
			printf("6\n");
		}else{
			printf("7\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1012
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define LL long long
using namespace std;
const int N=1e5+5;
int n,u,v,cnt,first[N];
struct edge{int to,next;}e[N<<1];
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
void ins(int u,int v){e[++cnt]=(edge){v,first[u]};first[u]=cnt;}
int dfs(int x,int fa)
{
	int sg=0;
	for(int i=first[x];i;i=e[i].next)
	{
		int to=e[i].to;
		if(to==fa)continue;
		sg^=dfs(to,x)+1;
	}
	return sg;
}
int main()
{
	n=read();
	for(int i=1;i<n;i++)
		u=read(),v=read(),ins(u,v),ins(v,u);
	if(dfs(1,-1))printf("Alice");
	else printf("Bob");
	return 0;
}

Measured memory_bytes: 6784
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc107_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            WriteLine(input[0]-input[1]+1);
        }
    }
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> S(N);
    rep(i, M) {
        int k;
        cin >> k;
        rep(j, k) {
            int s;
            cin >> s;
            S[s - 1].push_back(i);
        }
    }
    vector<int> p(M);
    rep(i, M) cin >> p[i];
    
    int cnt = 0;
    for (int bit = 0; bit < (1 << N); ++bit) {
        vector<int> X;
        rep(i, N) {
            if (bit & (1 << i)) X.push_back(i);
        }
        vector<int> P(M, 0);
        for (int x : X) {
            for (int y : S[x]) ++P[y];
        }
        rep(i, M) P[i] %= 2;
        
        bool judge = true;
        rep(i, M) {
            if (p[i] != P[i]) judge = false;
        }
        if (judge) ++cnt;
    }
    
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  unsigned int start=100000;
  int i,j,k,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    start/=100;
    start*=105;
    start+=999;
    start/=1000;
    start*=1000;
  }
  printf("%d\n",start);
  return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>A(N, 0);
	for (int i = 0; i<N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	for (int i = 0; i < N - 1; i++) {
		if (A[i] == A[i + 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout <<"YES"<< endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<vector>
#include<set>

/*0 1 2 3 4 5 6 7*/
using namespace std;

int slove(){
    int n;
    long long res = 0;
    cin>>n;
    vector<long long> arr(n+1,0);
    vector<long long> dp(n+1,0);
    
    for(int i = 1; i <= n; ++i){
        cin>>arr[i];
    }
    long long left = arr[1];
    for(int i = 2; i <= n; ++i){
        if(i%2 == 1){
            dp[i] = max(dp[i-2] + arr[i],dp[i-1]);
            left += arr[i];
        }else{
            dp[i] = max(dp[i-2] + arr[i],left);
        }
    }

    cout<<dp[n]<<endl;

    return 0;
}

int main(){
    slove();
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n; scanf("%d",&n);
	vector<int> x(n),y(n);
	rep(i,n){
		int u,v; scanf("%d%d",&u,&v);
		x[i]=u+v;
		y[i]=u-v;
	}

	sort(x.begin(),x.end());
	sort(y.begin(),y.end());

	printf("%d\n",max(x[n-1]-x[0],y[n-1]-y[0]));

	return 0;
}


Measured memory_bytes: 4856
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>

using namespace std;

/*const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];

}
*/
int main(){
    int n,m;
    cin>>n>>m;
    vector<bool> b;
    b.assign(n+1,true);
    for(int i = 0; i<m;i++){
      int a;
      cin>>a;
      b[a] = false;
    }

    vector<int> dp(n+1,0);

    dp[0] = 1;
    if(b[1]) dp[1] = 1;

    for(int i = 2; i<n+1; i++){
      if(b[i-1]) dp[i] += dp[i-1];
      if(b[i-2]) dp[i] += dp[i-2];
      dp[i]%=1000000007;
    }

    cout<<dp[n]<<endl;

    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
using namespace std;
int a[5];
int main(){
	scanf("%d%d%d",&a[1],&a[2],&a[3]);
	sort(a+1,a+3+1);
	if(a[1]==a[2]&&a[2]==a[3]) printf("0\n");
	else if((a[3]-(a[1]+a[3]-a[2]))%2==0) printf("%d\n",(a[3]-a[2])+(a[3]-(a[1]+a[3]-a[2]))/2);
	else if((a[3]-(a[1]+a[3]-a[2]))%2!=0) printf("%d\n",(a[3]-a[2])+(a[3]-(a[1]+a[3]-a[2]))/2+2);
}

Measured memory_bytes: 256
n, k, q = [ int(v) for v in input().split() ]
collect_list = [k-q for i in range(n)]

for i in range(q):
    a = int(input()) - 1
    collect_list[a] += 1


for i in range(n):
    print( "Yes" if collect_list[i] > 0 else "No" )

Measured memory_bytes: 51104
S = input()
Q = int(input())
flip = 0
head = []
tail = []
for i in range(Q):
  Query = input().split()
  if len(Query) == 3:
    T,F,C = Query
    F = int(F)-1
    if F^flip == 1:
      tail.append(C)
    else:
      head.append(C)
  else:
    flip ^= 1
if flip:
  head, tail = tail, head
  S = S[::-1]
head = ''.join(head[::-1])
tail = ''.join(tail)
print(head+S+tail)


Measured memory_bytes: 12056
// AOJ 0349: Cyclic Sugoroku
// 2017.10.26

#include <stdio.h>

int q[100002], top, end;
int a[100002], f[100002];

int main()
{
	int n, i, t, ans;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &t);
		t = (t + i) % n;
		a[i] = t, f[t]++;
	}
	ans = 0, top = end = 0;
	for (i = 0; i < n; i++) if (!f[i]) q[end++] = i;
	while (top < end) {
		ans++;
		t = a[q[top++]];
		if (!--f[t]) q[end++] = t;
	}
	printf("%d\n", n - ans);
	return 0;
}

Measured memory_bytes: 2744
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int>a(n);
  for(int i=0;i<m;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int s;
      cin>>s;
      s--;
      a[s] |= 1<<i;
    }
  }
  
  int p=0; 
  for(int i=0;i<m;i++){
    int x;
    cin>>x;
    p|=x<<i;
  }
  
  int ans=0;
  for(int s=0;s<(1<<n);s++){
    int t=0;
    for(int i=0;i<n;i++){
      if(1<<i&s)t^=a[i];
    }
  if(t==p)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
ll gcd(ll a,ll b) 
{ 
	if (a == 0) 
		return b; 
	return gcd(b % a, a); 
} 
bool isprime(ll n)
{
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int main()
{
	ll n;
	cin>>n;
	ll p[n+1],i;
	for(i=1;i<=n;i++)
	{
		cin>>p[i];
	}
	ll ctr=0;
	for(i=1;i<=n;i++)
	{
		if(p[i]!=i)
		{
			ctr++;
		}
	}
	if(ctr==2||ctr==0)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

long long  keta(long long n) {
	long long count = 0;
	while (n > 0) {
		count++;
		n = n / 10;
	}
	return count;
}

int main() {
	long long N;
	cin >> N;
	long long ans = N;
	for (long long A = 1; A*A <= N; A++) {
		long long B = N / A;
		if (ans > keta(B) && A*B == N) {
			ans = keta(B);
		}
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define cs(ans); cout<<setprecision(6)<<fixed<<ans<<endl;
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};	
void solve(){
	ll x;
	cin>>x;
	if(x<=200) cout<<x-100<<endl;
	else{
		ll ans=100,tol=200;
		while(tol<x){
			tol+=(tol/100);
			ans++;
		}
		cout<<ans<<endl;
	}
		
	
	
	
		
	
}
int32_t main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    


Measured memory_bytes: 3624
class fenwick_tree:
    def __init__(self, n=0, T=int):
        self._n = n
        self.data = [T() for _ in range(n)]
        self.T = T
    
    def add(self, p, x):
        p += 1
        while p <= self._n:
            self.data[p - 1] += x
            p += p & -p
    
    def sum(self, l, r):
        return self._sum(r) - self._sum(l)
    
    def _sum(self, r):
        s = self.T()
        while r > 0:
            s += self.data[r - 1]
            r -= r & -r
        return s

import sys
input = sys.stdin.readline
n, q = map(int, input().split())
t = fenwick_tree(n)
a = list(map(int, input().split()))
for i in range(n):
    t.add(i, a[i])
for _ in range(q):
    qtype, op1, op2 = map(int, input().split())
    if qtype == 0:
        t.add(op1, op2)
    else:
        print(t.sum(op1, op2))

Measured memory_bytes: 128692
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
typedef pair<int,int> pii;


long long int G[301][301];

long long int calc_t(int x1, int y1, int x2, int y2){
	return G[y2][x2] - G[y2][x1-1] - G[y1 - 1][x2] + G[y1 - 1][x1 - 1];
}

int N;
int A,B, T;

int avg[102];
int dp[102][2];

vi t;

int main(){
	cin >> N;
	cin >> A >> B;
	cin >> T;
	rep(i,N){
		int n;
		cin >> n;
		t.pb(n);
	}
	sort(all(t), greater<int>());
	dp[0][0]=A;
	dp[0][1]=T;
	avg[0] = dp[0][1] / dp[0][0];
	REP(i ,1, N+1){
		dp[i][0]=dp[i-1][0] + B;
		dp[i][1]=dp[i-1][1] + t[i-1];
		avg[i] = dp[i][1] / dp[i][0];
	}

	cout << *max_element(avg, avg+N+1) << endl;


	return 0;
}

Measured memory_bytes: 1220
#include "bits/stdc++.h"
#define ll long long int
#define ld long double
#define all(x) x.begin(), x.end()
#define pb push_back
#define se second
#define fi first
using namespace std;
typedef pair<ll,ll> pll;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ll n; cin>>n;
    ll x,y,z;
    if(n&1){
        for(ll i=1;i<=3500;i++){
            for(ll j=1;j<=3500;j++){
                ll num = 4*i*j-(i+j)*n;
                ll den = n*i*j;
                if(num>0 and den%num==0){
                    x=i; y=j;
                    z=den/num;
                    cout<<x<<" "<<y<<" "<<z<<endl;
                    return 0;
                }
            }
        }
    }
    else{
        x=n/2; y=n; z=n;
    }
    cout<<x<<" "<<y<<" "<<z<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll n,k;
cin >> n >> k;
ll x[n];
ll ans=0;
for(ll i=0;i<n;i++)cin >> x[i];
for(ll i=1;i<n+1;i++){
    ans+=2*min(abs(x[i-1]),abs(x[i-1]-k));
}
cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
#define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    int n,m;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    int q;
    cin>>q;
    rep(i,q){
        int b,c;
        cin>>b>>c;
        for(int i=b;i<(b+c)/2;i++)swap(v[i],v[c-(i-b)-1]);
    }
    rep(j,n){
        if(!j)cout<<v[0];
        else cout<<" "<<v[j];
    }cout<<endl;
}




Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
#define PI 3.141592
using namespace std;

int main()
{
	int n, i;
	int sum = 0;
	cin >> n;
	vector<int> w(n);
	int half = 0;
	int before = 0;
	int ans1, ans2;

	for (i = 0; i < n; i++) {
		cin >> w[i];
		sum += w[i];
	}
	i = 0;
	half = sum / 2;
	while (before <= half) {
		before += w[i];
		i++;
	}

	ans1 = 2 * before - sum;
	ans2 = sum - 2 * before + 2 * w[i - 1];

	printf("%d", min(ans1, ans2));

	return 0;
}

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

	int a,b,c,d,e,k;
	cin>>a>>b>>c>>d>>e;

	if(a>b){swap(a,b);}
	if(b>c){swap(b,c);}
	if(a>b){swap(a,b);}
	if(d>e){swap(d,e);}
	
	k=a+d-50;

	cout<<k<<endl;

	return 0;
	}


Measured memory_bytes: 3048
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    long long int a;
    double b;
    cin >> a >> b;
    long long int bi = floor(b * 100 + 0.001);
    cout << (a * bi) / 100 << endl;
    return 0;
}

Measured memory_bytes: 3844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] l = new int[n];
		int current = 0;
		for(int i = 0 ; i < n ; i++) {
			l[i] = sc.nextInt();
		}
		int ans = 1;
		for(int i = 1 ; i < n + 1 ; i++) {
			current += l[i - 1];
			if(current <= x) ans++;
		}

		System.out.println(ans);

		sc.close();

	}

}


Measured memory_bytes: 21844
#include <stdio.h>

int main() {
	int a, b;
	int ans;

	scanf("%d %d\n",&a,&b);
	ans = a * b;

	if ((ans % 2) == 0) {
		printf("Even");
	}
	else if ((ans % 2) != 0) {
		printf("Odd");
	}
	return 0;
}

Measured memory_bytes: 128
N=int(input())
Alist=list(map(int,input().split()))
sumheight=0
for n in range(N-1):
    if Alist[n]>Alist[n+1]:
        sumheight+=Alist[n]-Alist[n+1]
        Alist[n+1]=Alist[n]
print(sumheight)

Measured memory_bytes: 32260
#include <iostream>

using namespace std;
int main(){
  int A,B,K;
  cin>>A>>B>>K;
  for(int i=0;i<K;i++){
    if(i%2==0){
      B+=A/2;
      A/=2;
    }else{
      A+=B/2;
      B/=2;
    }
  }
  cout<<A<<" "<<B;
  return 0;
}

Measured memory_bytes: 256
n, q = gets.chomp.split.map(&:to_i)

children = Array.new(n+1).map{[]}

(n-1).times do
  a, b = gets.chomp.split.map(&:to_i)
  children[a] << b
end

scores = Array.new(n+1).map{0}

q.times do
  point, x = gets.chomp.split.map(&:to_i)
  scores[point] += x
end

n.times do |i|
  children[i+1].each do |a|
    score = scores[i+1]
    scores[a] += score
  end
end

puts scores[1..-1].join(" ")


Measured memory_bytes: 26620
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    vector<long long> B(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        B[i] = A[i] - (i + 1);
    }

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

    int m = B[N/2];

    long long ans = 0;
    for(int i = 0; i < N; i++){
        ans += abs(B[i] - m);
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#define N 10
using namespace std;

int h, w, c;
string a[N];
int main()
{
	int i, j;
	cin >> h >> w;
	for (i = 0; i < h; i++) {
		cin >> a[i];
		for (j = 0; j < w; j++) c += a[i][j] == '#';
	}
	if (c != h + w - 1) cout << "Impossible";
    else cout << "Possible" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace kyoupuro
{
    class MainClass
    {
        public static void Main()
        {
            MainClass mainClass = new MainClass();
            mainClass.Start();
        }

        public void Start(){
            var line = Console.ReadLine().Split(' ');
            int N = int.Parse(line[0]), M = int.Parse(line[1]), C = int.Parse(line[2]);
            var B = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int count = 0;

            for (int i = 0; i < N;i++) {
                var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                int sum = C;
                for (int j = 0; j < M; j++) {
                    sum += A[j] * B[j];
                }
                if (sum > 0) count++;
            }

            Console.WriteLine(count);
        }
    }
}




Measured memory_bytes: 13268
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Unit[] arr = new Unit[3 * n];
		TreeSet<Unit> befSet = new TreeSet<>();
		TreeSet<Unit> afSet = new TreeSet<>();
		TreeSet<Unit> stockSet = new TreeSet<>();
		long befScore = 0;
		long afScore = 0;
		for (int i = 0; i < n * 3; i++) {
		    arr[i] = new Unit(i, sc.nextInt());
		    if (i < n * 2) {
		        befSet.add(arr[i]);
		        befScore += arr[i].value;
		    } else {
		        afSet.add(arr[i]);
		        afScore += arr[i].value;
		    }
		}
		for (int i = 0; i < n; i++) {
		    Unit tmp = befSet.pollFirst();
		    befScore -= tmp.value;
		    stockSet.add(tmp);
		}
		long max = befScore - afScore;
		for (int i = 2 * n - 1; i >= n; i--) {
		    if (befSet.contains(arr[i])) {
		        befSet.remove(arr[i]);
		        befScore -= arr[i].value;
		        Unit tmp = stockSet.pollLast();
		        befSet.add(tmp);
		        befScore += tmp.value;
		    } else {
		        stockSet.remove(arr[i]);
		    }
		    afSet.add(arr[i]);
		    afScore += arr[i].value;
		    Unit tmp = afSet.pollLast();
		    afScore -= tmp.value;
		    max = Math.max(max, befScore - afScore);
		}
	    System.out.println(max);
   }
   
   static class Unit implements Comparable<Unit> {
       int id;
       int value;
       
       public Unit(int id, int value) {
           this.id = id;
           this.value = value;
       }
       
       public int hashCode() {
           return id;
       }
       
       public boolean equals(Object o) {
           Unit u = (Unit)o;
           return u.id == id && u.value == u.value;
       }
       
       public int compareTo(Unit another) {
           if (value == another.value) {
               return id - another.id;
           } else {
               return value - another.value;
           }
       }
       
       public String toString() {
           return id + ":" + value;
       }
   }
}




Measured memory_bytes: 114648
/*
by.YXH_XianYu
 */
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>

int a,b;

int main(){

	scanf("%d%d",&a,&b);
	if(0<a)
		printf("Positive\n");
	else if(b<0){
		if(-(b-a-1)&1)
			printf("Negative\n");
		else
			printf("Positive\n");
	}
	else
		printf("Zero\n");
	//system("pause");
	return 0;
}


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

int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >>k;
  bool ok = true;
  
  if (b-a > k) ok = false;
  if (c-a > k) ok = false;
  if (d-a > k) ok = false;
  if (e-a > k) ok = false;
  if (c-b > k) ok = false;
  if (d-b > k) ok = false;
  if (e-b > k) ok = false;
  if (d-c > k) ok = false;
  if (e-c > k) ok = false;
  if (e-d > k) ok = false;
  
  if (ok) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}


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

using namespace std;

int main(){
    string s;
    int n, ans = 1;
    cin >> n;
    cin >> s;
    for(int i = 1; i < n; ++i){
        if(s[i] != s[i - 1])ans++;
    }
    cout << ans;
    return 0;

}


Measured memory_bytes: 512
solve :: Int -> Int -> Int -> Int -> Int -> Int
solve q h s d n = f n
  where
    f :: Int -> Int
    f 0 = 0
    f 1 = best1
    f n = (n `div` 2) * best2 + (n `mod` 2) * best1
    best1 :: Int
    best1 = minimum [q * 4, h * 2, s]
    best2 :: Int
    best2 = min (best1 * 2) d
  

main :: IO ()
main = do
  cont <- getContents
  let [q, h, s, d, n] = map read (words cont)
      answer = solve q h s d n
  putStrLn $ show answer



Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n, x;
	cin >> n >> x;
	vector <int> A(n);
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		if (i > 0) {
			if (A[i] + A[i - 1] > x) {
				int val = min(A[i], A[i] + A[i - 1] - x);
				ans += val;
				A[i] -= val;
				if (A[i] + A[i - 1] > x) {
					ans += (A[i - 1] - x);
					A[i - 1] -= (A[i - 1] - x);
				}
			}
		}
	}
	cout << ans;
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int n,a,ans,tmp=0,best=100000000;cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>a;a*=n;
        tmp+=a;vec[i]=a;
    }
    tmp/=n;
    for(int i=0;i<n;i++){
        if(abs(tmp-vec[i])<best){
            best=abs(tmp-vec[i]);
            ans=i;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
int iinf=1<<30;
double pi=3.141592653589793238462643383279L;
double eps=1e-8;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}


int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n,s;cin>>n>>s;
    ll a[n];
    rep(i,0,n)cin>>a[i];
    ll ini=beki(2,n,mod2);
    ll gn=gyaku(2,mod2);
    ll dp[n+1][s+1];
    memset(dp,0,sizeof dp);
    dp[0][0]=ini;
    rep(i,0,n){
        rep(j,0,s+1){
            (dp[i+1][j]+=dp[i][j])%=mod2;
            if(j+a[i]<=s){
                (dp[i+1][j+a[i]]+=dp[i][j]*gn)%=mod2;
            }
        }
    }
    cout<<dp[n][s]<<endl;
}


Measured memory_bytes: 74028
def main():

    n = int(input())
    A = list(map(int, input().split()))

    from collections import Counter
    C = Counter(A)
    #print(C)

    M = max(A)

    X = [0]*(M+1)
    for i in A:
        j = i*2
        while j <= M:
            X[j] = 1
            j += i
    #print(X)

    ans = 0
    for a in A:
        if C[a] == 1 and X[a] != 1:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 126648
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

a = s()
b = s()

sample = ""
for i in range(len(a)):
	a = a[-1] + a[0:-1]
	if a == b:
		print("Yes")
		exit()
print("No")

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

using namespace std;

int main() {

    int a, b, c;
    cin >> a >> b >> c;

//    int x = 17;
//    int y = 11;
    int n;
//    int N = 100;

    /**
     * 実験
     */
    //    for (int i = 0; i < N; ++i) {
    //         n = i * x;
    //         int t = n % y;
    //
    //         cout << n << ":" << t << endl;
    //    }


    // 実験からB回ループすれば十分であることがわかる

    bool can = false;

    for (int i = 1; i < b+1; ++i) {
        n = i * a;
        int t = n % b;
        if (t == c) {
            // can = true;
              cout << "YES" << endl;
            return 0;
        }
    }


    cout << "NO" << endl;










}


Measured memory_bytes: 256
import  java.util.*;
class Main{
    int n;
    int[] h=new int[101];
    
    Main(){
	Scanner sc=new Scanner(System.in);
	while(true){
	    n=sc.nextInt();
	    if(n==0){
		break;
	    }
	    for(int i=0; i<n+1; i++){
		h[i]=sc.nextInt();
	    }
	    for(int i=0; i<n+1; i++){
		int[] a=new int[101];
		int b=0;
		for(int j=0; j<n+1; j++){
		    if(i!=j){
			a[b]=h[j];
			b++;
		    }
		}
		boolean flg=true;
		int key=a[1]-a[0];
		for(int j=1; j<n; j++){
		    if(key!=a[j]-a[j-1])flg=false;
		}
		if(flg){
		    System.out.println(h[i]);
		    break;
		}
	    }
	}
			       
       
    }

    public static void main(String[] args){
	new Main();
    }
}

Measured memory_bytes: 39636
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin>>s;
    int n, ans = 0;

    for (int i=0; i<(n=s.size())/2; i++) {
        if (s[i] != s[n-1-i]) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int k, x; cin >> k >> x;
    FOR(i, x - k + 1, x + k){
        if(i != x - k + 1) cout << " ";
        cout << i;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

int main(){
	//標準入力
	std::string s[3];
	std::cin>>s[0]>>s[1]>>s[2];
	//処理
	for(size_t i=0;i<3;i++){
		std::cout<<(char)(s[i][0]+('A'-'a'));
	}
	std::cout<<std::endl;
	//出力
	

	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
X = list(map(int, input().split()))
if N >= M:
    print(0)
    exit()
X.sort()
leng = []
for i in range(1, M):
    leng.append(X[i] - X[i-1])
ans = sorted(leng, reverse = True)
print(sum(ans[N - 1:]))

Measured memory_bytes: 13960
#include <iostream>

using namespace std;

int main()
{
    int N,K;

    cin >> N >> K;

    int dp[3][3][N];
    int menu[N];

    for(int i=0; i<N; ++i) {
        menu[i]=-1;
    }

    for(int i=0; i<K; ++i) {
        int a,b;
        cin >> a >> b;
        menu[a-1]=b-1;
    }

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

    if(menu[0]!=-1 && menu[1]!=-1) {
        dp[menu[0]][menu[1]][1]=1;
    } else if(menu[0]!=-1) {
        dp[menu[0]][0][1]=1;
        dp[menu[0]][1][1]=1;
        dp[menu[0]][2][1]=1;
    } else if(menu[1]!=-1) {
        dp[0][menu[1]][1]=1;
        dp[1][menu[1]][1]=1;
        dp[2][menu[1]][1]=1;
    } else {
        for(int i=0; i<3; ++i) {
            for(int j=0; j<3; ++j) {
                dp[i][j][1]=1;
            }
        }
    }

    for(int d=2; d<N; ++d) {
        if(menu[d]!=-1) {
            for(int i=0; i<3; ++i) {
                for(int j=0; j<3; ++j) {
                    if(j!=menu[d]) {
                        dp[i][j][d]=0;
                    } else {
                        dp[i][j][d]=dp[0][i][d-1]+dp[1][i][d-1]+dp[2][i][d-1];
                        if(i==j) dp[i][j][d]+=10000-dp[i][i][d-1];
                        dp[i][j][d]%=10000;
                    }
                }
            }
        } else {
            for(int i=0; i<3; ++i) {
                for(int j=0; j<3; ++j) {
                    dp[i][j][d]=dp[0][i][d-1]+dp[1][i][d-1]+dp[2][i][d-1];
                    if(i==j) dp[i][j][d]+=10000-dp[i][i][d-1];
                    dp[i][j][d]%=10000;
                }
            }
        }
    }

    int ans=0;

    for(int i=0; i<3; ++i) {
        for(int j=0; j<3; ++j) {
            ans+=dp[i][j][N-1];
            ans%=10000;
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3076
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	building := make([][][]int, 4)
	for i, _ := range building {
		building[i] = make([][]int, 3)
		for j, _ := range building[i] {
			building[i][j] = make([]int, 10)
		}
	}
	for i := 0; i < n; i++ {
		var b, f, r, v int
		fmt.Scan(&b, &f, &r, &v)
		building[b-1][f-1][r-1] += v
	}
	for i := 0; i < 4; i++ {
		for j := 0; j < 3; j++ {
			residents := ""
			for k := 0; k < 10; k++ {
				residents += " " + strconv.Itoa(building[i][j][k])
			}
			fmt.Println(residents)
		}
		if i != 3 {
			fmt.Println("####################")
		}
	}
}



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

int main () {
  int a, b, K;
  cin >> a >> b >> K;
  int count = 0;
  if (a > b) {
   for (int i = b; i >= 1; i--) {
    if ((a%i == 0) && (b%i == 0)) count ++;
    if (count == K){
      cout << i << endl;
      break;
    }
   }
  }
  else{
   for (int i = a; i >= 1; i--) {
    if ((a%i == 0) && (b%i == 0)) count ++;
    if (count == K){
      cout << i << endl;
      break;
    }
   }
  }
}

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

using namespace std;
#define all(v) v.begin(), v.end()
const int N = 1e5 + 5;
int p[N], q[N], a[N], b[N], par[N], sz[N];

int getpar(int v) {return par[v] = (par[v] == v ? v : getpar(par[v]));}
void Merge(int u, int v) {
    u = getpar(u), v = getpar(v);
    if (u == v) return ;
    par[u] = par[v], sz[v] += sz[u];
    return ;
}
int Solve(vector <int> v1, vector <int> v2) {
    int n = v1.size();
    for (int i = 0; i < n; i++) p[i] = i;
    for (int i = 0; i < n; i++) q[i] = i;
    for (int i = 0; i < n; i++) par[i] = i, sz[i] = 1;
    sort(p, p + n, [&](int i, int j){return v1[i] < v1[j];}), sort(q, q + n, [&](int i, int j){return v2[i] < v2[j];});
    for (int i = 0; i < n; i++) Merge(p[i], q[i]);
    for (int i = 1; i < n; i++) if (v1[p[i]] == v1[p[i - 1]]) Merge(p[i], p[i - 1]);
    int res = 0;
    for (int i = 0; i < n; i++) if (par[i] == i) res += sz[i] + 1;
    return res - 2;
}
int32_t main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i], a[n] ^= a[i];
    for (int i = 0; i < n; i++) cin >> b[i], b[n] ^= b[i];
    vector <int> v1, v2;
    for (int i = 0; i <= n; i++) if (a[i] != b[i]) v1.push_back(a[i]), v2.push_back(b[i]);
    if (a[n] == b[n]) v1.push_back(a[n]), v2.push_back(b[n]);
    sort(a, a + n + 1), sort(b, b + n + 1);
    for (int i = 0; i <= n; i++) if (a[i] != b[i]) return cout << -1 << "\n", 0;

    return cout << Solve(v1, v2) << "\n", 0;
}


Measured memory_bytes: 7188
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int alice = 0;
		int bob = 0;
		List<Integer> x = new ArrayList<>();
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		String cards = sc.nextLine();
		String dc[] = cards.split(" ");
		for (int i = 0; i < N; i++) {
			x.add(Integer.parseInt(dc[i]));
		}
		Comparator<Integer> c = new Comparator<Integer>() {
			@Override
			public int compare(Integer o1, Integer o2) {
				return o2.compareTo(o1);
			}
		};
		Collections.sort(x, c);
		for (int j = 0; j < N; j++) {
			if (!x.isEmpty()) {
				alice += x.get(0);
				x.remove(0);
			}
			if (!x.isEmpty()) {
				bob += x.get(0);
				x.remove(0);
			}
		}
		System.out.println(alice - bob);
	}
}

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

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

    int n, l;
    cin >> n >> l;

    int a = 0;
    for (int i = 0; i < n; i++) a += l+i;
    if (l > 0) cout << a - l << endl;
    else if (l+n-1 < 0) cout << a - (l+n-1) << endl;
    else cout << a << endl;
}





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

int MAX = 1e9+7;

int power (int value, int times) {
    if (times == 1)
        return value;

    long long int half = power(value, times/2) % MAX;

    (half *= half ) %= MAX;

    if (times&1)
        return (half*value) % MAX;
    else 
        return half;
}

int combination(int num, int total) {
/*
    num = 0;
    total = 3;
  */
    long long int divider = 1;

    long long int result = 1;
    for (int i = 0; i < num; i++) {
        (result *= total) %= MAX;
        (divider *= i+1 ) %= MAX;
        total--;
    }

    return (result * power(divider, MAX-2)) % MAX;
}

int main(){

    int X, Y;
    cin >> X >> Y;

    int ways = 0;
    if (((2*Y-X) % 3 == 0) && ((2*X-Y) %3 == 0)) {


        int a = (2*Y-X)/3;
        int b = (2*X-Y)/3;

        if (a >= 0 && b >= 0)
//       cout << a << " " << b << "\n"; 
        ways = combination(a, a+b);

    }

    cout << ways << "\n";

    return 0;
}


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


for i in range(a, b+1):
	if b-a >= k:
		print("OK")
		break
	elif i % k == 0:
		print("OK")
		break
	elif (i % k != 0) and (i == b):
		print("NG")
		break

Measured memory_bytes: 9092