akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <algorithm> 
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef long double ld;

void faster(){
  	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
	cout.tie(NULL);
}

const int MAXN = 5e1 + 1;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

ll n, K, mx, g;

int main(){
	faster();

	cin >> n >> K;

	for(ll i = 0, a; i < n; ++i){
		cin >> a;
		mx = max(a, mx);
		if(g == 0) g = a;
		else g = gcd(g, a);
	}
	if(K % g == 0 && K <= mx) cout << "POSSIBLE"; 
	else cout << "IMPOSSIBLE";

	return 0;
}

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

using namespace std;

int main(int argc, char const* argv[]) {
	uint32_t N;

	cin >> N;

	for (int i = 0; i < 3; i++) {
		if (N % 10 == 7) {
			cout << "Yes" << endl;
			return 0;
		}
		N /= 10;
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 29;
const int MOD = 1000000007;

int as[MAX], bs[MAX];

void solve(void){
    int N, M;
    cin >> N >> M;
    rep(M, i) {
        int A, B; cin >> A >> B;
        A--; B--;
        if (A==0) as[B]++;
        if (B == N-1) bs[A]++;
    }
    bool f = false;
    rep(N, i) if (as[i] && bs[i]) f = true;
    cout << (f?"POSSIBLE":"IMPOSSIBLE") << '\n';
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

#define WHITE 0
#define GRAY -1
#define BLACK 1
#define INF -1
#define MAX 100

int *u, *k, **v, *color, *d;
int *queue, head, tail;
int n, time;

void init() {
	int i, j;

	u = (int *)malloc(sizeof(int) * (n + 1));
	k = (int *)malloc(sizeof(int) * (n + 1));
	color = (int *)malloc(sizeof(int) * (n + 1));
	d = (int *)malloc(sizeof(int) * (n + 1));
	v = (int **)malloc(sizeof(int *) * (n + 1));
	queue = (int *)malloc(sizeof(int) * (n + 1));
}

void input() {
	int i, j;

	scanf("%d", &n);
	init();

	for (i = 1; i <= n; i++) {
		scanf("%d%d", &u[i], &k[i]);
		v[i] = (int *)malloc(sizeof(int) * (k[i] + 1));
		for (j = 1; j <= k[i]; j++) {
			scanf("%d", &v[i][j]);
		}
	}
}

void enqueue(int q) {
	if (tail > MAX) tail = 0;
	queue[tail++] = q;
}

int dequeue() {
	int x = queue[head];

	if (head == tail || head > tail) return x;
	else {
		if (head > MAX) {
			head = 0;
		}
	}
	return queue[head++];
}

void BFS(int s) {
	int i, u;

	for (i = 1; i <= n; i++) {
		color[i] = WHITE;
		d[i] = INF;
	}
	color[s] = GRAY;
	d[s] = 0;
	enqueue(s);

	while (head != tail) {
		u = dequeue();
		for (i = 1; i <= k[u]; i++) {
			if (color[v[u][i]] == WHITE) {
				color[v[u][i]] = GRAY;
				d[v[u][i]] = d[u] + 1;
				enqueue(v[u][i]);
			}
		}
		color[u] = BLACK;
	}
}

void output() {
	int i;

	for (i = 1; i <= n; i++) {
		printf("%d %d\n", u[i], d[i]);
		free(v[i]);
	}
	free(u);
	free(k);
	free(v);
	free(color);
	free(queue);
}

main () {
	input();
	BFS(u[1]);
	output();
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>

int main()
{
	int a[9], b[9];
	for(int i = 0;i < 9;i++)
	{
		a[i] = i + 1;
		
		for(int j = 0;j < 9;j++)
		{
			b[j] = j + 1;
			printf("%dx%d=%d\n",a[i],b[j],a[i]*b[j]);
		}
	}

	return 0;
}

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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
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; }

int dy[]={0, 0, 1, -1, 1, -1, -1, 1};
int dx[]={1, -1, 0, 0, 1, 1, -1, -1};


int main() {
    cout<<fixed<<setprecision(10);

    ll k; cin>>k;
    string s; cin>>s;

    if(s.size() <= k) cout<<s<<endl;
    else{
        string tmp = s.substr(0, k) + "...";
        cout<<tmp<<endl;
    }

    return 0;

}

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

int main()
{
    int t, n, a, b;

    while( cin >> t )
    {
        if( t == 0 )
            break;
        cin >> n;

        int sum = 0;
        for( int i = 0; i < n; i++ )
        {
            cin >> a >> b;
            sum += ( b - a );
        }

        if( t <= sum )
            cout << "OK" << endl;
        else
            cout << t - sum << endl;
    }
        
    return 0;
}


Measured memory_bytes: 3084
dice = list(map(int, input().split()))
q = int(input())

def dicing(lis, inst):
    if inst == 'N':
        ans_lis = [lis[1],lis[5],lis[2],lis[3],lis[0],lis[4]]
    if inst == 'W':
        ans_lis = [lis[2],lis[1],lis[5],lis[0],lis[4],lis[3]]
    if inst == 'S':
        ans_lis = [lis[4],lis[0],lis[2],lis[3],lis[5],lis[1]]
    if inst == 'E':
        ans_lis = [lis[3],lis[1],lis[0],lis[5],lis[4],lis[2]]
    
    return(ans_lis)

def turn_right(lis):
    inst = list('ENW')
    for i in range(len(inst)):
        lis = dicing(lis, inst[i])
    return(lis)

def find_above(lis, num):
    inst1 = list('NNNEWW')
    for i in range(len(inst1)):
        if lis[0] == num:
            break
        
        lis = dicing(lis, inst1[i])
        if lis[0] == num:
            break
    return(lis)

for i in range(q):
    question = list(map(int, input().split()))
    lis = [1,2,3,4,5,6]
    lis = find_above(lis, dice.index(question[0]) + 1)
    for j in range(4):
        lis = turn_right(lis)
        if dice[lis[1]- 1] == question[1]:
            break

    print(dice[lis[2]-1])


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

int main() {
        string str, str2;
        int r, i;
        r = 0;
        cin >> str;
        transform(str.begin(), str.end(), str.begin(), ::tolower);
        for(i = 0; i < 1000; i++) {
                cin >> str2;
                if (str2 == "END_OF_TEXT") break;
                transform(str2.begin(), str2.end(), str2.begin(), ::tolower);
                if( str == str2 ) {
                        r++;
                }
        }
        cout << r << endl;
        return 0;
}

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

int N;
int h[100001];

const int INF = 1e9;
int dp[100001];

void solve(){
	memset(dp, INF, sizeof(dp));
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(int i = 2; i < N; i++){
		dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
	}
	cout << dp[N-1] << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	for(int i = 0; i < N; i++)
		cin >> h[i];
	solve();
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
	long long i;
	long long j;
	long long range;
	long long result;
	
	scanf("%lld%lld", &i , &j);
	range = i*j;
	if (i == 1 || j == 1)
		result = 1;
	else if (range % 2 == 0)
		result = range/2;
	else
		result = (range/2) + 1;
	printf("%lld\n", result);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n; int a[200001];

int main(){
	cin>>n;
	int c=0;long long max_=-1;int pos;long long smax;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]>max_){
			smax=max_;
		    max_=a[i];	
		}
	}
	for(int i=0;i<n;i++){
		if(a[i]==max_){
			c++;pos=i;
			if(c>1){
	            for(int i=0;i<n;i++)cout<<max_<<endl;
	            return 0; 
	        } 
		}
	}
//	sort(a,a+n);
    for(int i=pos+1;i<n;i++){
    	if(a[i]>smax)smax=a[i];
	}
	for(int i=0;i<n;i++){
		if(i==pos) {
			cout<<smax<<endl;
		}
		else{
			cout<<max_<<endl;
		}
	} 
}

Measured memory_bytes: 2432
#include "bits/stdc++.h"
using namespace std;
pair<int,string> namesize[1000];
map<string, int> table;
string word;
int i = 0;

int main() {
    while (cin >> word) {
        namesize[i].second = word;
        namesize[i].first = word.size();
        i++;
        table[word] += 1;
    }
    int max=0;
    string maxword;
    for (map<string,int>::iterator p = table.begin(); p != table.end(); ++p) {
        if (max < p->second) {
            max = p->second;
            maxword = p->first;
        }
    }
    sort(namesize, namesize + i);
    reverse(namesize, namesize + i);
    cout << maxword << " " << namesize[0].second<<endl;



}


Measured memory_bytes: 3184
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	while (1) {
		string st; cin >> st;
		map<int, string>mp;
		mp[0] = "black";
		mp[1] = "blue";
		mp[2] = "lime";
		mp[3] = "aqua";
		mp[4] = "red";
		mp[5] = "fuchsia";
		mp[6] = "yellow";
		mp[7] = "white";
		if (st == "0")break;
		else {
			int red = stoi(st.substr(1, 2), nullptr, 16);
			int gre = stoi(st.substr(3, 2), nullptr, 16);
			int blu = stoi(st.substr(5, 2), nullptr, 16);
			int num = (red > 127) * 4 + (gre > 127) * 2 + (blu > 127);
			cout << mp[num] << endl;
		}
	}
	return 0;
}

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

