akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define in insert
#define er erase
#define fi first
#define se second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int) x.size()
using namespace std;
typedef vector <int> vi;
typedef vector <vector<int>> vii;
typedef pair<int,int> pii;
typedef queue <int> qi;
typedef double db;
typedef long long ll;
typedef long double ld;

const long double PI=3.141592653589793238462643383279502884;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main(){
    fast;
    int n,m;
    cin>>n>>m;
    vii gr(n);//graph
    int i,j;
    for (i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        gr[x-1].pb(y-1);
        gr[y-1].pb(x-1);
    }
    qi ft;//first tier
    ft.push(0);
    vector <bool> used(n,0);
    used[0]=1;
    int cur; //current vertice
    vi dist(n);
    j=1;
    int k1=1;
    while (ft.size()>0){
        int t1=ft.size();
        for (i=0;i<t1;i++){
            cur=ft.front();
            ft.pop();
            for (int l=0;l<gr[cur].size();l++){
                if (used[gr[cur][l]]==0){
                    int nxt=gr[cur][l];
                    used[nxt]=1;
                    dist[nxt]=cur;
                    ft.push(nxt);
                    k1++;
                }
            }
        }
        j++;
    }
    if (k1<n){
        cout<<"No";
        return 0;
    }
    cout<<"Yes"<<"\n";
    for (i=0;i<n-1;i++){
        cout<<dist[i+1]+1<<"\n";
    }
    return 0;
}





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


int main() {
  int a, b;
  cin >> a >> b;
  if (a % 500 <= b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
s = input()
t = input()

ls = len(s)
lt = len(t)

dp = [[0] * (lt + 1) for i in range(ls + 1)]

for i in range(1,ls+1):
    for j in range(1,lt+1):
        dp[i][j] = max(dp[i-1][j],dp[i][j-1])
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1]+1

i = ls
j = lt
ans = ""
while i>=1 and j>=1:
    if dp[i][j] == dp[i][j-1]:
        j -= 1
        continue
    if dp[i][j] == dp[i-1][j]:
        i -= 1
        continue
    ans = s[i-1] + ans
    i -= 1
    j -= 1
print(ans)

Measured memory_bytes: 112476
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
  map<string,int> a;
  string buf;
  int N;
  cin >> N;
  
  for(int i=0; i<N; i++){
    cin >> buf;
    if(a.count(buf) == 0)
      a.insert(make_pair(buf,1));
    else
      a[buf]++;
  }

  int max=0;
  vector<string> maxs;
  for(auto i=a.begin(); i!=a.end(); i++){
    if(max < i->second){
      maxs.clear();
      max = i->second;
      maxs.push_back(i->first);
    }
    else if(max <= i->second)
      maxs.push_back(i->first);
  }

  sort(maxs.begin(), maxs.end());
  
  for(int i=0; i<maxs.size(); i++)
    cout << maxs[i] << endl;
  
  
}


Measured memory_bytes: 26868
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main(String[] args)throws java.lang.Exception
    {		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine(),t=br.readLine();
		int c=0;
		for(int i=0; i<s.length(); i++) if(s.charAt(i)!=t.charAt(i)) ++c;
		System.out.println(c);
	}
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   	long long int n;
   	vector<pair<long long int,long long int> > v;
   	cin>>n;
   	while(n--){
   		long long int a,b;
		cin>>a>>b;
		v.push_back({a,b});	
   }
   int f=0;
   for(long long int i=0;i<v.size()-2;i++){
   	if((v[i].first==v[i].second)&&(v[i+1].first==v[i+1].second)&&(v[i+2].first==v[i+2].second)){
   		f=1;
   		break;
	   }
   }
   if(f){
   	cout<<"Yes";
   }
   else{
   	cout<<"No";
   }
   	return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int a[101][3];
bool wy(int c)
 {
 	bool t=true;
 	int b;
 	b=c+2;
 	for (int i=c;i<=b;i++)
 	 if (a[i][1]!=a[i][2]) t=false;
 	return t;
 } 
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	 scanf("%d%d",&a[i][1],&a[i][2]);
	for (int i=1;i<=n-2;i++)
	 if (wy(i)) {
	 	printf("%s","Yes");
	 	return 0;
	 }
	 printf("%s","No");
	return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[100] = {0},b[50] = {0},c[50] = {0};
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    a[i] -= 1;
  }
  for(int i=0;i<n;i++)
  {
    cin>>b[i];
  }
  for(int i=0;i<n-1;i++)
  {
    cin>>c[i];
  }
  long long ans = 0;
  for(int i=0;i<n;i++)
  {
    ans += b[a[i]];
  }
  for(int i=0;i<n;i++)
  {
    if(a[i+1]-a[i]==1){
      ans += c[a[i]];
    }
  }
  cout<<ans;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;


