akhauriyash/Code-Regression huggingface dataset:
S = input()
T = input()


def count_diff_chars(s, t):
    """
    文字列s, tの差分がある文字列数を数える
    """
    count = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            count += 1
    return count


def count_diff_chars_t(s): return count_diff_chars(s, T)


len_s = len(S)
len_t = len(T)


if len_s == len_t:
    print(count_diff_chars_t(S))
else:
    now_min_diff = 1001

    for i in range(len_s - len_t):
        s_ = S[i: len_t + i]
        diff_num = count_diff_chars_t(s_)
        now_min_diff = min(diff_num, now_min_diff)

    print(now_min_diff)


Measured memory_bytes: 9136
import java.util.*;
import java.lang.*;

public class Main{
	static Tree tree;
	static boolean[] visited;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		tree = new Tree(n);
		for (int i = 0; i < n - 1; i++) {
			tree.union(sc.nextInt() - 1, sc.nextInt() - 1);
		}
		for (int i = 0; i < q; i++) {
			tree.node[sc.nextInt() - 1].value += sc.nextInt();
		}
		visited = new boolean[n];
		visited[0] = true;
		dfs(0);
		for (int i = 0; i < n - 1; i++) {
			System.out.print(tree.node[i].value + " ");
		}
		System.out.println(tree.node[n - 1].value);
	}
	static void dfs(int n) {
		visited[n] = true;
		for (int key : tree.node[n].list) {
			if (!visited[key]) {
				visited[key] = true;
				tree.node[key].value += tree.node[n].value;
				dfs(key);
			}
		}
	}
}

class Node {
	ArrayList<Integer> list;
	int value;
	Node() {
		list = new ArrayList<>();
		value = 0;
	}
}

class Tree {
	Node[] node;
	Tree(int n) {
		node = new Node[n];
		for (int i = 0; i < n; i++) {
			node[i] = new Node();
		}
	}
	void union(int n, int m) {
		node[n].list.add(m);
		node[m].list.add(n);
	}
}

Measured memory_bytes: 234140
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

int main() {
	string N; cin >> N;
	if (N[0] == '9' || N[1] == '9') {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

int main(){
	double A,B,T;
	cin>>A>>B>>T;
	T += .5;
	int count = 0;
	for(double t=A; t<=T; t+=A){
		count += B;
	}
	ote(count);
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    map<string,int> mp;
    while(n--)
    {
        string verdict;
        cin>>verdict;
        //cout<<"INP: "<<verdict<<endl;
        mp[verdict]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>

typedef long long ll;

using namespace std;

int main(){
  ll n, ans = 1e15;
    cin >> n;
    for (ll i = 2; i * i <= n; i++){
        if (n % i == 0){
            if (n / i + i - 2 < ans){
                ans = n / i + i - 2;
            }
        }
    }
    if (ans == 1e15)
        ans = n - 1;
    cout << ans;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int rf()
{
	int r;int s=0,c;
	for(;!isdigit(c=getchar());s=c);
	for(r=c^48;isdigit(c=getchar());
	(r*=10)+=c^48);
	return s^45?r:-r;
}
//#define int long long
#define N
int n;
//int head[N<<1],nxt[N<<1],ver[N<<1],top=0;
//int val[N<<1];
/*
void add(int x,int y)
{
	 nxt[++top]=head[x];
	 head[x]=top;
	 ver[top]=y;
	 //val[top]=v;
}
*/
int a[60];
long long sum=0;
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n=rf();
  	for(int i=1;i<=n;i++)
      	a[i]=rf();
  	for(int i=1;i<n;i++)
      	for(int j=i+1;j<=n;j++)
          	sum+=a[i]*a[j];
  	cout<<sum;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);
            int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            long[] dp = Enumerable.Repeat(long.MaxValue, n).ToArray();
            dp[0] = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = 1; i + j < n && j <= k; j++)
                {
                    dp[i + j] = Math.Min(dp[i + j], dp[i] + Math.Abs(nums[i + j] - nums[i]));
                }
            }
            Console.WriteLine(dp[n - 1]);
        }
    }
}

