akhauriyash/Code-Regression huggingface dataset:
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	vector<int> b(4, 0);
	rep(i, n) {
		b[a[i] % 4]++;
	}
	if (b[2] %2==0) b[2] = 0;
	else b[2] = 1;
	if (b[0] >= b[1] + b[2] + b[3] - 1) cout << "Yes";
	else cout << "No";



	return 0;
}





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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
//#define int ll
#define swap(x, y)((x)^=(y)^=(x)^=(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define tcase int _; cin>> _; for( ; _; --_)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

void solve(){
	string s;
	cin>> s;

	cout<< (s[2] == s[3] && s[4] == s[5] ?"Yes\n" : "No\n");
}

int32_t main(){
	fastio;
	solve();
	return 0;
}


Measured memory_bytes: 3584
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x) do{rep(__i,(x).size()) pri(x,__i);}while(0)
#define pran(x,n) do{rep(__i,n) pri(x,__i);}while(0)
#define pral(x) do{cerr << (#x) << " =";rep(__i,(x).size()) cerr<<" "<<(x[__i]);cerr<<endl;}while(0)
#define prar(x,b,e) do{repr(__i,b,e) pri(x,__i);}while(0)

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

ll MOD = 1000000007;

function<void(int,int)> tensi_no_3p=[&](int v,int d){
};

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

int naive() {
	int N = in();
	vint A(N), B(N);
	rep(i, N) A[i] = in();
	rep(i, N) B[i] = in();
	int ax = 0, bx = 0;
	rep(i, N)ax ^= A[i];
	rep(i, N)bx ^= B[i];
	int ans = 0;
	rep(i, N) rep(k, N) {
		ans ^= A[i] + B[k];
	}
	pr(ans);
	pr(ax);
	pr(bx);
	return 0;
}

struct Sorter {
	int mask;
	Sorter(int m): mask(m){}
	bool operator () (int a, int b) const {
		return (a & mask) < (b & mask);
	}
};

