akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N = int(input())
    F = [set() for _ in range(N)]
    for _ in range(N - 1):
        a, b = read_index()
        F[a].add(b)
        F[b].add(a)

    D = [0] * N
    S = deque()
    S.append((1, 0))
    S.append((-1, N - 1))
    D[0] = 1
    D[N - 1] = -1
    while S:
        c, p = S.popleft()
        for q in F[p]:
            if D[q] != 0:
                continue
            D[q] = c
            S.append((c, q))
    a = D.count(1)
    b = N - a
    print("Fennec" if a > b else "Snuke")
        

if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795


ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}
vector<ll>v[10001];

void dfs(ll x,vector<bool>& vis)
{
vis[x]=true;
for(int j=0;j<v[x].size();j++)
  {
    ll t=v[x][j];
    dfs(t,vis);
  }

}

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

ll k;cin>>k;

vl v(50);

v[0]=k/50;
ll x=k%50;

for(int i=1;i<50;i++)
{
  v[i]=v[i-1]+1;
}

for(int i=1;i<=x;i++)
{
  sort(v.begin(),v.end());
  v[0]+=50;
  for(int j=1;j<50;j++)v[j]--;
}
cout<<50<<"\n";
for(int i=0;i<50;i++)cout<<v[i]<<" ";

  cout<<endl;

}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<map>
#include<numeric>
//#include <bits/stdc++.h>
#include<cstring>
#include<iostream>
#include<functional>
using namespace std;
int main() {

	int r, g, b; //X, A, B;

	cin >> r >> g >> b;// X >> A >> B;

	int num = r * 100 + g * 10 + b;
	if (num % 4 == 0)
		cout << "YES\n";
	else
		cout << "NO\n";

	cin >> r;
	return 0;
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<ctime>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<bitset>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
#define pb push_back
#define IT iterator
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20,mod=998244353;
const ll inf=1e18;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

//math
ll mult(ll a,ll b,ll p) {
	a=(a%p+p)%p; b=(b%p+p)%p;
	ll c=(ld)a*b/p;
	return a*b-c*p;
}
ll gcd(ll a,ll b) {return !a?b:gcd(b%a,a);}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
ll power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		b /= 2; a=a*a%mod;
	}
	return c;
}
ll Power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=mult(c,a,mod);
		b /= 2; a=mult(a,a,mod);
	}
	return c;
}

int n,a[N];
ll s=1,ans,b[N];

int main() {
	qr(n);
	for(int i=0;i<=n;i++) {
		qr(a[i]);
		if(s<a[i]) return puts("-1"),0;
		b[i]=s-a[i];
		s=min((s-a[i])*2,inf);
		ans+=a[i];
	}
	s=0;
	for(int i=n;i>=0;i--) {
		ans+=min(s,b[i]);
		s+=a[i];
	}
	pr2(ans);
	return 0;
}




Measured memory_bytes: 4108
from itertools import permutations
n_node, n_edge, R = map(int,input().split())
r_ls = list(map(int,input().split()))
for i in range(R):
    r_ls[i] -= 1
ad_mat = [[float('inf')]*n_node for _ in range(n_node)]
for i in range(n_node):
    ad_mat[i][i] = 0
for i in range(n_edge):
    a,b,c = map(int,input().split())
    ad_mat[a-1][b-1] = c
    ad_mat[b-1][a-1] = c

# ワーシャルフロイド
for stop in range(n_node):
    for start in range(n_node):
        for end in range(n_node):
            ad_mat[start][end] = min(ad_mat[start][end],ad_mat[start][stop]+ad_mat[stop][end])

ans = float('inf')
for path in permutations(r_ls):
    cost = 0
    for i in range(R-1):
        cost += ad_mat[path[i]][path[i+1]]
    ans = min(ans,cost)
print(ans)


Measured memory_bytes: 70760
//
// Created by munaiyi on 2020/3/18.
//

#include <bits/stdc++.h>

using namespace std;
const int maxn = 105;
char shit[maxn];
int nine[10];

inline long long Get(int num, int ci) {
    if (ci < 0) return 0;
    if (ci > num) return 0;
    long long ans = 1, cnt = 1;
    while (ci) {
        ans *= num;
        cnt *= ci;
        ci--;
        num--;
    }
    return ans / cnt;
}

