akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int mx = 100005;
int n, a[mx], ans, gc[mx], tmp;

inline int gcd(int a, int b){
    if(a < b) swap(a, b);
    while(b){
        a %= b;
        swap(a, b);
    }
    return a;
}

int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", a+i);
        if(i) gc[i] = gcd(gc[i-1], a[i]);
        else gc[i] = a[i];
    }
    ans = gc[n-2];
    tmp = a[n-1];
    for(int i = n-2; i >= 0; i--){
        ans = max(ans, (i ? gcd(tmp, gc[i-1]) : tmp));
        tmp = gcd(tmp, a[i]);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 20:00:11 2019

@author: screamLab
"""

a,b = input().split(' ')
a = int(a)
b= int(b)
s = [a+b,a-1+a,b-1+b]
    
print(max(s))

Measured memory_bytes: 2940
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N,M = (int(_) for _ in input().split())
    a = []
    b = []
    ans = [0]*(N+1)
    # for i in range(N+1):
    #     ans.append(0)
    for i in range(M):
        s1,s2 = (int(_) for _ in input().split())
        a.append(s1)
        b.append(s2)

    for i in range(M):
        ans[a[i]] +=1
        ans[b[i]] +=1
    print('\n'.join(str(_) for _ in ans[1:]))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=2e5+5;
const int mod=1e9+7;
int main()
{
	ll n,k;
	scanf("%lld%lld",&n,&k);
	n++;
	ll ans=0;
	for(ll i=k;i<=n;i++){
		ll mn=(1+i)*i/2;
		ll mx=(n-i+1+n)*i/2;
		ans+=mx-mn+1;
		ans%=mod;
	}
	printf("%lld",ans);
}


Measured memory_bytes: 3828
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=(int)l;i<=(int)r;++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

const int mod1 = 998244353; 
const int mod2 = 1e9 + 7;
const int inf = 9e18;
const int N = 1005;

void solve(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int req=ceil(1.0*c/b);
    if(a-d*(req-1)>0)
        cout<<"Yes";
    else
        cout<<"No";
}

signed main(){
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3700
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();	
		ArrayList<Integer> solist = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
				solist.add(x);		
		}
		Collections.sort(solist);
		int ans=999999999;
		int tori;
		for (int i = 0; i < n-k+1; i++) {
			tori=solist.get(i+k-1)-solist.get(i);
			if(tori<ans) {
				ans=tori;
			}
		}
		System.out.println(ans);	
	}
}

Measured memory_bytes: 59980
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func r() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := r()

	var oddCount int
	for i := 0; i < n; i++ {
		if r()%2 != 0 {
			oddCount++
		}
	}

	if oddCount%2 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void)
{
   int time;
   int hour, minute, second;
   
   scanf("%d", &time);
   
   second = time % 60;
   minute = ((time - second)/60) % 60;
   hour   = ((time - second)/60 - minute)/60;
   
   printf("%d:%d:%d\n", hour, minute, second);
   
   return (0);
}

Measured memory_bytes: 1848
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n=10000000,i,j;
  vector<int> a(10000010,1);
  a[0]=0,a[1]=0;
  for(i=2;i<=n;i++){
    if(a[i]==0){
      continue;
    }
    for(j=i*2;j<=n;j=j+i){
      a[j]=0;
    }
  }
  vector<int> ans;
  for(i=2;i<=10000000-8;i++){
    if(a[i]==1 && a[i+2]==1 && a[i+6]==1 && a[i+8]==1){
      ans.push_back(i+8);
    }
  }
  int x;
  while(1){
    cin >> x;
    if(x==0){
      break;
    }
    for(i=0;i<ans.size();i++){
      if(x<ans[i]){
        cout << ans[i-1] << endl;
        break;
      }
    }
    if(i==ans.size()){
      cout << ans[ans.size()-1] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 41624
// ※※※ 解答不能 ※※※
// kawatea氏.
// https://atcoder.jp/contests/keyence2019/submissions/4002251
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const int MOD = 1e9 + 7;
int a[1010], b[1010];

int main() {
    int n, m, c = 0;
    scanf("%d %d", &n, &m);
    rep(i, n) scanf("%d", &a[i]);
    rep(i, m) scanf("%d", &b[i]);
    
    sort(a, a + n);
    reverse(a, a + n);
    sort(b, b + m);
    reverse(b, b + m);
    
    int j = 0, k = 0;
    LL ans = 1;
    repr(i, n * m, 1){
        if(a[j] == i && b[k] == i){
            c += j + k;
            j++;
            k++;
        }else if(a[j] == i){
            ans = ans * k % MOD;
            c += k - 1;
            j++;
        }else if (b[k] == i){
            ans = ans * j % MOD;
            c += j - 1;
            k++;
        } else {
            ans = ans * c % MOD;
            c--;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
judge = True
while judge:
    H,W = list(map(int,input().split()))
    if H + W == 0:
        judge = False #finish
    else:
        for i in range(0, H):# H
            print("#",end="")
            if i == 0 or i == (H - 1):
                for j in range(1, W-1):
                    print("#",end="")
                print("#")
            else:
                for j in range(1, W-1):
                    print(".",end="")
                print("#")
        print()



Measured memory_bytes: 7000
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
inline int read(){
	int x=0,c=getchar(),f=0;
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(int x){
	if(x>9)write(x/10);
	putchar(x%10+'0');
}

const int mod = 1e9+7;
int n,m;
ll ans;

int main(){
	n = read(); m = read();
	if(n > m) swap(n,m);
	if(m-n > 1){
		puts("0");
		return 0;
	}
	if(n == m){
		ans = 2;
		for(int i = 2;i <= n;i++)
			ans = ans*i%mod;
		for(int i = 2;i <= n;i++)
			ans = ans*i%mod;
		printf("%lld\n", ans);
	}
	else{
		ans = 1;
		for(int i = 2;i <= n;i++)
			ans = ans*i%mod;
		for(int i = 2;i <= m;i++)
			ans = ans*i%mod;
		printf("%lld\n", ans);
	}
	return 0;
}

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

using namespace std;

const int MaxN = 300005;

int n;
int x, y, a, b, c;
pair<int, int> apple[MaxN];
int cnt[3];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> x >> y >> a >> b >> c;
    n = a + b + c;
    for (int i = 1; i <= a; ++i)
    {
        cin >> apple[i].first;
        apple[i].second = 1;
    }
    for (int i = a + 1; i <= a + b; ++i)
    {
        cin >> apple[i].first;
        apple[i].second = 2;
    }
    for (int i = a + b + 1; i <= n; ++i)
    {
        cin >> apple[i].first;
        apple[i].second = 0;
    }
    sort(apple + 1, apple + n + 1, greater<pair<int, int>>());
    for (int i = 1; i <= x + y; ++i)
    {
        cnt[apple[i].second]++;
    }
    if (cnt[1] <= x && cnt[2] <= y)
    {
        long long ans = 0;
        for (int i = 1; i <= x + y; ++i)
        {
            ans += 1LL * apple[i].first;
        }
        cout << ans;
    }
    else
    {
        long long ans = 0LL;
        if (cnt[1] > x)
        {
            for (int i = 1; i <= n && x; ++i)
            {
                if (apple[i].second == 1)
                {
                    ans += 1LL * apple[i].first, --x;
                }
            }
            for (int i = 1; i <= n && y; ++i)
            {
                if (apple[i].second != 1)
                {
                    ans += 1LL * apple[i].first, --y;
                }
            }
            cout << ans;
        }
        else
        {
            for (int i = 1; i <= n && y; ++i)
            {
                if (apple[i].second == 2)
                {
                    ans += 1LL * apple[i].first, --y;
                }
            }
            for (int i = 1; i <= n && x; ++i)
            {
                if (apple[i].second != 2)
                {
                    ans += 1LL * apple[i].first, --x;
                }
            }
            cout << ans;
        }
    }
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

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

	if (a == b && a != c || b == c && a != b || a == c && a != b)
	{
		cout << "Yes" << en;
	}
	else
	{
		cout << "No" << en;
	}

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h,n;
    cin>>h>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int s=0;
    for(int i=0;i<n;i++)s+=a[i];
    if(s>=h){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 1024
import itertools
X = int(input())

for x in itertools.count(X):
    # 2~x/2で割ってみて，すべての余りが0でなければ
    isprime = all([x % y != 0 for y in range(2,int(x/2)+1)])
    if isprime:
        prime = x
        break

print(prime)

Measured memory_bytes: 3480
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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



int main() {
  int h,w;
  cin>>h>>w;
  vector<vector<int>> dist(h,vin(w,0));
  vector<string> a(h);
  rep(i,0,h)cin>>a[i];
  queue<pair<int, int>> que;
  rep(i,0,h){
   rep(j,0,w){
     if(a[i][j]=='#'){
      que.push(mp(i,j)); 
     }
   }
  }
  while (que.size() != 0) {              // キューの要素がなくなったら終了
        pair<int, int> now = que.front();  // 現在の状態
        que.pop();
        for (int i = 0; i < 4; i++) {
            int ny = now.first + dy[i];                            // 次の探索場所の行番号
            int nx = now.second + dx[i];                           // 次の探索場所の列番号
            if (ny < 0 || h <= ny || nx < 0 || w <= nx) continue;  // 迷路の外に出るならスルー
            if (a[ny][nx] == '#') continue;                     // 障害物があればスルー
            if (dist[ny][nx] != 0) continue;                     //探索済みならスルー
            que.push(make_pair(ny, nx));
            dist[ny][nx] = dist[now.first][now.second] + 1;
        }
    }
  
  int ans=0;
  rep(i,0,h){
   rep(j,0,w){
     chmax(ans,dist[i][j]);
   }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 17032
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
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 long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    int a,b,c,t;
    
    cin >> a>> b >> c;
    
    t = b/a;
    
    if (t <= c){
    
        cout << t << endl;
    
    }else{
    
        cout << c << endl;
    
    }
    
    
    
    
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int a[200010];
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read(),m=read();long long sum=0;
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
	for(int i=1;i<=n-m;i++)sum+=a[i];
	printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

void func(int N,int M,int Start,int Goal_1,int Goal_2){

	int dist[N+1][N+1];

	for(int i = 1; i <= N; i++){
		for(int k = 1; k <= N; k++){
			if(i != k){
				dist[i][k] = BIG_NUM;
			}else{
				dist[i][k] = 0;
			}
		}
	}

	int from,to,cost;

	for(int i = 0;i < M; i++){
		scanf("%d %d %d",&from,&to,&cost);
		dist[from][to] = cost;
	}

	for(int i = 1; i <= N; i++){
		for(int k = 1; k <= N; k++){
			if(dist[k][i] == BIG_NUM)continue;
			for(int p = 1; p <= N; p++){
				if(dist[i][p] == BIG_NUM)continue;
				dist[k][p] = min(dist[k][p],dist[k][i]+dist[i][p]);
			}
		}
	}

	int ans = dist[Start][Goal_1]+dist[Start][Goal_2];

	for(int i = 1; i <= N; i++){
		if(dist[Start][i] == BIG_NUM || dist[i][Goal_1] == BIG_NUM || dist[i][Goal_2] == BIG_NUM)continue;
		ans = min(ans,dist[Start][i]+dist[i][Goal_1]+dist[i][Goal_2]);
	}

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

int main(){

	int N,M,Start,Goal_1,Goal_2;
	while(true){
		scanf("%d %d %d %d %d",&N,&M,&Start,&Goal_1,&Goal_2);
		if(N == 0 && M == 0 && Start == 0 && Goal_1 == 0 && Goal_2 == 0)break;

		func(N,M,Start,Goal_1,Goal_2);
	}

	return 0;
}

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

const int N = 55;
typedef long long ll;

int n, m, q, a[N], b[N], c[N], d[N], ans, p[N];

void check() {
	int res = 0;
	for(int i = 1; i <= q; i++)
		if(p[b[i]] - p[a[i]] == c[i]) res += d[i];
	ans = max(ans, res); 
}

void Dfs(int pos, int last) {
	if(pos == n) {
		check();
		return;
	}
	for(int i = last; i <= m; i++) {
		p[pos + 1] = i;
		Dfs(pos + 1, i);
	}
}

int main() {
	cin>>n>>m>>q;
	for(int i = 1; i <= q; i++) 
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	Dfs(0, 1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3652
eval"N,*A="+$<.read.split*?,
_4 = A.count{|a|a%4<1}
_1 = A.count(&:odd?)
_2 = N - _1 - _4
if _1 > _4+1 || (_4 == 0 && _1 > 0) || (_1 == _4+1 && _2 > 0)
  puts :No
else
  puts :Yes
end

Measured memory_bytes: 21324
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

long long int MOD = 1e9 +7;

int main(){

  long long int N, M, tmp;
  scanf("%lld%lld", &N, &M);

  std::vector<long long int> dp(N+1);
  
  for(long long int i = 0; i < M; i++){
    scanf("%lld", &tmp);
    dp[tmp] = -1;
  }

  dp[0] = 1;
  if(dp[1] == 0){
    dp[1] = 1;
  }

  for(long long int i = 2; i <= N; i++){
    if(dp[i] == -1) continue;
    if(dp[i-2] >= 0)dp[i] += dp[i-2];
    if(dp[i-1] >= 0)dp[i] += dp[i-1];
    dp[i] = (dp[i] + MOD)%MOD;
  }

  std::cerr << "Answer:" << std::endl;
  std::cout << dp[N] << std::endl;
  
  return 0;
}


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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 2e5 + 5;
int arr[MAX], x_pref[MAX], s_pref[MAX];

inline int s(int l, int r) {
	return s_pref[r] - s_pref[l - 1];
}

inline int x(int l, int r) {
	return x_pref[r] ^ x_pref[l - 1];
}

int main() {
	int n;
	scanf("%d", &n);

	fori(i, 1, n + 1) {
		scanf("%d", arr + i);
		s_pref[i] = s_pref[i - 1] + arr[i];
		x_pref[i] = x_pref[i - 1] ^ arr[i];
	}

	ll ans = 0;
	fori(i, 1, n + 1) {
		int left = i, right = n;
		int best = -1;
		while(left <= right) {
			int mid = (left + right) / 2;

			if(s(i, mid) == x(i, mid)) {
				best = mid;
				left = mid + 1;
			}
			else {
				right = mid - 1;
			}
		}
		ans += best - i + 1;
	}

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

	return 0;
}


Measured memory_bytes: 2560
n = int(input())
s = input()

count = 0
for a in range(10):
    for b in range(10):
        for c in range(10):
            f1 = False
            f2 = False
            p1 = 0
            p2 = 0
            for i in range(0, n-2):
                if int(s[i]) == a:
                    f1 = True
                    p1 = i
                    break
            if f1:
                for j in range(p1+1, n-1):
                    if int(s[j]) == b:
                        f2 = True
                        p2 = j
                        break
            if f2:
                for k in range(p2+1, n):
                    if int(s[k]) == c:
                        count += 1
                        break
            if not f1 or not f2:
                break
        if not f1:
            break
print(count)


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

int num[105];
int main(){
	int n;
	cin >> n;
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		cin >> num[i];
	}
	sort(num + 1, num + 1 + n);
	for(int i = 1; i <= n; i++){
		if(num[i] != num[i + 1]) cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef complex<ld> Point;
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

typedef pair<ll, P> speP;
void solve() {
	int x, y, z, k; cin >> x >> y >> z >> k;
	vector<ll> a(x), b(y), c(z);
	rep(i, x) {
		cin >> a[i];
	}
	rep(i, y)cin >> b[i];
	rep(i, z)cin >> c[i];
	vector<ll> v;
	rep(i, x) {
		rep(j, y) {
			v.push_back(a[i] + b[j]);
		}
	}
	sort(v.begin(), v.end(),greater<ll>());
	priority_queue<speP> q;
	rep(i, z) {
		q.push({ v[0] + c[i],{i,0} });
	}
	vector<ll> ans;
	rep(aa, k) {
		speP p = q.top(); q.pop();
		ans.push_back(p.first);
		P memo = p.second;
		memo.second++;
		if (memo.second < v.size()) {
			q.push({ v[memo.second] + c[memo.first],memo });
		}
	}
	rep(i, k) {
		cout << ans[i] << endl;
	}
}
int main() {
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 10608
N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[list(map(int,input().split())) for  _ in range(M)]#リストの表記が違う
BC.sort(key=lambda x: -x[1])#リバースと-1の違い

for b,c in BC:
    A.extend([c]*b)
    if len(A)>N*2:
        break
A.sort(reverse=True)
print(sum(A[:N]))

Measured memory_bytes: 36088
#include <stdio.h>

int main(void)
{
	int n, x;
	int i, j, k;
	int a=0;
	
	for(; ; ) {
		scanf("%d%d", &n, &x);
		if(n==0 && x==0) break;
		for(i=1; i<=n-2; i++){
			for(j=i+1; j<=n-1; j++) {
				for(k=j+1; k<=n; k++) {
					if(i+j+k==x) a++;
				}
			}
		}
		
		printf("%d\n", a);
		a=0;
	}
	return 0;
}


Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//UnionFind
//全て添字で扱うこと
struct union_find {
  vll parent;
  vll sizes;

  //コンストラクタ
  union_find(ll n) {
    for (ll i = 0; i < n; i++) {
      parent.push_back(i);
      sizes.push_back(1);
    }
  }

  //頂点nの根
  ll root_of(ll n) {
    if (parent[n] == n) return n;
    return parent[n] = root_of(parent[n]);
  }

  //頂点nと間接的に繋がっている頂点の数(自身含む)
  ll size_of(ll n) {return sizes[root_of(n)];}

  //頂点a, bが間接的に繋がっているか判定
  bool is_united(ll a, ll b) {return (root_of(a) == root_of(b));}

  //頂点aを含むグラフに頂点bを含むグラフを結合
  void unite(ll a, ll b) {
    if (is_united(a, b)) return;
    if (size_of(a) < size_of(b)) swap(a, b);
    sizes[root_of(a)] += size_of(b);
    parent[root_of(b)] = root_of(a);
  }
};

int main() {
  ll n, m, k;
  cin >> n >> m >> k;
  union_find uf(n);
  vector<vll> nx(n, vll(0));
  for (ll i = 0; i < m; i++) {
    ll a, b;
    cin >> a >> b;
    uf.unite(a - 1, b - 1);
    nx[a - 1].push_back(b - 1);
    nx[b - 1].push_back(a - 1);
  }
  vll bl(n, 0);
  for (ll i = 0; i < k; i++) {
    ll c, d;
    cin >> c >> d;
    if (uf.is_united(c - 1, d - 1)) {
      bl[c - 1]++;
      bl[d - 1]++;
    }
  }
  for (ll i = 0; i < n - 1; i++) cout << uf.size_of(i) - 1 - nx[i].size() - bl[i] << " ";
  cout << uf.size_of(n - 1) - 1 - nx[n - 1].size() - bl[n - 1] << endl;
}

Measured memory_bytes: 9452
--stack　逆ポーランド電卓

import Data.Char

data TOKEN = NUM Int | ADD | PRD | SUB deriving (Eq,Show)

tokenize::String->TOKEN
tokenize "+" = ADD
tokenize "-" = SUB
tokenize "*" = PRD
tokenize str = NUM (read str)
--stack input return
--スタックは数値のみのリスト
calc::[TOKEN] -> [TOKEN] ->Int
calc (NUM i:NUM j:st) (ADD:ls) = calc (NUM (i+j):st) ls
calc (NUM i:NUM j:st) (SUB:ls) = calc (NUM (j-i):st) ls
calc (NUM i:NUM j:st) (PRD:ls) = calc (NUM (i*j):st) ls
calc st (NUM i:ls) = calc (NUM i:st) ls
calc [NUM i] [] = i --return answer

fun::String->Int
fun = (calc []).(map tokenize).words

main::IO()
main=do
  str<-getLine
  print (fun str)


Measured memory_bytes: 4120
import java.util.*;

@SuppressWarnings("unchecked")
class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        int INF = Integer.MAX_VALUE/2;

        while(true){
            int w = sc.nextInt(), h = sc.nextInt();
            if(w==0 && h==0) break;
            ArrayList[] list = new ArrayList[5];
            for(int i=0; i<5; i++) list[i] = new ArrayList<int[]>();

            int sx = 0, sy = 0, gx = 0, gy = 0;
            for(int i=0; i<h; i++){
                char[] line = sc.next().toCharArray();
                for(int j=0; j<w; j++){
                    if(line[j]=='S'){ sx = j; sy = i;}
                    else if(line[j]=='G'){ gx = j; gy = i;}
                    else if(Character.isDigit(line[j])) list[line[j]-'1'].add(new int[]{j, i});
                }
            }

            int num = 0, min = INF;
            for(int start=0; start<5; start++){
                int[][] dp = new int[5][];
                int idx = (start+1) % 5;
                while(idx!=start){
                    dp[idx] = new int[list[idx].size()];
                    Arrays.fill(dp[idx], INF);
                    for(int j=0; j<list[idx].size(); j++){
                        int[] xy = (int[])list[idx].get(j);
                        if(idx==(start+1)%5){
                            dp[idx][j] = Math.min(dp[idx][j], Math.abs(sx - xy[0]) + Math.abs(sy - xy[1]));
                            continue;
                        }
                        int before = (idx+4) % 5;
                        for(int k=0; k<list[before].size(); k++){
                            int[] xy2 = (int[])list[before].get(k);
                            int dist = dp[before][k] + Math.abs(xy[0] - xy2[0]) + Math.abs(xy[1] - xy2[1]);
                            if((idx+1)%5==start){
                                dist += Math.abs(gx - xy[0]) + Math.abs(gy - xy[1]);
                                if(dist<min){
                                    min = dist;
                                    num = start+1;
                                }
                            }
                            dp[idx][j] = Math.min(dp[idx][j], dist);
                        }
                    }
                    idx = (idx + 1) % 5;
                }
            }
            if(min==INF) System.out.println("NA");
            else System.out.println(num+" "+min);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 72344
#include <iostream>
#include <algorithm>
#include <climits>
#include <cstdlib>
int H = 0, W = 0;
long long int solve(long long int a,long long int b){
    long long int i, ans = INT_MAX;
    long long int s1, s2, s3;
    for(i=1; i<a; ++i){
        s1 = i*b;

        s2 = (a-i)*(b/2);
        s3 = (a-i)*(b/2 + b%2);

        ans = std::min(ans, std::max(s1,std::max(s2,s3)) - std::min(s1, std::min(s2, s3)));

        s2 = ((a-i)/2)*b;
        s3 = ((a-i)/2 + (a-i)%2 )*b;

        ans = std::min(ans, std::max(s1,std::max(s2,s3)) - std::min(s1, std::min(s2, s3)));
    }
    return ans;
}
int main(void){
    std::cin >> H >> W;

    if(H%3 == 0 || W%3 == 0){
        std::cout << "0" << std::endl;
        return 0;
    }

    long long int ans1 = solve(H,W);
    long long int ans2 = solve(W,H);

    std::cout << std::min(ans1, ans2) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<map>
#include<vector>
#include<cmath>
#include<set>
#include<algorithm>
#define int long long int
#define mod 1000000007
int answer=100000000;
void function2(vector<int> &vec,int initial,int final,int mat[][2],int d,int g)
{
	if(initial>final)
	{
		int here=0;
		int sum=0;
		int j;
		vector<int> vec2;
		for(j=0;j<d;j++)
		{
			if(vec[j]==1)
			{
				sum+=(mat[j][1]+100*(j+1)*mat[j][0]);
				here+=mat[j][0];
			}
			else
			{
				int i;
				for(i=0;i<mat[j][0]-1;i++)
				{
					vec2.push_back(100*(j+1));
				}
			}
		}
		if(sum>=g)
		{
			answer=min(answer,here);
			return ;
		}
		sort(vec2.begin(),vec2.end());
		reverse(vec2.begin(),vec2.end());
		int n=vec2.size();
		for(j=0;j<n;j++)
		{
			sum+=vec2[j];
			here++;
			if(sum>=g)
			{
				answer=min(answer,here);
				break;
			}
		}
	}
	else
	{
		vec.push_back(0);
		function2(vec,initial+1,final,mat,d,g);
		vec.pop_back();
		vec.push_back(1);
		function2(vec,initial+1,final,mat,d,g);
		vec.pop_back();
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int d,g;
	cin>>d>>g;
	int mat[d][2];
	int j;
	for(j=0;j<d;j++)
	{
		cin>>mat[j][0]>>mat[j][1];
	}
	vector<int> vec;
	function2(vec,0,d-1,mat,d,g);
	cout<<answer<<endl;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<math.h>
long long int NUM = 1000000000000000000;
int main(){
  int n;
  int flag = 1;
  long long int ans = 1;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    long long int a;
    scanf("%lld",&a);

    if(a != 0 && ans > NUM/a){
       flag = 0;
       ans = 1;
    }
    else{
      ans *= a;
    }
  }
  if(ans == 0) flag = 1;
  if(flag == 0) ans = -1;

  printf("%lld\n",ans);
}

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

int main() {
  string s,ans="Yes";
  cin >> s;
  int n=s.size();
  for(int i=0;i<n/2;i++) {
    if(s[i]!=s[n-i-1]) ans="No";
  }
  for(int i=0;i<(n-1)/4;i++) {
    if(s[i]!=s[(n-1)/2-1-i]) ans="No";
    if(s[n-1-i]!=s[(n-1)/2+1+i]) ans="No";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int N, K;cin >> N >> K;
	int MAX = N * (N - 1) / 2 - (N - 1);
	if (K > MAX) {
		cout << -1 << endl;
		return 0;
	}cout << N - 1 + (MAX - K) << endl;
	for (int i = 2; i <= N; i++) cout << "1 " << i << endl;
	int now = 0;
	for (int i = 2; i <= N; i++) {
		for (int j = i + 1; j <= N; j++) {
			if (now == MAX - K) break;
			cout << i << " " << j << endl;
			now++;
		}if (now == MAX - K) break;
	}
}

Measured memory_bytes: 3620
import { readFileSync } from 'fs'

function calcSum(val: number[]) : number[] {
  let sum = []
  let sumAll = 0
  sum.push(sumAll)
  for (let one of val) {
    sumAll += one;
    sum.push(sumAll)
  }
  return sum
}

function lower_bound(arr: number[], n: number) {
  let first = 0, last = arr.length - 1, middle;
  while (first <= last) {
      middle = 0 | (first + last) / 2;
      if (arr[middle] < n) first = middle + 1;
      else last = middle - 1;
  }
  return first;
};

function upper_bound(arr: number[], n: number) {
  var first = 0, last = arr.length - 1, middle;
  while (first <= last) {
      middle = 0 | (first + last) / 2;
      if (arr[middle] <= n) first = middle + 1;
      else last = middle - 1;
  }
  return first;
};

function main(input: string[]) {
  let ans = 0
  let [N, M, K] = input[0].split(' ').map(v=>parseInt(v, 10))
  let [...A] = input[1].split(' ').map(v=>parseInt(v, 10))
  let [...B] = input[2].split(' ').map(v=>parseInt(v, 10))

  let aSum = calcSum(A)
  let bSum = calcSum(B)

  for (let i = 0; i <= N; i++) {
    let nokori = K - aSum[i]
    if (nokori < 0) break;
    let idx = upper_bound(bSum, nokori) - 1
    ans = Math.max(ans, idx + i)
  }
  console.log(ans)
}

let lines: string[] = [];
const reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', function (line: string) {
  lines.push(line);
});
reader.on('close', function () {
  main(lines)
});


Measured memory_bytes: 100392
'use strict';

function Main(input) {
    // N
    const N = input.trim().split('\n')[0];
    let bigN = BigInt(N);

    let bigArr = []
    while (bigN !== 0n) {
        const mod = bigN % 26n;
        if (mod === 0n) {
            bigArr.push(26n);
            bigN = bigN / 26n - 1n
        } else {
            bigArr.push(mod);
            bigN = bigN / 26n;
        }
    }
    let numArr = bigArr.map(v => Number(v));

    const alphabet = [
        'a', 'b', 'c', 'd', 'e',
        'f', 'g', 'h', 'i', 'j',
        'k', 'l', 'm', 'n', 'o',
        'p', 'q', 'r', 's', 't',
        'u', 'v', 'w', 'x', 'y', 'z'
        ];
    
    const result = numArr.map(v => alphabet[v - 1]).reverse().join('');

    console.log(result);

    return;
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29668
#include<iostream>
#include<vector>
#include<algorithm>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;
int main(void){
    string a;
    cin>>a;

    if(a=="SUN"){
        cout<<7<<endl;
    }else if(a=="MON"){
        cout<<6<<endl;
    }else if(a=="TUE"){
        cout<<5<<endl;
    }else if(a=="WED"){
        cout<<4<<endl;
    }else if(a=="THU"){
        cout<<3<<endl;
    }else if(a=="FRI"){
        cout<<2<<endl;
    }else if(a=="SAT"){
        cout<<1<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
int k,a,b,c,d,x,y;
  cin >> k >> a >>b;
  c=a/k;
  d=b/k;
  x=a%k;
  y=b%k;
if((c+1)*k<=b){
cout <<"OK";
}else if(x==0 || y==0){
  cout <<"OK";
}else{
cout <<"NG";
}
}


Measured memory_bytes: 3544
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
        int max = Math.max(a, b);
        int min = Math.min(a, b);
        int sum = a + b;
    
		// 出力
		System.out.println((sum) % 2 == 0 ? sum / 2 : "IMPOSSIBLE");
	}
}

Measured memory_bytes: 21844
//author : Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long
#define ln "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

const ll MOD = 1e9 + 7;

ll countDivisibles(ll A, ll B, ll M)
{
	if (A % M == 0)
		return (B / M) - (A / M) + 1;
	return (B / M) - (A / M);
}

int main()
{
	FASTIO;
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll lcm = (c * d) / __gcd(c, d);
	ll total = b - a + 1;
	ll X = countDivisibles(a, b, c);
	ll Y = countDivisibles(a, b, d);
	ll Z = countDivisibles(a, b, lcm);
	ll div = X + Y - Z;
	ll ans = total - div;
	cout << ans << ln;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define cint(d) scanf("%d", &d)
#define cint2(a, b) scanf("%d %d", &a, &b)
#define cint3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define cint4(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)

#define clong(d) scanf("%lld", &d)
#define clong2(a, b) scanf("%lld %lld", &a, &b)
#define clong3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define clong4(a, b, c, d) scanf("%lld %lld %lld %lld", &a, &b, &c, &d)

#define foreach(v, c) for(__typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define revforeach(v, c) for(__typeof( (c).rbegin()) v = (c).rbegin();  v != (c).rend(); ++v)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

typedef long long int slong;
typedef pair<int, int> pii;
typedef pair<slong, slong> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

#ifdef VSP4 
    #include "debug.h"    
#else
    #define debug(args...)                  // Just strip off all debug tokens
#endif

const int MOD = 1000000007;
#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define MODADDSET(d) if ((d) >= MOD) d -= MOD;
#define MODADDWHILESET(d) while ((d) >= MOD) d -= MOD;

const int MAXN = 1e6;
const int SQRTN = 550;
const int LOGN = 60;
const int INT_INFINITY = 1001001001;
const int LIMIT = 1e6;

const slong LONG_INFINITY = 1001001001001001001ll;
const slong LONG_LIMIT = 800100100100101ll;

int n;
int arr[MAXN+5];
int ans[MAXN+5];

int main()
{
	#ifdef VSP4
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	clock_t begin = clock();
	
	int t, i, j, l, r, k, x, type;
	
	cin >> n;
	
	for (i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}
	
	int first = 1;
	int last = n;
	
	bool putfirst = true;
	
	for (i = n; i >= 1; i--)
	{
		if (putfirst)
		{
			ans[first++] = arr[i];
		}
		else
		{
			ans[last--] = arr[i];
		}
		
		putfirst = 1 - putfirst;
	}
	
	for (i = 1; i <= n; i++)
	{
		cout << ans[i] << " ";
	}
	
	clock_t end = clock();
	double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
	
	cerr << elapsed_secs;
	
	return 0;
}


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

bool flag[100001];
int num[100001];

int main(void) {
  int n, m;
  cin >> n >> m;

  for (int i = 0; i <= n; i++) num[i] = 1;
  flag[1] = true;

  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    num[y]++;
    if (flag[x]) flag[y] = true;
    if (--num[x] == 0) flag[x] = false;
  }

  int ans = 0;
  for (int i = 0; i <= n; i++) {
    if (flag[i]) ans++;
  }
  cout << ans << endl;
}


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


    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846


    void solve(){
        int a,b;
        cin>>a>>b;
        string s="";
        string t="";
        for(int i=1;i<=a;i++)
            s+=(char)(b+'0');
        for(int i=1;i<=b;i++)
            t+=(char)(a+'0');
        if(s<t)
            cout<<s;
        else
            cout<<t;
    }


    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 256
N, K = map(int,input().split())
from itertools import accumulate
A = [0] + list(accumulate(map(lambda x:(int(x)+1)/2,input().split())))
M = 0
for x in range(N - K +  1):
    M = max(M,A[x + K] - A[x])
print(M)


Measured memory_bytes: 72048
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
using namespace std;

int main(){
    string s,t;
    cin >> s >> t; 
    string temp = s;
    temp += t.back();
    if( temp == t){
        cout << "Yes" << endl; 
    }else{
        cout << "No" << endl; 
    }
    return 0;
}

Measured memory_bytes: 3600
import bisect
n = int(input())
s6 = [pow(6,i) for i in range(1,20)]
s9 = [pow(9,i) for i in range(1,20)]
cost = [-1]*(max(n+1,12))
for x in range(12):
  if x < 6:
    cost[x] = x
  elif x < 9:
    cost[x] = (x//6) + (x%6)
  else:
    cost[x] = (x//9) + (x%9)
    
def get_cost(x):
  if 0 <= cost[x]:
    return cost[x]
  div6 = bisect.bisect_right(s6,x)-1
  a = pow(10,18)
  b = pow(10,18)
  for i in range(1,(x//s6[div6])+1):
    tmp = get_cost(x - i*s6[div6])
    if i + tmp < a:
      a = i + tmp
  div9 = bisect.bisect_right(s9,x)-1
  for j in range(1,(x//s9[div9])+1):
    tmp = get_cost(x - j*s9[div9])
    if j + tmp < b:
      b = j + tmp
  cost[x] = min(a,b)
  return cost[x]
print(get_cost(n))

Measured memory_bytes: 3828
import numpy as np 

N,K = map(int,input().split())
s=input()

li = []
right=0
left =0
cnta = 0
if s[right]=="0":
    cnta=1
while(right<len(s)-1):
    if s[right]=="1" and s[right+1]=="0":
        cnta += 1
    if cnta > K:
        li.append(len(s[left:right+1]))
        while(left<len(s)-1):
            if s[left]=="0" and s[left+1]=="1":
                left+=1
                cnta-=1
                li.append(len(s[left:right+1]))
                break
            left += 1
    right += 1
li.append(len(s[left:]))
mx = 0
for i in li:
    mx = max(mx, i)
print(mx)

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

int main(){
  int n,ga,sa,ba,gb,sb,bb;
  cin>>n>>ga>>sa>>ba>>gb>>sb>>bb;
  
  vector<long long> dp(n+1,0);
  for(int i =1;i<=n;++i){
    dp[i] = i;
    if(i>=ga){dp[i] = max(dp[i],dp[i-ga]+gb);}
    if(i>=sa){dp[i] = max(dp[i],dp[i-sa]+sb);}
    if(i>=ba){dp[i] = max(dp[i],dp[i-ba]+bb);}
  }
  int m = dp[n];
  vector<long long> dp2(m+1,0);
  for(int i =1;i<=m;++i){
    dp2[i] = i;
    if(i>=gb){dp2[i] = max(dp2[i],dp2[i-gb]+ga);}
    if(i>=sb){dp2[i] = max(dp2[i],dp2[i-sb]+sa);}
    if(i>=bb){dp2[i] = max(dp2[i],dp2[i-bb]+ba);}
  }  
  cout<<dp2[m]<<endl;
  return 0;
}

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


int main()
{
  string s;
  cin >> s;
  
  for (ll i = 0; i <= s.size(); ++i) {
    if ((i+1) & 1) {
      if (s[i] == 'L') {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if (s[i] == 'R') {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

int main(){
  int N,Y;
  cin>>N>>Y;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N-i;j++){
      if(10000*i+5000*j+1000*(N-i-j)==Y){
        cout<<i<<" "<<j<<" "<<N-i-j<<endl;
        return 0;
      }
    }
  }
  cout<<"-1 -1 -1"<<endl;
  return 0;
}

Measured memory_bytes: 256
S=input()
L=len(S)
ans='AC'

if S[0] != 'A':
    ans='WA'

cnt=0

for i in range(1,L):
    if S[i].isupper():
        if i==1 or i==L-1 or S[i] != 'C':
            ans='WA'
        cnt+=1

if cnt != 1:
    ans='WA'

print(ans)
    

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
         Scanner sc = new Scanner(System.in);
         int A=sc.nextInt();
         int B=sc.nextInt();
         
         int consent=1;
         int tap=0;
         int num=0;
         while(consent<B){
             consent-= 1;
             consent+=A;
             tap+=1;
         }
         
         
         System.out.println(tap);
    }
}


Measured memory_bytes: 35592
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define YES cout << "YES" << endl
#define NO  cout << "NO"  << endl
#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 1000000
using namespace std;
typedef long long ll;



int main(){
  int n;  cin >> n;
  vector<int> f(n, 0);
  vector<int> h(n);
  int max = -1;
  rep(i, 0, n){
    cin >> h[i];
    max = (max<h[i])?h[i]:max;
  }
  int ans=0;
  rep(i, 0, n-1){
    if(h[i]>h[i+1]){
      ans += (h[i]-h[i+1]);
    }
  }
  ans += h[n-1];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
S = input()
id = 0
keyence = "keyence"
for i in range(len(S)):
    if S[i] == keyence[id]:
        id += 1
    else:
        break
id2 = 1
for i in reversed(range(id, len(S))):
    if S[i] == keyence[-id2]:
        id2 += 1
    else:
        break

if id + id2 - 1 >= 7:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
using System;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        double ans = 0;
        for (int i = 0; i < n; i++)
        {
            var line = Console.ReadLine().Split();
            if (line[1] == "JPY") ans += double.Parse(line[0]);
            else ans += double.Parse(line[0]) * 380000;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N;
	char buf[55];

	scanf("%d",&N);
	scanf("%s",buf);

	int ans = 0;
	for(int i = 0; i+2 < N; i++){

		if(buf[i] == 'A' && buf[i+1] == 'B' && buf[i+2] == 'C'){
			ans++;
		}
	}

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

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int a, b, c;
int main() {
	cin >> a >> b >> c;
	for (int i = 1; i <= b; i++) {
		if (a * i % b == c) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;	
}

Measured memory_bytes: 256
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())

k = k - 1

print(l[k])

Measured memory_bytes: 3060