akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] A = new int[26];
		for(int i=0;i<N;i++){
			A[P[i][0] - 'A']++;
		}
		
		int ans = 0;
		while(true){
			Array.Sort(A);
			Array.Reverse(A);
			int k=0;
//Console.WriteLine(String.Join(" ",A));
			for(int i=0;i<26;i++){
				if(A[i] == 0)continue;
				k++;
				A[i]--;
				if(k==K) break;
			}
			if(k==K){
				ans++;
				continue;
			}
			break;
		}
		
		Console.WriteLine(ans);
		
		
	}
	int N,K;
	String[] P;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
		P = new String[N];
		for(int i=0;i<N;i++)P[i] = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 3288
#include<iostream>
#include<queue>
#include<algorithm>

#define rep(i,n) for(int i = 0; i < n; ++i)
#define X first
#define Y second
#define MP(x,y) make_pair(x,y)
using namespace std;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int w,h;
int cell[32][32];
int ans;

bool check(int x, int y){
  return 0 <= x && x < w && 0 <= y && y < h;
}

void dfs(int n , int x, int y)
{
//  cout << "dfs :" << n << endl;
  if(n > 10){
    return;
  }
//  rep(i,h){
//    rep(j,w){
//      if(i == y && j == x){
//        cout << "o";
//      }else{
//        cout << cell[i][j];
//      }
//    }
//    cout <<endl;
//  }

  rep(i,4){
    int nx = x + dx[i];
    int ny = y + dy[i];

    if( check(nx, ny)){
      if( cell[ny][nx] != 1){
        int nnx = nx, nny = ny;
        while(check(nnx, nny)){
          if(cell[nny][nnx] == 1){
            break;
          }
          if(cell[nny][nnx] == 3){
  //          cout <<"ans!!!" << endl;
//            cout << nnx << " , " << nny << endl;
            ans = min(n, ans);
            return;
          }
          nnx += dx[i];
          nny += dy[i];
        }
        if(check(nnx, nny)){
          cell[nny][nnx] = 0;
          dfs(n+1, nnx-dx[i], nny-dy[i]);
          cell[nny][nnx] = 1;
        }
      }
    }
  }
}


int main(void){
  int x,y;
  
  while(cin >> w >> h, h){
    ans = 10000;
    rep(i,32)rep(j,32) cell[i][j] = 0;
    rep(i,h){
      rep(j,w){
        cin >> cell[i][j];
        if(cell[i][j] == 2){
          x = j;
          y = i;
        }
      }
    }
    dfs(1, x, y);
    if(ans == 10000)ans = -1;
    cout << ans << endl;
  }

}

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

int main() {
int N;
int ans=0;
cin>>N;
vector<int> a(N);
  for (int i =0;i<N;i++){
  cin>>a[i];
  }
sort(a.begin(),a.end());
reverse(a.begin(),a.end());
  for (int j=0;j<N;j++){
  if (j%2==0)
    {ans+=a[j];}
  else
    {ans-=a[j];}
  }
cout<<ans<<endl;
}

Measured memory_bytes: 3600
n=gets.to_i
n2=(n*(n+1))/2
xs=gets.split.map{|e| e.to_i}

sum=xs.reduce(0){|s,e|
	s+e
}
if sum%n2!=0 then
	puts "NO"
else
	ds=xs.rotate(1).zip(xs).map{|a|
		a[0]-a[1]
	}
	m=sum/n2
	ans=ds.all?{|e|
		m-e>=0 && (m-e)%n==0
	}
	if ans==false then
		puts "NO"
	else
		puts "YES"
	end
end

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

int dp[21][11][156];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n,k,s;
	while(cin >> n >> k >> s,n){
		vector<vector<vector<int> > > dp(n+1,vector<vector<int> >(k+1,vector<int>(s+1,0)));
		for(int i = 0;i < n;i++)dp[i][0][0] = 1;
		for(int i = 1;i <= n;i++){
			for(int j = 1;j <= k;j++){
				for(int l = 1;l <= s;l++){
					if(l < i)dp[i][j][l] = dp[i-1][j][l];
					else dp[i][j][l] = dp[i-1][j][l] + dp[i-1][j-1][l-i];
				}
			}
		}
		cout << dp[n][k][s] << endl;
	}
  return 0;
}

Measured memory_bytes: 3164
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            //6
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("10");
            //55
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1");
            //1
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int N = int.Parse(InputList[0]);

        Console.WriteLine(N * (N + 1) / 2);
    }
}


