akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define il inline
#define RG register
#define ll long long
#define rhl (924844033)
#define N (1000010)

using namespace std;

struct edge{ int nt,to; }G[N];

int head[N],sz[N],g[N],h[N],fac[N],ifac[N],inv[N],rev[N],n,lg,len,num;

il int gi(){
  RG int x=0,q=1; RG char ch=getchar();
  while ((ch<'0' || ch>'9') && ch!='-') ch=getchar();
  if (ch=='-') q=-1,ch=getchar();
  while (ch>='0' && ch<='9') x=x*10+ch-48,ch=getchar();
  return q*x;
}

il void insert(RG int from,RG int to){
  G[++num]=(edge){head[from],to},head[from]=num; return;
}

il void dfs(RG int x,RG int p){
  sz[x]=1,++g[n]; RG int v;
  for (RG int i=head[x];i;i=G[i].nt){
    v=G[i].to; if (v==p) continue;
    dfs(v,x),sz[x]+=sz[v];
    if(--g[sz[v]]<0) g[sz[v]]+=rhl;
  }
  if (--g[n-sz[x]]<0) g[n-sz[x]]+=rhl; return;
}

il int qpow(RG int a,RG int b){
  RG int ans=1;
  while (b){
    if (b&1) ans=1LL*ans*a%rhl;
    a=1LL*a*a%rhl,b>>=1;
  }
  return ans;
}

il void NTT(int *a,RG int n,RG int f){
  for (RG int i=0;i<n;++i) if (i<rev[i]) swap(a[i],a[rev[i]]);
  for (RG int i=1;i<n;i<<=1){
    RG int wn=qpow(5,(rhl-1)/(i<<1));
    for (RG int j=0;j<n;j+=i<<1){
      RG int w=1,x,y;
      for (RG int k=0;k<i;++k,w=1LL*w*wn%rhl){
	x=a[j+k],y=1LL*w*a[j+k+i]%rhl;
	a[j+k]=x+y; if (a[j+k]>=rhl) a[j+k]-=rhl;
	a[j+k+i]=x-y; if (a[j+k+i]<0) a[j+k+i]+=rhl;
      }
    }
  }
  if (f==1) return; RG int inv=qpow(n,rhl-2); reverse(a+1,a+n);
  for (RG int i=0;i<n;++i) a[i]=1LL*a[i]*inv%rhl; return;
}

int main(){
  n=gi(),fac[0]=ifac[0]=1;
  for (RG int i=1;i<=n;++i){
    inv[i]=i==1 ? 1 : 1LL*(rhl-rhl/i)*inv[rhl%i]%rhl;
    fac[i]=1LL*fac[i-1]*i%rhl,ifac[i]=1LL*ifac[i-1]*inv[i]%rhl;
  }
  for (len=1;len<=(n<<1);len<<=1) ++lg;
  for (RG int i=0;i<len;++i) rev[i]=rev[i>>1]>>1|((i&1)<<(lg-1));
  for (RG int i=1,u,v;i<n;++i) u=gi(),v=gi(),insert(u,v),insert(v,u);
  dfs(1,0); for (RG int i=0;i<=n;++i) g[i]=1LL*g[i]*fac[i]%rhl; NTT(g,len,1);
  for (RG int i=0;i<=n;++i) h[i]=ifac[n-i]; NTT(h,len,1);
  for (RG int i=0;i<len;++i) g[i]=1LL*g[i]*h[i]%rhl; NTT(g,len,-1);
  for (RG int i=1;i<=n;++i) printf("%lld\n",1LL*g[n+i]*ifac[i]%rhl); return 0;
}


Measured memory_bytes: 36992
#include <iostream>
#include <vector>

constexpr int N = 1000'000'0;
int A[N + 1];

int main(void){
    std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
    
    int n; std::cin >> n;
    for(int i = 2; i <= n; ++i){
        for(int j = i; j <= n; j += i) ++A[j];
    }
    long long int res = 1;
    for(long long int i = 2; i <= n; ++i) res += (A[i] + 1) * i;
    std::cout << res << '\n';
    return 0;
}


