akhauriyash/Code-Regression huggingface dataset:
def add(x, y):
  ans = x + y
  return ans

def mux(x,y):
  ans = x * y
  return ans

n = int(input())
k = int(input())

ans = 1
min_ans = 1
cnt = 0

for i in range(n):
  min_ans = add(min_ans,k)


for i in range(n):
  ans = 1
  for j in range(n):
    if cnt < j:
      ans = add(ans, k)
    else:
      ans = mux(ans,2)
    
    #print(ans)

  if min_ans > ans:
    min_ans = ans
    
  cnt +=1
  
print(min_ans)

Measured memory_bytes: 3064
n = int(input())
A = list(map(int,input().split()))
A = sorted([(a,i) for i,a in enumerate(A)],reverse=True)
dp=[[0]*(n+1) for i in range(n+1)]

# i+j=n
for i in range(n):
    for j in range(n-i):
        a,k=A[i+j]
        dp[i+1][j]=max(dp[i+1][j], dp[i][j]+abs(k-i)*a)
        dp[i][j+1]=max(dp[i][j+1], dp[i][j]+abs((n-j-1)-k)*a)

ans=0
for i in range(n+1):
    ans=max(ans,max(dp[i]))
print(ans)

Measured memory_bytes: 100776
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
using namespace std;
int main(){
  string s;
  cin>>s;
  int b=-1,e;
  rep(i,s.size()){
    if (s[i]=='A' and b==-1) b=i;
    if (s[i]=='Z') e=i;
  }
  cout<<(e-b+1)<<endl;
  return 0;
}


Measured memory_bytes: 640
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let mut antenas: Vec<i32> = Vec::new();

    for _ in 0..5{
        antenas.push(read_as_vec()[0]);
    }

    let k: i32 = read_as_vec()[0];
    
    for i in 0..5{
        for j in i+1..5{
            if antenas[i] + k < antenas[j]{
                println!(":(");
                return;
            }
        }
    }
    println!("Yay!");
}


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

using namespace std;
#define EPS (1e-10)
#define ABS(x) ((x) < 0?-(x):(x))