int main(void)
{
	lli N, M; cin >> N >> M;

	if (N >= M / 2)cout << (M / 2) << endl;
	else {
		lli Cs = M - 2 * N;
		cout << (Cs / 4 + N) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;

template <typename T>
struct PrimeFact {
	vector<T> spf;
	PrimeFact(T N) { init(N); }
	void init(T N) { // 前処理。spf を求める
		spf.assign(N + 1, 0);
		for (T i = 0; i <= N; i++) spf[i] = i;
		for (T i = 2; i * i <= N; i++) {
			if (spf[i] == i) {
				for (T j = i * i; j <= N; j += i) {
					if (spf[j] == j) {
						spf[j] = i;
					}
				}
			}
		}
	}
	map<T, T> get(T n) { // nの素因数分解を求める
		map<T, T> m;
		while (n != 1) {
			m[spf[n]]++;
			n /= spf[n];
		}
		return m;
	}
};

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

	int n; cin >> n;
	int ans = 0;
	FOR(i, 1, n) {
		int N = n - i;
		int l = 2;
		VI so, shi;
		while (l*l <= N) {
			int cnt = 0;
			while (N%l == 0) {
				cnt++;
				N /= l;
			}
			if (cnt > 0) {
				shi.push_back(cnt);
				so.push_back(l);
			}
			l++;
		}
		if (N != 1) {
			shi.push_back(1);
			so.push_back(l);
		}
		int tmp = 1;
		REP(j, shi.size()) {
			tmp *= (shi[j] + 1);
			//cout << tmp << endl;
			//cout << so[j] << " " << shi[j] << endl;
		}
		ans += tmp;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3652
N = int(input())
h = [int(i) for i in input().split()]
dp = [0]*(N)
dp[1] = abs(h[0] - h[1])
for i in range(0,N-2):
    dp[i+2] = min(dp[i]+abs(h[i] - h[i+2]), dp[i+1]+abs(h[i+1] - h[i+2]))
print(dp[-1])

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

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

	string hi="hi",s,ans="";
	cin>>s;
	for(int i=0;i<s.size()/hi.size();i++)
		ans+=hi;

	cout<<(ans==s?"Yes":"No")<<endl;

	return 0;
}


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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const double PI = acos(-1);
double rad2deg(double rad) { return 180.0 / PI * rad; }

int main() {
	cin.sync_with_stdio(false); cin.tie(0);
	cin.exceptions(cin.failbit);

	double a, b, x; cin >> a >> b >> x;
	cout << fixed << setprecision(12);
	double area = x / a;

	if (int(a) * int(a) * int(b) == int(x) * 2) {
		// half
		cout << rad2deg(atan(b / a)) << endl;
	} else if (x < a * a * b / 2) {
		// less than half
		double h = area * 2 / b;
		cout << rad2deg(atan(b / h)) << endl;
	} else {
		double rem = b * a - area;
		double h = rem * 2 / a;
		cout << rad2deg(atan(h / a)) << endl;
		// more than half
	}
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, Q = MAP()
# 3種類の状態変化をイベントとして一括管理する
# 0: 工事終了, 1: 工事開始, 2: 人の出発
events = []
for i in range(N):
    s, t, x = MAP()
    # (開始座標に合わせた状態の工事開始時間, フラグ, 実際の座標)
    events.append((s-x, 1, x))
    # (開始座標に合わせた状態の工事終了時間, フラグ, 実際の座標)
    events.append((t-x, 0, x))
for i in range(Q):
    d = INT()
    # (人の出発時間, フラグ, index)
    events.append((d, 2, i))
# 時系列に沿ってソート、フラグも同時刻な時先に処理して欲しいものから番号を振ってある
events.sort()

# setとheapqを合わせて、時刻に合わせた処理と最小値取得を行う
S = set()
hp = []
ans = [0] * Q
for t, flag, x in events:
    # 工事終了
    if flag == 0:
        S.remove(x)
    # 工事開始
    elif flag == 1:
        S.add(x)
        heappush(hp, x)
    # 人の移動
    elif flag == 2:
        # heapqの先頭要素ついて、setと状態を合わせる
        while len(hp) and hp[0] not in S:
            heappop(hp)
        if len(hp):
            ans[x] = hp[0]
        else:
            ans[x] = -1
[print(a) for a in ans]


Measured memory_bytes: 97688
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

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

	int ans = 0;

	set<ll> cand;
	for(ll k=1; k*k<=N; k++){
		if(N%k==0){
			cand.insert(N/k);
			cand.insert(k);
		}
		if((N-1)%k==0){
			cand.insert((N-1)/k);
			cand.insert(k);
		}
	}

	for(ll k: cand){
		if(k==1) continue;
		ll n = N;
		while(n%k==0) n/=k;
		if((n-1)%k==0) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)

int main (){
	int NN;
	cin >> NN;
	string ans = "No";
	while(NN>0){
		if(NN%7==0 || NN%4 == 0) ans = "Yes";
		NN -=7;
	}	
	cout << ans << endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	int a, b, c;
	cin >> a;
	if(a == 1){
		cout << "Hello World" << endl;
	}else{
		cin >> b >> c;
		cout << b+c << endl;
	}
}


Measured memory_bytes: 764
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n; cin>>n;
	int h[100010];
	for(int i=0; i<n; i++){
		cin>>h[i];
	}
	int p=0;
	int ans=0;
	for(int i=1; i<n; i++){
		if(h[i-1]<h[i]){
			ans=max(ans, i-1-p);
			p=i;
		}
	}
	ans=max(ans, n-1-p);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#include <memory>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double l_double;

#define vtr vector
#define PB push_back
#define EB emplace_back
#define gcd __gcd
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define st_ct static_cast // <>
#define TEST uint _ {}; cin >> _; while (_--)
#define PI (3.1415926535897932384626433832795)
#define MOD st_ct<int>(1e9 + 7)
#define EPS 1e-9
#define deb1(x) cerr << #x << " -> " << x << endl;
#define deb2(x,y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ")" << endl;
#define deb3(x,y,z) cerr << "(" << #x << ", " << #y << ", " << #z << ") -> (" << x << ", " << y << ", " << z << ")" << endl;
#define debVV(V) cerr << #V << ":\n" << V << endl; // 2D

// 1D
template<typename T>
istream& operator>>(istream &is, vector<T> &A) {
    for (T &v: A)
        is >> v;
    return is;
}

template <typename T>
ostream& operator<<(ostream &os, const vector<T> &A) {
    for (T const &v: A)
        os << v << " ";
    return os;
}

template<typename T>
void vtrV(const vector<T> &A)
{ for (T const &val: A) cout << val << endl; }

// 2D
template<typename T>
istream& operator>>(istream &is, vector<vector<T>> &A) {
    for (vector<T> &i: A)
        for (T &j: i)
            is >> j;
    return is;
}

template <typename T>
ostream& operator<<(ostream &os, const vector<vector<T>> &A) {
    for (vector<T> const &i: A) {
        for (T const &j: i)
            os << j << " ";
        os << endl;
    }
    return os;
}

template<typename T>
void vvtrNS(const vector<vector<T>> &A) {
    for (vector<T> const &i: A) {
        for (T const &j: i)
            cout << j;
        cout << endl;
    }
}

template<typename T>
T cntDigits(const T &N) { return (floor(log10(N)) + 1); }

template<typename T>
bool isPowOfTwo(const T &N) { return (N && (!(N&(N-1)))); }

template<typename T>
T lcm(T a, T b) { return ((a*b)/gcd(a, b)); }
/* -------------------------------------------------------- */
/* -------------------------------------------------------- */

//

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // cout.setf(std::ios::boolalpha);
    cout<<std::fixed;
    cout<<std::setprecision(6); // default
    /* -------------------------------- */

    int ht {}, st {}, ha {}, sa {};
    cin >> ht >> st >> ha >> sa;

    bool t_turn {true};
    while (true) {
    	if (t_turn) {
    		ha -= st;
    		if (ha <= 0) {
    			cout << "Yes" << endl;
    			return 0;
    		}
    		t_turn = !t_turn;
    	}
    	else {
    		ht -= sa;
    		if (ht <= 0) {
    			cout << "No" << endl;
    			return 0;
    		}
    		t_turn = !t_turn;
    	}
    }
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b,c;
	cin>>a>>b>>c;
	int n=1;
	while(a-n*b-(n+1)*c>=0){
		n++;
	}
	cout<<n-1<<endl;
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
a = list(map(int, input().split()))
num1 = a[0]
num2 = a[1]
list1 = []
list2 = []
max = a[2]
for i in range(1, num1 + 1):
  if num1 % i == 0:
    list1.append(i)
    
for i in range(1, num2 + 1):
  if num2 % i == 0:
    list2.append(i)

list3 = list(set(list1) & set(list2))
list3.sort()
list3.reverse()

print(list3[max -1])

Measured memory_bytes: 3064
import numpy
na = lambda: list(map(int, input().split()))

n, m = na()
a = list(map(lambda x: x%m, list(numpy.cumsum([0] + na()))))

def count(n):
    return n*(n-1)//2

dic = dict()
ans = 0
for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

ans = 0
for i in dic.values():
    ans += count(i)
print(ans)

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

typedef struct{
  double x;
  double y;
}Point;

void koch(int n, Point p1, Point p2){
  if(n == 0) return;
  Point s, t, u;

  s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
  s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
  t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
  t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
  u.x = (t.x - s.x) * 0.5 - (t.y - s.y) * sqrt(3) / 2 + s.x;
  u.y = (t.x - s.x) * sqrt(3) / 2 + (t.y - s.y) * 0.5 + s.y;

  koch(n - 1, p1, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n - 1, t, p2);
}

int main(){
  Point p1, p2;
  int n;

  scanf("%d", &n);

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;

  printf("%.8f %.8f\n", p1.x, p1.y);
  koch(n, p1, p2);
  printf("%.8f %.8f\n", p2.x, p2.y);

  return 0;
}



Measured memory_bytes: 2080
S = input().split('T')
x, y = map(int, input().split())

x_axis = S[::2]
y_axis = S[1::2]

const = 8000
x_pos = 1 << const
y_pos = 1 << const
first = True
for s in x_axis:
    step = len(s)
    if first:
        x_pos <<= step
        first = False
    else:
        x_pos = x_pos << step | x_pos >> step

for s in y_axis:
    step = len(s)
    y_pos = y_pos << step | y_pos >> step

if x_pos >> (const+x) & 1 and y_pos >> (const+y) & 1:
    print('Yes')
else:
    print('No')

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

int main(){
	ll n;
	cin>>n;
	for(int i=1;i<50000;i++){
		if(i*108/100==n){
			cout<<i;
			return 0;
		}
	}
	cout<<":(";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <array>
#include <bitset>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
	int n; CI n;
	VI a(n); CI a;

	int tmp = 1, ans = 0;
	REP(i, n) {
		if (a[i] == tmp)tmp++;
		else ans++;
	}

	if (ans==n) {
		CO -1 EN; return 0;
	}

	CO ans EN;
}

Measured memory_bytes: 1024
N, M, X =map(int,input().split())
cost = 0
cost2 = 0
A = list(map(int,input().split()))
for i in range(M):
  if 0 < A[i] < X:
    cost += 1
  if X < A[i] < N:
    cost2 += 1
L = [cost,cost2]
print(min(L))

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int sum =0;
  
  if(N % 10 !=0){
    while(N>0) {
      sum += N % 10;
      N /= 10;
    }
  }
  else sum = 10;
  cout << sum << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const long double pi = 3.141592653589793;



int main(){
    ll N, M, R;
    cin>>N>>M>>R;
    vector<ll> r(R);
    rep(i, R){
        cin>>r[i];
        r[i]--;
    }
    vector<ll> A(M), B(M), C(M);
    vector<vector<ll>> Way(N, vector<ll>(N, INF));
    rep(i, M){
        cin>>A[i]>>B[i]>>C[i];
        A[i]--; B[i]--;
        Way[A[i]][B[i]]=min(Way[A[i]][B[i]],C[i]);
        Way[B[i]][A[i]]=min(Way[B[i]][A[i]],C[i]);
    }
  	rep(i, N){
      	Way[i][i]=0;
    }
    rep(k, N){
        rep(i, N){
            rep(j, N){
                Way[i][j]=min(Way[i][j], Way[i][k]+Way[k][j]);
            }
        }
    }
    sort(ALL(r));
    ll Ans=INF;
    do{
        ll Num=0;
        rep(i, R-1){
            Num+=Way[r[i]][r[i+1]];
        }
        Ans=min(Ans, Num);
    }while(next_permutation(ALL(r)));
  
    if(Ans!=INF){
        cout<<Ans<<endl;
    }else{
        cout<<-1<<endl;
    }
}
     


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();

    int n;
    cin>>n;

    double x;

    for (int i=1;i<=n;i++)
    {
        x=i*1.08;
        if ((int)x==n)
        {
            cout<<i;
            return 0;
        }
    }
    cout << ":(";

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    int flag = 0;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
        if(a[i] % 2 == 0){
            if(a[i] % 3 != 0 && a[i] % 5 != 0){
                flag = 1;
            }
        }
    }
    if(flag == 0) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <numeric>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vec>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int main(){
    int h=in(),w=in(),ch=in()+1,cw=in()+1,dh=in()+1,dw=in()+1;
    vector<vec> a(h+5,vec(w+5,1)),ans(h+5,vec(w+5,10000000));
    rep(i,h){
        string s=stin();
        rep(j,w)if(s[j]=='.')a[i+2][j+2]=0;
    }
    vector<vector<bool>> doneA(h+5,vector<bool>(w+5,false)), doneB(h+5,vector<bool>(w+5,false));
    priority_queue<pair<int,pii>,vector<pair<int,pii>>,greater<pair<int,pii>>> que;
    que.push(mp(0,mp(ch,cw)));
    doneA[ch][cw]=doneB[ch][cw]=true;
    ans[ch][cw]=0;
    vec d = {-2,-1,0,1,2};
    vecpii dd = {mp(1,0),mp(-1,0),mp(0,1),mp(0,-1)};
    while(!que.empty()){
        int num = que.top().first, x = que.top().second.first,y = que.top().second.second;
        que.pop();
       // cout<<num<<" "<<x<<" "<<y<<endl;
        REP(e,dd){
            int xx = x + e.first, yy = y + e.second;
    //        cout<<xx<<" "<<yy<<"#$#"<<endl;
            if(!doneA[xx][yy] && a[xx][yy]==0){
                ans[xx][yy]=min(num,ans[xx][yy]);
                doneA[xx][yy]=true;
                que.push(mp(num,mp(xx,yy)));
            }
        }
       // cout<<"#"<<endl;
        rep(i,5)rep(j,5){
            int xx = x + d[i], yy = y + d[j];
            if(!doneB[xx][yy] && a[xx][yy]==0){
                ans[xx][yy]=min(num + 1,ans[xx][yy]);
                doneB[xx][yy]=true;
                que.push(mp(num+1,mp(xx,yy)));
            }
        }
    }
    if(ans[dh][dw]==10000000)ans[dh][dw]=-1;
    cout<<ans[dh][dw]<<endl;
}

Measured memory_bytes: 12116
def test(N, A, B, E):
    assert solve(N, A, B) == E, "solve(%d, %d, %d) == %d" % (N, A, B, E)

def solve(N, A, B):
    if (B - A) % 2 == 0:
        return (B - A) // 2
    if A == 1:
        return solve(N, 1, B-1)+1
    if B == N:
        return solve(N, A+1, N)+1
    return min(solve(N, 1, B-(A-1))+(A-1), solve(N, A+(N-B), N)+(N-B))

N, A, B = map(int, input().split())
print(solve(N, A, B))


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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		for(;;){
			String s=br.readLine();
		    String[] st=s.split(" ");
			int a=Integer.parseInt(st[0]);
			int b=Integer.parseInt(st[1]);
			if(a==0&&b==0)break;
			for(int i=1;i<=a;i++){int m=0;
			
				if(i%2==1){System.out.print("#");m++;}
				for(int l=1;l<=b-m;l++){
					if(l%2==1)System.out.print(".");
					else System.out.print("#");					
				}
			 System.out.println();
			}System.out.println();
		}
		

	}
}