Measured memory_bytes: 42252
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main() {
	speed;
	int a, b, c;
	cin >> a >> b >> c;
	if ((a >= c && b <= c )|| (a <= c && b >= c)) {
		cout << "Yes";
		ed;
	}
	else {
		cout << "No";
		ed;
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
ba = []
for i in range(n):
    a, b = (int(j) for j in input().split())
    tmp = []
    tmp.append(b)
    tmp.append(a)
    ba.append(tmp)
ba.sort()

s = 0
f = True
for i in range(n):
    s += ba[i][1]
    if ba[i][0] < s:
        f = False
        break
if f:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38824
a_v = list(map(int, input().split())) 
b_w = list(map(int, input().split())) 
t = int(input())

a = a_v[0]
v = a_v[1]
b = b_w[0]
w = b_w[1]

answer = "YES"
if w - v >= 0:
    answer = "NO"

distance = abs(b-a)
speed = abs(w-v)

if distance <= t*speed and answer != "NO":
    answer = "YES"
else:
    answer = "NO"


print(answer)


Measured memory_bytes: 9196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

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

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);
		int x = Integer.parseInt(str[2]);

		int c[] = new int[n];
		int a[][] = new int[n][m];

		for (int i = 0; i < n; i++) {
			str = br.readLine().split(" ");
			c[i] = Integer.parseInt(str[0]);

			for (int j = 0; j < m; j++) {
				a[i][j] = Integer.parseInt(str[j + 1]);
			}
		}

		long ans = Long.MAX_VALUE;
		for (int i = 0; i < Math.pow(2, n); i++) {
			int under[] = new int[m];
			long sum = 0;
			boolean flag = false;

			for (int j = 0; j < n; j++) {
				if ((i & (1 << j)) != 0) {
					for (int k = 0; k < m; k++) {
						under[k] += a[j][k];
					}
					sum += c[j];
				}
			}
			for (int j = 0; j < m; j++) {
				if (under[j] < x) {
					flag = true;
				}
			}
			if (flag) {
				continue;
			}
			ans = Math.min(ans, sum);
		}

		if (ans == Long.MAX_VALUE) {
			System.out.println("-1");
		} else {
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 34088
#include<cstdio>
int main(){
	long long int a,b,c,d,e,f,g;
	scanf("%lld%lld%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e,&f,&g);
	long long int ans=b;
	int x=a%2+d%2+e%2;
	if(x==0){
		ans+=a+d+e;
	}else if(x==1){
		ans+=a+d+e-1;
	}else if(x==2){
		ans+=a+d+e-1;
		if(a==0||d==0||e==0)ans--;
	}else{
		ans+=a+d+e;
	}
	printf("%lld\n",ans);
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, x); }
template<class T, class U> void init(vector<T> &v, U x, size_t n, size_t m...) { v=vector<T>(n); for(auto& a : v) init(a, x, m);}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    while(k && b <= a){
        k--;
        b *= 2;
    }
    while(k && c <= b){
        k--;
        c *= 2;
    }

    if (b > a && c > b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;


    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}



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

int main(){
	int n, zmx = 0;
	ll ans = 1001001001;
	cin >> n;
	vector<int> x(n);
	rep(i, n){
		cin >> x.at(i);
		zmx = max(zmx, x.at(i));
	}
	rep(i, zmx+1){
		ll temp = 0;
		rep(j, n){
			temp += pow((x.at(j)-i), 2);
		}
		ans = min(ans, temp);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;

void main() {
	string[] input = split(readln());
	int n = to!int(input[0]);
	int m = to!int(input[1]);
	int r = to!int(input[2]);

	r -= n * m;
	if(r <= 0) {
		writeln(0);
	}
	else {
		BigInt ans = 1;
		for(int i = 1; i < n; ++i) {
			ans = ans * (i + r) / i;
		}

		writeln(ans);
	}
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

//Union-Find Tree

int par[100001];
int rnk[100001];
int size[100001];
int N;

void shoki(){
    for(int i=0;i<=N;i++) {par[i]=i; rnk[i]=0; size[i]=1;}
}

int sch(int x){
    if(par[x]==x) return x;
    else return par[x]=sch(par[x]);
}

void con(int A,int B){
    A=sch(A);
    B=sch(B);
    if(A==B) return;
    if(rnk[A]>rnk[B]) swap(A,B);
    par[A]=B;
    size[B]+=size[A];
    size[A]=size[B];
    if(rnk[A]==rnk[B]) rnk[B]++;

    return;
}

int is_size(int k){
    return size[sch(k)];
}

bool same(int A,int B){
    return sch(A)==sch(B);
}

int main(){
    int M;
    cin>>N>>M;
    vector<int> p(N+1);
    for(int i=0;i<N;i++){
        cin>>p.at(i+1);
    }

    shoki();
    for(int i=0;i<M;i++){
        int x,y;
        cin>>x>>y;
        con(x,y);
    }

    int ans=0;
    for(int i=1;i<=N;i++){
        if(same(p.at(i),i)) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll n, x, y;
    vector<ll> G[3000];

    cin >> n >> x >> y;
    x--;
    y--;

    vector<int> ans(n);

    for (ll i = 0; i < n; i++)
    {
        for (ll j = i + 1; j < n; j++)
        {
            ans[min({j - i, abs(j - y) + abs(x - i) + 1, abs(i - x) + abs(y - j) + 1})]++;
        }
    }

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

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>
#define ff first
#define ss second

void solve()
{
    int n,m;
    cin>>n>>m;
    string s(n,'0');
    bool vis[n+1]={0};
    for(int i=0;i<m;i++)
    {
        int a;
        char b;
        cin>>a>>b;
        a--;

        if(s.size()>1&&a==0&&b=='0')
        {
            cout<<-1<<endl;
            exit(0);
        }
        if(vis[a]&&s.at(a)!=b)
        {
            cout<<-1<<endl;
            exit(0);
        }
        else
        {
            s.at(a)=b;
        }
        vis[a]=1;
    }
    int count=0;
//    cout<<s.at(0)<<endl;
    while(count<s.size()&&s.at(count)=='0'&&s.size()!=1)
        count++;
    if(count>0)
    {
        s.at(0)='1';
    }
    cout<<s<<endl;
}

int main()
{

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

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void init(vector<double> &v, const int &M)
{
    int sum = 0;
    v.push_back(0);
    for(int i = 1; i <= M; i++)
    {
        sum += i;
        v.push_back((double)sum / i);
    }
}

void solve()
{
    cout << fixed << setprecision(10);
    int n, k; cin >> n >> k;
    vector<int> p(n);
    int M = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> p[i];
        M = max(M, p[i]);
    }
    
    vector<double> v;
    init(v, M);

    double ans = 0.0;
    double mean = 0.0;
    int front_idx = 0;
    for(int i = 0; i < k; i++) mean += v[p[i]];
    ans = max(ans, mean);

    for(int i = k; i < n; i++)
    {
        mean -= v[p[front_idx]];
        mean += v[p[i]];
        front_idx++;
        ans = max(ans, mean);
    }

    cout << ans << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 1024
n, q = map(int, input().split())
s = input()
c = [0] * n
for i in range(n - 1):
    if s[i] == 'A' and s[i + 1] == 'C':
        c[i + 1] += 1
    c[i + 1] += c[i]
for _ in range(q):
    l, r = map(int, input().split())
    print(c[r - 1] - c[l - 1])

Measured memory_bytes: 51160
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

//Ford-Fulkerson法、蟻本そのまま
//最大流(=最小カット)を求めるアルゴリズム
//隣接リスト表現での実装
//計算量は最大流量Fとして、O(F|E|)だが、実際はもっと高速
//Dinic法はさらに高速らしい

//辺を表す構造体（行き先、容量、逆辺）
struct edge{ll to, cap, rev;};

vector<vector<edge>> G(203, vector<edge>(0));;//$1には最大頂点数+3を入れよう！
bool used[203];

//辺を追加する！
//fromからtoへ向かう容量capの辺
void add_edge(ll from, ll to, ll cap){
    G[from].emplace_back(edge{to,cap,(ll)G[to].size()});
    G[to].emplace_back(edge{from,0,(ll)G[from].size()-1});
}

//増加パスをdfsで探す！
ll dfs(ll v, ll t, ll f){
    if(v==t)return f;
    used[v]=1;
    for(ll i=0;i<G[v].size();i++){
        edge &e=G[v][i];
        if(!used[e.to]&&e.cap>0){
            ll d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

//sからdへの最大流を求める
ll max_flow(ll s,ll t){
    ll flow=0;
    for(;;){
        memset(used,0,sizeof(used));
        ll f=dfs(s,t,INF);
        if(f==0)return flow;
        flow+=f;
    }
}



int main(){
    ll N;
    cin >> N;
    vector<ll> A(N+1,0);
    vector<ll> B(N+1,0);
    vector<ll> C(N+1,0);
    vector<ll> D(N+1,0);
    for(ll i=1;i<=N;i++)cin>>A[i]>>B[i];
    for(ll i=1;i<=N;i++)cin>>C[i]>>D[i];

    //辺の追加
    for(ll i=1;i<=N;i++)
        for(ll j=1;j<=N;j++)
            if(A[i]<C[j]&&B[i]<D[j])add_edge(i,j+N,1);
    
    for(ll i=1;i<=N;i++)add_edge(0,i,1);
    for(ll i=N+1;i<=2*N;i++)add_edge(i,2*N+1,1);

    ll ans=0;

    for(ll i=0;i<10000;i++)ans+=max_flow(0,2*N+1);
    for(ll i=0;i<9999;i++)ans-=max_flow(0,2*N+1);
    print(ans)

    return 0;
}


Measured memory_bytes: 512
n=int(input())
l=list(map(int,input().split()))
x=[0]*n
for i in range(n):
  x[l[i]-1]+=1
d=0
for i in range(n):
  d=d+x[i]*(x[i]-1)//2

for i in range(n):
  b=d-(x[l[i]-1]-1)
  print(b)
    


Measured memory_bytes: 32248
l = [[i**2+j**2,i,j] for j in range(1,151) for i in range(1,151) if i!=j and i<j]
l = sorted(l)
while True:
    h,w = map(int,input().split())
    if w==h==0: break
    i = l.index([w**2+h**2,h,w])+1
    print(*l[i][1:],sep=' ')

Measured memory_bytes: 9060
N, M= map(int, input().split())
A = list(map(int,input().split()))
A=[-1*a for a in A]
import heapq
import math
hq=heapq.heapify(A)
for m in range(M):
    X=heapq.heappop(A)
    heapq.heappush(A,math.ceil(X/2))
print(sum(A)*-1)

Measured memory_bytes: 14224
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		System.out.println(arr[n / 2] - arr[n / 2 - 1]);
   }
}


Measured memory_bytes: 51224
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ_DSL_4_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            int[] x1 = new int[N];
            int[] y1 = new int[N];
            int[] x2 = new int[N];
            int[] y2 = new int[N];
            for (int i = 0; i < N; i++)
            {
                var input = ReadInt();
                x1[i] = input[0];
                y1[i] = input[1];
                x2[i] = input[2];
                y2[i] = input[3];
            }

            //座標圧縮
            List<int> hhash;
            List<int> whash;
            int H = Compress(y1, y2, N, out hhash); //参照渡し hashのindexが返ってくるはず
            int W = Compress(x1, x2, N, out whash);

            //塗りつぶし 愚直：O(N^3⇒TLE)　累積和？
            int[,] map = new int[H, W];
            for (int i = 0; i < N; i++)
            {
                map[y1[i], x1[i]]++;
                map[y2[i], x2[i]]++;
                map[y2[i], x1[i]]--;
                map[y1[i], x2[i]]--;
            }
            for (int i = 0; i < H; i++)
            {
                for (int j = 1; j < W; j++)
                {
                    map[i, j] += map[i, j - 1];
                }
            }
            for (int i = 1; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    map[i, j] += map[i - 1, j];
                }
            }

            //総和の算出
            long ans = 0;
            for (int h = 0; h < H - 1; h++)
            {
                for (int w = 0; w < W - 1; w++)
                {
                    if (map[h, w] <= 0) continue;
                    long area = (long)(hhash[h + 1] - hhash[h]) * (whash[w + 1] - whash[w]);
                    ans += area;
                }
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }

        /// <summary>
        /// 座標圧縮
        /// </summary>
        /// <param name="x1"></param>
        /// <param name="x2"></param>
        /// <param name="w"></param>
        /// <returns></returns>
        static int Compress(int[] x1, int[] x2, int w, out List<int> xhash)
        {
            xhash = new List<int>();
            xhash.AddRange(x1);
            xhash.AddRange(x2);

            xhash = xhash.Distinct().OrderBy(x => x).ToList();

            for (int i = 0; i < x1.Length; i++)
            {
                x1[i] = xhash.FindIndex(x => x == x1[i]);
                x2[i] = xhash.FindIndex(x => x == x2[i]);
            }

            return xhash.Count;
        }
    }
}



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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
void print_line(vector<int> &line) {
    for (int i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;


int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int count = 0;
    bool flag = true;
    while (flag) {
        flag = false;
        for (int j = n - 1; j >= 1; j--) {
            if (a[j] < a[j - 1]) {
                swap(a[j], a[j - 1]);
                flag = true;
                count++;
            }
        }
    }
    print_line(a);
    cout << count << endl;

}



Measured memory_bytes: 3120
#include<iostream>
#include<algorithm>
using namespace std;
char box[30];
void input();
bool check();
bool check2(int[2]);
int solve(int);
void turn(int);
int ft[6][2]={{0,9},{9,12},{12,15},{15,18},{18,21},{21,30}};
int main(){
    int time;
    cin>>time;
    for(int i=0;i<time;++i){
        input();
        cout<<solve(0)<<endl;
    }
    return 0;
}

int solve(int num){
    if(num==8||check()){
       return num;
    }
    int res=8;
    for(int i=0;i<4;++i){
        turn(i);
        res=min(res,solve(num+1));
        turn(i);
    }
    return res;
}
void turn(int num){
    switch(num){
        case 0:
            swap(box[6],box[21]);
            swap(box[7],box[22]);
            swap(box[8],box[23]);
            swap(box[9],box[11]);
            swap(box[17],box[12]);
            break;
        case 1:
            swap(box[8],box[27]);
            swap(box[5],box[24]);
            swap(box[2],box[21]);
            swap(box[12],box[14]);
            swap(box[11],box[18]);
            break;
        case 2:
            swap(box[0],box[27]);
            swap(box[1],box[28]);
            swap(box[2],box[29]);
            swap(box[18],box[20]);
            swap(box[14],box[15]);
            break;
        case 3:
            swap(box[0],box[23]);
            swap(box[3],box[26]);
            swap(box[6],box[29]);
            swap(box[15],box[17]);
            swap(box[9],box[20]);
            break;
    }
}
void input(){
    for(int i=0;i<30;++i){
        cin>>box[i];
    }
}

bool check(){
    for(int i=0;i<6;++i){
        if(check2(ft[i]))return false;
    }
    return true;
}

bool check2(int j[2]){
    for(int i=j[0]+1;i<j[1];++i){
        if(box[j[0]]!=box[i])return true;
    }
    return false;
}

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

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    int b = 0;
    int kVal = 0, index = 0;
    int currMax = 0;
    int result = 0;
    while(index < n){
        if(s[index] == '1'){
            index++;
        } else {
            //when 0 at index;
            kVal++;
            while(index < n && s[index] == '0'){
                index++;
            }
            if(kVal > k){
                // now let b move back;
                while(b < n && s[b] == '1'){
                    b++;
                }
                while(b < n && s[b] == '0'){
                    b++;
                }
                kVal--;
            }
        }
         currMax = index - b;
        if(currMax > result){
             result = currMax;
        }
    }
    cout << result;
    return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  int count = 0;
  for (int i = A; i <= B; i++) {
    int j, k, l, m;
    j = i / 10000;
    k = (i % 10000) / 1000;
    l = (i % 100) / 10;
    m = i % 10;
    if (j == m && k == l) {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
//My thanks
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define fastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define MOD 1000000007
#define pii pair<int, int>

using namespace std;

struct Line {
	int k, b;
}arr[500010];

bool cmp(const Line &a, const Line &b)
{
	return a.k < b.k;
}

int n;
pii sect[500010];
int stk[500010], top;
ll dp[500010], sum[500010];

int main()
{
	fastIO
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> arr[i].b >> arr[i].k;
	sort(arr + 1, arr + n + 1, cmp);
	top = 0;
	for (int i = 1; i <= n; i++)
	{
		if (!top || arr[stk[top]].b < arr[i].b) stk[++top] = i;
		int st = 1, ed = top;
		while (st < ed)
		{
			int mid = (st + ed) >> 1;
			if (arr[stk[mid]].b >= arr[i].b) ed = mid;
			else st = mid + 1;
		}
		sect[i].second = stk[st];
	}
	top = 0;
	for (int i = n; i >= 1; i--)
	{
		if (!top || arr[stk[top]].b > arr[i].b) stk[++top] = i;
		int st = 1, ed = top;
		while (st < ed)
		{
			int mid = (st + ed) >> 1;
			if (arr[stk[mid]].b <= arr[i].b) ed = mid;
			else st = mid + 1;
		}
		sect[i].first = stk[st];
	}
	sort(sect + 1, sect + n + 1);
	for (int i = 1; i <= n; i++) swap(sect[i].first, sect[i].second);
	int cur = 1;
	for (int i = 1; i <= n; i++)
	{
		while (sect[cur].second < sect[i].first - 1) cur++;
		dp[i] = (sum[i - 1] - sum[cur - 1] + MOD + (sect[i].first == 1 ? 1 : 0)) % MOD;
		sum[i] = (sum[i - 1] + dp[i]) % MOD;
	}
	ll ans = 0;
	for (int i = n; i >= 1; i--)
	{
		if (sect[i].second != n) break;
		(ans += dp[i]) %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 16256
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

#[allow(non_snake_case)]
fn main() {
    let n = get!(usize);
    let mut v = Vec::new();
    let mut ans = 0;
    let mut BXA = 0;
    let mut BXX = 0;
    let mut XXA = 0;
    for _ in 0..n {
        let tmp: Vec<char> = get!(String).chars().collect();
        if tmp[0] == 'B' && tmp[tmp.len() - 1] == 'A' {
            BXA += 1;
        } else if tmp[0] == 'B' {
            BXX += 1;
        } else if tmp[tmp.len() - 1] == 'A' {
            XXA += 1;
        }
        for i in 1..tmp.len() {
            if tmp[i - 1] == 'A' && tmp[i] == 'B' {
                ans += 1;
            }
        }
        v.push(tmp);
    }
    //eprintln!("{:?}", v);
    //eprintln!("ans: {}", ans);
    //eprintln!("BXA: {}", BXA);
    //eprintln!("BXX: {}", BXX);
    //eprintln!("XXA: {}", XXA);
    if BXA == 0 {
        ans += std::cmp::min(BXX, XXA);
    } else {
        if BXX == 0 && XXA == 0 {
            ans += BXA - 1;
        } else {
            ans += BXA + std::cmp::min(BXX, XXA);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
a, b = map(int, input().split())
a_max = (a + 1)/0.08
a_min = a / 0.08
b_max = (b + 1)/0.1
b_min = b / 0.1
u = 0
for i in range(int(b_max) + 1):
    if a_min <= i < a_max and b_min <= i < b_max:
        print(i)
        break
    else:
        u += 1
if u == int(b_max) + 1:
    print(-1)

Measured memory_bytes: 38548
// by syu
package main

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

var in = NewScanner(os.Stdin, 0)

func main() {
	N, X := in.Int(), in.Int()
	x := in.ArrayInt(N)
	x = append(x, X)
	sort.Ints(x)
	ans := x[1] - x[0]
	for i := 0; i < len(x)-1; i++ {
		gcd := Gcd(ans, x[i+1]-x[i])
		if gcd < ans {
			ans = gcd
		}
	}
	Pln(ans)
}

type Scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader, max int) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(scanWords)
	if max <= 0 {
		max = 1048576
	}
	s.Buffer([]byte{}, max)
	return &Scanner{s}
}
func (s *Scanner) Int() int {
	s.Scan()
	i, e := strconv.ParseInt(s.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}
func (s *Scanner) ArrayInt(n int) (r []int) {
	for i := 0; i < n; i++ {
		r = append(r, s.Int())
	}
	return
}
func isSpace(b byte) bool {
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}
func scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	start := 0
	for start < len(data) && isSpace(data[start]) {
		start++
	}
	for i := start; i < len(data); i++ {
		if isSpace(data[i]) {
			return i + 1, data[start:i], nil
		}
	}
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	return start, nil, nil
}
func Pln(s ...interface{}) {
	fmt.Println(s...)
}
func Gcd(a, b int) int {
	t := 0
	for b != 0 {
		t = a % b
		a = b
		b = t
	}
	return a
}


Measured memory_bytes: 6656
a,b,c,d=gets.split("").map &:to_s
a=(a+b).to_i
b=(c+d).to_i
ans1=1 if a>=1 && a<=12
ans2=1 if b>=1 && b<=12
if ans1==1 && ans2 ==1
  puts "AMBIGUOUS"
elsif ans1==1
  puts :MMYY
elsif ans2==1
  puts :YYMM
else
  puts :NA
end


Measured memory_bytes: 14176
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////
vector<vector<int> > fld;
void solve() {
	int H, W;
	cin >> H >> W;
	fld = vector<vector<int>>(H, vector<int>(W, INF));
	fld[0][0] = 1;
	//黒、だめ#
	int CNT = 0;//.の個数
	for (int h = 0; h < H; ++h) {
		string str;
		cin >> str;
		for (int w = 0; w < W; ++w) {
			if (str[w] == '#') {
				fld[h][w] = -1;
			}
			else {
				++CNT;
			}
		}
	}
	pair<int, int>temp;
	queue<pair<int, int>> Q;
	temp = { 0,0 };
	Q.push(temp);
	vector<int> dh = {1,0,-1,0};
	vector<int> dw = { 0,1,0,-1 };
	while (!Q.empty()) {
		temp = Q.front();
		Q.pop();
		int hh = temp.first;
		int ww = temp.second;
		//四方向
		for (int i = 0; i < 4; ++i) {
			int nh = hh + dh[i];
			int nw = ww + dw[i];
			if (nh < 0 || H <= nh || nw < 0 || W <= nw) {
				continue;
			}
			int now = fld[hh][ww];
			if (fld[nh][nw] == -1) {
				continue;
			}
			else if (fld[nh][nw] > now + 1) {
				fld[nh][nw] = now + 1;
				temp.first = nh;
				temp.second = nw;
				Q.push(temp);
			}
		}
	}
	if (fld[H - 1][W - 1] == INF) {
		cout << -1 << endl;
	}
	else {
		int ans = CNT - fld[H - 1][W - 1];
		cout << ans << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include<stdio.h>
int G[1000],g;
int c=0;
void sort(int A[],int n,int g){
	int i,v,j;
	for(i=g; i<n; i++){
		v=A[i];
		j=i-g;
		while(j>=0 && A[j]>v){
			A[j+g]=A[j];
			j=j-g;
			c++;
			}
		A[j+g]=v;
	}
}
void shell(int A[],int n){
	int v,p;
	G[0]=1;
	for(v=1; ; v++){
		G[v]=G[v-1]*3+1;
		if(G[v]>n){
			g=v-1;
			break;
		}
	}
	for(p=g; p>=0; p--){
		sort(A,n,G[p]);
		}
}
int main(void){
	int n,i,j;
	scanf("%d",&n);
	int A[n];
	for(i=0; i<n; i++){
		scanf("%d",&A[i]);
	}
	shell(A,n);
	printf("%d\n", g+1);
	for(i=g; i>=1; i--){printf("%d ",G[i]);}
	printf("%d\n",G[0]);
	printf("%d\n",c);
	for(i=0; i<n; i++){
		printf("%d\n",A[i]);
	}
	return 0;
}


Measured memory_bytes: 5592
// B.

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

using namespace std;

int main(int argc, char *argv[]) {
	int n, d;
	cin >> n >> d;
	vector<vector<int>> x(n);
	for (int i = 0; i < n; ++i) {
		x[i].resize(d);
		for (int j = 0; j < d; ++j) {
			cin >> x[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			int sum = 0;
			for (int k = 0; k < d; ++k) {
				sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			int r = (int)sqrt(sum + 1e-8);
			ans += (sum == r * r);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

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

    ll nc = n;
    int ans = 0;
    ll tmp = 0;
    ll mul = 1;;
    while(n >= 10) {
        ans += 9;
        tmp += 9 * mul;
        mul *= 10;
        n /= 10;
    }
    tmp += n * mul;
    ans += n;
    if (tmp > nc) ans--;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int N,x[2000],i,j,dis,dismax=0,ex=2000;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&x[i]);
  }
  for(i=0;i<=2000;i++){
    for(j=0;j<N;j++){
      dis=i-x[j];
      if(dis<0)dis*=-1;
      if(dis>dismax)dismax=dis;
    }
    if(ex<dismax)break;
    ex=dismax;
    dismax=0;
  }
  printf("%d\n",ex);
  return 0;
}



Measured memory_bytes: 2728
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    K_max = (N-1)*(N-2) // 2
    if K > K_max:
        print(-1)
        return

    res = [ (0,i) for i in range(1, N) ]
    e = []
    for i in range(1, N):
        for j in range(i+1, N):
            e.append((i, j))

    add_num = K_max - K
    for i in range(add_num):
        res.append(e[i])

    print(len(res))
    for i, j in res:
        print("{} {}".format(i+1, j+1))


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define N 2333
#define mod 1000000007

int n,k;
long long fac[N*N],inv[N*N],f[N][N];

long long c(int x,int y){
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();k=read();f[n][n]=1;
	if (k==1) {printf("1\n");return 0;}
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for (int i=2;i<N*N;i++) fac[i]=fac[i-1]*i%mod;
	for (int i=2;i<N*N;i++) inv[i]=-(mod/i)*inv[mod%i]%mod;
	for (int i=2;i<N*N;i++) inv[i]=inv[i-1]*(inv[i]+mod)%mod;
	for (int i=n;i>=0;i--)
		for (int j=i;j>=0;j--){
			f[i][j]=(f[i][j]+f[i+1][j])%mod;
			if (i>j) f[i][j]=(f[i][j]+f[i][j+1]*c((n-j)*k-(i-j)-1,k-2))%mod;
		}
	printf("%lld\n",f[0][0]*fac[n]%mod);
	return 0;
}

Measured memory_bytes: 122112
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
  int n;
  cin >> n;
  ll h[n];
  rep(i,n){
    cin >> h[i];
  }
  for(int i=n-1;i>0;i--){
    if(h[i]<h[i-1]-1){
      cout << "No" << endl;
      return 0;
    }
    else if(h[i]==h[i-1]-1){
      h[i-1]=h[i-1]-1;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; 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^48); c=getchar(); }
	return x*f;
}
PR a[MAXN];
int main()
{
	int n=read(),k=read(),s=read();
	for (int i=1;i<=k;i++) printf("%d ",s);
	for (int i=k+1;i<=n;i++) printf("%d%c",(s<1e9)?(int)1e9:1," \n"[i==n]);
	return 0;
}

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

int main(){
	string a, b, c;
	cin >> a >> b >> c;
	if(a.at(a.size()-1)==b.at(0) && b.at(b.size()-1)==c.at(0)){
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

vecl f(10001);

int main() {
    int N; cin >> N;
    for(int x = 1; x <= 100; x++) {
        for(int y = 1; y <= 100; y++) {
            for(int z = 1; z <= 100; z++) {
                ll ret = x*x+y*y+z*z+x*y+y*z+x*z;
                if(ret <= 10000) f[ret]++;
            }
        }
    }
    for(int i = 1; i <= N; i++) cout << f[i] << endl;
}

Measured memory_bytes: 3712
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h> 
int symbol[26]={0};
struct zm
{
	int a[100+10];
	int Size;
 } z[27];
int main()
{
	for(int i=0;i<=26;i++)
	{
		z[i].Size=1;
		z[i].a[0]=0;
	}
	char u[100+10];
	scanf("%s",u+1);
	int len=strlen(u+1);
	for(int i=1;i<=len;i++)
		z[u[i]-'a'].a[z[u[i]-'a'].Size++]=i;
	for(int i=0;i<=26;i++)
		z[i].a[z[i].Size++]=len+1;
	int min=100000000;
	for(int i=0;i<26;i++)
	{
		int maxx=-1;
		for(int k=1;k<z[i].Size;k++)
		{
			if(z[i].a[k]-z[i].a[k-1]-1>maxx)
				maxx=z[i].a[k]-z[i].a[k-1]-1;
		}
		if(maxx<min)
			min=maxx;
	}
	printf("%d\n",min);
    return 0;
 } 

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
using namespace std;

int main(void){
  long int N;
  cin >> N;
  long int X[N];
  long int i,j=0;
  while(cin >> X[i]){
    i++;
  }
  
  long int W=0;
  long int sum[100];
  
  for(i=0;i<100;i++){
  sum[i]=0;
  }
  
  long int t=X[0],p=X[0],k;
  
  
  for(i=0;i<N;i++){
  if(t < X[i]) t=X[i];
    if(p > X[i]) p=X[i];
  }
  
  for(i=p;i<=t;i++){
  for(j=0;j<N;j++){
    k=abs(X[j]-i);
  	sum[i]+=k*k;
    
  }
  }
  
  for(W=sum[p],i=p;i<t;i++){
  if(W>sum[i]) W=sum[i];
  }
  
  cout << W << endl;
  
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
long long MOD = 1000000007;
long long modpow(long long a, long long b){
	long long ans = 1;
	while (b > 0){
		if (b % 2 == 1){
			ans *= a;
			ans %= MOD;
		}
		a *= a;
		a %= MOD;
		b /= 2;
	}
	return ans;
}
long long modinv(long long a){
	return modpow(a, MOD - 2);
}
int main(){
	int N;
	cin >> N;
	string s;
	cin >> s;
	int M = s.size();
	vector<vector<long long>> dp(N + 1, vector<long long>(N + 1, 0));
	dp[0][0] = 1;
	for (int i = 0; i < N; i++){
		for (int j = 0; j <= i; j++){
			dp[i + 1][max(j - 1, 0)] += dp[i][j];
			dp[i + 1][max(j - 1, 0)] %= MOD;
			dp[i + 1][j + 1] += dp[i][j] * 2;
			dp[i + 1][j + 1] %= MOD;
		}
	}
	cout << dp[N][M] * modinv(modpow(2, M)) % MOD << endl;
}

Measured memory_bytes: 198848
<?php

fscanf(STDIN, '%d %d', $n, $m);
$s = [];
$c = [];

$bucket = [];
for ($i = 1; $i <= $n; $i++) {
    $bucket[$i] = -1;
}

$flg = true;
for ($i = 0; $i < $m; $i++) {
    fscanf(STDIN, '%d %d', $s, $c);

    if ($s > $n) {
        $flg = false;
        break;
    } else {
        if ($n > 1 && $s == 1 && $c == 0) {
            $flg = false;
            break;
        } elseif ($bucket[$s] == -1) {

            $bucket[$s] = $c;
        } else {
            if ($bucket[$s] != $c) {
                $flg = false;
                break;
            }
        }
    }

}

//var_dump($bucket);

//$bucket = [];

if ($flg){
    if ($n == 1) {

        if ($bucket[1] == -1){
            echo '0'.PHP_EOL;exit;
        }
        echo $bucket['1'] . PHP_EOL;
        exit;
    }
    if ($n>1 && $bucket[1] == -1) {
        $bucket[1] = 1;
    }
    for ($i = 1; $i <= $n; $i++) {

        if ($bucket[$i] == -1){
            $bucket[$i] = 0;
        }
    }
} else{
    echo '-1'.PHP_EOL;exit;
}

echo implode('',$bucket).PHP_EOL;


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

int main(){
    int n, k;
    cin >> n >> k;
    map<int, int> mp;
    rep(i, n) {
        int a;
        cin >> a;
        mp[a]++;
    }
    vector<int> cnt;
    for (auto p: mp) {
        cnt.push_back(p.second);
    }
    sort(all(cnt), greater<>());
    int ans = n;
    rep(i, cnt.size()) {
        if (i >= k) break;
        ans -= cnt[i];
    }
    cout << ans << endl;
    return 0;
}

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

const int mod = 1000000007;
//const int mod = 998244353;
const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dj[] = {0, -1, 0, 1, -1, 1, -1, 1};

struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 0, n-1){
        string p, q;
        p = s.substr(0, i+1);
        q = s.substr(i+1, n);
        map<char, bool> mp, r;
        int cnt = 0;
        rep(j, 0, p.size()){
            mp[p[j]] = true;
        }
        rep(j, 0, q.size()){
            if(r[q[j]]) continue;
            if(mp[q[j]] == true) cnt++;
            r[q[j]] = true;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<math.h>
	using namespace std;
	
	bool check(int a){//aが素数かどうか
		
		if(a<=1)return false;
			int s=sqrt(a);
		for(int i=2;i<=s;i++){
			if(a%i==0)return false;
		}
		return true;
	}
	
/*bool check(int a){//a画素数かどうか
		int s=sqrt(a);
		vector<int>m;//aの平方根の範囲での素数
		for(int i=1;i<=s;i++){
			if(checkOf(i))m.push_back(i);
		}
		for(int i=0;i<m.size();i++)cout<<m[i]<<" ";
		for(int i=0;i<m.size();i++){
			if(a%m[i]==0)return false;
		}
		return true;
	}*/
	
	
	
int main(){
	int n[10000];
	int N;
	cin>>N;
	int count=0;
	for(int i=0;i<N;i++)cin>>n[i];
	for(int i=0;i<N;i++){
		if(check(n[i]))count++;
	}
	cout<<count<<endl;

	return 0;
}

Measured memory_bytes: 1196
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//English Sentences
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Map<String, Integer> m = new HashMap<String, Integer>();
		int mc = 0;
		String fre = "";
		String max = "";
		while(sc.hasNext()){
			String s = sc.next();
			if(max.length() < s.length())max = s;
			if(m.containsKey(s)){
				int c = m.get(s);
				if(mc < c+1){
					mc = c+1;
					fre = s;
				}
				m.put(s, c+1);
			}
			else{
				if(mc < 1){
					mc = 1;
					fre = s;
				}
				m.put(s, 1);
			}
		}
		System.out.println(fre + " " + max);
	}
}

Measured memory_bytes: 12000