int main() {
    nine[0] = 1;
    for (int i = 1; i < 5; i++) {
        nine[i] = nine[i - 1] * 9;
    }
    int nz = 0;
    scanf("%s%d", shit, &nz);
    int l = strlen(shit);
    shit[l++] = '0';
    long long ans = 0;
    for (int i = 0; i < l; i++) {
        if (shit[i] == '0') {
            continue;
        }
        ans += Get(l - 2 - i, nz) * nine[nz];
        ans += (shit[i] - '1') * Get(l - 2 - i, nz - 1) * nine[nz - 1];
        nz--;
        if (nz == 0) {
            ans++;
            break;
        }
    }
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int, int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<ll> > vvl;
typedef vector<ll> vl;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define mod (1e9+7)
#define inf (1e9+7)
#define nil -1
class disjointset {
public:
	vi p, rank;
	disjointset(int size) {
		p.resize(size, 0);
		rank.resize(size, 0);
		for (int i = 0; i < size; i++)makeSet(i);
	}
	void makeSet(int x) {
		p[x] = x;
		rank[x] = 0;
	}
	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}
	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}
	void link(int x, int y) {
		if (rank[x] < rank[y]) {
			p[x] = y;
		}
		else {
			p[y] = x;
			if (rank[x] == rank[y]) {
				rank[x]++;
			}
		}
	}
	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);
		}
		return p[x];
	}
};
class edge {
public:
	int source, target, cost;
	bool operator<(const edge& another) const
	{
		return cost < another.cost;
	};
};
int kuraskal(int V,vector<edge>& edges) {
	int total = 0;
	sort(all(edges));
	disjointset D = disjointset(V);
	//int s, t;
	for (int i = 0; i < edges.size(); i++)
	{
		edge e = edges[i];
		if (!D.same(e.source,e.target)) {
			total += e.cost;
			D.unite(e.source,e.target);
		}
	}
	return total;
}
int main() {
	int  V,E;
	cin >> V >> E;
	vector<edge> edges(E);
	for (int i = 0; i < E; i++)
	{
		int s, t,w;
		cin >> s >> t>>w;
		edges[i].source = s;
		edges[i].target = t;
		edges[i].cost = w;
	}
	cout << kuraskal(V,edges) << endl;
}


Measured memory_bytes: 4172
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

const ll MOD=1e9+7;

int N;
int a[100100];

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

  cin>>N;
  for(int i=0;i<N;i++) cin>>a[i];
  sort(a,a+N);


  int m=0;

  int prv=0;
  for (int i=0;i<N;i++) {
    if ((a[i]-prv)&1) m ^= (N-i);
    prv = a[i];
  }

  cout << (m==0 ? "second\n" : "first\n");


  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	static final long MOD = 1000000007;
	static long modpow(long n, long y){
		if(y == 0){
			return 1;
		}else if(y == 1){
			return n % MOD;
		}else{
			if(y % 2 == 0){
				long r = modpow(n , y / 2);
				return (r * r) % MOD;
			}else{
				long r = modpow(n , y / 2);
				long r2 = (r * r) % MOD;
				return (r2 * n) % MOD;				
			}
		}
	}
	static long modinv(long n){
		return modpow(n , MOD - 2);
	}
	static long comb(int N , int R){
		long ret = 1;
		for(long v = N - R + 1 ; v <= N ; ++v){
			ret = (ret * v) % MOD;
		}
		for(long v = 2 ; v <= R ; ++v){
			ret = (ret * modinv(v)) % MOD;			
		}
		return ret;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		long ca = comb(n ,a);
		long cb = comb(n, b);
		long ret = modpow(2, n) - 1 - (ca + cb) + 3 * MOD;
		ret = ret % MOD;
		System.out.println(ret);
		// 16 - 1 - 4 - 4 = 8 
	}
}


Measured memory_bytes: 21840
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
 
int main(){
    ll x;
    cin>>x;
    while(x!=0){
        ll r=x%10;
        x=x/10;
        if(r==7){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(4100000)
from collections import defaultdict
import math
 
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N=int(input())
A=list(map(int,input().split()))
md={}
for a in A:
  if a in md:
    md[a]+=1
  else:
    md[a]=1
md2={}
md3={}
for key,value in md.items():
  if value>1:
    md2[key]=combinations_count(value,2)
  else:
    md2[key]=0
  value-=1
  if value>1:
    md3[key]=combinations_count(value,2)
  else:
    md3[key]=0
s_md2=sum(md2.values())
for a in A:
  print(s_md2-md2[a]+md3[a])
  

Measured memory_bytes: 120396
import java.util.*;
import java.io.*;
import java.text.*;
import java.math.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import java.lang.Math.*;

public class Main {

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

	public void run() throws Exception {
		FastIO file = new FastIO();
		int n = file.nextInt();
		long[][] a = new long[n][3];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 3; j++) {
				a[i][j] = file.nextLong();
			}
		}
		long[][] dp = new long[n][3];
		dp[0][0] = a[0][0];
		dp[0][1] = a[0][1];
		dp[0][2] = a[0][2];
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					if (j == k) continue;
					dp[i][j] = Math.max(dp[i][j], dp[i-1][k] + a[i][j]);
				}
			}
		}
		file.out.println(Math.max(Math.max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]));
		file.out.flush();
	}

	public static class FastIO {
		BufferedReader br;
		StringTokenizer st;
		PrintWriter out;

		public FastIO() {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		void print(Object o) {
			out.print(o);
		}

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

		void printf(String s, Object... o) {
			out.printf(s, o);
		}
	}

	public static long pow(long n, long p, long mod) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n % mod;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2, mod);
			return (temp * temp) % mod;
		} else {
			long temp = pow(n, (p - 1) / 2, mod);
			temp = (temp * temp) % mod;
			return (temp * n) % mod;

		}
	}

	public static long pow(long n, long p) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2);
			return (temp * temp);
		} else {
			long temp = pow(n, (p - 1) / 2);
			temp = (temp * temp);
			return (temp * n);

		}
	}

	public static long gcd(long x, long y) {
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	}

	public static boolean isPrime(int n) {
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;

		if (n % 2 == 0 || n % 3 == 0)
			return false;

		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;

		return true;
	}
}