int main(){
    double xa, ya, xb, yb, xc, yc, xd, yd;
    while(cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd){
	if(ABS((xa - xb) * (xc - xd) + (ya - yb) * (yc- yd)) < EPS)cout << "YES" <<endl;
	else
	    cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
from math import atan2
def dist(x,y):
    return (x**2+y**2)**(1/2)
n = int(input())
data = []
for i in range(n):
    x,y = map(int,input().split())
    data.append([atan2(y,x),x,y])

data.sort()
data = data + data

ans = 0
for i in range(n):
    for j in range(i+1,n+i+1):
        x, y = 0, 0
        for k in range(i,j):
            x += data[k][1]
            y += data[k][2]
        ans = max(ans,dist(x,y))

print(ans)

Measured memory_bytes: 40812
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
int H1, M1, H2, M2, K, ans=0; cin >> H1 >> M1 >> H2 >> M2 >> K;
ans=60*(H2-H1)+M2-M1-K;
cout << ans << "\n";
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <fstream>
#define endl "\n"
#define ll long long
#define countBit1(x) __builtin_popcountll(x)
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    char s;
    cin >> s;
    cout << (s >= 'a' && s <= 'z' ? 'a' : 'A');
    return 0;
}

Measured memory_bytes: 3620
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		int[] kakaku = { 1, 2, 3, 4, 5 };
		FScanner sc = new FScanner();
		int X = sc.nextInt();
		int u2 = X % 100;
		int S = X / 100;
		int sum = 0;
		for (int i = 0; i < S; i++) {
			if (sum == u2) {
				System.out.println("1");
				return;
			}
			for (int j = kakaku.length - 1; j >= 0; j--) {
				if (u2 - sum >= kakaku[j]) {
					sum += kakaku[j];
					break;
				}
			}
			if (sum == u2) {
				System.out.println("1");
				return;
			}
		}
		System.out.println("0");
	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 21204
#include<iostream>
#include<cmath>
using namespace std;
int main() {
	int a,b;cin>>a>>b;
	for (int i=0; i<=10000; i++) {
        if ( floor(i*0.08)==a && floor(i*0.1)==b ) {
            cout << i << endl;
            return 0;
        }
    }
	cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

long long num[55];

int main()
{
    long long k;
    while(scanf("%lld",&k)==1)
    {
        printf("50\n");
        for(int i=0;i<50;i++)num[i]=49;

        long long p=k%50;
        long long q=k/50;

        for(int i=0;i<50;i++)
        {
            num[i]+=q;
        }

        for(int i=0;i<p;i++)
        {
            num[i]+=50;
            for(int j=0;j<50;j++)
            {
                if(i!=j)num[j]--;
            }
        }

        for(int i=0;i<50;i++)
        {
            if(i!=50-1)printf("%lld ",num[i]);
            else printf("%lld\n",num[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(){
	int a,b,y,X,Y,cnt;
    cnt = 0;
    if(scanf("%d%d",&X,&Y) == -1){
    	return 0;
    }
    for(a = 0;a <= X;a++){
        y = 2*a + 4*(X - a);
        if(y == Y){
        	cnt++;
        }
	}
    
    if(cnt == 0){
    	printf("No\n");
    }else{
    	printf("Yes\n");
    }
    
    return 0;
}

Measured memory_bytes: 1620
#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.at(i);
  }
  int max = 0;
  int sum = 0;
  for(int i=0; i<K; i++){
    sum += p.at(i);
  }
  max = sum;
  for(int i=0; i<N-K; i++){
    sum = sum + p.at(i+K) - p.at(i);
    if(sum > max) max = sum;
  }
  cout << fixed << setprecision(10) << 0.5*(max+K) << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<numeric>
#include<algorithm>
#include<tuple>

typedef unsigned long long ll;

ll DENOM = 1000000000LL + 7LL;

ll mypow(int n){
    ll ret = 1LL;
    for(auto i=0; i<n;++i){
        ret *= 2LL;
        ret %= DENOM;
    }
    return ret;
}

using namespace std;
int main(){
    ll n;
    cin >> n;
    vector<int> zs(61,0);
    for(auto i=0; i<n; ++i){
        ll ain;
        cin >> ain;
        int j=0;
        while(ain >0){
            auto tmp = ain % 2LL;
            zs[j++] += tmp;
            ain /= 2LL;
        }
    }
    ll ret = 0;
    for(auto i=0; i<61; ++i){
        ll x = mypow(i);
        ll y = (zs[i]*(n-zs[i])) % DENOM;
        x = (x * y) % DENOM;
        ret += x;
    }
    cout << ret % DENOM << endl;
    return 0;
}

Measured memory_bytes: 632
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;


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

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

int main() {
  #define int long long
  int d, g;
  cin >> d >> g;
  const int INF = 100000000;
  vector<int> p(d);
  vector<int> c(d);
  for (int i = 0; i < d; i++) {
    cin >> p.at(i) >> c.at(i);
  }
  int res = INF;
 
  for (int bit = 0; bit < (1<<d); bit++) {
    int g2 = g;
    int cnt = 0;
    for (int i = 0; i < d; i++) {
      if (bit & (1<<i)) {
        cnt += p.at(i);
        g2 -= c.at(i) + 100 * (i + 1) * p.at(i);
      }
    }
    if (g2 <= 0) {
      res = min(res, cnt);
    }
    else {
      for (int i = d - 1; i >= 0 && g2 > 0; i--) {
        
        if (!(bit & (1<<i))) {
          cnt += min(g2 / (100 * (i + 1)), p.at(i));
          g2 -= 100 * (i + 1) * min(g2 / (100 * (i + 1)), p.at(i));
        }
      }
      res = min(res, cnt);
    }
  }
  cout << res << endl;
}




Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()

val1 = pow(10,N,mod)
val2 = pow(9,N,mod)
val3 = pow(8,N,mod)

print((val1-2*val2+val3)%mod)

Measured memory_bytes: 65536
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
	int a[6];
	for (int i = 0; i < 6; i++){
		scanf("%d", &a[i]);
	}
	sort(a, a+4);
	
	int total = a[1]+a[2]+a[3]+max(a[4], a[5]);
	printf("%d\n", total);
	return 0;
} 

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for (int i=a; i<(b);++i)
const int INF = 1e9;

string grid[1010];
int dist[1010][1010];

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

int main(){
    cin >> H >> W;
    REP(i,H) cin >> grid[i];
    queue<pair<int,int> > q;
    REP(i,H) REP(j,W) dist[i][j] = INF;
    REP(i,H){
        REP(j,W){
            if(grid[i][j] == '#'){
                q.push(make_pair(i,j));
                dist[i][j] = 0;
            }
        }
    }

    int ans = 0;
    while(!q.empty()){
        int x = q.front().second;
        int y = q.front().first;
        q.pop();
        REP(i,4){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx >= 0 && nx < W && ny >= 0 && ny < H && dist[ny][nx]==INF){
                q.push(make_pair(ny,nx));
                dist[ny][nx] = min(dist[ny][nx],dist[y][x] + 1);
            }
        }
    }
    REP(i,H) REP(j,W) ans = max(ans, dist[i][j]);
    cout << ans << endl;
}

Measured memory_bytes: 13456
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll i,n,m,t;
vector<ll> nod[100005];
bool viz[100005];
void dfs(ll x){
    viz[x]=1;
    for(unsigned int j=0;j<nod[x].size();j++){
        ll u=nod[x][j];
        //cout<<u;
        if(viz[u]==0){
            dfs(u);

        }//cout<<"x";
    }
}
int32_t main(){
    cin>>n>>m;
    for(i=1;i<=m;i++){
        ll x,y;
        cin>>x>>y;
        nod[x].pb(y);
        nod[y].pb(x);
    }
    ll ans=0;
    for(i=1;i<=n;i++){
        if(viz[i]==0){
            ans++;
            dfs(i);
        }
    }
    cout<<ans-1;
    return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    cout << 6 - (a+b) << endl;
}

Measured memory_bytes: 384
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = I()
    f = LIR(n)
    po = [1]*11
    for i in range(n):
        k = 0
        p = 1
        for j in range(10):
            k += p*f[i][j]
            p *= 2
            po[j+1] = p
        f[i] = k
    p = LIR(n)
    ans = -float("inf")
    for i in range(1,1024):
        k = 0
        for j in range(n):
            c = i&f[j]
            s = 0
            for l in po:
                if c&l:s += 1
            k += p[j][s]
        ans = max(ans,k)
    print(ans)
#D
def D():
    n,C = LI()
    T = [[0 for i in range(200002)] for j in range(C)]
    for i in range(n):
        s,t,c = LI()
        c -= 1
        T[c][2*s] += 1
        T[c][2*t+1] -= 1
    for c in range(C):
        for i in range(200000):
            T[c][i+1] += T[c][i]
    ans = 0
    for i in range(200000):
        k = 0
        for c in range(C):
            if T[c][i]:k += 1
        ans = max(ans, k)
    print(ans)
#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

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


Measured memory_bytes: 40560
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>

#define INF 1000000000000000000
using namespace std;
typedef long long ll;

struct Edge {
	int s;
	int t;
	ll d;
};

int main() {
	ll n, m;
	Edge e[2010];
	ll cost[1010];
	bool aug[1010] = {};
	cin >> n >> m;

	for (int i = 0; i <= n ; i++) {
		cost[i] = -INF;
	}
	for (int i = 0; i < m; i++) {
		int a, b;
		ll c;
		cin >> a >> b >> c;
		e[i].s = a; e[i].t = b; e[i].d = c;
	}
	cost[1] = 0;
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (cost[e[j].s] == -INF)continue;
			cost[e[j].t] = max(cost[e[j].t], cost[e[j].s] + e[j].d);
		}
	}

	for (int i = 1; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (cost[e[j].t] < cost[e[j].s] + e[j].d) {
				cost[e[j].t] = cost[e[j].s] + e[j].d;
				aug[e[j].t] = true;
			}
		}
	}
	if (aug[n])cout<<"inf" << endl;
	else cout << cost[n] << endl;
	return 0;
}

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

ll n,m,l,p,c,ch[101000][2],cnt=1;
char s[101000];

ll dfs(ll x,ll d){
	return x? dfs(ch[x][0],d-1)^dfs(ch[x][1],d-1): d&-d;
}

int main(){
	for (scanf("%lld%lld",&n,&m);n--;){
		scanf("%s",s+1); l=strlen(s+1);
		for (int i=p=1;i<=l;++i){
			c=s[i]-'0';
			if (!ch[p][c]) ch[p][c]=++cnt;
			p=ch[p][c];
		}
	}
	puts(dfs(1,m+1)?"Alice":"Bob");
}

Measured memory_bytes: 4992
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    val works = (1..n).map {
        val (a, b) = readLine()!!.split(' ').map { s -> s.toLong() }
        Work(a, b)
    }.sortedBy { it.limit }
    var cnt = 0L
    var result = true
    works.forEach{
        work -> 
            cnt += work.require
            if (cnt > work.limit)
                result = false
    }
    
    println( if (result) "Yes" else "No")
}

