akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef vector<xy_t> polygon;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 29;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, n) for(int i = n; i >= 0; i--)

bool fail[1000];
int nxt[1000];

bool check(string s, int n){
	if(n % 3 == 0 && n % 5 == 0) return s == "FizzBuzz";
	if(n % 3 == 0) return s == "Fizz";
	if(n % 5 == 0) return s == "Buzz";
	if(!isdigit(s[0])) return false;
	return n == atoi(s.c_str());
	int num = 0;
	int sz = s.size();
	rep(i, sz){
		if(!isdigit(s[sz-1-i])) return false;
		num = num * 10 + s[sz-1-i] - '0';
	}
	return num == n;
}

int main(){
	int m, n;
	int rest;
	string s;
	while(cin >> m >> n && (m || n)){
		getline(cin, s);
		memset(fail, false, sizeof(fail));
		rep(i, m){
			nxt[i] = (i+1)%m;
		}
		int pos = m-1;
		rest = m;
		rep(i, n){
			getline(cin, s);
			
			if(rest == 1 ) continue;
			if(!check(s, i+1)){
				int tmp = nxt[pos];
				nxt[pos] = nxt[tmp];
				fail[tmp] = true;
				rest--;
			}else{
				pos = nxt[pos];
			}
		}
		
		vector<int> res;
		rep(i, m) if(!fail[i]) res.push_back(i+1);
		rep(i, (int)res.size()){
			if(i != 0) cout << " ";
			cout << res[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 960
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        String T = scanner.next();

        char[] schar = S.toCharArray();
        char[] tchar = T.toCharArray();

        int answer = 0;
        for(int i=0; i<3; i++){
            if(schar[i] == tchar[i]){
                answer++;
            }
        }

        System.out.println(answer);
    }
}

Measured memory_bytes: 21588
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt();
		int A[]=new int[26];
		int z=0,y=0;
		while(z<n){
			String a=stdIn.next();
			int G[]=new int[26];
			while(y<a.length()){
				char b=a.charAt(y);
				G[b-'a']++;
				y++;
			}y=0;
			while(y<26) {
				if(z==0||A[y]>G[y])
					A[y]=G[y];
				G[y]=0;
				y++;
			}y=0;
			z++;
		}z=0;
		while(z<26) {
			while(y<A[z]) {
				System.out.print((char)(z+97));
				y++;
			}y=0;
			z++;
		}
		System.out.println();
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
int main(){
        int a, b, c, d; cin >> a >> b >> c >> d;
        int x = (a + d - 1) / d;
        int y = (c + b - 1) / b;
        cout << ((x >= y) ? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll d[MAXn];
ll fpow(ll a,ll b){
    ll ret = 1;
    while (b) {
        if (b&1) ret = ret*a%MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return ret%MOD;
}
int main(){
    IOS();
    ll n;
    cin >> n;
    ll sum = 0;
    for (int i=0;i<n;++i) {
        cin >> d[i];
        sum += d[i];
    }
    ll ans = 0;
    for (int i=0;i<n;++i) {
        ans = (ans + ((sum - d[i])%MOD) * d[i]) % MOD;
        sum -= d[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n, a, b;

int main() {
    cin >> n >> a >> b;
    if(n*a < b) cout << n*a << endl;
    else cout << b << endl;
}

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

#define int long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

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

  vi cnt(26);
  rep(i, n) cnt[s[i]-'a']++;

  int ans = 1;
  rep(i, 26) ans = ans*(cnt[i]+1)%mod;
  
  cout << ans-1 << endl;

  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
  int x,y,tmp,r;

  scanf("%d%d",&x,&y);

  if(x<y){
    tmp = x;
    x = y;
    y = tmp;
  }
 
  r = x % y;
  while(r!=0){
    x = y;
    y = r;
    r = x % y;
  }
 
  printf("%d\n", y);
 
  return 0;


}



Measured memory_bytes: 2144
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n;cin>>n,n;){
		vi a(n);
		rep(i,n)
			cin>>a[i];
		sort(allof(a));
		vi b(n);
		partial_sum(allof(a),b.begin());
		ll res=0;
		rep(i,n-1)
			res+=b[i];
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream> 
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn = 200300;
int n, m, to1[maxn], ton[maxn];

int main(){
	cin >> n >> m;
	to1[1] = 1;
	ton[n] = 1;
	for (int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y;
		if (x == 1) to1[y] = 1;
		if (y == n) ton[x] = 1;
	}
	bool flag = 0;
	for (int i = 1; i <= n; i++) if (to1[i] && ton[i]) flag = 1;
	if (flag) cout << "POSSIBLE";
	else cout << "IMPOSSIBLE";
}

Measured memory_bytes: 1792
def prime_decomposition(n):
    p = 2
    prime = {}
    while n!=1:
        while n%p == 0:
            n = n/p
            if p not in prime:
                prime[p] = 0
            prime[p] += 1
        p += 1
    return prime

N = int(input())
primes = {}
for i in range(1,N+1):
    # print('now prime_decomposition',i)
    i_prime = prime_decomposition(i)
    for p in i_prime:
        if p not in primes:
            primes[p] = 0
        primes[p] += i_prime[p]

over75 = 0
over25 = 0
over15 = 0
over5 = 0
over3 = 0
for p in primes:
    # print('now primes',p)
    if primes[p]>=74:
        over75 += 1
    if primes[p]>=24:
        over25 += 1
    if primes[p]>=14:
        over15 += 1
    if primes[p]>=4:
        over5 += 1
    if primes[p]>=2:
        over3 += 1

ans75 = over75
ans253 = over25*(over3-1)
ans155 = over15*(over5-1)
ans553 = over5*(over5-1)/2*(over3-2)

ans = ans75+ans253+ans155+ans553

print(int(ans))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
using namespace std;

int infe[20010];

int main(){
	int N,M;
	while(cin >> N >> M && N){
		vector< pair<int, pair<int,int> > > v;
		for(int i = 0 ; i < M ; i++){
			int t,s,d;
			cin >> t >> s >> d;
			v.push_back(make_pair(t,make_pair(s,d)));
		}
		for(int i = 0 ; i < 20010 ; i++)
			infe[i] = 0;
		infe[1] = 1;
		sort(v.begin(),v.end());
		for(int i = 0 ; i < M ; i++){		
			if( infe[v[i].second.first] ){
				infe[v[i].second.second] = 1;
			}
		}
		int ans = 0;
		for(int i = 0 ; i < 20010 ; i++)
			ans += infe[i];
		cout << ans << endl;
	}
}

Measured memory_bytes: 1756
import math

A,B,H,M=map(int,input().split())

A_angle=H*30+0.5*M
B_angle=M*6

angle=math.radians(abs(A_angle-B_angle))

ans=math.sqrt(A**2+B**2-2*A*B*math.cos(angle))

print(ans)

Measured memory_bytes: 9440
#include<iostream>
#include<string.h>


int main(){
	char S[100000];
	std::cin >> S;
	int kodomo[strlen(S)];
	int flag = 0;
	int renzoku = 1;
	kodomo[0] = 0;
	
	for(int i = 0;i < strlen(S);i++){
		kodomo[i+1] = 0;
		if(flag == 0){
			if(S[i+1] == 'R'){
				renzoku++;
			}else{
				kodomo[i] += (renzoku-1)/2+1;
				kodomo[i+1] += renzoku/2;
				renzoku = 1;
				flag = 1;
			}
		}else{
			if(S[i+1] == 'L'){
				renzoku++;
			}else{
				kodomo[i-renzoku] += (renzoku)/2;
				kodomo[i-renzoku+1] += (renzoku-1)/2+1;
				renzoku = 1;
				flag = 0;
			}
		}
		
	}	

	for(int i = 0;i < strlen(S);i++){
		std::cout << kodomo[i] << " ";
	}

	return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin >> n;
	int sum=500;
	int count=0;
	int a=0;
	for(int i=1;i<n;i++){
		a=n-i;
		count=a/10000+(a/1000)%10+(a/100)%10+(a/10)%10+a%10+i/10000+(i/1000)%10+(i/100)%10+(i/10)%10+i%10;
		if(sum>count){
			sum=count;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;
 
public class Main {
	static ArrayList<Integer> primes;
	static int[] isComposite;

	static void sieve(int N)	// O(N log log N) 
	{
		isComposite = new int[N+1];					
		isComposite[0] = isComposite[1] = 1;			// 0 indicates a prime number
		primes = new ArrayList<Integer>();

		for (int i = 2; i <= N; ++i) 					//can loop till i*i <= N if primes array is not needed O(N log log sqrt(N)) 
			if (isComposite[i] == 0) 					//can loop in 2 and odd integers for slightly better performance
			{
				primes.add(i);
				if(1l * i * i <= N)
					for (int j = i * i; j <= N; j += i)	// j = i * 2 will not affect performance too much, may alter in modified sieve
						isComposite[j] = 1;
			}   
	}
	public static void main(String[] args) throws IOException {
		MScanner sc = new MScanner(System.in);
		//BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(System.out);
		int n=sc.nextInt();
		int[]a=new int[n+1];
		int[]in=new int[n];
		for(int i=0;i<=n;i++) {
			a[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++) {
			in[i]=sc.nextInt();
		}
		long ans=0;
		for(int i=0;i<n;i++) {
			long t=Math.min(in[i],a[i]);
			ans+=t;
			in[i]-=t;a[i]-=t;
			long t2=Math.min(in[i],a[i+1]);
			in[i]-=t2;a[i+1]-=t2;
			ans+=t2;
		}
		pw.println(ans);
		
		pw.close();
		pw.flush();
 
	}
	static int gcd(int a, int b) {

		if (b == 0)
			return a;
		return gcd(b, a % b);
	}
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 44100
if __name__ == '__main__':
	form = input().split()
	stack = []
	for i in range(len(form)):
		if form[i] == "+":
			y=stack.pop()
			x=stack.pop()
			stack.append(x+y)
		elif form[i] == "-":
			y=stack.pop()
			x=stack.pop()
			stack.append(x-y)
		elif form[i] == "*":
			y=stack.pop()
			x=stack.pop()
			stack.append(x*y)
		elif form[i] == "/":
			y=stack.pop()
			x=stack.pop()
			stack.append(x/y)
		elif form[i] == "%":
			y=stack.pop()
			x=stack.pop()
			stack.append(x%y)
		else:
			stack.append(int(form[i]))
	print(stack[0])


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

long long N, K;

int main() {
    cin >> N >> K;

    if (K * N > N * (N + 1) / 2) {
        cout << -1 << '\n';
        return 0;
    }

    vector<pair<int, int>> AB;

    for (int i = 0; i < N; i++)
        AB.emplace_back(i, 2 * N - 1 - i);

    int need = (N - 1) / 2;
    int start = 0;

    for (int d = need; d > 0; d -= 2) {
        swap(AB[start].first, AB[start + d].first);
        start++;
    }

    start = need + 1;

    for (int d = need - 1; d > 0; d -= 2) {
        swap(AB[start].first, AB[start + d].first);
        start++;
    }

    auto compare_sum = [&](pair<int, int> x, pair<int, int> y) {
        return x.first + x.second < y.first + y.second;
    };

    sort(AB.begin(), AB.end(), compare_sum);

    for (int i = 0; i < N; i++)
        cout << AB[i].first + K << ' ' << AB[i].second + K << ' ' << 2 * N + i + K << '\n';
}


Measured memory_bytes: 3188
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin>>n;
	vi a(n),b(n);
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	int s=0;
	rep(i,n)s+=max(0ll,a[i]-b[i]);
	cout<<s<<endl;
}











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

int main()
{
  int T;
  int n;
  string s;

  bool up[10001], down[10001];
  int dp[2][10001];

  cin >> T;
  for (int t=0;t<T;t++)
  {
    cin >> n;
    cin >> s;

    memset(up, false, sizeof(up));
    memset(down, false, sizeof(down));

    if (s[0] == 'Y') up[0]=true;
    if (s[2*n] == 'Y') down[0]=true;
    for (int c=1;c<=n-1;c++)
    {
      if (s[2*c-1] == 'Y' || s[2*c] == 'Y') up[c]=true;
      if (s[2*n+2*c-1] == 'Y' || s[2*n+2*c] == 'Y') down[c]=true;
    }
    if (s[2*n-1] == 'Y') up[n]=true;
    if (s[4*n-1] == 'Y') down[n]=true;

    if (down[0])
    {
      dp[0][0] = 3;
      dp[1][0] = 2;
    }
    else if (up[0])
    {
      dp[0][0] = 1;
      dp[1][0] = 1;
    }
    else
    {
      dp[0][0] = 0;
      dp[1][0] = 1;
    }

    int v0, v1;
    for (int c=1;c<=n;c++)
    {
      // dp[0][c]????¨????
      if (down[c])
      {
        v0 = dp[0][c-1] + 4;
        v1 = dp[1][c-1] + 3;
      }
      else if (up[c])
      {
        v0 = dp[0][c-1] + 2;
        v1 = dp[1][c-1] + 2;
      }
      else
      {
        v0 = dp[0][c-1] + 1;
        v1 = dp[1][c-1] + 2;
      }
      dp[0][c] = min(v0, v1);

      // dp[1][c]????¨????
      if (up[c] && down[c])
      {
        v0 = dp[0][c-1] + 3;
        v1 = dp[1][c-1] + 3;
      }
      else if (down[c])
      {
        v0 = dp[0][c-1] + 3;
        v1 = dp[1][c-1] + 2;
      }
      else if (up[c])
      {
        v0 = dp[0][c-1] + 2;
        v1 = dp[1][c-1] + 2;
      }
      else
      {
        v0 = dp[0][c-1] + 2;
        v1 = dp[1][c-1] + 1;
      }
      dp[1][c] = min(v0, v1);

    }
    cout << dp[0][n] << endl;

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

  }
  return 0;
}

Measured memory_bytes: 1412
#include<iostream>
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<cstring>
#include<string>
#define N 100001
using namespace std;

int main()
{
	long long  x,a[45];
	cin>>x;
	a[0]=2;
	for(int i=1;i<=x;i++)
	{
		a[i]=2+2*a[i-1];
	}
	cout<<a[x];
   return 0;     
}

Measured memory_bytes: 256
#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; cin >> a >> b >> c;
    cout << a + b + c - max({a, b, c}) << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
      final var br = new BufferedReader(stdin)) {
      final var n = Integer.parseInt(br.readLine());

      int ac = 0;
      int wa = 0;
      int tle = 0;
      int re = 0;

      for (int i = 0; i < n; i++) {
        switch (br.readLine()) {
          case "AC":
            ac++;
            break;
          case "WA":
            wa++;
            break;
          case "TLE":
            tle++;
            break;
          case "RE":
            re++;
            break;
        }
      }

      System.out.println("AC x " + ac);
      System.out.println("WA x " + wa);
      System.out.println("TLE x " + tle);
      System.out.println("RE x " + re);
    }
  }
}


Measured memory_bytes: 43264
#include <iostream>
#include <cmath>

using namespace std;

int N;
long long a[100000];
long long b[100000];

int main(){
    cin >> N;
    bool f = false;
    for(int i=0;i<N;i++){
        cin >> a[i];
        b[i] = a[i];
        if(a[i] == 0) f = true;
    }
    long long aa=0,bb=0;
    for(int i=0;i<N-1;i++){
        if(a[i] < 0){
            a[i+1] *= -1;
        }
    }
    if(a[N-1] > 0) f = true;
    if(f){
        for(int i=0;i<N;i++) aa += abs(a[i]);
        cout << aa << endl;
        return 0;
    }
    bb = 1e9+7;
    for(int i=0;i<N;i++){
        aa += abs(a[i]);
        bb = min(bb,abs(a[i]));
    }
    cout << aa - 2 * bb << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int K, A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> K >> A >> B;

	rep(x, A, B + 1) if (x % K == 0) {
		cout << "OK" << endl;
		return;
	}
	cout << "NG" << endl;
}







Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6+5;
int n,m,k,y,cnt;
struct node{
	int x,y;
};
bool operator < (node a,node b)
{
	if(a.x==b.x)return a.y<b.y;
	return a.x<b.x;
}
node a[N];
signed main()
{
	cin>>n>>k;
	int x=(n-1)*(n-2)/2;
	if(k>x){puts("-1");return 0;}
	for(int i=1;i<n;i++)a[++m]=(node){i,n};
	if(k<x)
	{
		for(int i=1;i<n;i++)
		{
			for(int j=i+1;j<n;j++)
			{
				x--;
				a[++m]=(node){i,j};
				if(k==x)break;	
			}
			if(k==x)break;
		}
	}
	cout<<m<<endl;
	for(int i=1;i<=m;i++)cout<<a[i].x<<" "<<a[i].y<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    long a, b, x;

    AtCoder(FastScanner sc) {
        a = sc.nextLong();
        b = sc.nextLong();
        x = sc.nextLong();
    }

    void solve(PrintWriter out) {
        long ans = b / x - a / x;
        out.println(a % x == 0 ? ans + 1 : ans);
    }

}

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: 22484
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N = I()
 
ans = 0
for i in range(1, N+1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        ans += i
 
print(ans)


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

int main(){
	long long x,n;
	cin>>x;
	n=0;
/*	n=x/11;
	if(x<=6){
		cout<<1;
		return 0;
	}
	if(x<=11){
		cout<<2;
		return 0;
	}
	if((n*11)>=(x-5)){
		cout<<n*2-1;
		return 0;
	}
	if((n*11)>=x){
		cout<<n*2;
		return 0;
	}
	if((n*11)<x){
		cout<<n*2+1;
		return 0;
	}*/

	
	int mm=1;
	n=x/11;
	x=x-n*11;
	n=2*n;
	while(x>0){
		n++;
		if (mm==1){
		    x=x-6;
		    mm=0;}
		else{
			mm=1;
			x=x-5;
		}
	}
	cout<<n;
	
    return 0;
}


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

ll a[1234567];
ll b[1234567];
int main()
{
   ll n,cur,c=0,i;
   cin>>n;
   for(i=1; i<=n; i++)
   {
       cin>>b[i];
      a[b[i]]=i;

   }
   for(i=1;i<=n;i++){
    if(i==1)cout<<a[i];
    else cout<<" "<<a[i];
   }


}


Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
 int main()
 {
 	 double a,b,c,d,e,f,x,y;
         while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF)
  {
  	 y=(c*d-f*a)/(b*d-e*a); x=(c-b*y)/a; 
 	  printf("%.3f %.3f\n",x,y);
  }
   return 0;
 }


Measured memory_bytes: 3160
s = input()
a = 0
for i in range(0, len(s), 2):
    if s[i] in ['R', 'U', 'D']:
        a += 1
for i in range(1, len(s), 2):
    if s[i] in ['L', 'U', 'D']:
        a += 1

print('Yes' if a == len(s) else 'No')    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
struct node {
    int to,next;
}E[MAXN * 2];
int head[MAXN],sumE;
int N,M,Q;
int dp[MAXN][11];
int c[MAXN],d[MAXN],v[MAXN];
void add(int u,int v) {
    E[++sumE].to = v;E[sumE].next = head[u];head[u] = sumE;
}
void dfs(int v,int d) {
    if(!d) return;
    for(int i = head[v] ; i ; i = E[i].next) {
	int t = E[i].to;
	if(dp[t][d - 1] < dp[v][d]) {
	    dp[t][d - 1] = dp[v][d];
	    dfs(t,d - 1);
	}
    }
}
void Solve() {
    read(N);read(M);
    int a,b;
    for(int i = 1 ; i <= M ; ++i) {
	read(a);read(b);
	add(a,b);add(b,a);
    }
    read(Q);
    for(int i = 1 ; i <= Q ; ++i) {
	read(v[i]);read(d[i]);read(c[i]);
    }
    for(int i = Q ; i >= 1 ; --i) {
	if(dp[v[i]][d[i]] < i) {
	    dp[v[i]][d[i]] = i;
	    dfs(v[i],d[i]);
	}
    }
    for(int i = 1 ; i <= N ; ++i) {
	int g = 0;
	for(int j = 0 ; j <= 10 ; ++j) {
	    g = max(g,dp[i][j]);
	}
	out(c[g]);enter;
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 510;
const double eps = 1e-6;

int n;
map<int, int> h;

int main()
{
    cin >> n;
    while(n--)
    {
        int x;
        cin >> x;
        if(!h.count(x) || !h[x]) h[x] = 1;
        else h[x] = 0;
    }

    int res = 0;
    for(auto it = h.begin(); it != h.end(); it++)
        if(it->second)
            res++;

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


Measured memory_bytes: 4992
#include<stdio.h>

int main(void){

    int N,i,result = 0,V[20],C[20];

    scanf("%d",&N);
    for(i = 0;i < N;i++){
        scanf("%d",&V[i]);
    }
    for(i = 0;i < N;i++){
        scanf("%d",&C[i]);
    }

    for(i = 0;i < N;i++){
        if(V[i] > C[i]){
            result += V[i] - C[i];
        }
    }

    printf("%d",result);
    return 0;
}

Measured memory_bytes: 128
import scala.io.StdIn.readInt

object Main extends App {
  def replace(i:Char) = i match {
    case '4' => '5'
    case '5' => '7'
    case '6' => '8'
    case '7' => '9'
    case x => x
  }

  def scan(n:Int,b:Long,p:Long):String = {
    val (m,r) = (n/8, n%8)
    if(m==0) (b + r*p).toString.map(c => replace(c))
    else scan(m, b+r*p, p*10)
  }

  Iterator.continually(readInt).takeWhile( _ != 0 ).foreach { n=>
    println(scan(n,0,1))
  }
}

Measured memory_bytes: 70044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;

int main(){
    int n,k; cin>>n>>k;
    vector<vector<int>> a(k);
    vector<int> snuke(n,0);
    rep(i,0,k){
        int x; cin>>x;
        rep(j,0,x){
            int y;
            cin>>y;
            y--;
            a[i].push_back(y);
            snuke[y]++;
        }
    }

    int ans=0;
    rep(i,0,n){
        if(snuke[i]==0) ans++;
    }


    cout<<ans<<endl;

}

Measured memory_bytes: 3656
import java.util.*;
import java.io.*;
import java.lang.*;
class Main{
  public static void main(String args[]){
    int id, l, r,root=0;
    StringBuilder build = new StringBuilder();
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Node node[] = new Node[n];

    for(int i = 0; i<n; i++){
      node[i] = new Node();
    }

    for(int i = 0; i<n; i++){
      id = sc.nextInt();
      l = sc.nextInt();
      r =  sc.nextInt();
      node[id].left = l;
      node[id].right = r;
      if(l != -1)node[l].parent = id;
      if(r != -1)node[r].parent = id;
    }

    for(int i = 0;i<n; i++){
      if(node[i].parent==-1)root = i;
    }
    setDepth(root,0,node);

    for(int i = 0 ; i < n; i++){
      build.append("node ").append(i).append(": parent = ").append(node[i].parent).append(", sibling = ").append(getSibling(i,node)).append(", degree = ").append(getDegree(i,node)).append(", depth = ").append(node[i].depth).append(", height = ").append(getHeight(i, node));
      if(node[i].parent==-1)build.append(", root\n");
      else if(node[i].right == -1 && node[i].left == -1)build.append(", leaf\n");
      else build.append(", internal node\n");
    }

    System.out.print(build);

  }

  static int getHeight(int u, Node node[]){
    int h1 = 0;
    int h2 = 0;
    if(node[u].right != -1)h1 = getHeight(node[u].right, node) +1;
    if(node[u].left != -1)h2 = getHeight(node[u].left, node) +1;

    return Math.max(h1,h2);
  }

  static void setDepth(int u,int d,Node node_d[]){
    if( u == -1)return;
    node_d[u].depth = d;
    setDepth(node_d[u].right,node_d[u].depth+1, node_d);
    setDepth(node_d[u].left, node_d[u].depth+1, node_d);
  }

  static int getSibling(int u, Node node[]){
    if(node[u].parent == -1)return (-1);
    if(node[node[u].parent].left != u && node[node[u].parent].left!=-1)return node[node[u].parent].left;
    if(node[node[u].parent].right != u && node[node[u].parent].right!=-1)return node[node[u].parent].right;
    return (-1);
  }

  static int getDegree(int u, Node node[]){
    int count=0;
    if(node[u].left != -1)count++;
    if(node[u].right != -1)count++;
    return count;
  }
}

class Node{
  int parent = -1;
  int left = -1;
  int right = -1;
  int depth = 0;
}


Measured memory_bytes: 26292
import java.util.*;
 
public class Main {
 
  static Scanner in = new Scanner(System.in);
	int[] a, b, c;
	void solve() {
		int n = in.nextInt();
		a = new int[n]; b = new int[n]; c = new int[n];
		for(int i = 0; i < n; i++) a[i] = in.nextInt();
		for(int i = 0; i < n; i++) b[i] = in.nextInt();
		for(int i = 0; i < n; i++) c[i] = in.nextInt();
		Arrays.sort(a); Arrays.sort(b); Arrays.sort(c);
		long sum = 0;
		for(int i = 0; i < n; i++){
			long t = search_small(a, b[i]);
			long s = search_big(c, b[i]);
			s = s <= 0 ? n + s : n - s - 1; 
			sum += s * t;
		}
		System.out.println(sum);
	}
 
  int search_small(int[] x, int key){
	  int left = 0, right = b.length;
	  while(left < right){
		   int mid = (left + right) / 2;
		   if(x[mid] == key && mid > 0 && x[mid - 1] != key) return mid;
		   else if(key <= x[mid]) right = mid;
		   else left = mid + 1;
	  }
	  return left;
  }
  int search_big(int[] x, int key){
	int left = 0, right = b.length;
	while(left < right){
		 int mid = (left + right) / 2;
		 if(x[mid] == key && mid < x.length - 1 && x[mid + 1] != key) return mid;
		 else if(key < x[mid]) right = mid;
		 else left = mid + 1;
	}
	return -1 * left;
}
  
  public static void main(String[] args) {
	  new Main().solve();
  }
}

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

bool isPrime(int t)
{
	int flag=0;
	for(int i=2;i<=sqrt(t);++i)
	{
		if(t%i==0)
		{
		flag=1;
		break;
		}
	}
	return flag;
}

int main()
{
	ios_base::sync_with_stdio(false);	
	cin.tie(NULL);
	int t{0};
	cin>>t;
	int flag=0;
	while(isPrime(t))
	{
		t+=1;
	}
	cout<<t<<"\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = sc.nextInt();
	int d = sc.nextInt();
	int e = sc.nextInt();
	int f = sc.nextInt();
	int g = 0;
	int ansA = 0;
	int ansS = 0;
	double conc = 0;
	for(int i=0; 100*a*i<=f; i++) {
		for(int j=0; 100*b*j<=f-100*a*i; j++) {
			for(int k=0; c*k<=f-100*a*i-100*b*j; k++) {
				for(int l=0; d*l<=f-c*k-100*a*i-100*b*j; l++) {
					g = 100 * a * i + 100 * b * j + c * k + d * l;
					if(g>0 && (double)(c*k+d*l)/g <= (double)e/(100+e) && conc <= (double)100*(c*k+d*l)/g) {
						conc = (double)100*(c*k+d*l)/g;
						ansA = g;
						ansS = c * k + d * l;
					}
				}
			}
		}
	}
	System.out.println(ansA);
	System.out.println(ansS);
}
}


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

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

using ll = long long;
using P = pair<ll,ll>;
using grid = vector<vector<int>>;

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
const int INF = 1<<30;
const ll mod = 998244353LL;

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

int main() {
    int N;
    cin>>N;
    ll ans = 0;
    rep(i,N+1){
        if(i%3!=0&&i%5!=0) ans = ans + i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 1e9+7
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define M 110


int main(){
    IOS;
 
 	
 	ll x,y;cin>>x>>y;
 	bool ok=1;
 	ll b=(y-2*x);
 	if(b&1)ok=0;
 	b>>=1;
 	ll a=x-b;
 	if(a<0 or b<0)ok=0;
 	cout<<(ok?"Yes":"No");
    return 0;
}

Measured memory_bytes: 3628
if __name__ == "__main__":
    n, x = map(int, input().split())
    a = list(map(int, input().split()))

    if sum(a) == x:
        print(n)
        exit()

    a.sort()

    ans = 0
    for i in range(n):
        if sum(a[:i+1]) <= x:
            ans = i+1
        else:
            print(i)
            exit()

    if sum(a[:ans]) == x:
        print(ans)
    else:
        print(ans-1)


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define debug cout<<"****************"<<endl
using namespace std;
typedef long long ll;
inline void ju() {
	freopen("***.in","r",stdin);
	freopen("***.out","w",stdout);
}
inline ll rd() {
	ll x=0,f=1; char c=getchar();
	while((c<'0'||c>'9')&&(c!='-')) c=getchar();
	if(c=='-') f=-1,c=getchar();
	while(c>='0'&&c<='9') {
		x=(x<<3)+(x<<1)+c-'0';
		c=getchar();
	}
	return x*f;
}
int a[110];
int ans=1e9;
int main() {
	int n=rd();
	for(int i=1;i<=n;++i) a[i]=rd();
	for(int k=-100;k<=100;++k) {
		int sum=0;
		for(int i=1;i<=n;++i) sum+=(a[i]-k)*(a[i]-k);
		ans=min(ans,sum);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long
int main()
{
    int A , B;
    scanf("%d %d",&A,&B);
    if (B%A==0)printf("%d",A+B);
    else printf("%d",B-A);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.util.TreeMap;
import java.util.ArrayList;
import java.util.Collections;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[M];
        int[] C = new int[M];
        ArrayList<Integer> lista = new ArrayList<Integer>();
        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
            lista.add(A[i]);
        }
        Collections.sort(lista);
        TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>(Collections.reverseOrder());
        for(int i=0; i<M; i++){
            B[i] = sc.nextInt();
            C[i] = sc.nextInt();
            if(map.containsKey(C[i])){
                map.put(C[i], map.get(C[i]) + B[i]);
            }
            else{
                map.put(C[i], B[i]);
            }
        }
        
        ArrayList<Integer> list = new ArrayList<Integer>();
        loop:for(int key: map.keySet()){
            for(int j=0; j<map.get(key); j++){
                list.add(key);
                if(list.size()==N){
                    break loop;
                }
            }
        }
        long ans = 0;
        for(int i=0; i<N; i++){
            if(list.size()>i){
                if(lista.get(i)<list.get(i)){
                    A[i] = list.get(i);
                }
                else{
                    A[i] = lista.get(i);
                }
            }
            else{
                A[i] = lista.get(i);
            }
            ans += A[i];
        }
        System.out.println(ans);
    }
}

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

int main() {
	string s;
	std::cin >> s;
	
	sort(s.begin(), s.end());
	
	if(s[0]==s[1] and s[2]==s[3] and s[1] != s[2]) std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000

int main(){
    ll n; cin >> n; bool jud = true; ll ans = 0;
    vector<vector<ll>> a(n,vector<ll>(n));
    vector<vector<ll>> dp(n,vector<ll>(n));
    vector<vector<ll>> ansl(n,vector<ll>(n));
    REP(i,n) REP(j,n) cin >> a[i][j];
    REP(i,n) REP(j,n) dp[i][j]=a[i][j];
    REP(i,n) REP(j,n) ansl[i][j]=a[i][j];
    REP(k,n) REP(i,n) REP(j,n){
        if (k!=i&&k!=j&&ansl[i][j]==dp[i][k]+dp[k][j]) ansl[i][j]=0;
        dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
    }
    REP(i,n) REP(j,n) if (a[i][j]!=dp[i][j]) jud = false;
    if (jud){
        REP(i,n) REP(j,n) ans+=ansl[i][j];
        cout << ans/2 << endl;
    }
    else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

//Prime Factorization(素因数分解)
map<ll,int> divisor; //約数を入れるmap
void PF(ll n){
    divisor.clear();
    ll c = n;
    for(int i = 2; i <= sqrt(n); i++){
        while(c%i == 0){
            divisor[i]++;
            c /= i;
        }
    }
    if(c != 1) divisor[c]++;
    return ;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n; cin >> n;
    ll res = 1;
    PF(n-1);
    for(auto v:divisor) res *= (v.second + 1);
    for(int i = 2; i <= sqrt(n) ; i++){
        ll c = n;
        if(n % i) continue;
        while(!(c % i)) c /= i;
        if((c % i) == 1) res++;
        c = n;
        ll j = n / i;
		if(i == j) continue;
        while(!(c % j)) c /= j;
        if((c % j) == 1) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <map>
using namespace std;

int l[50];
int t[50];
int r[50];
int b[50];

// right, down, left, up
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };

bool can[200][200][4];
bool visit[200][200];

int H, W;

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

void dfs(int x, int y) {
	visit[y][x] = true;
	for(int k = 0; k < 4; k++) {
		if(can[y][x][k]) {
			int nx = x + dx[k], ny = y + dy[k];
			if(!visit[ny][nx]) dfs(nx, ny);
		}
	}
}

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

	int n;
	while(cin >> n, n) {
		map<int, int> X, Y;
		for(int i = 0; i < n; i++) {
			cin >> l[i] >> t[i] >> r[i] >> b[i];
			for(int j = 0; j <= 1; j++) {
				X[l[i] + j] = -1;
				X[r[i] + j] = -1;
				Y[t[i] + j] = -1;
				Y[b[i] + j] = -1;
			}
		}

		H = Y.size(), W = X.size();

		int cnt = 0;
		for(auto& p : X) {
			X[p.first] = cnt++;
		}
		cnt = H - 1;
		for(auto& p : Y) {
			Y[p.first] = cnt--;
		}

		for(int y = 0; y < H; y++) {
			for(int x = 0; x < W; x++) {
				for(int k = 0; k < 4; k++) {
					int nx = x + dx[k], ny = y + dy[k];
					can[y][x][k] = in(nx, ny);
				}
			}
		}

		for(int i = 0; i < n; i++) {
			for(int x = X[l[i] + 1]; x <= X[r[i]]; x++) {
				can[Y[t[i]]][x][3] = false; // up
				can[Y[t[i] + 1]][x][1] = false; // down
				can[Y[b[i]]][x][3] = false; // up
				can[Y[b[i] + 1]][x][1] = false; // down
			}
			for(int y = Y[t[i]]; y <= Y[b[i] + 1]; y++) {
				can[y][X[l[i]]][0] = false; // right
				can[y][X[l[i] + 1]][2] = false; // left
				can[y][X[r[i]]][0] = false; // right
				can[y][X[r[i] + 1]][2] = false; // left
			}
		}

		memset(visit, 0, sizeof visit);
		int ans = 0;
		for(int y = 0; y < H; y++) {
			for(int x = 0; x < W; x++) {
				if(!visit[y][x]) {
					ans++;
					dfs(x, y);
				}
			}
		}
		cout << ans << endl;
	}
}

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

using namespace std;

typedef long long ll;

ll N, A;
ll x[55];
ll dp[55][2555][55];

ll solve(ll idx, ll sum, ll num)
{
  if(idx == N) {
    if(sum == A*num) return 1LL;
    else return 0LL;
  }
  ll &ret = dp[idx][sum][num];
  if(~ret) return ret;
  ret = solve(idx+1LL, sum, num) + solve(idx+1LL, sum+x[idx], num+1LL);
  return ret;
}

int main()
{
  cin >> N >> A;
  for(int i = 0; i < N; i++) cin >> x[i];
  memset(dp, -1LL, sizeof(dp));
  cout << solve(0LL, 0LL, 0LL) - 1 << endl;
  return 0;
}


Measured memory_bytes: 60672