akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
 
int main()
{
  string s,t;
  cin >> s;
  cin >> t;
 
  if (s == t.erase(s.size())){
       cout << "Yes" << endl;
  }else{
       cout << "No" << endl;
  }
    return 0;
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = double.Parse(Console.ReadLine());


        var t = Math.Ceiling(n * 100 / 108);
        Console.WriteLine((int)(t * 1.08) > n ? ":(" : t.ToString() );
    }
}


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

using ll = long long;
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> as(n);
  rep(i, n) { cin >> as[i]; }
  rep(i, n - k) {
    if (as[i] < as[k + i]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 4048
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    int ans = 1e18;
    bool flag = false;
    for(int i=1;i<=1000;i++){
        int c = i * 8;
        c /= 100;
        int d = i * 1;
        d /= 10;
        if(c == a and d == b){
            ans = min(i,ans);
        }
    }
    if(ans == 1e18){
        ans = -1;
    }
    cout<<ans<<endl;
    return 0;
    
}



Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
price = list(map(lambda x: -x, map(int, input().split())))
heapq.heapify(price)

while m >= 1:
    a = (heapq.heappop(price) + 1) // 2
    heapq.heappush(price, a)
    m -= 1
    
print(sum(price) * (-1))

Measured memory_bytes: 72216
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=300001;
int h,w,n,a[M],b[M];
set<P> st;

int main(){
	cin>>h>>w>>n;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		st.insert({x,y});
		a[x]++;b[y]++;
	}
	auto ix=max_element(a,a+M);
	auto iy=max_element(b,b+M);
	vi c,d;
	for(int i=0;i<M;i++) if(a[i]==*ix) c.push_back(i);
	for(int i=0;i<M;i++) if(b[i]==*iy) d.push_back(i);
	h=c.size(),w=d.size();
	int res=*ix+*iy-1;
	for(auto i:c) for(auto j:d) if(st.find({i,j})==st.end()){
		res++;
		goto GO;
	}
	GO:
	cout<<res<<endl;
}

Measured memory_bytes: 23788
n,m  = gets.chomp.split(' ').map(&:to_i)
a = gets.chomp.split(' ').map(&:to_i)
c =[]
count=0
if n ==1
  puts a[0]
else
    (n-1).times do |j|
    b = gets.chomp.split(' ').drop(1).map(&:to_i)
      c.push(b)
    end
a.shift.times do |i|
  flag = true
  (n-1).times do |j|
  	if c[j].include?(a[i])==false
      flag = false
      break
    end
  end 
  count+= 1 if flag
end
puts count
end

Measured memory_bytes: 1788
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdint>
#include <utility>
#include <tuple>
#include <map>    
#include <queue> 
#include <set>  
#include <stack> 
#include <deque>  
#include <unordered_map> 
#include <unordered_set> 
#include <bitset>

using namespace std;

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

	vector<int> L(N);
	for (int i = 0; i < N; i++) {
		cin >> L.at(i);
	}

	int count = 1;
	int D = 0;
	for (int i = 0; i < N; i++) {
		D += L.at(i);
		if (D > X) {
			break;
		}
		else {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main()
{
    const int INF = 1 << 30;
    int h, w;
    cin >> h >> w;

    vector<string> s(h);
    for (int i = 0; i < h; i++) { cin >> s[i]; }

    vector<vector<int>> d(h, vector<int>(w, INF));

    queue<pair<int, int>> q;
    vector<int> dx = {0, 1, 0, -1};
    vector<int> dy = {1, 0, -1, 0};

    d[0][0] = 0;
    q.push(make_pair(0, 0));

    while (!q.empty()) {
        auto nowpos = q.front();
        q.pop();

        for (int i = 0; i < 4; i++) {
            int x = nowpos.first + dx[i];
            int y = nowpos.second + dy[i];

            if (0 > x || x >= h || 0 > y || y >= w) continue;

            if (d[x][y] != INF) continue;
            if (s[x][y] == '#') continue;

            d[x][y] = d[nowpos.first][nowpos.second] + 1;
            q.push(make_pair(x, y));
        }
    }

    int ans;
    if (d[h - 1][w - 1] == INF) {
        ans = -1;
    } else {
        ans = h * w - d[h - 1][w - 1];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (s[i][j] == '#') ans--;
            }
        }
        ans--;
    }
    cout << ans << endl;
}

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

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

    char c;
    int found = 0;
    for (c = 'a'; c <= 'z'; c++) {
      if (s.find(c) == std::string::npos) {
        cout << c << endl;
        found = 1;
        break;
      }
    }
    if (found == 0) {
      cout << "None" << endl;
    }
    return 0;
}