Measured memory_bytes: 2904
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		boolean isZero = false;
		for (int i = 0; i < n; i++) {
			long tmp = sc.nextLong();
			if (tmp == 0) {
				isZero = true;
				break;
			}
			a[i] = tmp;

		}
		sc.close();
		long ans = 1;
		long max = (long) Math.pow(10, 9);
		int count = 0;
		boolean isLarge = false;
		Arrays.sort(a);
		for (int i = n - 1; i >= 0; i--) {
			ans *= a[i];
			if (a[i] > max) {
				count++;
			}
			if (count == 2 || ans > max * max) {
				isLarge = true;
				break;
			}
		}
		if (isZero) {
			System.out.println(0);
		} else if (isLarge) {
			System.out.println(-1);
		} else {
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 61204
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<queue>
using namespace std;

static const int inf=1e9;
struct Node
{
    int data;
    Node *l,*r;
};
int m;
int total;

void add_point(Node *&p,int x)
{
    if(p==NULL)
    {
        p=(Node *)malloc(sizeof(Node));
        p->data=x;
        p->l=NULL;
        p->r=NULL;
        return;
    }
    if(x<p->data)
        add_point(p->l,x);
    else
        add_point(p->r,x);
}

void inorder(Node *p)
{
    if(p!=NULL)
    {
        inorder(p->l);
        printf(" %d",p->data);
        inorder(p->r);
    }
}

void preorder(Node *p)
{
    if(p!=NULL)
    {
        printf(" %d",p->data);
        preorder(p->l);
        preorder(p->r);
    }
}

int main()
{
    int i,x;
    char st[20];
    Node *tree=NULL;

    cin>>m;
    for(i=1;i<=m;i++)
    {
        scanf("%s",st);
        if(st[0]=='i')
        {
            scanf("%d\n",&x);
            add_point(tree,x);
        }else
        {
            inorder(tree);
            cout<<endl;
            preorder(tree);
            cout<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 18744
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl

bool sosuu(const int x)
{
	if (x == 2)return true;
	if (x < 2 || x % 2 == 0)return false;
	for (int i = 3; i * i <= x; i += 2)
		if (x % i == 0)return false;
	return true;
}
int gcd(int a, int b)
{
	if (a % b == 0) { return b; }
	else { return gcd(b, a % b); }
}
int ketawa(int a)
{
	if (a < 10)return a;
	else return a % 10 + ketawa(a / 10);
}

typedef long long ll;
using namespace std;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 0, b = 0, c, d, n, k = 0,ans=0;
string s, t;


int main()
{

	cin >> n >> s;
	char x=s[sz(s)-1];
	map<string, int> ans;
  ans[s]++;
	rep(i, n - 1)
	{
		cin >> t;
		if (t[0] != x)
		{
			cout << "No" << endl; return 0;
		}
		x = t[sz(t) - 1];
		ans[t]++;
	}
	for (auto iter=ans.begin();iter!=ans.end();iter++)
	{
		if (iter->second >= 2)
		{
			cout << "No" << endl; return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try {
	    while(true){
		double q = Double.valueOf(sc.readLine());
		if(q==-1)
		    break;
		double x = q/2.0;
		while(Math.abs(x*x*x-q) >= 0.00001*q){
		    x -= (x*x*x-q)/(3.0*x*x);
		}
		System.out.printf("%.6f\n",x);
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 12000
#include "bits/stdc++.h"
using namespace std;
#define LL long long

void solve() {
   int n,m;
   cin>>n>>m;
   if(n<10){
       cout<<(100*(10-n))+m;
       return ;
   }
   cout<<m<<"\n";
}
  
int main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();
 	return 0; 
}

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

typedef long long ll;
typedef vector<int> VI;
#define rep(i,n) for(int i=0;i<(n);++i)

//example rep(i,n) cin >> h[i];

int main (){

int s,n;
  cin>>s;
 
  cin>>n;

 if(s>=10||n>=10)cout<<"-1"<<endl;
  
  else{
  
  cout<<s*n<<endl;
  }
  //sort(vec.begin(),vec.end());
  //reverse(vec.begin(),vec.end());

  
 return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int n,a[22][22],dp[1<<22];

int main() {
    scanf("%d",&n);
    for(int i = 0;i<n;i++) for(int j = 0;j<n;j++) scanf("%d",&a[i][j]);
    dp[0] = 1;
    for(int i = 1;i<(1<<n);i++) {
        int cnt = __builtin_popcount(i) -  1;
        for(int j = 0;j<n;j++) 
            if(i & (1<<j) && a[cnt][j]) dp[i] = (dp[i] + dp[i ^ (1<<j)]) % mod;
    }
    printf("%d\n",dp[(1<<n) - 1]);
    return 0;
}

Measured memory_bytes: 10496
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
	char name[100];
	int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
	Q[tail]=x;
tail=(tail+1)%LEN;
}

P dequeue(){
	P x=Q[head];
	head=(head+1)%LEN;
	return x;
}

int min(int a,int b){
	return a<b?a:b;
}

int main(){
	int elaps = 0, c;
	int i, q;
	P u;
	scanf("%d %d", &n, &q);

	for ( i = 0; i < n; i++){
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}
	head=0;
	tail=n;
	while(head!=tail){
		u=dequeue();
		c=min(q,u.t);
		u.t-=c;
		elaps+=c;
		if(u.t>0)
			enqueue(u);
			else{
			printf("%s %d\n",u.name,elaps);
		}
	}
	return 0;
}


Measured memory_bytes: 11924
#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<int> a[26];
    string in ;
    cin>>in;
    for(int i=0;i<in.size();i++)
    {
        a[in[i]-'a'].push_back(i);
    }
    for(int i=0;i<26;i++)
    {
        if(!a[i].size()) continue;
        int now=1;
        int pos=a[i][0];
        for(int j=1;j<a[i].size();j++)
        {
            int pos2=a[i][j];
            if(pos2==pos+1 || pos2==pos+2)
            {
                cout<<pos+1<<" "<<pos2+1<<endl;
                return 0;
            }else 
            {
                pos=pos2;
            }
        }
    }
    cout<<-1<<" "<<-1<<endl;
    return 0;
}


Measured memory_bytes: 1144
/*Lower_Rating*/
/*dianfenzhi*/
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
#include<bitset>
#include<map>
using namespace std;

#define LL long long
#define DB double
#define Pr pair<int,int>
#define X first
#define Y second
#define MAXN 1000000
#define eps 1e-10
#define INF 2147483647
#define mem(x,p) memset(x,p,sizeof(x))

LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
  return x*F;
}

int T,n,ans,pans;char s[MAXN+5];
int a[MAXN+5],F;
int pabs(int x){
    return (x>0)?x:-x;
}
int main(){
        ans=0;
        n=read();scanf("%s",s+1);
        for(int i=1;i<=n;i++)
        a[i]=s[i]-'0'-1;
        for(int i=1;i<n;i++){
            if(pabs(a[i+1]-a[i])==2)
            pans^=(((n-2)&(n-i-1))==(n-i-1));
            if(pabs(a[i+1]-a[i])==1)
            F|=1,ans^=(((n-2)&(n-i-1))==(n-i-1));
        }
        if(F)printf("%d",ans);
        else printf("%d",pans*2);
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, n) for(long i = x; i < n; i++)
#define erep(i, x, n) for(long i = x; i <= n; i++)
#define all(a) a.begin(), a.end()
#define show(ans)  cout << ans << endl;
const long MOD = 1000000007;


int main() {string s; long N; long K;
cin >> s >> K;
N = s.size();
vector<string> str;
map<string, bool> mp;
erep(i, 1, K){
    erep(j, 0, N-i){
        if(mp[s.substr(j, i)] == false){
            str.push_back(s.substr(j, i));
            mp[s.substr(j, i)] = true;
        }
        
    }
}
sort(all(str));
show(str[K-1]);

  return 0;
 
}



Measured memory_bytes: 2688
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String[] str = lines[0].split(" ");
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);
        int c = Integer.parseInt(str[2]);
        
        if(a < b && b < c){
            System.out.println("Yes");
        } else System.out.println("No");
   }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
}


Measured memory_bytes: 26088
/* maybemaybemaybeno */
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double lld ;
#define f(i,s,n) for(int i=s;i<(int)n;i++) 
const int MAXN = 1e5+5 ;
#define pb push_back 
#define X first 
#define Y second 
#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define pli pair<ll,int> 
#define pil pair<int,ll> 
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(10) ;
#define is(x) cout<<#x<<" : "<<x<<endl ;
// #define DEBUG
vector<int> al[MAXN] ;
int h[MAXN] ;
bool visited[MAXN] ;
int ans=0 ;
void dfs(int node,int parent)
{
    if(visited[node]) return ;
    visited[node] = true ;
    bool good = true ;
    for(auto x:al[node])
    {
        if(h[x]>=h[node]) good = false ;
        dfs(x,node) ;
    }
    ans+=good ;
}

int main()
{
    fio ;
    /* ======================Start of code ================ */
    int n,m;cin>>n>>m ;
    f(i,0,n) cin>>h[i] ;
    f(i,0,m)
    {
        int a,b;cin>>a>>b;a--;b--;
        al[a].pb(b) ;
        al[b].pb(a) ;
    }
    // dfs(0,-1) ;
    f(i,0,n) dfs(i,-1) ;
    cout<<ans<<"\n" ;
    /* ======================End of code ================== */
}

Measured memory_bytes: 10924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll x,y; cin>>x>>y;
    if(x<y) swap(x,y);
    while(x%y!=0){
        x%=y;
        swap(x,y);
    }
    cout<<y<<endl;
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)

int main() {
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> ls(k);
    vector<int> rs(k);
    rep(i, k) {
        ls[i] = -1;
        rs[i] = n;
    }
    int x = 0;
    rep(i, n) {
        if (s[i] == 'o') {
            ls[x] = i;
            x++;
            i += c;
        }
        if (x == k) break;
    }
    x = 0;
    for (int i = n - 1; i >= 0; --i) {
        if (s[i] == 'o') {
            rs[k-1-x] = i;
            x++;
            i -= c;
        }
        if (x == k) break;
    }
    rep(i, k) if (ls[i] == rs[i]) cout << ls[i]+1 << endl;
    return 0;
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

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

    int n;
    cin >> n;
    set<int> a;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        a.insert(x);
    }

    if (a.size() == n) cout << "YES";
    else cout << "NO";








    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <numeric>
#include <string>

#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 a, b;
	cin >> a >> b;
	cout << a * b;
	return 0;
}

Measured memory_bytes: 3624
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
P = [INT() for _ in range(N)]

dp = [0] * (N+1)
for p in P:
	if dp[p-1]:
		dp[p] = dp[p-1] + 1
	else:
		dp[p] = 1
print(N-max(dp))


Measured memory_bytes: 21004
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  cout << (n-1)/2 << endl;
  return 0;
}


