akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

int main(){
    ios;
    LL(x, k, d);
    x = abs(x);
    ll c = x / d;
    if(k <= c){
        print(x - d * k);
        return 0;
    }
    else{
        k -= c;
        x -= d * c;
        if(k % 2) print(abs(x - d));
        else print(abs(x));
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

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;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  char c;cin>>c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')cout<<"vowel"<<endl;
  else cout<<"consonant"<<endl;
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

bool odd(int n){
  if(n < 10) return true;
  if(n < 100) return false;
  if(n < 1000) return true;
  if(n < 10000) return false;
  if(n < 100000) return true;
  return false;
}

int main() {
	in(int, N);
    ll ans = 0;
    loop(i, N)
      if(odd(i+1))
        ++ans;
	out(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
   double X,Y;
   cin>>X>>Y;
   int count = 0;
   double Z;
   for(int i = 0;i<X;i++){
       double N,D;
       cin>>N>>D;
       //cout<<N<<D<<endl;
       Z=sqrt((N*N)+(D*D));
       //cout<<Z<<endl;
       if(Z<=Y){
       count++;
       }  
   }
   cout<<count<<endl;
    
}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct edge{ll to,cost;};

struct state{ll d,ret,v;};

bool operator> (const state &a,const state &b){
	if(a.d!=b.d) return a.d>b.d;
	else return a.ret>b.ret;
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n,m,l;
	cin>>n>>m>>l;
	vector<vector<edge>> g(n);
	rep(i,m){
		ll a,b,c;
		cin>>a>>b>>c;
		a--,b--;
		g[a].push_back({b,c});
		g[b].push_back({a,c});
	}
	ll q;
	cin>>q;
	vector<vector<P>> dist(n,vector<P>(n,P(inf,inf)));
	rep(st,n){
		priority_queue<state,vector<state>,greater<state>> que;
		dist[st][st]=P(0,0);
		que.push({0,0,st});
		while(!que.empty()){
			auto hoge=que.top();
			que.pop();
			ll v=hoge.v,d=hoge.d,used=hoge.ret;
			if(dist[st][v]<P(d,used)) continue;
			for(auto to:g[v]){
				if(l<to.cost) continue;
				if(to.cost<=l-used){
					if(chmin(dist[st][to.to],P(d,used+to.cost))){
						que.push({d,used+to.cost,to.to});
					}
				}else{
					if(chmin(dist[st][to.to],P(d+1,to.cost))){
						que.push({d+1,to.cost,to.to});
					}
				}
			}
		}
	}
	while(q--){
		ll s,t;
		cin>>s>>t;
		s--,t--;
		if(dist[s][t].fi==inf) cout<<-1<<endl;
		else cout<<dist[s][t].fi<<endl;
	}
}

Measured memory_bytes: 5672
# imos 法
N, K, Q = map(int, input().split())
cs = [0] * N
cs[0] = K
for _ in range(Q):
  A = int(input())
  if A == 1:
    cs[1] -= 1
  elif A == N:
    cs[0] -= 1
    cs[N - 1] += 1
  else:
    cs[0] -= 1
    cs[A - 1] += 1
    cs[A] -= 1
for i in range(1, N):
  cs[i] += cs[i - 1]
for i in cs:
  if i > 0:
    print('Yes')
  else:
    print('No')


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

int main(void){
    ll n,k;
    ll a[200005];
    cin>>n>>k;
    ll mx=0;
    rep(i,n){
        cin>>a[i];
        mx = max(mx,a[i]);
    }

    ll l=1,r=mx;
    ll ans=1000000001;
    while(l<=r){
        ll mid=(l+r)/2;
        ll total=0;
        rep(i,n){
            total+=a[i]/mid+(a[i]%mid!=0)-1;
        }
        if(total<=k){
            ans=min(ans,mid);
            r=mid-1;
        }
        else{
            l=mid+1;
        }
    }
    cout << ans << endl;
}

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

#define endl "\n"
using namespace std;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int a,b;
	cin >> a >> b;
	int cont=1;
	if(b==1){
		cout << 0 << endl;
	}else{
		b-=a;
		cont+=ceil(1.0*b/(a-1));
		cout << cont << endl;
	}
	
	return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, m;
  cin >> n >> m;

  ll ans = 1;

  vector<ll> res;
  for (ll i = 1; i * i <= m; ++i) {
    if (m % i == 0) {
      res.push_back(i);
      res.push_back(m / i);
    }
  }

  for (auto a : res)
    if (a * n <= m) ans = max(ans, a);

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
p0 = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p0
    else:
        return (x*(pow(x,(m-1)//2)**2)%p0)%p0

N = int(input())
A = list(map(int,input().split()))
A = [bin(A[i])[2:] for i in range(N)]
A = ["0"*(60-len(A[i]))+A[i] for i in range(N)]
C = {k:0 for k in range(60)}
for i in range(N):
    for m in range(60):
        if A[i][m]=="1":
            C[59-m] += 1
B = [0 for _ in range(60)]
for k in range(60):
    p = C[k]
    m = N-C[k]
    B[k] = p*m
cnt = 0
for k in range(60):
    cnt = (cnt+B[k]*pow(2,k))%p0
print(cnt)

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
ll const inf = 1LL<<55;

ll dp[1010];
ll sumw[1010];

int main() {

  int N; ll W;
  int tc = 1;
  for(; cin >> N >> W && (N || W); tc++) {

//    watch(N)   watch(W)

    rep(i, 1001) dp[i] = inf;
    dp[0] = 0;

    sumw[0] = 0;
    rep(i, N) {
      int P; cin >> P;
      sumw[i + 1] = sumw[i] + P;
    }

    sumw[N + 1] = inf;

//    rep(i, N + 2) {     cout << sumw[i] << " ";   }cout << endl;

    ll ans = inf;

    if(N == 0) {
      ans = 0;
    }
    else if(N == 1) {
      ans = max(0LL, sumw[1] - W);
    }
    else {
      rep(i, N) {
        int nextidx = upper_bound(sumw, sumw + N, sumw[i] + W) - sumw - 1;
  //      watch(i); watch(nextidx); watch(sumw[nextidx]);
        if(nextidx == N) {
          dp[nextidx] = dp[i] + max(0LL, sumw[nextidx] - sumw[i] - W);
        }
        else {
          dp[nextidx] = min(dp[nextidx], dp[i] + abs(sumw[nextidx] - sumw[i] - W));
          int nextidx2 = nextidx + 1;
          if(nextidx2 == N) {
            dp[nextidx2] = min(dp[nextidx2], dp[i] + max(0LL, sumw[nextidx2] - sumw[i] - W));
          }
          else {
            dp[nextidx2] = min(dp[nextidx2], dp[i] + abs(sumw[nextidx2] - sumw[i] - W));
          }
        }
      }
      ans = dp[N];
    }
    cout << "Case " << tc << ": " << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 2988
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void)
{
	int N, M, C;
	int B[100];
	int A;
	int i, j;
	int ans = 0;
	long tmp;

	cin >> N >> M >> C;
	for (i = 0; i < M; i++) {
		cin >> B[i];
	}
	for (i = 0; i < N; i++) {
		tmp = 0;
		for (j = 0; j < M; j++) {
			cin >> A;
			tmp += B[j] * A;
		}
		tmp += C;
		if (tmp > 0) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
H = [int(x) for x in input().split()]
max_H = H[0]
for i in range(1,len(H)):
    if H[i-1]-H[i] > 1:
        print('No')
        sys.exit(0)
    if max_H-H[i] > 1:
        print('No')
        sys.exit(0)
    if H[i] > max_H:
        max_H = H[i]
print('Yes')

Measured memory_bytes: 14252
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
ll rui[100005]={};
int m;
int n;
int main()
{
  scanf("%d %d",&n,&m);
  for(int i=2;i<=n;i++)
    {
      ll ro;
      scanf("%lld",&ro);
      rui[i]=rui[i-1]+ro;
    }
  int now=1;
  ll ans=0;
  for(int i=0;i<m;i++)
    {
      int ru;
      scanf("%d",&ru);
      int rp=now+ru;
      int a=min(now,rp);
      int b=max(now,rp);
      ans+=(rui[b]-rui[a]);
      now+=ru;
    }
  printf("%lld\n",ans%100000);
  return 0;
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl
#define rep(n, i) for (int i = 0; i < n; i++)

using namespace std;
using i64 = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    int amid, bmid, ans;

    if (n % 2 == 1)
    {
        amid = a[(n - 1) / 2];
        bmid = b[(n - 1) / 2];
        ans = bmid - amid + 1;
    }
    else
    {
        amid = (a[n / 2] + a[n / 2 - 1]);
        bmid = (b[n / 2] + b[n / 2 - 1]);
        ans = (bmid - amid) + 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4840
#include <iostream>
#include <cstring>

using namespace std;

using ll = long long;
constexpr int MAX = 100;

ll comb[MAX][MAX];

void make_com()
{
    memset(comb, 0, sizeof(comb));
    comb[0][0] = 1;
    for (int i = 0; i < 65; i++) {
        for (int j = 0; j <= i; j++) {
            comb[i + 1][j]     += comb[i][j];
            comb[i + 1][j + 1] += comb[i][j];
        }
    }
}

void solve(ll N, ll s, ll M, ll n)
{
    while (s < M) {
        ll j = -1;
        for (ll i = n; i <= N; i++) {
            if (s + comb[i][n] >= M) {
                s += comb[i - 1][n];
                j = i;
                break;
            }
        }

        for (int i = 0; i < N - j; i++) {            
            cout << '0';
        }
        
        if (n > 0) {
            cout << '1';
        }

        n--;        
        N = j - 1;
    }

    cout << endl;
}

bool run()
{
    ll N, M;
    cin >> N >> M;
    if (N == 0 && M == 0) {
        return false;
    }

    if (M == 1) {
        cout << string(N, '0') << endl;
        return true;
    }
    
    make_com();
    
    ll sum = 1;    
    for (ll i = 1; i <= N; i++) {
        sum += comb[N][i];
        if (sum >= M) {
            solve(N, sum - comb[N][i], M, i);
            break;
        }
    }
    return true;
}

int main()
{
    while (run())
        ;    
    return 0;
}

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


int main() {
    int n;
    cin >> n;
    cout << "ABC" << n << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int d = int.Parse(input[0]);
        int t = int.Parse(input[1]);
        int s = int.Parse(input[2]);
        if (t * s >= d)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

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

using namespace std;

int main(void)
{
    string s;
    int ans=0, i;

    cin >> s;

    for(i=0; i<=2; i++){
        if(s[i] == '1'){
            ans++;
        }
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
x, k, d = map(int, input().split(' '))
if x == 0:
	if k&1:
		print(d)
	else:
		print("0")
elif x < 0:
	_max = x + k*d
	if _max <= 0:
		print(abs(_max))
	else:
		k -= (abs(x)//d)
		x += d*(abs(x)//d)
		if k > 0:
			nxt = x + d
			if k&1:
				print(abs(nxt))
			else:
				print(abs(x))
		else:
			print(abs(x))
else:
	_max = x - k*d
	if _max >= 0:
		print(abs(_max))
	else:
		k -= (abs(x)//d)
		x -= d*(abs(x)//d)
		if k > 0:
			nex = x - d
			if k&1:
				print(abs(nex))
			else:
				print(abs(x))
		else:
			print(abs(x))
		

Measured memory_bytes: 61740
import sys

c=0
for s in sys.stdin:
  a,b = map(int,s.split())
  if a==b==0: break
  x=[]
  for i in range(a,b+1):
    if i%4==0:
      if i%400==0: x.append(i)
      elif i%100!=0: x.append(i)
    
  if c: print
  if x==[]: print "NA"
  else:
    for e in x: print e
  c=1

Measured memory_bytes: 4300
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N;
    cin >> N;
    vector<ll> v(N);
    for (auto &&i : v) {
        cin >> i;
    }
    SORT(v);
    ll ans = 0;
    if (N % 2 == 0) {
        ans += -v[N / 2 - 1] + v[N / 2];
        REP(i, N) {
            if (i == N / 2 - 1 || i == N / 2)
                continue;
            else if (i < N / 2)
                ans -= 2 * v[i];
            else
                ans += 2 * v[i];
        }
    } else {
        ll mx = +v[N / 2] + v[N / 2 + 1];
        ll mn = -v[N / 2 - 1] - v[N / 2];
        REP(i, N) {
            bool mxf = true, mnf = true;
            if (i == N / 2 || i == N / 2 + 1)
                mxf = false;
            if (i == N / 2 - 1 || i == N / 2)
                mnf = false;
            if (i <= N / 2) {
                if (mxf)
                    mx -= 2 * v[i];
                if (mnf)
                    mn -= 2 * v[i];
            } else {
                if (mxf)
                    mx += 2 * v[i];
                if (mnf)
                    mn += 2 * v[i];
            }
        }
        ans = max(mx, mn);
    }

    print(ans);
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main() {
  int stack[50], sp = 0, n, i, sum;
  while (scanf("%d", &stack[sp++]) != EOF)
    ;
  for (i = 0; i < sp; i++) {
    int ans = 1000000;
    n = stack[i];
    if (n == 0)
      break;
    for (int a = 0; a <= 50; a++) {
      for (int b = 0; b <= 50; b++) {
        for (int c = 0; c <= 50; c++) {
          sum = (380 * (5 * (a / 5))) * 0.8 + (a % 5) * 380;
          sum += (550 * (4 * (b / 4))) * 0.85 + (b % 4) * 550;
          sum += (850 * (3 * (c / 3))) * 0.88 + (c % 3) * 850;
          if (a * 200 + b * 300 + c * 500 == n) {
            if (sum < ans)
              ans = sum;
          }
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 2564
#include<bits/stdc++.h>
using namespace std;
int n,sum=0,l[205];
int main(){
    cin>>n;
    for(int i=1;i<=2*n;i++) cin>>l[i];
    sort(l+1,l+2*n+1);
    for(int i=1;i<=2*n;i+=2) sum+=l[i];
    cout<<sum<<endl;	
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	string s;
	cin >> s;
	if (s[5] == '0' && (s[6] == '4'||s[6]=='3'||s[6]=='2'||s[6]=='1') ) {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  if (a!=1) cout << 1;
  if (b!=2) cout << 2;
  if (c!=3) cout << 3;
  if (d!=4) cout << 4;
  if (e!=5) cout << 5;
  return 0;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
int main() {
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int x = tx - sx;
  int y = ty - sy;
  string ans = "";
  auto str=[&](string x, int t){
    string res="";
    while(t>0){
      res+=x;
      t--;
    }
    return res;
  };
  string U = "U";
  string D = "D";
  string L = "L";
  string R = "R";
  ans += str(U,y)+str(R,x)+str(D,y)+str(L,x)+str(L,1)+str(U,y+1)+str(R,x+1)+str(D,1)+str(R,1)+str(D,y+1)+str(L,x+1)+str(U,1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

	int p = 0;
	for (; n > 1; n /= 2)
	{
		p ++;
	}

	cout << pow(2, p) << endl;
}


Measured memory_bytes: 256
s = input()

while len(s) > 0:
    # 文字列の後ろから削っていく
    if s[-5:] == "dream":
        s = s[:-5]
    elif s[-7:] == "dreamer":
        s = s[:-7]
    elif s[-5:] == "erase":
        s = s[:-5]
    elif s[-6:] == "eraser":
        s = s[:-6]
    else:
        # どの単語にも一致しなかったら終了
        print('NO')
        exit()

print('YES')


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define inf (int)1e9+7
#define eb emplace_back

const int lim = (int)1e5 + 5;
ll dp[(int)1e5 + 5];
int table[(int)1e5 + 5];
int main() {
    int n, m; cin >> n >> m;
    /*
    rep(i, m) {int a; cin >> a; table[a] = -inf; table[a] = 1; if (table[a - 1] == 1) {cout << 0 << endl; return 0;}}
    rep(i, n + 1) cout << dp[i] << " "; cout << endl;
    rrep(i, 1, lim) {
        if (table[i] == 0 && table[i - 1] == 0) chmax(dp[i], dp[i - 1] + 1);
        if (i - 2 >= 0 && table[i] == 0 && table[i - 2] == 0) chmax(dp[i], dp[i - 2] + 1);
    }
    rep(i, n + 1) cout << dp[i] << " "; cout << endl;
    if (dp[n] >= 0) cout << dp[n] << endl;
    else cout << 0 << endl;
     */
    rep(i, m) {int a; cin >> a; table[a] = 1; if (table[a - 1] == 1) {cout << 0 << endl; return 0;}}
    if (table[1] == 1 && table[2] == 1) {cout << 0 << endl; return 0;}
    if (table[1] == 0) {dp[1] = 1; dp[2] = 1;}
    if (table[2] == 0) dp[2]++;
    rrep(i, 3, n + 1) {
        dp[i] = 0;
        dp[i] += (table[i - 1] == 0 ? dp[i - 1] : 0);
        dp[i] %= inf;
        dp[i] += (table[i - 2] == 0 ? dp[i - 2] : 0);
        dp[i] %= inf;
    }
    //rep(i, n + 1) cout << dp[i] << " "; cout << endl;
    cout << dp[n] << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{

    int N, A[200010] = {};
    cin >> N;

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

    sort(A,A+N);

    for(int i=1;i<N;i++){

        if(A[i-1]==A[i]){
            cout << "NO" <<endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 1024
A=[]
_max = 0
_max2 = 0
N=int(input())
for i in range(N):
    A.append(int(input()))
    if _max<A[-1]:
        _max2,_max=_max,A[i]
    elif _max2<A[-1]:
        _max2=A[i]
    #_,_max2,_max=sorted([A[-1],_max2,_max])

for i in range(N):
    print(_max if _max!=A[i] else _max2)

Measured memory_bytes: 16744
using System;

public static class Solution
{
  private static int[] s_dp;

  public static void Main()
  {
    string[] nk = Console.ReadLine().Split(' ');
    int n = int.Parse(nk[0]);
    int k = int.Parse(nk[1]);
	int[] arr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    s_dp = new int[arr.Length];
    for (int i = 0; i < arr.Length; i++) s_dp[i] = -1;
    Console.WriteLine(Solve(arr, 0, k));
  }

  private static int Solve(int[] arr, int currentPosition, int k)
  {
    if (s_dp[currentPosition] != -1) return s_dp[currentPosition];

    // Already arrived!
    if (currentPosition == arr.Length - 1) return 0;

    int min = int.MaxValue;
    for (int i = 1; i <= k; i++)
    {
      int destination = currentPosition + i;
      if (destination >= arr.Length) break;
      int currentSolution =
        Math.Abs(arr[currentPosition] - arr[currentPosition + i]) + Solve(arr, currentPosition + i, k);
      if (currentSolution < min) min = currentSolution;
    }
    return s_dp[currentPosition] = min;
  }
}

Measured memory_bytes: 43532
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<algorithm>
#include<iostream>
#include<bitset>
#include<functional>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<random>
#include<ctime>
#include<complex>
using namespace std;
typedef long long LL;
mt19937 gene(233);
typedef complex<double> Complex;
#define fi first
#define se second
#define ins insert
#define pb push_back
inline char GET_CHAR(){
	const int maxn = 131072;
	static char buf[maxn],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxn,stdin),p1==p2)?EOF:*p1++;
}
inline int getInt() {
	int res(0);
	char c = getchar();
	while(c < '0') c = getchar();
	while(c >= '0') {
		res = res * 10 + (c - '0');
		c = getchar();
	}
	return res;
}

inline LL fastpo(LL x, LL n, LL mod) {
	LL res(1);
	while(n) {
		if(n & 1) {
			res = res * (LL)x % mod;
		}
		x = x * (LL) x % mod;
		n /= 2;
	}
	return res;
}

inline string itoa(int x, int width = 0) {
  string res;
  if(x == 0) res.push_back('0');
  while(x) {
    res.push_back('0' + x % 10);
    x /= 10;
  }
  while((int)res.size() < width) res.push_back('0');
  reverse(res.begin(), res.end());
  return res;
}
const int _B = 131072;
char buf[_B];
int _bl = 0;
inline void flush() {
	fwrite(buf, 1, _bl, stdout);
	_bl = 0;
}
__inline void _putchar(char c) {
	if(_bl == _B) flush();
	buf[_bl++] = c;
}
inline void print(LL x, char c) {
	static char tmp[20];
	int l = 0;
	if(!x) tmp[l++] = '0';
	else {
		while(x) {
			tmp[l++] = x % 10 + '0';
			x /= 10;
		}
	}
	for(int i = l - 1; i >= 0; i--) _putchar(tmp[i]);
	_putchar(c);
}
const int N = 1000033;
const int LOG = 20;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
int n, m;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
char s[N];
int a[N], sum[N];
int calc(int mn) {
	mn -= n;
	a[n + 1] = 0;
	for(int i = n; i >= 1; i--) {
		a[i] = (s[i] == '0' ? -1 : 1) + a[i + 1];
		a[i] = min(0, a[i]);
	//	printf("a[%d] = %d\n", i, a[i]);
	}
	int mx = 0, cur = 0;
	for(int i = 1; i <= n; i++) {
		if(s[i] == '1') {
			cur += 1;
		}else if(s[i] == '0') {
			cur += -1;
		}else {
			if(cur - 1 + a[i + 1] >= mn) {
				cur -= 1;
			}else cur += 1;
		}
		if(cur < mn) {
		//	cout << '!' << endl;
			mx = mn + n;
			break;
		}
		mx = max(mx, cur);
	}
	///printf("calc %d = %d\n", mn, mx - mn);
	return mx - mn;
}
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	int le = 0, ri = n;
	while(le != ri) {
		int mid1 = (le * 2 + ri) / 3, mid2 = (le + ri * 2 + 2) / 3;
		//cout << le << ' '  << ri << endl;
		int x = calc(mid1), y = calc(mid2);
		if(x < y) {
			ri = mid2 - 1;
		}else if(x > y) le = mid1 + 1;
		else {
			le = mid1 + 1;
		}
	}
	cout << calc(le) << endl;
	/*
	for(int d = 0; d < 2; d++) {
		for(int i = 1; i <= n; i++) {
			a[i] = s[i] == '?' ? d : s[i] - '0';
			cout << a[i];
		}
		cout << endl;
		int mn = 0;
		sum[0] = 0;
		for(int i = 1; i <= n; i++) {
			sum[i] = sum[i - 1] + (a[i] == d ? 1 : -1);
			ans = max(ans, sum[i] - mn);
			mn = min(mn, sum[i]);
		}
	}
	cout << ans << endl;*/
}






Measured memory_bytes: 8700
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll N, A, B, C;
  cin >> N >> A >> B >> C;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }
  vector<char> ans;
  for (int i = 0; i < N; i++) {
    if (i < N - 1 && A == 1 && B == 1 && C == 0 && S[i] == "AB") {
      if (S[i + 1] == "AC") {
        B--;
        A++;
        ans.push_back('A');
      } else {
        A--;
        B++;
        ans.push_back('B');
      }
    } else if (i < N - 1 && A == 1 && B == 0 && C == 1 && S[i] == "AC") {
      if (S[i + 1] == "AB") {
        C--;
        A++;
        ans.push_back('A');
      } else {
        A--;
        C++;
        ans.push_back('C');
      }
    } else if (i < N - 1 && A == 0 && B == 1 && C == 1 && S[i] == "BC") {
      if (S[i + 1] == "AB") {
        C--;
        B++;
        ans.push_back('B');
      } else {
        B--;
        C++;
        ans.push_back('C');
      }
    } else if (S[i] == "AB") {
      if (B < A) {
        A--;
        B++;
        ans.push_back('B');
      } else {
        B--;
        A++;
        ans.push_back('A');
      }
    } else if (S[i] == "BC") {
      if (C < B) {
        B--;
        C++;
        ans.push_back('C');
      } else {
        C--;
        B++;
        ans.push_back('B');
      }
    } else if (S[i] == "AC") {
      if (C < A) {
        A--;
        C++;
        ans.push_back('C');
      } else {
        C--;
        A++;
        ans.push_back('A');
      }
    }
    if (A < 0 || B < 0 || C < 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for (char c : ans) cout << c << endl;
  return 0;
}

Measured memory_bytes: 6736
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<int>> S(H, vector<int>(W));
  rep(i, H) {
    rep(j, W) {
      char c;
      cin >> c;
      S[i][j] = c - '0';
    }
  }

  int ans = INF;
  /* 2bit */
  rep(b, bit(H - 1)) {
    int temp = __builtin_popcount(b);
    int G = temp + 1;

    vector<int> cut(H - 1);
    rep(i, H - 1) {
      if ((b >> i) & 1)
        cut[i] = 1;
      else
        cut[i] = 0;
    }

    vector<int> r2g(H);  // row to group
    rep(i, H - 1) {
      r2g[i + 1] = r2g[i] + cut[i];
    }

    vector<int> group(G);
    rep(i, H) {
      group[r2g[i]] += S[i][0];
    }

    bool ok = true;
    rep(g, G) {
      if (group[g] > K)
        ok = false;
    }
    if (!ok)
      continue;

    repp(j, 1, W - 1) {
      rep(i, H) {
        group[r2g[i]] += S[i][j];
      }

      bool ok = true;
      rep(g, G) {
        if (group[g] > K)
          ok = false;
      }

      if (ok)
        continue;

      temp++;
      rep(g, G) {
        group[g] = 0;
      }
      rep(i, H) {
        group[r2g[i]] += S[i][j];
      }
      ok = true;
      rep(g, G) {
        if (group[g] > K)
          ok = false;
      }
      if (!ok) {
        temp = INF;
        break;
      }
    }
    chmin(ans, temp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
//string binary = bitset<32>(n).to_string();  
lli x,y,d;
void gcd(lli a,lli b){
	if(b==0){
		d=a;
		x=1;
		y=0;
		return ;
	}
	gcd(b,a%b);
	lli temp=x;
	x=y;
	y=temp-(a/b)*y;
	return;
}
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
    lli n;
    cin>>n;
    cout<<(n-2)*180;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main(void)
{
    string S;
    cin >> S;
    int N = S.size();
    rep(i, N)
    {
        if (i % 2 == 0 && S[i] == 'L')
        {
            cout << "No" << endl;
            return 0;
        }
        else if (i % 2 != 0 && S[i] == 'R')
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String flag = br.readLine();
		List<String> pickUP = new LinkedList<String>();
		LinkedList<String> cards = new LinkedList<String>();
		while (!"0 0".equals(flag)) {
			cards.clear();
			int space = flag.indexOf(" ");
			int n = Integer.parseInt(flag.substring(0, space));
			int r = Integer.parseInt(flag.substring(space + 1));
			for (int i = 0; i < n; i++) {
				cards.addFirst(Integer.toString(i + 1));
			}
			for (int i = 0; i < r; i++) {
				String num = br.readLine();
				space = num.indexOf(" ");
				pickUP.clear();
				int from = Integer.parseInt(num.substring(0, space)) - 1;
				int to = Integer.parseInt(num.substring(space + 1)) + from;
				List<String> subList = cards.subList(from, to);
				pickUP.addAll(subList);
				subList.clear();
				cards.addAll(0, pickUP);
			}
			System.out.println(cards.peekFirst());
			flag = br.readLine();
		}
	}
}

Measured memory_bytes: 28416
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] B = new int[N];
    for (int i = 0; i < N; i++) {
      B[i] = sc.nextInt() - (i + 1);
    }
    Arrays.sort(B);
    int mid = B[N / 2];
    long ans = 0;
    for (int i = 0; i < N; i++) {
      ans += Math.abs(B[i] - mid);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 64732
#include<bits/stdc++.h>
using namespace std;
int main() {
 int N;
  cin >> N;
  vector<int> vec(N);
  for (int i=0; i<N; i++)
    cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int a, b;
  for (int i=0; i<N; i+=2) {
    a += vec.at(i);
    if (i+1>N-1)
      break;
    b += vec.at(i+1);
  }
  cout << a-b << endl;
}

Measured memory_bytes: 256
while True:
    m, f, r = map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    elif m ==-1 or f==-1:
        print('F')
    elif m+f >=80:
        print('A')
    elif m+f >= 65 and m+f < 80:
        print('B')
    elif m+f >= 50 and m+f < 65:
        print('C')
    elif m+f >= 30 and m+f < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    elif m+f < 30:
        print('F')


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
int main(){
	for(int i=0;i<2;i++){
		int arr[10]={};
		for(int j=0;j<10;j++)
			cin>>arr[j];
		sort(arr,arr+10);
		cout<<arr[7]+arr[8]+arr[9]<<(i==0?' ':'\n');
	}
}



Measured memory_bytes: 3164
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

x,y,a,b,c=MI()
ps=sorted(LI(),reverse=True)
qs=sorted(LI(),reverse=True)
rs=sorted(LI(),reverse=True)
ps=ps[0:x]
qs=qs[0:y]
u=rs+ps+qs
u.sort(reverse=True)
print(sum(u[0:x+y]))


Measured memory_bytes: 24496
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	long double a,b,c;
	cin>>a>>b>>c;
	if(a+b+2.0*sqrt(a*b)<c)
		cout<<"Yes";
	else 
		cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    string t = s;
    reverse(ALL(t));
    LL ans = 0;
    REP(i,s.size()/2){
        if(s[i] != t[i])ans++;
    }
    PUTS(ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int n;
int a[26];
int b[26];

int main(){
	scanf("%d", &n);
	for(int i=0; i<26; ++i) a[i] = 10000;
	for(int i=0; i<n; ++i){
		char t[51];
		scanf("%s", t);
		string s = t;
		for(int j=0; j<26; ++j) b[j] = 0;
		for(int j=0; j<s.size(); ++j) ++b[s[j] - 'a'];
		for(int j=0; j<26; ++j) a[j] = min(a[j], b[j]);
/*		printf("\n");
		for(int j=0; j<5; ++j) printf("%d\t", a[j]);
		printf("\n");
*/	}
	for(int i=0; i<26; ++i){
		char t;
		t = 'a' + i;
		for(int j=0; j<a[i]; ++j){
			printf("%c", t);
		}
	}
	printf("\n");
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import itertools
import math


def solve(N: int, x: "List[int]", y: "List[int]"):
    seq = range(N)
    comb = math.factorial(N)
    all_distance = [float(0.0)] * comb
    for i, road_map in enumerate(itertools.permutations(seq)):
        for n in range(N - 1):
            n1 = road_map[n]
            n2 = road_map[n+1]
            all_distance[i] += math.sqrt(pow(x[n1] - x[n2],
                                             2) + pow(y[n1] - y[n2], 2))
    print(sum(all_distance) / comb)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, x, y)


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {

    string s, t;    
    cin >> s >> t;

    int cnt, ans = 1000;
    for(int i = 0; i < s.length()-t.length()+1; i++) {
        cnt = 0;
        for(int j = 0; j < t.length(); j++) {
            if(s.at(i+j) != t.at(j)) cnt++;
        }

        ans = min(cnt, ans);
    }

    cout << ans << endl;

    return 0;
}

int min(int a, int b) {
    if(a<b) return a;
    else return b;
}

Measured memory_bytes: 3640
#import collections
#aa = collections.Counter(a) # list to list
#mod = 10**9 + 7
def readInts():
  return list(map(int,input().split()))
def main():
    C = [readInts() for _ in range(3)]
    a = [0] * 3
    b = [0] * 3
    # a[0] = 0としとく
    # 1つ適当に決めることでほかのものが決まる
    # それでちょいちょいやればよーい!
    for i in range(3):
        b[i] = C[0][i] - a[0]
    for i in range(1,3):
        a[i] = C[i][0] - b[0]
    for i in range(3):
        for j in range(3):
            if C[j][i] == a[j] + b[i]:
                pass
            else:
                print('No')
                exit()
    print('Yes')
if __name__ == '__main__':
  main()


Measured memory_bytes: 38256