akhauriyash/Code-Regression huggingface dataset:
'use strict'

const main = arg => {
    const input = arg.trim().split("\n");
    var N = input[0];
    var nums = input[1].split(" ").slice(0, N).map(num => Number(num));
    var min = nums.sort((a, b) => a - b)[0];
    var max = nums.sort((a, b) => b - a)[0];
    var sum = nums.reduce((a, b) => a + b);

    console.log(`${min} ${max} ${sum}`);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 18348
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int K = nextInt();
        int A = nextInt();
        int B = nextInt();

        for(int i=1; ; i++){
            if(K*i>= A && K*i<=B){
                println("OK");
                return;
            }
            if(K*i > B){
                break;
            }
        }

        println("NG");
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 35756
n = int(input())
a = list(map(int,input().split()))

ans = []

for i in range(n):
    tmp = a[i]
    cnt = 0
    for _ in range(1000):
        if tmp % 2 != 0:
            ans.append(0)
        tmp = tmp // 2
        cnt +=1
        if tmp % 2 != 0:
            ans.append(cnt)
            break
print(min(ans))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
vector<long long> v;
long long k;
void dfs(int d)
{
	if(v.size()==d){
		k--;
		if(k==0){
			for(int i=0;i<v.size();i++)
				cout<<v[i];
			cout<<endl;
			exit(0);
		}
		return;
	}
	if(v.empty())
		for(int i=1;i<=9;i++){
			v.push_back(i);
			dfs(d);
			v.pop_back();
		}
	else
		for(int i=v.back()-1;i<=v.back()+1;i++)
			if(i<=9&&i>=0){
				v.push_back(i);
				dfs(d);
				v.pop_back();
			}
}
int main()
{
	cin>>k;
	for(int d=1;;d++)
		dfs(d);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>


int main() {

	int a, b, c, x;
	int count = 0;

	std::cin >> a >> b >> c >> x;


	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (((i * 500) + (j * 100) + (k * 50)) == x) {
					count++;
				}
			}
		}
	}

	std::cout << count << std::endl;

	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         int N=gi();
         int K=gi();
         long[] sum=new long[N+2];

         for(long i=1; i<N+2;i++) {
        	 sum[(int)i]=i*(i-1)/2;
         }

         long ans=0;
         for (int i=K; i<N+2;i++) {
             long a=sum[i];
             long b=sum[N+1]-sum[N-i+1];
             ans=(ans+b-a+1)%1000000007;
         }

         System.out.println(ans);
     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 37144
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
#define d_arr(arr, h, w) rep(i,(h) ){ cout << "["; rep(j,(w) ) { cout << (arr)[i][j] << ", "; } cout << "]" << endl;}
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x);

typedef pair<int ,int> P;

//n までの登り方の総数を返す
int solve(int n){
    if ( n <= 0) { return 1; }
    else if( n == 1 ){ return 1; }
    else if( n == 2 ){ return 2; }
    //else if( n == 3 ){ return 4; }
    return solve(n-1) + solve(n-2) + solve(n-3);
}

