akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;
char Num_1[5]={'?',39,',','.','!'};
char Num_2[6]={'C','a','b','c','A','B'};
char Num_3[6]={'F','d','e','f','D','E'};
char Num_4[6]={'I','g','h','i','G','H'};
char Num_5[6]={'L','j','k','l','J','K'};
char Num_6[6]={'O','m','n','o','M','N'};
char Num_7[8]={'S','p','q','r','s','P','Q','R'};
char Num_8[6]={'V','t','u','v','T','U'};
char Num_9[8]={'Z','w','x','y','z','W','X','Y'};
void translate(char c,int n)
{
	int i;
	switch(c)
	{
	case '0':
		for(i=0;i<n-1;i++)cout<<" ";break;
	case '1':cout<<Num_1[n%5];break;
	case '2':cout<<Num_2[n%6];break;
	case '3':cout<<Num_3[n%6];break;
	case '4':cout<<Num_4[n%6];break;
	case '5':cout<<Num_5[n%6];break;
	case '6':cout<<Num_6[n%6];break;
	case '7':cout<<Num_7[n%8];break;
	case '8':cout<<Num_8[n%6];break;
	case '9':cout<<Num_9[n%8];break;
		
	}
}
void convert(char str[])
{
	int i=0;
	int cnt=0;
	while(str[i]!='\0')
	{
		if(str[i] != str[i+1])
		{
			cnt++;
			translate(str[i],cnt);
			cnt=0;
		}
		else cnt++;
		i++;
	}
}
int main()
{
	char str[10010];
	while(cin>>str)
	{
		convert(str);
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cctype>
//#include <stdio.h>
using namespace std;

string shuffle(string s, int n){
	string s1 = s;
	string s2 = s;
	s1.erase(s1.begin() + 0, s1.begin() + n);
	s2.erase(s2.begin() + n, s2.begin() + s2.size());
	return s1 + s2;
}


int main(){
	string str[200];
	int m, n;
	
	for (int i = 0; i < 200; i++){
		//cout << "string:";
		cin >> str[i];
		if (str[i] == "-") break;
		//cout << "m:";
		cin >> m;
		for (int j=0; j < m; j++){
			//cout << j << "-";
			cin >> n;
			str[i] = shuffle(str[i] , n);
		}
	}	
	for (int k = 0; k < 200; k++){
		if (str[k] == "-") break;
		cout << str[k] << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
def main():
    N = int(input())
    A = list(map(int, input().split()))

    mod = 10 ** 9 + 7

    s = [0] * N
    for i, a in enumerate(A[::-1], 1):
        if i == N:
            continue
        else:
            s[N-i-1] = (s[N-i] + a) % mod

    ans = 0
    for i, a in enumerate(A):
        ans += a * s[i]
        ans %= mod

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 31400
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i32,
        w: [i32; n],
    }
    let mut ans: i32 = 1 << 25;
    for i in 0..w.len() {
        let sum1: i32 = (&w[0..i]).iter().sum();
        let sum2: i32 = (&w[i..w.len()]).iter().sum();

        ans = std::cmp::min(ans, (sum1 - sum2).abs());
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		TreeMap<Integer,ArrayList<Integer>> tmap=new TreeMap<>();
		for(int i=0;i<n-1;i++) {
			int x=scn.nextInt();
			if(tmap.containsKey(x)) {
				ArrayList<Integer> a=tmap.get(x);
				a.add(i);
				tmap.put(x, a);
			}else{
				ArrayList<Integer> a=new ArrayList<>();
				a.add(i);
				tmap.put(x, a);
			}
		}
		int []arr=new int[n];
		for(int i=0;i<n;i++) {
			arr[i]=-1;
		}
		Set<Integer> set=tmap.keySet();
		for(int x:set) {
			ArrayList<Integer> al=tmap.get(x);
			for(int i=0;i<al.size();i++) {
				if(arr[al.get(i)]==-1)
				arr[al.get(i)]=x;
				if(arr[al.get(i)+1]==-1)
				arr[al.get(i)+1]=x;
			}
		}
		int sum=0;
		//System.out.println(tmap);
		for(int i=0;i<n;i++) {
			sum+=arr[i];
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 22100
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

S = s()
check = set(S)

success = True

if 'W' in check and 'E' not in check\
    or 'E' in check and 'W' not in check\
    or 'N' in check and 'S' not in check\
    or 'S' in check and 'N' not in check:
    success = False

if success:
    print 'Yes'
else:
    print 'No'



Measured memory_bytes: 4900
import sys,collections
#sys.stdin=open("data.txt")
input=sys.stdin.readline

n=int(input())

d=collections.deque()

c=0
for i in map(int,input().split()):
    if c==0:
        d.append(i)
        c=1
    else:
        d.appendleft(i)
        c=0

if c==1:
    l=list(d)[::-1]
else:
    l=list(d)

print(" ".join(map(str,l)))


Measured memory_bytes: 123220
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pb push_back
#define mp make_pair
#define int long long
const unsigned int mod = 1e9+7;
const int mx=100005;
const int N=2*1e5+100;
int t[4*N],a[N],b[N],n;
void upd(int v,int tl,int tr,int pos,int x){
	if(tl==tr){
		t[v]=x;
		return;
	}
	int tm=(tl+tr)/2;
	if(pos<=tm)upd(v*2,tl,tm,pos,x);
	else upd(v*2+1,tm+1,tr,pos,x);
	t[v]=max(t[v*2],t[v*2+1]);
}
int get(int v,int tl,int tr,int l,int r){
	if(l>r)return 0;
	if(tl==l and tr==r)return t[v];
	int tm=(tl+tr)/2;
	return max(get(v*2,tl,tm,l,min(r,tm)),get(v*2+1,tm+1,tr,max(tm+1,l),r));
}
signed main(){
	/*freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);*/  
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	cin >> n;
	for(int i=1;i<=n;++i)cin >> a[i];
	for(int i=1;i<=n;++i)cin >> b[i];
	for(int i=1;i<=n;++i){
		upd(1,1,N,a[i],get(1,1,N,1,a[i])+b[i]);
	}
	cout << get(1,1,N,1,n) << endl;
}
	

Measured memory_bytes: 8448
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

void solve(){
   int d,n;
    cin >> d >> n;
  
  int ans = 1;
  int cnt = 0;

  while(d--){
    //cout << cnt << end;
    ans*=100;
  }

  if(n<100)cout << ans*n << endl;
  else

    cout << ans*101 << endl;
} 

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


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

int main(void){
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    rep(i, n) cin >> x[i];
    rep(i, n) cin >> y[i];
    double a, b, c, mx;
    a = b = c = 0.0;
    mx = -1 * (1e9 + 7);
    rep(i, n){
        double v = abs(x[i] - y[i]);
        a += v;
        b += v * v;
        c += v * v * v;
        mx = max(mx, v);
    }
    b = sqrt(b);
    c = pow(c, 1.0 / 3.0);
    cout << fixed << a << endl << b << endl << c << endl << mx << endl;
    return 0;
}


Measured memory_bytes: 3404
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio()	 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)


int costmin(int n,int h[],int k){
	vector<int> dp(n,INT_MAX);

	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	// cout<<dp[]<<endl;
 	for(int i=2;i<n;i++){
 		for (int j = 1; j <= min(k,n); ++j){
 			if(i-j>=0) dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
 		}
    	
  }
   return dp[n-1];
}


int main(){
	fastio();
	int n;cin>>n;
	int a[n];
	int k;cin>>k;
	for(int&x:a) cin>>x;
	int ans=costmin(n,a,k);
	cout<<ans<<endl;







    return 0;
	
}

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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 100100;

int n;
pair<int, int> a[maxn + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	REP(i, 0, n) scanf("%d", &a[i].x), a[i].y = a[i].x;
	int ans = 0;
	while (1)
	{
		bool has = 0, flag = 0;
		REP(i, 0, n)
		{
			if (a[i].x > 1) 
			{
				if (!flag) ++ans, flag = 1;
				else if (a[i].y == 1) flag = 0;
				has = 1;
			}
			else flag = 0;
			a[i].x = (a[i].x + 1) >> 1;
			a[i].y = a[i].y >> 1;
		}
		if (!has) break;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1024
N, K = map(int, input().split())
i = 1
lstA = []
while (i < K + 1):
  lstd = list(map(int, input().split()))
  lstA0 = list(map(int, input().split()))
  for a in lstA0:
    lstA.append(a)
  i += 1

j = 1
lst2 = []
while(j < N + 1):
  if(j not in lstA):
    lst2.append(j)
  j += 1

print(len(lst2))

Measured memory_bytes: 9272
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll a, b, c, k ;
  cin >> a >> b >> c >> k ;
  if(k%2==0){
    cout << a-b <<endl ;
  }
  else{
    cout << b-a <<endl ;
  }
  
  
  
  return 0 ;
}



Measured memory_bytes: 256
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i + 5000*j + 1000*(n-i-j) == y:
            print(i, j, n-i-j)
            exit()

print("-1 -1 -1")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=3501 ;
int main()
{
   fast ;
   ll n,k ;
   cin>>n>>k ;
   ll ans=0 ;
   for(ll a=0;a<k;a++)
   {
       ll x=(n-a)/k ;
       if(x>=0)
       {
           ll b=k-a ;
           b%=k ;

           ll y=(n-b)/k ;
           if(y>=0)
           {
               if((b+b)%k==0)
               {
                   //cout<<a<<" "<<b<<" "<<x<<" "<<y<<endl;
                   if(a>0&&a<=n)
                   ans+=(x+1)*(y+1)*(y+1) ;
                   else
                    ans+=x*y*y ;

               }
           }
       }
   }
   cout<<ans ;

}


Measured memory_bytes: 256
n = int(input())
P = list(map(int, input().split()))

ans = 0
for i in range(1, n-1):
    a = P[i-1]
    b = P[i]
    c = P[i+1]
    if a < b < c:
        ans += 1
    elif a > b > c:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, K = LI()
A = LI()

for i in range(N - K):
    if A[i] < A[i + K]:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; i++) cin >> p[i];

    sort(p.begin(), p.end());

    int ans = 0;
    for (int i = 0; i < K; i++) ans += p[i];

    cout << ans << endl;
}

Measured memory_bytes: 3632
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    f = [0]*(n+1)
    for i in range(1,n+1):
        j = i
        while j <= n:
            f[j] += 1
            j += i
    print(f[1::2].count(8))
    return

#Solve
if __name__ == "__main__":
    solve()


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

using namespace std;

int main(){
	
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int maxval = 0;
	if(a>=k) cout<<k<<endl;
	else{
		maxval += a;
		k -=a;
		if(b>=k) cout<<maxval<<endl;
		else{
			k -= b;
			if(c>=k){
				maxval-=k;
				cout<<maxval<<endl;
				}
				else{
					maxval-=c;
					cout<<maxval<<endl;
					}
			}
		}
	
	return 0;
	}


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

long long N, a[111];

int main(){
  scanf("%lld", &N);
  for(int i = 0; i < N; ++i)scanf("%lld", a + i);
  cout << *max_element(a, a + N) - *min_element(a, a + N) << endl;
}

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

int main() {
  int array[5], k;
  for (int i = 0; i < 5; ++i) {
    cin >> array[i];
  }
  cin >> k;
  
  sort(array, array+5);
  
  if (array[4] - array[0] > k) {
    cout << ":(";
  } else { 
    cout << "Yay!";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

const int MAXN = 400000;

const int UNION_FIND_N = MAXN;
int parent[UNION_FIND_N];
LL sum[UNION_FIND_N];
int lastEdge[UNION_FIND_N];
int vWeight[MAXN];

vector<pair<int, pair<int, int> > > edges;

bool goodEdge[MAXN];
LL sumAtGood[MAXN];
vector<int> G[MAXN];


// assumes that if vertex v does not have parent,
// i.e. if v is root, then parent[v] = v
int root(int v) {
	if (parent[v] == v)
		return v;
	return parent[v] = root(parent[v]);
}

void merge(int u, int v, int edge) {
	int rv = root(v);
	int ru = root(u);
	if (rv == ru)
		return;
	
	parent[rv] = ru;
	sum[ru] += sum[rv];
	G[edge].pb(lastEdge[rv]);
	G[edge].pb(lastEdge[ru]);
	lastEdge[ru] = edge;
	if (edges[edge].first <= sum[ru]) {
		goodEdge[edge] = true;
		sumAtGood[edge] = sum[ru];
	}
}

void init_union_find(int n) {
	for (int i = 0; i < n; i++) {
		parent[i] = i;
		sum[i] = vWeight[i];
		lastEdge[i] = -i - 1;
	}
}

int n, m;



int label[MAXN];


void dfs(int edge, bool good, int l) {
	bool nextGood = good;
	int nextLabel = l;
	if (!good && goodEdge[edge]) {
		nextGood = true;
		nextLabel = edge;
	}
	
	int e0 = G[edge][0], e1 = G[edge][1];
		
	if (e0 < 0) {
		e0 = -e0 - 1;
		label[e0] = nextLabel;
	}
	else {
		dfs(e0, nextGood, nextLabel);
	}
	
	if (e1 < 0) {
		e1 = -e1 - 1;
		label[e1] = nextLabel;
	}
	else {
		dfs(e1, nextGood, nextLabel);
	}
}



int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	FOR (i, MAXN)
		G[i].clear();
	edges.clear();

	cin >> n >> m;
	FOR (i, n)
		cin >> vWeight[i];
	
	if (!m) {
		cout << 0 << endl;
		return 0;
	}
	
	int x, y, c;
	FOR (i, m) {
		cin >> x >> y >> c;
		x--;
		y--;
		edges.pb(make_pair(c, make_pair(x, y)));
	}
	sort(all(edges));
	
	init_union_find(n);
	
	SET(goodEdge, 0);
	
	int lastAdded = -1;
	
	FOR (i, edges.sz) {
		int a = edges[i].second.first;
		int b = edges[i].second.second;
		if (root(a) == root(b))
			continue;

		merge(a, b, i);
		lastAdded = i;
	}
	
	dfs(lastAdded, false, -1);
	
	int ret = 0;
	FOR (i, edges.sz) {
		int a = edges[i].second.first;
		int b = edges[i].second.second;
		if (label[a] < 0 || label[b] < 0) {
			ret++;
			continue;
		}
		if (label[a] != label[b]) {
			ret++;
			continue;
		}
		if (sumAtGood[label[a]] < edges[i].first)
			ret++;
	}
	
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 23796
#include <stdio.h>

int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if (a==5) {
        if (b==5) {
            if (c==7) printf("YES");
            else printf("NO");
        }else if(b==7){
            if (c==5) printf("YES");
            else printf("NO");
        }else printf("NO");
    }else if(a==7){
        if (b==5) {
            if (c==5) printf("YES");
            else printf("NO");
        }else printf("NO");
    }else printf("NO");
    return 0;
}


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

int main()
{
    int n = 0;
    cin >> n;
    bool flag = false;

    for (int i = 0; i < n; i++) 
    {
        string s;
        cin >> s;

        if(s == "Y") {
            flag = true; 
            break;
        }
    }

    if(flag){
        puts("Four");
    }else{
        puts("Three");
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    int X = w / 2;
    int Y = h / 2;
    //cout << X << " " << Y << endl;
    cout << fixed << setprecision(12) << w * h / 2.0 << " " << (X == x && Y == y && w % 2 == 0 && h % 2 == 0) << endl;

    return 0;
}


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

using namespace std;
 
int main(void){
 
   int A,B;
   int turi;
   int money[3];
   int neda[3]={100,500,1000};

   while(1){

	   cin>>A>>B;
	   if(A==0&&B==0) break;
	   turi=B-A;

	   for(int i=2;i>=0;i--){
		   money[i]=turi/neda[i];
		   turi%=neda[i];
	   }

	   for(int i=0;i<2;i++){
		   cout<<money[i]<<" ";
	   }
	   cout<<money[2]<<endl;

   }

   return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n = stoi(s.substr(0,2));

    int m = stoi(s.substr(2,2));

    if((n == 0 && m == 0) || (n > 12 && m > 12) || (n == 0 && m > 12) || n > 12 && m == 0){
        cout << "NA" << endl;
    }else if(n <= 12 && (m > 12 || m == 0)){
        cout << "MMYY" << endl;
    }else if((n > 12 || n == 0) && m <= 12){
        cout << "YYMM" << endl;
    }else{
        cout << "AMBIGUOUS" << endl;
    }
}


Measured memory_bytes: 384
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
S = list(input())[:-1]
T = list(input())[:-1]
N = len(S)
n = len(T)
MIN = 10000
for i in range(N-n+1):
    c = 0
    for j in range(n):
        if S[i+j] != T[j]:
            c += 1
    MIN = min(MIN,c)
print(MIN)
            








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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    int N; cin >> N;
    int ans = 0;
    FOR(i,1,N+1){
        if(i<10) ans++;
        else if(i<100) continue;
        else if(i<1000) ans++;
        else if(i<10000) continue;
        else if(i<100000) ans++;
    }
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ABC_113
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            var pys = new int[nm[1]][];
            for(int i = 0; i < nm[1]; i++)
            {
                int[] temp = ReadInts();
                pys[i] = new int[4] { temp[0], temp[1], i, 0 };
            }
            Array.Sort(pys, (a, b) => a[1] - b[1]);
            for(int i = 0; i < nm[1]; i++)
            {
                //Console.WriteLine(pys[i][0] + " " + pys[i][1]);
            }
            var cnts = new int[nm[0]];

            for(int i = 0; i < nm[1]; i++)
            {
                cnts[pys[i][0] - 1]++;
                pys[i][3] = cnts[pys[i][0] - 1];
            }
            Array.Sort(pys, (a, b) => a[2] - b[2]);
            for(int i = 0; i < nm[1]; i++)
            {
                Console.WriteLine(pys[i][0].ToString("D6")
                    + pys[i][3].ToString("D6"));
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 24364
#include <cstdio>
#include <cmath>

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1;; i++){
        if(pow(2,i) > n){
            printf("%d\n",(int)pow(2,i - 1));
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define low(i) (i&(-i))
#define mid ((l+r)>>1)
#define ls (now<<1)
#define rs (now<<1|1)
#define par pair<int,int>
#define mp make_pair
#define fr first 
#define se second
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define drep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])
int n, ans1, ans2;
signed main() {
    cin >> n;
    if (n)
        ans1 = n / 500;
    if (n)
        n = n % 500;
    if (n)
        ans2 = n / 5;
    printf("%lld\n", ans1 * 1000 + ans2 * 5);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	long long int a,b;
	cin >> a >> b;
	if(a==0){
		if(b==100)	cout << b+1 << endl;
		else cout << b << endl;
	}
	else if(a==1){
		if(b==100)	cout << 100*(b+1) << endl;
		else cout << 100*b << endl;
	}
	else{
		if(b==100)	cout << 10000*(b+1) << endl;
		else	cout << 10000*b << endl;
	}
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

def solve(n,a):
  memo = [0]*(n+1)
  def f(a,present=1,cnt=0):
    next = a[present]
    if memo[next]:
      return -1
    elif next == 2:
      return cnt+1
    else:
      memo[present] = 1
      return f(a,next,cnt+1)
  return f(a)
      

N = int(input())
a = [0] + [int(input()) for _ in range(N)]
print(solve(N,a))

Measured memory_bytes: 155052
n = int(input())
a = list(map(int, input().split()))
ans = 1

if 0 in a:
    ans = 0
else:
    for i in a:
        if ans <= 1000000000000000000:
            ans *= i
        else:
            ans = -1
            break
if ans > 1000000000000000000:
    ans = -1

print(ans)


Measured memory_bytes: 21608
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1



n=int(input())
C=collections.Counter([input() for i in range(n)])
M=max(C.values())
S=[]
for e,i in  C.items():
  if i == M:
    S.append(e)
S.sort()
print(*S,sep="\n")

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

int main() {
	int n;
	cin >> n;
	vector<ll> a(n+1);
	ll sum = 0;
	rep(i, n+1) {
		cin >> a[i];
		sum += a[i];
	}
	ll ans = 1, now = 1;
	if(n>0 && a[0]>0)  {
		cout << -1 << endl;
		return 0;
	}
	if(n==0 && a[0]==0)  {
		cout << -1 << endl;
		return 0;
	}
	if(n==0 && a[0]>1)  {
		cout << -1 << endl;
		return 0;
	}
	rep(i, n) {
		now -= a[i];
		sum -= a[i];
		if (now < 0) {
			cout << -1 << endl;
			return 0;
		}
		
		if (now*2 <= sum) {
			now *= 2;
		} else if (now < sum) {
			now += sum-now;
		}
		ans += now;
		// cout << now << endl;
	}
	if (a[n] > now) {
		cout << -1 << endl;
		return 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4036
/*                                      ___           ___                                ___                 
   ___                                /\  \         /|  |                              /\  \                
  /\__\         ___                  /::\  \       |:|  |                 ___         /::\  \       ___     
 /:/__/        /\__\                /:/\:\  \      |:|  |                /\__\       /:/\:\  \     /\__\    
/::\  \       /:/  /               /:/ /::\  \   __|:|  |               /:/__/      /:/  \:\  \   /:/__/    
\/\:\  \     /:/__/               /:/_/:/\:\__\ /\ |:|__|____          /::\  \     /:/__/ \:\__\ /::\  \    
 ~~\:\  \   /::\  \               \:\/:/  \/__/ \:\/:::::/__/          \/\:\  \__  \:\  \ /:/  / \/\:\  \__ 
    \:\__\ /:/\:\  \               \::/__/       \::/~~/~               ~~\:\/\__\  \:\  /:/  /   ~~\:\/\__\
    /:/  / \/__\:\  \               \:\  \        \:\~~\                   \::/  /   \:\/:/  /       \::/  /
   /:/  /       \:\__\               \:\__\        \:\__\                  /:/  /     \::/  /        /:/  / 
   \/__/         \/__/                \/__/         \/__/                  \/__/       \/__/         \/__/  
*/
#include <bits/stdc++.h>
using namespace std;

char s[2010][10010];
int len[2010];
int sum[2010];
char ss[1000010];
int tot;
bitset <1000010> pos;
bitset <1000010> node[70];
bool dp[2010][10010];

void get_pre(){
	for (int i = 0; i < tot; i++){
		node[ss[i] - 'a' + 32].set(i);
	}
	for (int i = 31; i >= 1; i--){
		node[i] = node[i << 1] | node[i << 1 | 1];
	}
}

char get_min(){
	int now = 1;
	while (now < 32){
		if ((pos & node[now << 1]).none()) now = now << 1 | 1;
		else now = now << 1;
	}
	return (now - 32) + 'a';
}

int main(){
	int n, k; scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++){
		scanf("%s", s[i]), len[i] = strlen(s[i]);
		sum[i] = tot;
		for (int j = tot; j < tot + len[i]; j++){
			ss[j] = s[i][j - tot];
		}
		tot += len[i];
	}
	sum[n] = tot;
	dp[n][0] = 1;
	for (int i = n - 1; i >= 0; i--){
		for (int j = 0; j <= k; j++){
			dp[i][j] = dp[i + 1][j];
			if (j >= len[i]) dp[i][j] |= dp[i + 1][j - len[i]];
		}
	}
	get_pre();
	pos.reset(), pos.set(0);
	string ans;
	for (int i = 0; i < k; i++){
		for (int j = 0; j < n; j++){
			if (pos[sum[j]]) pos.set(sum[j + 1]);
		}
		for (int j = 0; j < n; j++){
			if (k - i - len[j] < 0 || !dp[j + 1][k - i - len[j]]) pos.reset(sum[j]);
		}
		char c = get_min();
		ans.push_back(c);
		pos &= node[32 + c - 'a'];
		pos <<= 1;
	}
	printf("%s\n", ans.c_str());
	return 0;
}


Measured memory_bytes: 48384
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

type Node struct {
	Key int
	Priority int
	Left *Node
	Right *Node
}

func main() {
	var n int
	fmt.Scan(&n)

	var root *Node
	
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	wr := bufio.NewWriter(os.Stdout)
	for i := 0; i < n; i++ {
		sc.Scan()
		com := sc.Text()
		if com == "print" {
			printInorder(root, wr)
			wr.WriteString("\n")
			printPreorder(root, wr)
			wr.WriteString("\n")
			continue
		}

		sc.Scan()
		k, _ := strconv.Atoi(sc.Text())
		
		switch com {
		case "insert":
			sc.Scan()
			p, _ := strconv.Atoi(sc.Text())
			root = insert(root, k, p)
		case "find":
			if find(root, k) == nil {
				wr.WriteString("no\n")
			} else {
				wr.WriteString("yes\n")
			}
		case "delete":
			root = delete(root, k)
		default:
			panic("invalid command")
		}
	}
	wr.Flush()
}

func insert(t *Node, k int, p int) *Node {
	if t == nil {
		return &Node{k, p, nil, nil}
	}
	if k == t.Key {
		return t
	}

	if k < t.Key {
		t.Left = insert(t.Left, k, p)
		if t.Priority < t.Left.Priority {
			t = rotateRight(t)
		}
	} else {
		t.Right = insert(t.Right, k, p)
		if t.Priority < t.Right.Priority {
			t = rotateLeft(t)
		}
	}
	return t
}

func rotateLeft(t *Node) *Node {
	s := t.Right
	t.Right = s.Left
	s.Left = t
	return s
}

func rotateRight(t *Node) *Node {
	s := t.Left
	t.Left = s.Right
	s.Right = t
	return s
}

func find(t *Node, k int) *Node {
	if t == nil {
		return nil
	} else if t.Key == k {
		return t
	} else if k < t.Key {
		return find(t.Left, k)
	} else {
		return find(t.Right, k)
	}
}

func delete(t *Node, k int) *Node {
	if t == nil {
		return nil
	}

	if k < t.Key {
		t.Left = delete(t.Left, k)
	} else if k > t.Key {
		t.Right = delete(t.Right, k)
	} else {
		// 実際の削除
		if t.Left == nil && t.Right == nil {
			return nil
		}
		if t.Left == nil {
			t = rotateLeft(t)
		} else if t.Right == nil {
			t = rotateRight(t)
		} else {
			if t.Left.Priority < t.Right.Priority {
				t = rotateLeft(t)
			} else {
				t = rotateRight(t)
			}
		}
		return delete(t, k)
	}
	return t
}

func printInorder(t *Node, wr *bufio.Writer) {
	if t == nil {
		return
	}
	printInorder(t.Left, wr)
	wr.WriteString(" ")
	wr.WriteString(strconv.Itoa(t.Key))
	printInorder(t.Right, wr)
}

func printPreorder(t *Node, wr *bufio.Writer) {
	if t == nil {
		return
	}
	wr.WriteString(" ")
	wr.WriteString(strconv.Itoa(t.Key))
	printPreorder(t.Left, wr)
	printPreorder(t.Right, wr)
}



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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<long long> x, std::vector<long long> y, std::vector<long long> h){    
    int max_x = 0;
    int max_y = 0;
    LL max_h = -1;

    if(N==1){
        cout << h[0] << endl;
        return ;
    }

    REP(i, 101) REP(j, 101){
        LL now_h = 0;
        REP(k, N){
            if(i == x[k] && j == y[k]) {
                now_h = h[k];
                break;
            }
            if(h[k] != 0) {
                now_h = abs(x[k]-i) + abs(y[k]-j) + h[k];
            }
        }

        bool is_valid = true;
        REP(k, N){
            if(!is_valid) break;
            if(h[k] == 0) {
                is_valid = (now_h - abs(x[k]-i) - abs(y[k]-j) <= 0);
            }else {
                is_valid = (now_h  == abs(x[k]-i) + abs(y[k]-j) + h[k]);
            }
        }

        if(is_valid && max_h < now_h){
            max_x = i;
            max_y = j;
            max_h = now_h;
        }
    }

    cout << max_x << " " << max_y << " " << max_h << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        scanf("%lld",&h[i]);
    }
    solve(N, std::move(x), std::move(y), std::move(h));
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Union Find tree with potential
//-------------------------------------------------
template<typename T>
class pUnionFind
{
private:
    ::std::vector<int> par;
    ::std::vector<int> rank;
    ::std::vector<T> diff;
public:
    pUnionFind(int n):par(n), rank(n), diff(n){
        for(int i=0; i<n; i++){
            par[i] = i;
            rank[i] = 0;
            diff[i] = 0;
        }
    }
    int root(int x){
        if (par[x]==x) return x;
        int rx = root(par[x]);
        diff[x] += diff[par[x]];
        return par[x] = rx;
    }
    T weight(int x){
        root(x);
        return diff[x];
    }
    T climb(int x, int y){
        return weight(y)-weight(x);
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    void unite(int x, int y, T w){
        int rx = root(x);
        int ry = root(y);
        if (rx==ry) return;
        w += weight(x)-weight(y);
        if (rank[rx]>rank[ry]){
            diff[ry] = w;
            par[ry] = rx;
        }else{
            diff[rx] = -w;
            par[rx] = ry;
            if (rx==ry) rank[ry]++;
        }
    }
};

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    while(cin>>n>>m, n>0){
        pUnionFind<int> uf(n);
        while(m--){
            char c; cin>>c;
            if (c=='!'){
                int a,b,w; cin>>a>>b>>w; a--; b--;
                uf.unite(a,b,w);
            }else{
                int a,b; cin>>a>>b; a--; b--;
                if (uf.same(a,b)){
                    cout<<uf.climb(a,b)<<"\n";
                }else{
                    cout<<"UNKNOWN\n";
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 4864
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;

// #define int long long



signed main(){
  
    ios::sync_with_stdio(false);
    cin.tie(0);
	//cin高速化

	vector<int> v;
	int tmp;

    
    int n;
    cin>>n;

	int min_v=1000000;
    int max_v=-1;

    int hoge=-1;
    int ans=INF;

    REP(i,n){
    	cin>>tmp;

    	min_v=min(min_v,tmp);
    	max_v=max(max_v,tmp);
    	v.push_back(tmp);
    }


    sort(v.begin(),v.end());

    // REP(i,n){
    // 	cout<<v[i]<<" ";
    // }
    // cout<<endl;

    // cout<<min_v<<" "<<max_v<<endl;

    for(int i=min_v;i<=max_v;i++){

    	hoge=0;

    	REP(j,n){
    		hoge+=((v[j]-i)*(v[j]-i));
    	}

    	ans=min(ans,hoge);

    	// cout<<ans<<endl;
    }

    cout<<ans<<endl;



}

Measured memory_bytes: 256
from collections import Counter
n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
ans = float("inf")
for i in range(m):
    c = Counter([a[i][0] for i in range(n)])
    x, y = c.most_common()[0]
    ans = min(ans, y)
    for i in range(n):
        a[i].remove(x)
print(ans)

Measured memory_bytes: 10516
fn show_arr(arr: &Vec<i32>) {
    for i in 0..arr.len()-1 {
        print!("{} ", arr[i]);
    }
    print!("{}\n", arr.last().unwrap());
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    std::io::stdin().read_line(&mut buf).ok();
    let a: Vec<&str> = buf.trim().split_whitespace().collect();
    let mut an: Vec<i32> = Vec::new();
    
    for i in 1..a.len() {
        an.push(a[i].parse().unwrap());
    }
    
    show_arr(&an);
    
    for i in 1..a.len()-1 {
        let key = an[i];
        let mut j: usize = i-1;
        while an[j] > key {
            an[j+1] = an[j];
            an[j] = key;
            if j != 0 {
                j -= 1;
            } else {
                break;
            }
        }
        show_arr(&an);
    }
    
}


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

void max_heapify(int* A, int i, int H)
{
    int l = 2 * i, r = 2 * i + 1;
    if(l > H && r > H) return;
    int maxid = i, x;
    if(l <= H){ if(A[l] > A[maxid]) maxid = l; }
    if(r <= H){ if(A[r] > A[maxid]) maxid = r; }
    if(maxid == i) return;
    x = A[maxid]; A[maxid] = A[i]; A[i] = x;
    max_heapify(A, maxid, H);
}

int main()
{
    int A[2000001];
    int i, H, key;
    char cmd[8];
    scanf("%d", &H);
    for(i = 1; i <= H; i++) scanf("%d", &A[i]);
    H = 0;

    while(1){
        scanf("%s", cmd);  
        if(cmd[2] == 'd') break;  // end.
        if(cmd[2] == 't'){  // extract.
            if(H == 0) continue;
            printf("%d\n", A[1]);
            A[1] = A[H]; H--;
            if(H > 0) max_heapify(A, 1, H);
        }else{
            scanf("%d", &key); // H++;   // insert key.
            i = ++H;
            while(i > 1){
                if(A[i / 2] > key) break;
                A[i] = A[i / 2];
                i /= 2;
            };
            A[i] = key;
        }
    };
    return 0;
}

Measured memory_bytes: 6784
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-5-5 21:02:18
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

ll A[3];
int K;

int main()
{
  cin >> A[0] >> A[1] >> A[2];
  cin >> K;
  sort(A, A + 3);
  for (auto i = 0; i < K; i++)
  {
    A[2] *= 2;
  }
  cout << A[0] + A[1] + A[2] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>//stayCalmNeverSettle
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define szof(x) ((int)x.size())
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii; 
int const INF = (int)1e9+1e3;
ll const INFL = (ll)1e18+1e6;

const int N = 1e5+5; 

int main(){
	int x;
	cin >> x;
	if(x>=30){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

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

using namespace std;

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

  string ret="No";
  int m=stoi(to_string(a)+to_string(b));
  for(int i=0;i*i<=m;i++)
  {
    if(i*i==m)ret="Yes";
  }
  cout<< ret<< endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

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


int f(string s){
    int ret = 0;
    char c[20] = {"0123456789abcdef"};
    rep(i,s.size()){
        ret *= 16;
        rep(j,16)if(s[i] == c[j]){
            ret += j;
            break;
        }
    }
    return ret;
}

void print2(int a){
    string ret = "";
    while(a){
        ret = (a%2?"1":"0") + ret;
        a = a >> 1;
    }
    rep(i,12-ret.size())cout << " ";
    cout << ret << endl;
}

bool check(int a, int b, int i){
    int mask = 1LL << (i+1);
    mask--;
    if((a & mask) == (b & mask)) return true;
    return false;
}

signed main(void) {
    int i,j;
    int d;
    cin >> d;
    while(d--){
        vi in(9);
        rep(i,9){
            string s;
            cin >> s;
            in[i] = f(s);
        }
        ll ans = 0;
        rep(i,32){

            ll sum = 0;
            rep(j,8){
                sum += in[j] ^ ans;
            }
            if(!check(sum, in[8]^ans, i)){
                ans |= (1LL<<i);

            }
        }

        printf("%llx\n", ans);

    }
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define N 300010
const int mod=998244353;
int frac[N],ifrac[N];
void exgcd(int a,int b,int &x,int &y) {
	if(b==0) {
		x=1,y=0;
		return;
	}
	exgcd(b,a%b,y,x);
	y-=a/b*x;
}
int inv(int a) {
	int x,y;
	exgcd(a,mod, x, y);
	return (x+mod)%mod;
}
void pre(int n) {
	frac[0]=ifrac[0]=1;
	for(int i=1;i<=n;i++) frac[i]=(ll)i*frac[i-1]%mod;
	for(int i=1;i<=n;i++) ifrac[i]=inv(frac[i]);
}
int C(int a,int b) {
	return (ll)frac[a]*ifrac[b]%mod*ifrac[a-b]%mod;
}
int main() {
	int n,b,a;
	ll k;
	scanf("%d%d%d%lld",&n,&a,&b,&k);
	pre(n);
	int s=min(k/a,(ll)n),ans=0;
	for(int i=0;i<=s;i++) {
		ll last=k-(ll)i*a;
		if(last%b) continue;
		int j=last/b;
		if(j>n) continue;
		ans=(ans+(ll)C(n,i)*C(n,j))%mod;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 2560