akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n,k;cin>>n>>k;
    vi v(n);
    rep(i,n)cin>>v[i];
    vb dp(k+1,false);
    rep(i,k+1){
        rep(j,n){
            if(i-v[j]<0)break;
            if(!dp[i-v[j]]){
                dp[i]=true;
                break;
            }
        }
    }
    if(dp[k])out("First");
    else out("Second");
}

Measured memory_bytes: 256
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;

typedef pair<LL, LL> PP;

int W, H, N;
int x[101], y[101], a[101];
int main() {
	cin >> W >> H >> N;
	REP(i, 0, N) {
		cin >> x[i] >> y[i] >> a[i];
	}
	int minx = 0, miny = 0, maxx = W, maxy = H;
	REP(i, 0, N) {
		switch (a[i]) {
		case 1:
			minx = max(minx, x[i]);
			break;
		case 2:
			maxx = min(maxx, x[i]);
			break;
		case 3:
			miny = max(miny, y[i]);
			break;
		case 4:
			maxy = min(maxy, y[i]);
			break;
		}
	}
	cout << (maxx - minx) * (maxx - minx > 0) * (maxy - miny) * (maxy - miny > 0) << endl;
	return 0;
}

Measured memory_bytes: 384
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; long y; rd(n, y);
  
  for(int i=0; i<=n; i++)for(int j=0; i+j<=n; j++){
    auto k=n-(i+j);
    if(10000*i+5000*j+1000*k == y){
      writeln(i, " ", j, " ", k); return;
    }
  }

  writeln(-1, " ", -1, " ", -1);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
void wr(T...)(T x){
  import std.stdio;
  foreach(e; x) write(e, " ");
  writeln();
}

Measured memory_bytes: 256
N = int(input())
n = 0
a = n ** 2 + n - 2 * N
# 上から抑える
while a < 0:
    n += 1
    a = n ** 2 + n - 2 * N

score = 0
ans = []
for i in reversed(range(1, n + 1)):
    if score + i <= N:
        score += i
        ans.append(i)
    if score == N:
        break

for i in ans:
    print(i)

Measured memory_bytes: 43504
W, H, N = map(int, input().split())
left, right = 0, W
down, up = 0, H

for i in range(N):
  x, y, a = map(int, input().split())
  if a == 1:
    left = max(left, x)
  elif a == 2:
    right = min(right, x)
  elif a == 3:
    down = max(down, y)
  else:
    up = min(up, y)
    
w, h = 0, 0
if right-left > 0:
  w = right - left
if up-down > 0:
  h = up-down
ans = w * h
print(ans)

Measured memory_bytes: 9124
/** omgursocute **/
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int a, b, c;
	cin >> a >> b >> c;
	int d = c-(a-b);

	cout << max(d, 0);

	return 0;
}




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