Measured memory_bytes: 512
N = int(input())
dp = [float("inf") for i in range(N+1)]
for i in range(6):
  if i <= N:
    dp[i] = i

for i in range(N+1):
  c = 1
  while i+6**c <= N:
    dp[i+6**c] = min(dp[i+6**c],dp[i]+1)
    c += 1
  c = 1
  while i+9**c <= N:
    dp[i+9**c] = min(dp[i+9**c],dp[i]+1)
    c += 1

for i in range(N,0,-1):
  if dp[i] != 0:
    ans = dp[i] + N-i
    break
print(ans)    

Measured memory_bytes: 6296
#include <iostream>
#include <cmath>
typedef long long ll;
using namespace std;

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

    ll n, k;
    cin >> n >> k;

    if(k%2==1){
        ll base = n/k;
        ll res = pow(base, 3);
        cout << res << endl;
    }
    else{
        ll odd_base = 1 + (n-(k/2))/k;
        if(n*2 < k) odd_base = 0;
        ll res = pow(odd_base, 3);

        ll even_base = n/k;
        res += pow(even_base, 3);

        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 4020
import scala.io.Source.stdin

object Main extends App {
  def gcd(m:Long,n:Long):Long = if(n==0) m else gcd(n, m % n)

  for(s <- stdin.getLines.map(_.split(" ").map(_.toLong))) {
        val g = gcd(s(0),s(1))
        println(g + " " + (s(0)/g)*s(1))
  }
}

Measured memory_bytes: 43492
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

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

using namespace std;

typedef pair<int ,int > P;


int main()
{
	int n;
	while(cin>>n)
	{
		if(!n) return 0;
		rep(i,n)
		{
			int a,b,c,d,e,f,g,h;
			cin>>a>>b>>c>>d>>e>>f>>g>>h;
			cout<<a*e-b*f-c*g-d*h<<" ";
			cout<<a*f+e*b+c*h-g*d<<" ";
			cout<<a*g-b*h+e*c+f*d<<" ";
			cout<<a*h+b*g-c*f+d*e<<endl;
		}
	}
		return 0;
}

Measured memory_bytes: 1160
#!usr/bim/python
#! -*- coding: utf-8 -*-

n = raw_input()
n = int(n)

a = raw_input()
a = a.split()
a = map(int,a)

#+-
goukei_1 = 0
sousa_1 = 0
for i in range(n):
    goukei_1 += a[i]
    if i % 2 == 0 and goukei_1 <= 0:
        sousa_1 += 1 + (-goukei_1)
        goukei_1 = 1
    elif i % 2 == 1 and goukei_1 >= 0:
        sousa_1 += 1 + goukei_1
        goukei_1 = -1

#-+
goukei_2 = 0
sousa_2 = 0
for i in range(n):
    goukei_2 += a[i]
    if i % 2 == 1 and goukei_2 <= 0:
        sousa_2 += 1 + (-goukei_2)
        goukei_2 = 1
    elif i % 2 == 0 and goukei_2 >= 0:
        sousa_2 += 1 + goukei_2
        goukei_2 = -1

print min(sousa_1, sousa_2)


Measured memory_bytes: 11248
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.container;
import std.bigint;
import std.math;

void main()
{
	readln;
  auto mark = ["S", "H", "C", "D"];
  bool[int][string] cards;
  
  foreach (c; mark) {
    cards[c][0] = true;
  }

  foreach (line; stdin.byLine) {
    auto a = line.chomp.split;
    cards[a[0].to!string][a[1].to!int] = true;
  }

  foreach (c; mark) {
    foreach (i; 1..14) {
      if (!cards[c].get(i, 0)) {
        writeln(c, " ", i);
      }
    }
  }
}

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


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(10)<<fixed;
	
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int mx=INT_MAX;
	int x=0;
	for(int i=1;i<=100;i++)
	{
		int c=0;
		for(int j=0;j<n;j++)
			c+=(i-a[j])*(i-a[j]);
		if(mx>c)
		{
			mx=c;
			x=i;
		}
	}
	int c=0;
	for(int i=0;i<n;i++)
		c+=(x-a[i])*(x-a[i]);
	cout<<c<<endl;
	return 0;
}



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

using namespace std;

