akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N;
map<string,int>mp;
signed main(){
	cin>>N;
	while(N--){
		string s;cin>>s;
		mp[s]++;
	}
	int mx=0;
	for(auto p:mp)chmax(mx,p.second);
	for(auto p:mp)if(mx==p.second)cout<<p.first<<endl;
}


Measured memory_bytes: 19184
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, a[100010];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, n) {
		if (i % 2 == 0)ans += a[i] * 2;
		else ans -= a[i] * 2;
	}
	ans /= 2;
	cout << ans;
	REP(i, n - 1) {
		ans = (a[i - 1] - ans / 2) * 2;
		cout << " " << ans;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2048
from functools import reduce
import itertools
n = int(input())
s = [input() for i in range(n)]
head = ['M','A','R','C','H']
number = [0]*26
new_s = [i for i in s if i[0] in head]
ans = [0,0,0,1,4,10]
for i in new_s:
    number[ord(i[0])-65] += 1
ans2 = [i for i in number if i!=0]
if len(ans2) <= 2:
    print(0)
else:
    mul = 0
    ans2 = list(itertools.combinations(ans2,3))
    for i in ans2:
        mul += reduce(lambda x,y:x*y,i)
    print(mul)
    

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

int main()
{
    int N;
    cin >> N;
    int t1 = 0, t2 = 0, t4 = 0;
    for (int i = 0; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        if (tmp%4==0) t4++;
        else if(tmp%2==0) t2++;
        else t1++;
    }
    if (t1 > t4+1) cout << "No" << endl;
    else if (t2 >= 1 && t1 > t4) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod ll(1e9+7)
ll exp(ll a,ll b)
{
  if(b==0)
    return 1;
  if(b%2==0)
    return exp(a*a%mod,b/2);
  return a*exp(a*a%mod,(b-1)/2)%mod;
}
int main()
{
  #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
  #endif
   int n,m;
   cin>>n>>m;
   vector<int>adj[m+1];
   for(int i=1; i<=m; i++){
    int size;
    cin>>size;
    while(size--){
      int num;
      cin>>num;
      adj[i].push_back(num);
    }
   }
   vector<int>p(m+1);
   for(int i=1; i<=m; i++)
    cin>>p[i];
   int ans=0;
   for(int i=0; i<(1<<n); i++){
    int cnt=0;
    for(int j=1; j<=m; j++){
      int temp=0;
      for(int k=0; k<adj[j].size(); k++){
        int var=adj[j][k];
        var--;
        if(i&(1<<var)){
          temp++;
        }
      }
      if(temp%2==p[j])
        cnt++;
    }
    if(cnt==m)
      ans++;
   }
   cout<<ans;

   return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep2(i, s, n) for(ll i = s; i < n; i++)
using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> s(h+1);
  vector<vector<int>> mass(h, vector<int>(w, 0));
  rep(i, h){
    cin >> s[i];
    s[i].push_back('#');
  }
  string t(w+1, '#');
  s[h] = t;
  rep(i, h+1){
    int len;
    bool flag = true;
    rep(j, w+1){
      if (s[i][j] == '#'){
        if (!flag){
          rep2(k, j-len, j){
            mass[i][k] += len;
          }
          flag = true;
        }
      }
      else{
        if (flag){
          len = 1;
          flag = false;
        }
        else len++;
      }
    }
  }
  
  rep(i, w+1){
    int len;
    bool flag = true;
    rep(j, h+1){
      if (s[j][i] == '#'){
        if (!flag){
          rep2(k, j-len, j){
            mass[k][i] += len;
          }
          flag = true;
        }
      }
      else{
        if (flag){
          len = 1;
          flag = false;
        }
        else len++;
      }
    }
  }
  int ans = 0;
  rep(i, h)rep(j, w) ans = max(ans, mass[i][j]-1);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 26912
"use strict";
function gcd(a) {
    var f = (a, b) => b ? f(b, a % b) : a;
    var ans = a[0];
    for (var i = 1; i < a.length; i++) {
        ans = f(ans, a[i]); 
    }
    return ans;
}
function Main(input) {
    let lines = input.split("\n");
    let cols = lines[0].split(/\s/).map((v) => v - 0);
    let N = cols[0], X = cols[1];
    let x = lines[1].split(/\s/).map((v) => v - 0);
    let y = [];
    x.forEach(function(v) { y.push(Math.abs(X - v)); });
    console.log(gcd(y));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 1e5 + 5;
ll a[N], b[N], c[N];
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (fopen(".INP", "r")){
                freopen(".INP", "r", stdin);
                freopen(".OUT", "w", stdout);
        }
        ll x, y, A, B, C;
        cin >> x >> y >> A >> B >> C;
        for (int i = 1; i <= A; i++) cin >> a[i];
        for (int i = 1; i <= B; i++) cin >> b[i];
        for (int i = 1; i <= C; i++) cin >> c[i];
        sort(a + 1, a + A + 1, greater<ll>());
        sort(b + 1, b + B + 1, greater<ll>());
        sort(c + 1, c + C + 1, greater<ll>());
        ll sum = 0, l = x, r = y;
        for (int i = 1; i <= x; i++) {
                sum += a[i];
        }
        for (int i = 1; i <= y; i++){
                sum += b[i];
        }
        ll cur = 1;
        a[0] = 1e18;
        b[0] = 1e18;
        while (l >= 0 && r >= 0 && cur <= C){
                if (a[l] >= b[r]){
                        if (b[r] < c[cur]){
                                sum = sum - b[r] + c[cur];
                                cur++;
                                r--;
                        } else {
                                break;
                        }
                } else {
                        if (a[l] < c[cur]){
                                sum = sum - a[l] + c[cur];
                                cur++;
                                l--;
                        } else {
                                break;
                        }
                }
        }
        cout << sum;
}


Measured memory_bytes: 2560
n, z, w = map(int, input().split())
t = tuple(map(int, input().split()))

if n == 1:
    print(abs(t[0] - w))
    exit()

# dp[i][j] := i枚引いた後，jから始めるときの最善スコア
# j=0ならxから，j=1ならyから
# 求めたいのはdp[0][0]
dp = [[0] * 2 for _ in range(n)]

# n-1枚引いた後は分かる
for j in range(2):
    dp[n-1][j] = abs(t[n-2] - t[n-1])

# dp[i+1][j]が分かっているときのdp[i][j]を求める
for i in range(n-2, -1, -1):
    for j in range(2):
        # xスタートの時
        if j == 0:
            # n-i枚残っているので，
            # 取る枚数は1, 2, ..., n-i-1, n-i枚のどれか
            # n-i-i枚までのときは，k枚引くとして以下が考えられる
            l = [dp[i+k][1] for k in range(1, n-i)]
            # n-i枚引くときは
            q = abs(t[n-1] - w) if i == 0 else abs(t[n-1] - t[i-1])
            l.append(q)
            dp[i][j] = max(l)

        else:
            l = [dp[i+k][0] for k in range(1, n-i)]
            if i != 0:
                q = abs(t[n-1] - t[i-1])
                l.append(q)
            dp[i][j] = min(l)

print(dp[0][0])            

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

#define o(output) cout << output << endl

using namespace std;

string s,t,u;
double e;
int a,b,c,d;
char A,B;
priority_queue<int,vector<int>,greater<int> >small;

int main(){
  cin>>a;
  for(int i=a-1;i>0;i--){
    a+=i;
  }
  o(a);
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n - 1);
  for (int& bb : b)
    cin >> bb;

  int sum = b[0] + b[n - 2];
  for (int i = 1; i < n - 1; ++i) {
    sum += min(b[i - 1], b[i]);
  }
  cout << sum << "\n";
  return 0;
}


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


int main()
{
	string s;
	cin>>s;
	if(s=="SUN")
		cout<<7;
	else
		if(s=="SAT")
			cout<<1;
		else
			if(s=="FRI")
				cout<<2;
			else
				if(s=="THU")
					cout<<3;
				else
					if(s=="WED")
						cout<<4;
					else
						if(s=="TUE")
							cout<<5;
						else
							cout<<6;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    // youtube解説
    
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    // 等しい -> 差が0
    rep(i, n) --a[i];
    
    vector<int> acc(n + 1);
    rep(i, n) {
        acc[i + 1] = (acc[i] + a[i]) % k;
    }
    // rep(i, n + 1) cout << acc[i] << " "; cout << endl;
    map<int, int> mp;
    ll ans = 0;
    queue<int> q;
    rep(j, n + 1) { // n + 1!!
        ans += mp[acc[j]];
        ++mp[acc[j]];
        q.push(acc[j]);
        while (sz(q) >= k) { // 長さk未満
            --mp[q.front()];
            q.pop();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 12032
N = int(input())
A = tuple(map(int, input().split()))
MOD = 1000000007

ct = [0, 0, 0]
ans = 1
for a in A:
    cta = ct.count(a)
    if cta:
        ct[ct.index(a)] += 1
        ans = (ans * cta) % MOD
    else:
        print(0)
        exit()
print(ans)


Measured memory_bytes: 85292
#include<iostream>
using namespace std;
int main(){
	int N,H[100];
  int count=1,high=0;
  cin>>N;
  
  for (int i=0;i<N;i++){
  	cin>>H[i];
    if(i==0){
    	high=H[0];
    }else{
    	if(high<=H[i]){
        	count++;
          high=H[i];
        }
    }
  }
  cout <<count;
  return 0;
}

Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();
    let d: i32 = read();
    let e: i32 = read();
    let k: i32 = read();

    let ans = if b - a > k
        || c - a > k
        || d - a > k
        || e - a > k
        || b - c > k
        || b - d > k
        || b - e > k
        || c - d > k
        || c - e > k
        || d - e > k
    {
        ":("
    } else {
        "Yay!"
    };

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define LLI long long int
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}

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

  int N; cin >> N;
  vector<LLI> a(N);
  REP(i,N) cin >> a[i];

  sort(ALL(a));
  reverse(ALL(a));

  unordered_map<LLI,int> umap;

  REP(i,N){
    ++umap[a[i]];
  }

  int ans = 0;
  REP(i,N){
    for(LLI j=(1LL<<32); j>=1; j>>=1){
      if(j <= a[i]) continue;

      if(j-a[i] == a[i]){
	if(umap[a[i]] >= 2){
	  ++ans;
	  umap[a[i]] -= 2;
	  break;
	}
      }else{
	if(umap[a[i]] >= 1 && umap[j-a[i]] >= 1){
	  ++ans;
	  --umap[a[i]];
	  --umap[j-a[i]];
	  break;
	}
      }
    }
  }

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


Measured memory_bytes: 41744
n,m = map(int,input().split())
a = m//n
di = []
for i in range(1, min(a+1,int(m**0.5)+1)):
  if m % i == 0:
    di.append(i)
    if i != m // i and a >=  m // i:
      di.append(m//i)
di.sort()
print(di[-1])

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

int main() {
  int n;
  cin >> n;
  while(n > 0) {
    double m = 0;
    int s[n];
    rep(i,n) {
      cin >> s[i];
      m += s[i];
    }
    m /= n;
    double a = 0;
    rep(i,n) {
      a += (s[i] - m)*(s[i] - m);
    }
    a /= n;
    cout << fixed << setprecision(10) << sqrt(a) << endl;
    cin >> n;
  }

}



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

long long N;
long long p[100005];

int main(){
	cin >> N;
	for(long long i = 0; i < N; i++){
		cin >> p[i];
		p[i]--;
	}
	
	long long ans = 0;
	bool flag = false;
	long long tmp = 0;
	for(long long i = 0; i < N; i++){
		if(p[i] == i){
			tmp++;
			flag = true;
		}else{
			if(flag){
				ans += (tmp + 1)/2;
				tmp = 0;
				flag = false;
			}
		}
	}
	if(flag){
		ans +=(tmp + 1)/2;
		tmp = 0;
		flag = false;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
int x,y;
int mypow(int a,int b){
    if(b==1)return a;
    if(b%2)return a*mypow(a,b-1)%mod;
    int t=mypow(a,b/2);
    return t*t%mod;
}

signed main(){
    cin>>x>>y;
    if((x+y)%3)cout<<0<<endl;
    else if(x*2<y||y*2<x)cout<<0<<endl;
    else{
        int t=(x+y)/3;
        int r=x-t;
        int mot=1,chi=1;
        for(int i=t-r+1;i<=t;i++){
            chi*=i;
            chi%=mod;
        }
        for(int i=1;i<=r;i++){
            mot*=i;
            mot%=mod;
        }
        chi*=mypow(mot,1000000005);
        chi%=mod;
        cout<<chi<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
//////////////      VATSAL AGARWAL       ////////////////////////
////////////// Codeforces id : warhead38 ////////////////////////
////////////// Codechef   id : vatsal38  //////////////////////// 


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define endl '\n'
#define loop(var,a,b,c) for(ll var=a;var<=b;var+=c)
#define intarr(arr,n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i]
#define inparr(arr,n) for(ll i=0;i<n;i++)cin>>arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define newline cout<<endl
#define ump unordered_map<ll,ll>
#define vec vector<ll>
#define mkp make_pair
#define disp(var1,var2) cout<<var1<<" "<<var2<<endl;
#define all(v)             v.begin(),v.end()
#define cout(var) cout<<var<<endl
#define mod2 998244353
#define fbo find_by_order  /// find kth smallest by passing k-1
#define ook order_of_key  //// find no of smaller items less than k
#define teensort(a,r,g,b) a[0]=r;a[1]=g;a[2]=b;sort(a,a+3);
#define ss second
#define ff first
#define displayarray(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
#define pi pair<ll,ll>
#define meramax 1e18
#define meramin -1e18
#define percentile 1000000007
#define PI 3.14159265358979323846
#define input2darr(n,m,in) ll a[n+1][m+1];if(in==0){loop(i,0,n-1,1)loop(j,0,m-1,1)cin>>a[i][j];}else{loop(i,1,n,1)loop(j,1,m,1)cin>>a[i][j];}
#define minheap priority_queue<ll>
#define maxheap priority_queue<ll,vector<ll>,greater<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////                                     ///////////////////////////////////////////////////////////////
////////////////////////////////////////              CODE                   ///////////////////////////////////////////////////////////////
////////////////////////////////////////                                     ///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
void AcDegaYe()
{
    ll a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0)cout(1);
    else if(b==0)cout(2);
    else if(c==0)cout(3);
    else if(d==0)cout(4);
    else cout(5);
}
int main()
{   
    fastio
    //ll t;
    //cin>>t;
    ll t=1;
    while(t--)
    {
        AcDegaYe();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3632
n,*s=open(0).read().split()
l=[]
for i,t in enumerate(sorted(s)):
  if i==0: # 最初の文字列の処理
    b=t
    c=1
    continue
  if t==b: # 前の文字列と等しい時
    c+=1
    if i==int(n)-1:
      l+=[[c,t]]
  else: # 前の文字列と異なる時
    l+=[[c,b]]
    if i==int(n)-1:
      l+=[[c,t]]
    b=t
    c=1
l=sorted(l,key=lambda x:x[0],reverse=True)
m=l[0][0]
for c,s in l:
  if c!=m:break
  print(s)

Measured memory_bytes: 41512
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <utility>
#include <functional>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
  ll n,m;
  cin >> n >> m;
  cout << abs((n-2)*(m-2));
  
  
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int cnt(int x){
  int ans=0;
  for(int i=1;i<=x;i++){
    if(x%i==0)ans++;
  }
  return ans;
}
int main()
{
  int n;cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++){
    if(cnt(i)==8&i%2)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
length, pos = input().split(' ')
length, pos = int(length), int(pos)
target = input()
answer = ''
if pos == 1:
  answer = str(target[pos-1].lower() + target[1:])
elif pos == length:
  answer = str(target[:-1] + target[pos-1].lower())
else:
  answer = str(target[:pos-1] + target[pos-1].lower() + target[pos:])

print(answer)


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b, c;
  cin >> a >> b >> c;
  set<ll> s;
  ll t = 0;
  while(1){
    rep(i,a){
      ++t;
      if(t%60 == c){
        cout << t << endl;
        goto LABEL;
      }
    }
    if(!s.insert(t%60).se){
      cout << -1 << endl;
      break;
    }
    t += b;
  }
LABEL:
  return 0;
}

Measured memory_bytes: 3220
n,q=map(int,input().split())
s=input()
l=[list(map(int,input().split())) for _ in range(q)]
a=[0]*(n-1)
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    a[i]=1
b=[0]*n
for i in range(n-1):
  b[i+1]=b[i]+a[i]
for i in range(q):
  print(b[l[i][1]-1]-b[l[i][0]-1])

Measured memory_bytes: 33080
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace  std;

#define ll long long
#define ull unsigned long long
#define f first
#define s second
typedef pair<int , int > pii;
typedef pair<ll,ll> pll;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

const ll MOD = 998244353;


void min_self(ll &a , ll b){a=min(a,b);}
void max_self(ll &a, ll b){a=max(a,b);}
ll add(ll x, ll y){return (x + y) % MOD;}
ll sub(ll x, ll y){return add(x, MOD - y);}
ll mul(ll x, ll y){return (x * 1ll * y) % MOD;}
ll binpow(ll x, ll y)
{
    ll z = 1;
    while(y > 0)
    {
        if(y % 2 == 1)
            z = mul(z, x);
        x = mul(x, x);
        y /= 2;
    }
    return z;
}
ll inv(ll x){return binpow(x, MOD - 2);}
const int MXN = 1e6+10;
ll fact[MXN];
void fac_pre()
{
    fact[0]=1;
    for(ll i=1; i<MXN; i++){
        fact[i]=mul(fact[i-1],i);
    }
}
ll C(ll n, ll k)
{
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
// BIT //
const int MAXN=2*1e5+10;
vector<int> bit(MAXN,0);
int sump(int idx) {
    int ret = 0;
    for (++idx; idx > 0; idx -= idx & -idx)
        ret += bit[idx];
    return ret;
}

int sum(int l, int r) {
    return sump(r) - sump(l - 1);
}

void upd(int idx, int delta) {
    for (++idx; idx < MAXN; idx += idx & -idx)
        bit[idx] += delta;
}
/////-----//////
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll genRand(ll B) {
    return (ull)rng() % B;
}
///--//
int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    /* KEEP IN MIND
     * take care when sorting a 1 based indexed vector
     * const int N is defined way above in the starting
    */
    ll n;cin>>n;
    vector<char> c;
    while(n){
        int r=n%26;
        if( r== 0) {
            c.push_back('z');
            r=26;
        }
        else c.push_back( (char) 'a'+r-1);
        n-=r;
        n/=26;
    }
    reverse(c.begin(),c.end());
    for(int i=0; i<c.size() ;i++){
        cout<<c[i];
    }
}








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

int main(){
  int N;
  cin>>N;
  vector<pair<int,int>> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i).first;
    A.at(i).second=i+1;
  }
  sort(A.begin(),A.end());
  
  for(int i=0;i<N;i++){
    cout<<A.at(i).second<<" ";
  }
  cout<<endl;
}
    

Measured memory_bytes: 1536
import sys
input = sys.stdin.readline
from collections import *

N, S = map(int, input().split())
A = list(map(int, input().split()))
dp = [[0]*(S+1) for _ in range(N+1)]
dp[0][0] = 1
MOD = 998244353

for i in range(N):
    for j in range(S+1):
        dp[i+1][j] += 2*dp[i][j]
        dp[i+1][j] %= MOD
        
        if j+A[i]<=S:
            dp[i+1][j+A[i]] += dp[i][j]
            dp[i+1][j+A[i]] %= MOD

print(dp[N][S]%MOD)

Measured memory_bytes: 139788
#include<bits/stdc++.h>
using namespace std;
long long X,K,D,XP,KHAR;
int main(){
    cin>>X>>K>>D;
    X=abs(X);
    KHAR=min(K,X/D);
    K-=KHAR;
    X-=KHAR*D;
    if(K%2==0){cout<<X;return 0;} 
    else{cout<<D-X;return 0;}
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

const ll large = 2e17;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n; cin >> n; n = n+1LL;
    vector<ll> arr(n);
    vector<ll>  maxn(n);
    FOR(i,n) cin >> arr[i];
    maxn[0] = 1;
    if(arr[0] > maxn[0]){
        cout << -1 << endl;
        return 0;
    }
    F0R(i,1,n-1){
        maxn[i] = min(large,2LL*(maxn[i-1]-arr[i-1]));
        if(arr[i] > maxn[i]){
            cout << -1 << endl;
            return 0;
        }
//        cerr << i << " " << maxn[i] << endl;
    }
    ll counter = 0;
    ll current = 0;
    for(int i = n-1; i>= 0; i--){
        current += arr[i];
        current = min(current,maxn[i]);
        counter += current;
    }
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};


int main() {
    int N,M; cin>>N>>M;
    vector<int> s(M),c(M);
    for (int i = 0; i < M; ++i) {
        cin>>s[i]>>c[i]; --s[i];
    }
    vector<int>  digit(N,-1);
    if(N==1&&M==0){
        cout<<0<<endl;
        return 0;
    }
    for (int i = 0; i < M; ++i) {
        if(digit[s[i]]>-1&&digit[s[i]]!=c[i]){
            cout<<-1<<endl;
            return 0;
        }
        if(s[i]==0&&c[i]==0&&N>1){
            cout<<-1<<endl;
            return 0;
        }
        digit[s[i]]=c[i];
    }
    if(digit[0]==-1) cout<<1;
    else cout<<digit[0];
    for (int i = 1; i < N; ++i) {
        if(digit[i]==-1) cout<<0;
        else cout<<digit[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define mp make_pair
#define fi first
#define se second
#define pb push_back

LL N,A,B;

int main(){
	
	scanf("%lld%lld%lld",&N,&A,&B);
	
	LL g = N / (A+B);
	LL a = g * A;
	LL b = g * B;
	N -= g * (A+B);
	
	if ( N <= A ){
		a += N;
		N = 0;
	} else {
		a += A;
		N -= A;
		b += N;
	}
	
	printf("%lld\n",a);
	return 0;
}

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

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

int a[10];

int main(){
	int n,k;
	cin >> n >> k;
	rep(i,0,k) cin >> a[i];
	for(;;n++) {
		ostringstream out;
		out << n;
		string str = out.str();
		int len = SZ(str);
		bool ok = 1;
		rep(i,0,len) {
			rep(j,0,k) if(str[i]-'0'==a[j]) {
				ok = 0;
				break;
			}
			if(!ok) break;
		}
		if(ok) { cout<< n <<endl; break; }
	}

	return 0;
}

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

int main()
{
  int64_t N, base = 0;
  cin >> N;
  string S;
  cin >> S;
  for (int i = 0; i < N; i++)
  {
    if (S.at(i) == '1')
      base++;
  }
  int64_t n = 1, m = 1;
  vector<int64_t> r1(N, 0), r2(N, 0);
  reverse(S.begin(), S.end());
  for (int i = 0; i < N; i++)
  {
    r1[i] = n % (base + 1);
    (n *= 2) %= (base + 1);
  }
  if (base > 1)
  {
    for (int i = 0; i < N; i++)
    {
      r2[i] = m % (base - 1);
      (m *= 2) %= (base - 1);
    }
  }
  int64_t r, s1 = 0, s2 = 0;
  stack<int64_t> rs;
  for (int i = 0; i < N; i++)
  {
    if (S.at(i) == '1')
    {
      s1 += r1.at(i);
      s2 += r2.at(i);
    }
  }
  for (int i = 0; i < N; i++)
  {
    if (S.at(i) == '1')
    {
      if (base > 1)
        r = (s2 - r2.at(i) + (base - 1)) % (base - 1);
      else
        r = -1;
      rs.push(r);
    }
    else
    {
      r = (s1 + r1.at(i)) % (base + 1);
      rs.push(r);
    }
  }
  while (rs.size())
  {
    r = rs.top();
    rs.pop();
    if (r == -1)
    {
      cout << 0 << endl;
      continue;
    }
    int64_t x = 1, cnt = __builtin_popcount(r);
    while (cnt != 0)
    {
      r %= cnt;
      cnt = __builtin_popcount(r);
      x++;
    }
    cout << x << endl;
  }
}

Measured memory_bytes: 8152
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;


int main(){
    pair<pair<string,int>, int> r[100];
    int N;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> r[i].first.first >> r[i].first.second;
        r[i].first.second*=-1;
        r[i].second=i+1;
    }
    sort(r,r+N);
    for(int i=0; i<N; i++){
        cout<<r[i].second<<endl;
    }
    return 0;
    
}


Measured memory_bytes: 256
def main():
    a, b = map(int, input().split())
    s = input()

    al = [str(i) for i in range(0, 10)]

    f = 1
    for x in range(len(s)):
        if x == a:
            if s[x] == "-":
                f = 1
            else:
                f = 0
                break
        else:
            if s[x] not in al:
                f = 0
                break

    if f == 1:
        print("Yes")
    else:
        print("No")



if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
////=====BIsmillahir Rahmanir Rahim =====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
         Comilla University

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define fi 2*acos(0.0)
#define ll  long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl printf("\n")
#define infinity 1e16
#define mod 1000000007
#define cn continue
#define csprint1 printf("Case %lld: ", cs++)
#define csprint2 printf("Case %lld:\n", cs++)
#define sf(a) scanf("%lld", &a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define all(v) v.begin(),v.end()

using namespace __gnu_pbds;
using namespace std;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<pl> vpi;
typedef vector<pl> vpl;
typedef tree<pair<ll, int> , null_type, less<pair<ll, int> >, rb_tree_tag, tree_order_statistics_node_update> ost;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

bool checkbit(int mask,int bit){return mask & (1<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

/*----------------------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
/*------------------------------------------------*/

///=====================================///
const int maX=1e6+10;
ll Xor[maX];
ll ara[maX];
ll sum[maX];
int main()
{
    ll n;sf(n);
    for(ll i=1;i<=n;i++)cin>>ara[i];
    for(ll i=1;i<=n;i++){
        Xor[i]=Xor[i-1]^ara[i];
        sum[i]=sum[i-1]+ara[i];
    }
    ll l=1;
    ll ans=0;
    for(ll r=1;r<=n;r++){
        while((Xor[r]^Xor[l-1]) != (sum[r]-sum[l-1]))l++;
        ans+=(r-l+1);
    }
    printf("%lld\n",ans);
return 0;
}


Measured memory_bytes: 8460
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> x(N), y(N);
    rep(i,N){
        cin >> x[i] >> y[i];
    }
    vector<vector<ll>> S(N, vector<ll>(N));
    vector<vector<ll>> SS(N, vector<ll>(N));
    vector<vector<ll>> SX(N, vector<ll>(N));
    vector<vector<ll>> SY(N, vector<ll>(N));
    rep(yi,N)rep(xi,N)rep(i,N){
        if(y[yi] >= y[i] && x[xi] >= x[i]) S[yi][xi]++;
    }
    rep(yi,N)rep(xi,N)rep(i,N){
        if(y[yi] > y[i] && x[xi] > x[i]) SS[yi][xi]++;
    }
    rep(yi,N)rep(xi,N)rep(i,N){
        if(y[yi] > y[i] && x[xi] >= x[i]) SX[yi][xi]++;
    }
    rep(yi,N)rep(xi,N)rep(i,N){
        if(y[yi] >= y[i] && x[xi] > x[i]) SY[yi][xi]++;
    }
    //cout << "a" << endl;
    ll ans = ll(1e18)*4+1;
    rep(yh,N)rep(xh,N)rep(yl,N)rep(xl,N){
        ll ym = yl;
        ll yM = yh;
        ll xm = xl;
        ll xM = xh;
        if(y[ym] > y[yM])swap(ym,yM);
        if(x[xm] > x[xM])swap(xm,xM);
        ll cnt = S[yM][xM] - SY[yM][xm] - SX[ym][xM] + SS[ym][xm];
        if(cnt >= K){
            //cout << ll((y[yM] - y[ym])*(x[xM] - x[xm])) << endl;
            cmin(ans, ll((y[yM] - y[ym])*(x[xM] - x[xm])));
        }
    }
    cout << ans << endl;
}   

Measured memory_bytes: 3700
#include<iostream>
#include<string>
#include<map>
#include<utility>
#include<cstdlib>

struct Array
{
	int len;
	std::map<int, int> dat;	  // idx, val

	Array()
	:	len( 0 )
	{}

	Array( int sz )
	:	len( sz )
	{}
};

int line = 1;
std::string s;
std::map<char, Array> array;	// array name, array data
int bug;

// <assignment>(<array_name>[<expression>]=<expression><new_line>) → <array_name>[<expression>]
std::string lhs( const std::string& assign )
{
	std::string::size_type eq = assign.find( "=" );

	return assign.substr( 0, eq );
}

// <assignment>(<array_name>[<expression>]=<expression><new_line>) → <expression>
std::string rhs( const std::string& assign )
{
	std::string::size_type eq = assign.find( "=" ) + 1;

	return assign.substr( eq );
}

// <array_name>[*] → *
std::string index( const std::string& arr )
{
	std::string::size_type bo = arr.find( "[" ) + 1, bc = arr.find_last_of( "]" );

	return arr.substr( bo, bc - bo );
}

// <expression>を計算
int expr( const std::string& exp )
{
	//std::cout << "<function: expr> expression: " << exp << std::endl;

	if( exp.find( "[" ) == std::string::npos )   // <number>
	{
		//std::cout << "<function: expr> expr " << exp << " = " << atoi( exp.c_str() ) << std::endl;

		return atoi( exp.c_str() );
	}
	else   // <array_name>[<expression>]
	{
		int idx = expr( index( exp ) );
		
		if( idx == -1 )
			return -1;

		//std::cout << "<function: expr> idx: " << idx << std::endl;

		Array arr = array.find( exp[0] )->second;

		/*
		if( arr.dat.find( idx ) == arr.dat.end() )
			std::cout << "<function: expr> undefined! (" << exp[0] << "[" << idx << "])" << std::endl;
		else if( idx >= arr.len )
			std::cout << "<function: expr> out of range! (" << exp[0] << "[" << idx << "])" << std::endl;
		*/
		if( idx >= arr.len || arr.dat.find( idx ) == arr.dat.end() )
		{
			if( !bug )
				bug = line;
			
			return -1;
		}

		return arr.dat[idx];
	}

	return -1;
}

int main()
{
	bool f = false;

	do
	{
		f = false;

		line = 1;
		s.clear();
		array.clear();
		bug = 0;

		while( std::cin >> s )
		{
			if( s == "." )
				break;
			if( bug )
				continue;

			f = true;

			std::string::size_type i = s.find( "=" );
				
			if( i != std::string::npos )   // assignment
			{
				//std::cout << "[assignment]" << std::endl;

				int idx = expr( index( lhs( s ) ) );

				//std::cout << "idx: " << idx << std::endl;

				int v = expr( rhs( s ) );

				if( !bug )
				{
					if( idx < array[s[0]].len )
					{
						array[s[0]].dat[idx] = v;
						//std::cout << "rhs: " << v << std::endl;
					}
					else
					{
						bug = line;
						//std::cout << "out of range! (" << s[0] << "[" << idx << "])" << std::endl;
					}
				}
			}
			else   // declaration
			{
				int idx = expr( index( s ) );
				//std::cout << "idx: " << idx << std::endl;

				if( !bug )
				{
					//std::cout << "[declaration]" << std::endl;
					array[s[0]] = Array( idx );
					//std::cout << "Array " << s[0] << "(len: " << idx << ") was defined." << std::endl;
				}
			}

			++line;
		}

		if( f )
			std::cout << bug << std::endl;
	}while( f );

	return 0;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll isP(ll k){
	for(ll i = 2;i * i <= k;i++){
		if(k % i == 0) return 0;
	}
	return 1;
}
ll gcd(ll a,ll b){
    while(b){
        ll t = b;
        b = a % b;
        a = t;
    }
    return a;
}
int main(){
	ll a,b;
	cin >> a >> b;
	ll t = gcd(a,b);
	if(t == 1){
		cout << 1 << endl;
		return 0;
	}
	ll cnt = 0;
	for(ll i = 1;i <= sqrt(t);i++){
		ll j = t / i;
		if(i * j == t){
			if(isP(i))
				cnt++;
			if(isP(j))
				cnt++;
		}		
	}
	printf("%lld\n",cnt);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int n, tmp;
	cin >> n;
	int ans[n];
	int l= n/2;
	int r = l- (n%2==0?1:-1);
	REP(i, 0, n){
		cin >> tmp;
		if(i % 2 == 0){
			ans[l] = tmp;
			if(n%2 == 0) ++l;
			else --l;
		}
		else{
			ans[r] = tmp;
			if(n%2== 0) --r;
			else ++r;
		}
	}
	REP(i, 0, n) cout << ans[i] << " ";
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    ll N,now;
    cin >> N;
    vector<ll> height(N);
    REP(i,0,N){
        cin >> height[i];
    }

    string ans="Yes";
    RREP(i,0,N){
        if(i==N-1){
            now=height[i];
            continue;
        }
        if(height[i]>=now+2){
            ans="No";
        }
        if(height[i]<now){
            now=height[i];
        }
    }
    P(ans);
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void) {
    int n, i, n2, cnt;
    char s[101];
    scanf("%d", &n);
    scanf("%s", s);
    n2 = n/2;
    cnt = 0;
    if (n2*2 == n) {
        for (i=0; i<n2; i++) {
            if (s[i] == s[i+n2]) {
                cnt++;
            }
        }
        if (cnt == n2) {
            printf("Yes");
            return 0;
        }
    }
    
    printf("No");
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#define mod 1000000007

using namespace std;
typedef long long ll;

int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(b<c||d<a){
		cout<<0<<endl;
	}
	else if(c>=a&&d<=b){
		cout<<d-c<<endl;
	}
	else if(a>=c&&b<=d){
		cout<<b-a<<endl;
	}
	else if(c>=a&&c<=b&&d>=b){
		cout<<b-c<<endl;
	}
	else if(c<=a&&d>=a&&d<=b){
		cout<<d-a<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
object Main{
  def main(args: Array[String]) : Unit = {
    System.err.println("ok")
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val h : Array[Int] = 0 +: (1 to n).toArray.map{_ => sc.nextInt } 

    val dp = new Array[Int](n + 1)
    dp(n) = 0
    dp(n-1) = (h(n-1) - h(n)).abs
    (n-2 to 1 by -1).foreach{ x => 
      dp(x) = Math.min(
        (h(x) - h(x+1)).abs + dp(x+1),
        (h(x) - h(x+2)).abs + dp(x+2)
      )
    }
    println(dp(1))
  }
}



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

int N, W;
const int MAX_N = 100 + 10;
const int MAX_W = 1.0e5 + 100;
int w[MAX_N], v[MAX_N];

ll dp[MAX_N + 1][MAX_W + 1];

ll rec_dp(int i, int j) {
    if (dp[i][j] != -1) {
        return dp[i][j];
    }

    ll ret;
    if (i == N) {
        return dp[i][j] = 0;
    }
    else if (j < w[i]) {
        return dp[i][j] = rec_dp(i + 1, j);
    }
    else {
        return dp[i][j] = max(
            rec_dp(i + 1, j),
            rec_dp(i + 1, j - w[i]) + v[i]);
    }    
}

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; i++) cin >> w[i] >> v[i];

    memset(dp, -1, sizeof(dp));

    cout << rec_dp(0, W) << endl;

    return 0;
}


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

int main(void)
{
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
}


Measured memory_bytes: 3612
#include <stdio.h>

int point(int, int, int);

int main(){
    int m, f, r;
    
    while(1){
        scanf("%d %d %d", &m, &f, &r);
        if(m == -1 && f == -1 && r == -1){
            break;
        }
        point(m, f, r);
    }
    return 0;
}

int point(int m, int f, int r){
    if(m == -1 || f == -1){
        printf("F\n");
        return 0;
    }
    if(m + f >= 80){
        printf("A\n");
    }else if(m + f >= 65){
        printf("B\n");
    }else if(m + f >= 50){
        printf("C\n");
    }else if(m + f >= 30){
        if(r >= 50){
            printf("C\n");
        }else{
            printf("D\n");
        }
    }else{
        printf("F\n");
    }
    return 0;
}


Measured memory_bytes: 2048
import os, sys, re, math, queue

N,M = list(map(int,input().split(' ')))
A = list(map(int,input().split(' ')))

memo = {}
for a in A:
	if a in memo:
		memo[a] += 1
	else:
		memo[a] = 1

for _ in range(M):
	B,C = list(map(int,input().split(' ')))
	if C in memo:
		memo[C] += B
	else:
		memo[C] = B

ret = 0
cnt = 0

key_ary = sorted(memo.keys(),reverse=True)
for k in key_ary:
	tmp = memo[k]
	if cnt + tmp <= N:
		ret += k * tmp
		cnt += tmp
		if cnt >= N:
			break
	else:
		ret += k * (N - cnt)
		break
	
print(ret)

Measured memory_bytes: 32952
# import sys
# input = sys.stdin.readline

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

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




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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int, int>
#define pll pair <ll, ll>
#define gcd __gcd
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

const ll L = 1e5+5;

ll h[L];
ll m[L];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll N, K;
    cin >> N >> K;

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

    m[0] = 0;
    
    // for(ll i=1; i<=K; i++)
    // {
    //     m[i] = abs(h[i] - h[0]);
    // }

    for(ll i=1; i<N; i++)
    {
        m[i] = 1e15; 
        for(ll j=i-1; j>=0 && j>=i-K; j--)
        {
            m[i] = min(m[i], m[j]+abs(h[i]-h[j]));
        }    
    }

    cout << m[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll inf = 1e18;
ll h[100010];
ll dp[100010];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> h[i];
    for (int i = 0; i <= n; i++) dp[i] = inf;
    dp[1] = 0;
    for (int i = 1; i <= n; i++) {
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
suits = ('S', 'H', 'C', 'D')
cards = dict(zip(suits, [[]]*4))
for i in range(n):
    card = input().split()
    cards[card[0]] = cards[card[0]] + [int(card[1])]
a_suit = list(range(1, 14))
for k in suits:
    temp = a_suit[:]
    for c in cards[k]:
        temp.remove(c)
    cards[k] = temp
for s in suits:
    for i in range(len(cards[s])):
        print(s, cards[s][i])


Measured memory_bytes: 5596
import java.util.Scanner;

//AtCoder Beginner Contest 135
//C	City Savers
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt((sc.next()));
		long[] aArr = new long[N + 1];
		for (int i = 0; i <= N; i++) {
			aArr[i] = Long.parseLong(sc.next());
		}
		long[] bArr = new long[N];
		for (int i = 0; i < N; i++) {
			bArr[i] = Long.parseLong(sc.next());
		}
		sc.close();

		long ans = 0;
		for (int i = N - 1; i >= 0; i--) {
			long beated = Math.min(aArr[i + 1], bArr[i]);
			ans += beated;
			aArr[i + 1] -= beated;
			bArr[i] -= beated;
			beated = Math.min(aArr[i], bArr[i]);
			ans += beated;
			aArr[i] -= beated;
		}
		System.out.println(ans);
	}
}


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

int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  if(A >= K){
    cout << K << endl;
  }
  if(A < K && A + B >= K){
    cout << A << endl;
  }
  if(A + B < K && A + B + C >= K){
   cout << A + (K - A - B) * -1 << endl; 
  }
}


Measured memory_bytes: 3636