int main(){
	int n;
	cin >> n;
	int mah = 0;
	int cnt = 0;
	rep(i,n){
		int h;
		cin >> h;
		if(h >= mah) cnt++;
		mah = max(mah,h);
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define NIL -1
#define M 1046527
char H[M][14];
char getChar(char ch)
{
    if(ch=='A') return 1;
    if(ch=='C') return 2;
    if(ch=='G') return 3;
    if(ch=='T') return 4;
    else return 0;
}
long long getKey(char str[])
{
    long long sum=0,p=1,i;
    for(i=0;i<strlen(str);i++)
    {
        sum+=p*(getChar(str[i]));
        p*=5;
    }
    return sum;
}
int h1(int key){return key % M;}
int h2(int key){return 1+key%(M-1);}
int find(char str[])
{
    long long key,i,h;
    key=getKey(str);
    for(i=0;;i++)
    {
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0) return 1;
        else if(strlen(H[h])==0) return 0;
    }
    return 0;

}
int insert(char str[])
{
    long long key,i,h;
    key=getKey(str);
    for(i=0;;i++)
    {
        h=(h1(key)+i*h2(key))%M;
        if(strcmp((H[h]),str)==0) return 1;
        else if(strlen(H[h])==0)
        {
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}
int main()
{
    int n;
    scanf("%d",&n);
    char str[14],com[9];
    //初始化散列表
    for(int i=0;i<M;i++) H[i][0]='\0';
    for(int i=0;i<n;i++)
    {
        scanf("%s%s",com,str);
        if(com[0]=='i') insert(str);
        else
        {
            if(find(str)) printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}



Measured memory_bytes: 17060
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
int fie[102][102];
int check[102][102];
typedef struct state{
  int x;
  int y;
  int cost;
  state(int x,int y,int cost):x(x),y(y),cost(cost){}
};
int w,h;
int xg,yg;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
void makefie(int c,int d,int x,int y){
  int xm=0,ym=0;
  //cout << "oo";
  //fflush(stdout);
  if(d){ xm=2; ym=4;}
  else{ xm=4; ym=2;}
  for(int i=x; i < x+xm; i++){
    for(int j=y; j < y+ym; j++)
      fie[i][j]=c;
  }
  //  cout << "ee";
  // fflush(stdout);
}
int solve(int x,int y,int c){
  queue <state> q;
  q.push( state(x,y,0) );
  // cout << x << " " << y << " "<<endl;
  while(!q.empty()){
    state p = q.front(); q.pop();
    int cost = p.cost;
    for(int i=0;i<4;i++){
      int nx=p.x+dx[i];
      int ny=p.y+dy[i];
      if(nx <= 0 || nx >w || ny <= 0 || ny>h) continue;
      if(fie[nx][ny]!=c) continue;
      if(nx==xg && ny==yg) return 1;
      if(check[nx][ny]!=-1) continue;
      check[nx][ny]=cost+1;
      q.push( state(nx,ny,cost+1) );
      //  cout << nx << " " << ny << " "<< cost+1<<endl;
    }
  }
  return 0;
}
main(){
  int n;
  int xs,ys;
  while(1){
    cin >> w >>h;
    if(w==0 && h==0) break;
    cin >> xs >> ys;
    cin >> xg >> yg;
    cin >> n;
    memset(fie,0,sizeof(fie));
    memset(check,-1,sizeof(check));
    for(int i=0;i<n;i++){
      int c,d,x,y;
      cin >> c >> d >> x >> y;
      makefie(c,d,x,y);
    }

    if(fie[xs][ys]==0){ cout << "NG"<<endl; continue;}
    int res=solve(xs,ys,fie[xs][ys]);
    if(res) cout << "OK" <<endl;
    else cout << "NG" << endl;
  }
}

Measured memory_bytes: 0
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-05-17(Sun)
   note   
**********************************************************************/

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < 3; ++i) {
      cout << s.at(i);
  }
  return 0; 
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
typedef int64_t ll;

ll op(ll a,ll b){return max(a,b);}
ll e(){return -1;}
ll t,x,y;
bool f(ll a){return (a<y ? 1 : 0);}

int main(){
  ll n,q;
  cin>>n>>q;
  vector<ll> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  atcoder::segtree<ll,op,e> seg(a);
  for(int i=0;i<q;i++){
    cin>>t>>x>>y;
    if(t==1){x--;seg.set(x,y);}
    if(t==2){x--;cout<<seg.prod(x,y)<<endl;}
    if(t==3){x--;cout<<seg.max_right<f>(x)+1<<endl;}
  }
}


Measured memory_bytes: 9024
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include "math.h"

using namespace std;

int n;
int m;

int main() {
    
    cin >> n >> m;
    
    vector<int> x(m, 0);
    
    for (int i=0; i<m; i++) {
        cin >> x[i];
    }
    
    if (m <= n) {
        
        cout << 0 << endl;
        return 0;
        
    } else {
        
        priority_queue<int> dd;

        
        sort(x.begin(), x.end());
        
        int s = x.back() - x.front();
        
        for (int i=0; i<m-1; i++) {
            dd.push(x[i+1] - x[i]);
        }
        
        for (int j=0; j<n-1; j++) {
            s = s - dd.top();
            dd.pop();
        }
        
        cout << s << endl;

    }
    
    return 0;
    
}

Measured memory_bytes: 1276
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')[0].split(' ')
A = inp.shift()
B = inp.shift()
C = inp.shift()
console.log(A[A.length - 1] == B[0] && B[B.length - 1] == C[0] ? 'YES' : 'NO')

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>
#include<ios>
#include<iomanip>

using namespace std;

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

    int N, M;
    cin >> N >> M;

    vector<int> P(M), Y(M);
    vector<int> yd[N+1]; // vector of vector;
    for(int i = 0; i < M; i++){
        cin >> P[i] >> Y[i];
        yd[P[i]].push_back(Y[i]);
    }

    for(int i=0; i < N; i++){
        sort(yd[i+1].begin(), yd[i+1].end());
    }
    
    for(int i=0; i<M; i++){
        cout << setfill('0') << std::right << setw(12) << (long long)((long long)(P[i])*1000000 + (long long)(lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i])-yd[P[i]].begin()+1)) << endl;
    }
    

    return 0;
}


Measured memory_bytes: 7808
#include <iostream>
#include <algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const ll INF = 1e9L + 7;

int main() {
    int n;
    scanf("%d", &n);
    // dp[heads]
    // if we had i tosses, then tails=i-heads
    vector<double> dp(n + 1);
    // dp[i] - p-bility that there are i heads so far
    dp[0] = 1;
    for(int coin = 0; coin < n; ++coin) {
        double p_heads;
        scanf("%lf", &p_heads);
        for(int i = coin + 1; i >= 0; --i) {
            dp[i] = (i == 0 ? 0 : dp[i-1] * p_heads) + dp[i] * (1 - p_heads);
        }
    }
   double answer = 0;
    for(int heads = 0; heads <= n; ++heads) {
        int tails = n - heads;
        if(heads > tails) {
            answer += dp[heads];
        }
    }
    printf("%.10lf\n", answer);
    return 0;
}

Measured memory_bytes: 256
/*{{{*/
//#define HOME
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define F first
#define S second

template<class T> void _R(T &_x) { cin >> _x; }
void _R(int &_x) { scanf("%d", &_x); }
void _R(int64_t &_x) { scanf("%" SCNd64, &_x); }
void _R(double &_x) { scanf("%lf", &_x); }
void _R(char &_x) { scanf(" %c", &_x); }
void _R(char *_x) { scanf("%s", _x); }
template<class T, class U> void _R(pair<T, U> &_x) {_R(_x.F); _R(_x.S);}
void R() {}
template<class T, class... U> void R(T &_head, U &... _tail) { _R(_head); R(_tail...); }

template<class T> void _W(const T &_x) { cout << _x; }
void _W(const int &_x) { printf("%d", _x); }
void _W(const int64_t &_x) { printf("%" PRId64, _x); }
void _W(const double &_x) { printf("%.16f", _x); }
void _W(const char &_x) { putchar(_x); }
void _W(const char *_x) { printf("%s", _x); }
template<class T, class U> void _W(const pair<T, U> &_x) {_W(_x.F); putchar(' '); _W(_x.S);}
template<class T> void _W(const vector<T> &_x) { for (auto i = _x.begin(); i != _x.end(); _W(*i++)) if (i != _x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &_head, const U &... _tail) { _W(_head); putchar(sizeof...(_tail) ? ' ' : '\n'); W(_tail...); }
template<class T, class... U> void DB(const T &_head, const U &... _tail) {
#ifdef HOME
    W('#', _head, _tail...);
#endif
}

#define SZ(x) (int)((x).size())
#define ALL(x) (x).begin(), (x).end()
#define RAN(x,n) (x).begin(), (x).begin()+(n)
#define UNIQUE(x) {sort(ALL(x)); (x).erase(unique(ALL(x)), (x).end());}

#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
//#define ITER(i,t) for (auto i = t.begin(); i != t.end(); ++i)
#define IT3(i,st,ed) for (auto i = st; i != ed; ++i)
#define IT2(i,range) IT3(i,range)

#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define MS(X, v) memset((X), (v), sizeof((X)))

template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

inline int LG (const unsigned int &_x) { return 31-__builtin_clz(_x); }  // floor: LG(x), ceil: LG(x-1)+1
/*}}}*/

int n;
vector<pii> lrs;

int main(){
    R(n);
    lrs.assign(n, pii());
    FOR(i, n) R(lrs[i].F, lrs[i].S);

    sort(ALL(lrs));

    vi minr(n), minl(n);
    minr[n-1] = lrs[n-1].S;
    REPD(i, n-2, 0)
        minr[i] = min(minr[i+1], lrs[i].S);
    minl[0] = lrs[0].S;
    REP(i, 1, n-1)
        minl[i] = min(minl[i-1], lrs[i].S);

    int ans = 0;
    FOR(i, n-1){
        ans = max(ans, max(minl[i]-lrs[i].F+1, 0) + max(minr[i+1]-lrs[n-1].F+1, 0));
    }

    FOR(i, n){
        ans = max(ans, lrs[i].S-lrs[i].F+1 + max(minr[0]-lrs[n-1].F+1, 0));
    }

    W(ans);

    return 0;
}

/*

3
1 100
49 51
48 50

*/


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

class Combination {
    vector<ll> factorial;
    vector<ll> fact_inverse;
    vector<ll> inverse;
    int mod;

    void init(int size) {
        factorial[0] = 1;
        factorial[1] = 1;
        fact_inverse[0] = 1;
        fact_inverse[1] = 1;
        inverse[1] = 1;

        for (int i = 2; i < size; i++) {
            factorial[i] = factorial[i - 1] * i % mod;
            inverse[i] = mod - inverse[mod % i] * (mod / i) % mod;
            fact_inverse[i] = fact_inverse[i - 1] * inverse[i] % mod;
        }
    }

    public:
        Combination(int size, int m) {
           factorial = vector<ll>(size);
           fact_inverse = vector<ll>(size);
           inverse = vector<ll>(size);
           mod = m;
           init(size);
        }
    
        ll calc(int n, int k) {
            if (n < k) {
                return 0;
            }
            if (n < 0 || k < 0) {
                return 0;
            }
            return factorial[n] * (fact_inverse[k] * fact_inverse[n - k] % mod) % mod;
        }

        // i.e. nHk
        ll with_repetition(int n, int k) {
            return calc(n + k - 1, k);
        }
};

void solve() {
    int x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0 || x * 2 < y || x > y * 2) {
        cout << 0 << endl;
        return;
    }
    Combination c(1000000, MOD);
    int n = (x + y) / 3;
    cout << c.calc(n, x - n) << endl;
}


Measured memory_bytes: 23680
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

dist = abs(A-B)
if dist == 0:
    print("YES")
    exit()
vel = abs(W-V)

if V*T >= W*T + dist:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9084
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n=scan.nextInt();
        long[]a=new long[n];
        for(int i=0;i<n;++i)a[i]=-Integer.parseInt(scan.next());
        Arrays.sort(a);
        long[]b=new long[n];
        b[n-1]=-a[n-1];
        for(int i=n-2;i>=0;--i)b[i]=b[i+1]-a[i];
        int p;
        for(p=1;p<n;++p)
            if(-a[p-1]>2*b[p])break;
        System.out.println(p);
    }
}


