akhauriyash/Code-Regression huggingface dataset:
// Created by ahmed_drawy on 10/09/19.
///dp educational contest atcoder - vjudge
#include <bits/stdc++.h>
#include <string.h>
#pragma clang diagnostic push
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
using namespace std;
#define lp(i,start , end)       for(int i = start ; i<end ; ++i)
#define lllp(i,start , end)       for(ll i = start ; i<end ; ++i)
#define inN(arr ,  n) for(int i = 0 ; i< n ; ++i)  cin>>arr[i];
#define Rlp(i,start , end)      for(int i = start ; i>end ; --i)
#define all(v)                   ((v).begin(),(v).end())
#define sz(v)                  (int)((v).size())
#define clr(v,d)                memset(v , d , sizeof(v))
#define inf 0x3f3f3f3f
//#define dbg (v)    for(auto it : v)cout<<it<<' ';
typedef long long               ll;
typedef vector<int>             vi;
typedef vector  <ll>            vll;
typedef vector<vector<int> >    adj;
typedef pair<int ,int>          pii;
const double EPS =1e-7;
const int OO = 1e6;
#define endl '\n'
#define cint(c) (int)c -'0';
#define itc(c) (char)c +'A';
bool sortpair( const pair<int , int> & x, const pair<int , int> & y){
    return  x.first != y.first ? x.first < y.first : x.second > y.second ;
}
int dcomp(double x , double y){
    return fabs(x-y) <= EPS? 0: x>y?1:-1;
}

void smile() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
  //  freopen("/home/tw3/Desktop/Desktop/training/in.txt", "r", stdin);
//    freopen("/home/tw3/Desktop/Desktop/training/out.txt" , "w" , stdout);
#endif
}
#define fastin smile()

int n ;
const int N = 1e5 +3;
ll dp[N];
int h[N];
int main() {
    fastin;
    int k;
    cin >> n;
    k=2;
    inN(h, n);
    for (int l = 0; l < n; ++l) {
        dp[l] = inf;
    }
    dp[0] = 0;
    for (int j = 1; j < n; ++j) {
        for (int i = j - 1, m = 0; i >= 0 && m < k; m++, --i) {
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }
    cout << dp[n - 1];
}

Measured memory_bytes: 1408
#include<cstdio>
#include<algorithm>
#define N_ 201000
using namespace std;
int st[N_], ord[N_], Nxt[N_], Mod = 1000000007;
int n, top, B[N_], E[N_], D[N_], S[N_];
struct point{
    int x, y;
    bool operator <(const point &p)const{
        return x<p.x;
    }
}w[N_];
int main(){
    int i;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d%d",&w[i].x,&w[i].y);
    }
    sort(w+1,w+n+1);
    for(i=1;i<=n;i++){
        if(!top || st[top] < w[i].y){
            top++;
            st[top] = w[i].y, ord[top] = i;
        }
        B[i] = ord[lower_bound(st+1,st+top+1,w[i].y)-st];
    }
    top = 0;
    for(i=n;i>=1;i--){
        if(!top || -st[top] > w[i].y){
            top++;
            st[top] = -w[i].y, ord[top] = i;
        }
        E[i] = ord[lower_bound(st+1,st+top+1,-w[i].y)-st];
    }
    for(i=0;i<=n;i++)Nxt[i] = n+1;
    for(i=1;i<=n;i++){
        Nxt[B[i]-1] = min(Nxt[B[i]-1], E[i]);
    }
    for(i=n-1;i>=0;i--)Nxt[i] = min(Nxt[i], Nxt[i+1]);
    D[0] = 1;
    for(i=0;i<n;i++){
        S[i+1] = (S[i+1] + D[i])%Mod;
        S[Nxt[i]+1] = (S[Nxt[i]+1] + Mod - D[i])%Mod;
        S[i+1] = (S[i+1] + S[i])%Mod;
        D[i+1] = S[i+1];
    }
    int s = 0;
    for(i=0;i<=n;i++)if(Nxt[i] == n+1)s = (s + D[i])%Mod;
    printf("%d\n",s);
}

Measured memory_bytes: 7168
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#define INIT 100
using namespace std;
struct circle
{
    int x, y, r;
    int c;
}cc[24];
char dp[(1<<24)];
int n;
bool intersect(int i, int j)
{
    int x1, y1, x2, y2;
    int r1, r2;
    x1 = cc[i].x, y1 = cc[i].y, r1 = cc[i].r;
    x2 = cc[j].x, y2 = cc[j].y, r2 = cc[j].r;

    if( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) >=  (r1+r2)*(r1+r2))
    {
        return false;

    }//騾」蠢?キ夐聞>=蜊雁セ大柱?夂┌逶ク莠、
    else
        return true;

}
int check(int a, int b, int state)
{
    if( ((1<<a-1)&state) == 0 || ((1<<b-1)&state) == 0 )
    {
        return 0;
    }

    if(cc[a].c != cc[b].c) return 0;


    int p[2];
    p[0]=a, p[1]=b;

    for(int k=0; k<2; k++)
    {
        int x =  (1<<p[k]-1)-1;
        if( (x&state) > 0)
        {
            for(int i=1; i<=p[k]-1; i++)
            {
                int test = 1 << i-1;
                if( (test&state) && intersect(p[k], i) )
                {
                    return 0;
                }
            }
        }
    }

    return 1;
}
char DP(int state)
{
    if(state==0) return 0;
    if(dp[state]!=INIT) return dp[state];

    for(int i=1; i<n; i++)
    {
        for(int j=i+1; j<=n; j++)
        {
            if( check(i,j, state) )
            {
                int mask = (1<<i-1) | (1<<j-1);

                dp[state^mask] = DP(state^mask);
                if(dp[state^mask]+2 > dp[state] || dp[state]==INIT)
                    dp[state] = dp[state^mask]+2;
            }
        }
    }
    return dp[state]==INIT? 0:dp[state];
}

