akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define fr(i,x) for( int i=0;i<(x);i++)
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main() 
{ 
    
        string s;
        cin>>s;
        ll h=0,b=0,p=0;
        ll  n=s.size();
        for (int i = 0; i < n; i++) 
        {
       
       if(s[n-1]=='2' || s[n-1]=='4'|| s[n-1]=='5'|| s[n-1]=='7' || s[n-1]=='9')
       {
          h++;
       }
       else if(s[n-1]=='3')
       {
          b++;
       }
       else if(s[n-1]=='0'||s[n-1]=='6'||s[n-1]=='8'||s[n-1]=='1')
       {
          p++;
       }
        }
        if(h>0)
        {
            cout<<"hon"<<endl;
        }
        else if(b>0)
        {
         cout<<"bon"<<endl;
        }
        else
        
          cout<<"pon"<<endl;
       return 0;
       
}

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

int all[200005];
int dp[2000007];
int main()
{
    int t;
    cin>>t;
    for(int i=0;i<t;i++)
    {
        int input;
        cin>>input;
        all[i]=input;
    }
    
    dp[0]=1000007;
    dp[1]=0;
    dp[2]=abs(all[0]-all[1]);
    
    for(int i=3;i<=t;i++)
    {
        dp[i]=min((dp[i-2]+(abs(all[i-3]-all[i-1]))),(dp[i-1]+(abs(all[i-2]-all[i-1]))));
    }
    
    
    cout<<dp[t]<<endl;
    
    //cout << "Hello World!" << endl;
    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,Q;
  string s;
  cin >>N >>Q>>s;
  vector<int>l(Q),r(Q),c(N);
  for (int i=0;i<Q;i++){
    cin >>l.at(i)>>r.at(i);
  }
  int ctemp=0;
  c.at(0)=0;
  for (int i=1;i<N;i++){
    if (s.at(i-1)=='A' && s.at(i)=='C')ctemp++;
    c.at(i)=ctemp;
  }
  
  for (int i=0;i<Q;i++){
    int R=r.at(i)-1;
    int L=l.at(i)-1;
    cout << c.at(R)-c.at(L)<<endl;
  }
  
  
}

Measured memory_bytes: 2176
main :: IO ()
main = do
  ss <- fmap (map read . words) getLine :: IO [Int]
  putStrLn . unwords . map show $ solve ss

solve :: [Int] -> [Int]
solve (x1:y1:x2:y2:_) = x3:y3:x4:y4:[]
  where
    x3 = x2 - y2 + y1
    y3 = y2 + x2 - x1
    x4 = x1 - y2 + y1
    y4 = y1 + x2 - x1


Measured memory_bytes: 508
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    int N;
    cin >> N;
    int a[N];
    int count = 0;
    for(int i = 0; i < N;i++){
        cin >> a[i];
        if(a[i] != i + 1) count++;
    }
    if(count <= 2) cout << "YES" << endl;
    else cout << "NO" << 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>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 2000001
#define inf 1e17
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a,b,a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,n,m,m1,m2,n1,n2,o,p1,p2,p3,p4,
q1,q2,q3,q4,r,s,t,x,y,z,sum,mn,flg,flg1,flg2,id1,id2,id3,lim,cost;

int main()
{
    scanf("%lld",&n);
    n=1000-(n%1000);
    if(n==1000)n=0;
    printf("%lld\n",n);
    // solve();
    return 0;
}
/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 3776
#include <iostream>
#define N 10001


using namespace std;