Measured memory_bytes: 47880
/*	
*  Sachin Mittal
*/
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,j,n) for(int i=j;i<n;i++)
#define F first
#define S second
#define lb lower_bound
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define sz(s) (int)(s.size())
#define debug(x) cout << #x << " = " << x << '\n';
using namespace std;

void solve()
{
    double r;cin>>r;
    double pi=3.141592;
    double ans=(2*pi*r);
    cout<<fixed<<setprecision(10)<<ans;
}

int32_t main(){

ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t=1;
//cin>>t;
while(t--)
{
	solve();
}
}

Measured memory_bytes: 3800
import sys

m = int(input())
t = []
x = []
y = []

i = 0
while(i < m):
  a = input().split()
  t.append(int(a[0]))
  x.append(int(a[1]))
  y.append(int(a[2]))
  i += 1

cx = 0
cy = 0
ct = 0

i = 0
while(i < m):
  dx = abs(x[i] - cx)
  dy = abs(y[i] - cy)
  dt = (t[i] - ct) - (dx + dy)
  if(dt < 0 or dt > 0 and dt % 2 == 1):
    print('No')
    sys.exit()
  cx = x[i]
  cy = y[i]
  ct = t[i]
  i += 1
print('Yes')

Measured memory_bytes: 11816
long n,m,i,j,k,d[305][305][305],M=1000000007;main(){scanf("%lu%lu",&n,&m);for(d[0][1][0]=1;i<m;i++)for(j=1;j<=n;j++)for(k=0;k<=n-j;k++){d[i+1][j+k][0]+=(d[i][j][k]%=M)*j%M;d[i+1][j][k]+=d[i][j][k]*k%M;d[i+1][j][k+1]+=d[i][j][k]*(n-j-k)%M;}printf("%ld\n",d[m][n][0]%M);}

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