int main()
{

    while(scanf("%d",&n) && n)
    {
        for(int i=1; i<=n; i++)
            scanf("%d%d%d%d",&cc[i].x, &cc[i].y, &cc[i].r, &cc[i].c);

        int state = (1<<n)-1;
        for(int i=0; i<=state; i++)
            dp[i] = INIT;

        dp[state] = DP(state);

        printf("%d\n",dp[state]);


    }

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

int main(){
	int n; cin >> n;
	set<int> s;
	vi d(n); 
	rep(i,n){
		cin >> d[i];
		s.insert(d[i]);
	}
	int ans = 0;
	rep(i,100+1){
		set<int>::iterator ite;;

		ite = s.find(i);
		if(ite != s.end()) ans ++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    char b;
    cin >> b;

    if (b == 'A'){
        cout << 'T' << endl;
    }
    else if (b == 'T'){
        cout << 'A' << endl;
    }
    else if (b == 'G'){
        cout << 'C' << endl;
    }
    else {
        cout << 'G' << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <climits>
#include <queue>
#include <algorithm>

using std::queue;
using std::min;

const int MAXX=1e7+5,MAXN=205;
int n,cnt_x,cnt_y;
int x_id[MAXN],y_id[MAXN];
bool up[MAXX];

struct node{int he,iter,dis;}d[MAXN];
struct line{int to,nex,cap;}ed[MAXN*MAXN<<1];

inline bool is_odd_prm(int x){
	if(x==1) return false;
	for(int i=2;i*i<=x;++i){
		if(x%i==0) return false;
	}
	return true;
}

inline void addE(int u,int v,int cap){
	static int cnt=1;
	ed[++cnt]=(line){v,d[u].he,cap};
	d[u].he=cnt;
}

inline int revE(int i){return i^1;}

inline bool BFS(int s,int t,int n){
	for(int i=1;i<=n;++i)
		d[i].dis=-1;
	static queue<int> q;
	d[s].dis=0;
	q.push(s);
	int u;
	while(q.size()){
		u=q.front();
		q.pop();
		for(int i=d[u].he,v;i;i=ed[i].nex){
			if(ed[i].cap==0) continue;
			v=ed[i].to;
			if(d[v].dis==-1){
				d[v].dis=d[u].dis+1;
				q.push(v);
			}
		}
	}
	return d[t].dis!=-1;
}

int aug(int u,int rest,const int t){
	if(u==t) return rest;
	int ret=0;
	for(int &i=d[u].iter,v,cap,flow;i;i=ed[i].nex){
		v=ed[i].to,cap=ed[i].cap;
		if(d[v].dis!=d[u].dis+1 || cap==0)
			continue;
		flow=aug(v,min(cap,rest),t);
		ed[i].cap-=flow,ed[revE(i)].cap+=flow;
		ret+=flow,rest-=flow;
		if(rest==0) return ret;
	}
	if(ret==0) d[u].dis=-1;
	return ret;
}

inline int Dinic(int s,int t,int n){
	int ret=0;
	while(BFS(s,t,n)){
		for(int i=1;i<=n;++i)
			d[i].iter=d[i].he;
		ret+=aug(s,INT_MAX,t);
	}
	return ret;
}

inline void build(){
	for(int i=1;i<=cnt_x;++i){
		for(int j=1,v;j<=cnt_y;++j){
			if(is_odd_prm(abs(x_id[i]-y_id[j]))){
				v=j+cnt_x;
				addE(i,v,INT_MAX),addE(v,i,0);
			}
		}
	}
	for(int i=1,s=cnt_x+cnt_y+1;i<=cnt_x;++i)
		addE(s,i,1),addE(i,s,0);
	for(int i=1,u,t=cnt_x+cnt_y+2;i<=cnt_y;++i){
		u=cnt_x+i;
		addE(u,t,1),addE(t,u,0);
	}
}

int main(){
	scanf("%d",&n);
	int x;
	for(int i=1;i<=n;++i){
		scanf("%d",&x);
		up[x]=true;
	}
	for(int i=1;i<=x+1;++i){
		if(up[i]!=up[i-1])
			i&1 ? x_id[++cnt_x]=i:y_id[++cnt_y]=i;
	}
	build();
	int k=Dinic(cnt_x+cnt_y+1,cnt_x+cnt_y+2,cnt_x+cnt_y+2);
	printf("%d",k+((cnt_x-k)/2+(cnt_y-k)/2)*2+(cnt_x-k)%2*3);
	return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define pushb push_back()
#define popb pop_back()
#define makep make_pair
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv);
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v);
template<typename T> ll gcd(T a,T b);
template<typename T> ll lcm(T a,T b);
int main(){
    vector<int> a(5);
    int maxdif=0;
    int ans=0;
    for(auto& x:a){
        cin>>x;
        int dif=(10-x%10)%10;
        maxdif=max(maxdif,dif);
        ans+=((x-1)/10+1)*10;
    }
    ans-=maxdif;
    cout<<ans<<endl;
    
    return 0;
}

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

def main():
    N = int(input())
    T, A = map(int, input().split())
    for _ in range(N-1):
        t, a = map(int, input().split())
        # 桁が大きいとfloatの誤差が生じて正しく判定できない
        # 負の数にして切り捨てにすればceilと同じ挙動になる
        x = max(-(-T//t), -(-A//a))
        T = t*x
        A = a*x
    print(T+A)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
using namespace std;


void solve(long long N, long long K){
    long long mod_i = N % K;
    if(mod_i == 0){
        cout << 0 << endl;
        return;
    }

    if(mod_i < abs(mod_i - K)) {
        cout << mod_i << endl;
        return;
    }

    cout << abs(mod_i - K) << 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);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        x: i64,
        k: i64,
        d: i64
    };
    let c = x.abs() / d;
    let ans = if k <= c {
        (x.abs() - k * d).abs()
    } else {
        let x = x.abs() % d;
        if (k - c) % 2 == 0 {
            x
        } else {
            (x - d).abs()
        }
    };
    println!("{}", ans);
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int year = stoi(s.substr(0, 4));
    int month = stoi(s.substr(5, 2));
    int day = stoi(s.substr(8, 2));
    if (make_tuple(2019, 4, 30) >= make_tuple(year, month, day)) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [input()[0] for i in range(n)]
work = [0, 0, 0, 0, 0]
for el in s:
    if el == "M":
        work[0] += 1
    elif el == "A":
        work[1] += 1
    elif el == "R":
        work[2] += 1
    elif el == "C":
        work[3] += 1
    elif el == "H":
        work[4] += 1
temp = sum(work)
result = temp*(temp-1)*(temp-2)//6
for el in work:
    result -= el*(el-1)*(temp-el)//2
    result -= el*(el-1)*(el-2)//6
print(result)

Measured memory_bytes: 3888
m, k = map(int, input().split())

if k > 2 ** m - 1 or m == 1 and k == 1:
    print(-1)
    quit()

if k == 0:
    print(' '.join(map(lambda x : str(x // 2), range(0, 2 ** (m + 1)))))
    quit()

a = list(range(0, 2 ** m)) 
a.remove(k)
ans = a + [k]
a.reverse()
ans += a + [k]
print(' '.join(map(str, ans)))

Measured memory_bytes: 102440
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 1000000009
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
vector<P> G[100001];
int dist[100001];

int dijk(){
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,0));
	for(int i=0;i<n-1;i++){
		dist[i]=INF;
	}
	int res=-1;
	dist[0]=0;
	while(que.size()){
		P p=que.top();
		que.pop();
		int v=p.second,c=p.first;
		if(dist[v]<c)continue;
		for(int i=0;i<G[v].size();i++){
			P nex=G[v][i];
			int nev=G[v][i].first,nec=G[v][i].second;
			if(nec<c)continue;
			if(nev==n-1){
				res=max(res,nec);
			}else if(dist[nev]>nec){
				dist[nev]=nec;
				que.push(P(nec,nev));
			}
		}
	}
	return res;
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		a--;
		b--;
		G[a].push_back(P(b,c));
	}
	printf("%d\n",dijk());
	return 0;
}

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

int flag = 0;

typedef struct list{
    int key;
    struct list *prev;
    struct list *next;
}List;

List *nil;

void insert(int key){
    List *p = (List *)malloc(sizeof(List));
    p->key = key;
    p->prev = nil;
    p->next = nil->next;
    nil->next->prev = p;
    nil->next = p;
}

void delete(int key){
    List *p = nil;
    while(1){
        if(p->next->key == key){
            p->next->next->prev = p;
            p->next = p->next->next;
            flag--;
            return ;
        }
        if(p->next == nil)return;
        p = p->next;
    }
}

void deleteFirst(void){
    nil->next->next->prev = nil;
    nil->next = nil->next->next;
    return ;
}

void deleteLast(){
    List *p = nil->prev->prev;
    p->next->next->prev = p;
    p->next = p->next->next;
}

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

int main(){
    int nm, i, key;
    char wd[12];
    
    init();

    scanf("%d", &nm);
    for(i = 0; i < nm; i++){
        scanf("%s", wd);
        if(strcmp(wd, "insert") == 0){
            scanf("%d", &key);
            insert(key);
            flag++;
        } 
        else if(strcmp(wd, "delete") == 0){
            scanf("%d", &key);
            delete(key);
        }
        else if(strcmp(wd, "deleteFirst") == 0){
            deleteFirst();
            flag--;
        } 
        else if(strcmp(wd, "deleteLast") == 0){
            deleteLast();
            flag--;
        } 
    }

    for(i = 1; i <= flag-1; i++){
        printf("%d ", nil->next->key);
        nil = nil->next;
    }
    printf("%d\n", nil->next->key);

    return 0;
}



Measured memory_bytes: 36072
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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;
}
using ld=long double;
ld dist(ld xa,ld ya,ld xb,ld yb){
    return sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
}
int main(){
    ld sx,sy,gx,gy;
    cin >> sx >> sy >> gx >> gy;
    ll n;cin >> n;
    vector<vector<pair<ll,ld>>> g(n+2);
    vector<pair<pair<ld,ld>,ld>> v(n+2);
    repl(i,1,n+1)cin >> v[i].fi.fi >> v[i].fi.se >> v[i].se;
    v[0].fi={sx,sy};v[0].se=0; v[n+1].fi={gx,gy};v[n+1].se=0;
    rep(i,n+2){
        repl(j,i+1,n+2){
            ld t=max((ld)0,dist(v[i].fi.fi,v[i].fi.se,v[j].fi.fi,v[j].fi.se)-v[i].se-v[j].se);
            g[i].pb({j,t});
            g[j].pb({i,t});
        }
    }
    vector<ld> d(n+2,INF/10000);
    priority_queue<pair<ld,ll>,vector<pair<ld,ll>>,greater<pair<ld,ll>>> que;
    que.push({0,0});
    d[0]=0;
    while(!que.empty()){
        pair<ld,ll> p=que.top();
        que.pop();
        ld v=p.se;
        if(d[v]<p.fi)continue;
        rep(i,g[v].size()){
            pair<ll,ld> ed=g[v][i];
            if(d[ed.fi]>d[v]+ed.se){
                //prev[ed.fi]=v;
                d[ed.fi]=d[v]+ed.se;
                que.push({d[ed.fi],ed.fi});
            }
        }
    }
    CST(12);
    cout << d[n+1] <<endl;
}   

Measured memory_bytes: 44276
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(v)";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var mod = 1e9+7;

console.log(main());
function main(){
  var n = o.a();
  var s = o.a(1);
  return solve(s,n);
}

function solve(s,n){
  s = "<" + s;
  var dp = Array(n+1).fill(0);
  dp[0] = 1;
  for(var i = 0; i < n; i++){
    if(s[i] === "<")dp = solveH(dp,n-i);
    else dp = solveL(dp,n-i);
  }
  return dp[0];
}

function solveH(dp,n){
  var dp2 = [dp[0]];
  for(var i = 1; i < n; i++){
    dp2[i] = dp[i] + dp2[i-1];
    dp2[i] %= mod;
  }
  return dp2;
}

function solveL(dp,n){
  var dp2 = Array(n);
  dp2[n-1] = dp[n];
  for(var i = n-1; i; i--){
    dp2[i-1] = dp[i] + dp2[i];
    dp2[i-1] %= mod;
  }
  return dp2;
}

Measured memory_bytes: 14156
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin >> n;
 int a[n];
 int maxm = 0, c = 0;
 for(int i=0;i<n;i++)
 cin >> a[i];
 for(int i=0;i<n-1;i++)
 {
    if(a[i+1]<=a[i])
    c++;
    else
    c=0;
    maxm = max(maxm,c);
 }
 cout << maxm << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main (void){
    int N,i;
    long long int result;
    long long int A[100000];
    result = 1;
    scanf("%d",&N);
    for(i=0;i<N;i++) {
        scanf("%lld",&A[i]);
       if( A[i] == 0 ){
           printf("0");
           return 0;
       }
    }
      for(i=0;i<N;i++){
         if(A[i] <=1000000000000000000/result){
             result= result * A[i];
        }else{
             printf("-1\n");
             return 0;
    }
  }
     printf("%lld\n",result);
    return 0;
}

Measured memory_bytes: 2508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }

bool compare(string a, string b) {
    if (a.size() > b.size()) return true;
    else if (a.size() < b.size()) return false;
    else {
        for (long long i = 0; i < a.size(); i++) {
            if (a[i] > b[i]) return true;
            else if (a[i] < b[i]) return false;
        }
    }
    return true;
}


string add(string a, string b) {
    bool x = false, y = false;
    if (a[0] == '-') x = true;
    if (b[0] == '-') y = true;

    if (x && y) return '-' + add(a.substr(1, a.size()-1), b.substr(1, b.size()-1));
    else if (x) return add(b, a);
    // 'a - b' or 'a + b'

    if (y) b = b.substr(1, b.size()-1);
    if (y && !compare(a, b)) {
        return '-' + add(b, '-' + a);
    }

    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());

    string res = "";
    long long up = 0;

    for (long long i = 0; i < max(a.size(), b.size()); i++) {
        long long tmp = up;
        if (i < a.size()) {
            tmp += (a[i] - '0');
        }
        if (i < b.size() && b[i] != '-') {
            if (y) tmp -= (b[i] - '0');
            else tmp += (b[i] - '0');
        }

        if (tmp < 0) {
            res.push_back((10 + tmp) + '0');
            up = -1;
        }
        else if (tmp > 9) {
            res.push_back((tmp - 10) + '0');
            up = 1;
        }
        else {
            res.push_back(tmp + '0');
            up = 0;
        }
    }

    if (up > 0) res.push_back(up + '0');

    reverse(res.begin(), res.end());

    long long begin = 0;
    while (res[begin] == '0') begin++;
    
    if (res.size() == begin) return "0";
    else return res.substr(begin, res.size() - begin);
}

string mult(string a, string b) {
    if (a == "0" || b == "0") return "0";
    string res = "0";
    bool ifminus = false;
    if (a[0] == '-' && b[0] == '-') return mult(a.substr(1, a.size()-1), b.substr(1, b.size()-1));
    else if (a[0] == '-') return '-' + mult(a.substr(1, a.size()-1), b);
    else if (b[0] == '-') return '-' + mult(a, b.substr(1, b.size()-1));

    reverse(b.begin(), b.end());

    for (long long i = 0; i < b.size(); i++) {
        string tmp = "0";
        for (long long j = 0; j < (b[i] - '0'); j++) {
            tmp = add(tmp, a);
        }
        for (long long j = 0; j < i; j++) {
            tmp = tmp + '0';
        }
        res = add(res, tmp);
    }

    return res;
}


int main(){
    string a, b;
    cin >> a >> b;
    cout << mult(a, b) << endl;
    return 0;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int A, B;
	cin >> A >> B;

	int x1 = (A / 0.08) ;
	int x2 = (B / 0.1) ;
	int m = min(x1, x2);
	int M = 100 / max(0.08, 0.1);

	int ans = -1;
	int match = 0;
	for(ans = m ; ans <= M; ans++){
		if( (int)(ans * 0.08) == A && (int)(ans * 0.1) == B){
			match = 1;
			break;
		}
	}
	if(match == 1){
		printf("%d\n", ans);
	}
	else{
		printf("-1\n");
	}
	return 0;
}

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

int main() {
	string s;
	char a,r;
	int j,i,l;
	cin >> s;
	r = '`';
	for (j = 0; j < 3; j++){
		r++;
		l = 0;
		for (i = 0; i < 3; i++){
			a = s[i];
			if (a == r){
				l++;
				if (l > 1){
					cout << "No";
					return 0;
				}
			}
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string s;
int l;
#define mian main
int mian()
{
    cin>>s;
    l=s.size();
    for(register int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(register int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>

int main() {
    int d;
    while (~scanf("%d", &d)) {
        unsigned long long int r = 0;
        for (int i = 0; i < 600 / d; ++i) {
            r += std::pow(d * i, 2) * d;
        }
        printf("%llu\n", r);
    }
}

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

int main() {
int n,c=0;
cin>>n;
for(int i=0;i<n;i++){
    int a;
    cin>>a;
    while(a%2==0){
        a=a/2;
        c++;
    }
}
cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	
	private static List<Map<Character , Integer>> list = new ArrayList<>();	
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int i , j , n = scan.nextInt();
		for (i = 0;i < n;i ++) {
			String string = scan.next();
			Map<Character , Integer> map = new HashMap<Character , Integer>();
			for (j = 0;j < string.length();j ++) {
				char ch = string.charAt(j);	
				if (!map.containsKey(ch)) {
					map.put(ch , 0);
				}
				map.put(ch , map.get(ch) + 1);
			}
			list.add(map);
		}
		List<Character> chList = new ArrayList<Character>();
		for (char ch = 'a';ch <= 'z';ch ++) {
			int temp = - 1;
			for (Map<Character , Integer> map : list) {
				if (map.containsKey(ch)) {
					int cnt = map.get(ch);
					if (cnt < temp || temp < 0) {
						temp = cnt;
					}
				} else {
					temp = - 1;
					break;
				}
			}
			if (temp >= 0) {
				for (i = 0;i < temp;i ++) {
					chList.add(ch);
				}
			}
		}
		Collections.sort(chList);
		StringBuilder builder = new StringBuilder();
		for (char ch : chList) {
			builder.append(ch);
		}
		System.out.println(builder.toString());
		
	}

} 





Measured memory_bytes: 24020
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
	int k = Integer.parseInt(sc.next());
	String s = sc.next();
	for(int i = 0; i<n; i++) {
	    if(i==k-1) System.out.print((s.substring(i,i+1)).toLowerCase());
	    else System.out.print(s.charAt(i));
	}
	System.out.println();
    }
}

Measured memory_bytes: 21584
#!/usr/bin/env python3
#ABC117 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
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,m = LI()
x = LI()
x.sort()
if n >= m:
    print(0)
    quit()
y = [abs(x[i] - x[i+1]) for i in range(m-1)]
y.sort()
ans = sum(y[:m-n])
print(ans)


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

using namespace std;

typedef long long ll;

#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair

const int mx = 100050;
vector<pii> vec[mx];
bool vis[mx];
int color[mx];

void dfs(int u , int from , int sum)
{
    vis[u] = 1;
    color[u] = sum%2;
    int i , v ,w , l = vec[u].size();

    for(i = 0 ; i < l ; i++)
    {
        v = vec[u][i].F;
        w = vec[u][i].S;
        if(!vis[v])dfs(v,u,sum+w);
    }

}

int main()
{
    int n , i , j , u , v , k , w ;
    scanf("%d",&n);

    for(i = 1 ; i < n ; i++)
    {
        scanf("%d %d %d",&u,&v,&w);
        w = w%2;
        vec[u].push_back(mp(v,w));
        vec[v].push_back(mp(u,w));
    }
    dfs(1,-1,0);
    for(i = 1 ; i <= n ; i++)printf("%d\n",color[i]);



    return 0;
}


Measured memory_bytes: 8448
#if 0

#endif
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <memory>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
class UnionFindTree {
    ll n;
    ll P[100000];
public:
    void init(ll n) {
        for (ll i = 0; i <= n; ++i) P[i] = i;
    };
    ll root(ll node) {
        if (P[node] == node) return node; // aはroot
        return (P[node] = root(P[node])); // aの親のrootを求め，aの親とする(圧縮)
    }
    bool is_group(ll node_a, ll node_b) {
        return root(node_a) == root(node_b);
    }
    void unite(ll node_a, ll node_b) {
        P[root(node_a)] = root(node_b);
    }
};
ll a[10000][10000];
vector<pair<ll, pair<ll, ll> > > edge;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    unique_ptr<UnionFindTree> tree(new UnionFindTree);
    tree->init(10000);
    ll N;
    cin >> N;
    for (ll i = 0; i < N; ++i) {
        for (ll j = 0; j < N; ++j) {
            cin >> a[i][j];
            if (i >= j || a[i][j] == -1) continue;
            edge.push_back(make_pair(a[i][j], make_pair(i, j)));
        }
    }
    sort(edge.begin(), edge.end());

    ll cost_sum = 0;
    for (ll i = 0; i < edge.size(); ++i) {
        if (tree->is_group(edge[i].second.first, edge[i].second.second)) continue;
        tree->unite(edge[i].second.first, edge[i].second.second);
        cost_sum += edge[i].first;
    }

    cout << cost_sum << endl;

    return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for(int i=m; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <typename T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0; }
template <typename T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1;} return 0; }
 
 
int main() {
    int n,m; cin>>n>>m;
    if(n<=m) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
 
}

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

int include3(int n) {
	if(n%10==3) return 1;
	else if(n/10) return include3(n/10);
	else return 0;
}

int main() {
	int n;
	cin >> n;
	for(int i=1; i<=n; i++){
		if(i%3 == 0) cout << " " <<i;
		else if(include3(i)) cout << " " <<i;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3132
s = input()
t = input()
res = []

for s_index in range(len(s)-len(t)+1):
    if s[s_index] in ['?', t[0]]:
        s_p = s[s_index:s_index+len(t)]
        if all(s_p[x] in ['?', t[x]] for x in range(len(s_p))):
            res.append(s[:s_index].replace('?', 'a') + t + s[s_index+len(t):].replace('?', 'a'))
if res:
    print(sorted(res)[0])
else:
    print('UNRESTORABLE')


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            for (var i = 0; i < 3; i++)
            {
                var t = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                var r = new TimeSpan(t[3], t[4], t[5]) - new TimeSpan(t[0], t[1], t[2]);
                Console.WriteLine("{0} {1} {2}", r.Hours, r.Minutes, r.Seconds);
            }
        }
    }
}

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

#define null				""
#define all(dat)			dat.begin(), dat.end()
#define over(msg)			cout << msg << endl, exit(0);
#define loop(i, to)			for (int i = 0; i < to; ++i)
#define cont(i, to)			for (int i = 1; i <= to; ++i)
#define foreach(i, dat)		for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long			num;

using namespace std;

int n1, n2, dp[3005][3005];
pair<int, int> pre[3005][3005];
string s1, s2, ans;

int main() {
	ios_base::sync_with_stdio(0);
	cin >> s1 >> s2;
	n1 = (int) s1.size();
	n2 = (int) s2.size();
	s1 = ' ' + s1;
	s2 = ' ' + s2;
	pre[0][0] = make_pair(-1, -1);
	cont (i, n1) {
		cont (j, n2) {
			pre[i][j] = make_pair(-1, -1);
			if (s1[i] == s2[j]) {
				if (dp[i][j] < dp[i - 1][j - 1] + 1) {
					dp[i][j] = dp[i - 1][j - 1] + 1;
					pre[i][j] = make_pair(i - 1, j - 1);
				}
			}
			if (dp[i][j] < dp[i - 1][j]) {
				dp[i][j] = dp[i - 1][j];
				pre[i][j] = make_pair(i - 1, j);
			}
			if (dp[i][j] < dp[i][j - 1]) {
				dp[i][j] = dp[i][j - 1];
				pre[i][j] = make_pair(i, j - 1);
			}
		}
	}
	int i = n1, j = n2, pi = i, pj = j;
	while (1) {
		i = pre[pi][pj].first;
		j = pre[pi][pj].second;
		if (i == -1 && j == -1)  break;
		if (i == pi - 1 && j == pj - 1) {
			ans += s1[pi];
		}
		pi = i;
		pj = j;
	}
	reverse(all(ans));
	cout << ans << endl;
}


Measured memory_bytes: 105984
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define iFOR(idx, from, upto) for (int  idx = from; idx < upto; ++idx)
#define lFOR(idx, from, upto) for (long idx = from; idx < upto; ++idx)

#define ll long long

using namespace std;

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

    int coin_500 = x / 500;
    int coin_5   = (x - coin_500 * 500) / 5;

    cout << coin_500 * 1000 + coin_5 * 5 << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String a = scanner.next();
		String b = scanner.next();
		String result = "H";

		if (!a.equals(b)) {
			result = "D";
		}
		System.out.println(result);
	}

}