#define int unsigned long long

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,a,b;

    cin >> n >> a >> b;
    int cnt = 0;
    
    for(int i = 1; i <= n;++i)
    {
        int sum = 0;
        
        int x = i;
        for(int k = 0; k < 5; ++k)
        {
            sum += x % 10;
            x = x / 10;
        }
        if(a <= sum && sum <= b)
        {
            cnt+=i;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
} 

 
struct Dinic {
  struct edge {
    int to, cap, rever;
    edge(int to, int cap, int rever):to(to), cap(cap), rever(rever){}
  };
  vector< vector<edge> > graph;
  vector<int> level, iter;
  Dinic(int V):graph(V), level(V), iter(V){}
  void add_edge(int from, int to, int cap) {
    graph[from].emplace_back(to, cap, graph[to].size());
    graph[to].emplace_back(from, 0, graph[from].size()-1);
  }
  void bfs(int s) {
    fill(all(level), -1);
    queue<int> que;
    level[s] = 0;
    que.push(0);
    while(que.size()) {
      int v = que.front(); que.pop();
      for(edge& e : graph[v]) {
        if(e.cap > 0 && level[e.to] < 0) {
          level[e.to] = level[v] + 1;
          que.push(e.to);
        }
      }
    }
  }
  int dfs(int v, int t, int f) {
    if(v == t) return f;
    for(int& i = iter[v]; i < graph[v].size(); i++) {
      edge& e = graph[v][i];
      if(e.cap > 0 && level[v] < level[e.to]) {
        int d = dfs(e.to, t, min(e.cap, f));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rever].cap += d;
          return d;
        }
      }
    }
    return 0;
  }
  int max_flow(int s, int t) {
    int flow = 0;
    while(true) {
      bfs(s);
      if(level[t] < 0) return flow;
      fill(all(iter), 0);
      int f; while((f = dfs(s, t, inf)) > 0) flow += f;
    }
  }
}; 

int main(){
    ll x,y,e;cin >> x >> y >>e;
    Dinic dn(x+y+2);
    ll s=0,t=x+y+1;
    rep(i,x){
        dn.add_edge(s,i+1,1);
    }
    rep(i,y){
        dn.add_edge(i+x+1,t,1);
    }
    rep(i,e){
        ll a,b;cin >> a >> b;
        dn.add_edge(a+1,b+x+1,1);
        //cout << a <<" " << b+x <<endl;
    }
    cout << dn.max_flow(s,t) <<endl;
}


Measured memory_bytes: 3232
function main(input) {
  const inputs =input.split('\n')
  const [S] = inputs[0].split(' ')
  let s = ''
  for(let i = 0; i < S.length; i++) {
    s += 'x'
  }
  console.log(s)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if(N==3){
        	System.out.println("2 5 63");
        	System.exit(0);
        }
        
        
        System.out.print("2 3");
        int elmNum=2;
        int elm = 4;
        int sum=5;
        
        while(elmNum<N-2){
        	if(elm%2==0 || elm%3==0){
        	    System.out.print(" "+elm);
        	    elmNum++;
        	    sum+=elm;
        	}
        	elm++;
        }
        //2 elements left
        switch(sum%6){
        	case 0:
        	    System.out.println(" 29994 30000");
        	    break;
        	case 1:
        	    System.out.println(" 29996 29997");
        	    break;
        	case 2:
        	    System.out.println(" 29998 30000");
        	    break;
        	case 3:
        	    System.out.println(" 29997 30000");
        	    break;
        	case 4:
        	    System.out.println(" 29996 30000");
        	    break;
        	case 5:
        	    System.out.println(" 29997 29998");
        	    break;
        }
        
        System.out.println();
    }
}

Measured memory_bytes: 29372
#include <iostream>