Measured memory_bytes: 49916
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
int main() {
	string s;
	int n,a=0,w=0,t=0,r=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s == "AC")a++;
		if (s == "WA")w++;
		if (s == "TLE")t++;
		if (s == "RE")r++;
	}
	cout << "AC" << " " << "x" << " " << a << endl;
	cout << "WA" << " " << "x" << " " << w << endl;
	cout << "TLE" << " " << "x" << " " << t << endl;
	cout << "RE" << " " << "x" << " " << r << endl;


	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#define N 102
using namespace std;
int a[N],b[N],c[N],d[N];
int n,m,q;
int ans=0;
int num[N];
void dfs(int i,int x)
{
	num[i]=x;
	int j;
	if(i==n)
	{
		int res=0;
		for(j=1;j<=q;j++) if(num[b[j]]-num[a[j]]==c[j]) res+=d[j];
		ans=max(res,ans);
		return;
	}
	for(j=x;j<=m;j++) dfs(i+1,j);
}
int main()
{
	cin>>n>>m>>q;
	int i;
	for(i=1;i<=q;i++) scanf("%d%d%d%d",a+i,b+i,c+i,d+i);
	for(i=1;i<=m;i++) dfs(1,i);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3228
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define LONGMAX 1e18
#define dd double
#define MOD 998244353 
# define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define endl "\n"
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first	
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define INF 1e9
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll power(ll x, ll y){ll res=1;x=x%MOD;while(y>0){if(y&1)res = (res*x) % MOD;y = y>>1;x = (x*x) % MOD;}return res;}  
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
void ceilsearch(ll ar[],ll low,ll high,ll x,ll &y){if(low>high)return;ll mid=(low+high)/2;if(ar[mid]>=x){y=mid;ceilsearch(ar,low,mid-1,x,y);}else{ceilsearch(ar,mid+1,high,x,y);}}
signed main()
{
	fastio();	
  	ll N,M;
  	cin>>N>>M;
  	if(N==1||M==1)
  		cout<<1<<endl;
  	else
  		cout<<(M*N+1)/2<<endl;
}

Measured memory_bytes: 256
from fractions import gcd

a, b, c, d = map(int, input().split())

e = c * d // gcd(c, d)
rest = (b//c - (a-1)//c) + (b//d - (a-1)//d) - (b//e - (a-1)//e)
ans = b-a+1 - rest

print(ans)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
int64_t factm(int64_t n,int64_t MOD){
    if(n==0){
        return 1;
    }
    else{
        return (n*factm(n-1,MOD)%MOD)%MOD;
    }
}
int main(){
    int64_t n,m;
    cin>>n>>m;
    int64_t ans;
    int64_t k;
    if(n==m){
        k=factm(m,big);
        ans = ((2*k)%big)*k%big;
    }
    else if(n==m+1){
        k = factm(m,big);
        ans = ((k*k)%big)*(m+1)%big;
    }
    else if(m==n+1){
        k=factm(n,big);
        ans = (k*k%big)*(n+1)%big;
    }
    else{
        ans=0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3328
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
use std::cmp; // cmp::max,cmp::min

// Rust memo: https://hackmd.io/i0lQY1OKTDW1t66TECOmiw?both

#[allow(dead_code)]
fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn arange(start:i64,end:i64,step:i64) -> Vec<i64>{
    let mut ret = Vec::new();
    let mut i = start;

    while i < end{
        ret.push(i);
        i += step;
    }

    ret
}

#[allow(dead_code)]
const DXS : [i64; 4] = [0,0,1,-1];
#[allow(dead_code)]
const DYS : [i64; 4]  = [1,-1,0,0];
#[allow(dead_code)]
const INF : i64 = 999999999;

////////////////////////////////////////////////

fn my_mod(n:i64,m:i64)->i64{
    ((n%m)+m)%m
}

fn gcd(n:i64,m:i64)->i64{
    let a = cmp::min(n,m);
    let b = cmp::max(n,m);
    
    if my_mod(b, a) == 0{
        a
    }else{
        gcd(my_mod(b, a),a)
    }
}

fn main(){
    let xs = read_ints();
    let (n,x) = (xs[0]as usize,xs[1]);
    let xs = read_ints().into_iter().map(|y| (y - x).abs()).collect::<Vec<_>>();
    
    if n == 1{
        println!("{}",xs[0]);
        return;
    }
    
    let mut g = gcd(xs[0],xs[1]);
        
    //println!("{:?}",xs);
    
    for x in xs{
        g = gcd(g,x);
    }
    
    println!("{}",g);
}


Measured memory_bytes: 10492
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(long long a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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;
}

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    int N, A;
    cin >> N >> A;
    yesno(A >= (N % 500));
}


Measured memory_bytes: 256
a, b, c, x, y = gets.split.map(&:to_i)
ary = []
x>=y ? ary << 2*y*c+(x-y)*a : ary << 2*x*c+(y-x)*b
x>=y ? ary << 2*x*c : ary << 2*y*c
ary << x*a+y*b
puts ary.min

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

int ar[200005];

int32_t main(){
	int n,t;
	cin>>n;
	for(int i=2;i<=n;i++){
		cin>>t;
		ar[t]++;
	}
	for(int i=1;i<=n;i++){
		cout<<ar[i]<<'\n';
	}
}


Measured memory_bytes: 5160
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        String[] list = new String[n];
        for (int i = 0; i < n; i++) {
            list[i] = sc.next();
        }
        Arrays.sort(list);

        ArrayList<Moji> ans = new ArrayList<>();
        int count = 1;

        for (int i = 1; i < n; i++) {
            if (list[i].equals(list[i - 1])) {
                count++;
            } else {
                ans.add(new Moji(list[i - 1], count));
                count = 1;
            }
            if (i == n - 1) {
                ans.add(new Moji(list[i], count));
            }
        }

        ans.sort((a, b) -> b.count - a.count);
        int max = ans.get(0).count;
        for (Moji v: ans
             ) {
            if (max == v.count) {
                System.out.println(v.value);
            } else {
                return;
            }
        }
    }

    private static class Moji {
        private String value;
        private int count;

        public Moji(String value, int count) {
            this.value = value;
            this.count = count;
        }
    }
}

Measured memory_bytes: 82832
#include <iostream>
#include <string>
#include <vector>
#include <queue>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

struct edge {
    int to, cost;
};

struct state {
    int v, d, rest;
    bool operator<(const state& s)const{
        return d>s.d;
    }
};

int main(){
    int n;
    while (cin >> n, n){
        int math, eng, jap;
        rep(i, n){
            cin >> math >> eng >> jap;
            if (math == 100 || eng == 100 || jap == 100 ||
                (math + eng) / 2 >= 90 || (math + eng + jap) / 3 >= 80){
                cout << "A" << endl;
            }
            else if ((math + eng + jap) / 3 >= 70 ||
                (math + eng + jap) / 3 >= 50 && (math >= 80 || eng >= 80)){
                cout << "B" << endl;
            }
            else{
                cout << "C" << endl;
            }
        }
    }
}

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a*n,b);
	return 0;
}

