akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
class Main{


	static char[][] map;

	static long[][] c;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double x = sc.nextDouble();
		double ans = 0;
		if(a*a*b/2 < x){
			ans = (a*a*a) / (2*a*a*b-2*x);
		}else{
			ans = 2*x / (a*b*b);

		}
		
		


				System.out.print(90-Math.toDegrees(Math.atan(ans)));

	}

	//	static void dfs(int y,int x,int num,int count){
	//		if((y+1)*(x+1) > num){
	//			return;
	//		}
	//		if((y + 1)*(x+1) == num){
	//			ans = Math.min(ans, count);
	//			return;
	//		}
	//		
	//		if(y + 1 <= )
	//		dfs(y+1, x, num, count);
	//		
	//	}

	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



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




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}








}






Measured memory_bytes: 23252
#include<stdio.h>
int N, M, L, e, f, lx, ly, x, y, i;
char A[51][51], B[51][51];
int main(void){
	scanf("%d %d\n", &N, &M);
	for(i=0; i<N; i++){
		scanf("%s\n", A[i]);
	}
	for(i=0; i<M; i++){
		scanf("%s\n", B[i]);
	}
	e=0;
	for(ly=0; ly<N; ly++){
		for(lx=0; lx<N; lx++){
			if(ly+M-1>=N || lx+M-1>=N){continue;}
			f=1;
			for(int y=0;y<M;++y){
				for(int x=0;x<M;++x){
					if(A[ly+y][lx+x]!=B[y][x]){f=0;}
				}
			}
			if(f){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  string w;
  cin >> w;
  int A = 0, B = 0, C = 0, D = 0, E = 0, F = 0, G = 0, H = 0, I = 0, J = 0, K = 0, L = 0, M = 0, N = 0, O = 0, P = 0, Q = 0, R = 0, S = 0, T = 0, U = 0, V = 0, W = 0, X = 0, Y = 0, Z = 0, x = w.size();
  for (int i = 0; i < x; i++) {
    if (w.at(i) == 'a') {A++;}
    else if (w.at(i) == 'b') {B++;}
    else if (w.at(i) == 'c') {C++;}
    else if (w.at(i) == 'd') {D++;}
    else if (w.at(i) == 'e') {E++;}
    else if (w.at(i) == 'f') {F++;}
    else if (w.at(i) == 'g') {G++;}
    else if (w.at(i) == 'h') {H++;}
    else if (w.at(i) == 'i') {I++;}
    else if (w.at(i) == 'j') {J++;}
    else if (w.at(i) == 'k') {K++;}
    else if (w.at(i) == 'l') {L++;}
    else if (w.at(i) == 'm') {M++;}
    else if (w.at(i) == 'n') {N++;}
    else if (w.at(i) == 'o') {O++;}
    else if (w.at(i) == 'p') {P++;}
    else if (w.at(i) == 'q') {Q++;}
    else if (w.at(i) == 'r') {R++;}
    else if (w.at(i) == 's') {S++;}
    else if (w.at(i) == 't') {T++;}
    else if (w.at(i) == 'u') {U++;}
    else if (w.at(i) == 'v') {V++;}
    else if (w.at(i) == 'w') {W++;}
    else if (w.at(i) == 'x') {X++;}
    else if (w.at(i) == 'Y') {Y++;}
    else {Z++;}
  }
  if (A % 2 == 0 && B % 2 == 0 && C % 2 == 0 && D % 2 == 0 && E % 2 == 0 && F % 2 == 0 && G % 2 == 0 && H % 2 == 0 && I % 2 == 0 && J % 2 == 0 && K % 2 == 0 && L % 2 == 0 && M % 2 == 0 && N % 2 == 0 && O % 2 == 0 && P % 2 == 0 && Q % 2 == 0 && R % 2 == 0 && S % 2 == 0 && T % 2 == 0 && U % 2 == 0 && V % 2 == 0 && W % 2 == 0 && X % 2 == 0 && Y % 2 == 0 && Z % 2 == 0) {
    cout << "Yes" << endl;
  }
  else {cout << "No" << endl;}
}

Measured memory_bytes: 3560
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	string a;
	string s;
	while(cin>>a>>s,a!="0"||s!="0"){
		int A=atoi(&a[0]);
		int m=a.size();
		int out=-1;
		int n=s.size();
		int N=1<<(n-1);
		vi nu;
		bool H=false;
		rep(i,N){
			vi tmp;
			int t=i;
			int sum=0;
			int r=0;
			int co=0;
			bool h=true;
			while(t){
				if(co==m)h=false;
				co++;
				if(t%2){
					int q=atoi(&(s.substr(r,co))[0]);
					sum+=q;
					tmp.pb(q);
					r+=co;
					co=0;
				}
				t/=2;
			}
			int q=atoi(&s.substr(r)[0]);
			sum+=q;
			tmp.pb(q);
			if(A<sum)continue;
			if(h&&out==sum)H=true;
			else if(h&&out<sum){
				H=false;
				nu=tmp;
			}
			out=max(out,sum);
		}
		if(H)cout<<"rejected"<<endl;
		else if(out==-1)cout<<"error"<<endl;
		else{
			cout<<out;
			rep(i,nu.size())cout<<" "<<nu[i];
			cout<<endl;
		}
	}
}

Measured memory_bytes: 1224
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
int main(void){
	int n,i,k;
	scanf("%d %d",&n,&k);
	int h[n];
	for(i=0;i<n;i++)scanf("%d",&h[i]);
	qsort(h, n, sizeof(int), compare_int);
	int ans=h[k-1]-h[0];
	for(i=0;i+k<=n;i++){
		int a = h[i+k-1] - h[i];
		if(a < ans)ans = a;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	vector<string> mon = { "01","02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };
	bool elf1 = false, elf2 = false;
	rep(i, 12) {
		if (s.substr(0, 2) == mon[i]) elf1 = true;
		if (s.substr(2, 2) == mon[i]) elf2 = true;
	}
	if (elf1 && elf2) {
		puts("AMBIGUOUS");
	}
	else if (elf1) puts("MMYY");
	else if (elf2) puts("YYMM");
	else puts("NA");
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    X, A, B = map(int, input().split())

    if A - B >= 0:
        print('delicious')
    elif abs(A - B) <= X:
        print('safe')
    else:
        print('dangerous')

if __name__ == '__main__':
    main()

Measured memory_bytes: 10440
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int t;
    cin>>t; cin.ignore(); vector < pair<int, string> > v;
    vector <string> v1;
    map <string,int> mp;
    for (int i=0;i<t;i++){
        string a;
        cin>>a;
        mp[a]++;
    }
    int max=0;
    for (auto it=mp.begin();it!=mp.end();it++){
        v.push_back(make_pair(it->second, it->first));
    }
    sort(v.rbegin(),v.rend());
    for (int i=0;i<v.size();i++){
        if (v[i].first>=max){
            v1.push_back(v[i].second);
            max=v[i].first;
        }
    }
    sort(v1.begin(),v1.end());
    for (int i=0;i<v1.size();i++)
        cout<<v1[i]<<endl;
   

}

Measured memory_bytes: 32876
#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(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

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

ll k;

ll f(ll x){
  return ((10 * x) % k + 7) % k;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> k;
  ll tmp  = 7;
  for (int i = 0; i < 50000000; ++i) {
    if(tmp % k == 0){
      cout << i+1 << endl;
      exit(0);
    }
    tmp = f(tmp);
  }

  cout << -1 << endl;


}


Measured memory_bytes: 3596
use std::io::*;
fn main() {
	let a = read();
	let b = read();
	println!("{}", (a - 1) * (b - 1));
}

fn read() -> u32{
    let s = stdin();
    let b = s.bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    b.parse().ok().unwrap()
}



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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m),b(m),toshi(n);
  for(int i = 0;i < m;++i){
    cin >> a[i] >> b[i];
    toshi[a[i]-1]++;
    toshi[b[i]-1]++;
  }
  for(int i = 0;i  < toshi.size();++i){
     cout << toshi[i]<<endl;
  }
 
  return 0;
}

Measured memory_bytes: 256
/*
{By GWj
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
const int MOD=1e9+7;
LL pow(int A,int B){
	LL rest=1;
	rb(i,1,B)
		rest*=A,rest%=MOD;
	return rest;
}
int main(){
	fastio;
	int n;
	R(n);
	LL rest=pow(10,n);
	rest-=pow(9,n)*2ll;
	rest+=MOD+MOD;
	rest%=MOD;
	rest+=pow(8,n);
	rest%=MOD;
	cout<<rest<<endl;
	return 0;
}


Measured memory_bytes: 3612
#include<iostream>
int main(void){
	int a,b,c,n,i;
	std::cin>>n;
	for(i=0;i<n;i++){
		std::cin>>a>>b>>c;
		if(a*a==b*b+c*c)std::cout<<"YES"<<std::endl;
		else if(b*b==a*a+c*c)std::cout<<"YES"<<std::endl;
		else if(c*c==a*a+b*b)std::cout<<"YES"<<std::endl;
		else                 std::cout<<"NO"<<std::endl;
		}



	 return 0;
	}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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

int main() {
	int n;cin >> n;
    vector<double> x(n),y(n);REP(i,n)cin >> x[i] >> y[i];
    double s=0.0;

    // FOR(i,1,n){
    //     
    // }
    // 

    vector<int> v(n);
    iota(v.begin(), v.end(),0);       // v に 1, 2, ... N を設定
    int sn = 0;
    do {
        // int b=v[0];
        for(int i =1;i<v.size();i++){  
            s+= sqrt(pow((x[v[i]]-x[v[i-1]]),2) + (pow((y[v[i]]-y[v[i-1]]),2)) );
            // cout <<sqrt(pow((x[v[i]]-x[v[i-1]]),2) + (pow((y[v[i]]-y[v[i-1]]),2)) ) <<   "\n";    // v の要素を表示
            // b=v[i];
            // cout << v[i] << " " << v[i-1]<< " ";
        } 
        sn++;
    } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成

    cout << std::fixed << s/sn << endl;
    return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;
/**方針
//層の数が、Stringの桁数を溢れるかいなかの判断が必要。
//レベルN+1のバーガーには、レベルNのバーガーが2つ含まれるので、
//ざっくりレベルNのバーガーは、2^Nの文字数になる。（レベル０のバーガーが１文字なので）
//N<50なので、文字数の最大は2^50≒10^15。
//Stringは大体1億文字（10^8程度）までしか使えないので、単純にバーガーを文字で作ることはできない。
//
//そこで、バーガーの対称性や、再帰性に注目して、以下の作業を繰り返す。
//（ア）XがレベルNバーガーの中心層より、下のとき、
//レベルNバーガーのX番目だが、これはレベルN-1バーガーのX-1番目である。
//（イ）XがレベルNバーガーの中心層より、上のとき、
//レベルNバーガーのX番目は、レベルN-1バーガーの"X-(レベルN-1バーガーの層数)"層目である。
//ただし、このときはレベルN-1バーガーに含まれるパテ数＋１枚のパテを食べていることに注意（足していく）。
//この作業を繰り返していき、「1層目までを食べる。」等の計算できる状態となったときに計算して終了する。それまでに食べたパテ数が答え。
//ただし繰り返しの中で、もしも途中でXがレベルNバーガーの中心層になったら、簡単に計算できるので求めて、終わり。
*/

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		long X = sc.nextLong();
		long ans = 0;
		sc.close();
		
		//レベルNバーガーの中心の層の数が格納された配列。
		long mid[] = new long[N+1];
		mid[0]=1;
		for(int i=1;i<=N;i++) {
			mid[i]=(mid[i-1]*2-1)+2;
		}
		//レベルNのパテ数が格納された配列。
		long puttyNum[]= new long[N+1];
		puttyNum[0]=1;
		for(int i=1;i<=N;i++) {
			puttyNum[i] = 2*puttyNum[i-1]+1;
		}
		
		int levelcount=N;//バーガーのレベル数(ループの度に小さくなる。)
		while (true) {
			//Xがバーガーの中心に当たる場合
			//1つ低いレベルのバーガーのパテ数＋１枚食べて終わり
			if(X==mid[levelcount]) {
				ans += puttyNum[levelcount-1]+1;
				break;
			}
			//Xがバーガーの中心より上にある場合
			else if(X>mid[levelcount]) {
				//Xがバーガーの一番上だった場合は、そのバーガーを食べきって終了
				if(X==mid[levelcount]*2-1) {
					ans += puttyNum[levelcount];
					break;
				}else {
				ans += puttyNum[levelcount-1]+1;
				X -= mid[levelcount];
				}
			}
			//Xがバーガーの中心より下にある場合
			else{
				//Xがバーガーの一番下だった場合は、終了
				if(X==1) {
					break;
				}else {
				X --;
				}
			}
			levelcount--;
			if(levelcount==0) {
				ans += 1;
				break;
			}
		}		
		System.out.println(ans);
	}
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  ll n,k; cin>>n>>k;
  vll x(n);
  rep(i,n) cin>>x[i];
  
  ll centor=n;
  rep(i,n) {
    if(x[i]>=0){
      centor=i;
      break;
    }
  }
  
  ll ans =LINF;
  for(ll i=max(0LL,centor-k); i+k-1<n&&i<=centor; i++){
    ll tmp;
    if(i==centor-k || i-centor+1==k) {
      tmp=abs(x[i]);
    }
    else {
      tmp=abs(x[i+k-1]-x[i])+min(abs(x[i]),abs(x[i+k-1]));
    }
    chmin(ans,tmp);
  }
  cout<<ans<<endl;
  
}


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

 static int N=100;