data class Work(val require: Long, val limit: Long)

Measured memory_bytes: 122528
//              _      _                 
//             (_)    | |                
//    _ __ ___  _  ___| |__   __ _  ___  
//   | '_ ` _ \| |/ __| '_ \ / _` |/ _ \ 
//   | | | | | | | (__| | | | (_| | (_) |
//   |_| |_| |_|_|\___|_| |_|\__,_|\___/ 
//                                       
// 
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
using namespace std;

int32_t main()
{
  BOOST;
	string a,b;
	cin>>a>>b;
	int ans=0;
	for (int i=0;i<sz(a);i++)
	{
		if (a[i]!=b[i])ans++;
	}
	cout<<ans;
  return 0;
}


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

using namespace std;

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


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

int main(void) {
   char s[100];
   int k, len, i;

   scanf("%d", &k);
   scanf("%s", s);

   len = strlen(s);

   if(len <= k) {
      printf("%s\n", s);
   } else {
      for(i = 0; i < k; i++) {
         printf("%c", s[i]);
      }
      printf("...\n");
   }

   return 0;
}


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

public class Main{	
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		
		int min = scan.nextInt();
		int max = -1000000000;
		
		for(int i = 1; i < n; i++)
		{
			int r = scan.nextInt();
			
			if(r - min > max)
				max = r - min;
			
			if(r<min)
				min = r;
		}
	