Measured memory_bytes: 25892
#include<stdio.h>
#define  N 2000000
#define INF -2100000000

int h,a[N+1];

void maxHeapify(int i){
  int l,r,largest,temp;
  l=2*i;
  r=2*i+1;

  if(l<=h&&a[l]>a[i]) largest=l;
  else largest=i;
  if(r<=h&&a[r]>a[largest]) largest=r;

  if(largest!=i){
    temp=a[i];
    a[i]=a[largest];
    a[largest]=temp;
    maxHeapify(largest);
  }
}

int extract(){
  int max;
  if(h<1) return INF;
  max=a[1];
  a[1]=a[h--];
  maxHeapify(1);
  return max;
}

void heapincreasekey(int i,int key){
  int temp;

  if(key<a[i]) return;
  a[i]=key;

  while(i>1&&a[i/2]<a[i]){
    temp=a[i];
    a[i]=a[i/2];
    a[i/2]=temp;
    i=i/2;
  }
}

void insert(int key){
  h++;
  a[h]=INF;
  heapincreasekey(h,key);
}

int main(){
  int key;
  char c[10];

  while(1){
    scanf("%s",c);
    if(c[0]=='e'&&c[1]=='n') break;
    if(c[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    else{
      printf("%d\n",extract());
    }
  }

  return 0;
}


Measured memory_bytes: 5592
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

ll power(ll x,ll n)
{
    if(n==0){return 1;}
    if(n==1){return x;}
    if(n%2==0){
        return power((x*x)%mod,n/2);
    }
    if(n%2==1){
        return (power((x*x)%mod,n/2)*x)%mod;
    }
}

ll fac[N];

ll ncr(ll n,ll r)
{
    ll num=fac[n];
    ll denum=(fac[r]*fac[n-r])%mod;
    ll ans=(num*power(denum,mod-2))%mod;
    return ans;
}

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

    fac[0]=1;
    for(ll i=1;i<N;++i){
        fac[i]=(i*fac[i-1])%mod;
    }

    ll n,m,k;
    cin>>n>>m>>k;
    ll ans=0;
    for(ll b=1;b<=n;++b)
    {
        if(n-b<=k){
            ll ch=(m%mod*power((m-1+mod)%mod,b-1))%mod;
            ch=(ch*ncr(n-1,b-1))%mod;
            ans=(ans+ch)%mod;
        }
    }
    cout<<ans;

    return (0);
}


Measured memory_bytes: 7544
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))