int main () {
	int n;
	while (cin >> n, n) {
		int step[n + 1];
		step[0] = 1;
		for (int i = 1; i <= n; i++) {
			step[i] = step[i - 1];
			if (i > 1) step[i] += step[i - 2];
			if (i > 2) step[i] += step[i - 3];
		}
		cout << step[n] / 3650 + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight(int n) {
	int ans = 1;
	while (n >= 10) {
		n /= 10;
		ans++;
	}
	return ans;
}
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
signed main() {
	int x;
	cin >> x;
	cout << x / 500 * 1000 + (x % 500) / 5 * 5 << endl;
	ggr
}


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

#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define sor(v) sort(v.begin(),v.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))

const int INF=1000000000;
const int dre_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dre_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n;
	cin>>n;
	
	rep(i,n){
		int a[12];
		rep(j,10)cin>>a[j];
		
		int b=0,c=0;
		bool ret=true;
		rep(j,10){
			if(a[j]>b)b=a[j];
			else if(a[j]>c)c=a[j];
			else ret=false;
		}
		
		if(ret)cout<<"YES\n";
		else cout<<"NO\n";
	}
}

Measured memory_bytes: 1112
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#define long long ll
using namespace std;
int main()
{
	//int a, b, c;
	//cin >> a >> b >> c;
	//if (a == b)
	//{
	//	if (a != c)
	//	{
	//		cout << "Yes";
	//		exit(0);
	//	}
	//	else cout << "No";
	//}
	//else if (a == c)
	//{
	//	if (a != b)cout << "Yes";
	//	else cout << "No";
	//}
	//else if (b == c)
	//{
	//	if (b != a)cout << "Yes";
	//	else cout << "No";
	//}
	//else cout << "No";

	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		if (a % 2 == 0)
		{
			//cout << a<<" ";
			if (a % 3 != 0 && a % 5 != 0) {
				cout << "DENIED";
				exit(0);
			}
 
		}
	}
	cout << "APPROVED";
}



