akhauriyash/Code-Regression huggingface dataset:
/*
        karmany evadhikaras te
        ma phalesu kadacana 
        ma karma-phala-hetur bhur
        ma re sango'stv akarmani (B.G.-2.47)
 
Translation:
        Lord Krsna to Arjuna.
You have a right to perform your prescribed duty, 
but you are not entitled to the fruits of action. 
Never consider yourself the cause of the results of your activities, 
and never be attached to not doing your duty.    
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 200005;
const ll mod = 1e9+7;
#define ld long double
#define PI 3.14159265358979323846
const int X = 11000000;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
}

//3. Structure or classes
//3. Ends here

//1. Data structures declaration here
//1. Ends here

//2. Extra Functions here
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    for (int zz = 0; zz < t; zz++)
    {
        solve();
        //cout<<"\n";
    }
    return 0;
}

void solve()
{
    int a;
    cin>>a;
    cout<<(a+a*a+a*a*a);
    return;
}



Measured memory_bytes: 3644
/**
 *    author:  tourist
 *    created: 18.01.2020 23:19:35       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> balls(n, 1);
  vector<int> red(n, 0);
  red[0] = 1;
  while (m--) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    balls[x] -= 1;
    balls[y] += 1;
    red[y] |= red[x];
    red[x] &= !!balls[x];
  }
  cout << accumulate(red.begin(), red.end(), 0) << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef pair<P,P> Edge;
typedef long long ll;

const double PI=4*atan(1.0);

//#define RED_FILE

#ifdef RED_FILE
ifstream ifs("input.txt");
ofstream ofs("output.txt");
#define cin ifs
#define cout ofs
#endif

bool dp[101][321][321];

int main(){

    int t;
    cin>>t;
    while(t--){
        memset(dp,0,sizeof(dp));
        int n;
        cin>>n;
        int a[101];
        for(int i = 0; i < n; i++)
            cin>>a[i];
        if(n==1){
            cout<<a[0]<<endl;
            continue;
        }
        dp[0][a[0]][a[1]]=true;

        for(int i = 1; i < n-1; i++){
            // from
            for(int j = 0; j < 321; j++){
                for(int k = 0; k < 321; k++){

                    if(dp[i-1][j][k]){
                        if(k-1>=0)
                            dp[i][k-1][j+a[i+1]]=true;
                        dp[i][k][a[i+1]]=true;
                    }
                }
            }
        }
        int maxNum=0;
        for(int i = 0; i < 321; i++){
            for(int j = 0; j <321; j++){
                if(dp[n-2][i][j]){
                    maxNum=max(maxNum,j);
                }
            }
        }
        cout<<maxNum<<endl;
    }

    return 0;
}

Measured memory_bytes: 0
n = int(input())

for i in range(1, n+1):
    
    if i % 3 == 0:
        print(f" {i}", end="")
    else:
        x = i
        while (x):
            if x % 10 == 3:
                print(f" {i}", end="")
                break
            else:
                pass
            
            x = x // 10

print()


Measured memory_bytes: 5888
#include<stdio.h>

#define MAX 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

int C[MAX],A[MAX][MAX],d[MAX],f[MAX],time=0,k[MAX];

void visit(int);
 
 int main()
 {
   int n,i,j,v,id;

   scanf("%d",&n);

   for(i = 1 ; i <= n ; i ++)
     {
       scanf("%d",&id);
       scanf("%d",&k[id]);
       for(j = 1 ; j <= k[id] ; j++)
	 {
	   scanf("%d",&v);
	   A[id][j] = v;
	 }
     }

   for(i = 1 ; i <= n ; i++)
     {
       C[i] = WHITE;	 
     }

   for(i = 1 ; i <= n ; i++)
     {
       if(C[i] == WHITE) visit(i);
     }

   for(i = 1 ; i <= n ; i++)
     {
       printf("%d %d %d\n",i,d[i],f[i]);
     }
   
   return 0;
 }

void visit(int u)
{
  int v,i;
  
  C[u] = GRAY;
  d[u] = ++time;

  for(i = 1 ; i <= k[u] ; i++)
    {
      v = A[u][i];
      if(C[v] == WHITE) visit(v);
    }

  C[u] = BLACK;
  f[u] = ++time;

  return;
}



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

using namespace std;

int main() {
    map<string,string> x {
            {"Sunny", "Cloudy"},
            {"Cloudy", "Rainy"},
            {"Rainy", "Sunny"}
    };
    string s;
    cin >> s;
    cout << x[s] << endl;
    return 0;
}

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

using namespace std;

int main(){
    vector<int> a(10000);
    vector<int> b(10000);
    int a_check;
    int b_check;
    int tmp;
    int N = 0;
    
    for(int i=0;i<10000;i++){
        cin >> a_check >> b_check;
        if(a_check == 0&&b_check==0){
            break;
        }
        if(a_check > b_check){
            a.at(i) = b_check;
            b.at(i) = a_check;
        } else{
            a.at(i) = a_check;
            b.at(i) = b_check;
        }
        N++;
    }
    
    for(int i=0;i<N;i++){
        cout << a.at(i) << " " << b.at(i) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3188
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	n := nextInt()
	ab := make([]Pair, n)
	for i := 0; i < n; i++ {
		ab[i].a = nextInt()
		ab[i].b = nextInt()
	}
	sort.Sort(Pairs(ab))
	time := 0
	for i := 0; i < n; i++ {
		time = time + ab[i].a
		if ab[i].b < time {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].b == p[j].b {
		return p[i].a > p[j].a
	}
	return p[i].b < p[j].b
}


Measured memory_bytes: 6272
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(void){
	int A,B;
	cin >> A >> B;
	if(A>=13){
		cout << B ;
	}else if(A>=6){
		cout << B/2;
	}else{
		cout << 0;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

L = []
for i in range(N):
    L.append(S[i])
    
ans = 0
for i in range(1, N+1):
    c = 0
    temp1 = L[0:i]
    temp2 = L[i:N+1]
    temp1_set = set(temp1)
    temp2_set = set(temp2)
    temp1 = list(temp1_set)
    temp2 = list(temp2_set)
    for j in range(len(temp1)):
        for k in range(len(temp2)):
            if temp1[j] == temp2[k]:
                c += 1
                break
    if ans < c:
        ans = c
        
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

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


void solve(){
    string s;
    cin >> s;
    int a =0, b = 0;
    for(int i = 0 ; i < s.size(); i++){
        if(s[i] == 'A') a++;
        if(s[i] == 'B') b++;
    }
    if(a && b)
        cout << "Yes\n";
    else
        cout << "No\n";

}


int main(){
    //int t; cin >> t;
    //while(t--) solve();
    solve();
    return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	vector<tuple<string, int, int>> v;
	for(int i=1; i<=n; i++){
		string s;
		int score;
		cin >> s >> score;
		v.push_back(make_tuple(s, 100-score, i));
	}
	sort(v.begin(), v.end());
	for(int i=0; i<n; i++) cout << get<2>(v[i]) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
#define ll long long
using namespace std;
const int LIM = 4e6+3;
pair<int,int> arr[LIM+3];
int main(){
  int n;cin >> n;
  int Ans = 0;
  for(int i = 1;i<=n;i++)
  {
    string s = to_string(i);
    if((s.size())%2 == 1)Ans++;
  }
  cout <<Ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    N = int(input())
    A = list(map(int, input().split()))

    return N, A


def main(A: list) -> None:
    """
    メイン処理.

    Args:\n
        A (list): 整数列(1 <= A_i <= 10^9)
    """
    # 求解処理
    ans = max(A) - min(A)

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, A = get_input()

    # メイン処理
    main(A)


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

int main() {
  string s,t;
  cin >> s >> t;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

int main()
{
    int N;
    string S, ans = "";
    cin >> N >> S;
    for (int i = 0; i < S.length(); i++)
    {
        char transformed = S[i] + N;
        while (transformed > 90)
            transformed -= 26;
        ans.push_back(transformed);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC042A
{
	class Program
	{
		static void Main(string[] args)
		{
			int A, B, C;
			var word = Console.ReadLine().Split(' ');
			A = int.Parse(word[0]);
			B = int.Parse(word[1]);
			C = int.Parse(word[2]);
			if (A == 5 && B == 7 && C == 5 || A == 7 && B == 5 && C == 5 || A == 5 && B == 5 && C == 7)
				Console.WriteLine("YES");
			else
				Console.WriteLine("NO");



			Console.ReadKey();
		}
	}
}


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

using namespace std;

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

    int a,b,c,d;
    cin>>a>>b;
    c = a+b;
    d = a*b;
    if(c==15)
    {
        cout<<"+"<<endl;
    }
    else if(d==15)
    {
        cout<<"*"<<endl;
    }
    else
    {
        cout<<"x"<<endl;
    }
    return 0;
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	vector<pair<int, int>> x;

	rep(i, n){
		int in;
		cin >> in;

		x.push_back(make_pair(in - 1, i));
	}

	sort(all(x));

	rep(i, n){
		cout << x[i].second + 1;
		if(n != n - 1) cout << " ";
	}

	return 0;
}

Measured memory_bytes: 1780
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
use std::cmp::max;
fn main() {
    input! {
        n: i64,
        s: [String; n],
        m: i64,
        t: [String; m],
    }
    let mut ans = 0;
    for s_ in s.iter() {
        ans = max(
            s.iter().filter(|x| *x == s_).count() as i64
                - t.iter().filter(|x| *x == s_).count() as i64,
            ans,
        );
    }
    println!("{}", ans);
}


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

public class Main {

	public static void main(String[] args) {
		Main ans = new Main();
		System.out.println(ans.solve());
	}

	private long solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long [] array = new long[N+1];
		for(int i=1;i<=N;i++){
			array[i] = sc.nextLong();
		}

		long [][] dp = new long[N+1][K+1];
		long MOD = (long) 1e9+7;

		for(int i=0;i<=K;i++){
			dp[1][i] = (i<=array[1]) ? 1 : 0;
		}

		for(int i=2;i<=N;i++){
			for(int j=0;j<=K;j++){
				if (j==0) {
					dp[i][j] = dp[i-1][j];
				} else {
					dp[i][j] = (MOD+ dp[i-1][j] + dp[i][j-1] - (((j-1-array[i]) >=0) ? dp[i-1][(int)(j-1-array[i])] : 0))%MOD;
				}
			}
		}

		return dp[N][K];
	}

}

Measured memory_bytes: 140140
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstdio>
using namespace std;

#define int long long
#define INF 1e18

signed main() {
    int n; cin >> n;
    int sum = 0;
    for(int i = 0; i < n; i++) {
        int l, r; cin >> l >>r;
        sum += r - l + 1;
    }
    cout << sum << endl;
}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod = 1000000007;		

int n;
VI b[100003];

const int MAX = 510000;
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;
}


int main() {

	cin >> n;
	VI a(n + 1);
	int c, d;
	REP(i, n + 1) {
		cin >> a[i];
		if (b[a[i]].size() == 1) {
			c = b[a[i]][0];
			d = i;
		}
		else b[a[i]].push_back(i);
	}

	COMinit();

	cout << n << endl;

	FOR(i, 2, n + 2) {
		int j = i - 2;
		ll ans = 0;
		ans += COM(n - 1, i);

		ans += COM(c + n - d, i - 1);
		ans += (COM(c + n - d + (d - c - 1), i - 1) - COM(c + n - d, i - 1)) * 2;
		ans += COM(n - 1, j);
		ans += mod * 10;
		ans %= mod;
		cout << ans << endl;
	}
}

Measured memory_bytes: 19072
#include<stdio.h>
int main(){

    int a,b,plus,minus;
    scanf("%d%d",&a,&b);
    plus=a+b;
    minus=b-a;
    if(b%a==0){
        printf("%d\n",plus);
    }
    else{
        printf("%d\n",minus);
    }


return 0;



}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include <stdio.h> 
using namespace std;
#define MAXN 200005
char s[MAXN];
int cnt=0;
int mo1=0, mo2=0;
inline int qpow(int a, int b, int p) {
	int ans=1;
	for(;b;b>>=1) {
		if(b&1) ans = (long long)ans*a%p;
		a=(long long)a*a%p;
	}
	return ans;
}

int main() {
	int n; scanf("%d", &n);
	scanf("%s", s);
	for(int i=0; i<n; i++) {
		if(s[i]=='1') cnt++;
	}
	for(int i=0; i<n; i++) {
		mo1=(mo1*2+(s[i]-'0'))%(cnt+1);
	}
	if(cnt>1) {
		for(int i=0; i<n; i++)
		mo2=(mo2*2+(s[i]-'0'))%(cnt-1);
	}
    //cout << mo1 << "," << mo2 << endl;
    
	for(int i=0; i<n; i++) {
		int now;
		if(s[i]=='0') {
			now=(mo1+qpow(2,n-i-1,cnt+1))%(cnt+1);
		} else {
			if(cnt==1) {puts("0"); continue;}
			now=(mo2-qpow(2,n-i-1,cnt-1)+cnt-1)%(cnt-1);
		}
		int f=1;
		while(now>0) {
			now = now%__builtin_popcount(now);
			f++;
		}
		printf("%d\n", f);
	}
}

Measured memory_bytes: 3940
a = int(input())
x=list(input())
y=list(input())
s = 1
i=0
if x[0] == y[0]:
    s*=3
    i+=1
else:
    s*=6
    i+=2
while i <a :
    if x[i-1] == y[i-1] and x[i]==y[i]:
        s*=2
    elif x[i-1] == y[i-1] and x[i]!=y[i]:
        s*=2
    elif x[i-1] != y[i-1] and x[i] !=y[i]:
        s*=3
    if not x[i] == y[i]:
        i+=1
    i+=1
print(s%1000000007)
    

Measured memory_bytes: 3064
#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;

void solve(long long N, vector<long long> A){
	ll k = 0;

	rep(i, N) {
		k += A[i];
	}
	// cout << k << endl;
	bool flg = true;
	if (k * 2 % (N * (N + 1)) != 0) flg = false;
	k = k * 2 / (N * (N + 1));
	// cout << k << endl;
	ll cnt = 0;
	
	rep(i, N) {
		ll e =  -1 * (A[(i+1)%N] - A[i%N] - k);
		// cout << i << " " << e << endl;
		if (e < 0 || e % N != 0) {
			flg = false;
			break;
		}
		cnt += e / N;
	}
	if (cnt == k && flg) cout << "YES" << endl; else cout << "NO" << endl;
}

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



Measured memory_bytes: 1920
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <iostream>

#pragma warning(disable:4996)

using namespace std;



int main()
{
	char a[100], b[100], c[100];
	while (~scanf("%s %s %s", a, b, c))
	{
		if (b[0] == a[strlen(a) - 1] && c[0] == b[strlen(b) - 1])
			printf("YES\n");
		else
			printf("NO\n");

	}

	return 0;
}

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

using namespace std;

typedef long double ld;
typedef long long ll;

const long double eps = 1e-10;

ll lgput(ll a, ll b) {
    ll ret = 1;

    while(b) {
        if(b&1) ret *= a;
        b >>= 1;
        a *= a;
    }

    return ret;
}

const int MAXN = 2e5 + 10;

ll sp[MAXN];
ll ans = 1e18;
int n;
void solve(int mid, vector< ll > &v) {
    int pos1 = 0;
    for(int step = 30; step >= 0; --step) {
        int newpos = pos1 + (1<<step);
        if(newpos >= mid) continue;
        if(sp[newpos] < sp[mid] - sp[newpos]) pos1 = newpos;
    }

    int pos2 = mid;
    for(int step = 30; step >= 0; --step) {
        int newpos = pos2 + (1<<step);
        if(newpos >= n) continue;
        if(sp[newpos] - sp[mid] < sp[n] - sp[newpos]) pos2 = newpos;
    }

    pos1 = max(pos1, 1);
    pos2 = max(pos2, mid + 1);
    for(int i = pos1; i <= min(pos1 + 1, mid-1); ++i) {
        for(int j = pos2; j <= min(pos2 + 1, n-1); ++j) {
            vector< ll > s(4);
            s[0] = sp[i];
            s[1] = sp[mid] - sp[i];
            s[2] = sp[j] - sp[mid];
            s[3] = sp[n] - sp[j];
            ll minn = 1e18;
            ll maxx = -1e18;
            for(int k = 0; k < 4; ++k) {
                minn = min(minn, s[k]);
                maxx = max(maxx, s[k]);
            }

            ans = min(ans, abs(minn - maxx));
        }
    }

    pos1 = 0;
    for(int step = 30; step >= 0; --step) {
        int newpos = pos1 + (1<<step);
        if(newpos >= mid) continue;
        if(sp[newpos] <= sp[mid] - sp[newpos]) pos1 = newpos;
    }

    pos2 = 0;
    for(int step = 30; step >= 0; --step) {
        int newpos = mid + pos2 + (1<<step);
        if(newpos >= n) continue;
        if(sp[newpos] - sp[mid] <= sp[n] - sp[newpos]) pos2 = newpos;
    }

    pos1 = max(pos1, 1);
    pos2 = max(pos2, mid + 1);
    for(int i = pos1; i <= min(pos1 + 1, mid-1); ++i) {
        for(int j = pos2; j <= min(pos2 + 1, n-1); ++j) {
            vector< ll > s(4);
            s[0] = sp[i];
            s[1] = sp[mid] - sp[i];
            s[2] = sp[j] - sp[mid];
            s[3] = sp[n] - sp[j];
            ll minn = 1e18;
            ll maxx = -1e18;
            for(int k = 0; k < 4; ++k) {
                minn = min(minn, s[k]);
                maxx = max(maxx, s[k]);
            }

            ans = min(ans, abs(minn - maxx));
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n;

    vector< ll > v(n + 10);

    for(int i = 1; i <= n; ++i) {
        cin >> v[i];
        sp[i] = sp[i-1] + v[i];
    }

    for(int i = 2; i <= n-2; ++i) {
        solve(i, v);
    }

    cout << ans;
}


Measured memory_bytes: 3456
N, K = map(int, input().split())

ans = 1
for k in range(K, N + 1):
    sum_min = k * (k - 1) // 2
    sum_max = k * N - k * (k - 1) // 2
    ans += sum_max - sum_min + 1
    
print(ans % (10**9 + 7))


Measured memory_bytes: 63640
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	double a_d,b_d;
	scanf("%d %d",&a,&b);
	a_d = static_cast<double>(a);
	b_d = static_cast<double>(b);
	printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
}

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

using namespace std;

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;

  int passed = 0;
  int border = a + b;
  int count_b = 0;
  for(int i = 0;i < s.size();i++){
    switch(s[i]){
      case 'a':
        if(passed < border){
          cout << "Yes" << endl;
          passed++;
        }else{
          cout << "No" << endl;
        }
        break;
      case 'b':
      count_b++;
        if(passed < border && count_b <= b){
          cout << "Yes" << endl;
          passed++;
        }else{
          cout << "No" << endl;
        }
        break;
      case 'c':
        cout << "No" << endl;
    }
  }

}


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

int main (){
  string str;
  cin >> str;
  int count = 0;
  for (int i = 0; i < str.length() - 1; i ++){
    if (str[i] != str[i + 1]){
      count ++;
    }
  }
  cout << count << '\n';
}

Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
typedef vector<string> vs;
typedef pair<l_l,ll> lll;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
template<class T> inline bool chmin(T& a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
int main(){
    ll x;cin>>x;
    x/=200;
    cout<<10-x<<endl;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n,k,s;
    cin >> n >> k >> s;
    ll re = s+1;
    if(re > 1e9)re = 1;
    rep(i,k)cout << s << " ";
    for(int i = k;i<n;i++)cout << re << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

const int N = 1e3+50;
const int INF = 2e9;
const double PI = acos(-1);

int arr[2000][2000];

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

    memset(arr,0,sizeof(arr));

    int k=38;
    int n = n=k*k-k+1;
    // int n=21, k=5;
    int angka = 2;
    for(int i=0;i<k;++i){
        for(int j=0;j<k;++j){
            if(j == 0){
                arr[i][j] = 1;
            }else{
                arr[i][j] = angka;
                angka++;
            }
        }
    }

    angka = 2;
    int cnt = 0;
    for(int i=k;i<n;++i){
        arr[i][0] = angka;
        cnt++;
        if(cnt == k-1){
            cnt = 0;
            angka++;
        }
    }

    angka = arr[1][1];
    cnt = 0;
    int blok;
    for(int j = 1; j < k; ++j){
        for(int t=0;t<k-1;++t){
            blok = 2;
            for(int i = k+t; i <= n ;){
                int realpos;
                if(i == k+t) realpos = i;
                else realpos = i + cnt;
                if(realpos > blok*(k-1)){
                    realpos -= k-1;
                }
                arr[realpos][j] = angka;
                i = realpos + k-1;
                blok++;
            }
            angka++;
        }
        cnt++;
    }
    

    pf("%d %d\n",n,k);
    for(int i=0;i<n;++i){
        for(int j=0;j<k;++j){
            if(j) pf(" ");
            pf("%d",arr[i][j]);
        }
        pf("\n");
    }

    return 0;
}

Measured memory_bytes: 16128
import sys
N, Y = map(int, input().split())

Y //= 1000

for y in range(0, (10*N-Y)//5+1):
    for z in range(0, (10*N-Y-5*y)//9+1):
        if 10*N - Y == 5*y + 9*z:
            if N-y-z < 0:
                continue
            print(N-y-z, y, z)
            sys.exit()

print(-1, -1, -1)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main(){
    string str1,str2;
    int n,p=0,q=0;
    cin>>n;
    for(int i = 0;i<n;i++){
        cin>>str1>>str2;
        if(str1==str2){
            p++;
            q++;
        }
        else if(str1<str2){
            q=q+3;
        }
        else{
            p=p+3;
        }
    }
    cout<<p<<" "<<q<<endl;
    return 0;
}


Measured memory_bytes: 3156
program ABC166_D
  integer::A
  integer::C(10000)
  double precision::X
  C=0
  read(*,*)X
  N=0
  A=int(sqrt(X))
  do i=1,A
     if(int(X)/i*i==int(X)) then
        N=N+1
        C(N)=i
     end if
  end do
  do i=1,N
     do j=-1000,1000
        if(C(i)*(5*j**4+10*(j**3)*C(i)+10*(j**2)*(C(i)**2)+5*j*(C(i)**3)+C(i)**4)==int(X)) then
           write(*,*)C(i)+j,j
           stop
        end if
     end do
  end do
end program ABC166_D

Measured memory_bytes: 2964
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aparts = (1..4).map { (1..3).map { (1..10).map { 0 }.toMutableList() } }

    (1..n).forEach {
        val (b, f, r, v) = readLine()!!.split(" ").map(String::toInt)
        aparts[b-1][f-1][r-1] += v
    }

    aparts.forEachIndexed { index, apart ->
        apart.map { " " + it.joinToString(" ") }.map(::println)
        if (index != 3) println("#".repeat(20))
    }
}


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

int main(){
    int a, b, c;
    int penki[101];
    int sum;

    cin >> a >> b >> c;

    for(int i = 1; i <= 100; i++){
        penki[i] = 0;
    }

    penki[a]++;
    penki[b]++;
    penki[c]++;

    for(int i = 1; i <= 100; i++){
        if(penki[i] != 0)
            sum++;
    }

    cout << sum << endl;

    return 0;
}


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

int main()
{
    vector<vector<int>> c(3, vector<int>(3));
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> c.at(i).at(j);
        }
    }

    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            if (c.at(i + 1).at(j) - c.at(i).at(j) != c.at(i + 1).at(j + 1) - c.at(i).at(j + 1))
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
N = int(input())
a = input().split()

sum = 0
for a_int in a:
    a_int = int(a_int)
    count = 0
    flag = 0
    while flag == 0:
        if a_int % 2 == 0:
            a_int = a_int / 2
            count += 1
        else:
            flag = 1
            break
    sum += count
print(sum)


Measured memory_bytes: 3828
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=100010;
const int ws_[4]={1,-1,0,0},ad_[4]={0,0,1,-1};
int N;
struct point{
	double x,y;
	int dir;
	point(double xx=0,double yy=0,int dd=0){
		x=xx,y=yy,dir=dd;
	}
	point move(double t){
		return point(x+ws_[dir]*t,y+ad_[dir]*t,dir);
	}
}p[maxn];
double calc(double x){
	double mxx=-1e10,mxy=-1e10,mnx=1e10,mny=1e10;
	for(int i=1;i<=N;i++){
		point tmp=p[i].move(x);
		mxx=max(mxx,tmp.x);
		mxy=max(mxy,tmp.y);
		mnx=min(mnx,tmp.x);
		mny=min(mny,tmp.y);
	}
	return (mxx-mnx)*(mxy-mny);
}
int main(){
	//freopen("in","r",stdin);
	N=read();
	for(int i=1;i<=N;i++){
		p[i].x=read(),p[i].y=read();
		char ch=one();
		if(ch=='R')p[i].dir=0;
		else if(ch=='L')p[i].dir=1;
		else if(ch=='U')p[i].dir=2;
		else p[i].dir=3;
	}
	double L=0,R=1e12,mid1,mid2,val1,val2,ans=1e18;
	for(int i=1;i<=500;i++){
		mid1=L+(R-L)/3;
		mid2=R-(R-L)/3;
		val1=calc(mid1);
		val2=calc(mid2);
		if(val1>val2)
			L=mid1;
		else
			R=mid2;
		ans=min(ans,val1);
		ans=min(ans,val2);
	}
	printf("%.10lf\n",ans);
	return 0;
}



Measured memory_bytes: 3192
import java.lang.Math

fun main(args: Array<String>) {
    var (a,b,x) = readLine()!!.split(" ").map(String::toDouble)
    var s = x / a
    var ans = 0.0
    var la = 0.0
    if (s > b * a / 2) {
        val ub = 2 * s / a - b
        s -= a * ub
        b -= ub
        la = a
    } else {
        la = 2 * s / b
    }
    val r = Math.atan(b/la)
    ans = r * 180 / Math.PI

    println(String.format("%.10f",ans))
}

Measured memory_bytes: 37844
#include <stdio.h>

char board[600][600];

main(){
	int h,w;
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;i++)scanf("%s",board[i]);
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(j==0)printf(".");
			else if(i%2==0||j==w-1)printf("#");
			else printf("%c",board[i][j]);
		}
		puts("");
	}
	puts("");
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(j==w-1)printf(".");
			else if(i%2==1||j==0)printf("#");
			else printf("%c",board[i][j]);
		}
		puts("");
	}

}

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

int main(){
  long long a,b,c,d;  cin >> a >> b >> c >> d;
  long long ans;
  if(a >= 0){
    if(c >= 0)  ans = b*d;
    else if(d >= 0) ans = b*d;
    else  ans = a*d;
  }
  else if(b >= 0){
    if(c >= 0)  ans = b*d;
    else if(d >= 0) ans = max(b*d,a*c);
    else  ans = a*c;
  }
  else{
    if(c >= 0)  ans = b*c;
    else if(d >= 0) ans = a*c;
    else  ans = a*c;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e6+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

string s;
ll dp[MAXn][2];
ll cal(ll x,ll c){
    if (x == SZ(s)) return c;
    if (dp[x][c] != -1) return dp[x][c];
    ll cur = s[x] - '0' + c;
    ll ret = INF;
    if (cur < 10) ret = min(ret,cal(x+1,0LL) + cur);
    ret = min(ret,cal(x+1,1LL) + 10-cur);
    return dp[x][c] = ret;
}
int main(){
    IOS();
    cin >> s;
    reverse(ALL(s));
    RST(dp,-1);
    cout << cal(0,0) << endl;
}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

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

bool solve(int N, vll& A) {
    ll S = 0;
    for (ll a : A) S += a;

    if (N % 2 == 0) {
        if (S % 2 == 0) return false;
        else return true;
    } else {
        int num_odd = 0;
        int sum_odd = 0;
        for (ll a : A) {
            num_odd += (a % 2);
            if (a%2 == 1) sum_odd += a;  
        } 

        if (S % 2 == 0) return true;
        else if (num_odd > 1) return false;
        else {
            if (sum_odd == 1) return false;

            vll B(A);
            for (int i=0;i<N;i++){
                if (B[i] % 2 == 1) B[i]--;
            } 

            ll g = B[0];
            for (int i=1;i<N;i++) g = gcd(g, B[i]);

            for (int i=0;i<N;i++) {
                B[i]/=g;
            }
            return !solve(N, B);
        }

    }
}

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

    vll A(N);

    for (int i=0;i<N;i++) cin >> A[i];
    
    if (N == 1) {
        cout << "Second" << endl;
        return 0;
    } 

    if (solve(N, A)) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }

    return 0;

}


Measured memory_bytes: 19072
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void calc(long[] a) {
    long[long] freq;
    foreach (x; a) freq[x]++;

    long sum = 0;
    foreach (v; freq.values) {
        sum += v * (v - 1) / 2;
    }

    long[long] map; // 各ボールごとの組み合わせ数
    foreach (k, v; freq) {
        map[k] = v * (v - 1) / 2;
    }

    foreach (x; a) {
        long ans = sum - map[x];
        long k = freq[x] - 1;
        if (k > 1) ans += k * (k - 1) / 2;
        writeln(ans);
    }
}

void main() {
    readint;
    auto a = reads!long;
    calc(a);
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


Measured memory_bytes: 40720
#include <iostream>
using namespace std;
int main()
{
int n;
int a[1000];
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i];
int sum=0;
for(int i=0;i<n;i++)
{for(int j=i+1;j<n;j++)
sum+=a[i]*a[j];
}
cout <<sum;
}


Measured memory_bytes: 256
#include<cstdio>
int n,a[200010];
inline int read(){
	int ret=0;char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')ret=(ret<<1)+(ret<<3)+(c^48),c=getchar();
	return ret;
}
int main()
{
	n=read();
	for(register int i=1;i<=n;++i)a[i]=read();
	for(register int i=n;i>0;i-=2)printf("%d ",a[i]);
	for(register int i=(n&1)+1;i<=n;i+=2)printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n , m , k;
int a[21][21];
int b[21];
int ans;
int main(){

	cin >> n >> m >> k;
	for(int i = 0; i < m; i++){
		cin >> b[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	for(int i = 0; i < n; i++){
		int sum = 0;
		for(int j = 0; j < m; j++){
			sum += a[i][j] * b[j];
		}
		sum += k;
		if(sum > 0)
			ans = ans + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

const ll mod=998244353;
ll mu(ll a,ll b){
  return (ll)a*b%mod;
}
ll ad(ll a,ll b){
  if((a+=b)>=mod)a%=mod;
  return a;
}
ll pw(ll a,ll b,ll c=1LL){
  for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
  return c;
}
ll dv(ll a,ll b){
  return mu(a,pw(b,mod-2));
}


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

  ll n,a,b,k;
  cin >> n >> a >> b >> k;

  vector<ll> fact(n+1);
  vector<ll> inv(n+1);
  fact[0]=1;
  rep1(i,n) fact[i] = mu(fact[i-1],i);
  rep(i,n+1) inv[i] = dv(1,fact[i]);
  ll ans=0;
  rep(l,n+1){
    ll m = (k-l*a)/b;
    if(l*a+m*b==k && m>=0 && m<=n){
      //      cout << "l m "<< l << " " << m << endl;
      ans = ad(ans,mu(mu(mu(fact[n],inv[l]),inv[n-l]), mu(mu(fact[n],inv[m]),inv[n-m]) ));
    }
  }
    cout << ans << endl;
  
  return 0;
    

}


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

int main(){
  int N,K;
  scanf("%d %d",&N,&K);
  int A[N],B[N];
  int i;
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    B[i]=0;
  }
  for(i=0;i<N;i++){
    B[A[i]-1]+=1;
  }
  sort(B,B+N);
  int n=0;
  for(i=0;i<N-K;i++){
    n+=B[i];
  }
  printf("%d",n);
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
using namespace std;

typedef long long ll;

int main()
{
    ll n,i;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);
    for(i = 0;i < n-1;++i){
        cin >> a.at(i) >> b.at(i) >> c.at(i);
    }
    vector<vector<pair<ll,ll>>> rinsetsu(n);
    for(i = 0;i < n-1;++i){
        rinsetsu.at(a.at(i)-1).emplace_back(b.at(i)-1,c.at(i));
        rinsetsu.at(b.at(i)-1).emplace_back(a.at(i)-1,c.at(i));
    }

    ll q,k;
    cin >> q >> k;
    vector<ll> x(q);
    vector<ll> y(q);
    for(i = 0;i < q;++i){
        cin >> x.at(i) >> y.at(i);
    }
    vector<bool> visited(n,false);
    visited.at(k-1) = true;
    vector<ll> distance(n,0);
    stack<pair<ll,ll>> st;
    for(i = 0;i < rinsetsu.at(k-1).size();++i){
        st.emplace(rinsetsu.at(k-1).at(i).first, rinsetsu.at(k-1).at(i).second);
    }
    ll edge;
    ll temp_distance;
    while(!st.empty()){
        edge = st.top().first;
        temp_distance = st.top().second;
        st.pop();
        visited.at(edge) = true;
        distance.at(edge) = temp_distance;
        for(i = 0;i < rinsetsu.at(edge).size();++i){
            if(!visited.at(rinsetsu.at(edge).at(i).first)){
                st.emplace(rinsetsu.at(edge).at(i).first,temp_distance + rinsetsu.at(edge).at(i).second);
            }
        }
    }
    for(i = 0;i < q;++i){
        cout << distance.at(x.at(i)-1) + distance.at(y.at(i)-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 14704
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <string>
#include <iomanip>
using namespace std;


int main() {
	int n, element;
	cin >> n;
	vector<int>test(n);
	int count = 0;
	while (count < n) {
		cin >> element;
		test[count] = element;
		count++;
	}
	sort(test.begin(), test.end());
	for (int i = 0; i < n-1; ++i) {
		if (test[i] == test[i + 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}





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

int main(){
  string s;
  cin >> s;
  string check = "CODEFESTIVAL2016";
  int ans = 0;
  for (int i = 0; i < s.size(); i ++) {
    if (s[i] == check[i]) continue;
    ans ++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A, B;
    cin >> A >> B;
    
    if (A == B) cout << "a == b" << endl;
    if (A < B) cout << "a < b" << endl;
    if (A > B) cout << "a > b" << endl;
    
    return 0;
}



Measured memory_bytes: 3096
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	resolve()
}

func resolve() {
	n, m := scanInt(sc), scanInt(sc)
	ok := 0
	acs := make([]bool, n)
	penas := make([]int, n)
	for _ = range loop0(m) {
		p := scanInt(sc) - 1
		ans := scanString(sc)
		if acs[p] {
			continue
		}
		if ans == "AC" {
			ok++
			acs[p] = true
		} else {
			penas[p]++
		}
	}
	pena := 0
	for i := range loop0(n) {
		if acs[i] {
			pena += penas[i]
		}
	}
	fmt.Printf("%d %d\n", ok, pena)
}

func loop0(n int) chan int {
	return loop(0, n-1, 1)
}

func loop1(n int) chan int {
	return loop(1, n, 1)
}

func loop(s, e, d int) chan int {
	ch := make(chan int)
	go func() {
		for i := s; i <= e; i += d {
			ch <- i
		}
		close(ch)
	}()
	return ch
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 3340
#include <iostream>

using namespace std;

#define N 500

int adj[N][N], use[N];

int main(void){
    int n, m;
    while(1){
        cin >> n >> m;
        if(n == 0 && m == 0) break;

        for(int i = 0; i < n; i++) use[i] = 0;
        use[0] = 1;

        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                adj[i][j] = 0;
            }
        }
        for(int i = 0; i < m; i++){
            int a, b; cin >> a >> b;
            a--, b--;

            adj[a][b] = adj[b][a] = 1;
        }

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

                // 0 -- i
                if(adj[0][i] == 1){
                    use[i] = 1;

                    // 0 -- i -- j
                    if(adj[i][j] == 1){
                        use[j] = 1;
                    }
                }
            }
        }

        int res = 0;
        for(int i = 1; i < n; i++){
            if(use[i] == 1) res++;
        }

        cout << res << endl;
    }

    return 0;
}

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

int main(){
    int a, b, c, k;
    cin >> a >> b>>c>>k;
    if( k <= a){
        cout << k;
    }else if(k<= a+b){
        cout << a;
    }else{
        cout << a - (k - (a + b));
    }
}


Measured memory_bytes: 3168
N = int(input())
S = str(input())

count = S.count('R')*S.count('G')*S.count('B')

for i in range (0, N-2):
  colour1 = S[i]
  for j in range (i+1, N-1):
    colour2 = S[j]
    if colour1 == colour2:
      continue
    else:
      if 2*j-i > N-1:
        continue
      elif colour1 != S[2*j-i] and colour2 != S[2*j-i]:
          count-=1
      else:
          continue

print(count)

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

void solve(vector<int> &h,vector<int> &v,int k=2)
{ int n=h.size();
    for(int curr=0;curr<n;curr++)
    {
  	    for(int j=curr+1;j<n and j<=curr+k;j++)
  	    {
  	    int d1=abs(h[curr]-h[j]);
        v[j]=min(v[j],v[curr]+d1);
  	    }
    }
}
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>h(n),v(n);

  for(int i=0;i<n;i++)
	cin>>h[i];
    v[0]=0;
	for(int i=1;i<n;i++)
	v[i]=INT_MAX;
  solve(h,v,k);
  cout<<v[n-1]<<endl;
  
}

Measured memory_bytes: 1024