Measured memory_bytes: 256
# https://abc113.contest.atcoder.jp/tasks/abc113_c
def pad(n):
    return '{:0>6}'.format(n)


N, M = map(int, input().split())
data = [None for _ in range(M)]
for i in range(M):
    Pi, Yi = map(int, input().split())
    data[i] = [Pi, Yi, 1, i]

data.sort(key=lambda x: x[1])  # sort by year
data.sort(key=lambda x: x[0])  # sort by prefectures

for i in range(1, M):
    if data[i][0] == data[i - 1][0]:
        data[i][2] = data[i - 1][2] + 1

data.sort(key=lambda x: x[-1])  # original order
ans = []
for di in data:
    ans.append(pad(di[0]) + pad(di[2]))
print('\n'.join(ans))


Measured memory_bytes: 38420
def bigcmb(N, R, MOD):  # nCr(mod p) #n>=10**7,r<=10**6 #前処理不要
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    fact, inv = 1, 1
    for i in range(1, R + 1):
        fact = (fact * (N - i + 1)) % MOD
        inv = (inv * i) % MOD
    return fact * pow(inv, MOD - 2, MOD) % MOD


x, y = map(int, input().split())
mod = 10 ** 9 + 7

if (x + y) % 3 != 0:
    print(0)
else:
    cnt = (x + y) // 3
    print(bigcmb(cnt, x - cnt, mod))


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

int main() {
  int N, A, B;

  cin >> N >> A >> B;
  
  if (N < 1 || N > 20) {
    cout << "error" << endl;
  }  
  else if (A < 1 || A > 100) {
    cout << "error" << endl;
  }
  else if (B < 1 || B > 2000) {
    cout << "error" << endl;
  }
  else if ((N * A) == B) {
    cout << B << endl;
  }
  else if ((N * A) < B) {
    cout << N * A << endl;
  }
  else {
    cout << B << endl;
  }
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[] num = new int[n + 1];
			for (int i = 0; i < n; i++)
				num[i] = scanner.nextInt();
			num[n] = 1 << 30;
			StringBuilder builder = new StringBuilder();
			builder.append(num[0]);
			for (int i = 1; i < n; i++)
				if (num[i - 1] + 1 == num[i])
					if (num[i] + 1 == num[i + 1])
						continue;
					else
						builder.append('-').append(num[i]);
				else
					builder.append(' ').append(num[i]);
			System.out.println(builder);
		}
	}
}

Measured memory_bytes: 26200
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		//????????£???????????????
		Scanner sc = new  Scanner(System.in);
		//??£?¨?
		long Answer = 0;
		//??°?????????
		while(true){
			//????????????
			String line = sc.nextLine();
			//?????£???????????????0????????????
			if(line.equals("0")){
				break;
			}
			//???????????????????????????
			for(int i = 0; i<line.length();i++){
				Answer += Integer.parseInt(String.valueOf(line.charAt(i)));
			}
			//??°???????¶????????????????
			System.out.println(Answer);
			Answer = 0;
		}
	}
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

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

int main() {
    ll a, b; cin >> a >> b;
    ll c, d; cin >> c >> d;
    ll g = c * d / gcd(c, d);
    ll ans = (b - (b / c) - (b / d) + (b / g)) - (a - 1 - ((a - 1) / c) - ((a - 1) / d) + ((a - 1) / g));
    cout << ans << endl;
}


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

using namespace std;

int main(){
    string s,t,u;
    int a,b;

    cin >> s >> t >> a >> b >> u;

    if(s == u){
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " " << b-1 << endl;
    }
    return 0;



    
}