main(){
  int dp[N];
  int n;
  dp[0]=1;
  for(int i=1;i<N;i++){
    dp[i]=i+dp[i-1];
  }
  while(cin >> n){
    cout << dp[n] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vint;
#define FOR(i,x,y) for(int i=(int)x; i<(int)y; ++i)
#define REP(i,y) FOR(i, 0, y)
constexpr int INF = 1<<30;
int N;
vector<vint> X(18, vint(2));
vint V_(18), V(18), Vb(18);
int search(int F){
  int tmp = 0, I=0, i=0, j, k, ans=0;
Loop1_1:
  V[I] = X[I][F%2];
  V_[I] = V[I];
  tmp += F%2;
  Vb[I] = F%2;
  F>>=1;
  if(++I<N) goto Loop1_1;
  sort(V.begin(), V.begin()+N);
Loop2_1:
  j=i;
Loop2_2:
  if(!(V[i]==V_[j] && (j-i+Vb[j])%2==0)) goto IF2_1;
  ans += j-i;
  k=j-1;
Loop2_3:
  V_[k+1] = V_[k];
  Vb[k+1] = Vb[k]+1;
  if(--k>=i) goto Loop2_3;
  goto END;
IF2_1:
  if(++j<N) goto Loop2_2;
  return INF;
END:
  if(++i<N) goto Loop2_1;
  return tmp&1?INF:ans;
}
int main(){
  cin >> N;
  REP(i,N) cin >> X[i][0];
  REP(i,N) cin >> X[i][1];
  int ans=INF;
  REP(i,1<<N) ans = min(ans, search(i));
  cout << (ans==INF?-1:ans) << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
X = []
for i in range(N):
  X.append(list(map(int, input().split())))
  
cnt = 0
for j in range(N,0,-1):
  A = X[j-1][0] + cnt
  B = X[j-1][1]
  if A%B != 0:
    cnt += B - A%B
    
print(cnt)

Measured memory_bytes: 27380
let N = stdin.ReadLine() |> int
let S = stdin.ReadLine()

let rec solver l r i =
    if r <= l then i
    elif S.[l] = 'R' then solver (l + 1) r i
    elif S.[r] = 'W' then solver l (r - 1) i
    else solver (l + 1) (r - 1) (i + 1)

solver 0 (S.Length - 1) 0 |> stdout.WriteLine


Measured memory_bytes: 28708
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	int i = 0;
	while(true) {
		int x;
		cin>>x;
		++i;
		if(x == 0) break;
		cout<<"Case "<<i<<": "<<x<<endl;
	}
}

Measured memory_bytes: 3068
include Math

points = $<.readlines.map {|l| Complex(*l.split(",").map(&:to_f))}
start_po = p0 = points.sort_by(&:imaginary).last
prev_arg = PI
  
e = Enumerator.new do |y|
  loop do
    points -= [start_po]
    break if points.empty?
    selected = points.map {|po| [po - start_po, po]}
      .reject {|pos| pos.first == 0}
      .sort_by {|pos| a = pos.first.angle + PI - prev_arg; a >= 0 ? a : a + 2 * PI}
      .first.last
    y << selected
    prev_arg = (selected - start_po).angle + PI
    start_po = selected
  end
end

result = e.each_cons(2).map do |p1, p2|
  a = (p1 - p0).abs
  b = (p2 - p0).abs
  c = (p2 - p1).abs
  z = (a + b + c) / 2.0
  sqrt(z * (z - a) * (z - b) * (z - c))
end.sum
puts result


Measured memory_bytes: 7012
n, k = gets.chop.split.map(&:to_i)
m = 1000000007
bincom = 1.upto(n).inject([1]) { |acc, cur| acc << acc.last * cur % m; acc; }
inv = 2.upto(n).inject([1, 1]) { |acc, cur| acc << acc[m%cur] * (m - m/cur) % m; acc; }
bincominv = 1.upto(n).inject([1]) { |acc, cur| acc << acc.last * inv[cur] % m; acc; }

a = gets.chop.split.map(&:to_i).sort
sum = 0
 
t_n = n-1
t_i = 1
loop do
  c = bincom[t_n] * bincominv[k-1] * bincominv[t_n-k+1]
  sum += c * (a[-t_i] - a[t_i-1])
  sum %= m
  break if t_n == k-1
 
  t_n -= 1
  t_i += 1
end
puts sum

Measured memory_bytes: 15356
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    ll n, ans = 0;
    cin >> n;
    ll arr[n + 5];
    map<ll, ll> mp;
    for(int i = 1; i <= n; i++){
        cin >> arr[i];
        mp[i - arr[i]]++;
    }
    for(int i = 1; i <= n; i++){
        if(mp.find(arr[i] + i) != mp.end())
            ans += mp[arr[i] + i];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 16812
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <climits>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <utility>
#include <iostream>
#include <algorithm>
#define mkp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> veci;
typedef set<int> seti;
typedef size_t szt;
const int MAXN = 100014;
const int INF = 0x3f3f3f3f;
ll x[MAXN];
int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    for (int i = 1; i <= n; i++) {
        cin >> x[i];
    }
    if ((x[n] - x[1]) * a <= b) {
        cout << (x[n] - x[1]) * a << endl;
        return 0;
    }
    ll ans = 0;
    for (int i = 2; i <= n; i++) { 
        ans += min((x[i] - x[i - 1]) * a, b);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    while(true){
        char score;
        int m,f,r;
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;
        if(m == -1 || f == -1) score = 'F';
        else if(m + f >= 80) score = 'A';
        else if(m + f >= 65) score = 'B';
        else if(m + f >= 50) score = 'C';
        else if(m + f >= 30){
            if(r >= 50) score = 'C';
            else score = 'D';
        }
        else score = 'F';
        cout << score << endl;
    }
}


Measured memory_bytes: 3104
#include <iostream>
using namespace std;
int main()
{
	int a,b;
	for(;;){
		cin>>a>>b;
		if(a==0 && b==0)break;
		if(a<=b){
			cout<<a<<" "<<b<<endl;
		}
		else if(a>b){
			cout<<b<<" "<<a<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
// Problem : I - Coins
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_i
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define nl cout<<"\n"
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull ;
typedef long double ld;

inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a; a%=b;return gcd(b,a);}
ll power(ll x, ll y){if(y == 0) return 1; ll a = power(x,y/2);if (y % 2 == 0) return a * a; else return x * a * a; }
ll powermod(ll x, ll ex , ll md) {ll ans = 1ll;while (ex > 0) {if (ex & 1ll) ans = (ans * x) % md; ex >>= 1ll;x = (x * x) % md;}return ans;}

const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const ld PI = acos(-1);
const ld eps = 1e-9;

const ll N = 1e4 + 1;
ll n;
ld p[N];
ld dp[N][N]; // dp[i][j] till ith coin and attained j heads
void solve(){
	cin >> n;
 	rep(i , n) cin >> p[i];
 	for(ll i = 0 ; i < n; i++){
 		if(i == 0){
 			dp[0][0] = 1 - p[0];
 			dp[0][1] = p[0];
 		}
 		else{
	 		for(ll j =0 ; j <= n ; j++){
	 			if(j > i + 1) dp[i][j] = 0;
	 			else{
	 				dp[i][j] = dp[i - 1][j - 1]*p[i] + dp[i - 1][j]*(1 - p[i]);	
	 			}
	 		}
	 	}
 	}
 	ld ans = 0;
 	for(ll i = (n + 1)/2 ; i <= n ; i++){
 		ans += dp[n - 1][i];
 	}
 	cout << ans << endl;
}
int main(){
    IOS;
    cout << fixed << setprecision(20);
    ll NTC=1;
    // cin>>NTC;
    ll PTC=0;
    while(PTC++<NTC){
        // cout<<"Case #"<<PTC<<":"<<' ';
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 467840
#include <bits/stdc++.h>
using namespace std;
int N;
int ans = 0;
void dfs(long);
void check(long);

int main()
{
	cin >> N;
	dfs(0);
	cout << ans << endl;
	return 0;
}

void dfs(long x)
{
	if (x > N)
		return;
	check(x);
	if (x<=N)
	{
		dfs(10 * x + 3);
		dfs(10 * x + 5);
		dfs(10 * x + 7);
	}
}

void check(long x) 
{
	string s = to_string(x);
	int exist[3] = { 0 };
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == '3')exist[0] = 1;
		if (s[i] == '5')exist[1] = 1;
		if (s[i] == '7')exist[2] = 1;
	}
	if (exist[0]&&exist[1]&&exist[2])
	{
		if (x<=N)
		{
			ans++;
		}	
	}
}

Measured memory_bytes: 256
import math


def keta(num):
    count = 1
    while num >= 10:
        num = num / 10
        count += 1

    return count


N = int(input())

sqrt_N = int(math.sqrt(N))

A = 1
for i in range(1, sqrt_N+1):
    if N % i == 0:
        A = i

B = N // A

print(max(keta(A), keta(B)))


Measured memory_bytes: 3060
#include "bits/stdc++.h"

using namespace std;



int main(){
	int a,b;
	int tax=0;


	cin >> a>> b;

	for (int i=0; i < 1001 ; i++) {
		if ((int)((double)i*0.08) == a  && (int)((double)i*0.1 )== b) {
			cout << i << endl;
			cin >> a;
			return 0;
		}
	}
	
	cout << -1 << endl;
	cin >> a;
	return 0;

	
}

//x=100/8*a
//x=10b

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = input()
cnt = 0
for i in range(len(n)):
    cnt += int(n[i])
if cnt % 9 == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 74332
#include<stdio.h>
#include<string.h>

int main(){
  int k;
  scanf("%d",&k);
  char s[101];
  scanf("%s",s);

  if(k >= strlen(s))
    printf("%s",s);
  else{
    s[k]='\0';
    printf("%s...",s);
  }
}

Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  ll N, M;
  cin >> N >> M;

  ll ans = 0;
  if (2 * N <= M) {
    ans = N;
    ans += ((M - 2 * N) >= 4 ? (M - 2 * N) / 4 : 0);
  } else {
    ans = M / 2;
  }

  // 解答
  cout << ans << endl;

  return 0;
}


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

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

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

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

	ll a,b,x,y;
	cin >> x >> y;

	b = (y-2*x)/2;
	a = x-b;

	if(a >=0 && b >=0 && 2*a + 4*b == y)
		cout << "Yes\n";
	else
		cout << "No\n";

}




Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <vector>
typedef long long ll;

using namespace std;

void SieveOfEratosthenes(vector<int>& v, int n){
    vector<bool> l(n+1, true);
    for (int i = 2; i <= n; i++){
	if (!l[i]) continue;

	v.push_back(i);
	for (int j = 2; i*j <= n; j++){
	    l[i*j] = false;
	}
    }
}

int main(){
    int N;
    cin >> N;
    vector<int> a;
    SieveOfEratosthenes(a, 55555);

    int cnt = 0;
    int x = 0;
    while (cnt < N){
	if (a[x]%5 == 1){
	    cout << a[x] << " ";
	    cnt++;
	}
	x++;
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
//~ const ll inf = 1e18+5;
ll n, k, fw[100100];
const ll mod = 1e9+7;
ll add(ll a, ll b){
	return (a%mod+b%mod + mod)%mod;
}
ll sub(ll a, ll b){
	return (a%mod -b%mod + mod)%mod;
}
void upd(ll p, ll v){
	for (ll i= p; i <= k+5; i+=(i&(-i)))fw[i] = add(fw[i], v);
}
ll qry(ll p){
	ll res = 0;
	for (ll i= p; i > 0; i -= (i&(-i)))res  = add(res, fw[i]);
	return res%mod;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n >> k;
	ll sumai = 0;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++){
		cin >> a[i];
		sumai += a[i];
	}
	if (sumai < k){
		cout << 0; return 0;
	}
	upd(1, 1);
	upd(2, -1);
	//dp[i] stores the number of ways we can distribute i candies, all possible values have to be updated as we move through the n children
	//in the fenwick, each index is mapped to index+1
	//RUPQ
	for (ll i= 0; i < n; i++){
		//for each child
		for (ll j = k; j >= 0; j--){
			//for each possible value i can modify
				//im essentially doing the same thing here, i can add values to all using a fenwick,
				//there is a faster method by just using a prefix sum array for each child and updating dp values
				//after getting all the prefix values, refer to mcandine.cpp for the code or errichto's github
				//~ for (ll kk = 1; kk <= min(a[i], k-j); kk++){
					//~ dp[kk+j] += dp[j];
				//~ }
				ll qq = qry(j+1)%mod; 
				// we add one to L because if we start from 0, we double count cases such as 6 5, 6 5 0, 6 5 0 0, etc
				ll L = j+1+1, R = min(a[i], k-j)+j+1;
				if (L <= R ){upd(L, qq);upd(min(R+1, k+2), -qq);}//if can update, we update, rmb to MOD!!!!!!!
				
		}
	}
	cout << qry(k+1)%mod;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mn=1e5+7;
ll X[mn];
ll W[mn];
vector<ll> ret;

int main(){
	ll ants,length,time;cin>>ants>>length>>time;
	for(ll a=0;a<ants;++a)cin>>X[a]>>W[a];
	ll passed=0;
	for(ll a=0;a<ants;++a){
		ll n;
		if(W[a]==1){
			n=(X[a]+time)%length;
			passed+=(X[a]+time)/length;
		}else{
			n=((X[a]-time)%length+length)%length;
			passed-=(time-X[a]+length-1)/length;
		}
		ret.push_back(n);
	}
	sort(ret.begin(),ret.end());
	passed%=ants;
	if(passed<0)passed+=ants;
	rotate(ret.begin(),ret.begin()+passed,ret.end());
	for(ll a=0;a<ants;++a)cout<<ret[a]<<endl;
}


Measured memory_bytes: 3700
import scala.io.StdIn._
object Main extends App {
  val Array(a, b, c) = readLine.split(" ")
  if (a == b && b == c) {
    println("No")
  } else if (a != b && b != c && a != c) {
    println("No")
  } else {
    println("Yes")
  }
}


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

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string S[3]; rep (i, 3) cin >> S[i];
	
	int turn = 0;
	string curr = S[turn];
	while((int)S[turn].length() > 0){
		int next = (int)(S[turn][0] - 'a');
		S[turn] = S[turn].substr(1);
		turn = next;
	} // end while

	cout << (char)('A'+turn) << endl;

	return 0;
}

Measured memory_bytes: 256
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print("-1 -1 -1")

Measured memory_bytes: 40684
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
  cin >> s;
  int i,ans1,ans2;
  ans1=0;
  ans2=0;
  vector<char> t1(s.size()),t2(s.size());
  for(i=0;i<s.size();++i)
  {
  if(i%2==0) {t1.at(i)='0';
              t2.at(i)='1';}
  if(i%2==1) {t1.at(i)='1';
              t2.at(i)='0';}
  }
  
   for(i=0;i<s.size();++i)
  {
  if(t1.at(i)==s.at(i)) ans1++;
  if(t2.at(i)==s.at(i)) ans2++;
  }
  if(ans1>ans2) cout << s.size()-ans1;
  else cout << s.size()-ans2;
return 0;}

Measured memory_bytes: 3768
#include<stdio.h>
#include<string.h>

char inp[16];

int main (void) {
	int m, n, i, j, ox, oy;
	scanf(" %d %d", &m, &n);
	for(i = 0; i < m; i++) {
		for (j = 0; j < n; j++) {
			scanf(" %s", &inp);
			if(!strcmp(inp, "snuke")) {
				ox = i;
				oy = j;
				goto prre;
			}
		}
	}

	prre:
	printf("%c%d\n", 'A' + oy, ox + 1);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
const int INF = 1e9;
int gcd(int a, int b) {
	if (a > b) {
		int tmp = b;
		b = a;
		a = tmp;
	}
	int r = b % a;
	while (r != 0) {
		b = a;
		a = r;
		r = b % a;
	}
	return a;
}
int main() {
	int N, X;
	cin >> N >> X;
	vector<int>V(N);
	vector<int>v(N);
	for (int i = 0; i < N; ++i) {
		cin >> V[i];
		v[i] = abs(X - V[i]);
	}
	if (N == 1) {
		cout << v[0] << endl;
		return 0;
	}
	else {
		ll ans;
		for (int i = 0; i < N - 1; ++i) {
			ans = gcd(v[i], v[i + 1]);
			v[i + 1] = ans;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define endl '\n'

const ll MOD = 1000000007;

int main() {
   int H, W, M; scanf("%d%d%d", &H, &W, &M);
   vector<int> rowCnt(H), colCnt(W);
   set<pi> m;
   for (int i = 0; i < M; i++) {
      int h, w; scanf("%d%d", &h, &w);
      m.insert({h - 1, w - 1});
      rowCnt[h - 1]++;
      colCnt[w - 1]++;
   }
   int maxRow = 0, maxCol = 0;
   for (int i : rowCnt)
      maxRow = max(maxRow, i);
   for (int i : colCnt)
      maxCol = max(maxCol, i);
   vector<int> maxRowIdx;
   for (int i = 0; i < H; i++)
      if (rowCnt[i] == maxRow) maxRowIdx.pb(i);
   vector<int> maxColIdx;
   for (int i = 0; i < W; i++)
      if (colCnt[i] == maxCol) maxColIdx.pb(i);
   int ans = maxRow + maxCol - 1;
   if (maxRowIdx.size() * maxColIdx.size() <= M) {
      for (int i : maxRowIdx) {
         for (int j : maxColIdx)
            if (m.find({i, j}) == m.end()) ans = maxRow + maxCol;
      }
   } else {
      ans += 1;
   }
   printf("%d", ans);
   return 0;
}

Measured memory_bytes: 23856
a = gets.split.map(&:to_i)
# p a
b = a[1] - a[0]
c = a[1] + a[0]
# p (b+1..c-1)
for i in (b+1..c-1)
    print i.to_s + ' '
end
# a = [0,1,2,3]

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

void solve(long long N, std::vector<long long> a) {
    long long ans = 0;
    long long num = 1;
    for (long long i = 0; i < a.size(); i++) {
        if (a[i] == num) {
            num++;
        } else {
            ans++;
        }
    }
    if (ans == N) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}

// 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)
int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> a(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>


using namespace std;

int main(){
  int N;
  int a[100000];
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  int count=0;
  int  b=0;
  for(int i=0;i<N-1;i++){
    if(b==1&&a[i]>a[i+1]){
      count++;
      b=0;
      continue;
    }else if(b==-1&&a[i]<a[i+1]){
      b=0;
      count++;
      continue;
    }
    if(b==0){
      if(a[i]<a[i+1]){
        b=1;
        continue;
      }else if(a[i]>a[i+1]){
        b=-1;
        continue;
      }
    }
  }
  cout << count+1 <<endl;
  return 0;
}


Measured memory_bytes: 640
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let n :String  = read();
    let ans = if n.contains("9") == true {
        "Yes".to_string()
    } else {
        "No".to_string()
    };
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define repl(k,n) for(k=0;k<n;++k)

int main() {
	int x;
	cin >> x;
	if (x == 1) {
		cout << 0;
	}
	else {
		cout << 1;
	}
	return 0;
}

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

typedef long long ll;

int n;
pair<int,int> a[200005];
ll cur;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i].second>>a[i].first;
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
        cur+=a[i].second;
        if(cur>a[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

struct edge {
    int from;
    int to;
};

int main()
{
    // input
    int N,M;
    int A[200000], B[200000];
    scanf( "%d %d", &N, &M );
    for ( int i=0; i<M; i++ ) {
        scanf( "%d %d", A+i, B+i );
    }

    // 隣接リスト化
    std::vector<int> alist[100000]; // alist[i]: i+1 の部屋が隣接している部屋番号のリスト
    for ( int i=0; i<M; i++ ) {
        alist[A[i]-1].push_back(B[i]);
        alist[B[i]-1].push_back(A[i]);
    }

    // process
    int cost[100000]; // cost[i] : i + 1 の部屋から部屋1までの最短経路
    int next[100000]; // next[i] : 最短経路で部屋1へ向かうとき,次に向かう部屋は next[i]の部屋
    for ( int i=0; i<N; i++ ) {
        cost[i] = N+1;
    }
    cost[1-1] = 0;

    std::queue<int> q_rooms;
    q_rooms.push(1);
    while ( not q_rooms.empty() ) {
        int current = q_rooms.front();
        q_rooms.pop();
        int newcost = cost[current-1] + 1;
        for ( int i=0; i<alist[current-1].size(); i++ ) {
            int nextroom = alist[current-1][i];
            if ( cost[nextroom-1] > newcost ) {
                cost[nextroom-1] = newcost;
                next[nextroom-1] = current;
                q_rooms.push(nextroom);
            }
        }
    }

    // output
    // No って存在しなくない?
    printf( "Yes\n" );
    for ( int i=1; i<N; i++ ) {
        printf( "%d\n", next[i] );
    }

    return 0;
}


Measured memory_bytes: 11996
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int a[3];
int main() {
	for(int i=0; i<3; i++) cin >> a[i];
	sort(a, a+3);
	cout << a[0] * a[1] / 2;
	return 0;
}


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

typedef long long ll;

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

    ll taka, aoki;
    cin >> taka >> aoki;

    ll t, a;
    for(int i = 1; i < n; i++){
        cin >> t >> a;
        ll times = max(taka/t+(taka%t!=0), aoki/a+(aoki%a!=0));

        taka = times*t;
        aoki = times*a;
   }

    cout << taka+aoki << endl;
    return 0;
}

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

int ma[100][100];

int main() {
	int n, m, a, b, d;
	char t;
	while (cin >> n) {
		if (n == 0) break;
		cin >> m;

		fill(ma[0], ma[100], 114514810);
		for (int i = 0; i < m; i++) {
			cin >> a >> t >> b >> t >> d;
			ma[a][b] = ma[b][a] = (d - 100) / 100;
		}

		bool v[100] = {false};
		v[0] = true;
		d = 0;
		for (int i = 0; i < n - 1; i++) {
			m = 114514810;
			for (int j = 0; j < n; j++) {
				if (ma[0][j] < m && !v[j]) {
					m = ma[0][j];
					b = j;
				}
			}
			v[b] = true;
			d += ma[0][b];
			for (int j = 0; j < n; j++) {
				ma[0][j] = min(ma[0][j], ma[b][j]);
			}
		}
		cout << d << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll L[100010], R[100010];
    rep(i,0,N) cin >> L[i] >> R[i];
    sort(L, L+N, greater<ll>());
    sort(R, R+N);
    ll ans = 0;
    ll res = 0;
    rep(i,0,N){
        res += L[i];
        ans = max(ans, res);
        res -= R[i];
        ans = max(ans, res);
    }
    res = 0;
    rep(i,0,N){
        res -= R[i];
        ans = max(ans, res);
        res += L[i];
        ans = max(ans, res);
    }
    print(2 * ans);
    

}

Measured memory_bytes: 1920
#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define f(i,x,z) for(int i=x;i<z;i++)
#define debug(x) cout<<"DEBUG------> "<<x<<endl
#define endl "\n"

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   long long co=0;
   string aa,bb;
   cin>>aa>>bb;
  	f(i,0,aa.length())
  	{
  		if(aa[i]!=bb[i])
  		{
  			co++;
  		}
  	}
  	cout<<co;

  	return 0;
		
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

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

  int n = s.size();
  int ans = 0;
  rep(i, 0, n) {
    if (s[i] != t[i])
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3800
using System;
using System.Collections.Generic;
namespace I_am_the_brown_coder{
    class Inonoa{
        static void Main(){
            char[] s = Console.ReadLine().ToCharArray();
            int n = s.Length;
            int xs=0;
            for(int i=0;i<n;i++){
                if(s[i]=='x'){
                    xs ++;
                }
            }
            if(xs>7){
                Console.WriteLine("NO");
                return;
            }
            Console.WriteLine("YES");
        }
    }
}

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

int n, k, d, a, fp;
bool bo[102];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	fp = n;
	for(int i = 1; i <= k; ++i) {
		cin >> d;
		for(int i = 1; i <= d; ++i) {
			cin >> a;
			if(bo[a] == 0) --fp;
			bo[a] = 1;
		}
	}
	cout << fp << endl;
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

ll n;
vector<ll> sim(vector<ll> v){
  vector<ll> f(n+1, 0);
  bool g = true;
  for(ll i=0;i<n;i++){
    if(v[i]!=n) g = false;
    f[max(0LL, i-v[i])]++;
    f[min(n, i+v[i]+1)]--;
  }
  if(g){
    re(i, n) std::cout << n << (i==n-1?"\n":" ");
    exit(0);
  }
  ll cnt = 0;
  for(int i=0;i<n;i++){
    cnt += f[i];
    v[i] = cnt;
  }
  return v;
}
int main(int argc, char const *argv[]) {
  ll k;std::cin >> n >> k;
  vll a(n);re(i, n) scanf("%lld", &a[i]);
  for(int j=0;j<k;j++) a = sim(a);
  re(i, n) std::cout << a[i] << (i==n-1?"\n":" ");
  return 0;
}


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

const int N=100005;
int n, m, a[N];
set<int> g[N];

// Union find
int par[N];
void init(int n) {
    for(int i=0; i<=n; i++) {
        par[i]=i;
    }
}

int find(int x) {
    if(x == par[x]) return x;
    return (par[x] = find(par[x]));
}

bool same(int x, int y) {
    return find(x) == find(y);
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(x > y) swap(x, y);
    par[y] = x;
}

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

    cin >> n >> m;
    init(n);
    for(int i=1; i<=n; i++) {
        cin >> a[i];
    }

    for(int i=0; i<m; i++) {
        int x,y; cin >> x >> y;
        unite(x, y);
    }

    for(int i=1; i<=n; i++) {
        g[find(i)].insert(i);
    }

    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if(g[i].empty()) continue;
        vector<int> v;
        for(auto j:g[i]) v.push_back(a[j]);
        for(auto j:v) {
            if(g[i].count(j)>0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11008
/*
created by sanyam singhal
*/

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

#define pb push_back
#define mp make_pair
#define ll long long int
#define mod 1000000007
#define w(t) int t;	cin>>t while(t--)
#define triplet pair<int,pair<int,int>>
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
#define loop(i, k, n) for(ll i=k; i<n; i+=1)
#define loop2(i, k, n) for(ll i=k; i>=n; i--)

const ll inf = 1e18;
int dp[100001][2];

void take_fileIO(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  return;
}

int rec(int k, set<int> &s, int p){
  if(k==0)
    return 1-p;
  if(s.size()==1){
    int div =  (k / *(s.begin()));
    return ( div%2 == 1 ) ? p : 1-p;
  }
  else if(dp[k][p]!=-1)
    return dp[k][p];
  else{

    for(int x : s){
      if(x <= k){
        int z;
        if(dp[k-x][1-p]!=-1)
          z = dp[k-x][1-p];
        else{
          dp[k-x][1-p] = rec(k-x, s, 1-p);
          z = dp[k-x][1-p];
        }
        if(z == p)
          return dp[k][p] = p;
      }
    }
    return dp[k][p] = 1-p;
  }
}

void solve(){
  int n,k; cin>>n>>k;
  set<int>s;
  memset(dp, -1, sizeof(dp));

  for(ll i=0; i<n; i++){
    int data;  cin>>data;
    s.insert(data);
  }
  int result = rec(k, s, 1);
  if(result==1)
    cout<<"First\n";
  else
    cout<<"Second\n";
}

int main(){

  fastIO;
  //take_fileIO();
  solve();
  return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define ll long long
 
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int ans = 0;
  if(B/A <= C) cout << B/A <<endl;
  else cout << C << endl;
}

Measured memory_bytes: 256
#pragma G++ optimize (2)
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <queue>
#define INF 0x3f3f3f3f
#define NO 30005
#define MO 100005
typedef long long ll;
using namespace std;
inline ll read()
{
	char ch = ' ', last;
	ll ans = 0;
	while (ch < '0' || ch > '9')
		last = ch, ch = getchar();
	while (ch >= '0' && ch <= '9')
		ans = ans * 10 + int(ch - '0'), ch = getchar();
	if (last == '-')
		return -ans;
	return ans;
}
void write(ll x)
{
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
//head

int a, b, c;
//variable

void init()
{
	a = read(), b = read(), c = read();
}
//functions

int main()
{
	init();
	for (int i = max(a, b); i >= 0; i--)
		if (a % i == 0 && b % i == 0)
		{
			c--;
			if (!c)
			{
				cout << i << endl;
				return 0;
			}
		}
	return 0;
}
//main


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define writeln printf("\n")
using namespace std;
typedef long long LL;
typedef double DB;
const int MAXN = 20;
const DB eps = 1e-7;
int len;
LL d[MAXN], dp[MAXN][14][3];
LL n, m;
int main()
{
    scanf("%lld%lld", &n, &m);
    cout << n - m + 1;
}
/*
dcbbb
b


*/


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int A;
	int B;
	cin >> A >> B;
	int Min_tax;
	int X;
	int Y;
	
	for(int i = 1;i<1010;i++){
		Min_tax = i;
		X = Min_tax*8/100;
		Y = Min_tax*10/100;
		if(A==X && B==Y){
			cout << Min_tax << endl;
			return 0;
		}
	}
	cout << "-1" << endl;

}


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

int main(){
	
	while(1){
		int sum =0;
		string kazu;
		cin>>kazu;
		
		if(kazu == "0"){
		 break;
		}
			sum=0;
		for(int i=0;i<(int)kazu.size();i++){
			
			sum += kazu[i]-'0';
			
		}
			cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 3196
N = int(input())
A = list(input().split())

# B = [0 for i in range(N)]
med = N // 2
B = ['0' for i in range(N)]
fo = []
# for i in range(med, N):
#     fo.append
if N % 2 == 0:
    f_c = med
    for i in range(0, N, 2):
        B[f_c] = A[i]
        f_c += 1

    # print(f_c)
    # print(B)
    B = B[::-1]
    f_c = med
    for i in range(1, N, 2):
        B[f_c] = A[i]
        f_c += 1

    B = B[::-1]
    # print(B)
    print(' '.join(B))

else:
    B[med] = A[0]
    f_c = med+1
    for i in range(1, N, 2):
        B[f_c] = A[i]
        f_c += 1
    # print(B)
    B = B[::-1]
    # print(B)
    f_c = med
    for i in range(0, N, 2):
        B[f_c] = A[i]
        f_c += 1

    B = B[::-1]
    print(' '.join(B))

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

using namespace std;
typedef pair<int, int> P;

int main(void) {
  int n;
  while (cin >> n, n) {
    vector<P> v(n, P(0, 0));
    int id, m, s;    
    for (int i = 0; i < n; i++) {
      cin >> id;
      v[i].second = id;
      for (int j = 0; j < 4; j++) {
        cin >> m >> s;
        v[i].first += m * 60 + s;
      }
    }
    
    sort(v.begin(), v.end());

    cout << v[0].second << endl;
    cout << v[1].second << endl;
    cout << v[n - 2].second << endl;
  }

  return 0;
}


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

int main() {
    int N; cin >> N;
    int D[N][2];
    for (int i = 0; i < N; i++) cin >> D[i][0] >> D[i][1];
    int cnt = 0;
    bool flag = false;
    for (int i = 0; i < N; i++) {
        if (D[i][0] == D[i][1]) cnt++;
        else cnt = 0;
        if (cnt >= 3) {
            flag = true;
        }
    }
    if (flag) cout << "Yes" << endl;
    else cout  << "No" << endl;
    return 0;
}

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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define loop while(true)
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(v) (v).begin(), (v).end()
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

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

double d,t,s;

int main(){
  cin>>d>>t>>s;
  
  if(d/s>t)cout<<"No";
  else cout<<"Yes";
  
  return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------
#define bitrep(i, n)     for(ll i=0; i<(ll) (1<<n); i++)
#define bis(i, j)        i & (1<<j)

int main(void) {
  int n;
  cin >> n;
  vecll t(n), a(n);
  rep(i,n){
    cin >> t[i] >> a[i];
  }

  ll hyou_t=t[0], hyou_a=a[0];
  REP(i,1,n){
    ll k1 = (hyou_t-1)/t[i]+1;
    ll k2 = (hyou_a-1)/a[i]+1;
    hyou_t = max(k1, k2) * t[i];
    hyou_a = max(k1, k2) * a[i];
  }

  prt(hyou_a+hyou_t);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string s;
  cin >> s;
  int v = 0;
  int c = 0;
  rep(i, (int)s.size()) {
    if (s.at(i) == 'R') {
      c++;
      v = max(v, c);
    } else {
      c = 0;
    }
  }
  cout << v << endl;
  
  return 0;
}

Measured memory_bytes: 3620
N = int(input())
H = list(map(int, input().split()))

dp = [0] * N
dp[1] = dp[0] + abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]))

print(dp[N - 1])

Measured memory_bytes: 20616
// Shift-JIS（シフトジス）

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

int main()
{
    int A, B;
    cin >> A >> B;
    if (B % A == 0) {
        cout << A + B << endl;
    } else {
        cout << B - A << endl;
    }
}

Measured memory_bytes: 256
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

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

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

    int n,m;
    cin >> n >> m;
    vector<int> route(n-1);
    vector<vector<bool> > graph(n+1,vector<bool>(n+1));

    for(int i = 2;i <= n;++i) route[i-2] = i;

    rep(i,m){
        int a,b;
        cin >> a >> b;
        graph[a][b] = true;
        graph[b][a] = true;
    }

    int res = 0;

    do{
        rep(i,n-2){
            if(i == 0){
                if(!graph[1][route[i]]) goto ng;
            }
            if(!graph[route[i]][route[i+1]]) goto ng;
        }
        ++res;
        ng:;
    }while(next_permutation(all(route)));

    cout << res << '\n';

  	return 0;
}


Measured memory_bytes: 256
str = gets.chomp
x,y = gets.chomp.split(" ").map{ |item| item.to_i}
code = str.split("T").map{ |item| item.size}
ans = "No"
move = [[],[]]
num = 0
code.each do |co|
  move[num].push(co) if co != 0
  if num == 0
    num = 1
  else
    num = 0
  end
end
xlist = [0]
if move[0].size != 0
  xlist =[move[0][0]]
  xlist.push(-move[0][0]) if code[0] == 0
  move[0].shift
  move[0].each do |c|
    ti = xlist.size
    ti.times do |n|
      now = xlist.shift
      xlist.push(now + c)
      xlist.push(now - c)
    end
    xlist.uniq!
  end
end
ylist = [0]
if move[1].size != 0
  ylist =[move[1][0],-move[1][0]]
  move[1].shift
  move[1].each do |c|
    ti = ylist.size
    ti.times do |n|
      now = ylist.shift
      ylist.push(now + c)
      ylist.push(now - c)
    end
    ylist.uniq!
  end
end
if ( xlist.include?(x) && ylist.include?(y) )
  ans = "Yes"
end
puts ans


Measured memory_bytes: 4152
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
   
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
   
const int MAX_N=1<<17;
    
ll sum[2*MAX_N-1], part[2*MAX_N-1];
int m;
   
void init(int n){
    m=1;
    while(m<n) m*=2;
}
  
void eval(int k, int l, int r){
    if(part[k]>0){
        sum[k]+=(((ll)(r-l))*part[k]);
        if(k<m-1){
            part[2*k+1]+=part[k];
            part[2*k+2]+=part[k];
        }
        part[k]=0;
    }
}
    
void add(int a, int b, ll x, int k, int l, int r){
	eval(k, l, r);
	if(r<=a || b<=l) return;
    if(a<=l && r<=b){
        part[k]+=x;
        eval(k, l, r);
    }else{
        add(a, b, x, k*2+1, l, (l+r)/2);
        add(a, b, x, k*2+2, (l+r)/2, r);
        sum[k]=sum[2*k+1]+sum[2*k+2];
    }
}
    
ll getsum(int a, int b, int k, int l, int r){
	eval(k, l, r);
    if(b<=l || r<=a){
        return 0;
    }
    if(a<=l && r<=b){
        return sum[k];
    }else{
        return getsum(a, b, 2*k+1, l, (l+r)/2)+getsum(a, b, 2*k+2, (l+r)/2, r);
    }
}
   
int main()
{
    int n, q;
    cin>>n>>q;
    init(n);
    for(int i=0; i<q; i++){
        int tp;
        cin>>tp;
        if(tp==0){
            int s, t; ll x;
            cin>>s>>t>>x;
            add(s-1, t, x, 0, 0, m);
        }else{
            int s, t;
            cin>>s>>t;
            cout<<getsum(s-1, t, 0, 0, m)<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6236
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll,pair<ll, ll>> lpll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

#define deg_to_rad(deg) (((deg)/360)*2*PI)

const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;

const ld PI = (acos(-1));
const ld EPS = 0.0000000001;
// cout << fixed << setprecision(10) << middle << endl;

int main() {
    // input, ready
    string S;
    cin >> S;

    // output
    cout << S.substr(0,3) << endl;

    return 0;
}


Measured memory_bytes: 3632