#define F                   first
#define S                   second
#define int                 long long int
#define pb                  push_back
#define mp                  make_pair
#define pii                 pair<int,int>
#define vi                  vector<int>
#define mii                 map<int,int>
#define pqb                 priority_queue<int>
#define pqs                 priority_queue<int,vi,greater<int> >
#define mod                 1000000007
#define endl                '\n'
#define rep(i,a,b)            for(int i=a;i<b;i++)
int n, m, parth;

void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
bool helper(int x, int y, vector<vector<char>> b) {
    int i = 0;
    int k = 1;
    while (i < n) {
        if (x & (k << i)) {
            rep(z, 0, m) {
                b[i][z] = 'r';
            }
        }
        i++;
    }
    int j = 0;
    k = 1;
    while (j < m) {
        if (y & (k << j)) {
            rep(z, 0, n) {
                b[z][j] = 'r';
            }
        }
        j++;
    }
    int ans = 0;
    rep(k, 0, n) {
        rep(l, 0, m) {
            //cout << b[k][l] << " ";
            if (b[k][l] == '#') {
                ans++;
            }
        }
        //cout << endl;
    }
    // if (ans == parth) {
    //     rep(k, 0, n) {
    //         rep(l, 0, m) {
    //             cout << b[k][l] << " ";
    //             // if (b[k][l] == '#') {
    //             //     ans++;
    //             // }
    //         }
    //         cout << endl;
    //     }
    //     cout << endl;

    // }


    return ans == parth;
}
int32_t main()
{
    c_p_c();
    cin >> n >> m >> parth;
    vector<vector<char>> a(n, vector<char>(m));
    rep(i, 0, n) {
        rep(j, 0, m) {
            cin >> a[i][j];
        }
    }
    vector<int> r;
    vector<int> c;
    rep(i, 0, (int)pow(2, n)) {
        r.pb(i);
    }
    rep(i, 0, (int)pow(2, m)) {
        c.pb(i);
    }
    int ans = 0;
    for (auto x : r) {
        for (auto y : c) {
            vector<vector<char>> b = a;
            if (helper(x, y, b)) {
                ans++;
            }
            //cout << " " << x << " " << y << endl;
        }
    }
    //helper(1, 0, a);

    cout << ans << endl;
    //cout << "eheill-";

    return 0;
}

Measured memory_bytes: 4048
#include <stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  int h[n];
  for(int i = 0; i < n; i++){
    scanf("%d", &h[i]);
  }
  int a[n];
  a[0] = 0;
  for(int i = 1; i < n; i++){
    if(h[i] <= h[i - 1]){
      a[i] = a[i - 1] + 1;
    }else{
      a[i] = 0;
    }
  }
  int max = a[0];
  for(int i = 0; i < n; i++){
    if(a[i] > max){
      max = a[i];
    }
  }
  printf("%d\n", max);
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