Measured memory_bytes: 764
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from collections import defaultdict

N, *A = map(int, read().split())

INF = 10**18
dp_not = defaultdict(lambda : -INF)
dp_take = defaultdict(lambda: -INF)
dp_not[(0,0)] = 0

for i,x in enumerate(A,1):
	j = (i-1)//2
	for n in (j,j+1):
		dp_not[(i,n)] = max(dp_not[(i-1,n)], dp_take[(i-1,n)])
		dp_take[(i,n)] = dp_not[(i-1,n-1)] + x

print(max(dp_not[(N, N//2)], dp_take[(N, N//2)]))

Measured memory_bytes: 208872
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;
int main(){
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
   ll r , D , x;
   cin >> r >> D >> x;
   for(int i = 1 ;i <= 10 ; i++){
       x = r*x-D;
       cout << x << endl;
   }
   return 0;
}

Measured memory_bytes: 256
# from https://twitter.com/wakuwinmail_C/status/950277218411855872

N, Y = gets.split.map(&:to_i)
x = y = 0
z = Y / 1000

if z < N
  x = y = z = -1
else
  y = [(z - N) / 4, z / 5].min
  z -= y * 5

  x = y + z - N
  y -= x * 2

  if y < 0
    x = y = z = -1
  end
end

puts "#{x} #{y} #{z}"


Measured memory_bytes: 1916
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

static const LL MOD = 1000000007;
static const size_t MAX_N = 100030;

struct modll {
	long long x;
	modll() { }
	modll(long long _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(const modll& r) { return (x + r.x) % MOD; }
	modll operator+=(const modll & r) { return x = (x + r.x) % MOD; }
	modll operator-(const modll & r) { return (x + MOD - r.x) % MOD; }
	modll operator-=(const modll & r) { return x = (x + MOD - r.x) % MOD; }
	modll operator*(const modll & r) { return (x * r.x) % MOD; }
	modll operator*(int r) { return (x * r) % MOD; }
	modll operator*=(const modll & r) { return x = (x * r.x) % MOD; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

modll combination(LL n, LL r) {
	static modll fact[MAX_N + 1], inv[MAX_N + 1];
	if (!fact[0]) {
		fact[0] = 1;
		for (int i = 1; i <= MAX_N; ++i) {
			fact[i] = fact[i - 1] * i;
		}
		inv[MAX_N] = modll::modinv(fact[MAX_N]);
		for (int i = MAX_N; i >= 1; --i) {
			inv[i - 1] = inv[i] * i;
		}
	}
	if (r > n) {
		return 0;
	}
	return (fact[n] * inv[r])* inv[n - r];
}

int main(int argc, char *argv[]) {
	LL n, k;
	cin >> n >> k;
	for (LL i = 1; i <= k; ++i) {
		modll a = combination(n - k + 1, i);
		a *= combination(k - 1, i - 1);
		cout << a << endl;
	}
	return 0;
}	


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
MOD = 998244353 
INF = 10**10

m, d = [int(item) for item in input().split()]
ans = 0
for i in range(1, m+1):
    for j in range(1, d+1):
        a = j // 10
        b = j % 10
        if a >= 2 and b >= 2 and i == a * b:
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; cin >> N;
  map<int, int> m;
  for (int i = 1; i < N; ++i) {
    int a; cin >> a;
    m[a]++;
  }

  for (int i = 1; i <=N; ++i) {
    cout << m[i] << endl;
  }
}


Measured memory_bytes: 12984
require "matrix"

N = gets.to_i
V = []
N.times{
  V << gets.chomp.split(" ").map(&:to_i)
}

def get_center_radius(a, b, c)
  k = Matrix[[a[0] - b[0], a[1] - b[1]], [b[0] - c[0], b[1] - c[1]]]
  d = Matrix[[a[0]**2 - b[0]**2 + a[1]**2 - b[1]**2], [b[0]**2 - c[0]**2 + b[1]**2 - c[1]**2]]
  if k.determinant == 0 then
    [[0, 0], 0]
  else
    c = (k.inverse * d) / 2
    r = c - Matrix[[a[0]], [a[1]]]
    r2 = (r.transpose * r).to_a
    wk = c.to_a
    [[wk[0][0], wk[1][0]], r2[0][0]]
  end
end

radius_squared_max = 0
center = []
V.combination(2){|a, b|
  tmp = ((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) / 4.0
  if radius_squared_max < tmp then
    radius_squared_max = tmp
    center = [(a[0]+b[0])/2.0, (a[1]+b[1])/2.0]
  end
}
if V.all?{|a, b| (a - center[0])**2 + (b - center[1])**2 <= radius_squared_max} then
  puts Math.sqrt(radius_squared_max)
else
  radius3 = 0
  V.combination(3){|a, b, c|
    cent, rad = get_center_radius(a, b, c)
    next if rad <= radius_squared_max
    next if radius3 != 0 && radius3 <= rad
    next if V.any?{|a, b| (a - cent[0])**2 + (b - cent[1])**2 > rad}
    radius3 = rad
  }
  puts Math.sqrt(radius3)
end


Measured memory_bytes: 2684
#include<stdio.h>
#include<stdlib.h>
typedef struct{
  int parent;
  int left_child;
  int next_sibling;
  int child;
}node;
int depth(int);
node *T;
int count;
int main(){
  char c;
  int n, x, y, z, a, i, j;
  scanf("%d",&n);
  T = (node *)malloc(sizeof(node) * n);
  for(i=0; i<n; i++) T[i].parent = -1;
  for(i=0; i<n; i++){
    scanf("%d",&x);
    scanf("%d",&z);
    T[x].child = z;
    for(j=0; j<z; j++){
      if(j == 0){
	scanf("%d",&y);
	T[y].parent = x;
	T[x].left_child = y;
      }
      else{
	scanf("%d",&T[y].next_sibling);
	T[y].parent = x;
	T[T[y].next_sibling].parent = x;
	y = T[y].next_sibling;
      }
    }
  }
  for(i=0; i<n; i++){
    count=0;
    printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,depth(i));
    if(T[i].parent == -1) printf("root, [");
    else if(T[i].child == 0) printf("leaf, [");
    else printf("internal node, [");
    for(j=0; j<T[i].child; j++){
      if(j == 0){
	printf("%d",T[i].left_child);
	x = T[T[i].left_child].next_sibling;
      }
      else{
	printf("%d",x);
	x = T[x].next_sibling;
      }
      if(j != T[i].child - 1) printf(", ");
    }
    printf("]\n");
  }
  free(T);
  return 0;
}

int depth(int x){
  if(T[x].parent == -1) return count;
  else{
    count++;
    depth(T[x].parent);
  }
  return count;
}

Measured memory_bytes: 1944
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF 100000000000
#define N 200000
#define ll long long
using namespace std;

int main(){
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}

Measured memory_bytes: 3644
#include<iostream>

int main()
{
    int r, c, i, j, data[100][100], csum[100], rsum[100], sum=0;

    for (i = 0; i < 100; i++) {
        csum[i] = 0;
        rsum[i] = 0;
    }
        
    std::cin >> r >> c;

    for (i = 0; i < r; i++)
        for (j = 0; j < c; j++) {
            std::cin >> data[i][j];
            sum += data[i][j];
        }

    for (i = 0; i < r; i++)
        for (j = 0; j < c; j++) {
            rsum[i] += data[i][j];
        }

    for (j = 0; j < c; j++)
        for (i = 0; i < r; i++) {
            csum[j] += data[i][j];
        }

    for (i = 0; i < r; i++) {
        for (j = 0; j < c; j++) {
            std::cout << data[i][j] << " ";
        }
        std::cout << rsum[i] << std::endl;
    }

    for (j = 0; j < c; j++) {
        std::cout << csum[j] << " ";
    }

    std::cout << sum << std::endl;
   
    return 0;
}


Measured memory_bytes: 3104
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main implements Runnable {
	public static void main(String[] args) {
		new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		// int n = sc.nextInt();
		// int q = sc.nextInt();
		// int[] w = new int[n];
		// for (int i = 0; i < n; ++i) {
		// w[i] = sc.nextInt();
		// }
		// HLDecomposition hl = new HLDecomposition(n);
		// ArrayList<Integer>[] g = new ArrayList[n];
		// for (int i = 0; i < n; ++i) {
		// int s = sc.nextInt() - 1;
		// int e = sc.nextInt() - 1;
		// hl.ae(s, e);
		// }
		// hl.pre();
		int n = sc.nextInt();
		HLDecomposition hl = new HLDecomposition(n);
		for (int i = 0; i < n; ++i) {
			int k = sc.nextInt();
			for (int j = 0; j < k; ++j) {
				int c = sc.nextInt();
				hl.ae(i, c);
			}
		}
		hl.pre();
		int q = sc.nextInt();
		for (int i = 0; i < q; ++i) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			pw.println(hl.lca(u, v));
		}
		pw.close();
	}

	class HLDecomposition {
		int n;
		int[] depth;
		int[] head;
		int[] heavy;
		int[] parent;
		int[] sz;// ??¨?????¨?????§??????
		ArrayList<Integer>[] g;
		int[] id;

		@SuppressWarnings("unchecked")
		public HLDecomposition(int n) {
			this.n = n;
			depth = new int[n];
			head = new int[n];
			heavy = new int[n];
			parent = new int[n];
			id = new int[n];
			sz = new int[n];
			g = new ArrayList[n];
			for (int i = 0; i < n; ++i) {
				g[i] = new ArrayList<>();
			}
			Arrays.fill(head, -1);
			Arrays.fill(id, -1);
			Arrays.fill(parent, -1);
		}

		void ae(int a, int b) {
			g[a].add(b);
			g[b].add(a);
		}

		void pre() {
			dfs(0, -1);
			bfs();
		}

		void bfs() {
			ArrayDeque<Integer> pend = new ArrayDeque<>();
			int gen = 0;
			pend.add(0);
			while (!pend.isEmpty()) {
				int v = pend.pollFirst();
				int top = v;
				for (; v != -1; v = heavy[v]) {
					id[v] = gen++;
					head[v] = top;
					for (int d : g[v]) {
						if (d == parent[v] || d == heavy[v]) {
							continue;
						}
						pend.add(d);
					}
				}
			}
		}

		int lca(int u, int v) {
			if (head[u] != head[v]) {
				if (depth[head[u]] < depth[head[v]]) {
					int tmp = u;
					u = v;
					v = tmp;
				}
				return lca(parent[head[u]], v);
			} else {
				if (depth[u] > depth[v]) {
					int tmp = u;
					u = v;
					v = tmp;
				}
				return u;
			}
		}

		int dfs(int c, int p) {
			parent[c] = p;
			int s = 1;
			int to = -1;
			for (int d : g[c]) {
				if (d == p)
					continue;
				depth[d] = depth[c] + 1;
				s += dfs(d, c);
				if (to == -1 || sz[d] > sz[to]) {
					to = d;
				}
			}
			sz[c] = s;
			heavy[c] = to;
			return s;
		}

	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

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

#define mod 1'000'000'007
typedef long long ll;

template<typename T>
void deb(initializer_list<T> l)
{
	for (auto &e : l)
		cout << e << ' ';
	cout << endl;
}

void solve()
{
	int n;
	map<string, int> m;
	cin >> n;
	while (n--)
	{
		string s;
		cin >> s;
		m[s]++;
	}

	vector<string> a{"AC", "WA", "TLE", "RE"};
	for (auto&e : a)
		cout << e << " x " << m[e] << '\n';
}

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

	int t = 1;
	// cin >> t;
	while (t--)
		solve();

	return 0;
}


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

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

    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N - 1);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < N - 1; i++) {
        cin >> C[i];
    }
    int ans = 0;
    int before = A[0];
    for (int i = 0; i < N; i++) {
        ans += B[A[i] - 1];
        if (before + 1 == A[i]) {
            ans += C[before - 1];
        }
        before = A[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
int main(void)
{
    sync;
    int n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;++i)
        if(i%3!=0&&i%5!=0)
            sum+=i;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3224
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>
#include <queue>
#include <iomanip>

#define BIG 1000000007
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)
#define long long long

using namespace std;

int main(){
    long n,x;
    cin >> n >> x;
    long l = 0;
    for(int i = 0;i < n;++i){
        long k;
        cin >> k;
        l += k;
        if(l > x){
            cout << i + 1 << endl;
            return 0;
        }
    }

    cout << n + 1 << endl;
}




Measured memory_bytes: 888
#include<iostream>
using namespace std;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
int h, w, ans, vis[105][105];
char G[105][105];
void dfs(int x, int y, char c)
{
    vis[x][y] = 1;
    for(int i = 0; i < 4; i++)
        if(!vis[x + dx[i]][y + dy[i]] && G[x + dx[i]][y + dy[i]] == c) dfs(x + dx[i], y + dy[i], c);
    return;
}
int main()
{
    while(true)
    {
        cin >> h >> w;
        if(h == 0 && w == 0) return 0;
        ans = 0;
        for(int i = 0; i < 105; i++)
            for(int j = 0; j < 105; j++)
            {
                G[i][j] = '.';
                vis[i][j] = 0;
            }
        for(int i = 1; i <= h; i++)
            for(int j = 1; j <= w; j++)
                cin >> G[i][j];
        for(int i = 1; i <= h; i++)
            for(int j = 1; j <= w; j++)
                if(!vis[i][j])
                {
                    dfs(i, j, G[i][j]);
                    ans++;
                }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3508
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll; //long longをllとして簡略

int main(){
  ll n,k;
  ll ans=0;
  cin >> n >> k;// monster_no,deathblow_no
  vector <ll> h(n); //monster hp
  rep(i,n){
    cin >> h[i];
  }
  sort(h.rbegin(), h.rend());
  rep(i,k){
    h[i] = 0;
    if(n==i){
      cout << ans << endl;
      return 0;
      }
  }
  rep(i,n){
    ans += h[i];
  }
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a * b >= d * c)
        cout << a * b << endl;
    else
        cout << d * c << endl;

    return 0;
}


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

const int mod=1e9+7;
int dp[105][100005];

#undef int
int main() {
#define int long long
    int n,k;
    cin >> n >> k;

    int a[n];

    for(int i=1;i<=n;i++)
        cin >> a[i];

    for(int i=0;i<=k;i++)
    {
        if(i<=a[1])
            dp[1][i]=1;
        else
            dp[1][i]=0;
    }

    for(int i=1;i<=n;i++)
    {
        dp[i][0]=1;
    }

    
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(j>a[i])
                dp[i][j]=((dp[i-1][j]-dp[i-1][j-a[i]-1]+mod)%mod + dp[i][j-1]%mod)%mod;
            else
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
        }
    }
    
    cout << dp[n][k] << endl;
}

Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;cin>>x;
    for(int i=-1010;i<1010;i++){
      ll s=pow(i,5);
      for(int j=-1010;j<1010;j++){
      ll t=pow(j,5);
      if(s-t==x){
        cout<<i<<' '<<j<<endl;
        return 0;
      }
      }
    }
    return 0;
}


Measured memory_bytes: 4044
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten53 300005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


int main(void)
{
    ll m,n,i,j,k=1,d,sum=0;
    string s;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        k*=i;
        k%=mod;
    }
    cout<<k;
}


Measured memory_bytes: 3584
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<string>
using namespace std;

int main(){
    int a;
    cin>>a;
    if(a%2==0){
        cout<<a<<endl;
    }
    else{
        a=a*2;
        cout<<a<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a,b;
  cin >>a >>b;
  if(a =='H'){
    if(b =='H'){
      cout << 'H' <<endl;
    }
    else if(b=='D'){
      cout <<'D' <<endl;
    }
  }
  if(a =='D'){
    if(b =='H'){
      cout << 'D' <<endl;
    }
    else if(b=='D'){
      cout <<'H' <<endl;
    }
  }
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int n;
        ArrayList<Long> aa = new ArrayList<Long>();
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        BigInteger min = BigInteger.valueOf(1L);
        final BigInteger max = BigInteger.valueOf(1_000_000_000_000_000_000L);
        for(int i=0; i<n; i++) {
            aa.add(sc.nextLong());
            if(aa.get(i)==0L) {
                System.out.println("0");
                return ;
            }
        }
        for(long a : aa) {
            min = min.multiply(BigInteger.valueOf(a));
            if(min.compareTo(max) > 0) {
                System.out.println("-1");
                return ;
            }
        }
            System.out.println(min);
        sc.close();
        
    }
}


Measured memory_bytes: 61224
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;

const int C = 100010;
const ll infty = 100010100010100010;
pair<int, ll> P[C]; // root, diff: w_self - w_root

void init(int N) {
  for (auto i=0; i<N; i++) {
    P[i] = make_pair(i, 0);
  }
}

pair<int, ll> root(int a) {
  if (P[a].first == a) return P[a];
  pair<int, ll> t = root(P[a].first);
  return (P[a] = make_pair(t.first, t.second + P[a].second));
}

ll diff(int a, int b) { // a, bが同じ根を持つならw_b-w_aを、そうでないならinftyを返す。
  if (root(a).first == root(b).first) {
    return root(b).second - root(a).second;
  }
  return infty;
}

void weight(int a, int b, int w) { // w_b - w_aの値を登録する
  pair<int, ll> ta = root(a);
  pair<int, ll> tb = root(b);
  P[root(b).first] = make_pair(ta.first, -tb.second + w + ta.second);
}

int main() {
  int n, m;
  while (cin >> n >> m && n) {
    init(n);
    for (auto i=0; i<m; i++) {
      char c;
      int a, b, w;
      cin >> c;
      if (c == '!') {
        cin >> a >> b >> w;
        a--; b--;
        weight(a, b, w);
      } else {
        cin >> a >> b;
        a--; b--;
        ll d = diff(a, b);
        if (d < infty) {
          cout << d << endl;
        } else {
          cout << "UNKNOWN" << endl;
        }
      }
    }
  }
}

Measured memory_bytes: 8968
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  int sum = 0;
  for (int i = 0; i < N ; i++){
    int l_i, r_i;
    cin >> l_i >> r_i;
    sum += r_i - l_i + 1;
  }
  cout << sum << endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n, d;
    cin >> n >> d;
    int count = 0;
    while(n--){
		long long x, y;
		cin >> x >> y;
		if (x * x + y * y <= d * d){
			count++;
			}
		}
	cout << count << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i=a;i<=b;i++)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
int main()
{	
	ios_base:: sync_with_stdio(0);
	cin.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int a1,a2,a3,sum;
	cin>>a1>>a2>>a3;
	sum=a1+a2+a3;
	if(sum>=22) cout<<"bust";
	else cout<<"win";
	}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int a[106];
int n,sum=0,ans=0;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
sum+=a[i];
}
double n1=1.0*sum/n;
int av;
if(n1>=0)
av=(int)(n1+0.5);
else
av=(int)(n1-0.5);
for(int i=1;i<=n;i++)
{
	ans+=(a[i]-av)*(a[i]-av);
}
//cout<<sum<<" "<<n1<<" "<<av<<endl;
cout<<ans<<endl;
}


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