Measured memory_bytes: 22996
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
struct trump{
	int number;
	int mark;//S,H,C,D
};
int main() {
	char c;
	while (cin >> c, c != '#'){
		int first;
		if (c == 'S')first = 0;
		if (c == 'H')first = 1;
		if (c == 'C')first = 2;
		if (c == 'D')first = 3;
		trump player[4][13];
		REP(i, 4){
			REP(j, 13){
				string s;
				int num;
				int mark;
				cin >> s;
				if ('2' <= s[0] && s[0] <= '9'){
					num = s[0] - '0';
				}
				if (s[0] == 'T')num = 10;
				if (s[0] == 'J')num = 11;
				if (s[0] == 'Q')num = 12;
				if (s[0] == 'K')num = 13;
				if (s[0] == 'A')num = 14;

				if (s[1] == 'S')mark = 0;
				if (s[1] == 'H')mark = 1;
				if (s[1] == 'C')mark = 2;
				if (s[1] == 'D')mark = 3;
				player[i][j] = { num, mark };
			}
		}
		int ns = 0, ew = 0;

		REP(i, 13){
			int second;
			if (i == 0)
				second = player[3][0].mark;
			int count = 0;
			vector<int> vi;
			REP(j, 4){
				if (player[j][i].mark == first){
					count++;
					vi.push_back(j);
				}
			}
			if (count == 1){
				if (vi[0] % 2){
					ew++;
				}
				else{
					ns++;
				}
				if (i != 12)second = player[vi[0]][i+1].mark;
				continue;
			}
			if (count >= 2){
			int max=0;
			int pl;
				REP(j, vi.size()){
					if (max < player[vi[j]][i].number){
						max = player[vi[j]][i].number;
						pl = vi[j];
					}
				}
				if (pl % 2){
					ew++;
				}
				else{
					ns++;
				}
				if (i != 12)second = player[pl][i + 1].mark;
				continue;
			}
			count=0;
			vi.clear();
			REP(j, 4){
				if (player[j][i].mark == second){
					count++;
					vi.push_back(j);
				}
			}
			if (count == 1){
				if (vi[0] % 2){
					ew++;
				}
				else{
					ns++;
				}
				if (i != 12)second = player[vi[0]][i + 1].mark;
				continue;
			}
			if (count >= 2){
				int max = 0;
				int pl;
				REP(j, vi.size()){
					if (max < player[vi[j]][i].number){
						max = player[vi[j]][i].number;
						pl = vi[j];
					}
				}
				if (pl % 2){
					ew++;
				}
				else{
					ns++;
				}
				if (i != 12)second = player[pl][i + 1].mark;
				continue;
			}
		}
		if (ew>ns)
			cout << "EW "<<(ew%6)<<endl;
		else
			cout << "NS " << (ns % 6) << endl;
	}
}

Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    if(a == 1 && b == 2){
        cout << "Borys" << "\n";
        return 0;
    }
    if((b-a)%2){
        cout << "Borys\n";
    }else {
        cout << "Alice\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;
//ll longinf=1ll<<60;
int inf=1<<29;
int dn[4]={-1,1,0,0};
int dm[4]={0,0,-1,1};
ll longinf=(1ll<<60);
int main(){
      int N,K;
      cin>>N>>K;
      int x[N],y[N];
      char c[N];
      rep0(i,N) cin>>x[i]>>y[i]>>c[i];
      auto mod = [](int a,int b){
            return (b+a%b)%b;
      };
      rep0(i,N){
            x[i]%=2*K;
            y[i]%=2*K;
            if(c[i]=='W'){
                  y[i]=mod(y[i]+K,2*K);
                  c[i]='B';
            }
      }
      int D=2*K;
      int field[D][D];
      rep0(i,D){
            rep0(j,D){
                  field[i][j]=0;
            }
      }
      rep0(i,N){
            if((x[i]<K&&y[i]<K)||(x[i]>=K&&y[i]>=K)){
                  x[i]%=K;
                  y[i]%=K;
                  field[0][0]++;
                  field[0][y[i]]--;
                  field[0][y[i]+K]++;
                  field[x[i]][0]--;
                  field[x[i]][y[i]]+=2;
                  field[x[i]][y[i]+K]-=2;
                  field[x[i]+K][0]++;
                  field[x[i]+K][y[i]]-=2;
                  field[x[i]+K][y[i]+K]+=2;
            }
            else{
                  x[i]=max(x[i],mod(x[i]+K,2*K));
                  y[i]=min(y[i],mod(y[i]+K,2*K));
                  field[0][y[i]]++;
                  field[0][y[i]+K]--;
                  field[x[i]-K][0]++;
                  field[x[i]-K][y[i]]-=2;
                  field[x[i]-K][y[i]+K]+=2;
                  field[x[i]][0]--;
                  field[x[i]][y[i]]+=2;
                  field[x[i]][y[i]+K]-=2;
            }
      }
      rep0(i,D){
            rep1(j,D-1){
                  field[i][j]+=field[i][j-1];
            }
      }
      rep1(i,D-1){
            rep0(j,D){
                  field[i][j]+=field[i-1][j];
            }
      }
      /*rep0(i,D){
            rep0(j,D){
                  cout<<field[i][j]<<" ";
            }
            cout<<endl;
      }*/
      int ans=0;
      rep0(i,D){
            rep0(j,D){
                  ans=max(ans,field[i][j]);
            }
      }
      cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 16768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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 (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  vector<int> p(n);
  rep(i,n){
    cin>>p[i];
  }

  if(n==1) {
    cout << p[0] << endl;
    return 0;
  }

  for(int i=n-1;i>=0;i-=2){
    cout << p[i] << " ";
  }

  for(int i=n%2;i<n;i+=2){
    cout << p[i];
    if(i<n-2) cout << " ";
  }
  cout << endl;

}

Measured memory_bytes: 2944
use proconio::input;

fn main() {
    input! {
        x: usize,
    }
    println!(
        "{}",
        match x {
            400..=599 => 8,
            600..=799 => 7,
            800..=999 => 6,
            1000..=1199 => 5,
            1200..=1399 => 4,
            1400..=1599 => 3,
            1600..=1799 => 2,
            1800..=1999 => 1,
            _ => unreachable!(),
        }
    );
}


Measured memory_bytes: 2112
#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//
#include<cmath>
#include<iomanip>

using namespace std;

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

typedef long long ll;

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); }