		System.out.println(max);
	}	
}


Measured memory_bytes: 68352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		StringBuffer sb = new StringBuffer(S);
		sb.insert(3, 8);
		sb.deleteCharAt(4);
		String ans = sb.toString();
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 21972
n=int(input())
L=[[] for i in range(n)]
for i in range(n-1):
    u,v,w=map(int, input().split())
    u-=1
    v-=1
    L[u].append([v,w])
    L[v].append([u,w])
ans=[-1]*n
ans[0]=0
from collections import deque
stack=deque([])
stack.append(0)
while stack:
    v=stack.popleft()
    for u, w in L[v]:
        if ans[u]!=-1:
            continue
        ans[u]=(ans[v]+w)%2
        stack.appendleft(u)
for a in ans:
    print(a)


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

void counting(unsigned short *A,unsigned short*B,int n){
  int C[10001];
  int i;
  
  for (i=0;i<10001;i++){
    C[i] = 0;
  }
  for(i = 1; i <= n;i++){
    C[A[i]]++;
  }
  for (i =1;i<10001;i++){
    C[i] = C[i] + C[i-1];
  }
  for(i = n;i>0;i--){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
}

int main(){
  unsigned short *A;
  unsigned short *B;
  int n;
  scanf("%d",&n);
  int i;
  A = malloc(sizeof(short)*(n+1));
  B = malloc(sizeof(short)*(n+1));
  for(i=1;i<=n;i++){
    scanf("%hu",&A[i]);
  }
  counting(A,B,n);
  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[n]);
  return 0;
}