total = sum(abs(x) for x in A)
neg_num = len([x for x in A if x < 0])

if neg_num % 2 == 1:
    min_num = min(abs(x) for x in A)
    total -= min_num * 2

print(total)

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

int main(){
  int num,a[4]={};
  char c;
  string s,b[4]={"A","B","AB","O"};

  while(cin>>num>>c>>s)
    for(int i=0;i<4;i++)
      if(s==b[i]) 
	a[i]++;

  for(int i=0;i<4;i++)
    cout<<a[i]<<endl;
 return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <string.h>

int main(void)
{
  char W[10];
  char T[1000];
  int i,n;

  scanf("%s",W);

  n=0;
  while(1){
    scanf("%s",T);
    if(strcmp(T,"END_OF_TEXT")==0){
      break;
    }

    for(i=0;T[i]!='\0'; i++){
      if('A'<=T[i]&&T[i]<='Z'){
        T[i] += 0x20;
      }
    }
    if(strcmp(T,W)==0){
      n++;
    }
  }
  printf("%d\n",n);
  return(0);
}



Measured memory_bytes: 2136
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
	int n;
	cin >> n;
	n=(n+110)/111;
	cout << n*111 << endl;
	return 0;
}	

Measured memory_bytes: 256
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
  
    ll n,i,j,ac=0,re=0,tle=0,wa=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
    	string s;
    	cin>>s;
    	if(s=="AC") ac++;
    	else if(s=="WA") wa++;
    	else if(s=="TLE") tle++;
    	else re++;
    }
    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE x "<<re<<"\n";
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>