int main() {
  long a,b;
  cin >> a >> b;
  vector<string> ans(100,"");
  for(long i=0;i<100;i++) ans[0]+=".";
  for(long i=0;i<100;i++) ans[99]+="#";
  for(long i=1;i<99;i++) {
    ans[i]=".";
    for(long j=0;j<49;j++) {
      ans[i]+="#";
    }
    for(long j=0;j<49;j++) {
      ans[i]+=".";
    }
    ans[i]+="#";
  }
  a--,b--;
  for(long i=1;b!=0;i+=2) {
    for(long j=1;b!=0&&j!=45;j+=2) {
      ans[i][j+1]='.';
      ans[i+1][j]='.';
      ans[i+1][j+1]='.';
      b--;
    }
  }
  for(long i=98;a!=0;i-=2) {
    for(long j=98;a!=0&&j!=54;j-=2) {
      ans[i][j-1]='#';
      ans[i-1][j]='#';
      ans[i-1][j-1]='#';
      a--;
    }
  }
  cout << "100 100" << endl;
  for(long i=0;i<100;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int a, b;
    cin >> a >> b;
    if (a < 13 and a > 5) {
        b /= 2;
    } else if (a <= 5) {
        b = 0;
    }
    cout << b << endl;
}

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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main() {
  int n;
  int tmp;
  cin >> n;
  vector<int> vec(n);
  vector<int> vec2(n);
  rep(i,n){
    cin >> tmp;
    vec[i]=tmp;
    vec2[i]=tmp;
  }
  sort(vec.begin(),vec.end());
  rep(i,n){
    auto itr=upper_bound(vec.begin(),vec.end(),vec2[i]);
    if (itr!=vec.end()) cout << vec[n-1] << endl;
    else cout << vec[n-2] << endl;
  }
  return 0;
}


Measured memory_bytes: 3200
n, m = (int(i) for i in input().split())
a = [list(map(int,input().split())) for i in range(n)]
b = sorted(a)
cnt = 0
money = 0
while True:
	for x,y in b:
		cnt += y
		money += x * y
		if m < cnt:
			money -= (cnt - m)*x
			print(money)
			exit()


Measured memory_bytes: 28648
#include<iostream>
#include<cstdio>
#include<deque>
#include<algorithm>
using namespace std;
int main(){

	long long sum = 0LL, osum = 0LL;
	long long f1, f2, f3, cnt, w, h, L, HL,temp, oxy[2][2], *LXY[2], ox, oy, max = 0;
	deque<long long> XY[2];
	//freopen("18-02.in","r",stdin);
	scanf("%lld %lld",&w, &h);
	scanf("%lld",&L);
	for(f1 = 0; f1 < 2; f1++)
		LXY[f1] = new long long [L];
	//100k
	for(f1 = 0; f1 < L; f1++){
		scanf("%lld %lld",&LXY[0][f1], &LXY[1][f1]);
		XY[0].push_back(LXY[0][f1]);
		XY[1].push_back(LXY[1][f1]);
	}
	//1m
	sort( XY[0].begin(), XY[0].end() );
	sort( XY[1].begin(), XY[1].end() );
	HL = (L + 1) / 2;
	//x軸での最小値の点、y軸での最小値の点を探す
	//200k
	if(L == 1){
		printf("0\n");
		printf("%lld %lld\n",LXY[0][0],LXY[1][0]);
	}
	else{
		for(f1 = 0; f1 < 2; f1++){
			cnt = 0;
			temp = XY[f1][cnt];
			cnt++;
			while(cnt < HL){
				while(cnt < L && temp == XY[f1][cnt])
					cnt++;
				if(cnt < HL){
					temp = XY[f1][cnt];
					//cnt++;
				}
			}
			oxy[0][f1] = XY[f1][cnt-1];
			oxy[1][f1] = XY[f1][cnt];
		}
		//400k
		for(f2 = 0; f2 < 2; f2++){
			for(f3 = 0; f3 < 2; f3++){
				sum = 0LL;
				max = 0LL;
				//printf(" %lld %lld\n",oxy[f2][0],oxy[f3][1]);
				for(f1 = 0; f1 < L; f1++){
					temp = (long long)abs(LXY[0][f1] - oxy[f2][0]) + abs(LXY[1][f1] - oxy[f3][1]);
					sum += temp * 2;
					if(sum < 0)
						break;
					if(max == 0 || max < temp)
						max = temp;
				}
				sum -= max;
				//printf("%lld\n\n",sum);
				if(sum > 0 && (osum == 0 || osum > sum || osum == sum && ox >= oxy[f2][0] && oy > oxy[f3][1])){
					osum = sum;
					ox = oxy[f2][0];
					oy = oxy[f3][1];
				}
			}
		}
		printf("%lld\n", osum);
		printf("%lld %lld\n", ox, oy);
	}
	return 0;
}

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

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  
  int N,M;
  cin >> N >> M;
  
  VI c(N);
  REP(i,M){
    int a,b;
    cin >>a>>b;
    c.at(a-1)++,c.at(b-1)++;
  }
  REP(i,N){
    cout << c.at(i) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256