int main() {

	int T_defence, T_attack, A_defence, A_attack;

	std::cin >> T_defence >> T_attack >> A_defence >> A_attack;

	while (T_defence > 0 && A_defence > 0) {
		A_defence -= T_attack;
		if(A_defence <= 0) break;
		T_defence -= A_attack;
		if(T_defence <= 0) break;
	}

	if (T_defence <= 0) {
		std::cout << "No" << std::endl;
	}
	else {
		std::cout << "Yes" << std::endl;
	}
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>

using namespace std;

string s;
int cnt[26];

int main(void)
{
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		cnt[s[i]-'a']++;
	};
	
	bool ans = true;
	for(int i = 0; i < 26; i++){
		if(cnt[i] >= 2) ans = false;
	}
	
	if(ans) cout << "yes" << endl;
	else cout << "no" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbg(nazwa) cerr<<#nazwa ": " << (nazwa) << "\t"
#define nl cerr << endl
using namespace std;
using ll = long long;
const int N = 1e3 + 7;
const ll MOD = 1e9+7;

ll t[N][N]; // po x i po y

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int h,w;
	char cz;
	cin >> w >> h;
	for(int j = 1; j <= w; j++) {
		for(int i = 1; i <= h; i++) {
			cin >> cz;
			//t[i][j] = 1;
			if(cz == '#')
				t[i][j] = -1;
		}
	}
	t[1][1] = 1;
	int dx[] = {-1,0};
	int dy[] = {0,-1};
	for(int j = 1; j <= w; j++) {
		for(int i = 1; i <= h; i++) {
			//dbg(i); dbg(j); nl;
			if(t[i][j] == -1) continue;
			for(int x = 0; x < 2; x++) {
				int nx = i + dx[x];
				int ny = j + dy[x];
				//dbg(nx); dbg(ny); nl;
				if(1<=nx and nx <= h and ny >= 1 and ny <= w and t[nx][ny] != -1) {
					t[i][j] += t[nx][ny];
					if(t[i][j] >= MOD) t[i][j] -= MOD;
				}
			}
			//nl;nl;
		}
	}

	//for(int j = 1; j <= w; j++) {
		//for(int i = 1; i <= h; i++) {
			//cout << t[i][j] << " ";
		//}
		//cout << "\n";
	//}
	
	cout << (t[h][w] == 1 ? 0 : t[h][w]);
}


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

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 2000;

int A[N];

int main() {
	int n,z,w;cin>>n>>z>>w;
	rep(i,n) cin>>A[i];
	int ans;
	if(n==1) ans=abs(A[0]-w);
	else ans=max(abs(w-A[n-1]),abs(A[n-2]-A[n-1]));
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });


void solve(long long A, long long B){
	ll res = B-A;
	if (B%A==0) res = A+B;
	cout << res << "\n";
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string o, e;
    cin >> o >> e;
    int on = o.size();
    int en = e.size();
    string ans = "";
    for(int i = 0; i < min(on, en); i++) {
        ans += o[i];
        ans += e[i];
    }
    if(on > en) {
        ans += o.back();
    }
    cout << ans << endl;
}

Measured memory_bytes: 3556
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int main(void){
	string s;
	cin>>s;
	if(s[0]=='1')s[0]='9';
	else if(s[0]=='9')s[0]='1';
	if(s[1]=='1')s[1]='9';
	else if(s[1]=='9')s[1]='1';
	if(s[2]=='1')s[2]='9';
	else if(s[2]=='9')s[2]='1';
	cout<<s<<endl;
}
/*reveres begin end
cout<<"\n";
  m.insert(std::make_pair('c', 30));
*/


Measured memory_bytes: 256
import sys
a, b, c, x = [int(sys.stdin.readline()) for i in range(4)]
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                count += 1
print(count)

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