int dy[] = {1,0,-1,0}; //次に行くところ
int dx[] = {0,1,0,-1}; //s上に同じ

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,m,ans = INT_MAX;
  string s,t;
  cin >> s >> t;
  n = s.size();
  m = t.size();

  for (int i = 0; i < n-m+1; i++){
    int cnt = 0;
    for (int j = 0; j < m; j++){
      if (s[i+j] != t[j]){
        cnt++;
      }
    }
    chmin(ans,cnt);
  }
  
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
typedef long long ld;


int main() {
	// violinista forever xd
	ios::sync_with_stdio(0),cin.tie(0);
	
	ll n,m;
	cin>>n>>m;
	ll rta=0;
	rta+=n*(n-1)/2;
    rta+=m*(m-1)/2;
    cout<<rta<<endl;
	
	return 0;
}

Measured memory_bytes: 3608
def gcd(a,b)
  return a if b == 0
  return gcd(b, a%b)
end

k = gets.to_i

s = 0

for i in 1..k
  s += i
  for l in i+1..k
    dd = gcd(i,l)
    s += 6 * dd
    for j in l+1..k
      s += 6 * gcd(j, dd)
    end
  end
end

puts s


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

#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define let const auto
#define USE1(T) template <typename T>
#define USE2(T, U) template <typename T, typename U>
#define I_ inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