vector<ll> vec(1000000+10);


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

    ll N;
    string S;
    cin >> N;

    ll ans = 0;

    REPS(i,N-1){
        ll tmp = (N-1) / i;
        ans += tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 10980
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
typedef unsigned long long ull;
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define f(i,a,b) for(ll i=a;i<=b;i++)
#define testcases ll t;cin>>t;while(t--)
#define dec(x) greater<x>()

/*** Define Values ***/
#define mx 200005
#define mod 1000000007
#define PI acos(-1.0)
#define eps 1e-7
#define size1 100005
const char nl = '\n';

#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define mem(name, value) memset(name, value, sizeof(name))

/*** STLs ***/
typedef vector <ll> vll;
typedef set <ll> sll;
typedef multiset <ll> msll;
typedef queue <ll> qll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef vector <pair <ll , ll> > vpll;

/*** Sorts ***/
#define all(v) (v).begin(), (v).end()
#define rev(v) reverse(all(v))
#define srt(v) sort(all(v))
#define srtGreat(v) sort(all(v), greater<ll>())
inline bool cmp(pll a, pll b) { if (a.ff == b.ff)return a.ss < b.ss; return a.ff > b.ff; }

#define en cout << '\n';
#define no cout << "NO" << '\n'
#define yes cout << "YES" << '\n'
#define case cout << "Case " << t++ << ": "

/*** Functions
ll BigMod(ll base, ll pow, ll modvalue){ if (pow == 0) return 1;  ll ans = BigMod(base, pow / 2, modvalue);ll total = ((ans % modvalue) * (ans % modvalue)) % modvalue;  if(pow % 2 == 0) return total; else{ return (total * (base % modvalue) ) % modvalue; } }
ll InverseMod(ll base, ll pow) { if(pow == 0) return 1; ll ans = InverseMod(base, pow / 2); ans = (ans * ans) % mod; if(pow & 1){ return (ans * base) % mod; } else{ return ans; } }
bool checkprime(ll num) { if(num < 2) return false; for(ll i = 2; i * i <= num; i++){ if(num % i == 0) return false; } return true; }
ll EularPHI(ll num) { double ans = num; for(ll i = 2; i * i <= num; i++){ if(num % i == 0){ while (num % i == 0) { num /= i; } ans *= (1.0 - (1.0 / (double)i)); } } if(num > 1) ans *= (1.0 - (1.0 / (double)num)); return (ll)ans; }
ll sumofdigit(long ll n){ll sum=0;while(n){sum=sum+n%10;n=n/10;}return sum;}
ll countDigit(ll n) { if (n == 0) return 0; return 1 + countDigit(n / 10); }
ll countDigit(ll n) { return floor(log10(n) + 1); } //only positive
 ***/

template <class T> inline T gcd(T a, T b) {if (b == 0)return a; return gcd(b, a % b);}
template <class T> inline T lcm(T a, T b) {return a * b / gcd<T>(a, b);}
template <class T> inline T power(T b, T p) {ll ans = 1; while (p--) ans *= b; return ans;}

ll pw(ll a, ll b) {
    ll c = 1;
    for (ll i = 0; i  < b;i ++) {
        c = (1LL * c * a) % mod;
    }
    return c;
}

void solve()
{	
	ll n;
    cin >> n;
    ll f = pw(10, n);
    f -= 2LL * pw(9, n);
    f += pw(8, n);
    f %= mod;
    if (f < 0) f += mod;
    cout << f;
}


int main()
{

#ifndef ONLINE_JUDGE
	freopen("C:/Users/91731/Documents/input.txt", "r", stdin);
	freopen("C:/Users/91731/Documents/output.txt", "w", stdout);
	freopen("C:/Users/91731/Documents/error.txt", "w", stderr);
#endif

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	solve();
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>

using ll = long long;

int main() {
    int N, M;
    std::cin >> N >> M;

    int maxL = 0;
    int minR = 100000;
    for (int i = 0; i < M; i++) {
        int l, r;
        std::cin >> l >> r;
        maxL = std::max(maxL, l);
        minR = std::min(minR, r);
    }

    std::cout << std::max(0, minR - maxL + 1) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cassert>
#include <map>
#include <set>
using namespace std;
int ans = 0;
int n, k;
vector<vector<int>> gr;
int Dfs(int v, int from) {

  int mx = 0;
  int cnt = 0;
  for (auto to : gr[v]) {
    auto res = Dfs(to, v);
    if (res != -1) {
      mx = max(mx, res);
      cnt++;
    }
  }
  if (cnt) {
    mx++;
  }
  if (!(mx == k && v == 0)) {
    if (!(mx == k - 1 && from == 0)) {
      if (mx == k - 1) {
        ans++;
        return -1;
      }
      assert(mx < k - 1);
    }
  }
  return mx;
}

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

  cin >> n >> k;
  vector<int> v(n);
  gr.resize(n);
  for (int& val : v) {
    cin >> val;
    val --;
  }
  if (v[0] != 0) {
    ans++;
    v[0] = 0;
  }

  for (int i = 0; i < n; i++) {
    if (i != 0) {
      gr[v[i]].push_back(i);
    }
  }

  Dfs(0, 0);
  cout << ans << endl;



  return 0;
}

Measured memory_bytes: 12416
#include<cstdio>

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

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		rep(i,n) scanf("%*d%*d");
		puts("0.000000000000000 0.000000000000000");
	}
	return 0;
}

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