Measured memory_bytes: 21216
import java.util.*;
public class Main {
    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        int N = in.nextInt();
        int[] c = {0,0,0,0,0,0,0,0,0};
        for(int i = 0; i < N;c[Math.min(in.nextInt() / 400, 8)]++, i++);
        int sum = (int)Arrays.stream(Arrays.copyOf(c, 8)).filter(a -> a > 0).count();
        System.out.println(Math.max(1,  sum) + " " + (sum + c[8]));
    }
}

Measured memory_bytes: 29012
import java.util.*;
class Main 
{
	public static void main(String[]args)
	{
		Scanner sc=new Scanner(System.in);
		String str=sc.nextLine();
		int count=0;
		for(int i=0;i<str.length();i++)
		{
			if(str.charAt(i)=='1')
				count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    ll h,n,sum=0;
    cin>>h>>n;
    rep(i,n){
        ll t;cin>>t;
        sum+=t;
    }
    if(sum>=h)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
def f_dp(x, h):
    dp = [0 for i in range(x)]
    dp[0] = 0
    for i in range(1, x):
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1])
        if i >= 2:
            dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
    return dp

if __name__ == "__main__":
    n = int(input())
    h = list(map(int,input().split()))
    dp = f_dp(n, h)

    print(dp[n - 1])

Measured memory_bytes: 52800
<?php
	fscanf(STDIN, "%d %d %d %d", $a, $b, $h, $m);
$arg_h = $h * -2 * M_PI / 12 + $m * -2*M_PI/12/60;
$arg_m = $m * -2 * M_PI / 60;

function crd($r, $arg){
  return [$r*cos($arg), $r*sin($arg)];
};

$arr_h = crd($a, $arg_h);
$arr_m = crd($b, $arg_m);

$x = $arr_h[0] - $arr_m[0];
$y = $arr_h[1] - $arr_m[1];
  
echo sqrt($x**2+$y**2);

?>



Measured memory_bytes: 16664
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e933
#define INFL 1e18
#define MOD 1e9+7
#define pb push_back
#define MP make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main() {
    int N,W;
    cin>>N>>W;
    vector<vector<int>> dp(N+1,vector<int>(W+1,0));
    
    rep(i,0,N){
        int v,w;
        cin>>v>>w;
        rep(j,0,W+1){
            if(j<w)dp[i+1][j]=dp[i][j];
            else dp[i+1][j]=max(dp[i][j],dp[i][j-w]+v);
        }
    }
    cout<<dp[N][W]<<endl;
    return 0;
}



Measured memory_bytes: 6824
/*

Author : @karngyan
Team : BlundersPride
Date : 02-03-2019
Time : 00:02:04

*/


#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair

