akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> bool chmax(T &a, U b) { if (a < b) a = b; return true; }
template<class T, class U> bool chmin(T &a, U b) { if (a > b) a = b; return true; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  int a, b; cin >> a >> b;
  if (a >= 10 || b >= 10) cout << -1 << endl;
  else cout << a * b << endl;

  return (0);
}


Measured memory_bytes: 3588
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);
		String str = sc1.next();
		String[] array = new String[26];
		HashMap<Character,Integer> map = new HashMap<Character,Integer>();

		array[0] = "a";
		array[1] = "b";
		array[2] = "c";
		array[3] = "d";
		array[4] = "e";
		array[5] = "f";
		array[6] = "g";
		array[7] = "h";
		array[8] = "i";
		array[9] = "j";
		array[10] = "k";
		array[11] = "l";
		array[12] = "m";
		array[13] = "n";
		array[14] = "o";
		array[15] = "p";
		array[16] = "q";
		array[17] = "r";
		array[18] = "s";
		array[19] = "t";
		array[20] = "u";
		array[21] = "v";
		array[22] = "w";
		array[23] = "x";
		array[24] = "y";
		array[25] = "z";

		map.put('a', 0);
		map.put('b', 1);
		map.put('c', 2);
		map.put('d', 3);
		map.put('e', 4);
		map.put('f', 5);
		map.put('g', 6);
		map.put('h', 7);
		map.put('i', 8);
		map.put('j', 9);
		map.put('k', 10);
		map.put('l', 11);
		map.put('m', 12);
		map.put('n', 13);
		map.put('o', 14);
		map.put('p', 15);
		map.put('q', 16);
		map.put('r', 17);
		map.put('s', 18);
		map.put('t', 19);
		map.put('u', 20);
		map.put('v', 21);
		map.put('w', 22);
		map.put('x', 23);
		map.put('y', 24);
		map.put('z', 25);

		String a = "null";
		String ans = "";
		if("zyxwvutsrqponmlkjihgfedcba".equals(str)) {
			System.out.println("-1");
		}
		else {
			for (int i = 0 ; i < 26 ; i++ ) {
				if(str.indexOf(array[i])==-1) {
					a = array[i];
					ans = str + a;
					break;
				}
			}

			if (a.equals("null")) {
				for (int i = 25 ; i > 0 ; i-- ) {
					if(map.get(str.charAt(i)) > map.get(str.charAt(i-1))){

						char c = str.charAt(i-1);
						char d = 'z';
						for (int j = 25 ; j > i-1 ; j-- ) {
							if(map.get(str.charAt(j)) > map.get(c)) {
								if(map.get(str.charAt(j)) < map.get(d)) {
									d = str.charAt(j);
								}
							}
						}
						ans = str.substring(0, i-1) + d;
						break;
					}
				}
			}
			System.out.println(ans);
		}
		sc1.close();
	}
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/22  Problem: ABC 052 C / Link: http://abc052.contest.atcoder.jp/tasks/abc052_c  ----- */