Measured memory_bytes: 3612
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	a := make([]int, N)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	var asum, bsum int
	for i, v := range a {
		if i%2 == 0 {
			asum += v
		} else {
			bsum += v
		}
	}
	fmt.Println(asum - bsum)
}


Measured memory_bytes: 512
N=int(input())
A=[]
g=[[-1]*(N) for i in range(N)]#g[i][j]はi番目からのj番目に対する証言

for i in range(N):
    a=int(input())
    A.append(a)
    for j in range(a):
        x,y=map(int,input().split())
        x-=1
        g[i][x]=y
""""
num=[]
for i in range(2 **N):
  chars = list(f"{i:0{N}b}")
  chars=list(map(int,chars))
  num.append(chars)
"""
num=[]
for i in range(2**N):
    x=[]
    for j in range(N):
        if i>>j & 1:
            x.append(1)
        else:
            x.append(0)
    num.append(x)

ans=[]
for x in num:
    ok = True
    for k in range(N):#k番目の人
        if x[k]:
            for j in range(N):
                if g[k][j]==-1:
                    continue
                elif g[k][j]!=x[j]:
                    ok=False
    if ok:
        ans.append(x.count(1))
print(max(ans))

Measured memory_bytes: 10356
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		String[] strs = br.readLine().split(" ");
		
		long min = 1000000;
		long max = -1000000;
		long total = 0;
		long num = 0;
		
		if (0 < n && n <= 10000) {
			for (int i = 0; i < n; i++) {
				num = Integer.parseInt(strs[i]);
				if (min > num) min = num;
				if (max < num) max = num;
				total += num;
			}
			
			System.out.println(min + " " + max + " " + total);
		}
	}
		
}

Measured memory_bytes: 28540
n,m = map(int,input().split())
A = [[int(i) for i in input().split()] for j in range(m)]
B = []
C = []
for i in A:
    if 1 in i:
        B += i
B = set(B)
for i in A:
    a,b = i
    if a in B:
        C.append(b)
    elif b in B:
        C.append(a)
        
C = set(C)

if n in C or n in B:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 47848
#define s(X,Y,Z)(t=X,X=Y,Y=t,f(Z?&X:&Y),a&7)
f(int*a){*a=*a%8*8|*a/8;}m,a,b,c,t,r;main(n){while(scanf("%d",&n),n){for(r=1,a=49,b=42,c=35;n--;scanf(" %c%*s",&t),m=t-76,r+=m%6==0?s(c,b,m):1<m&m<8?s(b,a,m^7):s(c,a,m>0));printf("%d\n",r);}}

Measured memory_bytes: 0
#pypyは内包表記使わない, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 1000000007

    s = input().rstrip()
    K = int(input())
    a = sorted(set(s))
    res = set()
    n = len(s)
    for i in a:
        res.add(i)
        if len(res)>=K:
            res = sorted(res)
            print(res[K-1])
            exit()
        for j in range(n):
            if s[j] == i:
                for k in range(1, 5):
                    res.add(s[j:j+k+1])
        if len(res)>=K:
            res = sorted(res)
            print(res[K-1])
            exit()



if __name__ == '__main__':
    main()

Measured memory_bytes: 3436
#include"bits/stdc++.h"
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << 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...);
}

#define pii pair<int,int>
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i);
#define int long long int
#define all(n) n.begin(),n.end()
#define mem(n,i) memset(n,i,sizeof n);
//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));

signed main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	vector<int>vv(6);
	int f = 0;
	rep(i, 5)
	{
		int a; cin >> a;
		if (!a) f = i;
	}
	cout << f;
}