int main()
{
    int n,m;
    cin>>n>>m;
    map<ll,int> g;
    for(int i=1;i<=n;++i)
    {
        int x;
        cin>>x;
        g[x]++;
    }
    for(int i=1;i<=m;++i)
    {
        int b,c;
        cin>>b>>c;
        int cnt = 0;
        for(auto it = g.begin();;)
        {
            if(c > it->first)
            {
                if(b >= it->second)
                {
                    cnt += it->second;
                    b -= it->second;
                    it = g.erase(it);
                }else
                {
                    cnt += b;
                    g[it->first] -= b;
                    b = 0;
                    break;
                }
            }else
            {
                break;
            }
        }
        if(cnt)
        {
            g[c] += cnt;
        }
    }
    ll ans = 0;
    for(auto p:g)
        ans += p.first * p.second;
    cout<<ans<<endl;
}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			int[] nx = new int[2] { -1, -1 };
			List<int> counts = new List<int>();

			Func<int[], bool> checker = (c) => c[0] == 0 && c[1] == 0;

			while (checker.Invoke(nx) == false) {
				nx = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
				if (checker.Invoke(nx)) {
					break;
				}

				int n = nx[0];
				int x = nx[1];

				int count = 0;
				for (int i = 1; i <= n; ++i) {
					for (int j = i + 1; j <= n; ++j) {
						for (int k = j + 1; k <= n; ++k) {
							if (i + j + k == x) {
								++count;
							}
						}
					}
				}

				
				counts.Add(count);
			}

			foreach (var item in counts) {
				Console.WriteLine($"{item}");
			}

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 16416
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
int c[110000];
vector<int>g[110000];
int h[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",c+i);
		g[c[i]%b].push_back(c[i]);
		h[c[i]]++;
	}
	int ret=0;
	for(int i=0;i<b;i++){
		if((b-i)%b<i)continue;
		if((b-i)%b==i){
			ret+=g[i].size()/2;
		}else{
			int s=i;
			int t=(b-i)%b;
			if(g[s].size()<g[t].size()){
				swap(s,t);
			}
			ret+=g[t].size();
			int am=((int)g[s].size()-(int)g[t].size())/2;
			for(int j=s;j<=100000;j+=b){
				if(am==0)break;
				int can=min(h[j]/2,am);
				am-=can;
				ret+=can;
			}
		}
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 6784
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
S = input()
if S =="ABC":
    print("ARC")
else:
    print("ABC")
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 9080
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

static const ll MAX_N = 100001;
static const ll MAX_M = 200001;

ll x[100001] = {};
int main() {
	ll n, a, b; cin >> n >> a >> b;
	repe(i, 1, n) cin >> x[i];
	ll ans = 0;
	rep(i, 1, n) {
		ans += min((x[i + 1] - x[i])*a, b);
	}

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

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
	int temp,N,K,Q;
	cin >> N >> K >> Q;
	vector<int> A(N,K-Q);
	for (int i = 0; i < Q; ++i) {
		cin >> temp;
		++A[temp-1];
	}
	for (int i = 0; i < N; ++i) {
		if (A[i] > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
#include <string>
#include <vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>

using namespace std;

int main(){

	int a[5];

	for(int i=0;i<5;i++) cin >> a[i];

	int m=5000;
	for(int i=0;i<3;i++){
	for(int j=3;j<5;j++){
	if(m>a[i]+a[j]) m=a[i]+a[j];

	}
	}

	cout << m-50 << endl;

	return 0;
}

Measured memory_bytes: 1160
package main

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

const (
	maxBufSize = 1024 * 1024
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, 1)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	out = bufio.NewWriter(os.Stdout)
)

func main() {
	defer out.Flush()

	h := nextInt()
	w := nextInt()
	as := make([]string, 0, h)
	ws := make([]bool, w)
	for y := int64(0); y < h; y ++ {
		a := next()
		if !strings.Contains(a, "#") {
			continue
		}
		as = append(as, a)
		for x, c := range(a) {
			ws[x] = ws[x] || c == '#'
		}
	}

	for _, a := range(as) {
		for x, c := range(a) {
			if ! ws[x] {
				continue
			}
			fmt.Fprintf(out, "%c", c)
		}
		fmt.Fprintln(out)
	}
}

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

func nextStringAsBytes() []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


Measured memory_bytes: 1772
/*
ID: htc9811
LANG: C++
TASK:
*/

#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
#include<list>
using namespace std;

int a,b,c;

int main(){
	scanf("%d%d%d",&a,&b,&c);
	if(a+b+1>=c) printf("%d\n",b+c);
	else printf("%d\n",b+a+b+1);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 2684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

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

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

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> T(N);
	for (ll i = 0; i < N; ++i) cin >> T[i];

	ll res{1};
	for (ll i = 0; i < N; ++i) res = lcm(T[i], res);

	std::cout << res << std::endl;
}

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

int main() {
  int64_t mod=pow(10,9)+7;
  int N, M;
  cin >> N >> M;
  int64_t ans=1;
  if (N==M) {ans=2;}
  if (abs(N-M)>1) {ans=0;}
  else {
    for (int i=1; i<=N; i++) {
      ans*=i;
      ans=ans-ans/mod*mod;
    }
    for (int i=1; i<=M; i++) {
      ans*=i;
      ans=ans-ans/mod*mod;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll,ll> pll;


ll n, k;
inline ll f(ll x)
{
        return ((x*(x-1)))/2;
}
ll mp[111][111];
vector< pll > ans;
inline bool adde(ll x, ll y)
{
        if(mp[x][y] == 1 || mp[y][x] == 1) return false;
        mp[x][y]=1;
        mp[y][x]=1;
        ans.pb(make_pair(x, y));
        return true;
}
map<ll,ll> p;
int main()
{
        cin >> n >> k;
        if(k > f(n-1)){
                cout << "-1\n"; return 0;
        }
        ll cur = f(n - 1);
        for(ll i=1;i<n;i++) {
                bool d = adde(i, n);
        }
        while(cur > k){
                for(ll i=1;i<n;i++){
                        bool ok=false;
                        for(ll j=1;j<n;j++){
                                if(i==j) continue;
                                if(adde(i,j)) {
                                        cur--;
                                        ok = true;
                                        break;
                                }
                        }
                        if(ok) break;
                }
        }
        cout << ans.size() << endl;
        for(auto &i : ans) cout << i.first << " " << i.second << "\n";
        return 0;
}


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

#define      ll      long long int

const int N = 100005;
vector<ll> pos, neg;
ll ara1[N];
ll ara2[N];

int main( )
{
    ll n, i, j, k;
    pos.push_back(0);
    neg.push_back(0);
    cin >> n >> k;
    ll c = 0;
    for (i = 1; i <= n; i++) {
        cin >> j;
        if (j == 0) {
            c++;
        }
        else if (j > 0) {
            pos.push_back(j);
        }
        else {
            neg.push_back(j);
        }
    }
    ll lpos, lneg;
    lpos = (int) pos.size();
    lneg = (int) neg.size();
    reverse(neg.begin() + 1, neg.end());
    for (i = 1; i < lpos; i++) {
        ara1[i] = ara1[i - 1] + (pos[i] - pos[i - 1]);
        //cout << ara1[i] << ' ';
    }
    //cout << '\n';
    for (i = 1; i < lneg; i++) {
        ara2[i] = ara2[i - 1] + (neg[i - 1] - neg[i]);
        //cout << ara2[i] << ' ';
    }
    //cout << '\n';
    ll mn = 1e18, taken, need;
    if (c >= k) {
        cout << "0\n";
        return 0;
    }
     for (i = 1; i < lneg; i++) {
        taken = i + c;
        need  = k - taken;
        if (need < 0) {
            break;
        }
        if (need <= (lpos - 1)) {
            if (need == 0) {
                mn = min(ara2[i], mn);
            }
            else {
                mn = min(2 * ara2[i] + ara1[need], mn);
            }
        }
    }
    for (i = 1; i < lpos; i++) {
        taken = i + c;
        need  = k - taken;
        if (need < 0) {
            break;
        }
        if (need <= (lneg - 1)) {
            if (need == 0) {
                mn = min(ara1[i], mn);
            }
            else {
                mn = min(2 * ara1[i] + ara2[need], mn);
            }
        }
    }
    cout << mn << '\n';
    return 0;
}

Measured memory_bytes: 2292
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
//#include<string>
//#include<sstream>
using namespace std;
int main()
{
	long long a,b,c,d;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	if(a*b>c*d){
		printf("%lld\n",a*b);
	}
	else printf("%lld\n",c*d);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll n,A[5],ans;
    cin>>n;
    rep(i,5) cin>>A[i];
    sort(A,A+5);
    cout<<4+n/A[0]+(n%A[0]>0);
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::fmt;
use std::collections::HashMap;

fn read_line() -> String {
    let mut ret = String::new();
    io::stdin().read_line(&mut ret).expect("read_line failed");
    ret.trim().to_string()
}

fn read_one<F>() -> F where F: FromStr {
    // FromStr has type Error in its struct.
    // https://doc.rust-lang.org/std/str/trait.FromStr.html
    // String#parse return Result<F, F::Err>,
    // and unwrap is only available in Result<T, Result>
    match read_line().parse::<F>() {
        Ok(v)  => v,
        Err(_) => panic!("failed to parse.")
    }
}

fn read_many<F>() -> Vec<F> where F: FromStr {
    read_line().split(' ').map(
        |s| match s.parse::<F>() {
            Ok(v)  => v,
            Err(_) => panic!("failed to parse.")
        }
    ).collect()
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
fn main() {
    let n = read_one::<u32>();
    let mut m = HashMap::new();

    for _ in 0 .. n {
        let s = read_one::<String>();
        let v = m.get(&s).unwrap_or(&0) + 1;
        m.insert(s, v);
    }

    // let v = m.iter().map(|(key, val)| (val, key) );
    // let maxi = v.max_by_key(|(val, key)| val);

    let maxi = m.values().max().unwrap();
    let mut vs: Vec<String> = m.iter().filter(|&(k, val)| val == maxi).map(|(key, _)| key.clone()).collect();
    vs.sort();

    for v in vs {
        println!("{}", v);
    }
}


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

int n;
string str;

map<tuple<int, bool>, long long> dp;

long long dfs(int p, bool black) {
	if (p == n) return 0;
	auto status = make_tuple(p, black);
	if (dp.count(status)) return dp[status];
	if (!black) {
		if (str[p] == '#') {
			return dp[status] = min(dfs(p + 1, false) + 1, dfs(p + 1, true));
		}
		return dp[status] = dfs(p + 1, str[p] == '#');
	}
	if (str[p] == '.') {
		return dp[status] = dfs(p + 1, true) + 1;
	}
	return dp[status] = dfs(p + 1, true);
}

void hawawa()
{
	int a, b, t;
	cin >> a >> b >> t;
	cout << t / a * b << "\n";
}


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


Measured memory_bytes: 256
/** 
 *    author:  pankaj_m05
 *    created: 26.09.2020 18:16:54
**/ 
#include<bits/stdc++.h>

using namespace std;

void dfs(vector<vector<int>>& adj, vector<bool>& vis, int s) {
	vis[s] = 1;
	for(int& v : adj[s]) {
		if (!vis[v]) {
			dfs(adj, vis, v);
		}
	}
}

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> adj(n);
  vector<bool> vis(n, 0);
  while (m--) {
  	int u, v;
  	cin >> u >> v;
  	adj[u - 1].emplace_back(v - 1);
  	adj[v - 1].emplace_back(u - 1);
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
  	if (!vis[i]) {
  		dfs(adj, vis, i);
  		++ans;
  	}
  }
  cout << ans - 1;
  return 0;
}

Measured memory_bytes: 9532
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e5 + 5;
int main()
{
    ios::sync_with_stdio(false);
    int a , b , c; cin >> a >> b >>c;
    if (b * c >= a) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int n, k;
  cin >> n >> k;
  unordered_map<int, int> mp;
  int tmp;
  REP(i,n){
    cin >> tmp;
    mp[tmp]++;
  }
  if(mp.size() <= k ){
    cout << 0 <<endl;
    return 0;
  }
  vector<int > num(mp.size(),0);
  // sort(all(mp));
  int i = 0;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr){
    num[i] = itr->second;
    i ++;
  }
  sort(all(num),greater<int>());
  // REP(i,mp.size()){
  //   cout <<setw(2)<<left<< i << num[i] << endl;
  // }
  int ans = 0;
  for(int i = k; i < mp.size(); i++){
    ans += num[i];
  }
  cout << ans << endl;
}


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

using namespace std;

int main() {
	int a, b, k;
	cin >> a >> b >> k;

	for (int i = min(a, b); i >= 0; i--) {
		if (a % i == 0 && b % i == 0) {
			k--;
			if (k == 0) {
				cout << i;
				break;
			}
		}
	}
}

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

#define fi first
#define se second

const int N = 100100;
const int Q = 200200;
const long long mod = 1e9 + 7;

using namespace std;

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        //freopen("teleports.in", "r", stdin);
        //freopen("teleports.out", "w", stdout);
        ios_base::sync_with_stdio(0);

        int a, b, c, n;
        cin >> a >> b >> c >> n;
        int res = 0;
        for(int i = 0; i <= 3000; i++){
                for(int j = 0; j <= 3000; j++){
                        int need = n - a * i - b * j;
                        if(need < 0){
                                continue;
                        }
                        res += need % c == 0;
                }
        }
        cout << res << "\n";
}


Measured memory_bytes: 256
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ld INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n;
  cin >> n;
  vector<ld> a(n);
  rep(i, n) cin >> a[i];

  ld ave = 0;
  rep(i, n) ave += a[i];
  ave /= n;
  int ans = -1;
  ld res = INF;
  rep(i, n) if (chmin(res, fabs(a[i] - ave))) ans = i;
  cout << ans << '\n';


  
  return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

bool dfs(const vector<vector<pair<int64_t, int64_t>>>& adjs, vector<int64_t>& f,
         vector<int64_t>& k, int64_t& x, int64_t v) {
    for (const auto& link : adjs[v]) {
        auto u = link.first;
        auto s = link.second;

        auto ff = (f[v] + 1) % 2;
        auto kk = s - k[v];

        // if visited, verify consistency
        if (f[u] >= 0) {
            if (f[u] != ff) {
                int64_t xx = kk - k[u];
                if (xx % 2 != 0) {
                    return false;
                }
                xx /= 2;

                if (f[u]) {
                    xx *= -1;
                }

                if (x >= 0 && x != xx) {
                    return false;
                }

                if (xx < 0) {
                    return false;
                }

                x = xx;
            } else {
                if (kk != k[u]) {
                    return false;
                }
            }
        } else {
            f[u] = ff;
            k[u] = kk;

            if (!dfs(adjs, f, k, x, u)) {
                return false;
            }
        }
    }

    return true;
}

int main() {
    int64_t n, m;
    cin >> n >> m;

    vector<vector<pair<int64_t, int64_t>>> adjs(n);
    for (auto _ : irange(0L, m)) {
        int64_t u, v, s;
        cin >> u >> v >> s;
        --u;
        --v;
        adjs[u].emplace_back(v, s);
        adjs[v].emplace_back(u, s);
    }

    vector<int64_t> f(n, -1), k(n, -1);
    int64_t x = -1;
    f[0] = 0;
    k[0] = 1;
    if (!dfs(adjs, f, k, x, 0)) {
        cout << 0 << endl;
        return 0;
    }

    if (x >= 0) {
        for (auto i : irange(0L, n)) {
            if (f[i] == 0) {
                if (x + k[i] <= 0) {
                    cout << 0 << endl;
                    return 0;
                }
            } else {
                if (-x + k[i] <= 0) {
                    cout << 0 << endl;
                    return 0;
                }
            }
        }
        cout << 1 << endl;
    } else {
        int64_t l0 = numeric_limits<int64_t>::max(),
                l1 = numeric_limits<int64_t>::max();
        for (auto i : irange(0L, n)) {
            if (f[i] == 0) {
                l0 = min(l0, k[i]);
            } else {
                l1 = min(l1, k[i]);
            }
        }

        l1 += l0 - 1;
        l0 = 1;

        if (l1 <= 0) {
            cout << 0 << endl;
            return 0;
        }

        cout << l1 << endl;
    }
}

Measured memory_bytes: 17152
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,h[100005];
  long long dp[100005],mi;
  cin>>n>>k;
  for(int i=0; i<n; i++){
    cin>>h[i];
  }
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  for(int i=2; i<n; i++){
    mi=abs(h[i-1]-h[i])+dp[i-1];
    for(int j=1; j<=k; j++){
      if(j<=i){
	mi=min(abs(h[i-j]-h[i])+dp[i-j],mi);
      }
    }
    dp[i]=mi;
  }

  cout<<dp[n-1]<<'\n';
  return 0;
}


Measured memory_bytes: 1408
n = int(input())
a = list(map(int,input().split()))
cum = sum(a)
d = n*(n+1)//2
if cum%d:
    print("NO")
    exit()
x = cum//d

a.append(a[0])
count = 0
for i in range(n):
    dif = a[i+1]-a[i]
    if (x-dif)%n or x-dif < 0:
        print("NO")
        exit()
    count += (x-dif)//n
if count == x:
    print("YES")
else:
    print("NO")

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for(int i=0;i<n;i++){
    cin >> x[i];
  }
  int MIN=MOD;
  sort(x.begin(),x.end());
  int ans;
  for(int i=x[0];i<=x[n-1];i++){
    ans=0;
    for(int j=0;j<n;j++){
      ans +=(x[j]-i)*(x[j]-i);
    }
    MIN=min(MIN,ans);
  }
  cout << MIN << endl;
}

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

ll ktw(ll x){
  ll ret = 0;
  while(x){
    ret += x%10;
    x /= 10;
  }
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll k;
  cin >> k;
  
  vector<pair<ld, ll>> a;
  repr(i, 1, 100){
    a.emplace_back((ld)i/ktw(i), i);
  }
  rep(i, 16){
    repr(j, 100, 1000){
      ll x = j;
      rep(ii, i) x = x*10+9;
      a.emplace_back((ld)x/ktw(x), x);
    }
  }
  sort(ALL(a));
  ll ma = 0;
  vll ans;
  rep(i, SZ(a)){
    if(ma < a[i].second){
      //print(a[i]);
      ans.emplace_back(a[i].second);
      ma = a[i].second;
    }
  }
  rep(i, k) print(ans[i]);
  /*
  while(1){
    ll i;
    cin >> i;
    cout << (ld)i/ktw(i) << endl;
  }
  */
}


Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
    int A,B,C,D,X,Y,N,L,M,P,Q;
    int ans = 0;
    cin>>A>>B;
    if((A+B)%2==0){
        cout<<(A+B)/2<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    vector<pair<int,int>> A(N);
    int time = 0;
    REP(i,N){
        A[i].second = in();
        A[i].first = in();
    }
    sort(ALL(A));
    bool out = 0;
    REP(i,N){
        time += A[i].second;
        if(A[i].first < time)out = 1;
    }
    cout << (out ? "No" : "Yes") << "\n";
}

Measured memory_bytes: 1792