int main() {
  int d;
  while(cin >> d) {
    int sum = 0;
    int n = 1;
    while(n * d < 600) {
      sum += n*d * n*d * d;
      n++;
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 3084
#include <iostream>
#define N 5000

using namespace std;

void input();
void pro();

bool ok = false;
char c[N][N];

int x[N];
int ans[N];
int n, m;
int v = 0;
int at = 0;
int a, b;
int i, j, l;

int main() {

	input();
	pro();

	for (i = 0; i < n; i++) cout << ans[i] + 1 << endl;

	if (ok == true)cout << "1" << endl;
	else cout << "0" << endl;

	//	cin >> n;

	return 0;

}

void input() {

	cin >> n >> m;
	for (i = 0; i < m; ++i) {

		cin >> a >> b;

		--a; --b;

		c[a][b] = 1;
		c[b][a] = 2;
		++x[b];

	}
}

void pro() {

	for (i = 0; i<n; ++i) {

		v = 0;

		for (j = 0; j<n; ++j) {

			if (x[j] == 0) {
				at = j;
				++v;

			}
		}

		//		printf("%d\n", v);

		if (v >= 2)ok = true;
		x[at] = 5000;
		ans[i] = at;
		for (j = 0; j<n; ++j)if (c[j][at] == 2) --x[j];

	}
}



Measured memory_bytes: 27520
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define sz(x) ((int)x.size())

int d;
vector<vector<int>> dp(100005, vector<int>(101, -1));
const int mod = 1000*1000*1000 + 7;

int digitDP(int index, int rem, int fit, string &number)
{
    if(index == -1)
        return (rem == 0) ? 1 : 0;
    if(!fit && dp[index][rem] != -1)
        return dp[index][rem];
    int limit = (fit) ? (number[index]-'0') : 9, cnt = 0;
    for(int i = 0; i <= limit; i++)
    {
        int newFit = (fit && (i == limit)) ? 1 : 0;
        cnt += digitDP(index-1, (rem-i+1000*d)%d, newFit, number);
        cnt %= mod;
    }
    if(!fit)
        dp[index][rem] = cnt;
    return cnt;
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string k;
    cin >> k;
    reverse(k.begin(), k.end());
    cin >> d;
    cout << (digitDP(sz(k)-1, 0, 1, k) - 1 + mod)%mod << endl;
}

Measured memory_bytes: 86360
R, G, B, N = (int(i) for i in input().split())


res = 0
for ri in range(N // R + 1):    
    for gi in range(N // G + 1):
        if (N - (ri * R + gi * G)) % B == 0 and N - (ri * R + gi * G) >= 0:
            res += 1    
print(res)



Measured memory_bytes: 40556
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
using namespace std;

const long long MOD = pow(10, 9) + 7;

int main()
{
    int N;
    string S1, S2;
    cin >> N >> S1 >> S2;

    if (S1.size() == 1) {
        cout << 3 << endl;
    } else if (S1.size() == 2) {
        cout << 6 << endl;
    } else {
        long long ans = 6;
        int start;
        if (S1[1] == S2[1])
            start = 2;
        else {
            start = 3;
        }
        for (int i = start; i < S1.size(); i++) {
            if (S1[i] == S2[i]) { //縦並び
                if (S1[i - 1] == S2[i - 1]) { //一個前も縦並び
                    ans *= 2;
                } else { //一個前が横並び
                    //付け加わる部分の色は1つしかありえない
                }
            } else { //横並び
                if (S1[i - 1] == S2[i - 1]) { //一個前が縦並び
                    ans *= 2;
                } else { //一個前が横並び
                    ans *= 3;
                }
                //横並びのものはインデックス2つ分
                i++;
            }
            ans %= MOD;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll max_n=1e5+100;
const ll inf=0x3f3f3f3f;
int t,n,a[max_n],dp[max_n];
int main(){
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    dp[0]=0;dp[1]=abs(a[0]-a[1]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i-1]-a[i]));
    }cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 4484
#include<bits/stdc++.h>
#define pb push_back
#define mod int(1e9+7)
#define N int(2e5+100)
#define ll long long int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define si second
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
   ll n,k,s=0ll,e=0ll,ans=0ll;
   cin>>n>>k;
   for(int i=0;i<k;i++){
      s+=i;
      e+=(n-i);
   }
   for(int j=k;j<=n+1;j++){
      ans=(ans+e-s+1ll)%mod;
      while(ans<0ll)
         ans+=mod;
      e+=(n-j);
      s+=j;
   }
   cout<<ans<<'\n';
   return 0;
}



Measured memory_bytes: 3652
a, b, c = map(int, input().split( ));
if a > b:
    a, b = b, a
    if b > c:
        b, c = c, b
        if a > b:
            a, b = b, a
            print(f"{a} {b} {c}")
        elif a < b or a ==b:
            print(f"{a} {b} {c}")
    elif b < c or b == c:
            print(f"{a} {b} {c}")
elif a < b :
    if b > c:
        b, c = c, b
        if a > b :
            a, b = b, a
            print(f"{a} {b} {c}")
        elif a < b or a == b:
            print(f"{a} {b} {c}")
    elif b < c or b == c:
        print(f"{a} {b} {c}")


Measured memory_bytes: 5620
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_postal_code(void) {
	int a, b;
	string s;
	string msg = "Yes";
	cin >> a >> b >> s;
	if (s.size() != a + b + 1) msg = "No";
	else if (s[a] != '-') msg = "No";
	else {
		for (int i = 0; i < a + b + 1; i++) {
			if (i == a) continue;

			if (s[i] == '-') {
				msg = "No";
				break;
			}
		}
	}
	cout << msg << endl;
}

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

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}
int32_t main()
{
	long double a,b,x;
	cin >> a >> b;
	x=a*b;
	cout << (int)x;
}


Measured memory_bytes: 3748
#include<stdio.h>
int main(void){
  int i;
  int j;
  int k=0;
  int t;
  int h;
  int count=0;
  int sum1=0;
  int sum2=0;
  int min=100000;
  int ataro[1000]={0};
  int ahanako[1000]={0};
  int taro[1000];
  int hanako[1000];

  while(1){
    scanf("%d %d",&t,&h);
    if(t==0)
      break;
    count++;

    for(i=0;i<t;i++){
      scanf("%d",&taro[i]);
      sum1+=taro[i];
    }
    for(i=0;i<h;i++){
      scanf("%d",&hanako[i]);
      sum2+=hanako[i];
    }
    min=10000;
    for(i=0;i<t;i++){
      for(j=0;j<h;j++){
	if(sum1-taro[i]+hanako[j]==sum2-hanako[j]+taro[i]&&min>taro[i]+hanako[j]){
	  ataro[k]=taro[i];
	  ahanako[k]=hanako[j];
	  min=taro[i]+hanako[j];
	}
      }
    }
    k++;
    sum1=0;
    sum2=0;
  }

  for(i=0;i<count;i++){
    if(ataro[i]==0)
      printf("-1\n");
    else
      printf("%d %d\n",ataro[i],ahanako[i]);
  }
  return 0;
}



Measured memory_bytes: 2752
dic = { c: i for i, c in enumerate('abcdefghijklmnopqrstuvwxyz')}

n = int(input())
strs = [tuple(sorted(map(lambda x: dic[x], input())))  for _ in range(n)]

a = {}
for s in strs:
  if s not in a:
    a[s] = 1
  else:
    a[s] += 1

print(sum(item[1]*(item[1]-1)//2 for item in a.items()))


Measured memory_bytes: 26000
import sys
[print([670, 660, 633, 592, 540, 480, 415, 348, 282, 220, 165, 120, 84, 56, 35, 20, 10, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0][abs(18 - int(e))]) for e in sys.stdin]


Measured memory_bytes: 5608
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 101010;
int n , A , B , x[N];

int main(){
    scanf("%d%d%d",&n,&A,&B);
    rep(i,1,n+1) scanf("%d",x + i);
    ll ans = 0;
    rep(i,2,n+1) ans += min(1ll * (x[i] - x[i-1]) * A , (ll)B);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	cin>>n;
	int a[2*n];
	rep(i,2*n)cin>>a[i];
	sort(a,a+2*n);
	int p=0,sum=0;
	rep(i,n){
		sum+=a[2*i];
	}
	cout<<sum<<endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N + 2, 0);
  int start = 0;
  int total = 0;
  for (int i = 1; i <= N; ++i) {
    cin >> A[i];
    total += abs(abs(A[i] - start));
    start = A[i];
  }
  total += abs(A[N]);
  vector<int> memo(N + 1);
  for (int i = 1; i <= N; ++i) {
    int last = A[i] - A[i - 1], next = A[i + 1] - A[i];
    if (last < 0 && 0 < next || 0 < last && next < 0) {
      memo[i] = min(abs(last), abs(next)) * 2;
    }
  }
  for (int i = 1; i <= N; ++i) {
    cout << total - memo[i] << endl;
  }
}

Measured memory_bytes: 2048
n = int(input())
s = []


for i in range(n):
    x = list(str(input()))
    x.sort()
    s.append(''.join(x))

    
s.sort()
count = 0
ans = 0

import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

import math
for i in range(n-1):
    if s[i] == s[i+1]:
        count += 1
        if i == n-2:
            ans += comb(count+1,2)
    else:
        if count != 0:
            ans += comb(count+1,2)
        count = 0

print(ans)

Measured memory_bytes: 11484
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-13

#define INF 1e9
int const MaxSize = 2e5 + 10;
int n, a[MaxSize];

int main() {
	ios_base::sync_with_stdio(false);
//	freopen("/Users/george/A_1.in", "r", stdin);

	cin >> n;

	LPE(i, 1, n)
	{
		cin >> a[i];
	}

	for (int i = n; i >= 1; i -= 2)
		cout << a[i] << " ";

	int start = 1;
	if (n % 2) {
		start = 2;
	}

	for (int i = start; i < n; i += 2)
		cout << a[i] << " ";

	return 0;
}


Measured memory_bytes: 2944
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//228
	int n;
	cin>>n;
	ll cnt = 0;
	while(n--) {
		int val;
		cin>>val;
		while((val&1)!=1) {
			cnt++;
			val>>=1;
		}
	}
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

int main(){
	int n; cin >> n;
	vll a(n);
	Loop(i, n) {
		cin >> a[i];
	}
	ll ans = a[0] - 1, m = 2;
	Loop1(i, n - 1) {
		if (a[i] > m) {
			ans += ((a[i] - 1) / m);
		}
		else {
			m = max(m, a[i] + 1);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>

using namespace std;

class Digraph {
  int n;
  vector<vector<int>> adj;

  void dfs (int u, vector<int> &vis, bool &ok) {
    vis[u] = 1;
    for (int nxt : adj[u]) {
      if (vis[nxt] == 0) {
        dfs(nxt, vis, ok);
      } else if (vis[nxt] == 1) {
        ok = false;
      }
    }
    vis[u] = 2;
  }
  
public:
  Digraph (int _n) : n(_n), adj(_n, vector<int> (0)) {}

  void add_edge (int u, int v) {
    adj[u].push_back(v);
  }

  bool dag () {
    vector<int> vis (n, 0);
    for (int i = 0; i < n; i++) {
      if (vis[i] == 0) {
        bool ok = true;
        dfs(i, vis, ok);
        if (!ok) return false;
      }
    }
    return true;
  }
};

const int MAX_N = 55;

int conn_a [MAX_N][MAX_N];
vector<int> adj_a [MAX_N];
vector<int> adj_b [MAX_N];

int safe [MAX_N];
void find_safes (int u, int p) {
  safe[u] = 1;
  for (int nxt : adj_b[u]) {
    if (nxt != p) {
      if (conn_a[u][nxt]) {
        find_safes(nxt, u);
      }
    }
  }
}

void fill_graph_a (int u, int p, Digraph &G) {
  for (int nxt : adj_a[u]) {
    if (nxt != p) {
      if (!safe[u]) {
        G.add_edge(u, nxt);
      }
      fill_graph_a(nxt, u, G);
    }
  }
}

void fill_graph_b (int u, int p, Digraph &G) {
  for (int nxt : adj_b[u]) {
    if (nxt != p) {
      if (!safe[u]) {
        G.add_edge(nxt, u);
      }
      fill_graph_b(nxt, u, G);
    }
  }
}

int try_root (int root, int n) {
  for (int i = 0; i < n; i++) {
    safe[i] = 0;
  }
  find_safes(root, -1);

  Digraph G (n);
  fill_graph_a(root, -1, G);
  fill_graph_b(root, -1, G);

  if (G.dag()) {
    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (!safe[i]) {
        ans++;
      }
    }
    return ans;
  } else {
    return MAX_N;
  }
}

int try_roots (int root_a, int root_b, int n) {
  for (int i = 0; i < n; i++) {
    safe[i] = 0;
  }

  Digraph G (n);
  fill_graph_a(root_a, -1, G);
  fill_graph_b(root_b, -1, G);

  if (G.dag()) {
    return n;
  } else {
    return MAX_N;
  }
}

void solve () {
  for (int i = 0; i < MAX_N; i++) {
    adj_a[i].clear();
    adj_b[i].clear();
    for (int j = 0; j < MAX_N; j++) {
      conn_a[i][j] = 0;
    }
  }
  
  int n;
  cin >> n;
  
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--; v--;

    conn_a[u][v] = 1;
    conn_a[v][u] = 1;
    adj_a[u].push_back(v);
    adj_a[v].push_back(u);
  }

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--; v--;

    adj_b[u].push_back(v);
    adj_b[v].push_back(u);
  }

  int ans = MAX_N;
  for (int i = 0; i < n; i++) {
    ans = min(ans, try_root(i, n));
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i != j) {
        ans = min(ans, try_roots(i, j, n));
      }
    }
  }
  
  if (ans == MAX_N) {
    cout << -1 << '\n';
  } else {
    cout << ans << '\n';
  }
}

int main () {
  ios::sync_with_stdio(false);

  int testc;
  cin >> testc;

  for (int i = 0; i < testc; i++) {
    solve();
  }
}


Measured memory_bytes: 3664
#include <limits>
#include <initializer_list>
#include <utility>
#include <bitset>
#include <tuple>
#include <type_traits>
#include <functional>
#include <string>
#include <array>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <complex>
#include <random>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <regex>
#include <cassert>
#include <cstddef>
#ifdef CPP17
#include <variant>
#endif

#define endl codeforces

#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)

using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
using size_type = ssize_t;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

template <typename T, std::size_t Head, std::size_t... Tail> 
struct multi_dim_array { using type = std::array<typename multi_dim_array<T, Tail...>::type, Head>; };

template <typename T, std::size_t Head> 
struct multi_dim_array<T, Head> { using type = std::array<T, Head>; };

template <typename T, std::size_t... Args> using mdarray = typename multi_dim_array<T, Args...>::type;

#ifdef CPP17
template <typename T, typename F, typename... Args> 
void fill_seq(T &t, F f, Args... args) { 
    if constexpr (std::is_invocable<F, Args...>::value) { 
        t = f(args...); 
    } else { 
        for (size_type i = 0; i < t.size(); i++) fill_seq(t[i], f, args..., i); 
    } 
}
#endif

template <typename T> vec<T> make_v(size_type sz) { return vec<T>(sz); }

template <typename T, typename... Tail> 
auto make_v(size_type hs, Tail&&... ts) { 
    auto v = std::move(make_v<T>(std::forward<Tail>(ts)...)); 
    return vec<decltype(v)>(hs, v); 
}

namespace init__ { 
struct InitIO { 
    InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } 
} init_io; 
}


int main() {
    ll n;
    std::cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        ll cnt = n / i;
        ans += cnt * (cnt + 1) / 2 * i;
    }
    std::cout << ans << "\n";
    return 0;
}


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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> v(n, 0);
  for(int i = 0; i < q; i++){
    int a;
    cin >> a;
    v.at(a-1)++;
  }
  for(int i = 0; i < n; i++){
    if(v.at(i) > q - k)
      cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 1024
def read_int_list():
    return list(int(i) for i in input().split())

n = int(input())
k = int(input())
x = read_int_list()

typeA=0
typeB=k
ans=0
for i in range(len(x)):
    ans += min(abs(x[i]-typeA),abs(x[i]-typeB))
print(ans*2)

Measured memory_bytes: 3060