map<LL, LL> make_factor(long long  N) {
	map<LL, LL>ans;
	FOR(x, 1, N + 1) {
		LL n = x;
		for (long long i = 2; i * i <= n; i++) {
			while (n%i == 0) {
				ans[i]++;
				n /= i;
			}
		}
		if (n != 1)ans[n]++;
	}
	return ans;
}

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

	LL N;
	cin >> N;
	auto facts = make_factor(N);
	LL ans = 1;
	for (auto it : facts) {
		ans *= it.second + 1;
		ans %= MOD;
	}


	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
  int n;
  int a;
  int flag[200020]={};
  cin >> n;
  for (int i=2;i<=n;i++){
  	cin >> a;
  	flag[a]++;
  }
  for (int i=1;i<=n;i++){
  	cout << flag[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4420
#G
import pprint
H,W,K=map(int,input().split())
import copy
x1,y1,x2,y2=map(int,input().split())
#raw=["#"]+["."]*(601)+["#"]
lastraw=["@"]*(W+2)
field=[["@"]*(W+2)]
for i in range(H):
  field.append(["@"]+list(input())+["@"])
 
field.append(lastraw)
 
#print(field)
 
goal_point=(y2,x2)
 
[sy,sx]=[y1,x1]
[gy,gx]=[y2,x2]
 
field[x1][y1]=0
queue=[[sy,sx]]
tests = ((-1,0),(0, 1),(1, 0),(0, -1))
moves=0
 
while True:
  if len(queue)==0:
    moves=-1
    break
  queue_next = []
  moves += 1
  #pprint.pprint(field)
  for y, x in queue:
    for ny, nx in tests:
      ty, tx = y + ny, x + nx
      if field[tx][ty] == '.':
        field[tx][ty] = moves
        queue_next.append((ty, tx))
        #print(ty,tx)
        for i in range(K-1):
          ty, tx = ty + ny, tx + nx
          if field[tx][ty] == '.':
            field[tx][ty] = moves
            queue_next.append((ty, tx))
            #print(ty,tx)
          elif field[tx][ty] ==moves:
            k=0
          else:
            break
      elif field[tx][ty] ==moves:
        #field[tx][ty] = moves
        #queue_next.append((ty, tx))
        #print(ty,tx)
        for i in range(K-1):
          ty, tx = ty + ny, tx + nx
          if field[tx][ty] == '.':
            field[tx][ty] = moves
            queue_next.append((ty, tx))
            #print(ty,tx)
          elif field[tx][ty] ==moves:
            k=0
          else:
            break
  queue = queue_next
  if goal_point in queue:
    break
#pprint.pprint(field)
print(moves)

Measured memory_bytes: 200004
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;

	int up[100];
	int dn[100];
	for (int i = 0; i < N; i++) {
		cin >> up[i];
		if (i > 0)
			up[i] += up[i - 1];
	}
	for (int i = 0; i < N; i++) {
		cin >> dn[i];
		if (i > 0)
			dn[i] += dn[i - 1];
	}

	int max;
	for (int i = 0; i < N; i++) {
		int drops = up[i];
		drops += dn[i] - (i > 0 ? dn[i - 1] : 0);
		drops += dn[N - 1] - dn[i];
		if (drops > max) max = drops;
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
py = []
for _ in range(m):
  py.append(list(map(int,input().split())) + [0])

sortPy = sorted(py, key = lambda x : (x[0], x[1]))
 
d = {}
for i, (p, y, n) in enumerate(sortPy):
  if p in d:
    d[p] += 1
  else:
    d[p] = 1
  sortPy[i][2] = d[p]

for p, y, n in py:
  print(str(p).zfill(6) + str(n).zfill(6))

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

using namespace std;

int main()
{
   int n,m;
   cin>>n>>m;
   int sum=0;
   while(m--)
   {
       int x;
       cin>>x;
       sum+=x;
   }
   if(sum<n)
   {
       cout<<n-sum<<endl;
   }
   else if(sum==n) cout<<0<<endl;
   else{cout<<-1<<endl;}
    return 0;
}


Measured memory_bytes: 3604
from collections import deque
def q4():
    class Room:
        def __init__(self, i):
            self.id = i
            self.d = -1
            self.next = []
            self.sign = -1

        def add_next(self, n):
            self.next.append(n)

        def print(self, tab=0, printed=[]):
            if self.id in printed:
                return
            printed.append(self.id)
            print("  " * tab + str(self.id) + f"({self.sign})")
            for n in self.next:
                n.print(tab + 1, list(printed))
    
        
    N, M = [int(i) for i in input().split(" ")]
    room_dict = {}

    def get_room(i):
        if i in room_dict:
            return room_dict[i]
        else:
            room = Room(i)
            room_dict[i] = room
            return room

    for i in range(M):
        A, B = [int(i) for i in input().split(" ")]
        get_room(A).add_next(get_room(B))
        get_room(B).add_next(get_room(A))


    d = 0
    sign = -1
    queue = deque([[get_room(1), d, sign]])
    while queue:
        room, d, sign = queue.popleft()
        if room.sign != -1:
            continue
        room.sign = sign
        room.d = d
        for n in room.next:
            queue.append([n, d + 1, room.id])

    print("Yes")
    for i in range(2, N + 1):
        print(get_room(i).sign)

q4()


Measured memory_bytes: 85432
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

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

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}




#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


  


int main() {
    ll n;
    cin >> n;
    vector<ll> x(n),y(n);
    map <ll,ll> ind;
  
    rep (i,n){
      cin >> x[i];
      y[i]=x[i];

    }
    ll temp;
    sort (x.begin(),x.end());
    rep (i,n){
      ind[x[i]]=i;
    }
    rep (i,n){
      if (ind[y[i]]<n/2){
        cout << x[n/2] << endl;
      }
      else cout << x[n/2-1] << endl;
      
    }
}



Measured memory_bytes: 18436
#include <stdio.h>
#define N 500001
#define INFTY 1000000000
int A[N],L[N],R[N],cnt=0;

void merge(int A[],int left,int mid,int right){
  int n1,n2,i,j,k;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }
    else {
      A[k]=R[j];
      j++;
    }
  }
}

