akhauriyash/Code-Regression huggingface dataset:
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int k; gi(k);
	int ans = 0;
	rep1(a, k) rep1(b, k) {
		int v = __gcd(a, b);
		rep1(c, k) ans += __gcd(v, c);
	}
	print(ans);
}


Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>

using namespace std;

int main() {
	int N, A, B;
	scanf("%d",&N);//N
	scanf("%d",&A);//A
	scanf("%d",&B);//B
	if (N * A < B) {
		printf("%d\n", N * A);
	}
	else {
		printf("%d\n", B);
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define REP(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int
main(int argc, char *argv[])
{
  ll a, b;
  scanf("%lld %lld", &a, &b);

  if(a <= 0 && 0 <= b) printf("Zero\n");
  else if(0 < a) printf("Positive\n");
  else{
    if((b - a + 1) % 2 == 0) printf("Positive\n");
    else printf("Negative\n");
  }

  return 0;
}


Measured memory_bytes: 128
N, K = map(int,input().split())
A = []
B = []

for i in range(N):
    a = list(map(int, input().split()))
    A.append(a)

A = sorted(A)

ss = [0]*(N+1)
ss[0] = A[0][1]

for i in range(1, N):
    ss[i] = ss[i-1] + A[i][1]
    if ss[i-1] < K <= ss[i]:
        print(A[i][0])
        exit()
    else:
        pass


Measured memory_bytes: 32296
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  int N,M;
  cin>>N>>M;
  int a=1900*M+100*(N-M);
  while(M--){
    a*=2;
  }
    cout<<a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define PI acos(-1.0)
#define INF 1000000000
#define LINF (LL)INF * INF
#define pow10 tipa_pow10
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
LL obm[100000][2];
int visited[100000][2];
int n , m;
LL val[100000];
vector<vector<pair<int , int> > >g(100000);
void dfs(int u , int type)
{
    //cout << u << " " << type << endl;
    visited[u][type] = 1;
    for(int i = 0; i < g[u].size(); i++)
    {
        int v = g[u][i].first , d = g[u][i].second;
        if(visited[v][!type])
        {
            if(obm[v][!type] != d - obm[u][type])
            {
                cout << 0;
                exit(0);
            }
        }
        else
        {
            obm[v][!type] = d - obm[u][type];
            dfs(v , !type);
        }
    }
}
bool check()
{
    set<LL> vals;
    for(int i = 0; i < n; i++)
    {
        LL A = obm[i][1] - obm[i][0];
        if(A & 1)
        {
            cout << 0;
            exit(0);
        }
        vals.insert(A >> 1);
        if(vals.size() > 1)
        {
            cout << 0;
            exit(0);
        }
    }
    LL A = *vals.begin();
    //cout << A << endl;
    for(int i = 0; i < n; i++)
    {
        val[i] = obm[i][0] + A;
    }
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < g[i].size(); j++)
        {
            int u = i , v = g[i][j].first , s = g[i][j].second;
            if(val[u] + val[v] > s || val[u] <= 0 || val[v] <= 0)
            {
                 cout  << 0;
                exit(0);
            }
        }
    }


    cout << 1;
}
int main()
{
    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        int u , v , s;
        cin >> u >> v >> s;
        u--;v--;
        g[u].pb({v , s});
        g[v].pb({u , s});
    }
    dfs(0 , 0);
    for(int i = 0; i < n; i++)
    {
        if(visited[i][0] && visited[i][1])
        {
            check();
            //cout << check();
            return 0;
        }
    }
    LL L = 1 , R = INF;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < g[i].size(); j++)
        {
            int v = g[i][j].first , s = g[i][j].second;
            if(visited[v][0])
            {
                L = max(L , 1 - obm[v][0]);
                R = min(R , s - obm[v][0]);
            }
            else
            {
                L = max(L , obm[v][1] - s);
                R = min(R , obm[v][1] - 1);
            }
        }
    }
    cout << max(R - L + 1 , 0LL);
}


Measured memory_bytes: 15744
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>

using ull = unsigned long long;
using sll = signed long long;

struct counter {
	//sum, count
	std::pair<sll, ull> zero, posi, nega;

	counter() 
		:zero{}
		, posi{}
		, nega{}{}

	auto operator()(sll s) {
		auto& p
			= s == 0 ? zero :
				s > 0 ? posi : nega;
		
//		std::cout << s << "\n";
		p.first += s;
		++p.second;
	}

};

int main() {
	
	int n;
	std::cin >> n;

	std::vector<sll> a,b;
	a.resize(n);
	b.resize(n);

	for (int i{}; i < n; ++i) {
		std::cin >> a[i];
		b[i] = a[i]-(i+1);
	}

	/*
	for (const auto&e : b)
		std::cout << e << " ";
	std::cout << "\n";
	*/

	std::sort(std::begin(b), std::end(b));

	auto mid = b[b.size() / 2];
	ull ans{};
	for (int i{}; i < n; ++i) {
		ans += std::abs(a[i] - (mid + i + 1));
	}

	std::cout << ans << "\n";
	/*
	auto c
		= std::for_each(std::begin(v), std::end(v), counter{});

	auto put = [](const auto&p) {
		std::cout << p.first << " " << p.second << "\n";
	};

	put(c.zero);
	put(c.posi);
	put(c.nega);
	*/

	/*
	ull ans{};
	for (int i{}; i < n; ++i) 
		ans += std::abs( v[i] - (i + 1));
	
	std::cout << ans << "\n";
	*/

	return 0;
}