int main()
{
    while (true){
        int n;
        cin >> n;
        if ( n == 0) {break;}
        int sum = solve(n);
        int ret;
        if( sum % 3650  == 0){ ret = sum /3650; }
        else { ret = sum /3650 + 1; }
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
package main

import (
	"fmt"
	"strings"
)

func main() {
	num := "0123456789"
	var a, b int
	var s string
	fmt.Scan(&a, &b, &s)
	if len(s) != a+b+1 {
		fmt.Println("No")
		return
	}
	for i := range s {
		switch {
		case i < a:
			if strings.Index(num, string(s[i])) == -1 {
				fmt.Println("No")
				return
			}
		case i == a:
			if string(s[i]) != "-" {
				fmt.Println("No")
				return
			}
		case a+1 <= i:
			if strings.Index(num, string(s[i])) == -1 {
				fmt.Println("No")
				return
			}
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 640
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func debug(a ...interface{}) {
	if os.Getenv("ONLINE_JUDGE") == "false" {
		fmt.Fprintln(os.Stderr, a...)
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	if n == 1 {
		fmt.Fprintln(wr, 0)
		return
	}
	if n == 2 {
		fmt.Fprintln(wr, 2)
		return
	}

	fmt.Fprintln(wr, (mpow(10, n)+mpow(8, n)-mpow(9, n)*2%mod+mod)%mod)

}

const mod = 1000000007

func mpow(a, n int) int {
	res := 1
	for n > 0 {
		if n&1 == 1 {
			res = res * a % mod
		}
		a = a * a % mod
		n >>= 1
	}
	return res
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string s;
    cin >> s;
    string fs = "", en = "";

    fs += s;
    en += s;

    int len = (int)s.size();
    int fl, el;

    int l = 0, r = 0, ans = 0;
    fl = (int)fs.size();
    el = (int)en.size();
    reverse(all(en));
    bool flag = true;

    fs += '0';
    en += '0';

    while (1) {
        if (fl == l && el == r) break;
        if (fs[l] == en[r]) {
            l++;
            r++;
        }
        else {
            if (fs[l] == 'x') {
                ans++;
                l++;
            }
            else if (en[r] == 'x') {
                ans++;
                r++;
            }
            else {
                flag = false;
                break;
            }
        }
    }

    if (flag) cout << ans / 2 << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel

signed main()
{
	fasterthanlight;
	int h1, m1, h2, m2;
	cin >> h1 >> m1 >> h2 >> m2;
	int k;
	cin >> k;
	int t = (60 * (h2 - h1)) + (m2 - m1);
	int ans = t - k;
	cout << ans;
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


Measured memory_bytes: 3648
import sys
import itertools


def resolve(in_, out):
    n, k = map(int, next(in_).split())
    a = tuple(map(int, next(in_).split()))

    b, c = itertools.tee(a)
    c = itertools.islice(c, k, None)
    for v, w in zip(b, c):
        s = 'Yes' if v < w else 'No'
        print(s, file=out)
        


def main():
    resolve(sys.stdin.buffer, sys.stdout)


if __name__ == '__main__':
    main()


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

int main() {
  int N,K;
  cin >> N >> K;
  int leng=0;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    if(x*x <= (K-x)*(K-x)){
      leng += 2*x;
    } 
    else{
      if(K-x >= 0){leng+= 2*(K-x);}
      else{leng+= 2*(x-K);}
    }
  }
  cout << leng <<endl;
}

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

using namespace std;

typedef long long ll;

int main () {
	ll n, x;
	ll i, j, k;
	ll ret = 0;
	
	cin >> n;
	
    for ( i = 0; i < 50000; i++ ) {
        if ( i <= n) {
            if ( i * 108 / 100 == n ) {
                cout << i << endl;
                return 0;
            }
        }
        else {
            cout << ":(" << endl;
            return 0;
        }
    }
	return 0;
}


Measured memory_bytes: 3596
from operator import itemgetter

N = int(input())
X = []
L = []
for _ in range(N):
    row = list(map(int,input().split()))
    X.append(row[0])
    L.append(row[1])

# Xでソート
c = list(zip(X, L))
c.sort(key=itemgetter(0))
X, L = zip(*c)

# stack
stack = []
stack.append(0)
# 2~N番を，それ以前と重複しなければpush
for i in range(1,N):
    X1 = X[stack[-1]]
    L1 = L[stack[-1]]
    X2 = X[i]
    L2 = L[i]
    # 重複しなければ
    # print(X1+L1,X2-L2)
    if X1+L1 <= X2-L2:
        stack.append(i)
    else:
        # 重複していて，新しく追加する腕のほうが→にあれば
        if X1+L1 <= X2+L2:
            # なにもしない
            continue
        else:
            # 前のロボットを消して，追加する
            stack.pop()
            stack.append(i)


print(len(stack))

Measured memory_bytes: 26768
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s, t;
  cin >> n >> s >> t;
  rep(i, n){
    cout << s[i] << t[i];
  }
  cout << endl;
}


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


/**
 * AIZU ONLINE JUDGE
 * 0407
 *  2020/5/6
 */
public class Main {



    boolean main() throws IOException {

        Scanner sc = new Scanner(systemin);

        int N = sc.nextInt();
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for(int i = 0; i < N; i++) {
            int x = sc.nextInt();
            max = Math.max(max,  x);
            min = Math.min(min,  x);
        }
        result.printf("%d\n", (max - min + 1) / 2);

        sc.close();
        return false;
    }



    PrintStream log;
    PrintStream result = System.out;
    BufferedReader systemin;

    static Main instance = new Main();

    Main() {
        systemin = new BufferedReader(new InputStreamReader(System.in));
        log = new PrintStream(new OutputStream() { public void write(int b) {} } );
    }

    public static void main(String[] args) throws IOException {

        instance.main();
        instance.systemin.close();
    }


}




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

vector<long long> R;

int digit(long long A) {
	
	int c = 0;

	while (A != 0) {
		c++;
		A /= 10;
	}

	return c;
}

long long divisor(long long N) {
	
	long long F;
	long long mincost = 1 << 24;

	for (long long a = 1; a*a <= N; a++){
		if (N%a != 0) continue;
	
		long long b = N / a;

		F = max(digit(a), digit(b));
	
		if (F < mincost)
			mincost = F;
	}

	return mincost;

}

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

	long long res = divisor(N);

	cout << res;
}

Measured memory_bytes: 3496
import collections
N=int(input())
j=0
L=list()
R=list()
for i in range(N):
  S="".join(sorted(list(input())))
  L.append(S)
c = collections.Counter(L)
counts=c.values()
counts=list(counts)
A=[i*(i-1)//2 for i in counts]
print(sum(A))

Measured memory_bytes: 23896
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<cstring>
#include<iterator>
#include <map>
using namespace std;

bool cmp(pair<long long, long long> a, pair<long long, long long> b){
    return a.second < b.second;
}

int main()
{
    long long t, i, j, k, n, ch, ch1, count, prev_left, prev_right, m;
    cin >> n;
    string s;
    long long ac_c = 0, ac_wa = 0, ac_tle = 0, ac_re = 0;
    for (i = 0; i < n; i++){
        cin >> s;
        if (s == "AC")
            ac_c++;
        if (s == "WA")
            ac_wa++;
        if (s == "TLE")
            ac_tle++;
        if (s == "RE")
            ac_re++;
    }
    cout << "AC x " << ac_c << endl;
    cout << "WA x " << ac_wa << endl;
    cout << "TLE x " << ac_tle << endl;
    cout << "RE x " << ac_re << endl;
    return 0;
}

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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define print_var(x) cerr << #x << " = " << x << endl
#define print_array(arr, len) {cerr << #arr << " = "; for (int i = 0; i < len; i++) cerr << arr[i] << " "; cerr << endl;}
#define print_iterable(it) {cerr << #it << " = "; for (const auto &e : it) cerr << e << " "; cerr << endl;}
#else
#define eprintf(...) (void)0
#define print_var(x) (void)0
#define print_array(arr, len) (void)0
#define print_iterable(it) (void)0
#endif

typedef long long ll;



void solve()
{
    int n;
    ll A, B, C, D;
    scanf("%d%lld%lld%lld%lld", &n, &A, &B, &C, &D);
    n--;

    for (int i = 0; i <= n; i++)
    {
        ll x = i;
        ll y = -(n - i);
        ll L = A + x * C + y * D;
        ll R = A + y * C + x * D;
        if (L <= B && B <= R)
        {
            puts("YES");
            return;
        }
    }
    puts("NO");
}

int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    solve();

    eprintf("\n\ntime = %.3lf\n", (double)clock() / CLOCKS_PER_SEC);
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
using namespace std;
const long long inf = 1e15;
const int mod = 1e9+7;

int main(void){
    int h, w;
    char c[103][103];
    map<char, int> m;
    map<char, int>::iterator ite;
    cin >> h >> w;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> c[i][j];
            ite = m.find(c[i][j]);
            if(ite == m.end()){
                m.insert(make_pair(c[i][j], 1));
            }else{
                m[c[i][j]]++;
            }
        }
    }


    int ne_4 = (w/2)*(h/2), ne_2=0;
    if(h%2 == 1){
        ne_2 += w/2;
    }
    if(w%2 == 1){
        ne_2 += h/2;
    }
    bool flag = false;
    for(int i=0; i<ne_4; i++){
        flag = false;
        for(ite = m.begin(); ite != m.end(); ite++){
            if(ite->second >= 4){
                m[ite->first] -= 4;
                flag = true;
                break;
            }
        }
        if(!(flag)){
            cout << "No" << endl;
            return 0;
        }
    }

    for(int i=0; i<ne_2; i++){
        flag = false;
        for(ite = m.begin(); ite != m.end(); ite++){
            if(ite->second >= 2){
                m[ite->first] -= 2;
                flag = true;
                break;
            }
        }
        if(!(flag)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <cstdlib>
#define INF 998244353

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pi;

const ll MOD = 1e9+7;

static long gcd(long a, long b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
/*
long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}*/

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

map< ll, ll > prime_factor(ll n) {//素因数分解
    map< ll, ll > ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

ll calcNumOfCombination(ll n, ll r){
    ll num = 1;
    for(ll i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}

int bubblesort(vector<int> array,int size){//バブルソート　転倒数
    int kaisu = 0;
    for(int i = 0; i < size; i++){
        for(int j = i + 1; j < size; j++){
            if(array[i] > array[j]){
                int number = array[i];
                array[i] = array[j];
                array[j] = number;
                kaisu++;
            }
        }
    }
    return kaisu;
}

ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = (sum * i)%MOD;
    }
    return sum;
}

// nPnの順列に対して処理を実行する
void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}



int main() {
    int N;
    cin >> N;
    ll A[N];
    ll sum = 0;
    ll left = 0;
    ll half = 0;
    ll min = LONG_LONG_MAX;
    for(int i=0;i<N;i++){
        cin >> A[i];
        sum += A[i];
    }

    half = sum / 2;



    int leftindex = 0;
    for(int i=0;i<N;i++){
        sum -= A[i];
        left += A[i];
        if(abs(sum - half) + abs(left - half)<min){
           min = abs(sum - half) + abs(left - half);
        }
    }
    cout << min << endl;


}






Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(void){
   int a,b,c,d;
   cin>>a>>b>>c;
   d=b;
   b=a;
   a=c;
   c=d;
   cout<<a<<" "<<b<<" "<<c<<endl;
   
    
}


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

int x[100010],w[100010];
pair<int,int> p[100010];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,L,T;
	cin>>n>>L>>T;
	for(int i=1;i<=n;i++)
		cin>>x[i]>>w[i];
	for(int i=1;i<=n;i++){
		if(w[i]==1)
			p[i]={x[i]+T,i};
		else
			p[i]={x[i]-T,i};
		p[i].first%=L;
		if(p[i].first<0)	p[i].first+=L;
	}
	sort(p+1,p+n+1,[&](pair<int,int> A,pair<int,int> B){
		if(A.first==B.first)	return w[A.second]==2;
		else	return A.first<B.first;
	});
	long long int cnt = 0;
	int idx;
	if(w[1]==1){
		for(int i=2;i<=n;i++)
			if(w[i]==2){
				int cur = x[i]-x[1];
				if(cur<0)	cur+=L;
				if(cur>T*2)	continue;
				cur = T*2-cur,cnt++;
				cnt+=cur/L;
			}
		idx = (cnt)%n+1;
	}
	else{
		for(int i=2;i<=n;i++)
			if(w[i]==1){
				int cur = x[1]-x[i];
				if(cur<0)	cur+=L;
				if(cur>T*2)	continue;
				cur = T*2-cur,cnt++;
				cnt+=cur/L;
			}
		idx = ((-cnt)%n+n)%n+1;
	}
	int z;
	for(int i=1;i<=n;i++)
		if(p[i].second==1)
			z=i;
	z-=(idx-1);
	if(z<=0)	z+=n;
	for(int i=1;i<=n;i++){
		cout<<p[z].first<<'\n';
		z++;
		if(z>n)	z=1;
	}
}


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

vector<int> eratosthenes() {
  int MAX = 55555;
  vector<int> is_prime(MAX, 1);
  is_prime[0] = 0;
  is_prime[1] = 0;
  for (int i = 2; i < MAX; i++) {
    if (!is_prime[i]) continue;
    for (int j = i * 2; j < MAX; j += i)
      is_prime[j] = 0;
  }
  return is_prime;
}

int main() {
  int n;
  cin >> n;
  vector<int> e = eratosthenes();

  vector<int> res(n);

  int index = 0;
  int sum   = 0;
  vector<int> arr(n);
  int k   = 5;
  int pre = -1;
  for (int i = 0; i < e.size(); i++) {
    if (e[i] == 0 || i < k) { continue; }
    int tmp = i % k;
    if (tmp == 1) {
      arr[index] = i;
      sum += i;
      index++;
      if (index == n) {
        // aa
        break;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << arr[i];
    if (i != n - 1) { cout << " "; }
  }
  cout << endl;
}

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

void testCase() {    
    
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    double R;
    cin >> R;
    cout << 2*M_PI*R << "\n";
    
}
















Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
//https://www.creativ.xyz/dump-cpp-652/
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
 
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

#ifdef DEBUG_
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif

signed main(void) { cin.tie(0); ios::sync_with_stdio(false);
    int n; cin>>n; 
    vector <int> a(n);
    rep(i,n) cin>>a[i];
    int tmp = INF; 
    int now = INF;
    rrep(i,n){
        if(tmp >=  a[i]) {now = i; tmp = a[i];}
    }
    cout<<now+1<<endl;
}


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

int main()
{
    int a[3], count{};
    scanf("%d%d%d", a, a + 1, a + 2);
    std::sort(a, a + 3);
    switch((a[0] % 2) + a[1] % 2 + a[2] % 2)
    {
        case 1:
        for (int i = 0; i < 3; i++)
        {
            if (a[i] % 2)
            {
                a[(i + 1) % 3]++;
                a[(i + 2) % 3]++;
                count++;
                break;
            }
        }
        break;
        case 2:
        for (int i = 0; i < 3; i++)
        {
            if (a[i] % 2 == 0)
            {
                a[(i + 1) % 3]++;
                a[(i + 2) % 3]++;
                count++;
                break;
            }
        }
    }
    count += (a[2] * 2 - a[1] - a[0]) / 2;
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        sc.close();

        if(Character.isUpperCase(N.charAt(0))){
            System.out.println("A");
        }else{
            System.out.println("a");
        }
    }
}


Measured memory_bytes: 35612
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    vs32 cnt(9, 0);
    int n;
    cin >> n;
    int a;
    rep (i, n)
    {
        cin >> a;
        if (a >= 3200)
        {
            ++cnt[8];
        }
        else
        {
            ++cnt[a / 400];
        }
    }

    int sum = 0;
    rep (i, 8)
    {
        if (cnt[i] > 0)
        {
            ++sum;
        }
    }

    int ansm = sum;
    int ansM = sum;
    ansM = ansM + cnt[8];
    ansm = MAX(1, ansm);

    cout << ansm << " " << ansM << "\n";
    return 0;
}


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

string S; int N, cnt;

int main() {
	cin >> N >> S;
	for (int i = 0; i < 1000; i++) {
		int c[3] = {i / 100, (i / 10) % 10, i % 10};
		int f = 0;
		for (int j = 0; j < N; j++) {
			if (S[j] == ('0' + c[f])) f++;
			if (f == 3) break;
		}
		if (f == 3) cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3640
import math
a,b,x = map(int,input().split())

if a*a*b >= 2*x:
  y = 2*x/(a*b)
  atan1 = math.degrees(math.atan(b/y))
  print(atan1)
else:
  y  = 2*b-2*x/(a*a)
  atan1 = math.degrees(math.atan(y/a))
  print(atan1)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

#define ll long long
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=1e5+500;
const ll inf=1e9+800;
const ll mod=1e9+7;

vector<ll> zoj;
vector<ll> fard;
vector<ll> a;
void pri(vector<ll> anss){
	for(auto e:a){
		cout<<e<<' ';
	}	
	vector<ll> ans;
	for(auto e:anss)if(e)ans.pb(e);
	cout<<endl<<ans.size()<<endl;
	for(auto e:ans){
		cout<<e<<' ';
	}
	exit(0);
}
void add(vector<ll> &ans,ll a){
	ll b=a/2;
	if(b%2==0){
		ans.pb(a);
	}else{
		
	}
}


int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	ll n,m;
	cin>>n>>m;
	for(ll i=0;i<m;i++){
		ll a;
		cin>>a;
		if(a%2==1){
			fard.pb(a);
		}else{
			zoj.pb(a);
		}
	}
	vector<ll> ans;
	if(fard.size()==0){
		a=zoj;
	}
	if(fard.size()==1){
		a.pb(fard[0]);
		for(auto e:zoj){
			a.pb(e);
		}
	}
	if(fard.size()<=1){
		ans.pb(a[0]-1);
		for(ll i=1;i<a.size();i++){
			ans.pb(a[i]);
		}
		ans.pb(1);
		pri(ans);
	}
	if(fard.size()==2){
		a.pb(fard[0]);
		for(auto e:zoj){
			a.pb(e);
		}
		a.pb(fard[1]);

		ans.pb(a[0]-1);
		for(ll i=1;i+1<a.size();i++){
			ans.pb(a[i]);
		}
		ans.pb(2);
		ans.pb(a.back()-1);
		pri(ans);
	}
	cout<<"Impossible";
}




















Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    
    bool f = true;
    int st[26], ts[26];
    fill(st, st+26, -1);
    fill(ts, ts+26, -1);
    for (int i = 0; i < s.length(); i++) {
        if (st[s[i]-'a'] == -1) {
            st[s[i]-'a'] = t[i] - 'a';
        } else if (st[s[i]-'a'] != t[i] - 'a') {
            f = false;
        }

        if (ts[t[i]-'a'] == -1) {
            ts[t[i]-'a'] = s[i] - 'a';
        } else if (ts[t[i]-'a'] != s[i] - 'a') {
            f = false;
        }
    }
    
    cout << (f ? "Yes" : "No") << endl;
    
    return 0;
}


Measured memory_bytes: 776
#include <algorithm>
#include <iostream>
#include <cstdio>

constexpr static int ___maxN = 100010;

int gcd(int x, int y)
{
    return y ? gcd(y, x % y) : x;
}

int n, ans;
int a[___maxN], l[___maxN], r[___maxN];

int main()
{
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cin >> n; 
    for (int i = 1; i <= n; ++i)
        std::cin >> a[i];
    
    for (int i = 1; i <= n; ++i)
        l[i] = ::gcd(l[i - 1], a[i]);
    for (int i = n; i; --i)
        r[i] = ::gcd(r[i + 1], a[i]);
    for (int i = 1; i <= n; ++i)
        ans = std::max(ans, ::gcd(l[i - 1], r[i + 1]));
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <math.h>

int main(void){
	int A,B,C,K;
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&K);
	
	int x;
	int ans;
	x = pow(2,K);
	if(A>=B && A>=C){//max a
		ans=A*x+B+C;
	}
	if(B>=A && B>=C){
		ans=A+C+B*x;
	}
	if(C>=A && C>=B){
		ans = A+B+C*x;
	}
	printf("%d",ans);
	
	
	
	return 0;}

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

int main()
{
	int n;
	cin >> n;
	vector<int> p(n),q(n);
	vector<int> a, b;
	for(int i=0;i<n;i++){
		cin >> p[i];
		q[p[i]-1] = i;
		a.push_back(i+1);
		b.push_back(n-i);
	}
	int sum = 0;
	for(int i=0;i<n;i++){
		sum+=q[i];
		a[i]+= sum;
	}
	sum=0;
	for(int i=n-1; i>=0;i--){
		sum+=q[i];
		b[i]+=sum;
	}
	for(int i=0;i<n;i++){
		cout << a[i] << " ";
	}cout << endl;
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}cout << endl;
}

Measured memory_bytes: 1024
L = 5
table = Array.new(10) {|i| [i / 5, i % 5]}

r = $<.readlines.map {|l| l.chomp.rjust(L, "0").chars.map(&:to_i)}.map do |given|
  soroban = given.map do |place|
    high, low = table[place]
    ((high.zero? ? "* =" : " *=") + "*" * low + " " + "*" * (4 - low)).chars
  end
  soroban.transpose.map {|l| l.join + "\n"}.join
end.join("\n")

print r


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

int main() {
	string s; cin >> s;
	int len = s.length();
	bool ok = false;
	for (int i = 0; i < len; i++) {
		if (i % 2 != 0) {
			if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D') {
				ok = true;
			}
			else {
				ok = false;
				break;
			}
		}
		else {
			if ( s[i] == 'U' || s[i] == 'R' || s[i] == 'D') {
				ok = true;
			}
			else {
				ok = false;
				break;
			}
		}
	}
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


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

#define v short
const char nl = '\n';
#define loop(i, n) for (v i = 0; i < n; i++)

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

    v l, r, d, c = 0;
    cin >> l >> r >> d;

    for (v i = l; i <= r; i++) {
        if (i % d == 0) {
            c++;
        } 
    }
    
    cout << c << nl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

struct Culc {

    vector<long long> factorial;
    long long p;
    vector<vector <LL> > comb;
    vector<LL> inv;

    //階乗
    Culc(long long N, long long p_) {
        long long ans = 1;
        p=p_;
        factorial.push_back(ans);
        for (long long i = 1; i <= N; i++) {
            ans = ans * i % p;
            factorial.push_back(ans);
        }
        REP(i,N+1)comb.push_back(vector<LL> (N+1,-1));
        REP(i,N+1)inv.push_back(-1);
    }

    long long extgcd(long long a, long long b, long long &x, long long &y) {
        long long g = a;
        if (b) {
            g = extgcd(b, a % b, y, x);
            y -= x * (a / b);
        } else {
            x = 1;
            y = 0;
        }
        return g;
    }

    long long gcd(long long a, long long b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    long long lcm(long long a, long long b) {
        return a * b / gcd(a, b);
    }

    long long inverse(long long a, long long p) {
        long long x, y;
        extgcd(a, p, x, y);
        return ((x % p) + p) % p;
    }

    LL factinv(LL k){
        if(inv[k]>0)return inv[k];
        return inv[k]=inverse(factorial[k],p);
    }

//nCk mod p
//
    long long combination(long long n, long long k) {
        if(comb[n][k]>0)return comb[n][k];
        return comb[n][k] = factorial[n] * (inverse(factorial[k] * factorial[n - k] % p, p)) % p;
    }

};

int main(){

    LL N,A,B,C,D;cin>>N>>A>>B>>C>>D;
    LL inf = 1e9+7;

    //dp[i][j]:i人をj人以下のグループで分けるときの組み合わせ
    //dp[i][j] = dp[i][j-1] + iCj * dp[i-j][j-1] + iCj*(i-j)Cj/2 * dp[i-2*j][j-1] + ...
    //=dp[i][j-1] + sigma(for k=C; k<=D&&kj<=i;k++) dp[i-kj][j-1]* (iCj*(i-j)Cj*...*(i-(k-1)j)Cj)/k!
    //k=0 or C<=k<=D
    LL dp[N+1][B+1];
    fill(dp[0],dp[N+1],0);
    REP(i,B+1)dp[0][i]=1;
    Culc culc(N+1,inf);

    REP(i,N+1){
        for(LL j=A;j<=B;j++){
            LL sigma =0;
            LL comb=1;
            for(LL k=1;k<=D&&k*j<=i;k++){
                comb *= culc.combination(i-j*(k-1),j);
                comb %=inf;
                if(k<C)continue;
                sigma += ((dp[i-k*j][j-1]*comb)%inf)*culc.factinv(k)%inf;
                sigma %=inf;
            }
            dp[i][j]=(dp[i][j-1]+sigma)%inf;
        }
    }

    cout<<dp[N][B]<<endl;


    return 0;
}

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

int main() {
	// your code goes here
	ll n;
    cin>>n;
    int c=0;
    int f=0;
    while(n--)
    {
        ll a,b;
        cin>>a>>b;
        if(a==b)
           c++;
        else
           c=0;
        if(c==3)
        {
            f=1;
            break;
        }
    }
    if(f==1)
       cout<<"Yes"<<endl;
    else
       cout<<"No"<<endl;
	return 0;
}

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

using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	
	int sum = 0;

	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			int left, right, mid;
			left = j;
			right = n - 1;
			mid = (left + right) / 2;
			while (right - left > 1) {
				if (a[mid] >= a[i] + a[j]) {
					right = mid;
					mid = (mid + left) / 2;
				}
				else {
					left = mid;
					mid = (mid + right)/2;
				}
			}
			sum = sum + left - j;
			if (a[n - 1] < a[i] + a[j]) {
				sum++;
			}
		}

	}
	cout <<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (xe).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;
typedef pair<long long, long long> pll;
// scanf("%d %d %d %d", &w, &b, &d, &s); %lld
// printf("%d\n", points);
// const double PI = acos(-1);

int main() 
{
	fastIO;
	int n;
	cin >> n;
	int per[n];
	ll ans = 0;
	
	for(int i = 0; i<n; i++)
		cin >> per[i];
		
	for(int i = 1; i<n; i++){
		if(per[i] < per[i-1]){
			ans += per[i-1]-per[i];
			per[i] += per[i-1]-per[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4380
// You either die a hero, or you live long enough to see yourself become the villain.

/**
 *   author:  Blind_is_love
 *   created: 12.10.2019, 15:31
**/

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

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

#define endl "\n"
#define vll vector<int>
#define max_heap priority_queue<int>
#define min_heap priority_queue<int , vector<int>, greater<int> >
#define pb push_back
#define all(container) container.begin(), container.end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define printArr(name,from,to) for(int x = from; x < to; x++) cout << name[x] << " ";
#define fi first
#define se second
#define mp make_pair
#define prime1 304933
#define prime2 15486277 
#define mod2 179424691
#define int ll

typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

const ll MOD = 1000000007;
const ll MAX = 1e5+10;
const double PI = 3.1415926;
const ll INF = 1e18;
const double EPS = 1e-5;

int n;
int days[MAX][3];
int dp[MAX][3];
bool seen[MAX][3];

int solve(int i, int prev){

	if (i == n) return 0;
	if (seen[i][prev]) return dp[i][prev];
	int ans = 0;
	
	for(int j = 0 ; j < 3; ++j){
		if (j == prev) continue;
		int f = solve(i+1, j);
		ans = max(ans, f + days[i][j]);
	}

	seen[i][prev] = true;
	return dp[i][prev] = ans;
}

signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	clock_t t1, t2;
	t1 = clock();
	cin >> n;
	
	for(int i = 0 ; i < n; ++i){
		cin >> days[i][0] >> days[i][1] >> days[i][2];
	}
	cout << solve(0,-1) << endl;
	t2 = clock(); cerr << "time taken: " << (t2-t1)/(long double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
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 int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    queue<int> A[n];
    rep(i, n) {
        rep(_, n - 1) {
            int a;
            cin >> a;
            A[i].push(a-1);
        }
    }
    int ans = 0;
    while(1) {
        bool flag = 1, end = 1;
        vector<int> op(n, -1);
        rep(i, n) {
            if (A[i].empty()) {
                continue;
            } else {
                end = 0;
            }
            op[i] = A[i].front();
            if (op[A[i].front()] == i) {
                A[op[i]].pop();
                A[i].pop();
                flag = 0;
            }
        }
        if (end) break;
        if (flag) {
            cout << -1 << endl;
            return;
        }
        ans++;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 8056
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=1;i<=n;i++)
using namespace std;
using ll=long long;
using P = pair<int,int>;
int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = max(a*c,max(a*d,max(b*c,b*d)));
    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
//		入力表示
		String str =sc.next();

//		英大文字ならA、英小文字ならa
		if(str == str.toUpperCase()) {
			System.out.println("A");
		}else {
		System.out.println("a");
		}
		
	}
}

Measured memory_bytes: 26960
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    s = input()
    print('Yes' if s[2]==s[3] and s[4]==s[5] else 'No')


if __name__ == '__main__':
    solve()


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

int main() {
    long long N, A, B; cin >> N >> A >> B;
    if (N%(A+B) <= A) {
        cout << N/(A+B) * A + N%(A+B) << endl;
    } else {
        cout << N/(A+B) * A + A << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
 
int N, M;
int color[705];
int white[705];
int black[705];
int E[705][705];
vector<int> G[705];
bool flg = false; // 二部グラフ判定失敗フラグ
 
void dfs(int s, int c, int p) {
    if(color[s] != 0) return;
    color[s] = c;
    if(c == 1) white[p]++;
    else black[p]++; 
    for(auto x:G[s]) {
        if(color[x] != 0) {
            if(color[x] != -c) {
                flg = true;
                return;
            }
            continue;
        }
        dfs(x, -c, p);
    }
}
 
void solve() {
    scanf("%d%d", &N, &M);
    memset(E,0,sizeof(E));
    REP(i,M) {
        int a, b;
        scanf("%d%d", &a, &b);
        a--, b--;
        E[a][b]++;
        E[b][a]++;
    }
    // REP(i,N) { REP(j,N) cout << E[i][j] << " "; cout << endl;}
    REP(i,N) REP(j,N) {
        if(i==j) continue;
        if(E[i][j]==0) {
            G[i].push_back(j);
        }
    }
    memset(color,0,sizeof(color));
    memset(white,0,sizeof(white));
    memset(black,0,sizeof(black));
    REP(i,N) dfs(i, 1, i);
    if(flg) {
        printf("%d\n", -1);
    }
    else {
        vector<bitset<1410>> dp(N + 1);
        dp[0].set(0);
        REP(i,N) {
            dp[i+1] |= (dp[i] << white[i]);
            dp[i+1] |= (dp[i] << black[i]);
        }
        // REP(i,N+1) cout << dp[N][i]; cout << endl;
        int ans = 1<<29;
        REP(i,N+1) {
            if(dp[N][i]) ans = min(ans, i*i-N*i+(N-1)*N/2);
        }
        printf("%d\n", ans);
    }
}
 
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 4992
from collections import Counter

def solve():
    N = int(input())
    a = list(map(int, input().split()))
    
    if len(set(a)) == 1 and a[0] == 0:
        return 'Yes'
    
    if N % 3 == 0:
        s = list(set(a))
        c = Counter(a)
        if len(s) == 2:
            i = max(c.items(), key=lambda x: x[1])
            j = min(c.items(), key=lambda x: x[1])
            if i[0] ^ j[0] == i[0] and i[1] == (2 * N // 3) and j[1] == (N // 3):
                return 'Yes'
        if len(s) == 3:
            if c[s[0]] == c[s[1]] and c[s[1]] == c[s[2]] and s[0] ^ s[1] == s[2]:
                return 'Yes'
        
    return 'No'

print(solve())

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    string s;
    cin >> s;

    int ans = 0;
    rep(i, 4)
    {
        if (s[i] == '+')
            ans++;
        else
            ans--;
    }
    cout << ans << '\n';
    return (0);
}


Measured memory_bytes: 3584
s = gets.to_i
a = s / 100; a = a > 12 ? -1 : (a + 11) / 12
b = s % 100; b = b > 12 ? -1 : (b + 11) / 12

puts [%w(NA YYMM NA),%w(MMYY AMBIGUOUS MMYY),%w(NA YYMM NA)][a][b]

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
bool canbe = false;
int inp[10];

void dfs(int b, int c, int depth){
    if (depth >= 10){
	canbe = true; return;
    }
    if (inp[depth] < b && inp[depth] < c) return;

    if (inp[depth] > b) dfs(inp[depth], c, depth+1);
    if (inp[depth] > c) dfs(b, inp[depth], depth+1);
}


int n;
int main(){
    cin >> n;
    for (int i = 0; i < n; i++){
	canbe = false;
	for (int j = 0; j < 10; j++) cin >> inp[j];
	
	dfs(0, 0, 0);

	if (canbe) cout << "YES" << endl;
	else cout << "NO" << endl;
    }
}

Measured memory_bytes: 0