int main(void){
    int i,j,k;
    int N;
    int H[100000];
    int answer = 0,max_value = 0,max_index = 0,start = 0;
    
    scanf("%d",&N);
    for(i = 0;i < N-1;i++){
        scanf("%d\n",&H[i]);
    }
    scanf("%d",&H[i]);
    
    for(i = 0;i < N-1;i++){
        if(H[i] >= H[i+1]){
            answer++;
            if(answer > max_value){
                max_value = answer;
                max_index = start;
            }
        }else{
            if(answer > max_value){
                max_index = start;
            }
            answer = 0;
            start = i + 1;
        }
    }
    
    printf("%d\n",max_value);
    
    return 0;
}













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

void solve(long long N) {
    if (N % 1000 == 0) {
        cout << 0 << endl;
    } else {
        cout << ((N / 1000) + 1) * 1000 - N << endl;
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

const int Nmax=100010;
vi g[Nmax];
int p[Nmax];
int buf[Nmax];
int Coincide(vi a,vi b){
	for(auto x:a)
		buf[x]=1;
	int res=0;
	for(auto x:b)
		res+=buf[x];
	for(auto x:a)
		buf[x]=0;
	return res;
}
bool vis[Nmax];
void dfs(int v,vi&a,vi&b){
	if(vis[v])return;
	vis[v]=true;
	a.PB(v);
	b.PB(p[v]);
	for(auto to:g[v])
		dfs(to,a,b);
}

signed main(){
	int n=read(),m=read();
	REP(i,n)p[i]=read()-1;
	REP(_,m){
		int x=read()-1,y=read()-1;
		g[x].PB(y);
		g[y].PB(x);
	}
	int ans=0;
	REP(i,n)if(!vis[i]){
		vi a,b;
		dfs(i,a,b);
		ans+=Coincide(a,b);
	}
	print(ans);
}


Measured memory_bytes: 14748
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#define int long long
using namespace std;

int dp[100001];
signed main() {
	int n, w; cin >> n >> w;
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		int x, y; cin >> x >> y;
		for (int j = 100000; j >= y; j--) {
			dp[j] = min(dp[j], dp[j - y] + x);
		}
	}
	for (int i = 100000; i >= 0; i--) {
		if (dp[i] <= w) { cout << i << endl; return 0; }
	}
}

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

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;

    if(a + b == 15)cout << '+' << endl;
    else{
        if(a * b == 15){
            cout << '*' << endl;
        }
        else cout << 'x' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int n,a[101],i,j,k=0,max,min,t,b[101];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	max=a[0];
	for(i=0;i<n;i++)
	{
		if(max<a[i])
		max=a[i];
	}
	min=a[0];
	for(i=0;i<n;i++)
	{
		if(min>a[i])
		min=a[i];
	}
	for(i=0;i<100;i++)
	b[i]=0;
	for(i=min;i<=max;i++)
	{
		for(j=0;j<n;j++)
		{
			b[k]=b[k]+(a[j]-i)*(a[j]-i);
		}
		k++;
	}
	min=b[0];
	for(i=0;i<k;i++)
	{
		if(min>b[i])
		min=b[i];
	}
	printf("%d",min);
	return 0;
}

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

long long gcd(long long a, long long b){
	if(a%b==0){
		return b;
	}else{
		return gcd(b, a%b);
	}
}
int main(){
	long long a, b, c, d, nstart, nend, nsum, ccnt, dcnt, cdcnt, cd;
	cin >> a >> b >> c >> d;
	nsum = b - a + 1;
	if(a!=0){
		a--;
	}
	ccnt = b/c - a/c;
	dcnt = b/d - a/d;
	cd = c*d/gcd(c, d);
	cdcnt = b/cd - a/cd;
	cout << nsum - ccnt - dcnt + cdcnt << endl;
	return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str,strArray[];

		while((str=br.readLine()) != null){
			int index[] = new int[14];
			int count=0;
			boolean judge=false;
			strArray = str.split(",");

			for(String s:strArray){
				count = Math.max(count, ++index[Integer.parseInt(s)]);
			}

			if(count==4){
				System.out.println("four card");
			}
			else if(count==3){
				for(int i=0; i<14; i++){
					if(index[i]==2){
						judge=true;
						break;
					}
				}
				System.out.println(judge ? "full house" : "three card");
			}
			else if(count==2){
				int c=0;
				for(int i=0; i<14; i++){
					if(index[i]==2){
						c++;
					}
				}
				System.out.println(c==2 ? "two pair" : "one pair");
			}
			else{
				if(index[1]==1 && index[10]==1 &&index[11]==1 && index[12]==1 && index[13]==1){
					System.out.println("straight");
				}else{
					int i=0;
					for(i=0; i<14; i++){
						if(index[i]==1){
							judge=true;
							break;
						}
					}

					for(int j=i; j<i+5; j++){
						if(index[j] != 1){
							judge=false;
						}
					}
					System.out.println(judge ? "straight" : "null");
				}
			}
		}
	}
}