Measured memory_bytes: 3644
/*****************************************************************************************
******************************AUTHOR:***************************************************
****************************ASHISH RANJAN***********************************************
*****************************************************************************************/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<chrono>
#include<vector>
#include<string>
using namespace std;
using namespace std::chrono;
/*
auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    cout << "Time taken by function: "
         << duration.count() << " microseconds" << endl;
*/
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define mod 1000000007
#define fr(i,n) for(int i=0;i<(int)n;i++)
int main(){
  fast();
int n;
cin>>n;
int arr[n];
fr(i,n)cin>>arr[i];
int avg = 0,sum = 0;
fr(i,n)sum += arr[i];
  avg = sum/n;
int ans = 0;
  int p=0,q=0;
fr(i,n){p += ((arr[i]-avg)*(arr[i]-avg));
        q += ((arr[i]-(avg+1))*(arr[i]-(avg+1)));    
}
  ans = min(p,q);
cout<<ans;
 return 0;
  
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
ll fact[2 * N];
ll sqr(ll a)
{
    return ((a % MOD) * (a % MOD)) % MOD;
}
ll Pow(ll a, ll b, ll M = MOD)
{
    if(b == 0) return 1;
    if(b & 1) return (((a % M) * (sqr(Pow(a, b / 2, M) % M))) % M);
    else return sqr(Pow(a, b / 2, M));
}
ll msub(ll a, ll b)
{
    return ((a - b) % MOD + MOD) % MOD;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    ll n, a, b;
    cin >> n >> a >> b;
    fact[0] = 1;
    FOR(i, 1, b) fact[i] = ((fact[i - 1] % MOD) * (i % MOD)) % MOD;
    ll t1 = 1;
    ll t2 = 1;
    ll g1 = Pow(fact[a], MOD - 2);
    ll g2 = Pow(fact[b], MOD - 2);
    FOR(i, 0, a - 1) t1 = ((t1 % MOD) * ((n - i) % MOD)) % MOD;
    FOR(i, 0, b - 1) t2 = ((t2 % MOD) * ((n - i) % MOD)) % MOD;
   // cout << t1 << " " << t2 << " " << g1 << " " << g2 << " " << fact[a] << " " << fact[b] << endl;
    cout <<  msub(msub(Pow(2, n), (t1 * g1) % MOD), (t2 * g2) % MOD) - 1;
    return 0;
}


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

int main() {
    int N, Z, W;
    cin >> N >> Z >> W;
    vector<int> a(N + 1);
    for(int i = 0; i < N; ++i) {
        cin >> a[i + 1];
    }

    vector<vector<int>> dp(N + 1, vector<int>(2, -1));
    // 直前の相手の手: top, turn: 今の手番
    function<int(int, int)> rec = [&] (int top, int turn) {
        int& res = dp[top][turn];
        if(dp[top][turn] != -1) {
            return dp[top][turn];
        }
        if(top == 0) {
            res = abs(W - a.back()); // 最後まで引く
        } else {
            res = abs(a[top] - a.back()); // 最後まで引く
        }
        if(turn == 0) { // 途中まで引く
            for(int nex = top + 1; nex < N; ++nex) {
                res = max(res, rec(nex, turn^1));
            }
        } else {
            for(int nex = top + 1; nex < N; ++nex) {
                res = min(res, rec(nex, turn^1));
            }
        }
        return res;
    };

    cout << rec(0, 0) << endl;
}


Measured memory_bytes: 512
#include <stdio.h>


int main()
{
    char a,b,c,d;int flag=1;
    a=getchar();b=getchar();c=getchar();d=getchar();
    if (a==b) flag=0;
    if (b==c) flag=0;
    if (c==d) flag=0;
    if (flag) printf("Good");else printf("Bad");
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
string names;
int h[101010];
int Total[101010];
int main() {
	int N = 0,K=0;
	cin >> N>>K;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
		Total[i] = INF;
	}
	Total[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 1; j <= K; j++) {
			if ((i + j) < N) {
				Total[i + j] = min(Total[i + j], Total[i] + abs(h[i + j] - h[i]));
			}
			else { break; }
		}
	}
	
	cout << Total[N-1] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

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

	long ans = 0;

	if (N == 1 && M == 1) ans = 1;

	// top & bottom
	if (N > 2) {
		if (M == 1) {
			ans += N - 2;
		}
	}

	// left & right
	if (M > 2) {
		if (N == 1) {
			ans += M - 2;
		}
	}

	if (N > 2 && M > 2) {
		ans += (N - 2) * (M - 2);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <functional>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,s) for(int i=s;i>=0;i--)

using ll = long long;
using namespace std;

const ll INF = 1010101010;
const ll MOD = 1000000007;

int main() {
	int n, m, add;
	string str;
	char A[10];
	cin >> n >> m;
	rep(i, m) cin >> A[i];

	for (int i = n; i < 100001; i++) {
		str = std::to_string(i);
		rep(j, str.size()) {
			rep(k, m) {
				if (str[j] == A[k])
					add = 1;
			}
		}
		if (add != 1) {
			cout << i << endl;
			break;
		}
		add = 0;
	}
	return 0;
}

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

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    if((b - a) % 2 == 0){
        cout << (b - a) / 2 << endl;
    }else{
        cout << min(n - b, a - 1) + 1 + ((b - a - 1) / 2) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

Int count2(Int num){
  Int res = 0;
  while(num % 2 == 0) num/=2,res++;
  return res;
}

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  
  Int n;
  cin>>n;
  vector<Int> A(n);
  cin>>A;

  Int sum = 0;
  for(Int i=0;i<n;i++) sum += count2(A[i]);

  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 384
N=int(input())
city=[]
for i in range(N):
    x,y=map(int,input().split())
    city.append((i,x,y))
city.sort(key=lambda x:x[1])
data=[]
for i in range(N-1):
    data.append((city[i][0],city[i+1][0],city[i+1][1]-city[i][1]))
city.sort(key=lambda y:y[2])
for i in range(N-1):
    data.append((city[i][0],city[i+1][0],city[i+1][2]-city[i][2]))
data.sort(key=lambda d:d[2])
idx=[-1]*N
def find(idx,x):
    if idx[x]<0:
        return x
    elif idx[x]>=0:
        idx[x]=find(idx,idx[x])
        return idx[x]
ans=0
for q in range(len(data)):
    i,j,d=data[q]
    iidx=find(idx,i)
    jidx=find(idx,j)
    if iidx==jidx:
        continue
    elif idx[iidx]<=idx[jidx]:
        idx[iidx]+=idx[jidx]
        idx[jidx]=iidx
        ans+=d
    elif idx[iidx]>idx[jidx]:
        idx[jidx]+=idx[iidx]
        idx[iidx]=jidx
        ans+=d
print(ans)


Measured memory_bytes: 46536
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;


int main(){
    int A[100][100];
    int b[100];
    int res[100] = {0};
    int n, m;
    cin >> n >> m;

    for(int row=0;row<n;row++){
        for(int col=0;col<m;col++){
            cin >> A[row][col];
        }
    }
    for(int row=0;row<m;row++){
        cin >> b[row];
    }

    for(int row=0;row<n;row++){
        for(int col=0;col<m;col++){
            res[row] += A[row][col]*b[col];
        }
    }

    for(int row=0;row<n;row++){
        cout << res[row] << endl;
    }
}


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

long long  n, ans=0, cntr=0, cntb=0, cntg=0;
string s;

int main(){
	cin >> n >> s;
	for (int i=0;i<n;i++){
		if (s[i]=='R') cntr++;
		else if (s[i]=='G') cntg++;
		else cntb++;
	}
	ans=cntr*cntg*cntb;
	for (int i=0;i<n;i++){
		for (int j=1;i+j+j<n;j++){
			if (s[i]!=s[i+j] && s[i]!=s[i+j+j] && s[j+i]!=s[i+j+j]) ans--;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, K;
string s;

int main() {
  INCANT;
  cin >> N >> K;
  cin >> s;
  tolower(s[K-1]);
  rep(i, N) {
    if (i==K-1) cout << char(tolower(s[i]));
    else cout << s[i];
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

vector<vector<int>> gridBFS(vector<string> & s, int sy, int sx, char wall = '#', const int INF = 1e9){
    const int dy[] = {0, 1, 0, -1}, dx[] = {1, 0, -1, 0};
    int h = s.size(), w = s[0].size();
    vector<vector<int>> dist(h, vector<int>(w, INF));
    queue<pair<int, int>> que;
    que.emplace(sy, sx);
    dist[sy][sx] = 0;
    while(!que.empty()){
        pair<int, int> p = que.front();
        que.pop();
        for(int i = 0; i < 4; i++){
            int ny = p.first + dy[i], nx = p.second + dx[i];
            if(0 <= ny && ny < h && 0 <= nx && nx < w && s[ny][nx] != wall && dist[ny][nx] == INF){
                que.emplace(ny, nx);
                dist[ny][nx] = dist[p.first][p.second] + 1;
            }
        }
    }
    return dist;
}

signed main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> a(h);
    rep(i,h){
        cin >> a[i];
    }
    int sy,sx;
    rep(i,h){
        rep(j,w){
            if(a[i][j] == 'S'){
                sy = i;
                sx = j;
            }
        }
    }
    vector<vector<int>> dist = gridBFS(a, sy, sx);
    int ans = INF;
    rep(i,h){
        rep(j,w){
            if(dist[i][j] <= k){
                ans = min(ans, 1 + min({(i + k - 1) / k, ((h - 1) - i + k - 1) / k, (j + k - 1) / k, ((w - 1) - j + k - 1) / k}));
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

#define X first
#define Y second

const int N=3e2+10;

int n,m,MOD;
ll f[N][N][N];


ll DP(int cur,int len,int pos){
        if (len>n) return 0;
        if (cur>m) return len==n;
        ll &ans=f[cur][len][pos];
        if (ans!=-1) return ans;
        ans=(pos+1)*DP(cur,len+1,pos)%MOD;
        if (pos==0) ans=(ans+DP(cur+1,len,len))%MOD;
        else ans=(ans+DP(cur,len,pos-1))%MOD;
        return ans;
}
int main(){
        cin>>n>>m>>MOD;
        memset(f,-1,sizeof(f));
        cout<<DP(1,0,0);
}


Measured memory_bytes: 240128
MAX = 114514

N,C=map(int, input().split())

Z=[[] for _ in range(C+1)]
for _ in range(N):
	s,t,c = map(int, input().split())
	Z[c].append([s,t])

Y=[]
for z in [sorted(z) for z in Z if len(z) > 0]:
	for i in range(len(z)-1):
		if z[i][1] == z[i+1][0]:
			z[i+1][0] = z[i][0]
		else:
			Y.append(z[i])
	Y.append(z.pop())

X=[0 for _ in range(MAX)]
for s,t in Y:
	X[s] += 1
	X[t+1] -= 1

for i in range(1, MAX):
	X[i] += X[i-1]

print(max(X))


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s; cin >> s;
    if (s[s.length() - 1] == 's') {
        cout << s + "es";
    }
    else {
        cout << s + "s";
    }
    
    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <memory.h>
#include <algorithm>
#include <cassert>
#include <numeric>
#include <functional>
#include <queue>

using namespace std;

#define prev prev_______________________
#define next next_______________________
#define hash hash_______________________
#define y1 y1___________________________

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(c) (c).begin(), (c).end()
#define sz(c) int((c).size())
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define fst first
#define snd second

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

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr);
#else
#define eprintf(args...) ;
#define cerr if (0) cerr
#endif

int n;
vi p;

bool read() {
    if  (!(cin >> n)) {
        return 0;
    }
    p.resize(n);
    forn(i, n) {
        cin >> p[i];
        --p[i];
    }
    return 1;
}

int solve() {
    vi dp(n, 0);
    forn(i, n) {
        dp[p[i]] = 1;
        if  (p[i] > 0) {
            dp[p[i]] = dp[p[i] - 1] + 1;
        }
    }
    return n - *max_element(all(dp));
}

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

#ifdef LOCAL
    #define FNAME "a"
    freopen(FNAME ".in", "r", stdin);
    freopen(FNAME ".out", "w", stdout);
#endif

    while (read()) {
        cout << solve() << endl;
    }

    return 0;
}


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

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

int main() {
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  int ans;
  ans = gcd(max(a[0],a[1]),min(a[0],a[1]));
  for(int i=2;i<n;i++){
    ans = gcd(max(ans,a[i]),min(ans,a[i]));
  }

cout<<ans<<endl;
  }


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

//しぐまがわからん

int main() {
    //処理用
    double d1, d2, d3, d4;
    int i, j, k, l, n;
    double x[1020] = {0};
    double y[1020] = {0};
    double z[1020] = {0};
    double o, p, q, max;
    max = -1;
    o = 0;
    p = 0;
    q = 0;
    d1 = 0;
    d2 = 0;
    d3 = 0;
    d4 = 0;
    
    scanf("%d", &n);
    
    for (i=0; i<n; i++) {
        scanf("%lf", &x[i]);
    }
    
    for (i=0; i<n; i++) {
        scanf("%lf", &y[i]);
    }
    
    for (i=0; i<n; i++) {
        o = (x[i] - y[i]) * (x[i] - y[i]);
        p = (x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]);
        p = p * p;
        p = sqrt(p); //
        
        d3 = d3 + p;
        d2 = d2 + o;
        d1 = d1 + sqrt(o); //
        
        if (max < sqrt(o)) { //ルートで壊したこんなけ
            max = sqrt(o);
        }
    }
    
    d2 = pow(d2, 1.0/2);
    d3 = pow(d3, 1.0/3);
    d4 = max;
    
    printf("%lf\n%lf\n%lf\n%lf\n", d1, d2, d3, d4);
    
    return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
vector<ll> v;
vector<string> vs;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
map<ll, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	ll a, b, c;
	cin >> a >> b >> c;
	if (c - b <= 0) cout << "delicious" << endl;
	else if (c - b <= a) cout << "safe" << endl;
	else cout << "dangerous" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

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

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

int main(){
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll E = lcm(C, D);
  A--;
  ll A_wareru = A / C + A / D - A / E;
  ll B_wareru = B / C + B / D - B / E;
  ll wareru = B_wareru - A_wareru ;
  ll ans = B - A - wareru;
  //if (A % D == 0 || A % C == 0) ans--;
  //if (B % D == 0 || B % C == 0) ans--;
  cout << ans << endl;
  return 0;
}


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

int selection_sort(int *array, int n);
void print_array(int *array, int size);
int main(){
	int n;

	cin >> n;

	int* array = (int*)malloc(n * sizeof(int));

	if(n < 1){
		return 0;
	}

	for(int i = 0; i < n; i++){
		cin >> array[i];
	}
	int result = selection_sort(array, n);
	print_array(array, n);
	cout << result <<endl;
	return 0;
}

int selection_sort(int *array, int n){
	int change_num = 0;
	for(int i = 0; i < n; ++i){
		bool is_swaped = false;
		int minj = i;
		for(int j = i; j < n; ++j){
			if(array[j] < array[minj]){
				minj = j;
				is_swaped = true;
			}
		}
		if(is_swaped){
			swap(array[i], array[minj]);
			++change_num;
		}
	}
	return change_num;
}

void print_array(int *array, int size){
	for(int i = 0; i < size; i++){
		cout <<  array[i];
		if(i != size - 1){
		cout << " " ;
		}
	}
	cout << endl;
}

Measured memory_bytes: 1188
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($A,$B) =  explode(" ",trim(fgets(STDIN)));
$p =  explode(" ",trim(fgets(STDIN)));

$d=0;
for($i=0;$i<$N;$i++) {
  if ($p[$i] != $i+1) {
    $d++;
  }
}
if ($d == 0 || $d == 2) {
  printf("YES\n");
}
else {
  printf("NO\n");
}


Measured memory_bytes: 4728
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/rand"
	"os"
	"time"
)

var D int
var cs []int
var ss [][]int

func main() {
	D = ReadInt()
	cs = ReadInts(26)
	ss = make([][]int, D)
	for i := 0; i < D; i++ {
		ss[i] = ReadInts(26)
	}

	// naives
	answers := []int{}
	last := make([]int, 26)
	for d := 1; d <= D; d++ {
		maxT, maxScore := -1, math.MinInt32
		for i := 0; i < 26; i++ {
			s := ss[d-1][i] - cs[i]*(d-last[i])
			if s > maxScore {
				maxT, maxScore = i, s
			}
		}
		last[maxT] = d
		answers = append(answers, maxT+1)
	}

	rand.Seed(123456777)

	score := scores(answers)
	bestAnswers, bestScore := Dup(answers), score

	start := time.Now()
	timeout := 1950 * time.Millisecond

	for {
		elapsed := time.Now().Sub(start)
		if elapsed >= timeout {
			break
		}

		d, q := rand.Intn(D)+1, rand.Intn(26)+1
		orig := answers[d-1]
		answers[d-1] = q
		score := scores(answers)

		best := false
		if score > bestScore {
			best = true
			bestAnswers, bestScore = Dup(answers), score
		}

		if elapsed < time.Second {
			// 最初はベストのときだけ更新する
			if best {
				// none
			} else {
				answers[d-1] = orig // revert
			}
		} else {
			// answers[d-1] = orig // revert
		}
	}

	for _, v := range bestAnswers {
		fmt.Println(v)
	}
}

func Dup(xs []int) []int {
	return append([]int{}, xs...)
}

func scores(answers []int) int {
	last := make([]int, 26)
	score := 0
	for d := 1; d <= D; d++ {
		t := answers[d-1] - 1
		score += ss[d-1][t]
		last[t] = d
		for i := 0; i < 26; i++ {
			score -= cs[i] * (d - last[i])
		}
	}
	return score
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 4752
#include <bits/stdc++.h> 
#define ll long long
#define pb push_back
#define mp make_pair
const ll inf = 1e9;
const ll MOD = 1e9+7;
const ll zero = 0;
using namespace std;
int main(){
	ll n,ans(1);
	
	cin >> n;
	ll mn = 1-(n%2);
	ll a[n];
	ll v[100001]={};
	for (int i = 0;i<n;i++){
		cin>>a[i];
		v[a[i]]++;
	}
	if ( n%2 == 0 ){
		for (int i =1;i<=n;i+=2){
			if( v[i]!=2 )
				return cout <<0,0;
		}
	} else{
		if (v[0]!=1)
			return cout << 0,0;
		for (int i =2;i<=n;i+=2){
			if (v[i]!=2)
				return cout << 0,0;
		}
	}
	for (int i = 0; i < (n/2);i++){
		ans = (ans*2)%MOD;
	}
	cout << ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=300+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
}
int n,m;
char s[N][N];
void input()
{
	n=read<int>(),m=read<int>();
	For(i,1,n)scanf("%s",s[i]+1);
}
ll ans;
int w[N<<1][N<<1],h[N<<1][N<<1],a[N<<1][N<<1];
struct node
{
	int x,y;
}e[N*N];
int top;
void work()
{	
	int x,y;
	int Max=max(n,m);
	For(i,1,n)For(j,1,m)if(s[i][j]=='#')
	{
		x=i+j,y=i-j+Max;
		e[++top]=(node){x,y};
		a[x][y]=1;
	}
	Max<<=1;
	For(i,1,Max)For(j,1,Max)w[i][j]=w[i][j-1]+a[i][j],h[i][j]=h[i-1][j]+a[i][j];
	For(i,1,top)
	{
		x=e[i].x,y=e[i].y;
		for(int d=2;d<=Max;d+=2)
		{
			if(y+d<=Max&&a[x][y+d])
			{
				if(x-d>0)ans+=w[x-d][y+d]-w[x-d][y-1];
				if(x+d<=Max)ans+=w[x+d][y+d]-w[x+d][y-1];
			}
			if(x+d<=Max&&a[x+d][y])
			{
				if(y-d>0)ans+=h[x+d-1][y-d]-h[x][y-d];
				if(y+d<=Max)ans+=h[x+d-1][y+d]-h[x][y+d];
			}
		}
	}
	write(ans,'\n');
}
int main()
{
	//file();
	input();
	work();
	return 0;
}


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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

typedef long long LL;

const int N = 1e5 + 10;

LL ans[N], cnt[N];
LL stk[N], len[N];
int n, m, q;

int main(){
	
	scanf("%d%d", &n, &q);
	len[1] = n, ++q;
	For(i, 2, q) scanf("%lld", &len[i]);
	Forr(i, q, 1) if(!m || len[i] < stk[m]) stk[++m] = len[i];
	reverse(stk + 1, stk + m + 1);

	cnt[m] = 1;
	Forr(i, m, 1){
		if(!cnt[i]) continue;

		//printf("%d %d\n", i, cnt[i])

		LL now = stk[i];
		int pos = i;
		while(true){
			pos = upper_bound(stk + 1, stk + pos, now) - stk - 1;
			if(!pos){
				ans[now] += cnt[i];
				break;
			}
			cnt[pos] += cnt[i] * (now / stk[pos]);
			now %= stk[pos];
		}
	}

	Forr(i, n, 1) ans[i] += ans[i + 1];
	For(i, 1, n) printf("%lld\n", ans[i]);

	return 0;
}

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

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

    if(s == 'a' || s == 'i' || s == 'u' || s == 'e' || s == 'o'){
        cout << "vowel"<< endl;
    }else{
        cout << "consonant" << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>

namespace __temp_inbuilt{
	int read(void){
		int res = 0, sign = 1;
		char ch = std::getchar();
		while(!std::isdigit(ch)){
			if(ch == '-')
				sign = -1;
			ch = std::getchar();
		}
		while(std::isdigit(ch))
			res = res * 10 + ch - 48, ch = std::getchar();
		return sign * res;
	}
	
	template<class Tp>
		void write(const Tp &x){
			if(x > 9)
				write(x / 10);
			std::putchar(x % 10 + 48);
	}
}

using __temp_inbuilt::read;

template<class Tp>
	void writeln(const Tp &x){
		if(x < 0)
			std::putchar('-');
		__temp_inbuilt::write(x > 0 ? x : -x);
		std::putchar('\n');
	}

template<class Tp>
	void writesp(const Tp &x){
		if(x < 0)
			std::putchar('-');
		__temp_inbuilt::write(x > 0 ? x : -x);
		std::putchar(' ');
	}

template<class Tp>
	void write(const Tp &x){
		if(x < 0)
			std::putchar('-');
		__temp_inbuilt::write(x > 0 ? x : -x);
	}

typedef long long ll;
typedef unsigned long long ull;
typedef double rl;
typedef long double RL;

const rl PI = 3.1415926535898, E = 2.71828182845904;

namespace contest{
	const int MAXN = 2e5 + 19;
	
	int n;
	char s[MAXN];
	
	int main(){
		n = read();
		std::scanf("%s", s + 1);
		int a = 0, b = 0,l=1,r=n;
		while(s[l]=='R')++l;
		while(s[r] == 'W')--r;
		for(int i =l ;i <= r; ++i)if(s[i] == 'R')++a;else++b;
		int aa = a, bb = b;
		for(int i=l;i<l+a;++i)
			if(s[i]=='R')
				--aa;
		for(int i = r; i > r - b; --i)
			if(s[i] == 'W')
				--bb;
		writeln(std::min(aa,bb));
		return 0;
	}
}

int main(){
	contest::main();
	return 0;
}

Measured memory_bytes: 3880
l = raw_input().split('/')
m = int(l[1])
d = int(l[2])
if m < 4:
	print 'Heisei'
elif m == 4:
	if d <= 30:
		print 'Heisei'
	else:
		print 'TBD'
else:
	print 'TBD'

Measured memory_bytes: 28012
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  int n = s.size();
  int res1 = n, res0 = n;
  rep(i, n) {
    if (s[i] == '1') {
      res1 = min(res1, max(i, n - i - 1));
    }
  }
  rep(i, n) {
    if (s[i] == '0') {
      res0 = min(res0, max(i, n - i - 1));
    }
  }
  cout << max(res1, res0) << endl;



  
  return 0;
}

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

int main(void){
    int n;

    cin >> n;
    pair<pair<string, int>, int> shop[n];

    int tmp_i;
    string tmp_s;
    rep(i, n){
        cin >> tmp_s >> tmp_i;
        shop[i] = {{tmp_s, -tmp_i}, i};
    }

    sort(shop, shop + n);

    rep(i, n)
        cout << shop[i].second + 1 << endl;

}


Measured memory_bytes: 256