signed main()
{
	fast;
////////////////////////////////////////////////////////////////////////////////////////////
	
	ll a ,b , c;
	cin >> a >> b >> c;
	ll ans = 0;
	while(1)
	{
		if(b-a < 0)
			break;
		b = b - a;
		ans++;
		if(ans == c)
			break;
	}
	cout<<ans<<endl;






////////////////////////////////////////////////////////////////////////////////////////////
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main () {
  int n;
  cin >> n;
  long long *a = new long long[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long x, y, z;
  x = a[0];
  y = a[0];
  z = 0;
  for (int j = 0; j < n; j++) {
    x = min(x, a[j]);
    y = max(y, a[j]);
    z += a[j];
  }
  cout << x << " " << y << " " << z <<endl;
  delete[] a;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll L, R, d;
    cin >> L >> R >> d;
    ll ans = 0;
    for (ll i = L; i <= R; i++) {
        if (i % d == 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define N 400005
using namespace std;

int n,m,cnt,tot,num[N],fst[N],pnt[N],nxt[N],dgr[N],a[N],b[N]; bool vis[N];
map<int,int> mp;
void add(int x,int y){
	dgr[x]++;
	pnt[++tot]=y; nxt[tot]=fst[x]; fst[x]=tot;
}
void dfs(int x){
	int i,y; vis[x]=1;
	for (i=fst[x]; i; i=nxt[i]){
		y=pnt[i];
		if (!vis[y]) dfs(y);
	}
}
int main(){
	scanf("%d",&n);
	int i; n++;
	for (i=1; i<n; i++){
		scanf("%d",&a[i]); a[n]^=a[i];
	}
	for (i=1; i<n; i++) {
		scanf("%d",&b[i]); b[n]^=b[i];
	}
	for (i=1; i<=n; i++){
		if (!mp[a[i]]) mp[a[i]]=++cnt; a[i]=mp[a[i]];
		if (!mp[b[i]]) mp[b[i]]=++cnt; b[i]=mp[b[i]];
	}
	for (i=1; i<=n; i++) num[a[i]]++;
	for (i=1; i<=n; i++) num[b[i]]--;
	for (i=1; i<=cnt; i++) if (num[i]) break;
	if (i<=cnt){ puts("-1"); return 0; }
	int ans=0;
	for (i=1; i<=n; i++) num[a[i]]++;
	for (i=1; i<=n; i++) if (a[i]!=b[i]){
		add(a[i],b[i]); add(b[i],a[i]);
		if (i<n) ans++; else ans--;
	} else if (i==n && num[a[i]]>1) ans--;
	for (i=1; i<=cnt; i++) if (!vis[i] && dgr[i]){
		ans++; dfs(i);
	}
	printf("%d\n",max(ans,0));
	return 0;
}


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

const int MAX = 300;
int main() {
	int N;
	string S[MAX], tmp;
	cin >> N;
	for (int i = 0;i < N;i ++) cin >> S[i];
	
	int correct = 0;
	for (int i = 0;i < N;i ++) { // Aに当たる
		bool isCorrect = true;
		for (int j = 0;j < N;j ++) {
			for (int k = 0;k < N;k ++) {
				if (S[j][k] != S[k][j]) isCorrect = false;
			}
		}
		if (isCorrect) correct ++;
		tmp = S[0];
		for (int j = 1;j < N;j ++) {
			S[j - 1] = S[j];
		}
		S[N - 1] = tmp;
	}
	cout << correct * N;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

実験。後で説明
*/

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <cstdlib>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); };

bool chmin(double&a,int b){return a>b?(a=b,true):false;}
bool chmax(double&a,double b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int inf = TEN(9) + 10;
const int mod = TEN(9) + 7;

int A, B, C, D, E, F;

signed main()
{
	cin>>A>>B>>C>>D>>E>>F;
	double mx = -1;
	int ans, sugar;
	for (int i = 0; i <= 70; ++i) { // A
		for (int j = 0; j <= 70; ++j) { // B
			for (int k = 0; k <= 3000; ++k) { // D
				int w = 100*(A*i+B*j)+D*k;
				int can_melt = E*(A*i+B*j);
				if (w <= F and can_melt >= D * k) {
					int l = min((F - w) / C, (can_melt - D*k) / C);
					if ((100*A*i+100*B*j+C*l+D*k) == 0.0) {
						continue;
					}
					double concentration = 100.0*(C*l+D*k) / (double)(100*A*i+100*B*j+C*l+D*k);
					if (chmax(mx, concentration)) {
						ans = 100*A*i+100*B*j+D*k+C*l;
						sugar = D*k+C*l;
					}
				}
			}
		}
	}
	printf("%lld %lld\n",ans,sugar);
}


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

ans = 0
for i in range(N - 1):
    a = S[:i + 1]
    b = S[i + 1:]
    count = 0
    for j in range(97, 123):
        if chr(j) in a and chr(j) in b:
            count += 1
    if count > ans:
        ans = count
print(ans)


Measured memory_bytes: 9048
H,W=map(int,raw_input().split())
a=max([H,W]);b=min([H,W])

if H%3==0 or W%3==0:ans=0
else:
	ans=H*W
	for i in range(a/2+1):
		s1=b*i
		if (a-i)%2==0:
			s2=[(a-i)/2*b]
		else:
			s2=[(a-i)/2*b,(a-i)/2*b+b]
		if b%2==0:
			s3=[(a-i)*(b/2)]
		else:
			s3=[(a-i)*(b/2),(a-i)*(b/2)+(a-i)]

		vx=max([s1,max(s2)])
		vn=min([s1,min(s2)])
		px=max([s1,max(s3)])
		pn=min([s1,min(s3)])

		ans=min([ans,vx-vn,px-pn])

	for i in range(b/2+1):
		s1=a*i
		if (b-i)%2==0:
			s2=[(b-i)/2*a]
		else:
			s2=[(b-i)/2*a,(b-i)/2*a+a]
		if a%2==0:
			s3=[(b-i)*(a/2)]
		else:
			s3=[(b-i)*(a/2),(b-i)*(a/2)+(b-i)]

		vx=max([s1,max(s2)])
		vn=min([s1,min(s2)])
		px=max([s1,max(s3)])
		pn=min([s1,min(s3)])

		ans=min([ans,vx-vn,px-pn])

print ans

Measured memory_bytes: 4356
/**
*    created: 25.07.2020 06:24:27
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8]={0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8]={1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

void gridbfs(int i,int j,vector<string> s,vector<vector<int>> &dis) {
    int h = s.size(), w = s[0].size();
    queue<vector<int>> q; q.push({i,j});
    dis[i][j] = 0;
    while (!q.empty()) {
        auto v = q.front(); q.pop();
        if (v[0] > 0 && s[v[0] - 1][v[1]] == '.' && dis[v[0] - 1][v[1]] == -1) {
           dis[v[0] - 1][v[1]] = dis[v[0]][v[1]] + 1;
           q.push({v[0] - 1, v[1]});
        }
        if (v[1] > 0 && s[v[0]][v[1] - 1] == '.' && dis[v[0]][v[1] - 1] == -1) {
           dis[v[0]][v[1] - 1] = dis[v[0]][v[1]] + 1;
           q.push({v[0], v[1] - 1});
        }
        if (v[0] < h - 1 && s[v[0] + 1][v[1]] == '.' && dis[v[0] + 1][v[1]] == -1) {
            dis[v[0] + 1][v[1]] = dis[v[0]][v[1]] + 1;
            q.push({v[0] + 1, v[1]});
        }
        if (v[1] < w - 1 && s[v[0]][v[1] + 1] == '.' && dis[v[0]][v[1] + 1] == -1) {
            dis[v[0]][v[1] + 1] = dis[v[0]][v[1]] + 1;
            q.push({v[0], v[1] + 1});
        }
    }
    return;
}

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int h, w; cin >> h >> w;
    vector<string> v(h);
    int bcnt = 0;
    rep(i,h) cin >> v[i];
    rep(i,h) rep(j,w) if (v[i][j] == '#') bcnt++;
    vector<vector<int>> dis(h,vector<int>(w,-1));
    gridbfs(0,0,v,dis);
    if (dis[h-1][w-1] == -1) cout << -1 << endl;
    else cout << h * w - bcnt - dis[h-1][w-1] - 1 << endl;
    return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#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 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

vector<char> ch(1000001, 2);

char check(int m){
	FOR(i, 2, sqrt(m)){
		if(m%i==0) return 1;
	}
	
	return 2;
}

int main(){
	ch[0]=ch[1]=1;
	FOR(i, 2, 1000001){
		if(ch[i]==1) continue; 
		
		for(int j=2*i; j<=1000000; j+=i){
			ch[j]=1;
		}
	}
	
	while(1){
		int n, x;
		scanf("%d%d", &n, &x);
		if(n==0) return 0;
		
		vector<int> v(n);
		REP(i, n) scanf("%d", &v[i]);
		
		vector<vector<char> > dp(n+1, vector<char>(x+1, 0));
		dp[0][0]=1;
		REP(i, n){
			REP(j, x+1){
				if(dp[i][j]!=0){
					dp[i+1][j]=dp[i][j];
				}
				else {
					if(j>=v[i] && dp[i+1][j-v[i]]!=0){
						dp[i+1][j]=ch[j];
					}
				}
			}
		}
		
		int ans=-1;
		REP(i, x+1) if(dp[n][i]==2) ans=i;
		
		if(ans!=-1) cout << ans << endl;
		else cout << "NA" << endl;
	}
}

Measured memory_bytes: 33404
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void chmin(int &a, int b) { if (b < a) a = b; }
bool check(string &x, string &y, int n){
    int nx = x.length(), ny = y.length();
    bool res = 1;
    for(int i = max(n,4000); i < min(n+nx,4000+ny); i++) if(x[i-n]!='?' && y[i-4000]!='?' && x[i-n]!=y[i-4000]) res = 0;
    return res;
}

int main(){
    string a, b, c; cin >> a >> b >> c;
    int na = a.length(), nb = b.length(), nc = c.length();
    vector<bool> ab(8000), ac(8000), bc(8000);
    rep(i,8000){ ab[i] = check(a,b,i); ac[i] = check(a,c,i); bc[i] = check(b,c,i); }
    int ans = 6000;
    rep(i,8000) rep(j,8000) if((abs(i-j)>=2000 || ab[4000+i-j]) && ac[i] && bc[j]) chmin(ans,max({i+na,j+nb,4000+nc})-min({i,j,4000}));
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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 main(){
	int n,k,in;
	cin >> n >> k;
	vector<int> x;
	REP(i,n){
		cin >> in;
		x.push_back(in);
	}
	
	ll ans = 1LL<<60;
	for(int i=0; i<n-k+1; i++){
		int a=0;
		a = abs(x[i]) + abs(x[i+k-1]-x[i]);
		chmin(a, abs(x[i+k-1]) + abs(x[i+k-1]-x[i]));
		chmin(ans, (ll)a);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3768
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        String ans = "Yes";
        int a[] = new int[n]; 
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
            //System.out.println("a[i]"+a[i]);
        }
        double sum = 0;
        for(int i = 0; i < a.length; i++){
            sum += a[i];
            //System.out.println("sum"+sum);
            
        }
        if(sum < h){
                ans = "No";
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 49036
# 入力の受け取り
D, G = [int(i) for i in input().split()]
p = []
c = []
num_solves = []
for i in range(D):
    p_i, c_i = [int(i) for i in input().split()]
    p.append(p_i)
    c.append(c_i)

# 完答時のスコアを算出しておく
cs = []
for i in range(D):
    cs.append(100 * (i + 1) * p[i] + c[i])

# 完答する問題を全探索する
for i in range(2 ** D):
    score = 0
    num_solve = 0
    not_complete = []
    for j in range(D):
        # 完答する場合は完答時のスコアと問題数を加算する。
        if i >> j & 1:
            score += cs[j]
            num_solve += p[j]
        else:
            not_complete.append(j)
    # 目標を超えているか判定する。
    if score >= G:
        num_solves.append(num_solve)
    else:
        # 目標を超えていなければ、点数の高い順にスコアを加算していく。ただし完答はしないので解く問題数は最大p_i -1 
        for np in reversed(not_complete):
            for n in range(p[np]-1):
                score += 100 * (np + 1)
                num_solve += 1
                if score >= G:
                    num_solves.append(num_solve)
                    break
            if score >= G:
                break
# 解いた問題数の最小値を出力する
print(min(num_solves))

Measured memory_bytes: 3064
# abc_95_c
# import sys
from sys import stdin
A, B, C, X, Y = [int(x) for x in stdin.readline().rstrip().split()]
ans1 = 0
# ans2 = 0
if C < (A/2)+(B/2):
    if X > Y:
        ans1 = C*2*min(X, Y)+(max(X, Y)-min(X, Y))*A
    else:
        ans1 = C*2*min(X, Y)+(max(X, Y)-min(X, Y))*B
else:
    ans1 = A*X+B*Y
ans2 = C*2*max(X, Y)
print(min(ans1, ans2))


Measured memory_bytes: 3064
/*
ID: amagica1
TASK: ariprog
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define NINF -INF
#define mp make_pair
#define boost() cin.tie(0); cin.sync_with_stdio(0)
#define For(i, a, b) for(int i=a; i<b; i++)
#define FOR(i, a, b) for(int i=a; i<=b; i++)
#define Rev(i, a, b) for(int i=a; i>b; i--)
#define REV(i, a, b) for(int i=a; i>=b; i--)
typedef long long ll;
typedef long double ld;
typedef int64_t l;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int MAXN = 100005;
ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
int main() {
    //-----------FILE------------//
    // freopen("ariprog.in", "r", stdin);
    // freopen("ariprog.out", "w", stdout);
    //----------------------------//
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if(a1+a2+a3 >= 22) printf("bust\n");
    else printf("win\n");
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b,c,d,e,f = LI()
    ans = 0
    p = [100*a,0]
    n = 31
    for x in range(n):
        A = a*x
        for y in range(n):
            B = b*y
            s = A+B
            r = min(f-100*s,s*e)
            if r > 0:
                for z in range(r+1):
                    C = c*z
                    rest = r-C
                    if rest < 0:
                        break
                    w = rest//d
                    D = d*w
                    res = (C+D)/(100*s+C+D)
                    if ans < res:
                        ans = res
                        p[0] = 100*s+C+D
                        p[1] = C+D
    print(*p)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39152
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(2000005);

mint g(int r, int c){
    return comb(r+c+2,r+1)-1;
}

int main(){
    ll r1,r2,c1,c2;
    cin >> r1>> c1>> r2>> c2;
    r1--;c1--;
    mint ans=g(r2,c2)-g(r2,c1)-g(r1,c2)+g(r1,c1);
    cout<<ans.x<<endl;
    return 0;
}



Measured memory_bytes: 31488
from itertools import accumulate

N = int(input())
a = list(map(int, input().split()))

s = list(accumulate(a))

ans = abs(2 * s[0] - s[-1])
for i in range(N-1):
    ans = min(ans, abs(2 * s[i] - s[-1]) )
    
print(ans)

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 200005;
int N, K;
int A[MAX_N], F[MAX_N];

bool check(int af)
{
  int ret = 0;
  REP(n,N) {
    if(A[n]*F[n] > af) {
      int x = af/F[n];
      ret += A[n] - x;
    }
  }
  return ret <= K;
}

signed main()
{
  cin >> N >> K;
  REP(n,N) {
    cin >> A[n];
  }
  REP(n,N) {
    cin >> F[n];
  }

  sort(F, F+N, greater<int>());
  sort(A, A+N);

  int l = -1, r = INF_LL;
  while(r-l>1) {
    int mid = (l+r)/2;
    if(check(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }

  cout << r << endl;

  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
int n,ans=0;
vector<int> a(15,0);
vector<bool> f(15,0);
vector<vector<int>> x(15,vector<int>(15)),y(15,vector<int>(15));

int dfs(int nn){
  if(nn==n){
    int flag=1,count=0;
    for(int j=0;j<n;j++){
      //cout<<f.at(j)<<" ";
      if(f.at(j)){
        count++;
        for(int k=0;k<a.at(j);k++){
          //cout<<"["<<y.at(j).at(k)<<"]";
          if(y.at(j).at(k)){
            //cout<<"[["<<x.at(j).at(k)-1<<"]]";
            if(!f.at(x.at(j).at(k)-1)) flag=0;
          }else{
            if(f.at(x.at(j).at(k)-1)) flag=0;
          }
        }
      }
    }
    if(flag) ans=max(ans,count);
    //cout<<ans<<endl;
    return 0;
  }
  f.at(nn)=0;
  dfs(nn+1);
  f.at(nn)=1;
  dfs(nn+1);
  return 0;
}

int main(){
  cin>>n;
  REP(i,n){
    cin>>a.at(i);
    REP(j,a.at(i)){
      cin>>x.at(i).at(j);
      cin>>y.at(i).at(j);
    }
  }
  dfs(0); 
  cout<<ans;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var line string
	fmt.Scan(&line)

	dic := map[string]struct{}{}

	for _, r := range line {
		if _, ok := dic[string(r)]; !ok {
			dic[string(r)] = struct{}{}
		}
	}

	count := 0
	for {
		strs := line[:len(line)-count]
		for i := 'a'; i <= 'z'; i++ {
			if _, ok := dic[string(i)]; ok {
				continue
			}

			added := strs + string(i)
			if line < added {
				fmt.Println(added)
				return
			}
		}
		count++
		if count > 26 {
			break
		}
		delete(dic, string(line[len(line)-count]))
	}
	fmt.Println("-1")
}


Measured memory_bytes: 512
#include<iostream>
#include<map>
using namespace std;
int main(){
  map<int,int> num;
  int n,a=0;
  while(cin >>n) num[n]++;
  for(map<int,int>::iterator it = num.begin(); it!=num.end(); it++){
    if(a<(it->second)) a = it->second;
  }
  for(map<int,int>::iterator it = num.begin(); it!=num.end(); it++){
    if(a == (it->second)) cout<<(it->first)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	string s;
	cin >> s;
	if (s == "Sunny") {cout << "Cloudy" << endl;}
	if (s == "Cloudy") {cout << "Rainy" << endl;}
	if (s == "Rainy") {cout << "Sunny" << endl;}
} 

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

const string YES = "Yes";

const string NO = "No";

void solve(int N, string S)
{
    string s1 = S.substr(0, N / 2);
    string s2 = S.substr(N / 2);
    cout << ((s1 == s2) ? YES : NO) << endl;
}

int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, A[50];

int main(void) {
  cin >> N;
  REP(i, 0, N) cin >> A[i];

  ll ans = 0;
  while(1) {
    bool f = true;
    REP(i, 0, N) f = f && (A[i] < N);
    if(f) break;
    REP(i, 0, N) {
      ll x = A[i] / N;
      A[i] -= x * N;
      REP(j, 0, N) if(i != j) A[j] += x;
      ans += x;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
    char S[100];
    int N;
    scanf("%s",&S);
    N=strlen(S);
    int frag=1;
    int i;
    for(i=0; i<N/2 ;i++){
        if(S[i]!=S[N-i-1]){
            frag=0;
            break;
        }
    }
    if(frag==0){
        printf("No");
        return 0;
    }
    if(N==3){
        printf("Yes");
        return 0;
    }
    for(i=0; i<(N/2)/2 ;i++){
        if(S[i]!=S[N/2-i-1]){
            frag=0;
            break;
        }
    }
    if(frag==0){
        printf("No");
    }
    else{
        printf("Yes");
    }

    return 0;
}

Measured memory_bytes: 128
/* Simplicity and Goodness */
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{
    int n;
    scn(n);

    vi a(n);

    rep(i, 0, n)
    scn(a[i]);

    sort(a.begin(), a.end()); int nm = 0;

    for(int i=0; i<n; ) {
        int f = i, cnt = 0;
        while(i<n and a[i] == a[f])
            cnt ++, i++;
        cnt --;
        nm += cnt;
    }

    if(nm % 2 == 1)
        nm ++;

    prin(n - nm);
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3796
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
using namespace std;
typedef long long unsigned int ll;
typedef long long int lli;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int N;
vector<unsigned int> a;



int main() {
    cin >> N;

    lli max_a = 0;
	for(int i=0; i<N; i++) {
		unsigned int x;
		cin >> x;
		a.push_back(x);
	}

    sort(a.begin(), a.end());

    lli n, r;

    n = a[N-1];

    lli diff = INF;
	for(int i=0; i<N-1; i++) {
        if( abs(n/2 - a[i]) <= diff) {
            r = a[i];
            diff = abs(n/2 - a[i]);
        }
	}

    cout << n << " " <<  r << endl;
}


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

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<char>> masu(H, vector<char> (W));
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cin >> masu.at(i).at(j);
    }
  }
  int ans = 0;
  for(int k = 0; k < (1 << H + W); k++) {
    bitset<12> data(k);
    vector<vector<char>> keep(H, vector<char> (W));
    for(int i = 0; i < H; i++) {
      for(int j = 0; j < W; j++) {
        keep.at(i).at(j) = masu.at(i).at(j);
      }
    }
    for(int i = 0; i < H; i++) {
      if(data.test(i)) {
        for(int j = 0; j < W; j++) {
          keep.at(i).at(j) = 'r';
        }
      }
    }
    for(int i = H; i < H + W; i++) {
      if(data.test(i)) {
        for(int j = 0; j < H; j++) {
          keep.at(j).at(i - H) = 'r';
        }
      }
    }
    int count = 0;
    for(int i = 0; i < H; i++) {
      for(int j = 0; j < W; j++) {
        if(keep.at(i).at(j) == '#') {
          count++;
        }
      }
    }
    if(count == K) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[100];
  double sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  sum/=n;
  double min=BIG;
  int sam=0;
  rep(i,n){
    if(min > abs(a[i]-sum) ){
      min=abs(a[i]-sum);
      sam=i;
    }
  }
  cout<<sam<<endl;

  return 0;
}


Measured memory_bytes: 256
//--- pC ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		int N = ni(), M = ni();
		int[] res = new int[N];
		for (int i=0; i<M; i++) {
			int s = ni(), c = ni();

			if (res[s - 1] != 0 && res[s - 1] != c) {
				System.out.println("-1");
				return;
			}
			if (N!=1 && s==1 && c==0) {
				System.out.println("-1");
				return;
			}

			res[s - 1] = c;
		}

		if (N != 1 && res[0] == 0) res[0] = 1;
		StringBuilder sb = new StringBuilder();
		for (int i=0; i<N; i++) {
			sb.append(res[i]);
		}
		System.out.println(sb.toString());

		return;
	}
	private int ni() {return Integer.parseInt(reader.next());}
	private String ns() {return reader.next();}
}

class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code
int main(int argc, char const* argv[])
{
    int n;
    cin >> n;
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        int a,b;
        cin >> a >> b;
        ans += b-a+1;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;
using ll = long long;

ll f(string s) {
  ll n = 0;
  rep(i,0,s.size()-1) {
    n += (s[i] - '0') % 10;
  }
  return n;
}

int main() {
  string s, t;
  cin >> s;
  rep(i,1,s.size()) t.push_back('9');

  ll n = stoll(s);
  ll ans = 0;
  rep(i,0,t.size()-1) {
    rep(j,0,9) {
      t[i] = j + '0';
      if (stoll(t) <= n) {
        ans = max(ans, f(t));
      }
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            string N = Console.ReadLine();
            int na = N.Length;
            int[] n = new int[na];
            for(int x = 0;x < na;x++)
            {
                n[x] = int.Parse(N.Substring(x,1));
            }
            int g = 0;
            for(int y = 0;y < na;y++)
            {
                g = g + n[y];
            }
            if(g%9==0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 33400
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M,x;
    cin >>N>>M;
    priority_queue<int> Q;
    rep(i,N){cin>>x;Q.push(x);}
    rep(i, M) { x = Q.top() /2;Q.pop();Q.push(x); }
    ll t=0;
    while(!Q.empty()){
        t+=Q.top();
        Q.pop();
    }
    cout<<t<<endl;
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

signed main() {
    
    int a, b;
    cin >> a >> b;
    
    if(a%3==0 || b%3==0 || (a+b)%3==0)
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
money = {'JPY': 0, 'BTC': 0.0}
for i in range(N):
    u, x = input().split()
    if x == "JPY":
        money['JPY'] += int(u)
    else:
        money['BTC'] += float(u)
print(money['JPY'] + money['BTC'] * 380000.0)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc086.contest.atcoder.jp/tasks/arc086_a>
問題文============================================================
 高橋君は，N 個のボールを持っています． 最初，i 番目のボールには，整数 Ai が書かれています．
 
 高橋君は，いくつかのボールに書かれている整数を書き換えて，
 N 個のボールに書かれている整数が K 種類以下になるようにしたいです．
 
 高橋君は，少なくとも何個のボールの整数を書き換える必要があるでしょうか？

=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N,K; cin >> N >> K;
    vector<ll> A(N);
    for(auto &in:A) cin >> in;
    map<ll,ll> mp;
    for(auto v:A) mp[v]++;
    vector<ll> ps;
    for(auto c:mp) ps.push_back(c.second);
    sort(ps.begin(),ps.end());
    ll ans = 0;
    for(int i = 0; i < (int)ps.size()-K;i++){
        ans += ps[i];
    }
    cout << ans << endl;
	return 0;
}


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

int main() {
  int n, k, d;
  cin >> n >> k;
  
  bool count[n];
  for(int i = 0; i < n; i++) {
    count[i] = false;
  }
  for(int i = 0; i < k; i++) {
    cin >> d;
    for(int j = 0; j < d; j++) {
      int x;
      cin >> x;
      count[x - 1] = true;
    }
  }
  int ans = 0;
  for(int i = 0; i < n; i++) {
    if(count[i] == false) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596