Measured memory_bytes: 16924
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main(){
	int N, M;
	cin >> N >> M;

	int ans = N * (N-1) / 2 + M * (M-1) / 2;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<string.h>
#include<string>

#define Max 1005
using namespace std;

int N;

int Long(string A, string B)
{
	int a = A.length();
	int b = B.length();
	int L[Max][Max];
	int maxi = 0;
	for (int i = 0; i < a; i++)
	{
		L[i][0] = 0;
	}

	for (int i = 0; i < b; i++)
	{
		L[0][i] = 0;
	}

	for (int i = 1; i < a; i++)
	{
		for (int j = 1; j < b; j++)
		{
			if (A[i] == B[j])
				L[i][j] = L[i - 1][j - 1] + 1;
			else
				L[i][j] = max(L[i - 1][j], L[i][j - 1]);
			maxi = max(maxi, L[i][j]);
		}
	}
	return maxi;
}

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string A;
		string B;
		cin >> A;
		A = ' ' + A;
		cin >> B;
		B = ' ' + B;
		cout << Long(A, B) << endl;
	}
	return 0;
}


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

#define MAX 200005
#define sf scanf
#define FOR(i, x, y) for(int i = int(x); i < int(y); i++)
#define clr(x, y) memset(x, y, sizeof(x))
#define ll long long
#define pii pair<int, int>
#define inf 0x3f3f3f3f
#define ff first
#define ss second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