int main(){
  int i,l,j,k,num,p[N+1],m[N+1][N+1];
  scanf("%d",&num);
  for(i=1;i<=num;i++){
    scanf("%d",&p[i-1]);
    scanf("%d",&p[i]);
  }

  for(i=1;i<=num;i++)m[i][i]=0;
  for(l=2;l<=num;l++){
    for(i=1;i<=num-l+1;i++){
      j=i+l-1;
      m[i][j]=1<<21;
      for(k=i;k<=j-1;k++){
        	m[i][j]=fmin(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
  printf("%d",m[1][num]);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2052
using System;
using static System.Console;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            if(N == 1)
            {
                WriteLine("Hello World");
            }
            else
            {
                int A = int.Parse(ReadLine());
                int B = int.Parse(ReadLine());
                WriteLine(A + B);
            }
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ll long long
#define MOD int(1e9+7)
#define mp make_pair
#define pb push_back
using namespace std;

vector<vector<ll>> dp(1000,vector<ll>(10001,-1));

ll dfs(auto& a,auto& b,int index,ll h)
{
    if(index>=b.size())
    {
        if(h>0) return INT_MAX;
        return 0;
    }
    if(h<=0) return 0;
    if(dp[index][h]!=-1) return dp[index][h];

    dp[index][h]=min(dfs(a,b,index+1,h),dfs(a,b,index,h-a[index])+b[index]);

    return dp[index][h];
}

int main()
{
    ll h,n;
    cin>>h>>n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++) cin>>a[i]>>b[i];

    cout<<dfs(a,b,0,h);

    return 0;
}


Measured memory_bytes: 79360
#include <iostream>
#include <string>
#include <map>
#include <cmath>

using namespace std;

map<char, string> cod;
const char deco[] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"};

void initi(void);

int main()
{
    string src;
    
    initi();

    while (getline(cin, src)) {
        string dis;

        for (int i = 0; i < src.size(); i++) 
            dis += cod[src[i]];

        for (int i = 0; i < dis.size() % 5; i++)
            dis += '0';

        src.clear();
        for (int i = 0; i < dis.size(); i += 5) {
            string tmp = dis.substr(i, 5);
            int ind = 0;

            for (int i = 0; i < 5; i++) {
                if (tmp[i] == '1')
                    ind += pow(2, 4 - i);
            }
            cout << deco[ind];
        }
        cout << endl;
    }

    return 0;
}


void initi(void)
{
    cod.insert(pair<char, string>(' ', "101"));
    cod.insert(pair<char, string>('\'', "000000"));
    cod.insert(pair<char, string>(',', "000011"));
    cod.insert(pair<char, string>('-', "10010001"));
    cod.insert(pair<char, string>('.', "010001"));
    cod.insert(pair<char, string>('?', "000001"));
    cod.insert(pair<char, string>('A', "100101"));
    cod.insert(pair<char, string>('B', "10011010"));

    cod.insert(pair<char, string>('C', "0101"));
    cod.insert(pair<char, string>('D', "0001"));
    cod.insert(pair<char, string>('E', "110"));
    cod.insert(pair<char, string>('F', "01001"));
    cod.insert(pair<char, string>('G', "10011011"));
    cod.insert(pair<char, string>('H', "010000"));
    cod.insert(pair<char, string>('I', "0111"));
    cod.insert(pair<char, string>('J', "10011000"));

    cod.insert(pair<char, string>('K', "0110"));
    cod.insert(pair<char, string>('L', "00100"));
    cod.insert(pair<char, string>('M', "10011001"));
    cod.insert(pair<char, string>('N', "10011110"));
    cod.insert(pair<char, string>('O', "00101"));
    cod.insert(pair<char, string>('P', "111"));
    cod.insert(pair<char, string>('Q', "10011111"));
    cod.insert(pair<char, string>('R', "1000"));

    cod.insert(pair<char, string>('S', "00110"));
    cod.insert(pair<char, string>('T', "00111"));
    cod.insert(pair<char, string>('U', "10011100"));
    cod.insert(pair<char, string>('V', "10011101"));
    cod.insert(pair<char, string>('W', "000010"));
    cod.insert(pair<char, string>('X', "10010010"));
    cod.insert(pair<char, string>('Y', "10010011"));
    cod.insert(pair<char, string>('Z', "10010000"));
}

Measured memory_bytes: 1244
import numpy as np

n, m, q = map(int, input().split())
a = list(range(q))
b = list(range(q))
c = list(range(q))
d = list(range(q))
for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

A = np.sort(np.random.randint(1, m+1, n))


def calc_energy(A):
    energy = 0.
    for i in range(q):
        if (A[b[i]-1] - A[a[i]-1]) == c[i]:
            energy += d[i]
    return energy


T = 20000
temperature = 100
for t in range(T):
    A_prev = np.copy(A)
    energy_prev = calc_energy(A_prev)

    idx = np.random.randint(0, n,3)
    A[idx] = np.random.randint(1, m+1,3)
    A = np.sort(A)
    energy = calc_energy(A)

    if np.random.rand() < (energy - energy_prev)/temperature:
        pass
    else:
        A = np.copy(A_prev)
    temperature  = temperature*0.999#temperature_init*(1/(1+t**4))

print(np.int(calc_energy(A)))


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

using namespace std;
#define vsort(v) sort(v.begin(), v.end())
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int ans = 0;
	for(int i = 0; i < N; i++) {
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
   FAST/**/
   
   ll n,m;
   cin>>n>>m;
   
   ll arr[n];
   for(ll i=0;i<n;i++)
        cin>>arr[i];
   
   map<ll,ll>ma;
   for(ll i=0;i<n;i++)
        ma[arr[i]]++;
           
  for(ll i=0;i<m;i++)
  {
      ll a,b;
      cin>>a>>b;
      
      ma[b]+=a;
  }
  
  ll sum = 0, cnt = n;
  
  for(auto it = ma.rbegin();it!=ma.rend();it++)
  {
      if(it->second>cnt)
      {
          sum+=cnt*it->first;
          break;
      }
      
      cnt-=it->second;
      sum+=(it->first)*(it->second);
  }
  
  cout<<sum;
   return 0;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
const string tr="abcdefghijklmnopqrstuvwxyz";
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main(){
  ll ans=0;
  ll ans1=0;
  ll ans2=0;
  string s;
  cin>>s;
  ll k;
  cin>>k;
  ll cnt=1;
  rrep(i,len(s)-1){
    if(s[i]!=s[i-1]){
      ans1+=cnt/2;
      cnt=1;
    }
    if(s[i]==s[i-1]) cnt++;
  }
  ans1+=cnt/2;
  if(cnt==len(s)){
    cout<<len(s)*k/2<<endl;
    return 0;
  }
  cnt=1;
  string t=s+s;
  rrep(i,len(t)-1){
    if(t[i]!=t[i-1]){
      ans2+=cnt/2;
      cnt=1;
    }
    if(t[i]==t[i-1]) cnt++;
  }
  ans2+=cnt/2;
  ans=(ans2-ans1)*(k-1)+ans1;
  cout<<ans<<endl;
}


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

int main(){
	int n;
	cin >> n;
	int a[n][3];
	for (int i=0;i<n;i++){
		cin >> a[i][0];
		cin >> a[i][1];
		cin >> a[i][2];
	}
	for (int i=0;i<n;i++){
		if(a[i][0] > a[i][1] && a[i][0] > a[i][2] && a[i][0]*a[i][0]== a[i][1]*a[i][1] + a[i][2]*a[i][2]){
			cout << "YES" << endl;
		}else if(a[i][1] > a[i][0] && a[i][1] > a[i][2] && a[i][1]*a[i][1]== a[i][0]*a[i][0] + a[i][2]*a[i][2]){
			cout << "YES" << endl;
		}else if(a[i][2] > a[i][1] && a[i][2] > a[i][0] && a[i][2]*a[i][2]== a[i][1]*a[i][1] + a[i][0]*a[i][0]){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}


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

int main() {
  int n, m; cin >> n >> m;
  long long answer = 0;
  
  vector<pair<long long, long long>> pairs(n);
  for (int i = 0; i < n; i++) {
    long long first, second; cin >> first >> second;
    pairs[i] = make_pair(first, second);
  }
  
  sort(pairs.begin(), pairs.end());
  
  for (int i = 0; i < n; i++) {
    if (pairs[i].second < m) {
      answer += pairs[i].first * pairs[i].second;
      m -= pairs[i].second;
    } else {
      answer += pairs[i].first * m;
      break;
    }
  } 
  
  cout << answer << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
	int W,H,x,y,r;
	int flg = 1;

	while( scanf("%d %d %d %d %d %d", &W, &H, &x, &y, &r) != EOF ){}

	if(x - r < 0) flg = 0;
	if(y - r < 0) flg = 0;
	if(x + r > W) flg = 0;
	if(y + r > H) flg = 0;

	if(flg) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 584
import java.util.Arrays;
import java.util.Scanner;

/**
 * Voting Judges
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            long M = sc.nextLong();
            int V = sc.nextInt();
            int P = sc.nextInt();
            long[] A = new long[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextLong();
            }

            Arrays.sort(A);

            long[] S = new long[N];
            for (int i = 0; i < N; i++) {
                if (i == 0) {
                    S[i] = A[i];
                } else {
                    S[i] = S[i - 1] + A[i];
                }
            }

            long ans = -1;

            for (int i = 0; i < N; i++) {
                long K = A[i] + M;

                if (K < A[N - P]) {
                    continue;
                }

                long x = M * V - M * (P + i) - (K * (N - P - i) - (S[N - P] - S[i]));
                if (x <= 0) {
                    ans = N - i;
                    break;
                }
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 58352
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n, k;
vi a;

int main()
{
    cin >> n >> k;
    a.resize(n);
    rep(i, n) cin >> a[i];

    int ans = ceil((float)(n - 1) / (k - 1));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;
 
import static java.util.Comparator.*;
 
public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==================================================================
    public void solve() {
    	int A = Integer.parseInt(sc.next());
    	int B = Integer.parseInt(sc.next());
    	if(A == 1 && B == 2)		out.println(3);
    	else if(A == 1 && B == 3)	out.println(2);
    	else if(A == 2 && B == 1)	out.println(3);
    	else if(A == 2 && B == 3)	out.println(1);
    	else if(A == 3 && B == 1)	out.println(2);
    	else if(A == 3 && B == 2)	out.println(1);
    }
}

Measured memory_bytes: 21332
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353

def get_factorials(max, mod=None):
    """
    階乗 0!, 1!, 2!, ..., max!
    :param int max:
    :param int mod:
    """
    ret = [1]
    n = 1
    if mod:
        for i in range(1, max + 1):
            n *= i
            n %= mod
            ret.append(n)
    else:
        for i in range(1, max + 1):
            n *= i
            ret.append(n)
    return ret


def mod_invs(max, mod):
    """
    逆元 0, 1/1, 1/2, 1/3, ..., 1/max
    :param int max:
    :param int mod:
    """
    invs = [1] * (max + 1)
    invs[0] = 0
    for x in range(2, max + 1):
        invs[x] = (-(mod // x) * invs[mod % x]) % mod
    return invs


def factorial_invs(max, mod):
    """
    階乗 0!, 1!, 2!, ..., max! の逆元
    :param int max:
    :param int mod:
    """
    ret = [1]
    r = 1
    for inv in mod_invs(max, mod)[1:]:
        r = r * inv % mod
        ret.append(r)
    return ret


class Combination:
    def __init__(self, max, mod):
        """
        :param int max:
        :param int mod: 3 以上の素数であること
        """
        self._factorials = get_factorials(max, mod)
        self._finvs = factorial_invs(max, mod)
        self._mod = mod

    def ncr(self, n, r):
        """
        :param int n:
        :param int r:
        :rtype: int
        """
        if n < r:
            return 0
        return self._factorials[n] * self._finvs[r] % self._mod * self._finvs[n - r] % self._mod


finvs = factorial_invs(2 * 10 ** 5 + 100, MOD)


def ncr(n, r):
    ret = 1
    for _ in range(r):
        ret *= n
        ret %= MOD
        n -= 1
    return ret * finvs[r] % MOD


N, A, B = list(map(int, sys.stdin.buffer.readline().split()))

comb = Combination(2 * 10 ** 5 + 100, MOD)
ans = pow(2, N, MOD) - 1
ans -= ncr(N, A)
ans -= ncr(N, B)
print(ans % MOD)


Measured memory_bytes: 75764
n, m = map(int, input().split())
a_lst = list(map(int, input().split()))
bc_lst = [list(map(int, input().split())) for _ in range(m)]

sorted_a = sorted(a_lst)
sorted_bc = sorted(bc_lst, key = lambda x: -x[1])

bc_index = 0
bc_count = 1
bc = sorted_bc[bc_index]
for i in range(n):
    if sorted_a[i] < bc[1]:
        sorted_a[i] = bc[1]
    else:
        break
    if bc[0] == bc_count:
        bc_count = 1
        bc_index += 1
        if len(sorted_bc) == bc_index:
            break
        else:
            bc = sorted_bc[bc_index]
    else:
        bc_count += 1
print(sum(sorted_a))

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

using namespace std;

typedef pair<int, int> II;
typedef pair<long long, int> LLI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<II> VII;

#define For(i,a,b) for(int i = a;i <= b; i++)
#define Rep(i,a,b) for(int i = a;i >= b; i--)
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, f) for(auto i : f)
#define fi first
#define se second
#define pb push_back
#define sz(s) int(s.size())
#define reset(f, x) memset(f, x, sizeof(f))
#define all(x) x.begin(), x.end()
#define two(x) (1LL << x)
#define getbit(x, i) ((x >> (i-1)) & 1LL)
#define onbit(x, i) (x | (1LL << (i-1)))
#define offbit(x, i) (x & ~(1 << (i-1)))

const int N = 2e5+1;

int a[N], n;

int main() {
    ios_base::sync_with_stdio(false);
    //freopen("in.txt","r",stdin);
    //freopen("","w",stdout);
    cin >> n;
    LL res = 0;
    For(i, 1, n) cin >> a[i];
    int j = 1;
    int sum = 0, sor = 0;
    For(i, 1, n) {
        sum += a[i];
        sor ^= a[i];
        while (sum != sor) {
            sum -= a[j];
            sor ^= a[j];
            j++;
        }
        res += i-j+1;
    }
    cout << res;
}




Measured memory_bytes: 1024
def get_int(): return int(input())
def get_float(): return float(input())
def get_line(): return input().split()
def get_lines(v): return [get_line() for _ in range(v)]
def get_int_line(): return list(map(int, get_line()))
def get_int_lines(v): return [get_int_line() for _ in range(v)]
def get_float_line(): return list(map(float, get_line()))
def get_float_lines(v): return [get_float_line() for _ in range(v)]

import functools
import math

def gcd(a, b):
  if (b == 0): return a
  else: return gcd(b, a % b)


N = get_int()
A = get_int_line()

print(functools.reduce(gcd, A))

Measured memory_bytes: 14676
import numpy as np

n = int(input())
a = str(input())
array = [int(s) for s in a.split()]
sum = 0
difference = 0
index = 0

avarage = np.average(array)

for i, a in enumerate(array):
    tmp_diff = abs(a-avarage)
    if i == 0:
        difference = tmp_diff
        index = 0
    else:
        if difference > tmp_diff:
            difference = tmp_diff
            index = i

print(index)

Measured memory_bytes: 20436
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
typedef long long LL;

LL n,m,k;

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> m >> k;
	if(k <= n){
		cout << n - k << ' ' << m << endl;
		return 0;
	}
	cout << 0 << ' ' << max(0LL,m + n - k) << endl;
	return 0;
}

Measured memory_bytes: 256
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
const int N = 100005;
using namespace std;

int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  ll n,ans = 1,r,c;
  cin >> n;
  vector <ll> v;
  for (ll i = 1; i <= sqrt(n) ; ++i)
  {
    if(n%i == 0)
    {
      if (n/i == i)
      {
        v.pb(i);
      }
      else
      {
        v.pb(n/i);
        v.pb(i);
      }
    }
  }
  sort(v.begin(),v.end());
  if(v.size()% 2 == 0)
  {
    r = v[v.size()/2 -1];
    c = v[v.size()/2];
  }
  else
  {
    r = v[v.size()/2];
    c = v[v.size()/2];
  }
  ans = abs(1-r)+abs(1-c);
  cout << ans;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using  namespace std;
#define    ll  long long int
ll fre[11];
int main( )
{
    ll N,x, k, mx = -1,sum=0;
    int a[100010], b[100010];
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> b[i];
    }

    for (int i = 0; i < N; i++)
    {
         sum = 0;
        for (int j = 0; j <= i; j++)
        {
            sum += a[j];
        }
        for (int j = i; j < N; j++)
        {
            sum += b[j];
        }
        mx = max(mx, sum);
    }
    cout << mx<< endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        s += s;
        String p = sc.nextLine();

        if(s.contains(p)) {
        	System.out.println("Yes");
        } else {
        	System.out.println("No");
        }
    }
}


Measured memory_bytes: 26288
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        char c = sc.NextChar();

        string answer = (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') ? "vowel" : "consonant";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
//#include <bits/stdc++.h>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007


#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(int a,int b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 

 
int main() {
    ll N;
    cin >> N ;
    ll a[N];

    double sum=0;
  FOR(i,0,N-1){
    cin>>a[i];
    sum=sum+a[i];
  }

  double avg=sum/N;
  double min =999;
  int ans;

  FOR(i,0,N-1){
    double sabun;
    if(a[i]>avg){
      sabun =a[i]-avg;
    }else{
      sabun =-a[i]+avg;
    }


    if(min>sabun){
      min=sabun;
      ans=i;
    }
  }

    cout<<ans<<endl;

  return 0;
}





Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int M = GetInt();
		int[] s = new int[M];
		int[] c = new int[M];
		for(int i = 0; i < M; i++)
		{
			s[i] = GetInt() - 1;
			c[i] = GetInt();
		}

		if(M == 0)
		{
			switch(N)
			{
				case 1:
					WriteLine(0);
					return;

				case 2:
					WriteLine(10);
					return;

				case 3:
					WriteLine(100);
					return;
			}
		}

		int[] ans = new int[N];
		ans[0] = 1;
		for(int i = 0; i < M; i++)
		{
			if(s[i] >= N || (N > 1 && s[i] == 0 && c[i] == 0))
			{
				WriteLine(-1);
				return;
			}
			ans[s[i]] = c[i];

			for(int j = i + 1; j < M; j++)
			{
				if(s[i] == s[j] && c[i] != c[j])
				{
					WriteLine(-1);
					return;
				}
			}
		}
		WriteLine(string.Concat(ans));
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<map>
#include<cstring>
#include <stack>
#include <numeric>
#include<climits>
#include<cmath>
#include<set>
#include<unordered_set>
#include<iomanip>
#include<queue>
#include<unordered_map>
#define vi vector<float>
#define vl vector<long long>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define loop(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair<float,float>
#define umap unordered_map<ll,float>
using namespace std;

#define xx first
#define yy second

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

// #ifndef ONLINE_JUDGE
// 	freopen("in.txt", "r", stdin);
// 	freopen("out.txt", "w", stdout);
// #endif

	int n, r;
	cin >> n >> r;

	if (n >= 10) {
		cout << r << endl;
	} else {
		cout << r + 100 * (10 - n) << endl;
	}







	return 0;
}










Measured memory_bytes: 256
#include<stdio.h>

int main(int argc,char** argv){
        int dataset,i,j;
        int data[11][11];
        scanf("%d",&dataset);
        while(dataset!=0){
                for(i=0;i<=dataset;i++)
                        for(j=0;j<=dataset;j++)
                                data[i][j]=0;
                for(i=0;i<dataset;i++){
                        for(j=0;j<dataset;j++){
                                scanf("%d",&data[i][j]);
                                data[i][dataset]+=data[i][j];
                                data[dataset][j]+=data[i][j];
                        }
                        data[dataset][dataset]+=data[i][dataset];
                }
                for(i=0;i<=dataset;i++){
                        for(j=0;j<=dataset;j++)printf("%5d",data[i][j]);
                        printf("\n");
                }
                scanf("%d",&dataset);
        }
        return 0;       
}

Measured memory_bytes: 0
import java.util.*;class Main{public static void main(String[]g){Scanner S=new Scanner(System.in);int i;for(double x,y,a[]=new double[6];S.hasNext();System.out.printf("%.3f %.3f\n",x,y)){for(x=y=i=0;i<6;)a[i++]=S.nextInt();if(a[1]==0&&a[4]==0){x=a[0]==0?a[5]/a[3]:a[2]/a[0];}else{if(a[0]!=0&&a[3]!=0){x=a[0];for(i=0;i<6;a[i]*=i++>2?x:a[3]);for(i=0;i<3;)a[i]-=a[i+++3];}if(a[0]!=0){y=a[5]/a[4];x=(a[2]-y*a[1])/a[0];}if(a[3]!=0){y=a[2]/a[1];x=(a[5]-y*a[4])/a[3];}}x=x==-0?0:x;y=y==-0?0:y;}}}


Measured memory_bytes: 26532
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
 
typedef enum { top, south, east, west, north, bottom, NUM_SIDES } sides;
 
int checkDice(const int dice0[], const int dice1[])
{
    int i, flag = 1;
 
    for( i = 0; i < NUM_SIDES && flag; ++i )
        if( dice0[i] != dice1[i] )
            flag = 0;
 
    return flag;
}
 
sides getOperator()
{
    return rand() % north + 1;
}
 
void roll(int *dice, const sides operator)
{
    int anti_op;
    switch( operator ){
    case south: anti_op = north; break;
    case east: anti_op = west; break;
    case west: anti_op = east; break;
    case north: anti_op = south; break;
    default: break;
    }
 
    int tmp = dice[operator];
    dice[operator] = dice[top];
    dice[top] = dice[anti_op];
    dice[anti_op] = dice[bottom];
    dice[bottom] = tmp;
}
 
int main()
{
    int i;
 
    srand(time(0));
 
    int dice0[NUM_SIDES], dice1[NUM_SIDES];
    for( i = 0; i < NUM_SIDES; ++i )
        scanf("%d", &dice0[i]);
    for( i = 0; i < NUM_SIDES; ++i )
        scanf("%d", &dice1[i]);
 
    sides operator = getOperator();
    while( dice0[top] != dice1[top] || dice0[south] != dice1[south] ){
        roll(dice1, operator);
        operator = getOperator();
    }
 
    if( checkDice(dice0, dice1) ) printf("Yes\n");
    else printf("No\n");
 
    return 0;
}

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

class Dice {
  private:
    int *numbers;
  public:
    Dice(int *numbers) {
      this->numbers = numbers;
    }

    int getCurrentNumber() {
      return this->numbers[0];
    }

    void turn(char direction) {
      switch (direction) {
        case 'N':
          this->turnNorth();
          break;
        case 'S':
          this->turnSouth();
          break;
        case 'E':
          this->turnEast();
          break;
        case 'W':
          this->turnWest();
          break;
      }
    }

    void turnNorth() {
      swap(this->numbers[0], this->numbers[1]);
      swap(this->numbers[1], this->numbers[5]);
      swap(this->numbers[5], this->numbers[4]);
    }

    void turnSouth() {
      swap(this->numbers[0], this->numbers[4]);
      swap(this->numbers[4], this->numbers[5]);
      swap(this->numbers[5], this->numbers[1]);
    }

    void turnEast() {
      swap(this->numbers[0], this->numbers[3]);
      swap(this->numbers[3], this->numbers[5]);
      swap(this->numbers[5], this->numbers[2]);
    }

    void turnWest() {
      swap(this->numbers[0], this->numbers[2]);
      swap(this->numbers[2], this->numbers[5]);
      swap(this->numbers[5], this->numbers[3]);
    }
};

int main() {
  int numbers[6];
  char direction;
  string directions;

  for (int i = 0; i < 6; i++) {
    cin >> numbers[i];
  }
  cin >> directions;

  Dice dice(numbers);
  for (int i = 0; i < directions.size(); i++) {
    dice.turn(directions[i]);
  }

  cout << dice.getCurrentNumber() << endl;

  return 0;
}

Measured memory_bytes: 1204