Measured memory_bytes: 256
#include<stdio.h>

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

int main()
{
    int a,b,c;
    int res;
    
    scanf("%d %d %d",&a,&b,&c);
    
    res = c - (a - b);
    if(res < 0)
    {
        res = 0;
    }
    
    printf("%d\n",res);
    
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2010,M=30005,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int cnt,n,m,S,T;
ll cost;
int fir[N],siz;
struct edge{int v,w,fl,re;};
vector<edge> e[N];
void add(int u,int v,int w,int fl){
	e[u].push_back((edge){v,w,fl,(int)e[v].size()});
	e[v].push_back((edge){u,-w,0,(int)e[u].size()-1});
}
ll dist[N];
int dis[N];
vector<int> que;
bool inq[N];
bool spfa(){
	memset(dist,0xA0,8*(cnt+1));
	memset(inq,0,cnt+1);
	dist[S]=0;inq[S]=1;
	que.clear();que.push_back(S);
	for (unsigned i=0;i<que.size();i++){
		int x=que[i];
		for (auto cur : e[x])
		if (cur.fl&&(dist[cur.v]<dist[x]+cur.w)){
			if (!inq[cur.v]) {que.push_back(cur.v);inq[cur.v]=1;}
			dist[cur.v]=dist[x]+cur.w;
		}
		inq[x]=0;
	}
	return dist[T]>=0;
}
void bfs(){
	memset(dis,0x3f,4*(cnt+1));
	dis[S]=0;
	que.clear();que.push_back(S);
	for (unsigned i=0;i<que.size();i++){
		int x=que[i];
		for (auto cur : e[x])
		if ((dist[cur.v]==dist[x]+cur.w)&&cur.fl&&(dis[cur.v]>dis[x]+1)){
			que.push_back(cur.v);
			dis[cur.v]=dis[x]+1;
		}
	}
	return;
}
int dfs(int x,int flow){
	if (x==T) return flow;
	int fl=0,t=0;
	for (unsigned i=fir[x];i<e[x].size();i++){
		edge &cur=e[x][i];
		if ((dist[cur.v]==dist[x]+cur.w)&&cur.fl&&(dis[cur.v]>dis[x])){
			t=dfs(cur.v,min(flow-fl,cur.fl));
			fl+=t;cur.fl-=t;e[cur.v][cur.re].fl+=t;
			if (fl==flow) {fir[x]=i;return fl;}
		}
	}
	fir[x]=e[x].size();
	return fl;
}
int dinic(){
	int flow=0;
	while (spfa()){
		bfs();
		for (int i=0;i<=cnt;i++) fir[i]=0;
		int cur=dfs(S,inf);
		flow+=cur;
		cost+=(ll)dist[T]*cur;
	}
	return flow;
}
int main(){
	n=read();
	S=0;T=cnt=n*2+5;
	for (int i=1;i<=n;i++){
		int x=read(),y=read(),c=read();
		add(S,i,0,c);
		add(i,n*2+1,x+y,c);
		add(i,n*2+2,x-y,c);
		add(i,n*2+3,-x+y,c);
		add(i,n*2+4,-x-y,c);
	}
	for (int i=n+1;i<=n+n;i++){
		int x=read(),y=read(),c=read();
		add(i,T,0,c);
		add(n*2+1,i,-x-y,c);
		add(n*2+2,i,-x+y,c);
		add(n*2+3,i,x-y,c);
		add(n*2+4,i,x+y,c);
	}
	dinic();
	printf("%lld\n",cost);
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>

using namespace std;


vector<long long> list_elem(int s) {
  int c = 0;
  vector<long long> ans;
  while(s != 0) {
    if (s & 1 ) ans.push_back(c);
    s = s >> 1;
    c = c + 1;
  }
  return ans;
}


int main() {

  int N;

  cin >> N;
  vector< vector<long long> > A(N, vector<long long>(N));

  for (auto i=0;i <N; i++)
  for (auto j=0;j <N; j++) cin >> A[i][j];

  vector<long long> F( 1<<17, 0);

  // consider all sub sets of {1..N}
  for (long long s = 1; s < (1<<N); s++) {
    auto l = list_elem(s);
    // for (auto tt=0; tt<l.size(); tt++) 
    // cout << "l" << l[tt] << "  ";
    // cout << endl;
    F[s] = 0;
    for (auto i=0; i < l.size(); i++)
    for (auto j=i+1; j < l.size(); j++) F[s] += A[l[i]][l[j]];

    auto L = l.size();

    for (auto i=0; i< (1<<L); i++) {
      long long a=0, b=0;
      for(auto bit=0; bit<L; bit++) {
        if ( (1<<bit) & i ) a |= (1 << (l[bit]) );
        else b |= ( 1 << (l[bit]) );

      }    
      F[s] = max( F[s],  F[a] + F[b] );
    }
    // cout << endl;
  }


  cout << F[ (1<<N)-1] << endl;


  return 0;
}

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

public class Main
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken()), c = Integer.parseInt(st.nextToken()), k = Integer.parseInt(st.nextToken());
		int[] times = new int[n];
		for(int i = 0; i < n; i++)
			times[i] = Integer.parseInt(br.readLine());
		Arrays.sort(times);
		int i = 0, buses = 0;
		while(i < n)
		{
			int end = times[i] + k, num = 1;
			i++;
			while(i < n && times[i] <= end && num < c)
			{
				num++;
				i++;
			}
			buses++;
		}
		pw.println(buses);
		br.close();
		pw.close();
		System.exit(0);
	}
}

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