map<string, int> mp;
vector<string> v;

char s[MAX];

int main(){
    #ifdef VAMP
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // VAMP
    int n; sf("%d", &n);
    int mx = 0;
    FOR(i, 0, n){
        sf("%s", s);
        mx = max(mx, ++mp[s]);
    }
    for(auto x: mp){
        if(x.ss == mx) v.pb(x.ff);
    }
    sort(all(v));
    for(auto x: v){
        cout<<x<<endl;
    }


    return 0;
}


Measured memory_bytes: 25584
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,in,ans=0;
    vector<int> tl;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>in;
        tl.push_back(in);
    }
    sort(tl.rbegin(),tl.rend());
    for(int i=0;i<tl.size();i++){
        if(i%2)ans-=tl[i];
        else ans+=tl[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int i, j = 0, seisu[10000], max = -10000000, min = 10000000, num;
	long int sum = 0;
	scanf("%d", &i);

	while(j != i)
	{
		scanf("%d", &seisu[j]);

		j++;
	}

	j = 0;

	for(j=0; j<i; j++)
	{
		num = seisu[j];

		if(max < num)
		{
			max = num;
		}
		
		if(min > num)
		{
			min = num;
		}

		sum = sum + num;
	}

	printf("%d %d %ld\n", min, max, sum);

	return 0;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))