Measured memory_bytes: 3328
import math
X = int(input())
X -= 1
Flag = True

if X == 1:
  print(2)
  Flag = False

while Flag:
  X += 1
  r = 1
  for i in range(math.ceil(math.sqrt(X)) - 1):
    r += 1
    if X % r == 0:
      break
    if r == math.ceil(math.sqrt(X)):
      print(X)
      Flag = False

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

int main(void)
{
    long N;
    cin >> N;
    string c;
    long C[4]={};
    
    while(N!=0)
    {
        cin >> c;
        if(c == "AC")
        {
            C[0]++;
        }
        else if(c == "WA")
        {
            C[1]++;
        }
        else if(c == "TLE")
        {
            C[2]++;
        }
        else if(c == "RE")
        {
            C[3]++;
        }
        N--;
    }
    cout << "AC x " << C[0] << endl << "WA x " << C[1] << endl << "TLE x " << C[2] << endl << "RE x " << C[3] << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(int argc, char const *argv[])
{
	cin.sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	vector<int> A(n);
	for(int i = 0;i < n; ++i)
	{
		cin>>A[i];
	}
	vector<ll> S(n + 1,0),Si(n + 1,0);
	for(int i = 0;i < n; ++i)
	{
		S[i + 1] = S[i] + A[i];
	}
	for(int i = n - 1;i >= 0; --i)
	{
		Si[i] = Si[i + 1] + A[i];
	}
	vector<ll> less2(n + 1),less2i(n + 1);
	int a = 0;
	for(int i = 0;i <= n; ++i)
	{
		while(a < i && 2 * S[a + 1] <= S[i])
		{
			a++;
		}
		less2[i] = S[a];
		if(a < i)
		{
			less2[i] = max(less2[i],S[i] - S[a + 1]);
		}
	}
	a = n;
	for(int i = n;i >= 0; --i)
	{
		while(a > i && 2 * Si[a - 1] <= Si[i])
		{
			a--;
		}
		less2i[i] = Si[a];
		if(a > i)
		{
			less2i[i] = max(less2i[i],Si[i] - Si[a - 1]);
		}
	}
	ll ans = -1;
	for(int i = 0;i < n; ++i)
	{
		ll v[4] = {0};
		v[0] = less2[i],v[1] = S[i] - less2[i];
		v[2] = less2i[i],v[3] = Si[i] - less2i[i];
		ll mxn = v[0],mix = v[0];
		for(int j = 1;j <= 3; ++j)
		{
			mxn = max(mxn,v[j]);
		}
		for(int j = 1;j <= 3; ++j)
		{
			mix = min(mix,v[j]);
		}
		if(ans == -1 || ans > mxn - mix)
		{
			ans = mxn - mix;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7296
// AOJ 1281 The Morning after Halloween
// 2018.3.3 bal4u
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

int  w, h;
char map[18][18];
int  n;
char sr[3], sc[3], gr[3], gc[3];
char r[3], c[3], nr[3], nc[3];
int  mv[5][2] = {{0,0},{-1,0},{0,1},{1,0},{0,-1}};
short mk[16][16][16][16][16][16];

#define QMAX 300000
typedef struct { char r[3], c[3]; short t; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(short t)
{
	int i, j, min;
	QUE qt;

	if (t >= mk[nr[0]][nc[0]][nr[1]][nc[1]][nr[2]][nc[2]]) return;
	mk[nr[0]][nc[0]][nr[1]][nc[1]][nr[2]][nc[2]] = t;

	i = qsize++;
	for (j = 0; j < n; j++) que[i].r[j] = nr[j], que[i].c[j] = nc[j]; 
	que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

int check(int i, int j)
{
	if (nr[i] == nr[j] && nc[i] == nc[j]) return 1;
	if (r[i] == nr[j] && c[i] == nc[j] && r[j] == nr[i] && c[j] == nc[i]) return 1;
	return 0;
}

int dijkstra()
{
	int i, j, k, t, nt;

	memset(mk, 0x55, sizeof(mk));
	for (i = n; i < 3; i++) r[i] = c[i] = nr[i] = nc[i] = 0;
	for (i = 0; i < n; i++) nr[i] = sr[i], nc[i] = sc[i];
	qsize = 0;
	enq(0);

	while (qsize) {
		for (i = 0; i < n; i++) r[i] = que[0].r[i], c[i] = que[0].c[i];
		t = que[0].t, nt = t+1, deq();

		for (i = 0; ; i++) {
			if (i == n) return t;
			if (gr[i] != r[i] || gc[i] != c[i]) break;
		}

		if (mk[r[0]][c[0]][r[1]][c[1]][r[2]][c[2]] < t) continue;

		for (i = 0; i < 5; i++) {
			if (!i) nr[0] = r[0], nc[0] = c[0];
			else {
				nr[0] = r[0] + mv[i][0], nc[0] = c[0] + mv[i][1];
				if (map[nr[0]][nc[0]] == '#') continue;
			}

		if (n >= 2) for (j = 0; j < 5; j++) {
			if (!j) nr[1] = r[1], nc[1] = c[1];
			else {
				nr[1] = r[1] + mv[j][0], nc[1] = c[1] + mv[j][1];
				if (map[nr[1]][nc[1]] == '#') continue;
			}
			if (check(0, 1)) continue;

		if (n == 3) for (k = 0; k < 5; k++) {
			if (!k) nr[2] = r[2], nc[2] = c[2];
			else {
				nr[2] = r[2] + mv[k][0], nc[2] = c[2] + mv[k][1];
				if (map[nr[2]][nc[2]] == '#') continue;
			}
			if (check(1,2) || check(0,2)) continue;
			enq(nt);
		} else enq(nt);
		} else enq(nt);
		}
	}
	return -1;
}

int main()
{
	int i, r, c;
	char buf[20], *p;

	while (fgets(buf, 20, stdin) && *buf != '0') {
		sscanf(buf, "%d%d%d", &w, &h, &n);
		for (i = n; i < 3; i++) sr[i] = sc[i] = gr[i] = gc[i] = 0;
		for (r = 0; r < h; r++) {
			fgets(p=map[r], 18, stdin);
			for (c = 0; c < w; c++) {
				if (isalpha(*p)) {
					if (islower(*p)) gr[*p-'a'] = r, gc[*p-'a'] = c;
					else             sr[*p-'A'] = r, sc[*p-'A'] = c;
					*p = ' ';
				}
				p++;
			}
		}
		printf("%d\n", dijkstra());
	}
	return 0;
}


Measured memory_bytes: 35024
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

int main() {
  int q;
  cin >> q;
  rep(i,q){
      ll a,b,c,d,s=3;
      ll f=1;
      rep(i,30) f*=3;
      cin >> a >> b >> c >> d;
      a--;b--;c--;d--;
      ll ans=abs(a-c)+abs(b-d);
      rep(i,30){
          f/=3;
          ll aa=a/f,bb=b/f,cc=c/f,dd=d/f;
          if (aa%3==1){
              if (aa==cc && abs(bb-dd)>1){
                  ll u=a-aa*f,uu=c-cc*f;
                  ll h=min(min(u,uu)*2ll+2ll,min(f-u,f-uu)*2ll);
                  ans=ans+h;
                  break;
              }
          }
          if (bb%3==1){
              if (bb==dd && abs(aa-cc)>1){
                  ll u=b-bb*f,uu=d-dd*f;
                  ll h=min(min(u,uu)*2ll+2ll,min(f-u,f-uu)*2ll);
                  ans=ans+h;
                  break;
              }
          }
      }
      cout << ans << endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    map<char, int> mp;
    rep(i,s.length())
    {
        // if (mp[s[i]])
        mp[s[i]]++;
    }
    bool flag = true;
    for (auto itr=mp.begin();itr!=mp.end();++itr)
    {
        if(itr->second%2!=0) flag = false;
    }
    if(flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int s[100],q[100];
int main()
{
    int n,a,b,p;
    cin>>n>>a>>b;
    for(int i=0;i<n;i++)
    {
        cin>>p;
        s[p]++;
    }
    q[0]=s[0];
    for(int i=1;i<=20;i++)
    {
       q[i]=q[i-1]+s[i];
    }
    int f=q[a];
    int s=abs(q[a]-q[b]);
    int th=abs(q[b]-q[20]);
    //cout<<f<<" "<<s<<" "<<th<<endl;
    cout<<min(f,min(s,th))<<endl;

    return 0;
}


Measured memory_bytes: 256
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Sun Jan 20 19:46:19 2019
//
package main

import "fmt"

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)
	if A <= C && C <= B {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
# 黒マスの数をカウントして返す
def count(il,jl):
    cnt = 0
    for k in range(h):
        for l in range(w):
            if il[k] == 0 and jl[l] == 0:
                if c[k][l] == "#":
                    cnt += 1
    return cnt


h, w, k = map(int, input().split())
c = []
for i in range(h):
    c.append(list(input()))

ans = 0

for i in range(2**h):
    il = [0] * h
    for ii in range(h):
        if i>>ii & 1:
            il[ii] = 1
    for j in range(2**w):
        jl = [0] * w
        for jj in range(w):
            if j>>jj & 1:
                jl[jj] = 1
        # print(il)
        # print(jl)
        # print("-------")
        if k == count(il, jl):
            ans += 1

print(ans)


Measured memory_bytes: 9188
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops")


using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

string s;

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s;
	if (s.size() == 1){
		cout << (s[0] == '?'?'D':s[0]);
		return 0;
	}
	for (int i = 0; i < s.size(); i++){
		if (i == 0){
			if (s[i] == '?'){
				if (s[i + 1] == 'D' || s[i + 1] == '?'){
					s[i] = 'P';
				}else s[i] = 'D';
			}
		}else{
			if (s[i] == '?'){
				if (s[i - 1] == 'P') s[i] = 'D';
				else{
					if (i == s.size() - 1) s[i] = 'D';
					else if(s[i + 1] == 'D' || s[i + 1] == '?') s[i] = 'P';
					else s[i] = 'D';
				}
			}
		}
			
	}
	cout << s;











	return 0;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    ll r=a%b;
    while(r)a=b,b=r,r=a%b;
    return b;
}
int main(){
    ll n,x;cin>>n>>x;
    ll a;cin>>a;
    ll ans=abs(a-x);
    for(int i=0;i<n-1;i++){
        cin>>a;
        ans=gcd(ans,abs(a-x));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli gcd(lli x, lli y) {
  while (x%y != 0) {
    lli t = y;
    y = x % y;
    x = t;
  }
  return y;
}

lli lcm(lli x, lli y) {
  return x * y / gcd(x, y);
}

lli n, m;
string s, t;
int main() {
  cin >> n >> m >> s >> t;
  lli ok = true;
  for (lli i=1; i<=min(n, m); ++i) {
    if (m%i==0 && n%i==0) {
      for (lli j=0, k=0; j<n && k<m; j+=n/i, k+=m/i) {
        if (s[j] != t[k]) ok = false;
      }
    }
  }
  lli ans = ok ? lcm(n, m) : -1;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 512
W, H, x, y, r = map(int, input().split())
if x - r < 0 or W < x + r or y - r < 0 or H < y + r:
  print("No")
if x - r >= 0 and W >= x + r and x < W and r <= W / 2 and y - r >= 0 and H >= y + r and y < H and r <= H / 2 :
  print("Yes")


Measured memory_bytes: 5600
from itertools import product
from collections import Counter


def solve():
    N = int(input())
    *D, = map(int, input().split())

    l, m = [], []
    for i, j in Counter(D).items():
        if j>=3 or (i==12 and j>=2) or i==0:
            print(0)
            return
        elif j==2:
            l.append(i)
        elif j==1:
            m.append(i)

    size = len(m)
    ans = 0

    for i in product(range(2), repeat=size):
        c = []
        for j, k in enumerate(i):
            if k:
                c.append(m[j])
            else:
                c.append(24-m[j])
        for j in l:
            c.append(j)
            c.append(24-j)

        v = 24
        for j in c:
            d = min(j, 24-j)
            v = min(v, d)

        for j in range(N):
            for k in range(j+1, N):
                d = abs(c[j]-c[k])
                v = min(v, min(d, 24-d))
        ans = max(ans, v)

    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3316
N = int(input())
S = input()
string = list(S)

alphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
            'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
            'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']

#Generate empty output
output = ''

for i in range(len(S)):
    #Get the index of an alphabet in the list
    ind1 = alphabet.index(string[i])
    #Divide N by 26 and get the remainder
    ind2 = (int(ind1) + N) % 26
    #Update the letter and keep adding it to the list
    output += alphabet[ind2]

print(output)

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

int main() {
  int A,B,K;
  cin >> A >> B >> K;
  int now = min(A,B);
  while (K > 0) {
    if (A%now == 0 && B%now == 0) {
      K--;
    }
    now--;
  }
  cout << now+1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int a[200000];
signed main(){
	int n;cin>>n;
	ll cnt=0;
	rep(i,n){
		cin>>a[i];
		int b=0;
		int n=a[i];
		while(n%2==0){
			b++;
			n/=2;
		}
		cnt+=b;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,a[100],i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=n-1;i>=0;i--){
    printf("%d",a[i]);
    if(i!=0)printf(" ");
    else printf("\n");
  }
  return(0);
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  for (int i = 0; ; ++i) {
	if (i % 2 == 0) {
	  c -= b;
	  if (c <= 0) {
		cout << "Yes" << endl;
		return 0;
	  }
	} else {
	  a -= d;
	  if (a <= 0) {
		cout << "No" << endl;
		return 0;
	  }
	}
  }	
    
    return 0;
}



Measured memory_bytes: 3600
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include<ctime>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#define mem(name,value) memset(name,value,sizeof(name))
#define loop(i,from,to) for(int i=from;i<to;i++)
#define pb push_back
using namespace std;
typedef long long ll;

const int maxn=100000+5;
int par[maxn],n,q,v;
char op;
bool marked[maxn];
ll ans;

void init(int N)
{
    loop(i,0,N)
        par[i]=i;
}

int main()
{
    while(scanf("%d%d",&n,&q)!=EOF){
        if(n==0 && q==0) break;
        init(n+1);
        mem(marked,false);
        marked[1]=true;
        ans=0;
        loop(i,2,n+1)
            scanf("%d",&par[i]);
        loop(i,0,q){
            getchar();
            scanf("%c%d",&op,&v);
            if(op=='M') marked[v]=true;
            if(op=='Q'){
                while(!marked[v]) v=par[v];
                ans+=v;
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define fastii        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl         "\n"
#define f0(i,n)     for(int i=0; i<n; i++)
#define f1(i,n)     for(int i=1; i<=n; i++)
#define mp           make_pair
#define pb           push_back
#define F           first
#define S           second
#define ll             long long int
#define pi            pair<int , int>
#define ai(v)       v.begin(),v.end()
#define air(v)     v.rbegin(),v.rend()
#define pii         3.14159265358979323
#define inf     LLONG_MAX
#define fill(a,b)   memset(a,b,sizeof(a))
#define mod 1000000007

ll static t[101][100001];

ll mod_pow(ll a,ll b,ll m)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
        {
        res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}
ll gcd (ll a,ll b)
{
  if (b==0)
    return a;
  return (a%b,b);
}

void sieveofEratosthenes(ll n)
{
    bool prime[n+1];
    fill(prime,true);
    for(int i=2; i*i<=n; i++)
    {
        if (prime[i]==true)
        {
            for(int j=i*i; j<=n; j+=i)
                prime[j]=false;
        }
    }
    for(int i=2; i<=n; i++)
    {
        if (prime[i])
            cout<<i<<" ";
    }
}

ll mod_inverse(ll a)
{
return mod_pow(a , mod-2 , mod);
}
ll knapsack(ll wt[],ll val[],ll W,ll n)
{

    if (n==0||W==0)
        return 0;
    if(t[n][W]!=-1)
        return t[n][W];
    if (wt[n-1]<=W)
        return t[n][W]= max(val[n-1]+knapsack(wt,val,W-wt[n-1],n-1),knapsack(wt,val,W,n-1));
    else if(wt[n-1]>W)
        return (t[n][W]= knapsack(wt,val,W,n-1));
}
void solve()
{
    ll n,W;
    cin>>n>>W;
    ll wt[n],val[n];
    f0(i,n)
    {fill(t,-1);
        cin>>wt[i];cin>>val[i];
    }

   cout<< knapsack(wt,val,W,n)<<endl;;

}
signed main()
{
fastii;
 int T=1;

 while (T--)
    {

        solve();
    }
 return 0;
}



/*Author :- Ankit Raj
*Site:-
*Topic:-
* Competative Programming
*email :-
*Technocrats Institute Of Technology
*5th Sem
*/


Measured memory_bytes: 82568
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007LL
#define mod2 1000000009LL
#define base1 19
#define base2 31
#define base3 137
#define MAX 1e12
#define MIN -10000000000
#define pi acos(-1)
#define esp 1e-6
#define memz(x) memset(x, 0, sizeof x)
#define memn(x) memset(x, -1, sizeof x)
#define pb push_back
#define nai string::npos
#define in1(a) scanf("%lld", &a)
#define in2(a,b) scanf("%lld%lld", &a, &b)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(i) printf("Case #%lld: ", ++i)
#define FILE    freopen("input.txt", "r", stdin); freopen("out.txt", "w", stdout);
using namespace std;
const ll N = 300010;
ll a, b;
int main()
{
    in2(a,b);
    ll high = 100000000000, low=0, mid, ans=-1;
    if(a<b)
        while(high>=low)
        {
            mid=(high+low)/2;
            ll x = abs(a-mid);
            ll y = abs(b-mid);
            if(x==y)
            {
                printf("%lld\n", mid);
                return 0;
            }
            if(x>y)
                high=mid-1;
            else low=mid+1;
        }
    else
        while(high>=low)
        {
            mid=(high+low)/2;
            ll x = abs(a-mid);
            ll y = abs(b-mid);
            if(x==y)
            {
                printf("%lld\n", mid);
                return 0;
            }
            if(x>y)
                low=mid+1;
            else
                high=mid-1;
        }
    printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int n=sc.nextInt();
String[] w=new String[n];
for (int i = 0; i < n; i++) {
    w[i]=sc.next();
}
HashSet<String> set=new HashSet<>();
set.add(w[0]);
for (int i = 1; i < n; i++) {
    set.add(w[i]);
    if(w[i].charAt(0)!=w[i-1].charAt(w[i-1].length()-1)){
        out.println("No");
       exit(0);
    }
}
if(set.size()==n){
    out.println("Yes");
}else{
    out.println("No");
}
}}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int a[3][105];
int main()
{
    int n;
    scanf("%d",&n);
    int i,j;
    for(i=1;i<=2;i++)
        for(j=1;j<=n;j++){
            scanf("%d",&a[i][j]);
            a[i][j] += max(a[i-1][j],a[i][j-1]);
        }
    printf("%d\n",a[2][n]);
    
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt(), m = sc.nextInt();
			if((n|m) == 0) break;
			
			int[] wx = new int[n], wy = new int[n];
			int[] bx = new int[m], by = new int[m];
			
			for(int i=0;i<n;i++) {
				wx[i] = sc.nextInt(); wy[i] = sc.nextInt();
			}
			
			for(int i=0;i<m;i++) {
				bx[i] = sc.nextInt(); by[i] = sc.nextInt();
			}
			
			boolean ok = false;
			for(int i=0;i<n;i++) for(int j=0;j<m;j++) {
				boolean flg = true;
				ArrayList<P> on = new ArrayList<P>();
				
				int v = 0;
				for(int k=0;k<n;k++) {
					int tmp = cross(wx[i], wy[i], bx[j], by[j], wx[k], wy[k]);
					if(tmp == 0) on.add(new P(wx[k], wy[k], true));
					if(tmp == -v && v != 0) { flg = false; break; }
					if(tmp != 0) v = tmp;
				}
				if(!flg) continue;
				v = -v;
				for(int k=0;k<m;k++) {
					int tmp = cross(wx[i], wy[i], bx[j], by[j], bx[k], by[k]);
					if(tmp == 0) on.add(new P(bx[k], by[k], false));
					if(tmp == -v && v != 0) { flg = false; break; }
					if(tmp != 0) v = tmp;
				}
				
				if(!flg) continue;
				sort(on);
//				for(P p: on) debug(p.x, p.y, p.c);
				int cnt = 0;
				for(int k=1;k<on.size();k++) if(on.get(k).c ^ on.get(k-1).c) cnt++;
				
				if(cnt <= 1) {
					ok = true;
					break;
				}
			}
			
			System.out.println((ok? "YES": "NO"));
		}
	}
	
	int cross( int x1, int y1, int x2, int y2, int x, int y ) {
		if( (x1 - x2) * (y - y1) ==  (x - x1) * (y1 - y2)) return 0;
		return (x1 - x2) * (y - y1) < (x - x1) * (y1 - y2)? -1: 1;
	}
	
	class P implements Comparable<P> {
		int x, y; boolean c;
		P(int x, int y, boolean c) {
			this.x = x; this.y = y; this.c = c;
		}
		
		public int compareTo(P arg0) {
			// TODO 自動生成されたメソッド・スタブ
			if(x != arg0.x) return x - arg0.x;
			return y - arg0.y;
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 85256
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
l.sort(key=lambda x:x[0])
ans=0
for i in range(n):
  s,t=l[i]
  if m-t<=0:
    ans+=s*m
    break
  else:
    m-=t
    ans+=s*t
print(ans)

Measured memory_bytes: 29024
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;

int main()
{
    string ori_s, s;
    int q, t, f;
    cin >> ori_s >> q;
    bool is_rev = false;
    ori_s.reserve(q);
    s.reserve(q);
    for(int i = 0; i < q; i++)
    {
        cin >> t;
        if(t == 1) is_rev = !is_rev;
        else
        {
            cin >> f >> s;
            if(is_rev)
            {
                if(f == 1) ori_s += s;
                else ori_s.insert(0, s);
            }
            else
            {
                if(f == 1) ori_s.insert(0, s);
                else ori_s += s;
            }
        }
    }

    if(is_rev) reverse(ori_s.begin(), ori_s.end());
    cout << ori_s << endl;
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  vector<bool> isprime(100001, true);
  isprime[0] = false;
  isprime[1] = false;
  rep(i, 2, sqrt(100000)+1) {
    if(isprime[i]) {
      ll j = 2*i;
      while(j <= 100000) {
        isprime[j] = false;
        j += i;
      }
    }
  }
  
  ll q;
  cin >> q;
  
  vector<ll> a(100000);
  for(ll i = 1; i <= 100000; i += 2) {
    if(isprime[i] and isprime[(i+1)/2])
      a[i-1]++;
  }
  vector<ll> wa(100001, 0);
  rep(i, 0, 100001) {
    wa[i+1] = wa[i] + a[i];
  }
  
  rep(i, 0, q) {
    ll l, r;
    cin >> l >> r;
    cout << wa[r]-wa[l-1] << "\n";    
  }
  
}

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

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

ll mod = 1e9+7;
ll N,M;
ll S[100005],T[100005];

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

    cin >> N >> M;

    for (int i = 0;i < N;i++){
        cin >> S[i];
    }
    for (int i = 0;i < M;i++){
        cin >> T[i];
    }

    ll dp[2003][2003];

    for (int i = 0;i <= N;i++){
        dp[i][0] = 1;
    }
    for (int i = 0;i <= M;i++){
        dp[0][i] = 1;
    }

    for (int i = 1;i <= N;i++){
        for (int j = 1;j <= M;j++){
            dp[i][j] = (dp[i][j-1]+dp[i-1][j]+mod-dp[i-1][j-1])%mod;
            if(S[i-1] == T[j-1]) dp[i][j] = (dp[i][j]+dp[i-1][j-1])%mod;
        }
    }

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

    return 0;

}

Measured memory_bytes: 31616
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

x,a,b = map(int,input().split())
c = abs(x-a)
d = abs(x-b)
if c<d:
    print("A")
else:
    print("B")

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

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

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

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

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

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

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

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

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

    xs
}

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

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

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

    ret
}

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

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

fn main(){
    let xs = read_ints2(5);
    let ys : Vec<i64> = xs.iter().map(|&x| if x % 10 == 0 { x } else {(x+9)/10*10}).collect();
    let z = (xs.iter().map(|x|(x+9)%10).min().unwrap()+1)%10;
    let s : i64 = ys.iter().sum();

    println!("{}",s- if z == 0 {0}else{10-z});
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
int main(){
  int n, k; cin >> n >> k;
  vector<int> v(n);
  for(int i = 0; i < n; ++i){
    cin >> v[i];
  }
  int ru = k - 2, div = k - 1;
  cout << (n - 1 + ru) / div << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#define pb push_back
#define mk make_pair
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int uii;
typedef pair<int,int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, pair<int, int> >piii;
typedef unsigned long long uLL; 
typedef vector<int> vii; 
const int inf = 1e9;
const LL INF = 1e18;
const int M = 1e9 + 7;
//__int128
const int maxn = 2005;
int a[maxn][maxn], b[maxn][maxn], c[maxn][maxn], d[maxn][maxn];
char s[maxn][maxn];
int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	int h, w;
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> h >> w;
	for(int i = 1; i <= h; ++i){
		cin >> (s[i] + 1);
	}
	for(int i = 1; i <= h; ++i){
		for(int j = 1; j <= w; ++j){
			if(s[i][j] == '.' && i - 1 > 0 && s[i - 1][j] == '.')
				a[i][j] = a[i - 1][j] + 1;
			if(s[i][j] == '.' && j - 1 > 0 && s[i][j - 1] == '.'){
				b[i][j] = b[i][j - 1] + 1;
			}
		}
	}
	for(int i = h; i >= 1; --i){
		for(int j = w; j >= 1; --j){
			if(s[i][j] == '.' && i + 1 <= h && s[i + 1][j] == '.'){
				c[i][j] = c[i + 1][j] + 1;
			}
			if(s[i][j] == '.' && j + 1 <= w && s[i][j + 1] == '.'){
				d[i][j] = d[i][j + 1] + 1;
			}
		}
	}
	int res = 0;
	for(int i = 1; i <= h; ++i){
		for(int j = 1; j <= w; ++j){
			if(s[i][j] == '.'){
				res = max(res, 1 + a[i][j] + b[i][j] + c[i][j] + d[i][j]);
			}
		}	
	}
	cout << res << endl;
	return 0;
}

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

using namespace std;

int main() {
  int h;
  cin>>h;
  vector<int> vec(4);
  vec[0]=h%10;
  h/=10;
  vec[1]=h%10;
  h/=10;
  vec[2]=h%10;
  vec[3]=h/10;
  for(int tmp=0;tmp<8;tmp++){
    bitset<3> s(tmp);
    int x=vec[3];
    for(int i=0;i<3;i++){
      if(s[i]==0){
        x+=vec[2-i];
      }
      else{
        x-=vec[2-i];
      }
    }
    if(x==7){
      cout<<vec[3];
      for(int i=0;i<3;i++){
        
        if(s[i]==0){
        cout<<'+';
      }
        else{
        cout<<'-';;
      }
        cout<<vec[2-i];
      }
      cout<<"=7"<<endl;
      return 0;
    }
  }
    
    
  
}


Measured memory_bytes: 3640
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.equals("A")) {
			System.out.println("T");
		} else if(s.equals("C")) {
			System.out.println("G");
		} else if(s.equals("G")) {
			System.out.println("C");
		} else {
			System.out.println("A");
		}
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
#define lm0 (ll) 0
using namespace std;

int main() {
    ll N, mod=1000000007;
    int K;
    cin >> N >> K;
    ll p=pow(N, 0.50);
    vector<vector<ll>> dp(1+p*2, vector<ll>(K+1, (ll) 0));
    for(ll i=0; i<p; ++i){
        dp[i][0]=i+1;
        dp[i][1]=1;
    }
    for(ll i=0; i<p; ++i) dp[p+i][0]=N/(i+1);
    dp[p*2][0]=p;
    for(ll i=0; i<p; ++i){
        dp[p+i][1]=dp[p+i][0]-dp[p+i+1][0];
    }
    ll sum=N;
    for(int i=2; i<=K; ++i){
        ll cnt=0;
        for(ll j=0; j<p; ++j){
            dp[j][i]=sum;
            sum=(sum+mod-dp[p+j][i-1])%mod;
            cnt=(cnt+dp[j][i])%mod;
        }
        sum=0;
        for(ll j=0; j<p; ++j){
            sum=(sum+dp[j][i-1])%mod;
            dp[p+j][i]=(dp[p+j][1]*sum)%mod;
            cnt=(cnt+dp[p+j][i])%mod;
        }
        sum=cnt;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 52096
n=int(input())
a=list(map(int,input().split()))
ave=0
for i in range(n):
    ave+=a[i]
ave/=n
if ave in a:
    ans=a.index(ave)
    print(ans)
else:
    min=101
    for i in range(n):
        gap=abs(ave-a[i])
        if min>gap:
            min=gap
            num=a[i]
    print(a.index(num))


Measured memory_bytes: 3060
A, B, K = map(int,input().split())
if A + B <= K:
    a = 0
    b = 0
else:
    if K == 0:
        a = A
        b = B
    elif K > A:
        a = 0
        b = abs(B-(K-A))
    elif K == A:
        a = 0
        b = B
    elif K < A:
        a = A - K
        b = B
print(a,b)

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

int main() {
int n,q[100000],z=4e4;
cin>>n;
for(int i=0;i<n;i++){
    int p;
    cin>>p;
    p--;
    q[p]=i;
}
for(int i=0;i<n;i++){
    cout<<(i+1)*z;
    if(i<n-1)cout<<" ";
    else cout<<endl;
}
for(int i=0;i<n;i++){
    cout<<(n-i)*z+q[i];
    if(i<n-1)cout<<" ";
    else cout<<endl;
}
	return 0;
}

Measured memory_bytes: 768
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    int N;
    cin >> N;
    REP(i,100){
      REP(j,100){
        if((i*4+j*7)==N){
          cout << "Yes" << endl;
          exit(0);
        }
      }
    }
    cout << "No" << endl;
          exit(0);
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

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


bool f(ll x,ll K,ll N,vector<ll> A,vector<ll> F)
{
	ll res=0;
	rep(i,N)
	{
		res+=max(A[i]-x/F[i],(ll)0);
	}
	return res<=K;
}
int main()
{
	ll N,K;
	cin>>N>>K;
	vector<ll> A(N);
	rep(i,N) cin>>A[i];
	vector<ll> F(N);
	rep(i,N) cin>>F[i];
	sort(A.begin(),A.end());
	sort(F.begin(),F.end(),greater<ll>());
	ll head=-1;
	ll tail=A[N-1]*F[0];
	while(tail-head>1)
	{
		ll mid=head+(tail-head)/2;
		if(f(mid,K,N,A,F))
		{
			tail=mid;
		}
		else
		{
			head=mid;
		}
	}
	cout<<tail<<endl;
	return 0;
}


Measured memory_bytes: 9504
import java.util.*;
import static java.lang.Math.*;

public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		final long stackSize = 8*1024*1024;
		new Thread(null, new AOJ1330(), "RUN", stackSize).start();
	}
	
	class AOJ1330 implements Runnable{
		AOJ1330(){}
		@Override public void run(){
//			long start = System.currentTimeMillis();
			while(sc.hasNext()){
				N=sc.nextInt();
				M=sc.nextInt();
				if((N|M)==0)	break;
				solve();
			}
//			System.out.println( (System.currentTimeMillis()-start)+"ms");
		}
		
		int N,M;
		
		void solve(){
			UnionFind uf = new UnionFind(N);
			for(int i=0; i<M; ++i){
				if(sc.next().equals("!")){
					int a=sc.nextInt(), b=sc.nextInt(), w=sc.nextInt();
					--a;
					--b;
					uf.unite(a, b, w);
				}else{
					int a=sc.nextInt(), b=sc.nextInt();
					int ret = uf.getWeight(--a, --b);
					System.out.println(ret>=uf.INF? "UNKNOWN" : ret);
				}
			}
			System.gc();
		}
		
//		// Union-Find Tree
		class UnionFind{
			int[] par,w;
			final int INF = Integer.MAX_VALUE/4;
			
			UnionFind(int n){
				par = new int[n];
				w = new int[n];
				for(int i=0; i<n; ++i)	par[i]=i;
			}
			
			int find(int x){
				if(par[x] == x)	return x;
				else{
					int tmp = find(par[x]);
					w[x] += w[par[x]];
					return par[x] = tmp;
				}
			}
			
			void unite(int x,int y,int ww){
				int px=find(x),
					py=find(y);
				if(px==py)	return;
				
				w[px] = ww - w[x];
				par[px] = y;
			}
			
			int getWeight(int x,int y){
				int xx = find(x),
					yy = find(y);
				return (xx==yy? w[x]-w[y] : INF);
			}
			
		}
}}

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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;

#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)

int main(){
    ll N;
    vector<ll> P;
    cin >> N;
    REP(i,0,N){
        ll p;
        cin >> p;
        P.push_back(p);
    }
    ll ret = 0;
    ll cur_min = LLONG_MAX;
    REP(i,0,N){
        if(P[i] < cur_min){
            ret++;
            cur_min = P[i];
        }
    }
    cout << ret << endl;
    return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

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

const ll INF=1LL<<60;
const ll MOD=1e9+7;

int main(){
    int N, M; cin >> N >> M;
    cout << (N == M ? "Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  string s;
  cin >> s;
  int isA = 0;
  int isB = 0;
  rep(i, s.size())
  {
    if (s.at(i) == 'A')
    {
      isA = i;
      break;
    }
  }
  for (int i = s.size() - 1; i > 0; i--)
  {
    if (s.at(i) == 'Z')
    {
      isB = i;
      break;
    }
  }
  cout << isB - isA + 1 << endl;
  return 0;
}

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

int main(void)
{
	int a,b,c;
	double s=0,l=0,h=0,ra,pi=3.141592653589;
	scanf("%d%d%d",&a,&b,&c);
	ra=c*pi/180;
	s=0.5*a*b*sin(ra);
	l=sqrt(a*a+b*b-2*a*b*cos(ra))+a+b;
	h=s*2/a;
	printf("%8lf\n%8lf\n%8lf\n",s,l,h);
    return 0;
}

Measured memory_bytes: 2932
using System;
using System.Collections.Generic;

namespace _4_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var ans = new List<int>();
            while (true)
            {
                var aopb = Console.ReadLine().Split(' ');
                var a = int.Parse(aopb[0]);
                var op = aopb[1];
                if (op == "?") break;
                var b = int.Parse(aopb[2]);
                switch(op)
                {
                    case "+":
                        ans.Add(a + b);
                        break;
                    case "-":
                        ans.Add(a - b);
                        break;
                    case "/":
                        ans.Add(a / b);
                        break;
                    case "*":
                        ans.Add(a * b);
                        break;
                }
            }
            foreach(var ch in ans)
            {
                Console.WriteLine(ch);
            }
        }
    }
}



Measured memory_bytes: 17900
# coding: utf-8

count = int(input())
num = input().rstrip().split(" ")

min,max = int(num[0]),int(num[0])
sum = 0

for i in range(count):
    sum = sum + int(num[i])
    if int(min) > int(num[i]):
        min = int(num[i])
    if int(max) < int(num[i]):
        max = int(num[i])

print(str(min) + " " + str(max) + " " + str(sum))

Measured memory_bytes: 8380