signed main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k; cin >> k;
	cout << a[k-1];



	

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define N 100000
int main(void)
{
  int a[N+1];
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int count = 1;
  int next = 1;
  while(count < n) {
    next = a[next];
    if(next==2) {
      break;
    }
    count++;
  }
  if(count < n) {
    cout << count << endl;
  } else {
    cout << "-1" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<float.h>
#include<cfloat>
#include<string>
#include<ctype.h>
#include<algorithm>
#include<errno.h>
#include<cerrno>
#include<assert.h>
#include<cassert> 
#include<map>
#include<memory.h>
#include<cctype>
#include<ctype.h>
#include<math.h>
#include<vector> 
#include<cstdio> 
#include<set>
#include<string.h>
#include<stdio.h>
#include<new>
#include<memory>
#include<cmath>
#include<queue>
#include<cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
int main()
{string a,b,c;
 cin>>a>>b>>c;
 if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0])cout<<"YES";
 else cout<<"NO";
 return 0;
}

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

using namespace std;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int win = count(s.begin(), s.end(), 'o');
  win += 15 - s.size();
  cout << (win >= 8 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <complex>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef complex<double> P;
const double PI = 3.141592653589793238462643383279502884L;
const int LARGE_PRIME = 1000000007;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i,a,cont,next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i,a,b,step) repfn(i, a, i < b, i + step)
#define repab(i,a,b) repby(i, (a), (b), 1)
#define rep(i,n) repab(i, 0, (n))
#define pb push_back
#define sz(c) int((c).size())

int main(int argc, char **argv)
{
  int n;
  double x, y;
  cin >> n;

  while (n--) {
    cin >> x >> y;
    P p(x, y);
    cin >> x >> y;
    P q(x, y);
    cin >> x >> y;
    P r(x, y);

    double eA = norm(q - r);
    double eB = norm(r - p);
    double eC = norm(p - q);

    P c = (eA*(eB+eC-eA)*p + eB*(eC+eA-eB)*q + eC*(eA+eB-eC)*r)
          / (eA*(eB+eC-eA) + eB*(eC+eA-eB) + eC*(eA+eB-eC));

    printf("%.3f %.3f %.3f\n", c.real(), c.imag(), abs(p - c));

  }
  return 0;
}

Measured memory_bytes: 1252
#include<iostream>
#include<cstdio>
#define eps 10e-10
using namespace std;
int main()
{
	int n;
	double w,h;
	while(scanf("%d,%lf,%lf",&n,&w,&h)!=EOF)
	{
		if(25.0<=w/(h*h)) cout<<n<<endl;
	}
  return 0;
}

Measured memory_bytes: 1232
use text_io::*;
use std::collections::HashMap;
use std::process::exit;

fn main() {
    let mut n:usize = read!();
    for i in 0..n {
        let mut a:usize = read!();
        if a%2==0 && a%3!=0 && a%5!=0 {
            println!("DENIED");
            exit(0);
        }
    }
    println!("APPROVED");
}

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

