akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    long long X,Y;
    cin >> X >> Y;
    
   cout << ( X%Y == 0 ? -1 : X ) << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var abc = sc.ArrayInt(3).OrderBy(val => val).ToArray();
        WriteLine((abc[0] * abc[1]) / 2);
    }
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, long long K, vector<long long> p){
	double res = 0, now = 0;
	rep(i, K) {
		res += (p[i]+1)/2.0;
	}
	now = res;
	rep(i, N-K) {
		now -= (p[i]+1)/2.0;
		now += (p[i+K]+1)/2.0;
		res = max(res, now);
	}
	printf("%.16f\n", res);
}

int main(){	
	long long N;
	long long K;
	scanf("%lld",&N);
	vector<long long> p(N-1+1);
	scanf("%lld",&K);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&p[i]);
	}
	solve(N, K, p);
	return 0;
}



Measured memory_bytes: 3328
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2) 
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions 

#endif


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

    int N; cin >> N;
    vi H(N); REP(i, N) cin >> H[i];

    int cnt = 0;
    int ans = 0;
    int l = 0, r = 0;
    while (l < N) {
        while (r + 1 < N && H[r] >= H[r + 1]) {
            r++;
        }
        ans = max(ans, r - l);
        
        l = r + 1;
        r = l;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main(void)
{
	int a,b,d,i,j;
	char c[6]="ABCDE";
	scanf("%d %d",&a,&b);
	while(a!=0 && b!=0){
		j=0; d=a+b;
		for(i=1;i<5;i++){
			scanf("%d %d",&a,&b);
			if(a+b>d){
				d=a+b; j=i;
			}
		}
		printf("%c %d\n",c[j],d);
		scanf("%d %d",&a,&b);
	}
	return 0;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        map<int,int> cnt; LL sum = 0;
        FOR(i,0,n) {
            int a; cin >> a; sum += a; cnt[a]++;
        }
        int q; cin >> q;
        FOR(_,0,q) {
            int b,c; cin >> b >> c;
            const LL x = cnt[b];
            sum -= b*x; cnt[b] = 0;
            sum += c*x; cnt[c] += x;
            cout << sum << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 8068
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int n = sc.nextInt();

        final long[] a = new long[n];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        long ans = a[0];
        for (int i = 1; i < n; i++) {
            ans = gcm(ans, a[i]);
        }

        System.out.println(ans);
    }

    private static long lcd(final long a, final long b) {
        if (b == 0) return a;
        return lcd(b, a % b);
    }

    private static long gcm(final long a, final long b) {
        return a / lcd(a, b) * b;
    }
}



Measured memory_bytes: 26324
#include<stdio.h>
int main(void){
	int h,m,S,s,a;
	scanf("%d",&S);
	h=S/3600;
	a=S%3600;
	m=a/60;
	s=a%60;
	printf("%d:%d:%d\n",h,m,s);
return 0;
}
	
	


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

using namespace std;

#define int          long long
#define mem(a , v)   memset(a , v , sizeof a)
#define all(v)       v.begin() , v.end()
#define err(x)       cerr << #x << " is : " << x << endl
#define endl         "\n"



const int MOD   =   1e9 + 7;
const int N     =   1e6 + 20;
const int big   =   1e14;

void solve()
{
    int n , m , k;
    cin >> n >> m >> k;
    vector <vector <char> > a(n + 1 , vector <char> (m));
    vector <vector <char> > save(n + 1 , vector <char> (m));
    int blacks = 0;
    for(int i = 1; i <= n ; i++)
        for(int j = 1 ;j <= m; j++)
        {
            cin >> a[i][j] , save[i][j] = a[i][j];
            blacks += (a[i][j] == '#');
        }

    int temp = blacks ,cnt = 0;
    for(int i = 0 ; i < (1 << n) ; i++)
    {
        for(int j = 0 ; j < (1 << m); j++)
        {
            save = a;
            bitset <6> x(i) , y(j);

            blacks = temp;
            for(int k = 1 ; k <= n ; k++)
            {
                for(int l = 1 ; l <= m ; l++)
                {
                        if(a[k][l] == '#')
                        {
                            if(x[k - 1] > 0 or y[l - 1] > 0)
                                blacks--;
                        }
                }
            }
            if(blacks == k)
                cnt++;
        }
    }
    cout << cnt << endl;
    return;
}


int32_t main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie();

    int t = 1;
    //cin >> t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
int main(void){
    int card[4][14],n,i,j,d;
    char c;
    scanf("%d",&n);
    for(i=0;i<4;i++){
        for(j=0;j<14;j++){
            card[i][j]=0;
        }
    }
    for(i=0;i<n;i++){
        scanf(" %c %d",&c,&d);
        if(c=='S'){
            card[0][d]=1;
        }else if(c=='H'){
            card[1][d]=1;
        }else if(c=='C'){
            card[2][d]=1;
        }else if(c=='D'){
            card[3][d]=1;
        }
    }
    for(i=0;i<4;i++){
        for(j=1;j<14;j++){
            if(card[i][j]==0){
                if(i==0){
                    printf("S");
                }else if(i==1){
                    printf("H");
                }else if(i==2){
                    printf("C");
                }else if(i==3){
                    printf("D");
                }
                printf(" ");
                printf("%d\n",j);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {
    public static void main(String[]args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt(), k = s.nextInt();
        if (k == 1) {
            System.out.println(0);
        } else {
            System.out.println(n - k);
        }
    }
}

Measured memory_bytes: 21844
//raja1999
 
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
 
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
 
using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define int ll
 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
 
 
//std::ios::sync_with_stdio(false);
 
int main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	string s;
  	cin>>s;
  	string ans="";
    ans+=s[0];
  	ans+=s[1];
  	ans+=s[2];
  	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	int res = 0;
	while (n > 0) {
		res++;
		n /= k;
	}
	cout << res << endl;
}


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

int main() {
    int t = 1;
    while(t--) {
        int n;
        cin>>n;
        vector<int> a(n);
        for(int i=0; i<n; i++) {
            cin>>a[i];
        }        
        int ans = 0;
        for (size_t i = 0; i < n; i++)
        {
            for (size_t j = i+1; j < n; j++)
            {
                for (size_t k = j+1; k < n; k++)
                {
                    if(a[i] != a[j] && a[j] != a[k] && a[i] != a[k] && a[i] + a[j] > a[k] && a[j] + a[k] > a[i] && a[i] + a[k] > a[j]){
                        // cout<<i+1<<" "<<j+1<<" "<<k+1<<endl;
                        ans++;
                    }
                }
                
            }
            
        }

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

Measured memory_bytes: 3592
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 1e6+1;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//sieve(MAX);でベクトルIsPrimeに「MAXまでの数値の素数の真偽」を格納する。
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
// ここから開始

int main(){
    int x,y;
    cin>>x>>y;
    if(x%y==0) cout<<-1<<endl;
    else cout<<x<<endl;
    return 0;
}



Measured memory_bytes: 256
def partition(a,b,c,p,r):
  x = a[r]
  i = p - 1
  
  for j in range(p,r):
    if x >= a[j]:
      i += 1
      a[i],a[j] = a[j],a[i]
      b[i],b[j] = b[j],b[i]
      c[i],c[j] = c[j],c[i]
      
  a[i+1],a[r] = a[r],a[i+1]
  b[i+1],b[r] = b[r],b[i+1]  
  c[i+1],c[r] = c[r],c[i+1]
  return i+1
  
def quickSort(a,b,c,p,r):
  if p < r:
    q = partition(a,b,c,p,r)
    quickSort(a,b,c,p,q-1)
    quickSort(a,b,c,q+1,r)
  
def checkStable(a,b):
  for i in range(1,len(a)):
    if a[i-1] == a[i]:
      if b[i-1] > b[i]:
        return "Not stable"
  return "Stable"
  
n = int(input())
mark = [""]*n
num = [0]*n
count = [i for i in range(n)]
for i in range(n):
  mark[i],num[i] = input().split()
num = list(map(int,num))

quickSort(num,mark,count,0,n-1)
print(checkStable(num,count))
for i in range(n):
  print(mark[i],num[i])

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

typedef long long lglg;

int main() {
    ios::sync_with_stdio(0);//, cin.tie(0), cout.tie(0);

	string weather[3] = {"Sunny", "Cloudy", "Rainy"};
	string x; cin >> x;
	int n;
	for (int i=0; i<3; ++i) if (weather[i] == x) n = i;
	cout << weather[(n+1)%3];
}

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

int main()
{    int A,B,C;
    long int X,Y;
    cin>>A>>B>>C>>X>>Y;
    long int sum=0;
    int index=2*C;
    if(A+B <= index)
        sum=A*X+B*Y;
    else {
        if(X<Y){
            if(index <= B)
                sum=index*Y;
        else    sum=index*X+B*(Y-X);
            }
        else{
            if(index <= A)
                sum=index*X;
            else    sum=index*Y+A*(X-Y);
        }
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int h,w,n; cin >> h >> w >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<deque<int>> s(h);
  
  int cnt = 0;
  rep(i,n){
    rep(j,a[i]){
      if((cnt/w)%2 == 0){
        s[cnt/w].push_back(i+1);
      }else{
        s[cnt/w].push_front(i+1);
      }
      cnt++;
    }
  }
  
  rep(i,h){
    for(auto q:s[i]){
      cout << q << " ";
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 384
import sys

Line = [int(s) for s in input().split()]

N,K = Line[0],Line[1]

Line = [int(s) for s in input().split()]

Line.sort()

# print(Line)

ans = 0
count = 0

for i in Line:
    ans += i
    count +=1
    if count == K:
        print(ans)
        sys.exit()

Measured memory_bytes: 9272
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<deque>
#define f(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
const int neko=200010;
int n,a[neko];
std::deque<int>q;
int main()
{
	scanf("%d",&n);
	f(i,1,n)scanf("%d",&a[i]);
	int opt=n&1;
	f(i,1,n)
	{
		if((i&1)^opt)q.push_back(a[i]);
		else q.push_front(a[i]);
	}while(!q.empty())printf("%d ",q.front()),q.pop_front();
	return 0;
}

Measured memory_bytes: 3712
import java.util.*;
import java.io.*;

public class Main {

	static int my[]= {1,0,-1,0}, mx[]= {0,1,0,-1};//n,e,s,w
	static int h,w;
	static int d[][],sidew[][],udw[][];
	
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);

		while(true) {
			w=Integer.parseInt(in.next()); h=Integer.parseInt(in.next());
			if(h==0)break;
			
			d=new int[h][w];sidew=new int[h][w-1]; udw=new int[h-1][w];

			for(int i=0;i<h;i++) {
				for(int j=0;j<w-1;j++)sidew[i][j]=Integer.parseInt(in.next());
				if(i!=h-1)for(int j=0;j<w;j++)udw[i][j]=Integer.parseInt(in.next());
			}
			
			Stack<point> stk=new Stack<>();
			point p=new point();
			p.x=0; p.y=0; stk.push(p);
			d[0][0]=1;
			DFS(0,0);
			
			System.out.println(d[h-1][w-1]);
		}
		
	}
	
	static void DFS(int x,int y) {
		
		//n,e,s,w
		if(y+1<h && udw[y][x]!=1 && (d[y+1][x]==0 || d[y+1][x]>d[y][x]+1)) {
			d[y+1][x]=d[y][x]+1;
			DFS(x,y+1);
		}
		if(x+1<w && sidew[y][x]!=1 && (d[y][x+1]==0 || d[y][x+1]>d[y][x]+1)) {
			d[y][x+1]=d[y][x]+1;
			DFS(x+1,y);
		}
		if(y-1>=0 && udw[y-1][x]!=1 && (d[y-1][x]==0 || d[y-1][x]>d[y][x]+1)) {
			d[y-1][x]=d[y][x]+1;
			DFS(x,y-1);
		}
		if(x-1>=0 && sidew[y][x-1]!=1 && (d[y][x-1]==0 || d[y][x-1]>d[y][x]+1)) {
			d[y][x-1]=d[y][x]+1;
			DFS(x-1,y);
		}
	}

}

class point{
	int x,y;
}



Measured memory_bytes: 71696
#include<stdio.h>
 
int main(){
	int i,num,X,Y,cnt;
    cnt = 0;
    if(scanf("%d%d",&X,&Y) == -1){
    	return 0;
    }
    for(i = 0;i <= X;i++){
        num = 2*i + 4*(X - i);
        if(num == Y){
        	cnt++;
        }
	}
    
    if(cnt == 0){
    	printf("No\n");
    }else{
    	printf("Yes\n");
    }
    
    return 0;
}

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

vector<int> adjList[202020];
long long ar[202020];

void dfs(int cur, int last, int total) {
    ar[cur] += total;
    for (auto nxt : adjList[cur])
        if (nxt != last)
            dfs(nxt, cur, ar[cur]);
}
 
int main() {
    int n, q;
    cin >> n >> q;
    
    int a, b;

    for (int ctr1 = 1; ctr1 < n; ++ctr1)
        cin >> a >> b, --a, --b, adjList[a].push_back(b), adjList[b].push_back(a);
    
    for (int ctr1 = 0; ctr1 < q; ++ctr1)
        cin >> a >> b, ar[a - 1] += b;

    dfs(0, -1, 0);
    
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
        cout << ar[ctr1] << " ";
    return 0;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=1e17;
const ll ms=(2e6)+5;


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

    if(n%2)cout<<"0";
    else{
        ll p=5;
        ll ans=0;
        ll x;
        while(p<=n)
        {
            x=n/p;
            ans+=(x/2);
            p*=5;
        }
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 3604
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
a=list(input())
a=list(map(int,a))
ans=0
for i in range(10):
    s=set(a)
    if i in s:
        p=a.index(i)
        for j in range(10):
            s=set(a[p+1:])
            if j in s:
                q=a[p+1:].index(j)+p+1
                for k in range(10):
                    s=set(a[q+1:])
                    if k in s:
                        ans+=1
print(ans)

Measured memory_bytes: 219892
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int l, a, b, c, d;
    cin >> l >> a >> b >> c >> d;

    int ret = l - max((a + c - 1) / c, (b + d - 1) / d);
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1160
import numpy as np

N = int(input())
As = sorted(map(int, input().split()))

flgs = np.full(10**6+1, False)
flgs[As] = True

for i, A in enumerate(As):
    if flgs[A] == True:
        flgs[::A] = False
        if i+1 == len(As) or As[i+1] != A:
            flgs[A] = True

print(np.count_nonzero(flgs))

Measured memory_bytes: 51428
from math import sqrt
count = [0] * 10001
p = 100
for x in range(1,p+1):
    for y in range(1,p+1):
        for z in range(1,p+1):
            if x*x + y*y + z*z + x*y + y*z + z*x <= 10000:
                count[x*x + y*y + z*z + x*y + y*z + z*x] += 1
N = int(input())
for i in range(1,N+1):
    print(count[i])

Measured memory_bytes: 69364
#include "bits/stdc++.h"
using namespace std;

template<class Abel> struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<Abel> diff_weight;

	UnionFind(int n = 1, Abel SUM_UNITY = 0) {
		init(n, SUM_UNITY);
	}

	void init(int n = 1, Abel SUM_UNITY = 0) {
		par.resize(n); rank.resize(n); diff_weight.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
	}

	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			int r = root(par[x]);
			diff_weight[x] += diff_weight[par[x]];
			return par[x] = r;
		}
	}

	Abel weight(int x) {
		root(x);
		return diff_weight[x];
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y, Abel w) {
		w += weight(x); w -= weight(y);
		x = root(x); y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) swap(x, y), w = -w;
		if (rank[x] == rank[y]) ++rank[x];
		par[y] = x;
		diff_weight[y] = w;
		return true;
	}

	Abel diff(int x, int y) {
		return weight(y) - weight(x);
	}
};

int main() {
	int N, M;
	cin >> N >> M;
	UnionFind<int> uf(N);
	for (int i = 0; i < M; ++i) {
		int l, r, d;
		cin >> l >> r >> d;
		--l, --r;
		if (uf.issame(l, r)) {
			int diff = uf.diff(l, r);
			if (diff != d) {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			uf.merge(l, r, d);
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 4592
from bisect import bisect_right

n = int(input())
a = list(map(int, input().split()))

r = [400, 800, 1200, 1600, 2000, 2400, 2800, 3200]
c = [0] * 9

for score in a:
	i = bisect_right(r, score)
	c[i] += 1

ans = 8 - c[:-1].count(0)

print(max(1, ans), ans + c[8])

Measured memory_bytes: 38256
#include <stdio.h>
#include <stdlib.h>

int dsc(const void *a, const void *b){
  return *(int *)b - *(int *)a;
}

int
main(int argc, char *argv[])
{
  int n, a[100];
  scanf("%d", &n);
  for(int i = 0; i < n; i++) scanf("%d", &a[i]);

  qsort(a, n, sizeof(int), dsc);

  int ans = 0;

  for(int i = 0; i < n; i++){
    if(i % 2 == 0) ans += a[i];
    else ans -= a[i];
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

int dp[1<<18][51],popcount[1<<18], a[18], b[18], n;
int solve(int msk,int prv){
	int c = popcount[msk];
	if( c == n )return 0;
	int & ans = dp[msk][prv];
	if( ans !=-1 )return ans;
	ans = 1e15;
	int smaller = 0;
	for(int i=0;i<n;i++){
		if( msk >> i & 1 )continue;
		int cur = abs(c-i)&1 ? b[i] : a[i];
		if( cur >= prv ){
			ans = min(ans,smaller + solve(msk|1<<i,cur));
		}
		smaller++;
	}
	return ans;
}
	
int32_t main(){
	IOS
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<1<<18;i++){
		popcount[i]=__builtin_popcount(i);
	}
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	int ans = solve(0,0);
	cout<<(ans<1e15?ans:-1);
}
 
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 110116
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

#n = int(input())
#n,a = [int(i) for i in readline().split()]
n,x = [int(i) for i in readline().split()]

sou = [1]*51
pat = [1]*51
for i in range(50):
    sou[i+1] = 2*sou[i]+3
    pat[i+1] = 2*pat[i]+1
#print(sou)
#print(pat)

# B L-1 P L-1 B
def solve(n,x):
    if x==0: return 0
    if n==0:
        if x == 0: return 0
        else: return 1

    if x <= sou[n-1]+1:
        return solve(n-1,x-1)
    elif x == sou[n-1]+2:
        return pat[n-1]+1
    elif x == sou[n]:
        return pat[n]
    else:
        return pat[n-1] + 1 + solve(n-1,x-sou[n-1]-2)
        
print(solve(n,x))        






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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define swapll(x, y) { ll tmp = x; x = y; y = x; }

int main()
{
  ld h,w;
cin >> h >> w;

  ll ans = ceil(h * w / 2);
  if(w == 1 || h == 1)
  {
  	ans = 1;
  }
  
  cout << fixed << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
   public static void main(String[] args) {  
      Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();
      int y = sc.nextInt();
      int z = sc.nextInt();
      
      x-=z;
      System.out.println(x/(y+z));      
   }
}

Measured memory_bytes: 21332
// B - Grid Compression
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int H,W; cin>>H>>W;
	vector<string> A(H);
	rp(i, 0, H) cin>>A[i];

	vector<bool> row(H, false);
	rp(h, 0, H) rp(w, 0, W)
		if(A[h][w] == '#'){ row[h] = true; break; }

	vector<bool> col(W, false);
	rp(w, 0, W) rp(h, 0, H)
		if(A[h][w] == '#'){ col[w] = true; break; }

	rp(h, 0, H){
		int f = false;
		rp(w, 0, W) if(row[h] && col[w]){ cout<<A[h][w]; f = true; }
		if(f) puts("");
	}
}

Measured memory_bytes: 256
x, y = map(int, input().split())
dist = abs(abs(x) - abs(y))

if x + dist == y:
  ans = dist
elif - x + dist == y:
  ans = dist + 1
elif x + dist == -y:
  ans = dist + 1
elif - x + dist == -y:
  ans = dist + 2

print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>

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

int main(){
	int n, i, j, k, l, s = 0;
	scanf("%d", &n);
    for(i = 1; i <= n; i++){
    	for(j = 1; j <= n; j++){
        	for(k = 1; k <= n; k++){
            	l = gcd(i, j);
                s += gcd(k, l);
            }
        }
    }
    printf("%d\n", s);
    return 0;
}


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

void solve(int id, double w, double h){
    double bmi = w / (h*h);
    if(bmi >= 25.0){
        cout << id << endl;
    }
}

int main(){
    string s;
    while(cin >> s){
        int id;
        double w, h;
        sscanf(s.c_str(), "%d,%lf,%lf", &id, &w, &h);
        solve(id, w, h);
    }
    return 0;
}

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

int main() {
    vector<int> x(10), y(10);
    cin >> x[1] >> y[1] >> x[2] >> y[2];
    int vx = -(y[2] - y[1]);
    int vy = x[2] - x[1];
    cout << x[2] + vx << ' ' << y[2] + vy << ' ' << x[1] + vx << ' ' << y[1] + vy << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <utility>
#include <bitset>
#include <queue>
#include <stack>
#define mod 998244353
#define pb(x) push_back(x)
using namespace std;
int fuck(int x)
{
    printf("%d\n",x);
    fflush(stdout);
    char s[30]; scanf("%s",s);
    if(s[0]=='M')return 0;
    else 
    if(s[0]=='F')return 1;
    return -1;
}
int a[100010];
int main()
{
    int n;
    cin>>n;
    int l=0;
    int r=n;
    a[r]=fuck(l);
    a[l]=a[r];
    if(a[l]==-1)return 0;
    while (l<r)
    {
        int mid=(l+r)>>1;
        a[mid]=fuck(mid);
        if(a[mid]==-1)return 0;
        int t1=mid-l+1;
        int t2=a[l]^a[mid];
        if(t1%2==t2)r=mid;else l=mid;
    }
    return 0;
}

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

  string s;
  
  cin >> s;
  
  if ( s.at(0) == s.at(1) || s.at(1) == s.at(2) || s.at(2) == s.at(3) )
    cout << "Bad" << endl;
  else
    cout << "Good" << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset> 
using namespace std;
typedef long long ll;
int main(void)
{
	ll l,r,d;
	cin>>l>>r>>d;
	ll ans=0;
	for(ll i=l;i<=r;i++) 
	{
		if(i%d==0) ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 3616
s=input()
s_l=[s[_] for _ in range(len(s))]
a_l=[0]*(len(s)+1)
for i in range(len(s)):
	if s[i]=='<':
		a_l[i+1]=a_l[i]+1
a_l.reverse()
s_l.reverse()
for j in range(len(s)):
	if s_l[j]=='>':
		a_l[j+1]=max(a_l[j]+1,a_l[j+1])
print(sum(a_l))

Measured memory_bytes: 27956
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;
 
 
int main(){
 
int n,m;
cin >> n >> m;
 
char a[n][n],b[m][m];
 
rep(i,n)rep(j,n)cin >> a[i][j];
rep(i,m)rep(j,m)cin >> b[i][j];
 
bool exist =false;
rep(i,n){
    rep(j,n){
        if(j+m-1>=n or i+m-1>=n) continue;
        bool match = true;
        rep(k,m){
            rep(l,m){
                if(a[i+k][j+l]!=b[k][l])match = false;
            }
 
        } 
        if(match)exist = true;  
     }
}
 
if(exist)cout << "Yes" << endl;
else cout << "No" << endl;
 
 
return 0;
 
}
 

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
const int L = 1'000'000;
char s[L + 1];
int A[L / 2 + 1];
int B[L / 2 + 1];
int main(){
  int Nzj9Y0kE, i;
  int n;
  rd(n);
  int aa = 0;
  int bb = 0;
  int cc = 0;
  for(Nzj9Y0kE=(0);Nzj9Y0kE<(n);Nzj9Y0kE++){
    int i;
    int l;
    l = rd(s);
    int mi = 0;
    int sum = 0;
    for(i=(0);i<(l);i++){
      sum += (s[i] == '(' ? +1 : -1);
      chmin(mi, sum);
    }
    int a = -mi;
    int b = sum - mi;
    if(a == b){
      chmax(cc, a);
    }
    if(a <  b){
      chmax(aa, a);
      A[a] += sum;
    }
    if(a >  b){
      chmax(bb, b);
      B[b] += sum;
    }
  }
  int mi = 0;
  int sum = 0;
  for(i=(0);i<(aa + 1);i++){
    chmin(mi, sum - i);
    sum += A[i];
  }
  chmin(mi, sum - cc);
  for(i=(bb + 1)-1;i>=(0);i--){
    sum += B[i];
    chmin(mi, sum - i);
  }
  puts(mi >= 0 && sum == 0 ? "Yes" : "No");
  return 0;
}
// cLay varsion 20200430-1

// --- original code ---
// const int L = 1'000'000;
// char s[L + 1];
// int A[L / 2 + 1], B[L / 2 + 1];
// {
// 	int n; rd(n);
// 	int aa = 0, bb = 0, cc = 0;
// 	rep(n) {
// 		int l; rd(s@l);
// 		int mi = 0, sum = 0;
// 		rep(i, l) {
// 			sum += (s[i] == '(' ? +1 : -1);
// 			mi <?= sum;
// 		}
// 		int a = -mi, b = sum - mi;
// 		if(a == b) { cc >?= a; }
// 		if(a <  b) { aa >?= a; A[a] += sum; }
// 		if(a >  b) { bb >?= b; B[b] += sum; }
// 	}
// 	
// 	int mi = 0, sum = 0;
// 	rep(i, aa + 1) {
// 		mi <?= sum - i;
// 		sum += A[i];
// 	}
// 	mi <?= sum - cc;
// 	rrep(i, bb + 1) {
// 		sum += B[i];
// 		mi <?= sum - i;
// 	}
// 	puts(mi >= 0 && sum == 0 ? "Yes" : "No");
// }


Measured memory_bytes: 4684
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
ll p[200005];
int main() {
	int n;
	cin >> n;
	deque<int>A;
	int x;
	for (int i = 0; i < n; i++) {
		cin >> x;
		if (i % 2 == (n - 1) % 2) {
			A.push_front(x);
		}
		else {
			A.push_back(x);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << A[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2944
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
 
void main() {
    auto s = readln.split;
    auto c = (s[0] == s[1]) ? "=" : (s[0] < s[1] ? "<" : ">");
    writefln("%s", c);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector <ll>
#define vii vector <int>
#define vpii vector <pii>
#define vpll vector <pll>
#define ff first
#define ss second
#define matrix vector <vll>
#define all(v) v.begin(),v.end()
#define PQ priority_queue
using namespace std;
int main()
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	int n; string s;
	cin >> n;
	cin >> s;
	vii v(n);
	for(int i = 0; i < n; i++){
		if(s[i] == 'R') v[i] = 0;
		if(s[i] == 'G') v[i] = 1;
		if(s[i] == 'B') v[i] = 2;
	}
	vii cnt(3);
	ll ans = 0;
	for(int i = 0; i < n-2; i++){
		vii tcnt = cnt;
		cnt[v[i]]++;
		cnt[v[i+1]]++;
		for(int k = i+2; k < n; k++){
			cnt[v[k]]++;
			if(v[i] != v[k]){
				int col = 3- v[i] - v[k];
				ans+=cnt[col];
				if((k+i)%2 == 0 && v[(k+i)/2] == col) ans--;
			}
		}
		cnt = tcnt;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>

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

using namespace std;

int A[100] = {0};
int d[100] = {0};

int main(void){

    int N, K;
    cin >> N >> K;

    for(int i=0; i < K; i++){
        int d;
        cin >> d;

        for(int j=0; j < d; j++){
            int tmp_A;
            cin >> tmp_A;
            //cout << " debug ";
            //cout << tmp_A << endl;
            A[tmp_A-1] += 1;
        }
    }
    
    //rep(i,N) cout << A[i];

    int count = 0;
    for(int i=0; i < N; i++){
        if(A[i] == 0) count++;
    }
    
    cout << count;

    return 0;
}

Measured memory_bytes: 3636
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

int main() {
	ll N, K; cin >> N >> K;
	vector<ll> A(N); rep(i, N) cin >> A[i];

	vector<ll> cnt(200001);
	ll sp = 0;
	rep(i, N) {
		if (cnt[A[i]] == 0) sp++;
		cnt[A[i]]++;
	}

	sort(ALL(cnt));

	ll c = 1, ans = 0;
	for (int i = 0; c <= sp - K; i++) {
		if (cnt[i] != 0) {
			ans += cnt[i];
			c++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main() {
	string w;
	cin >> w;
	int ans = 0;
	while (true) {
		string s;
		cin >> s;
		if (s == "END_OF_TEXT") break;
		for (int i = 0; i < s.length(); i++) {
			if (65 <= s.at(i) && s.at(i) <= 90) {
				s.at(i) +=32;
			}
		}
		if (s == w) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3216
while true do
  input = STDIN.gets
  fomura = input.split(" ")
  a = fomura[0].to_i
  op = fomura[1]
  b = fomura[2].to_i
  if op == "?"
    break
  end
  ans = 0
  if op == "+" then
    ans = a + b
  elsif op == "-" then
    ans = a - b
  elsif op == "*" then
    ans = a * b
  else
    ans = a / b
  end
  print ans.to_s + "\n"
end

Measured memory_bytes: 8628
#include<bits/stdc++.h>
		#include <bitset>
		using namespace std;
		#define ll long long 
		#define mod7 1000000007
		#define mod9 1000000009
		#define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
		#define mp make_pair
		#define pb push_back
		#define ct ll t;cin>>t;while(t--)
		#define bi begin()
		#define ei end()
		#define fi first 
		#define se second
		#define foe(i,a,b) for(ll i=a;i<b;i++)
		#define sz(s) s.size()
        #define mem(a,s) memset(a,s,sizeof(a))    
//   ll fact[1000007]={0};
//   ll expo(ll x, ll y) {ll res=1;x=x%mod7;while(y>0){if(y&1)res=(1ll*res*x)%mod7;
//     y=y>>1;x=(1ll*x*x)%mod7;} return res;}
// void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod7;}
//   ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],mod7-2)))%mod7; return res; }
	
		ll n,m,k;
		int const N = 1e5+5;
		int const MAX = 1e7+5;
		vector<ll>v[N],t[N];
		set<ll>s[N];
		ll a[N],vis[N],b[N],s1=0;
		void dfs(ll x)
		{
			if(!vis[x])
			{
				vis[x]=1;
				b[x]=s1;
				t[s1].pb(x);
				for(auto i:v[x])
				{
					dfs(i);
				}
			}
		}
		 int main()
		 {
			 fast
// 			   freopen("std.in", "r", stdin);
//  			 freopen("std.out", "w", stdout);
//  		 	freopen("input.txt", "r", stdin);
//			   freopen("output.txt", "w", stdout);
			mem(a,0);
			mem(vis,0);

			cin>>n>>m>>k;
			foe(i,0,m)
			{
				ll a,b;
				cin>>a>>b;
				v[a].pb(b);
				v[b].pb(a);
				s[a].insert(b);
				s[b].insert(a);
			}
			s1=0;
			for(ll i=1;i<=n;i++)
			{
				if(!vis[i])
				{
					dfs(i);
					s1++;
				}
			}
			for(ll i=0;i<k;i++)
			{
				
				ll a,c;
				cin>>a>>c;
				// v[a].pb(b);
				// v[b].pb(a);
				if(b[a]==b[c])
				{
					s[a].insert(c);
					s[c].insert(a);
				}
				
			}
			for(ll i=1;i<=n;i++)
			{
				ll g=t[b[i]].size()-sz(s[i])-1;
				cout<<g<<" ";
			}
			
	}	



Measured memory_bytes: 39540
# 2019-11-15 00:35:39(JST)
import sys
import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    s = sys.stdin.readline().rstrip()
    for v in collections.Counter(s).values():
        if v == 2:
            continue
        else:
            ans = 'No'
            break
    else:
        ans = 'Yes'

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
import numpy as np

N, x = map(int, input().split())
cost = np.fromstring(input(), dtype=np.int64, sep=' ')

ans = 10 ** 18
for i in range(N):  # i: 色の変更を行う回数
    ans = min(ans, sum(cost) + i * x)
    new_cost = np.empty_like(cost)
    new_cost[1:] = cost[:-1]
    new_cost[0] = cost[-1]
    new_cost = np.minimum(new_cost, cost)
    cost = new_cost

print(ans)

Measured memory_bytes: 27008
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main()
{
	int i;
	int n;
	
	int flag = 1;
	int cnt = 0;
	cin >> n;

	long* a;
	a = new long[n];

	for (i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	
	for (i = 1; i < n; i++)
	{
		if (a[i - 1] >= a[i])
		{
			if (a[i - 1] == a[i])
			{
				if (i - 2 >= 0)
				{
					if (a[i - 2] < a[i - 1])
					{
						a[i - 1]--;
					}
				}
			}
			else
			{
				a[i - 1]--;
			}
		}
	}

	for (i = 1; i < n; i++)
	{
		if (a[i - 1] > a[i])
		{	
			flag = 0;
		}
		if (!flag)
			break;
	}

	if (flag)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define MOD1 1000000007
#define MOD2 998244353
#define IOS std::ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define print(a) for(auto x : a)    cout<<x<<" "; cout<<"\n";
using namespace std;

int main(){

    IOS;

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int flag = 0;
    while(a > 0 && c > 0)
    {
        c -= b;
        if(c <=0)
        {
            flag = 1;
            break;
        }        
        a -= d;
        if(a <= 0)
            break;
    }
    if(flag)
        cout<<"Yes\n";
    else
        cout<<"No\n";


    return 0;
}

Measured memory_bytes: 3644