b = [0] * (n + 5)
for i in range(n):
    b[a[i]] += 1

ans = 0
for i in range(1, n + 1):
    ans += b[i] * (b[i] - 1) // 2

for i in range(n):
    l = b[a[i]]
    print(ans - (l * (l - 1) // 2) + ((l - 1) * (l - 2)) // 2)

Measured memory_bytes: 26140
#include<bits/stdc++.h>
using namespace std;
vector<int> L[2000];int N,M,E,match[2000],x[2000],y[2000];bool used[2000];
bool DFS(int V){
    used[V]=true;
    for(int i=0;i<L[V].size();i++){
        int u=L[V][i],w=match[u];
        if(w<0||!used[w]&&DFS(w)){
            match[V]=u;
            match[u]=V;
            return 1;
        }
    }
    return 0;
}
int SM(){
    int r=0;
    memset(match,-1,sizeof(match));
    for(int j=0;j<N+M;j++){
        if(match[j]<0){
            memset(used,0,sizeof(used));
            if(DFS(j)){r++;}
        }
    }
    return r;
}
int main(){
    while(1){
        for(int i=0;i<2000;i++){L[i].clear();}
        cin>>N>>M;if(!N){break;}
        for(int i=0;i<N;i++){
            cin>>x[i];
        }
        for(int i=0;i<M;i++){
            cin>>y[i];
        }
        for(int i=0;i<N;i++){
            for(int j=0;j<M;j++){
                if(__gcd(x[i],y[j])>1){
                    L[i].push_back(j+N);
                }
            }
        }
        cout<<SM()<<endl;
    }
    return 0;
}

Measured memory_bytes: 4112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		Scanner in= new Scanner(System.in);
		PrintWriter out= new PrintWriter(System.out);
		int n= in.nextInt();
		int [] a= new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i]= in.nextInt();
		}
		Arrays.sort(a);
		int prev= a[0];
		int res=0;
		int numof=1;
		for (int i = 1; i < a.length; i++) {
			int cur= a[i];
			if(cur==prev) {
				numof++;
			}
			else {
				if(numof%2!=0) res++;
				numof=1;
			}
			prev= cur;
		}
		//System.out.println(numof);
		if(numof%2!=0) res++;
		System.out.println(res);
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 49544
from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
res = []
for i in range(n):
    for j in range(len(a))[::-1]:
        if a[j] == j+1:
            res.append(a[j])
            del a[j]
            break
    else:
        print(-1)
        quit()
for i in range(n)[::-1]:
    print(res[i])



Measured memory_bytes: 39020
#include <iostream>
#include <cstdlib>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main(void)
{
    int64_t N, D;
    cin >> N >> D;

    int64_t ans = 0;

    for (int64_t i = 0; i < N; ++i)
    {
        int64_t x, y;
        cin >> x >> y;
        if (x*x + y*y <= D*D) ++ans;
    }

    cout << ans;
    
    return 0;
}


Measured memory_bytes: 3160
#include <stdio.h>

int a[10000];

int main() {
	
	int s;

	scanf("%d",&s);
	
	int i;
	
	a[s]=1;
	
	for(i=2;;i++){
		if(s%2==0){s/=2;}
		else{s=(3*s)+1;}
		if(a[s]>0 && i!=2){break;}
		a[s]=i;
	}
	
	printf("%d\n",i);

	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main(){
  ll n;
  cin >> n;
  vl vec(n);
  rep(i, n) cin >> vec[i];
  ll sum = 0;
  rep(i, n) sum += vec[i];
  ll snuke = 0;
  ll ans = 1000000000000000001;
  rep(i, n-1){
    snuke += vec[i];
    ll araiguma = sum-snuke;
    ans = min(ans, abs(araiguma-snuke));
  }
  cout << ans << endl;
  return 0;
}

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


int main() {
    int A,B,C,X,Y;
    int ans;
    cin >>A>>B>>C>>X>>Y;
    int mx =max(X,Y);
    if(A+B>2*C){
        if(X>=Y){
            ans = min(2*C*mx,2*C*Y + A*(X-Y));
        }
        else ans = min(2*mx*C,2*C*X + B*(Y-X));
    }
    else ans = A*X + B*Y;



    cout << ans <<endl;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

INF = int(1e20)
dp = [INF] * (N)
dp[0] = 0


for i in range(N-1):
    if i == N-2:
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
    else:
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]))

print(dp[N-1])

Measured memory_bytes: 52208