Measured memory_bytes: 8456
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int r = sc.nextInt();
		int ans = r * r;
		System.out.println(ans);
	}



	public static long gcd(long a, long b) {
		long remainder = a % b;
		if (remainder == 0) {
			return b;
		} else {
			return gcd(b, remainder);
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22484
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;
using namespace __gnu_pbds;

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	bool flag = true;
	int n, ele;
	cin >>n;
	while(n--) {
		cin >>ele;
		if(ele % 2 == 0) {
			if(ele % 3 == 0){
				continue;
			}
			else if(ele % 5 == 0) {
				continue;
			}
			else {
				flag = false;
			}
		}
	}
	if(flag) {
		cout <<"APPROVED";
	}
	else {
		cout <<"DENIED";
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define INFTY 1000000
#define M -1
#define WHITE 0
#define GRAY  1
#define BLACK 2
#define N 100
int prim(void);
int n,A[N][N];

int main()
{
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  scanf("%d",&A[i][j]);
	  if(A[i][j]==M) A[i][j]=INFTY;
	}
    }
  printf("%d\n",prim());
  return 0;
}

int prim(void)
{
  int d[N],p[N],color[N];
  int i,v,u,mincost,sum=0;
  for(i=0;i<n;i++)
    {
      d[i]=INFTY;
      p[i]=M;
      color[i]=WHITE;
    }
  d[0]=0;
  while(1)
    {
      mincost=INFTY;
      //u=M;
      for(i=0;i<n;i++)
	{
	  if(mincost>d[i]&&color[i]!=BLACK)
	    {
	      u=i;
	      mincost=d[i];
	    }
	}
      if(mincost==INFTY) break;
      
      color[u]=BLACK;
      for(v=0;v<n;v++)
	{
	  if(color[v]!=BLACK&&A[u][v]<d[v])
	    {
	      d[v]=A[u][v];
	      p[v]=u;
	      color[v]=GRAY;
	    }
	}
    }
  for(i=0;i<n;i++)
    {
      if(p[i]!=M) sum+=A[i][p[i]];
    }
  return sum;
}

Measured memory_bytes: 632
#include<bits/stdc++.h>
#define rg register
using namespace std;
const int mod=1e9+7;
#define _ 2001
int n, k, f[_][_], sum[_*_];
int qp(int x, int y){
	int ans=1;
	while(y){
		if(y&1)ans=1ll*ans*x%mod;
		x=1ll*x*x%mod, y>>=1;
	}return ans;
}
int C(int m, int r){return 1ll*sum[m]*qp(sum[r], mod-2)%mod*qp(sum[m-r], mod-2)%mod;}
int main(){
	sum[0]=sum[1]=1;
	for(int i=2; i<=2000*2000; ++i)
		sum[i]=1ll*sum[i-1]*i%mod;
	
	scanf("%d%d", &n, &k);
	if(k==1){puts("1"); return 0;}
	f[0][0]=1;
	for(int i=1; i<=n; ++i)
		for(int j=0; j<=i; ++j){
			f[i][j]=f[i-1][j];
			if(j)(f[i][j]+=1ll*C((n-j+1)*(k-1)+n-i-1, k-2)*f[i][j-1]%mod)%=mod;
		}
	for(int i=2; i<=n; ++i)
		f[n][n]=1ll*f[n][n]*i%mod;
	printf("%d", f[n][n]);
}


Measured memory_bytes: 31488
#include<stdio.h>
#define N 101

int main(){
  int G[N][N],A[N],key[N],p[N];
  int i,j,n,count=0,cost,u=0;

  scanf("%d",&n);

  for(i=0 ; i<n ; i++){
    for(j=0 ; j<n ; j++){
      scanf("%d",&G[i][j]);
    }
  }

  for(i=0 ; i<n ; i++){
    A[i] = 0;
    p[i] = -1;

    if(i==0)key[i] = 0;
    else key[i] = 2001;
    
  }


  while(cost != 2001){
    cost = 2001;
    for(i=0 ; i<n ; i++){
      if(A[i]!=2 && key[i]<cost){
	/*２は探索済み*/
	cost = key[i];
	u = i;
      }
    }

    A[u]=2;
    for(i=0 ; i<n ; i++){
      if(G[u][i] != -1 && A[i] != 2 && G[u][i]<key[i]){
	p[i] = u;
	key[i] = G[u][i];
	A[i] = 1;
      }
    }
  }

  for(i=0 ; i<n ; i++){
    if(p[i] != -1){
      count += G[i][p[i]];
    }
  }

    printf("%d\n",count);

    return 0;
  }

Measured memory_bytes: 640
K = int(input())

def calc_n(K):
  for n in range(1, int(K/2)+2):
    if n*(n+1)/2 == K:
      return n
  return "No"

N = calc_n(K)
if not isinstance(N, int):
  print(N)
else:
  print("Yes")
  print(N+1)
  last = [i for i in range(1, N+1)]
  count = 2
  first_set = [str(i) if i == 1 else str(sum(last[:i-1])+1) for i in range(1, N+1)]
  print(N, " ".join(first_set))
  last_set = [str(sum(last[:i])) for i in range(1,N+1)]
  print(N, " ".join(last_set))
  while count != N+1:
    first_number = sum(last[:count-1])+1
    other_set = [i for i in range(first_number, first_number+count)]
    other_set.extend([first_number+count*(i+1)-1+sum(last[:i-1]) for i in range(1, N-count+1)])
    count += 1
    other_set = [str(i) for i in other_set]
    print(N, " ".join(other_set))

Measured memory_bytes: 4212
str = input()
count = 0
if str[0] == str[1]:
  if str[2] == str[3]:
    count += 1
if str[0] == str[2]:
  if str[1] == str[3]:
    count += 1
if str[0] == str[3]:
  if str[1] == str[2]:
    count += 1
if count == 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define flash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define all(v) (v).begin(),(v).end() 
#define endl "\n"
#define int long long int
#define ll long long
#define ld long double
const int mod = 1000000007;
const int N=200005;
const int inf=1e18;
int vis[N];
vector<vector<int>>adj(N);


bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res%mod;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
ll max(ll a,ll b){ll ans=a>b?a:b;return ans;}
ll min(ll a,ll b){ll ans=a<b?a:b;return ans;}
void dfs(int x){
    vis[x]=1;
    for(auto i:adj[x]){
        if(!vis[i])
            dfs(i);
    }
}


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


signed main(){
    flash;
    fun();
    int t=1;
    //cin>>t;
    while(t--){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        if(a>0 && b>0 && c>0 && d>0)
            cout<<max(a,b)*max(c,d);
        else{
            vector<int> k;
            k.push_back(a*c);
            k.push_back(a*d);
            k.push_back(b*c);
            k.push_back(b*d);
            sort(k.begin(),k.end());
            cout<<k[3]<<endl;
        }
    }
    return 0;
}

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

typedef long long ll;

const int MAX_N=3e2+10;
const ll INF=1e18+10;

ll dp[MAX_N][MAX_N],H[MAX_N];
int N,K,M;

int main(){
	for(int i=0;i<MAX_N;i++) for(int j=0;j<MAX_N;j++) dp[i][j]=INF;
	scanf("%d%d",&N,&K);
	for(int i=0;i<N;i++) scanf("%lld",&H[i]);
	if(N==K){
		printf("0\n");
		return 0;
	}
	K=N-K; 
	for(int i=0;i<N;i++){
		dp[i][1]=H[i];
		for(int k=2;k<=K;k++){
			for(int j=0;j<i;j++){
				dp[i][k]=min(dp[i][k],dp[j][k-1]+(H[i]>H[j]?H[i]-H[j]:0));
			}
		}
	}
	ll ans=INF;
	for(int i=0;i<N;i++) ans=min(ans,dp[i][K]);
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 1532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back;
#define mod 1000000007
#define test cout<<"#"


int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   ll n;
   cin>>n;
   ll sum = 0;
   while(n!=0)
   {
      if(n%3!=0 && n%5!=0)
      {
         sum += n;
      }
      n--;
   }
   cout<<sum<<"\n";
}

Measured memory_bytes: 3652
// Millennium
#include <iostream>
using namespace std;

struct Date {
  int year, month, day;
};

void IncrementDay(Date& d) {
  d.day += 1;
  int day_of_month = 20;
  if (d.year % 3 != 0 && d.month % 2 == 0) {
    day_of_month = 19;
  }
  if (d.day > day_of_month) {
    d.day = 1;
    d.month += 1;
    if (d.month > 10) {
      d.month = 1;
      d.year += 1;
    }
  }
}

int main() {
  int n; cin >> n;
  for (int i = 0; i < n; ++i) {
    Date d; cin >> d.year >> d.month >> d.day;
    int ans = 0;
    while (d.year < 1000) {
      IncrementDay(d);
      ++ans;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 868
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

ll w[214514] = {}, b[214514];

int main() {
	IOS();
	ll n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == '.')
			w[i + 1] = w[i] + 1;
		else
			w[i + 1] = w[i];
	}
	for (int i = n - 1; i >= -1; i--) {
		if (s[i] == '#')
			b[i + 1] = b[i + 2] + 1;
		else
			b[i + 1] = b[i + 2];
	}
	ll ans = INF;
	for (int i = 0; i <= n; i++) {
		//cout << w[i] << " " << b[i] << endl;
		ll tmp = i - w[i] + (n - i - b[i + 1]);
		ans	= min(tmp, ans);
	}
	dump(ans);
	return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>                
using namespace std;
char S;
bool answer;
vector<bool> B(4, true);
int main(void){
	int i;
	for(i = 0; i < 4; i++){
		cin >> S;
		if('1' == S)B[0] = false; 
		if('7' == S)B[1] = false; 
		if('9' == S)B[2] = false; 
		if('4' == S)B[3] = false; 
	}
	for(i = 0; i < 4; i++) if(B[i]) answer = true;
  if(answer)printf("NO\n");
	else printf("YES\n");
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;

bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2:
        case 3: return true;
    }
    if(n%2 == 0) return false;
    if(n%3 == 0) return false;
    if(n%6 != 1 && n%6 != 5) return false;
    for(unsigned i=5;i*i<=n;i+=6){
        if(n%i     == 0) return false;
        if(n%(i+2) == 0) return false;
    }

    return true;
}

int main(){
  int Q,k;
  vector<int> v;
  v.resize(50000);
  v[0] = 0;
  for(int i=1;i<50000;i++){
    v[i]=v[i-1];
    k=i*2+1;
    if(is_prime(k) && is_prime((k+1)/2)) v[i]++;
  }
  cin >> Q;
  for(int i=0;i<Q;i++){
    int l,r;
    scanf("%d %d",&l,&r);
    if(is_prime(l) && is_prime((l+1)/2)){
      cout << v[r/2]-v[l/2]+1 << endl;
    }else{
      cout << v[r/2]-v[l/2] << endl;
    }
  }
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        int n, mi=1000000, ma=-1000000;
        long su=0;
        
        Scanner s = new Scanner(System.in);
        n = s.nextInt();
        for(int i=0; i<n; i++){
            int tmp = s.nextInt();
            mi = Math.min(mi,tmp);
            ma = Math.max(ma,tmp);
            su += tmp;
        }
        System.out.println(mi+" "+ma+" "+su);
    }
}


Measured memory_bytes: 41564
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <stdlib.h>

using namespace std;

int main(){
	int w, h;
	int cost[100][100];
	while(cin >> w >> h, w){
		vector< vector< pair<int,int> > > vp(w*h);
		string str;
		int gx, gy;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> str;
				if(str=="S"){
					vp[0].push_back(make_pair(i,j));
					cost[i][j] = 0;
				}
				else if(str=="G"){
					gx = i, gy = j;
				}
				else if(isdigit(str[0])){
					istringstream iss(str);
					int t; iss >> t;
					vp[t].push_back(make_pair(i,j));
				}
			}
		}
		for(int i=1; ;i++){
			if(vp[i].empty()){
				int m = 1000000007;
				for(int k=0;k<vp[i-1].size();k++){
					int cur = cost[vp[i-1][k].first][vp[i-1][k].second];
					int dx  = abs(vp[i-1][k].first-gx);
					int dy  = abs(vp[i-1][k].second-gy);
					m = min(m, cur+dx+dy);
				}
				cout << m << endl;
				break;
			}
			else{
				for(int j=0;j<vp[i].size();j++){
					int m = 1000000007;
					for(int k=0;k<vp[i-1].size();k++){
						int cur = cost[vp[i-1][k].first][vp[i-1][k].second];
						int dx  = abs(vp[i-1][k].first-vp[i][j].first);
						int dy  = abs(vp[i-1][k].second-vp[i][j].second);
						m = min(m, cur+dx+dy);
					}
					cost[vp[i][j].first][vp[i][j].second] = m;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <functional>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++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;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;
constexpr double EPS = 1e-10;

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

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int H, W;
    string s[100];
    function<void(int,int)> dfs = [&](int y, int x) {
        char c = s[y][x];
        s[y][x] = '.';
        REP(i,4) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if(0 <= ny && ny < H && 0 <= nx && nx < W && s[ny][nx] == c) dfs(ny, nx);
        }
    };


    while(true) {
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        REP(i,H) cin >> s[i];
        
        int ans = 0;
        REP(i,H) REP(j,W) {
            if(s[i][j] != '.') {
                dfs(i, j);
                ++ans;
            }
        }

        cout << ans << '\n';
    }

    return 0;
}


Measured memory_bytes: 4148
###
### atcorder test program
###

import sys

### math class
class math:
    ### pi
    pi = 3.14159265358979323846264338

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

math = math()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#A, B, C = [x for x in input().split()]
#inlist = [int(w) for w in input().split()]
#R = float(input())
#A = [int(x) for x in input().split()]
#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

S = input()

A = int(S[:2])
B = int(S[2:])

ans = "NA"

if (0<A<13) and (0<B<13):
    ans = "AMBIGUOUS"
elif (0<A<13):
    ans = "MMYY"
elif (0<B<13):
    ans = "YYMM"

print(ans)


Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int num[14]={};

bool DO(int n){
	int tmp[14]={};
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(num[i]==num[j])tmp[i]++;
		}
	}

	bool flag=true;
	for(int i=1;i<=n;i++)if(num[i]!=tmp[i])flag=false;
	if(flag)return true;
	for(int i=1;i<=n;i++)num[i]=tmp[i];
	return false;
}