int main(){
	int n,i,j,a,b,c,ans=0;
	cin >> n;
	string s[310];
	for(i=0;i<n;i++){
		cin >> s[i];
	}
	
	for(b=0;b<n;b++){
		c = 0;
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				if(s[i%n][(j+n-b)%n]==s[j%n][(i+n-b)%n]){
					c++;
				}
			}
			if(c==n*n){
				ans += n;
			}
		}
	}
	
	cout << ans << endl;
}
	

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

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        int sales[10] = {};
        for (int i = 0; i < n; i++) {
            int ice;
            cin >> ice;
            sales[ice]++;
        }
        for (int i = 0; i < 10; i++) {
            if (sales[i] == 0) {
                cout << "-";
            } else {
                for (int j = 0; j < sales[i]; j++) {
                    cout << "*";
                }
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 0
/*input
1 1
1000000000
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long lol;
#define INF 0x3f3f3f3f
#define MAX 100010

int n, x, ans;
int a[MAX];

int main() {
	cin >> n >> x;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] = abs(a[i] - x);
	}
	ans = a[1];
	for (int i = 1; i <= n; i++) ans = __gcd(ans, a[i]);

	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

#define N 100

int min(int a, int b) {
	return a < b ? a : b;
}

int main() {
	static int bb[N];
	int n, i, sum;

	scanf("%d", &n);
	for (i = 0; i < n - 1; i++)
		scanf("%d", &bb[i]);
	sum = bb[0];
	for (i = 0; i < n - 2; i++)
		sum += min(bb[i], bb[i + 1]);
	printf("%d\n", sum + bb[n - 2]);
	return 0;
}


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

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

using namespace std;

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

const int MAX = 1e3 + 5;
ll arr[MAX];
int n;

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

	ll maxx = -2e9;
	ll sum[2] = {0};
	fori(i, 0, n) {
		scanf("%lld", arr + i);
		if(arr[i] >= 0) {
			sum[i & 1] += arr[i];
		}
		maxx = max(maxx, arr[i]);
	}

	vector<int> ans;
	if(maxx < 0) {
		int idx = -1;
		fori(i, 0, n) {
			if(arr[i] == maxx) {
				idx = i;
				break;
			}
			ans.push_back(1);
		}

		int left = n - idx;
		fori(i, idx + 1, n) {
			ans.push_back(left--);
		}
	}
	else {
		int chosen = sum[1] > sum[0];
		maxx = sum[chosen];

		vector<int> guys;
		for(int i = chosen; i < n; i += 2) {
			if(arr[i] >= 0) {
				guys.push_back(i);
			}
		}

		ford(i, n - 1, guys.back() + 1) {
			ans.push_back(i + 1);	
		}

		fori(i, 0, guys[0]) {
			ans.push_back(1);
		}

		fori(i, 1, guys.size()) {
			int diff = guys[i] - guys[i - 1];
			fori(j, 0, diff / 2 - 1) {
				ans.push_back(3);
			}
			ans.push_back(2);
		}
	}

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

	printf("%d\n", (int) ans.size());
	for(auto &each : ans) {
		printf("%d\n", each);
	}

	return 0;
}


Measured memory_bytes: 256
#
import sys
import math
import numpy as np
import itertools
import fractions

# ひとつ入力
n = int(input())
# リストに入れる
a = [int(i) for i in input().split()]

hidari = [0]*n
migi   = [0]*n
hidari[0] = a[0]
for i in range(1,n):
    hidari[i]=fractions.gcd(hidari[i-1],a[i])
migi[n-1] = a[n-1]
for i in range(n-2,-1,-1):
    migi[i]=fractions.gcd(migi[i+1],a[i])

saidai=max(migi[1],hidari[n-2])
for i in range(1,n-1):
    saidai = max(saidai, fractions.gcd(hidari[i-1],migi[i+1]))
#    print(fractions.gcd(hidari[i-1],migi[i+1]))
#print(hidari,migi)
print(saidai)



Measured memory_bytes: 24244
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,x,kari=0;
    long long ans=0;
    int N=10,S=10, E=10, W=10;
    char direction[1005];

    cin>>a>>b>>c;

    if(a>b&&a>c){
        ans=b*c*(a-(a/2)*2);
    }else if(a<b&&c<b){
        ans=a*c*(b-(b/2)*2);
    }else{ 
        ans=a*b*(c-(c/2)*2);
    }
 
        cout<<ans<<endl;

}



Measured memory_bytes: 256
from bisect import bisect_left as bl
N=int(input())
A=[int(input()) for _ in [0]*N]
def bl3(A,x):
    # Aは逆順ソートされている
    # x未満のうち最大の要素のインデックスを返す
    ok=len(A)
    ng=-1
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if A[mid]<x:
            ok=mid
        else:
            ng=mid
    return ok

B=[A[0]]
for a in A[1:]:
    ind=bl3(B,a)
    if ind==len(B):
        B.append(a)
    else:
        B[ind]=a
print(len(B))

Measured memory_bytes: 85612
//By Krishna Yadav
#pragma GCC optimize("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define testcase(t) \
    int t;          \
    cin >> t;       \
    while (t--)
#define forstl(i, v) for (auto &i : v)
#define forn(i, e) for (int i = 0; i < e; i++)
#define ln "\n"

#define dbg(x) cout << #x << " = " << x << ln
#define dbg2(x, y) cout << #x << " = " << x << " & " << #y << " = " << y << ln
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> p32;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef map<int, int> m32;
const int LIM = 2e5 + 5, MOD = 1e9 + 7;
int t, n, m, k, x, y;

int findMex(map<int, int> mp)
{
    int i = 0;
    while (mp[i])
        i++;
    return i;
}

int main()
{
    int n;
    cin >> n;
    int ans = 1000 - n % 1000;
    if (ans == 1000)
        ans = 0;
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int lli;
#define MAXSIZE 100000

int main(){
    lli n, a[MAXSIZE], b[MAXSIZE], h, a_max = 0;
    cin >> n >> h;
    for(lli i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        a_max = max(a[i], a_max);
    }
    //cout << endl << a_max << endl << endl;

    sort(b, b + n, greater<lli>());
    lli damage_sum = 0, attack_num = 0;
    
    for(lli i = 0; i < n; i++){
        if(b[i] > a_max){
            damage_sum += b[i];
            attack_num++;
        }else{
            break;
        }
        //cout << damage_sum << endl;
        
        if(damage_sum >= h){
            cout << attack_num << endl;
            return 0;
        }
    }
    
    //cout << endl << (h - damage_sum) % a_max << endl << endl;

    if((h - damage_sum) % a_max == 0){
        cout << attack_num + (h - damage_sum) / a_max << endl;
    }else{
        cout << attack_num + (h - damage_sum) / a_max + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
s = input()
result_list = [0 for i in range(len(s))]
left = 0
past_str = "R"
r_group = 1
l_group = 1
final_i = 0
sep_i = 0
import math
for i in range(1,len(s)):
  if past_str == "R" and s[i] == "L":
    sep_i = i
    past_str = "L"
  elif past_str == "L" and s[i] == "R":
    result_list[sep_i-1] = math.ceil(r_group/2) + math.floor(l_group/2)
    result_list[sep_i] = math.floor(r_group/2) + math.ceil(l_group/2)
    l_group = 1
    r_group = 1
    past_str = "R"
  elif past_str == "L" and s[i] == "L":
    l_group += 1
    past_str = "L"
  elif past_str == "R" and s[i] == "R":
    r_group += 1
    past_str = "R"  
result_list[sep_i-1] = math.ceil(r_group/2) + math.floor(l_group/2)
result_list[sep_i] = math.floor(r_group/2) + math.ceil(l_group/2)    
print(*result_list)
    
    
    
    
  

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


void solve(long long K, long long N, std::vector<long long> A){
  vector<int> vec = {};
  long long first = (K - A[A.size()-1]) + A[0];
  vec.push_back(first);

  for (int i=0; i<A.size()-1; i++) {
    long long distance = A[i+1] - A[i];
    vec.push_back(distance);
  }
  cout << K - *max_element(vec.begin(), vec.end()) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(K, N, std::move(A));
    return 0;
}


Measured memory_bytes: 2936
#include<iostream>
using namespace std;
int a[100];
int n;
int ans1=1,ans2=1;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)   cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		ans1*=3;
		if(a[i]%2==0)    ans2*=2;
		else             ans2*=1;
	}
	cout<<ans1-ans2;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
c = [0 for _ in range(5)]
for _ in range(N):
    s = input()
    if s[0] == 'M':
        c[0] += 1
    elif s[0] == 'A':
        c[1] += 1
    elif s[0] == 'R':
        c[2] += 1
    elif s[0] == 'C':
        c[3] += 1
    elif s[0] == 'H':
        c[4] += 1
ans = c[0]*c[1]*c[2] + c[0]*c[1]*c[3] + c[0]*c[1]*c[4] + c[0]*c[2]*c[3] + c[0]*c[2]*c[4] + c[0]*c[3]*c[4] + c[1]*c[2]*c[3] + c[1]*c[2]*c[4] + c[1]*c[3]*c[4] + c[2]*c[3]*c[4]
print(ans)


Measured memory_bytes: 3064
import sys
from heapq import*
r=sys.stdin.readline
def g(s,g):
 F=[1e7]*-~n;F[s]=0
 H=[(0,s)]
 while H:
  c,u=heappop(H)
  if u==g:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:
    F[v]=t
    heappush(H,(t,v))
 return-1
for e in iter(input,'0 0'):
 n,k=map(int,e.split())
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=[*map(int,r().split())]
  if f[0]:
   c,d,e=f[1:]
   E[c]+=[(e,d)];E[d]+=[(e,c)]
  else:print(g(*f[1:]))


Measured memory_bytes: 6268
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,Y;
  cin >> N >> Y;
  
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N-i; j++) {
      if (10000*i + 5000*j + 1000*(N-i-j) == Y){
        cout << i << ' ' << j << ' ' << N-i-j << endl;
        return 0;
      }
    }
  }
  cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}
      
    
   

Measured memory_bytes: 3628
from functools import reduce
N = int(input())
g = 10 ** 9 + 7

def add(a, b):
  return (a + b) % g
def mul(a, b):
  return (a * b) % g

def adda(a, p1, p2):
    for x in range(len(a)):
        a[x] = add(p1[x], p2[x])

d = []
DP = [[0 for _ in range(N+1)] for _ in range(N+1)]
ans = [0 for _ in range(N+1)]
for i in range(2, N+1):
  for j in (x for x in d if x * x <= N):
    if i % j == 0:
      adda(DP[i], DP[j], DP[i//j])
      break
  else:
    d.append(i)
    DP[i][i] = 1
  adda(ans, ans, DP[i])

print(reduce(mul, [x + 1 for x in ans[1:N+1]]))


Measured memory_bytes: 50908
#include <iostream>
#include <array>
#include <string>

class Baseball{
	
private:
	//アウトカウント
	int out_count;
	//ランナー
	std::array<bool, 3> runner;
	//点数
	int point;
	
public:
	//コンストラクタ
	Baseball(){
		out_count = 0;
		for(int i = 0; i < 3; ++i) runner[i] = false;
		point = 0;
	}
	
	//デストラクタ
	~Baseball(){}
	
	//点数出力
	int get_point(){ return point; }
	
	//ゲーム開始
	void playball();
	
	//アウト判定
	void process_out();
	
	//ヒット判定
	void process_hit();
	
	//ホームラン判定
	void process_homerun();
};

//ゲーム開始
void Baseball::playball(){
	while(out_count < 3){
		std::string str;
		std::cin >> str;
		if(str == "OUT") process_out();
		else if(str == "HIT") process_hit();
		else if(str == "HOMERUN") process_homerun();
	}
}

//アウト判定
void Baseball::process_out(){
	++out_count;
}

//ヒット判定
void Baseball::process_hit(){
	if(runner[2]){
		++point;
		runner[2] = false;
	}
	if(runner[1]){
		runner[1] = false;
		runner[2] = true;
	}
	if(runner[0]){
		runner[0] = false;
		runner[1] = true;
	}
	runner[0] = true;
}

//ホームラン判定
void Baseball::process_homerun(){
	++point;
	for(int i = 0; i < 3; ++i){
		if(runner[i]){
			++point;
			runner[i] = false;
		}
	}
}


int main(){
	int count;
	std::cin >> count;
	
	for(int i = 0; i < count; ++i){
		Baseball baseball;
		
		baseball.playball();
		std::cout << baseball.get_point() << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 1212