int main() {
	int N = in();
	vint A(N), B(N);
	rep(i, N) A[i] = in();
	rep(i, N) B[i] = in();
	int ans = 0;
	rep(b, 30) {
		int tow = 1 << b;
		int mask = tow - 1;
		Sorter st(mask);
		sort(A.begin(), A.end(), st);
		sort(B.begin(), B.end(), st);
		int k = N - 1;
		int count = 0;
		rep(i, N) {
			while (k >= 0 && (A[i] & mask) + (B[k] & mask) >= tow) k--;
			count += N - 1 - k;
		}
		int at = 0, bt = 0;
		rep(i, N) {
			if (A[i] & tow) at++;
			if (B[i] & tow) bt++;
		}
		if (N % 2 && (at + bt) % 2) count++;
		if (count % 2) ans ^= tow;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
def _run(N, colors):
    count = 0
    head_i = 0
    tail_i = N - 1
    while head_i < tail_i:
        if colors[head_i] == "W" and colors[tail_i] == "R":
            count += 1
            head_i += 1
            tail_i -= 1
        else:
            if colors[head_i] != "W":
                head_i += 1
            if colors[tail_i] != "R":
                tail_i -= 1

    print(count)


def _main():
    N = int(input())
    colors = str(input())
    _run(N, colors)


if __name__ == "__main__":
    _main()


Measured memory_bytes: 9520
/*
	ID: sixathofpain
	TASK: friday
	LANG: C++   

*/


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
// #define int long long int

int32_t main(){
    IOS;
	
	int n,m;
	cin>>n>>m;
	//n=> number of heads
	//m=> number of legs

	int x,y;
	//x=> number of cranes
	//y=> number of turtles

	y = (m-2*n)/2;
	x = n-y;

	if(2*x+4*y==m and x>=0 and y>=0){
		cout<<"Yes";
	}else{
		cout<<"No";
	}

    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 1000000007

int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n)cin >> h[i];
    vector<int> dp(n);
    dp[0]=0;
    for(int i=1;i<n;++i){
        int val=MAX;
        for(int j=1;j<=k;++j){
            if(i-j<0){
                break;
            }
            val=min(val,dp[i-j]+abs(h[i]-h[i-j]));
        }
        dp[i]=val;
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 4028
// Date: 2020-04-04

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int n, k, c;
char s[N];
int L[N], R[N], t1, t2;
int cnt[N];
VI ans;
vector<pii> vec;

int main() {
    scanf("%d%d%d", &n, &k, &c);
    scanf("%s", s+1);
    int pre = -inf;
    rep(i, 1, n) {
        cnt[i] = cnt[i-1];
        if(s[i] != 'x') cnt[i]++;
        if(s[i] != 'x' && i-pre > c) {
            L[++t1] = i;
            pre = i;
            if(SZ(vec) < k) vec.pb(mk(i, SZ(vec)+1));
        }
    }
    pre = inf;
    per(i, n, 1) {
        if(s[i] != 'x' && pre-i > c) {
            pre = i;
            R[++t2] = i;
        }
    }
    for(auto pa : vec) {
        int p = pa.fi, id = pa.se, r;
        if(id < k) r = R[k-id]-c-1;
        else r = n;
        if(cnt[r]-cnt[p-1] == 1) ans.pb(p);
    }
    for(auto v : ans) printf("%d\n", v);


    return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int b[n-1];
    for (int i = 0; i < n-1; ++i) cin >> b[i];

    int res = b[0] + b[n-2];
    for (int i = 1; i < n-1; ++i){
        res += min(b[i-1], b[i]);
    }

    cout << res << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

ull Euclid(ull A, ull B){
    if(A<B) swap(A, B);
    ull C = B;
    while(C != 0){
        C = A%B;
        A = B;
        B = C;
    }
    return A;
}

int main(){
    int N;
    cin >> N;
    vector<ull> T(N);
    REP(i, N) cin >> T[i];
    ull lcm = T[0];
    REP(i, T.size()){
        lcm = T[i]*(lcm/Euclid(T[i], lcm));
    }
    cout << lcm << endl;
    return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
//using namespace std;
//#define mem(a) memset(a,0,sizeof(a))
//#define dbg(x) cout<<#x<<" = "<<x<<endl
//#define ll long long
//int main()
//{
//	int na,nb,nc,n,i;
//	vector<char>C;
//	char c[100010][3];
//	cin>>n>>na>>nb>>nc;
//	//dbg(n);
//	for(i=0;i<n;i++)scanf("%s",c[i]);
//	for(i=0;i<n;i++)
//	{
//		if(!strcmp(c[i],"AB"))//AB
//		{
//			//cout<<"AB\n";//*****************
//			if(na<nb)na++,nb--,C.push_back('A');
//			else if(na>nb)na--,nb++,C.push_back('B');
//			else
//			{
//				if(c[i+1][0]=='A')na++,nb--,C.push_back('A');
//				else na--,nb++,C.push_back('B');
//			}
//		}
//		else if(!strcmp(c[i],"AC"))//AC
//		{
//			//cout<<"AC\n";//*****************
//			if(na<nc)na++,nc--,C.push_back('A');
//			else if(na>nc)na--,nc++,C.push_back('C');
//			else
//			{
//				if(c[i+1][0]=='A')na++,nc--,C.push_back('A');
//				else na--,nc++,C.push_back('C');
//			}
//		}
//		else//BC
//		{
//			//cout<<"BC\n";//*****************
//			if(nb<nc)nb++,nc--,C.push_back('B');
//			else if(nb>nc)nb--,nc++,C.push_back('C');
//			else
//			{
//				if(c[i+1][1]=='C')nb--,nc++,C.push_back('C');
//				else nb++,nc--,C.push_back('B');
//			}
//		}
//	}
//	if(na<0||nb<0||nc<0){cout<<"No";return 0;}
//	cout<<"Yes\n";
//	for(vector<char>::iterator it=C.begin();it!=C.end();it++)printf("%c\n",*it);
//	return 0;
//}
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
char s[N][5];
int main(){
    int n,na,nb,nc;
    cin>>n>>na>>nb>>nc;
    for(int i=1;i<=n;i++)scanf("%s",s[i]+1); 
    vector<char>C;
    for(int i=1;i<=n;i++)
    {    
		if(s[i][1]=='A'&&s[i][2]=='B')
		{
            if(na>nb)na--,nb++,C.push_back('B');
            else if(na<nb)na++,nb--,C.push_back('A');
            else 
			{
                if(s[i+1][1]=='A')na++,nb--,C.push_back('A');
                else na--,nb++,C.push_back('B');
            }
        }
        else if(s[i][1]=='A'&&s[i][2]=='C')
		{
            if(na>nc)na--,nc++,C.push_back('C');
            else if(na<nc)na++,nc--,C.push_back('A'); 
            else 
			{
                if(s[i+1][1]=='A')na++,nc--,C.push_back('A');
                else na--,nc++,C.push_back('C');
            }
        }
        else 
		{
            if(nb>nc)nb--,nc++,C.push_back('C');
            else if(nb<nc)nb++,nc--,C.push_back('B'); 
            else 
			{
                if(s[i+1][2]=='C')nb--,nc++,C.push_back('C');
                else nb++,nc--,C.push_back('B');
            }
        } 
        if(na<0||nb<0||nc<0) return cout<<"No"<<endl,0;
    }
    puts("Yes");
    for(vector<char>::iterator it=C.begin();it!=C.end();it++)
    {
    	printf("%c\n",*it);
	}
    return 0;
}

Measured memory_bytes: 4396
#include <stdio.h>
#include <map>

using namespace std;

#define MAXN 100005

int A[MAXN];
map<int, int> m;

int main() {
	int N;
	int ans = 0;

	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d", A + i);

	for(int i = 0; i < N; i++) m[A[i]]++;
	for(auto &kv : m) ans += kv.second >= kv.first ? kv.second - kv.first : kv.second;

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


Measured memory_bytes: 5120
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int M = nextInt();

		int[][] AB = new int[N][2];
		for(int i=0;i<N;i++) {
			AB[i] = nextIntArray(2);
		}
		Arrays.sort(AB,(a1,a2)->Integer.compare(a2[1],a1[1]));
		Arrays.sort(AB,(a1,a2)->Integer.compare(a1[0],a2[0]));

		List<Integer> list = new ArrayList<Integer>(N);
		long sum = 0;
		int AB_i = 0;
		for(int l=1;l<=M;l++) {
			int Search_l = -1;
			while(AB_i<N&&AB[AB_i][0]==l) {
				int Insert_i = Search(list ,AB[AB_i][1],Search_l);
				if(M<Insert_i)break;// 候補外となるため挿入する必要なし
				list.add(Insert_i,AB[AB_i][1]);
				AB_i++;
				Search_l = Insert_i;
			}

			if(list.size()>0) {
				sum+=list.get(0);
				list.remove(0);
			}
		}

		out.println(sum);
	}

	//二部探索
	static int Search(List<Integer> list, int k, int Search_l) {
		int l = Search_l;
		int r = list.size();
		while(r - l > 1) {
			int mid = (r + l) / 2;
			if(list.get(mid) <= k) r = mid;
			else l = mid;
		}
		return r;
	}


	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

Measured memory_bytes: 65376
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<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 MOD 10000007 //10^9+7

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}


int main(void){
  
  ll n;
  cin>>n;
  vector<ll> v(n);
  ll sum;

  REP(i, n){
    ll x;
    cin>>x;
    v[i] = x;
  }

  map<int, int> m;
  map<int, int> p;

  for(int i=0;i<n;i++){
    if(i%2==0) m[v[i]]++;
    else p[v[i]]++;
  }

  vector<pair<ll, ll>> a;
  vector<pair<ll, ll>> b;
  
  a.push_back(make_pair(0, 0));
  b.push_back(make_pair(0, 0));
  for(auto i=m.begin(); i!=m.end() ;i++) a.push_back(make_pair(i->second, i->first));
  for(auto i=p.begin(); i!=p.end() ;i++) b.push_back(make_pair(i->second, i->first));
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  ll a_size = a.size()-1;
  ll b_size = b.size()-1;

  if(a[a_size].second == b[b_size].second){
    if(a[a_size].first > b[b_size].first){
      sum = n - a[a_size].first - b[b_size-1].first;
    }else if(a[a_size].first == b[b_size].first){
      sum = min(n - a[a_size].first - a[a_size-1].first, n - a[a_size].first - b[b_size-1].first);
    }else{
      sum = n - b[b_size].first - a[a_size-1].first;
    }
  }else{
    sum = n - a[a_size].first - b[b_size].first;
  }

  cout<<sum<<endl;
  return 0;

}

Measured memory_bytes: 8052
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[666666];
bool cmp(int a,int b){
	return a>b;
}
signed main(){
	int n,m;cin>>n>>m;int s=0;
	for(int i=0;i<n;i++) {
		cin>>a[i];s+=a[i];
	} 
	sort(a,a+n,cmp);
	if(m>=n) cout<<"0";
	else{
		for(int i=0;i<m;i++) s-=a[i];
		cout<<s;
	}
	return 0;
} 

Measured memory_bytes: 1792
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define ff first
#define ss second
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }	
using namespace std;
//?

int power(int x, unsigned int y) 
{ 
    int temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return temp*temp; 
    else
        return x*temp*temp; 
} 
int main(){
	SPEED;
	int a,tmp,cnt;
	cnt=0;
	int res=0;
	cin>>a;
	tmp=a;
	while(tmp){
		tmp/=10;
		cnt++;
	}
	if((cnt%2)!=0){
		if((cnt-2)>0){
			res=(((power(100,(cnt-1)/2))-1)/99);
			res*=9;
			res++;
			res+=a-power(10,cnt-1);
		}
		else{
				res=a;
			}
	}
	else {	
			res+=9*((power(100,(cnt)/2)-1)/99);
		}
	cout<<res<<endl;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,k,l,m,n,x;
    cin>>n;
    vector<int>v;
    for(i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
    }
   sort(v.begin(),v.end());
   k=(v[n-1]-v[0]);
     cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tst"
using namespace std;
const ll N = 3e5 + 9;
const ll mod = 1e9 + 7;
typedef pair<ll,ll> LL;

ll n,k,a[N],i,maxx;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>k>>n;
    for (i = 1;i <= n;i++) cin>>a[i];
    for (i = 2;i <= n;i++) maxx = max(maxx,a[i] - a[i - 1]);
    maxx = max(maxx,k - a[n] + a[1]);
    cout<<k - maxx;
}


Measured memory_bytes: 5196
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

D = ii()

if D == 25:
    print('Christmas')
if D == 24:
    print('Christmas Eve')
if D == 23:
    print('Christmas Eve Eve')
if D == 22:
    print('Christmas Eve Eve Eve')

Measured memory_bytes: 3064
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

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

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

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

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

	VI a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int c=0, cc=0;
	rep(i, n) {
		if (a[i] % 4 == 0) {
			cc++;
		} else if(a[i]%2==0){
			c++;
		}
	}
	//cout << cc << " " << c << " " << n / 2 << endl;
	if ((cc + c / 2) >= n / 2) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0 && c>0){
    	c-=b;
    	if(c<=0){
    		cout<<"Yes";
    		break;
		}
    	a-=d;
    	if(a<=0){
    		cout<<"No";
    		break;
		}
	}
    
//system("pause");
return 0;

}


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

/*
  // Overview

  // Time complexity

  // Initialization
*/
template<typename T, bool directed>
struct FordFulkerson {
    struct edge{
        int to, rev;
        T cap;
        edge(int to, int rev, T cap) : to(to), rev(rev), cap(cap) { }
    };
    int n;
    int s;
    int t;
    vector< vector< edge > > g;
    vector< bool > used;
    FordFulkerson(int n, int s, int t) : n(n), s(s), t(t), g(n) { }
    void add_edge(int from, int to, T cap) {
        g[from].emplace_back(to, g[to].size(), cap);
        g[to].emplace_back(from, g[from].size() - 1, directed ? 0 : cap);
    }
    T dfs(int v, T f) {
        if (v == t) return f;
        used[v] = true;
        for (edge &e : g[v]) {
            if (!used[e.to] && e.cap > 0) {
                int d = dfs(e.to, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    g[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    T solve() {
        T res = 0;
        while (true) {
            used.assign(n, false);
            T f = dfs(s, numeric_limits<T>::max()/2);
            if (f == 0) return res;
            res += f;
        }
    }
};

/*
    verified http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A&lang=jp
*/
int main() {
    int V, E; cin >> V >> E;
    FordFulkerson<int, true> ff(V, 0, V - 1);
    for (int i = 0; i < E; ++i) {
        int u, v, c; cin >> u >> v >> c;
        ff.add_edge(u, v, c);
    }
    cout << ff.solve() << endl;
}



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

int A[100]; 
int n;

void ShowArray() 
{
    for (int i = 0; i < n; i++) 
    {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

void SWAP(int i, int j) 
{
    int t = A[i];
    A[i] = A[j];
    A[j] = t;
}

void SelectionSort()
{
    int cnt = 0;
    for (int i = 0; i < n-1; i++)
    {
        int min = i;
        for (int j = i+1; j < n; j++) 
        {
            if (A[j] < A[min]) 
            {
                min = j;
            }
        }
        if (min != i) 
        {
            SWAP(i, min);
            cnt ++;
        }
    }

    ShowArray();
    cout << cnt << endl;
}

int main() 
{
    cin >> n;
    
    for (int i = 0; i < n; i++) 
    {
        cin >> A[i];
    }

    SelectionSort();
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 2005000000
#define MOD 1000000007
#define N 2005
#define M 100000000
#define LOG 22
#define KOK 4000000
using namespace std;

int a[3],b[3];

int main() {

	//freopen("input.txt","r",stdin);

	for(int i=0;i<3;i++) scanf("%d",&a[i]);

	int tot=0;

	while(1) {

		sort(a,a+3);

		if(a[0]&1 || a[1]&1 || a[2]&1) {

			printf("%d",tot);

			return 0;

		}

		if(a[0]==a[1] && a[1]==a[2]) {

			if(a[0]%2==0) {

				printf("-1");

			}
			else {

				printf("%d",tot);

			}

			return 0;

		}

		b[0]=(a[1]+a[2])/2;
		b[1]=(a[0]+a[2])/2;
		b[2]=(a[0]+a[1])/2;

		a[0]=b[0];
		a[1]=b[1];
		a[2]=b[2];

		++tot;

	}

}

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

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

    std::reverse(s.begin(), s.end());

    const int mod = 1000000007;
    long long reminds[13] = { 1 };
    int pos = 1;
    for (auto c : s) {
        long long new_reminds[13] = { 0 };
        if (c == '?') {
            for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 13; j++) {
                    new_reminds[(i * pos + j) % 13] += reminds[j];
                    new_reminds[(i * pos + j) % 13] %= mod;
                }
            }
        } else {
            int i = c - '0';
            for (int j = 0; j < 13; j++) {
                new_reminds[(i * pos + j) % 13] += reminds[j];
                new_reminds[(i * pos + j) % 13] %= mod;
            }
        }
        pos *= 10;
        pos %= 13;

        std::swap(new_reminds, reminds);
    }

    std::cout << reminds[5] << std::endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
std::string s;
main(){
    std::cin>>s;
    for(register int i=0;i<s.size();i++)if(s[i]=='C')for(register int j=i+1;j<s.size();j++)if(s[j]=='F')return std::cout<<"Yes",0;
    std::cout<<"No";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a * c < b) {
			System.out.println(c);
		} else {
			System.out.println(b / a);
		}
		sc.close();

	}
}


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

int main() {
	int n,k,i,j;
	long s,x;
	cin>>n>>k>>s;
	if(s!=1000000000)
	{
		for(i=0;i<k;i++)
		cout<<s<<" ";
		for(i=0;i<n-k;i++)
		cout<<s+1<<" ";
	}
	else 
	{
		for(i=0;i<k;i++)
		cout<<s<<" ";
		for(i=0;i<n-k;i++)
		cout<<s-1<<" ";
	}
	return 0;
}

Measured memory_bytes: 1280
fn print_vec(arr: &Vec<i32>, i_threshold: usize) {
    for i in 0..arr.len() {
        if i == i_threshold {
            print!("[{}]", arr[i]);
        } else {
            print!("{}", arr[i]);
        }
        if i < arr.len() - 1 {
            print!(" ");
        }
    }
}

fn partition(inputs: &mut Vec<i32>, left: i32, right: i32) -> usize {
    let mut i = (left - 1) as usize;
    let left = left as usize;
    let right = right as usize;

    let threshold = inputs[right - 1];

    for j in left..(right - 1) {
        if inputs[j] <= threshold {
            i = (i as i32 + 1) as usize;

            let tmp = inputs[j];
            inputs[j] = inputs[i];
            inputs[i] = tmp;
        }
    }
    {
        let tmp = inputs[i + 1];
        inputs[i + 1] = inputs[right - 1];
        inputs[right - 1] = tmp;
    }
    return i + 1;
}

fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let n = line.trim().parse::<i32>().unwrap();

    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let mut inputs: Vec<i32> = line.split_whitespace()
        .map(|e| e.parse::<i32>().ok().unwrap())
        .collect();

    let (left, right) = (0, n);
    let i_threshold = partition(&mut inputs, left, right);

    print_vec(&inputs, i_threshold);
    println!();
}



Measured memory_bytes: 5040
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n;
	cin >> n;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			if(i*j == n){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  vector<pair<int, int>> P(k);
  rep(i, k) cin >> P[i].first >> P[i].second;
  sort(all(P));
  vector<ll> cnt(n+1);
  cnt[0] = 1;
  ll sum = 0;
  rep(i, n) {
    (sum += cnt[i]) %= mod2;
    rep(j, k) {
      (cnt[min(i+P[j].first, n)] += sum) %= mod2;
      (cnt[min(i+P[j].second+1, n)] += mod2 - sum) %= mod2;
    }
  }
  cout << cnt[n-1] << endk;
  return 0;
}


Measured memory_bytes: 4760
from itertools import product
S = input()

# is insert + on the right side.
patterns = product([True, False], repeat=len(S)-1)

ans = 0
for ptn in patterns:
  ptn_idxs = [i for i, bl in enumerate(ptn) if bl]
  ptn_s = ''
  for i in range(len(S) - 1):
    ptn_s += S[i]
    if i in ptn_idxs:
      ptn_s += '+'
  ans += eval(ptn_s + S[-1])

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;

int main(){
    map<char,int> alf;
    for(int i=0;i<26;i++){
        alf[(char)('a'+i)]=(26-i)%26;
    }
    string s;
    cin >> s;
    LL K;
    cin >> K;
    for(int i=0;i<s.length();i++){
        if(alf[s[i]]<=K){
            K-=alf[s[i]];
            s[i]='a';
        }
        if(i==s.length()-1){
            K%=26;
            int t=((int)s[i]+K-'a')%26;
            s[i]=(char)('a'+t);
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public int n = 0;
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str = br.readLine();
		String[] s = str.split(" ");
		int[] n = new int[s.length];
		for (int i = 0; i < s.length; i++) {
			n[i] = Integer.parseInt(s[i]);
		}
		if(n.length > 3){
			System.exit(0);
		}
		int a = n[0];
		int b = n[1];
		int c = n[2];
		Main main = new Main();
		main.calculate(a, b, c);
	}
	public void calculate(int a, int b, int c){
		if(a <= b && b <= c ) {
			System.out.println(a + " " + b + " " + c);
			System.exit(0);
		}
		if(a > b) {
			n = a;
			a = b;
			b = n;
			calculate(a, b, c);
		} else if(b > c) {
			n = b;
			b = c;
			c = n;
			calculate(a, b, c);
		}
	}
}

Measured memory_bytes: 24264
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
#define MAXN 2005
long long a[MAXN];
long long b[MAXN][MAXN];
int main() {
	int n;
	long long x, sum = 1LL << 60LL;
	cin >> n >> x;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) {
		b[i][0] = a[i];
		for (int k = 1; k <= n - 1; k++) {
			int pos = i - k;
			if (pos <= 0) pos = n - abs(pos);
			b[i][k] = min(b[i][k - 1], a[pos]);
		}
	}
	for (int k = 0; k <= n - 1; k++) {
		long long ans = 0;
		for (int i = 1; i <= n; i++) {
			ans += b[i][k];
		}
		sum = min(sum, ans + x * k);
	}
	cout << sum << endl;
	//getchar(); getchar(); getchar();
}

Measured memory_bytes: 31616
#include<stdio.h>
int main(void)
{
	int E,Y;
	scanf("%d%d",&E,&Y);
	if (E==0)
	{
		if (Y<=1911)
		printf("M%d\n",Y-1867);
		else if (Y<=1925)
		printf("T%d\n",Y-1911);
		else if (Y<=1988)
		printf("S%d\n",Y-1925);
		else 
		printf("H%d\n",Y-1988);
	}
	else if (E==1)
	printf("%d\n",Y+1867);
	else if (E==2)
	printf("%d\n",Y+1911);
	else if (E==3)
	printf("%d\n",Y+1925);
	else 
	printf("%d\n",Y+1988);
	return 0;
}

Measured memory_bytes: 1860
N = int(input())
nums = []
first = (-1,-float('inf'))
second = (-1,-float('inf'))
for i in range(N):
  num = int(input())
  nums.append(num)
  if num >= first[1]:
    second = first
    first = (i, num)
  elif num >= second[1]:
    second = (i, num)

for i in range(N):
  if i == first[0]:
    print(second[1])
  else:
    print(first[1])

Measured memory_bytes: 12532
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct Combination {
    vector<int64_t> fact, rfact;
    Combination(int sz) : fact(sz + 1), rfact(sz + 1) {
        fact[0] = 1;
        for(int i = 1; i < fact.size(); i++){
            fact[i] = fact[i - 1] * i % mod;
        }
        rfact[sz] = inv(fact[sz]);
        for(int i = sz - 1; i >= 0; i--){
            rfact[i] = rfact[i + 1] * (i + 1) % mod;
        }
    }
    int64_t inv(int x) const {
        return pow(x, mod - 2);
    }
    int64_t pow(int64_t x, int64_t n) const {
        int64_t ret = 1;
        while(n > 0){
            if(n & 1) (ret *= x) %= mod;
            (x *= x) %= mod;
            n >>= 1;
        }
        return (ret);
    }
    int64_t P(int n, int r) const {
        if(r < 0 || n < r) return (0);
        return (fact[n] * rfact[n - r] % mod);
    }

    int64_t C(int p, int q) const {
        if(q < 0 || p < q) return (0);
        return (fact[p] * rfact[q] % mod * rfact[p - q] % mod);
    }

    int64_t H(int n, int r) const {
        if(n < 0 || r < 0) return (0);
        return (r == 0 ? 1 : C(n + r - 1, r));
    }
};

Combination cb(500010);

int calc(int n, int m){
    int res = 0;
    rep(i, 1, n){
        int tmp = i * (n - i) * m % mod * m % mod;
        res += tmp;
        res %= mod;
    }
    return res;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m, k;
    cin >> n >> m >> k;
    int ans = (calc(n, m) + calc(m, n)) % mod * cb.C(n * m - 2, k - 2) % mod;
    cout << ans << endl;
}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef pair<int,int> P;

const int MAX_V = 101;
const int INF = 1000000009;
struct edge { int to, cost, time; };
vector<edge> G[MAX_V];
int dist[MAX_V];

int dijkstra(int s, int t, int type) {
	fill(dist, dist+MAX_V, INF);
	dist[s] = 0;
	priority_queue<P, vector<P>, greater<P> > que;
	que.push(P(0, s));
	while(!que.empty()) {
		P n = que.top(); que.pop();
		int v = n.second;
		if(v == t) return dist[v];

		for(int i=0; i<G[v].size(); i++) {
			edge& e = G[v][i];
			if(type == 0) {
				if(dist[e.to] > dist[v] + e.cost) {
					dist[e.to] = dist[v] + e.cost;
					que.push(P(dist[e.to], e.to));
				}
			} else {
				if(dist[e.to] > dist[v] + e.time) {
					dist[e.to] = dist[v] + e.time;
					que.push(P(dist[e.to], e.to));
				}
			}
		}
	}
	return INF;
}

void add_edge(int from, int to, int cost, int time) {
	edge e1 = { to, cost, time };
	edge e2 = { from, cost, time };
	G[from].push_back(e1);
	G[to].push_back(e2);
}

int M, N, K;
int a, b, c, t;
int p, q, r;

int main() {
	while(scanf("%d%d", &N, &M), N|M) {
		for(int i=0; i<MAX_V; i++) G[i].clear();

		for(int i=0; i<N; i++) {
			scanf("%d%d%d%d", &a, &b, &c, &t);
			add_edge(a, b, c, t);
		}

		scanf("%d", &K);
		for(int i=0; i<K; i++) {
			scanf("%d%d%d", &p, &q, &r);
			int d = dijkstra(p, q, r);
			printf("%d\n", d);
		}
	}
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    rep(i,n-1){
        if(a[i] > a[i + 1]){
            ans += a[i] - a[i+1];
            a[i+1] = a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4820
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#define FUP(i,x,y) for(int i=(x);i<=(y);i++)
#define FDW(i,x,y) for(int i=(x);i>=(y);i--)
#define MAXN 100010
#define INF 0x7fffffff
#define MOD 1000000007
#define ll long long
#define db double
using namespace std;
int read(){
    int w=0,flg=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')flg=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){w=w*10-'0'+ch,ch=getchar();}
    return w*flg;
}
int n,a[110],k,ans=INF;
int main(){
	n=read();
	FUP(i,1,n)
	{
		a[i]=read();
		k=max(k,a[i]);
	}
	FUP(i,1,k)
	{
		int tmp=0;
		FUP(j,1,n)
		{
			tmp+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ans,tmp);
	}
	printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
def judge(visited):
    for v in visited:
        if not v:
            return True
    else:
        # 完走 橋ではない
        return False


def dfs(visited, graph, n):
    visited[n] = True

    for k, v in enumerate(graph[n]):
        if not v:
            continue

        if visited[k]:
            continue

        visited = dfs(visited, graph, k)

    return visited


def main():
    N, M = map(int, input().split())

    graph = [[False for j in range(N)] for i in range(N)]

    am = [0] * M
    bm = [0] * M

    for i in range(M):
        # 0-indexed
        ai, bi = map(int, input().split())
        ai -= 1
        bi -= 1

        am[i] = ai
        bm[i] = bi

        graph[ai][bi] = True
        graph[bi][ai] = True

    ans = 0

    for ai, bi in zip(am, bm):
        graph[ai][bi] = False
        graph[bi][ai] = False

        # 訪問済 All False
        visited = dfs([False] * N, graph, 0)

        if judge(visited):
            ans += 1

        # 元に戻す
        graph[ai][bi] = True
        graph[bi][ai] = True

    print(ans)
    return


main()


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

int main() {
    int no_of_stones, no_of_steps;
    cin >> no_of_stones >> no_of_steps;

    vector<int> height(no_of_stones + 1, 0);
    for (int i = 1; i <= no_of_stones; i++)
        cin >> height[i];

    const int oo = 1e9;
    vector<int> minimum_cost(no_of_stones + 1, oo);
    minimum_cost[1] = 0;

    for (int i = 2; i <= no_of_stones; i++) {
        for (int j = i - 1; j >= max(1, i - no_of_steps); j--) {
            minimum_cost[i] = min(minimum_cost[i], minimum_cost[j] + abs(height[i] - height[j]));
        }
    }

    cout << minimum_cost[no_of_stones];
    return 0;
}


Measured memory_bytes: 4036
def check_prime(num):
  for i in range(2,num):
    if (x % i == 0):
      return False
      break
  else: 
    return True

if __name__ == "__main__":
  x = int(input())
  flag = True
  while flag: 
    if (check_prime(x)):
      print(x)
      flag = False
    else: 
      x = x + 1
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long 
#define MAXN 10010

using namespace std;

int n, m, d;
bool f[MAXN];
int a[MAXN][MAXN];
ll t;
string s;

bool check() {
	for (int i = 1; i <= n; i++) {
		if (a[i][0] != n) return false;
	}
	return true;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n - 1; j++) {
			scanf("%d", &a[i][j]);
		} 
		a[i][0] = 1;
	}
	while (1) {
		if (check()) {
			printf("%d\n", d);
			return 0;
		}
		memset(f, false, sizeof(f));
		d++;
//		cout << "Day: "<< d << endl;
		bool tf = false;
		for (int i = 1; i <= n; i++) {
			if (f[i] || a[i][0] == n) continue;
			int x = a[i][a[i][0]];
			int y = a[x][a[x][0]];
//			cout << i << " and " << y << " "<< x << endl;
//			cout << f[i] << f[x] << endl;
			if (!f[i] && !f[x] && y == i) {
//				cout << "YTES" << endl;
				tf = true;
				a[i][0]++;
				a[x][0]++;
				f[i] = true;
				f[x] = true;
			}
		}
		if (!tf) {
			cout << "-1" << endl;
			return 0;
		}
	}
//	cout << "Error" << endl;
	return 0;
}

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

namespace AOJGPL_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var VEr = ReadInt();
            int V = VEr[0];
            int E = VEr[1];
            int r = VEr[2];

            List<int>[] edges = new List<int>[V].Select(x => new List<int>()).ToArray();
            List<int>[] distance = new List<int>[V].Select(x => new List<int>()).ToArray();

            for (int i = 0; i < E; i++)
            {
                var input = ReadInt();
                edges[input[0]].Add(input[1]);
                distance[input[0]].Add(input[2]);
            }

            long[] ans = new long[V].Select(x => long.MaxValue).ToArray();
            ans[r] = 0;

            Queue<int> que = new Queue<int>();
            que.Enqueue(r);
            while (que.Count > 0)
            {
                int now = que.Dequeue();

                //決定済みなら行かない
                //if (ans[now] != long.MaxValue && ans[now] != 0) continue;

                for (int i = 0; i < edges[now].Count; i++)
                {
                    long cand = ans[now] + distance[now][i];
                    if (ans[edges[now][i]] > cand)
                    {
                        ans[edges[now][i]] = cand;
                        que.Enqueue(edges[now][i]);
                    }
                }
            }

            foreach (var a in ans)
            {
                if (a == long.MaxValue) Console.WriteLine("INF");
                else Console.WriteLine(a);
            }
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}



Measured memory_bytes: 46012
#include <iostream>
#include <math.h>

using namespace std;
int thr = (int)pow(10,9) + 7;

long long factorial (int M){
  long long ans=1;
  for(int i = 1; i <= M;i++)
    ans = ans*i%thr;
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);//高速化、endlは使わない


  int N,M;
  cin >> N >> M;
  if( (N-1 <= M) && (M <= N+1)){
    if(N==M)
      cout << (factorial(N)*factorial(M)*2)%thr << "\n";
    else
      cout << (factorial(N)*factorial(M))%thr << "\n";
  }
  else
    cout << 0 << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
    long long int h;
    long long int s=0;
    scanf("%lld",&h);
    for(int i=0;h>0;i++){
        s = s + pow(2,i);
        h = h/2;
    }
    printf("%lld",s);
}

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

int main(){
  int x, a, b; cin >> x >> a >> b;
  int A=abs(x-a);
  int B=abs(x-b);
  if(A<B){
    cout << "A" << endl;
  }
  else cout << "B" << endl;
}

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

typedef long long int ll;
typedef long double ld;

#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
string s;
bool check(ll x){
    if(x==s.size()) return 1;
    if(x+4 >=  s.size()) return 0;
    if(s[x]=='d'&&s[x+1]=='r'&&s[x+2]=='e'&&s[x+3]=='a'&&s[x+4]=='m'){
        if(x+6 >= s.size() ) return check(x+5);
        else{
            if(s[x+5]=='e' && s[x+6]=='r') return check(x+5) || check(x+7);
            else return check(x+5);
        }
    }
    if(s[x]=='e'&&s[x+1]=='r'&&s[x+2]=='a'&&s[x+3]=='s'&&s[x+4]=='e'){
        if(x+5 >= s.size()) return check(x+5);
        else{
            if(s[x+5]=='r') return check(x+5) || check(x+6);
            else return check(x+5);
        }
    }
    return 0;
}
int main()
{
    cin>>s;
    if(check(0)) cout<<"YES";
    else cout<<"NO";
}


Measured memory_bytes: 512
n,m = map(int,input().split())
a_list = []
c = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c.append(sum(1 << j-1 for j in list(map(int,input().split()))))

inf = 10**10
dp = [inf]*(1 << n)
dp[0] = 0

for i in range(1 << n):
    for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j])

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])

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

int main() {
    int N;
    cin >> N;
    int A[N];
    rep(i,N){
        cin >> A[i];
    }
    int B[N];
    rep(i,N){
        int t=A[i]-1;
        B[t]=i+1;
    }
    rep(i,N){
    cout << B[i] <<" ";
    }
    cout << endl;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>

using namespace std;


int main(){

	int answer = 0;

	int W[10], K[10];

	for (int i = 0; i < 10; i++) {
		cin >> W[i];
	}
	for (int i = 0; i < 10; i++) {
		cin >> K[i];
	}

	sort(W, W + 10);
	sort(K, K + 10);


	cout << W[7] + W[8] + W[9] << ' '
		<< K[7] + K[8] + K[9] << endl;

	return 0;
}


Measured memory_bytes: 3156