int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		int c=0;
		int ans;
		rep(i,n)cin>>num[i+1];

		while(1){
			c++;
			if( DO(n) ){
				ans=c;
				break;
			}
		}
		cout<<ans-1<<endl;
		for(int i=1;i<=n;i++){
			if(i!=1)cout<<" ";
			cout<<num[i];
		}
		cout<<endl;

	}
}

Measured memory_bytes: 1160
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 1e5 + 5;
const int M = 1e6 + 5;
const int Q = 2e5 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

int n,k,cur[4],r[N],s[N],p[N],ans,dp[N][4];
string t;

int solve(int idx, int col) {

    if(idx>=n) return 0;

    int &ret = dp[idx][col];

    if(~ret) return ret;
    
    ret = 0;

    for(int i=1;i<=3;++i) {

        bool ok = 0;

        if(i==1 && t[idx]=='s') ok = 1;
        if(i==2 && t[idx]=='p') ok = 1;
        if(i==3 && t[idx]=='r') ok = 1;
        if(i==0) ok = 1;

        if(col!=i) ret = max(ret,(ok ? cur[i] : 0) +solve(idx+k,i));

    }

    return ret;

}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k >> cur[1] >> cur[2] >> cur[3] >> t;

    memset(dp,-1,sizeof(dp));

    for(int i=0;i<k;++i) ans += solve(i,0);

    cout << ans << '\n';

    return 0;
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define VEC vector

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				Vint;
typedef vector<Vint>			VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		100010