USE1(T) using duo = std::pair<T, T>;
USE1(T) using vec = std::vector<T>;
using ll = long long;
// clang-format off
USE2(T,U) I_ bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U) I_ bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int) I_ T in(){T x;std::cin>>x;return x;}
USE1(T=int) I_ vec<T> in(int n){vec<T> v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE1(T) vec<T> ndvec(T v,int n){return vec<T>(n, v);}
USE2(T,...Ts) auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T) I_ void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts) I_ void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
I_ int re(){int x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
I_ void wr(int x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
struct IoSetup {
  IoSetup(){
    using namespace std;
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<setprecision(10);
    cerr<<setprecision(10);
  }
} iosetup;
// clang-format on
// }}}
using namespace std;
const int inf = 1001001001;
const ll infll = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

#define int long long

int dp[55][55 * 55];

signed main() {
  int N = in(), A = in();
  auto X = in(N);
  dp[0][0] = 1;
  for (int x : X) {
    rrep(i, N) {
      rrep(s, 2501) { dp[i + 1][s + x] += dp[i][s]; }
    }
  }
  int tot = 0;
  rep(i, 1, N + 1) { tot += dp[i][i * A]; }
  pr(tot);
  return 0;
}


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

int main() {
	string str1, str2;
	int n;
	cin >> n;

	int ans1, ans2;
	ans1 = 0;
	ans2 = 0;
	for (int i = 0; i < n; i++) {
		cin >> str1 >> str2;

		if (str1 == str2) {
			ans1++;
			ans2++;
		}
		else if (str1 < str2) {
			ans2 += 3;
		}
		else if (str1 > str2) {
			ans1 += 3;
		}
	}

	cout << ans1 << " " << ans2 << endl;
	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

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


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in(),M=in();
	
	out((N*M)%2 ? "Odd" : "Even");
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int getCount = int.Parse(input[1]);
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long answer = 0;

    for(int i = 0; i <= getCount && i <= n; i++)
    {
      for(int j = 0; j <= getCount-i && j <= n-i; j++)
      {
        List<long> getList = new List<long>();
        for(int k = 0; k < i; k++)
        {
          if(k < n) getList.Add(nums[k]);
        }
        for(int k = 0; k < j; k++)
        {
          if(n-1-k >= 0) getList.Add(nums[n-1-k]);
        }
        getList.Sort();

        long answerMemo = 0;
        for(int k = 0; k < getList.Count(); k++)
        {
          if(k < getCount-i-j && getList[k] < 0)
          {
            answerMemo += 0;
          }else answerMemo += getList[k];
        }
        answer = Math.Max(answer, answerMemo);
      }
    }

    
		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;

int main(){
    int N,K;
    cin >> N >> K;
    int a=1;
    while(pow(K,a)<=N){
        a++;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 512