void mergeSort(int A[],int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int main(){
  int i,j;

  scanf("%d",&j);
  for(i=0;i<j;i++)scanf("%d",&A[i]);

  mergeSort(A,0,j);


  for(i=0;i<j;i++){
    printf("%d",A[i]);
    if(i<j-1)printf(" ");
  }
  printf("\n%d\n",cnt);
  
  return 0;
}



Measured memory_bytes: 5696
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    vector<ll> b(200001);
    for(int i=n-1;i>=0;i--) b[a[i]] = i;
    vector<ll> c(n), inc(n);
    for(int i=n-1;i>=0;i--){
    	if(b[a[i]] <= i) inc[i] = 1;
    	else  inc[i] = 0;
    	c[i] = b[a[i]];
    	b[a[i]] = i;
    }
    ll num = 1, now = 0;
    while(1){
    	num += inc[now];
    	now = (c[now] + 1) % n;
    	if(now == 0) break;
    }
    k %= num;
    if(k == 0)return 0;

    num = 1;
    while(!(num == k && inc[now])){
    	num += inc[now];
    	now = c[now] + 1;
    }
    for(int i=now;i<n;i++){
    	if(inc[i] == 0) i = c[i];
    	else cout << a[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N+5,0);
  for(int i=0;i<N;i++){
    cin>>a.at(i)>>b.at(i);
    if(a.at(i)==b.at(i))
      c.at(i)=1;
  }
  int d=0;
  for(int i=0;i<N;i++){
    if(c.at(i)==1 && c.at(i+1)==1 && c.at(i+2)==1)
      d=1;
  }
    if(d==0)
      cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3628
#define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 10
#define MIN -100001
#define _MAX 10
int main(void)
{
	int n,l[MAX], v1, v2, sum = 0, sum2 = 0;
	double x1, x2;
	char ans;	  // 1, 2, 3, 4, 5, 6, 7, 8, 9,10,v1,v2
	while (scanf_s("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2], &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2) != EOF) {
		for (int i = 0; i < MAX; ++i) {
			sum += l[i];
		}
		x1 = (double)sum / (v1 + v2) * v1;
		x2 = (double)sum / (v1 + v2) * v2;
		for (int i = 0; i < MAX; ++i) {
			sum2 += l[i];
			if (sum2 >= x1 || sum - sum2 <= x2) {
				printf("%d\n", i + 1);
				break;
			}
		}
		sum = sum2 = 0;
	}

}

Measured memory_bytes: 1188
#include<cstdio>

int ymd2d(int y, int m, int d) {
    int res=0;
    y--, m--; d--;
    res += y/3*((20+19)*5*2+20*10);
    res += (y%3)*(20+19)*5;
    switch(y%3) {
        case 0:
        case 1:
            res += m/2*(20+19);
            res += (m%2)*20;
            break;
        case 2:
            res += m*20;
            break;
    }
    res += d;

    return res;
}

int main(void) {
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++) {
        int y,m,d;
        scanf("%d%d%d", &y, &m, &d);
        printf("%d\n", ymd2d(1000,1,1) - ymd2d(y,m,d));
    }
    return 0;

}

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

int main(){
	int N; cin>>N;
	vi A(N); rep(i, N) cin>>A[i];
	int Q; cin>>Q;
	vector<vi> BC(Q, vi(2));
	rep(i, Q) cin>>BC[i][0]>>BC[i][1];

	long long s = 0;
	map<int, int> C;
	rep(i, N){ s += A[i]; C[A[i]]++; }

	for(auto bc:BC){
		int b = bc[0], c = bc[1];
		s += (c - b) * C[b];
		C[c] += C[b];
		C[b] = 0;
		cout<< s << endl;
	}
}


Measured memory_bytes: 13476
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n, t;
	scanf("%d%d", &n, &t);
	int c, ti, ans = INF;
	rep(i, n) {
		scanf("%d%d", &c, &ti);
		if (ti <= t)ans = min(ans, c);
	}
	if (ans != INF)printf("%d\n", ans);
	else printf("TLE\n");

	Please AC;
}


Measured memory_bytes: 256
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using V = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(n, m, x);
    vector<ll> c(n);
    vector<vector<ll>> a(n);
    rep(i, n)
    {
        cin >> c[i];
        rep(j, m)
        {
            IN(aj);
            a[i].push_back(aj);
        }
    }
    ll ans = INF;
    for (int bit = 0; bit < (1<<n); ++bit)
    {
        vector<int> S;
        for (int i = 0; i < n; ++i)
        {
            if (bit & (1<<i))
            {
                S.push_back(i);
            }
        }
        vector<ll> b(m);
        ll s = 0;
        for (int i = 0; i < (int)S.size(); ++i)
        {
            s += c[S[i]];
            rep(j, m)
            {
                b[j] += a[S[i]][j];
            }
        }
        rep(j, m)
        {
            if (b[j] < x) goto end;
        }
        chmin(ans, s);
        end:;
    }
    cout << (ans == INF ? -1 : ans) << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3664
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		String A = sc.next();
		String B = sc.next();
		String C = sc.next();
		if (A.charAt(A.length()-1) == B.charAt(0) && B.charAt(B.length()-1) == C.charAt(0))
			System.out.println("YES");
		else
			System.out.println("NO");

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define y1 zzz
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
int n,x[100010],y[100010];
vector<int> v;
bool cmp(PII a,PII b)
{
    return a.se<b.se;
}
void solve()
{
    cin>>n;
    vector<PII> a;
    for(int i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
        a.pb({x[i]-y[i],x[i]+y[i]});
    }
    sort(all(a),cmp);
    int res=0,cur=-1e18;
    for(int i=0;i<n;i++)
    {
        if(cur<=a[i].fi)
        {
            res++;
            cur=a[i].se;
        }
    }
    cout<<res;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("XORQUERY.inp","r",stdin);
    //freopen("XORQUERY.out","w",stdout);
    //int test;cin>>test;while(test--)
    solve();
    return 0;
}


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

#define sc second
#define fr first
#define mk make_pair
#define pb push_back
#define int long long

using namespace std;

const int N = (3e5 + 5);
const int inf = (1e9 + 7);

int n;
int ans = 1;
int u[28];
string a;

main () {
    cin >> n;
    cin >> a;

    for (int i = 0; i < a.size(); i ++) {
        ++u[a[i] - 'a'];
    }
    for (int i = 0; i < 26; i ++) {
        ans = (ans * (u[i] + 1)) % inf;
    }
    ans --;
    ans += inf;
    ans %= inf;

    cout << ans << endl;
}


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

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

    string s;
    cin >> s;
    int memo[26] = {};
    for (char c : s) {
        int d = c-97;
        if (memo[d] > 0) {
            cout << "no" << endl;
            return 0;
        }
        else memo[d]++;
    }
    cout << "yes" << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N), m(N);
    rep(i, N) cin >> v[i] >> w[i] >> m[i];

    vector<int> vv, ww;
    rep(i, N){
        for(int j = 0; j <= 13; j++){
            int x = pow(2, j);
            if(x > m[i]){
                break;
            }
            vv.push_back(v[i] * x);
            ww.push_back(w[i] * x);
            m[i] -= x;
        }
        for(int j = 13; j >= 0; j--){
            int x = pow(2, j);
            if(x > m[i]){
                continue;
            }
            vv.push_back(v[i] * x);
            ww.push_back(w[i] * x);
            m[i] -= x;
        }
    }

    int nn = vv.size();
    vector<int> dp(W+1, 0);
    rep(i, nn){
        vector<int> tmp(W+1);
        for(int j = W; j >= 0; j--){
            if(j < ww[i] || dp[j-ww[i]] == -1){
                tmp[j] = dp[j];
                continue;
            }
            tmp[j] = max(dp[j], dp[j-ww[i]] + vv[i]);
        }
        swap(dp, tmp);
    }

    int ans = 0;
    rep(i, W+1){
        if(ans < dp[i]){
            ans = dp[i];
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3444
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7


Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

s = ri()
if s.isupper():
    print('A')
else:
    print('a')

Measured memory_bytes: 62860
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define fix(n) cout<<fixed<<setprecision(n);
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  ll n; cin>>n;
  string s="";
  char c;
  n--;
  int a=n%26;
  s+=a+97;
  n/=26;
  while(n>0){
    char c;
    n--;
    int a=n%26;
    s+=a+97;
    n/=26;
  }
  reverse(all(s));
  co(s);
    
  return 0;
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<int> A(N);
    vector<int> W(N);

    rep(i, M){
        int p; cin >> p;
        string S; cin >> S;

        if(A[p-1] == 1){
            continue;
        } else if (S == "AC"){
            A[p-1] = 1;
        } else {
            W[p-1]++;
        }
    }

    int cor = 0;
    int wro = 0;
    rep(i, N){
        cor += A[i];
        if(A[i] == 1){
            wro += W[i];
        }
    }

    cout << cor << " " << wro << endl;
}

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

int main() {
	string s;
	cin>>s;
	string fin="";
	for(int i=0;i<s.length();++i){
		if(s[i]=='0')fin+="0";
		if(s[i]=='1')fin+="1";
		if(s[i]=='B'){
			if(fin.length()) fin.erase(fin.length()-1);
		}

	}
	cout<<fin<<endl;

	return 0;
}

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

int main(void)
{
    char s[15];
    int a = 0, sum = 0;
    cin >> s;
    for(int i = 0; s[i] != '\0'; ++i)
    {
        sum = sum*10+s[i]-'0';
        a += s[i]-'0';
    }
    if(sum%a == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define PI 3.1415926535898

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

int main() {
    int n;
    cin >> n;
    set<int> st;

    rep(i, n) {
        int d;
        cin >> d;
        st.insert(d);
    }

    cout << st.size() << endl;

    return 0;
}



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

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

int main(void){
    int N; cin >> N;
    int A,B; cin >> A >> B;
    
    int ans = min(N*A,B);
    cout << ans << endl;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,long double> P;
typedef pair<ll,P> PP;

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

int h,w;
string s[50];
int d[50][50];
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

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

	cin>>h>>w;
	REP(i,h) cin>>s[i];

	REP(i,50) REP(j,50) d[i][j]=INF;
	d[0][0]=1;
	queue<P> q;
	q.push(P(0,0));
	while(!q.empty()) {
		P p=q.front();q.pop();
		int x=p.fi,y=p.se;
		REP(i,4) {
			int nx=x+dx[i],ny=y+dy[i];
			if(nx<0||nx>=w||ny<0||ny>=h||s[ny][nx]=='#'||d[ny][nx]!=INF) continue;
			d[ny][nx]=d[y][x]+1;
			q.push(P(nx,ny));
		}
	}

	if(d[h-1][w-1]==INF) {
		cout<<-1<<endl;
		return 0;
	}

	int cnt=0;
	REP(i,h) REP(j,w) if(s[i][j]=='#') cnt++;

	cout<<h*w-cnt-d[h-1][w-1]<<endl;

	return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;
const ll MOD=1e9+7;

int main() {
    int x,y,z,k;
    cin>>x>>y>>z>>k;
    ll a[x],b[y],c[z];
    rep(i,x){
        cin>>a[i];
    }
    rep(i,y){
        cin>>b[i];
    }
    rep(i,z){
        cin>>c[i];
    }
    priority_queue<ll> q1;
    rep(i,x){
        rep(j,y){
            q1.push(a[i]+b[j]);
        }
    }
    priority_queue<ll> q2;
    for (int i=0;i<min(3000,x*y);i++){
        auto s=q1.top();
        q1.pop();
        for (int j=0;j<z;j++){
            q2.push(c[j]+s);
        }
    }
    rep(i,k){
        auto s=q2.top();
        q2.pop();
        cout<<s<<endl;
    }



    return 0;
}

Measured memory_bytes: 42980
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int a, b, c, n;
    a = sc.nextInt();
    b = sc.nextInt();
    c = sc.nextInt();
    n = 0;

    for(;a < (b + 1);a++){
      if(c % a == 0)++n;
    }

    System.out.println(n);
/*fin*/
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	vector<int> dp(N);
	for (int i = N - 2; i >= 0; i--) {
		dp[i] = H[i + 1] <= H[i] ? dp[i + 1] + 1 : 0;
	}
	cout << *max_element(dp.begin(), dp.end()) << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;

    double max_dens = -1.0;
    pair<LL, LL> ans;
    rep(a, 31) rep(b, 31) rep(c, 301) rep(d, 301) {
        LL water = 100 * A * a + 100 * B * b ;
        LL sugar = C * c + D * d;
        if (water == 0 or water + sugar > F) break;
        if (water * E / 100 >= sugar) {
            double density = 100. * sugar / (double)(water + sugar);
            if (max_dens < density) {
                ans = {water + sugar, sugar};
                max_dens = density;
            }
        }
    }
    cout << ans.first << " " << ans.second << endl;
}


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

public class Main {
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = in.i();
        char[] S = in.s(N);

        int left = 0;
        int extra = 0;
        for (int i = 0; i < N; i++) {
            if (S[i] == '(') {
                left++;
            } else if (left == 0) {
                extra++;
            } else {
                left--;
            }
        }


        for (int i = 0; i < extra; i++) {
            out.print('(');
        }
        for (int i = 0; i < N; i++) {
            out.print(S[i]);
        }
        for (int i = 0; i < left; i++) {
            out.print(')');
        }
        out.close();
    }
}

class IntStack {
    final int MAX;
    int[] array;
    int head = 0;

    IntStack(int N) {
        MAX = N;
        array = new int[N];
    }

    void push(int n) {
        array[head++] = n;
    }

     int pop() {
        return array[--head];
    }

    boolean isEmpty() {
        return head == 0;
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 32820
while True:
	cards=list(input())
	n=len(cards)
	if cards[0] == "-":
		break
	work=[0 for i in range(n)]
	for h in (int(input()) for i in range(int(input()))):
		for i in range(h,n):
			work[i-h]=cards[i]
		for i in range(h):
			work[n-h+i]=cards[i]
		for i in range(n):
			cards[i] = work[i]
	print("".join(cards))


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

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

#define rrep(i,n) for(int i =n; i >=0; --i)

#define rep_(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

#define ll long long

const ll MOD = 1000000007;

const  long double PI=(acos(-1));

const  long double EPS=0.0000000001;

int main(){
    
    int n;cin >> n;
    vector<int> p(n);
    vector<int> q(n);

    rep(i,n)cin >> p[i];
    rep(i,n)cin >> q[i];

    vector<int> s(n);
    rep(i,n)s[i] = p[i];
    sort(s.begin(),s.end());

    int cnt = 0;
    int a,b;
    do{
        if(s == p)a = cnt;
        if(s == q)b = cnt;
        cnt++;
    }while(next_permutation(s.begin(),s.end()));

    cout << abs( b - a) << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i < (b); i++)
ll modi = 1000000007;

bool cp(ll n){
    if(n == 1)return false;
    else if(n == 2)return true;
    else if(n ==3)return true;
    for(int i  = 2; i*i<=n; i++){
        if(n%i == 0){
            return false;
        }
    }
    return true;
}
void SforPrime(int n)
{
	bool prime[n+1];
	memset(prime, true, sizeof(prime));

	for (int p=2; p*p<=n; p++)
	{
		if (prime[p] == true)
		{
			for (int i=p*p; i<=n; i += p)
				prime[i] = false;
		}
	}
}
ll calPower(ll val, ll n){
    ll i = 1;
    ll ind = 1;
    ll prev = val;
    while(val<=n){
        if(n%val == 0)ind = i;
        val  = val*prev;
        i++;
    }
    return i-1;
}
bool check(ll val, int vec[]){
    while(val != 0){
        ll rem = val %10;
        if(vec[rem] == 1)return false;
        val /= 10;
    }
    return true;
}
int main(){
    //130016239756757
    ll n;
    cin>>n;
    int arr[n];
    double avg = 0;
    rep(i, 0, n){
        cin>>arr[i];
        avg += arr[i];
    }
    avg = round(avg/ n);
    ll sum = 0;
    rep(i, 0, n){
        sum += abs(avg - arr[i]) * abs(avg - arr[i]);
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ff first
#define ss second
#define cy cout<<"Yes"<<endl;
#define cn cout<<"No"<<endl;
#define urs(r...)          typename decay<decltype(r)>::type
#define fi(i,n)                for(urs(n) i=0;i<n;i++)
#define rep(i,n)               for(urs(n) i=1;i<=n;i++)
#define pb push_back
#define gap ' '
#define endl '\n'
#define mex 300000
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>*/
main()
{
	int i,j,k,n,q;
	int cnt=0;
	bool flag=0,ok=0,f=0;
  cin>>n;
  for(i=1;i<=n;i++)
  {
  	for(j=1;j<=n;j++)
	{
		for(k=1;k<=n;k++)
		{
			cnt+=__gcd(i,__gcd(j,k));
		}
	}
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3636
n,m=map(int,input().split())
a=[1]*n
b=[0]*n
b[0]=1
for _ in range(m):
    x,y=map(lambda x:int(x)-1,input().split())
    a[x] -= 1
    a[y] += 1
    if b[x]:
        if a[x] == 0:
            b[x]=0
        b[y]=1 
print(sum(b))

Measured memory_bytes: 52696
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int a,b;
    cin>>a>>b;
    vector<int>v,ev,od;
    int x=1,y=2;
    for(int i=0;i<b;i++)
    {
        v.push_back(x);
        x+=2;
    }
    for(int i=0;i<a;i++)
    {
        v.push_back(y);
        y+=2;
    }

    for(int i=0;i<v.size();i++)
    {
        //cout<<v[i]<<" ";
    }

    int c=0;
    for(int i=0;i<v.size();i++)
    {
        for(int j=i+1;j<v.size();j++)
        {
            if((v[i]+v[j])%2==0)
            {
                c++;
            }
        }
    }

    cout<<c<<endl;


    return 0;
}


Measured memory_bytes: 256
H, W = gets.chomp.split(" ").map(&:to_i)
A = []
H.times do 
    A << gets.chomp.split("").map{|char| char == '#' ? true : false} + [false]
end
A << Array.new(W+1, false)
ans = true
i, j = [0, 0]
while i < H-1 || j < W-1
    if !A[i][j] || (A[i+1][j] && A[i][j+1])
        ans = false
        break
    else
        if A[i+1][j]
            i += 1
        else
            j += 1
        end
    end
end
ans = false if A.flatten.count(true) != H + W - 1
puts ans ? "Possible" : "Impossible"

Measured memory_bytes: 1788
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;

int main()
{
	string s;
	cin >> s;
	if (s.size() >= 4)
	{
		if (s[0] == 'Y'  && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
		{
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



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

int main() {
	int n,k;cin>>n>>k;
	int d[k];
	vector<int> can(10,1);
	vector<int> can2;
	for(int i=0;i<k;i++){
		cin>>d[i];
		can[d[i]]=0;
	}
	for(int i=0;i<10;i++){
		if(can[i]){
			can2.push_back(i);
		}
	}
	int num=1;
	for(int i=0;i<5;i++){
		num*=10-k;
	}
	int ans=99999;
	for(int i=0;i<num;i++){
		int pay=0;
		int i2=i;
		for(int j=0;j<5;j++){
			pay*=10;
			pay+=can2[i2%(10-k)];
			i2/=10-k;
		}
		for(int j=0;j<5;j++){
		if(pay>=n){
			if(ans>pay){
				ans=pay;
			}
		}
		pay/=10;
		}
	}
	cout<<ans<<endl;
			//	int digit=1;
//	int n2=n;
//	while(n2>=10){
//		digit++;
//		n2/=10;
//	}
//	vector<int> v(digit);
//	for(int i=0;i<digit;i++){
//		v[digit-i-1]=n%10;
//		n/=10;
//	}
//	int ans=0;
//	int flag=0;
//	int flag2=0;
//	for(int i=0;i<digit;i++){
//		if(flag){
//			for(int j=0;j<10;j++){
//				if(can[j]){
//					ans*=10;
//					ans+=j;
//					break;
//				}
//			}
//
//		}else{
//			for(int j=0;j<10;j++){
//				if(can[j]){
//					if(v[i]<j){
//						ans*=10;
//						ans+=j;
//						flag=1;
//						break;
//					}else if(v[i]==j){
//						ans*=10;
//						ans+=j;
//						break;
//					}
//				}
//				if(j==9){
//					flag2=1;
//				}
//			}
//		}
//
//	}
//	cout<<ans<<endl;



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long  n,arr[100005],dp[100005],k;
long long  f(long long  a){
	if(a>n)return 1e18;
	if(a==n)return 0;
	if(dp[a]!=-1)return dp[a];
	long long ret = 1e18;
	for(int i =a+1;i<=min(a+k,n);i++){
		ret=min(abs(arr[i]-arr[a])+f(i),ret);
	}
	return dp[a]=ret;
}
int  main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	for(long long  i =1;i<=n;i++){
		cin>>arr[i];
	}

	cout<<f(1)<<endl;
	// for(int i =1;i<=n;i++){
	// 	cout<<dp[i]<<endl;
	// }
}

Measured memory_bytes: 6528
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var c = o.m(3);
  var a = c[1][0] - c[0][0];
  var N = "No";
  if(a + c[0][1] !== c[1][1] || a + c[0][2] !== c[1][2])return N;
  a = c[2][0] - c[0][0];
  if(a + c[0][1] !== c[2][1] || a + c[0][2] !== c[2][2])return N;
  return "Yes";
}

Measured memory_bytes: 7372
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main() {
  int N; cin >> N;
  int D[N], E[N]; for (int i = 0; i < N; i++) cin >> D[i];
  sort(D, D+N);
  if (D[0] == 0) {
    cout << 0 << endl; return 0;
  }
  int f = 1, min_dist = 50;
  for (int i = 0; i < N; i++) {
    E[i] = (D[i] * f + 24) % 24;
    f *= -1;
  }
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      min_dist = min(min_dist, abs(E[i] - E[j]));
    }
    min_dist = min(min_dist, D[i]);
  }
  cout<<min_dist<<endl;
}

Measured memory_bytes: 3648