const ll LINF = (ll)9e18+7;		//
const int INF = 100100100;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

// int DP[MAX];

vector<pair<ll, ll> > prime_factorize(ll n) {
	vector<pair<ll,ll> > res;
	for (ll p = 2; p * p <= n; ++p) {
		if (n % p != 0) continue;
		int num = 0;
		while (n % p == 0) { ++num; n /= p; }
		res.push_back(make_pair(p, num));
	}
	if (n != 1) res.push_back(make_pair(n, 1));
	return res;
}

int main(){
	ll N;cin >> N;
	
	auto t = prime_factorize(N);

	// for(auto itr : t)cout << itr.first << " " << itr.second << endl;

	int cnt = 0;
	for(auto itr : t){
		int score=0;
		for(int i = 1;itr.second >= 0;++i){
			itr.second -= i;
			if(itr.second < 0)break;
			score++;
		}
		cnt += score;
	}

	cout << cnt << endl;

	return 0;
}
 



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len;
    cin >> len;
    map<int, int> m;
    for(int i = 1; i < len; i++) {
        int a;
        cin >> a;
        m[a] += 1;
    }
    for(int i = 1; i <= len; i++) {
        cout << m[i] << endl;
    }
}



Measured memory_bytes: 12980
n,k = map(int, input().split())
d = n//k
r = n%k
if k%2:
    d = n//k
    ans = d**3
elif k > 2:
    if r >= k//2:
        ans = (d+1)**3 + d**3
    else:
        ans = 2*d**3
else:
    if n%2:
        ans = (n//2 + 1)**3 + (n//2)**3
    else:
        ans = 2*(n//2)**3
print(ans)


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

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	int ans = 1e9;
	for (int i = -100; i <= 100; ++i) {
		int subans = 0;
		for (int j = 0; j < N; ++j) {
			subans += (A[j] - i)*(A[j] - i);
		}
		ans = min(ans, subans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var str = ReadLine();
        var isb = true;
        var ct = 0;
        var res = int.MaxValue;
        for(var i=0;i<str.Length;i++)
        {
            if ((isb && str[i] == '0') || (!isb && str[i] == '1'))
                ct++;
            isb = !isb;
        }
        res = ct;
        ct = 0;
        isb = false;

        for (var i = 0; i < str.Length; i++)
        {
            if ((isb && str[i] == '0') || (!isb && str[i] == '1'))
                ct++;
            isb = !isb;
        }
        WriteLine(Min(res, ct));
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 11232
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int a[4]={0};
  string s;
  cin >> s;
  for(int i=0; i<s.size(); i++) {
    if(s[i]=='S') {
      a[0]=1;
    }
    if(s[i]=='N') {
      a[1]=1;
    }
    if(s[i]=='W') {
      a[2]=1;
    }
    if(s[i]=='E') {
      a[3]=1;
    }
  }
  if(a[0]==a[1]&&a[2]==a[3]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256