akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int N = readInt(reader);
            int[] A = readIntArray(reader);

            int[] order = new int[N];
            for (int i = 0; i < N; i++) {
                order[A[i] - 1] = i + 1;
            }

            StringBuilder sb = new StringBuilder();
            sb.append(order[0]);
            for (int i = 1; i < N; i++) {
                sb.append(" ").append(order[i]);
            }
            System.out.println(sb.toString());
        }
    }

    public static int readInt(BufferedReader reader) throws Exception {
        return Integer.parseInt(reader.readLine());
    }

    public static int[] readIntArray(BufferedReader reader) throws Exception {
        String[] str = reader.readLine().split(" ");
        int[] array = new int[str.length];
        for (int i = 0; i < str.length; i++) {
            array[i] = Integer.parseInt(str[i]);
        }
        return array;
    }

}


Measured memory_bytes: 42588
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define IN4(P1,P2,P3,P4) cin>>(P1)>>(P2)>>(P3)>>(P4)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int N,K,X,Y;
inline void solve(){
  IN4(N,K,X,Y);
  OUT(min(K,N)*X+max(N-K,0)*Y);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main() {
	vector<int> A(6);
	for (int i = 0; i < 6; i++) {
		cin >> A[i];
	}
	int ans = 0;
	for (int i = 0; i < 4; i++) {
		for (int j = i + 1; j < 5; j++) {
			if ((A[j] - A[i]) > A[5])ans++;
		}
	}
	if (ans == 0) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <algorithm>
#include <cmath>

#define ll long long

using namespace std;

int main(int argc, char *argv[])
{
  ll A, B, C;
  cin >> A >> B >> C;
  if (A + B + C == 17) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#define mp make_pair
#define pb push_back
#define INF 100000005
#define rep(i,n) for(int i = 0;i < n;i++)
using namespace std;
typedef pair<int,int> PI;
int n;
bool erased[805];
vector<PI> G[805];
int dist[805];
void dfs(int s){
    rep(i,G[s].size()){
        int to=G[s][i].first;
        if(!erased[to]&&dist[to]>=INF){
            dist[to]=G[s][i].second+dist[s];
            dfs(to);
        }
    }
}


int main(){
    while(1){
        int temp;
        int t[805],ans=0;
        cin>>n;
        if(!n){
            break;
        }
        rep(i,n){
            erased[i]=false;
            G[i].clear();
        }
        rep(i,n-1){
            cin>>t[i];
            t[i]--;
        }
        rep(i,n-1){
            cin>>temp;
            ans+=temp*3;
            G[i+1].pb(mp(t[i],temp));
            G[t[i]].pb(mp(i+1,temp));
        }
        int start = 0;
        rep(i,n){
            if(G[i].size()==1){
                ans-=G[i][0].second*2;
                erased[i]=1;
                if(i==start){
                    start++;
                }
            }
        }
        fill(dist,dist+n,INF);
        dist[start]=0;
        dfs(start);
        rep(i,n){
            if(!erased[i]&&dist[i]>dist[start])start=i;
        }
        fill(dist,dist+n,INF);
        dist[start]=0;
        dfs(start);
        int hoge = 0;
        rep(i,n){
            if(!erased[i]){
                hoge = max(hoge,dist[i]);
            }
        }
        ans -= hoge;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1332
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    cout.precision(18);

    long long X, Y;
    cin >> X >> Y;

    long long c = abs(abs(X) - abs(Y));
    if (X == 0 && Y < 0)
        c++;
    else if (Y == 0 && X > 0)
        c++;
    else if (X * Y < 0)
        c++;
    else if (X > 0)
    {
        if (X > Y)
            c += 2;
    }
    else if (X < 0)
    {
        if (X > Y)
            c += 2;
    }

    cout << c << endl;
}

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

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vecll var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl
#define prseq(var, n)    rep(i,n){cout << var[i] << " ";} cout << endl
#define prseql(var, n)   rep(i,n){cout << var[i] << " " << endl;}

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

int main(void) {
  int n;
  cin >> n;
  arrll(h,n);

  if(n==1){
    prt("Yes"); return 0;
  }

  rep(i,n-1){
    if(h[n-i-2]-h[n-i-1]>1){
      prt("No"); return 0;
    } else if (h[n-i-2]-h[n-i-1]==1){
      h[n-i-2]--;
    }
  }

  prt("Yes");

}

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

int main(){
	int a[5];
	for(int i = 0;i < 5;i++)cin >> a[i];
	sort(a, a+5);
	reverse(a, a+5);
	for(int i = 0;i < 4;i++)cout << a[i] << " ";
	cout << a[4] << endl;
	return 0; 
}

Measured memory_bytes: 3120
import java.util.Scanner;

/**
 * Created by Reopard on 2014/05/06.
 */
public class Main {
    public static void main(String args[]){
        int debt = 100000;
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for(int i = 0; i < n; i++){
            debt += debt*0.05;
            if(debt % 1000 > 0){
                debt -= debt % 1000;
                debt += 1000;
            }
        }
        System.out.println(debt);
    }
}

Measured memory_bytes: 17148
N, K = ARGF.gets.chomp.split.collect {|el| el.to_i}

aa = ARGF.gets.chomp.split.collect {|el| el.to_i}


kt = 0
ai = 0

tn = Array.new(N)
tn[0] = 0

tl = [1]
ti = 1

spi = nil
epi = nil
K.times do |ki|
  nti = aa[ti - 1]
  aa[ti - 1] = nil
  if nti.nil?
    spi = tn[ti - 1]
    epi = ki
    ti = nil
    break
  end
  tn[ti - 1] = ki
  tl << nti
  ti = nti
end

# p aa
# p tl
# p tn
# p spi
# p epi

if ti.nil?
  kn = (K - spi) % (epi - spi)
  ti = tl[spi + kn]
end

puts ti


Measured memory_bytes: 31528
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

#define ll long long

int main() {
	int N; cin >> N;
	vector<pair<int, int>> v(N+1);
	bool flag=false;
	for(int i=1; i<=N; ++i){
	    int B; cin >> B;
	    v[i]=make_pair(i, B);
	    if(i<B) flag=true;
	}
	if(flag){
	    cout << -1 << endl;
	    return 0;
	}
	vector<bool> bit(N+1, false);
	vector<int> ans(N);
	for(int cnt=0; cnt<N; ++cnt){
	    int se=N;
	    while(bit[se] || v[se].first>v[se].second){
	        if(!bit[se]) --v[se].first;
	        --se;
	    }
	    ans[N-cnt-1]=v[se].second;
	    bit[se]=true;
	}
	for(int i=0; i<N; ++i) cout << ans[i] << endl;
	return 0;
}


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


int main(void){
    int i;
    char *tok;
    char text[20];
    char year[20];
    char mouth[20];
    char date[20];
    
    for(i = 0; i < 20; i++){
        text[i] = '\0';
        year[i] = '\0';
        mouth[i] = '\0';
        date[i] = '\0';
    }
    scanf("%s", text);
    tok = strtok(text, "/");
    strcpy(year, tok);
    tok = strtok(NULL, "/");
    if(tok != NULL){
        strcpy(mouth, tok);
    }
    tok = strtok(NULL, "/");
    if(tok != NULL){
        strcpy(date, tok);
    }
    if(strcmp(year, "2017") == 0){
        strcpy(year, "2018");
    }
    printf("%s/%s/%s\n", year, mouth, date);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	LL A,B,K;
	cin>>A>>B>>K;
	if(A<=K){
		K-=A;
		A=0;
		B=max(B-K,(LL)0);
	}else{
		A-=K;
	}
	cout<<A<<" "<<B<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

	double a,b,c,d,e,f;
        double x,y;

	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){

		if(b!=0){
		    x=((e*c/b)-f)/((e*a/b)-d);
		}
		else{
                x=c/a;
		}

		if(a!=0){
		y=((d*c/a)-f)/((d*b/a)-e);
		}
		else{
			y=c/b;
		}

		x=x*1000,y=y*1000;
		if(x>0){
			x=(double)(int)(x+0.5);
		}
		else{
			x=(double)(int)(x-0.5);
		}
		if(y>0){
			y=(double)(int)(y+0.5);
		}
		else{
			y=(double)(int)(y-0.5);
		}
		x=x/1000;y=y/1000;
		printf("%.3f %.3f\n",x,y);
	}

	return 0;
}



Measured memory_bytes: 2044
#include <stdio.h>
#include <string.h>
int main(){
  char a[51],p[6]= {"KIHBR"};
  int i,b,fla=1,m,sum=0,ok=0,akiba=0,w=0;
  scanf("%s",&a);
  b = strlen(a);
  if(b>9){
    fla =0;
  }
  if(fla){
  for(i=0;i<b;i++){
    if(ok>1){   //AA連続弾き
      fla =0;
      break;
    }
    if(sum=='K'||sum=='K'+'I'){
      if(a[i]=='A'){
        fla =0;
        break;
      }
      }
    if(w){
      if(akiba != sum){  //KIHBRの順番正しいか
        fla =0;
        break;
      }
    }
  for(m=0;m<5;m++){
    if(a[i]==p[m]){
      sum = sum + p[m]; //KIHBRがあるかどうか
      ok = 0;
      akiba += p[w];
      w++;
      break;
    }
    else if(a[i]=='A'){
      ok++;
      break;
    }
    if(m ==4)fla = 0;//違うの弾き
  }
  }
  }
  if(sum != 368)fla =0;
   if(fla)puts("YES");
   else puts("NO");
  return 0;
}

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

using namespace std;

int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  int ans=0;
  for(int i=0;i<n;i++){
    if(i%2==0){
      ans+=a[n-i-1];
    }else{
      ans-=a[n-i-1];
    }
  }
  cout<<ans<<endl;
}
  


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

int main() {
	string s = "CODEFESTIVAL2016";
	string t;

	cin >> t;

	int res = 0;

	for (int i = 0; i < 16; i++) if (s[i] != t[i]) res++;

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

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX], n;
    
    cin>>n;
    for(int i=0; i<n; i++) cin >> R[i];
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i=1; i<n; i++){
        maxv = max(maxv, R[i]-minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 3896
# 6199094

import array
import sys
input = sys.stdin.readline

class UnionFind():
    def __init__(self,n):
        self.parent = [-1 for _ in range(n)]

    def size(self,x):
        return -self.parent[self.find(x)]

    def find(self,x):
        if(self.parent[x]<0):
            return x
        else:
            self.parent[x]=self.find(self.parent[x])
            return self.parent[x]

    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if(x == y):
            return False
        if(self.size(x)<self.size(y)):
            self.parent[y]+=self.parent[x]
            self.parent[x]=y
        else:
            self.parent[x]+=self.parent[y]
            self.parent[y]=x
        return True

    def same(self,x,y):
        return self.find(x)==self.find(y)

def main():
    N = int(input())
    xli = []
    yli = []
    x_app = xli.append
    y_app = yli.append


    for i in range(N):
        x,y = (int(x) for x in input().split())
        x_app([x-1,i])
        y_app([y-1,i])
    xli.sort()
    yli.sort()

    edges = []
    edges_app = edges.append
    for i in range(N-1):
        edges_app((xli[i][1],xli[i+1][1],xli[i+1][0]-xli[i][0]))
        edges_app((yli[i][1],yli[i+1][1],yli[i+1][0]-yli[i][0]))


    edges.sort(key=lambda edge: edge[2])
    uf = UnionFind(N)
    weight = 0

    for edge in edges:
        if not uf.same(edge[0], edge[1]):
            uf.unite(edge[0], edge[1])
            weight+=edge[2]
    print(weight)

if __name__ == '__main__':
    main()


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

int main()
{
    int N, C, K;
    cin >> N >> C >> K;
    vector<int> T(N, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> T[i];
    }
    sort(T.begin(), T.end());
    int ans = 1, t = T[0], c = 0;
    for (int i = 0; i < N; i++)
    {
        if (c == C)
        {
            c = 0;
            ans++;
            t = T[i];
        }
        if (T[i] <= t + K)
        {
            c++;
        }
        else
        {
            t = T[i];
            ans++;
            c = 1;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main()
{
	int n,k,s;
	scanf("%d %d %d",&n,&k,&s);
	for(int i=1;i<=n;i++)
	{
		if(k>0)
		printf("%d ",s);
		else
		if(s==1000000000)
		printf("1 ");
		else
		printf("%d ",s+1);
		k--;
	}
	return 0;
 } 

Measured memory_bytes: 1280
object Main {
  def main(args: Array[String]): Unit = {
    val in = io.Source.stdin.getLines().next.toInt
    val h = in / (60 * 60)
    val m = (in % (60 * 60)) / 60
    val s = (in % (60 * 60)) % 60
    println(s"${h}:${m}:${s}")
  }
}


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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void chmin(int &a, int b){
  if(a > b)
    a = b;
}
void chmax(int &a, int b){
  if(a < b)
    a = b;
}

void llchmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  bool check = false;
  
  if(a == b || b == c || c == a){
    if(a ==b && b == c){}
    else
      check = true;
  }
  
  if(check)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
  
}

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

int main(){

    while(1){
        int N, M, P;
        cin>> N>> M>> P;
        if(!(N||M||P)) break;
        int X[N];
        for(int i=0; i<N; i++) cin>> X[i];

        int s=100*accumulate(X, X+N, 0);
        int haito=s/100*(100-P);

        cout<< (X[M-1]==0? 0: haito/X[M-1])<< endl;
    }
    
    return 0;
}

Measured memory_bytes: 3088
/*
读题不规范，爆零两行泪。
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int inf=0x3f3f3f3f3f3f3f3f;
int n,a,b,c,d;
map<int,int> mp;
int dfs(int x){
	if(x==0)return 0;
	int &res=mp[x];
	if(res)return res;
	res=x<=1.*LLONG_MAX/d?x*d:inf;
	if(x<=100)res=min(res,dfs(x-1)+d);
	if((x+2-1)/2<x)res=min(res,dfs((x+2-1)/2)+(2-x%2)%2*d+a);
	if((x+3-1)/3<x)res=min(res,dfs((x+3-1)/3)+(3-x%3)%3*d+b);
	if((x+5-1)/5<x)res=min(res,dfs((x+5-1)/5)+(5-x%5)%5*d+c);
//	if((x+2-1)/2<x&&x-(x+2-1)/2<=1.*LLONG_MAX/d)res=min(res,dfs((x+2-1)/2)+(x-(x+2-1)/2)*d);
//	if((x+3-1)/3<x&&x-(x+3-1)/3<=1.*LLONG_MAX/d)res=min(res,dfs((x+3-1)/3)+(x-(x+3-1)/3)*d);
//	if((x+5-1)/5<x&&x-(x+5-1)/5<=1.*LLONG_MAX/d)res=min(res,dfs((x+5-1)/5)+(x-(x+5-1)/5)*d);
	//-----------------------------------------------------------------------------------
	if(x/2<x)res=min(res,dfs(x/2)+x%2*d+a);
	if(x/3<x)res=min(res,dfs(x/3)+x%3*d+b);
	if(x/5<x)res=min(res,dfs(x/5)+x%5*d+c);
//	if(x/2<x&&x-x/2<=1.*LLONG_MAX/d)res=min(res,dfs(x/2)+(x-x/2)*d);
//	if(x/3<x&&x-x/3<=1.*LLONG_MAX/d)res=min(res,dfs(x/3)+(x-x/3)*d);
//	if(x/5<x&&x-x/5<=1.*LLONG_MAX/d)res=min(res,dfs(x/5)+(x-x/5)*d);
	//-----------------------------------------------------------------------------------
	if((x+2-1)/2+1<x)res=min(res,dfs((x+2-1)/2+1)+(2-x%2)%2*d+2*d+a);
	if((x+3-1)/3+1<x)res=min(res,dfs((x+3-1)/3+1)+(3-x%3)%3*d+3*d+b);
	if((x+5-1)/5+1<x)res=min(res,dfs((x+5-1)/5+1)+(5-x%5)%5*d+5*d+c);
//	if((x+2-1)/2+1<x&&x-(x+2-1)/2-1<=1.*LLONG_MAX/d)res=min(res,dfs((x+2-1)/2+1)+(x-(x+2-1)/2-1)*d);
//	if((x+3-1)/3+1<x&&x-(x+3-1)/3-1<=1.*LLONG_MAX/d)res=min(res,dfs((x+3-1)/3+1)+(x-(x+3-1)/3-1)*d);
//	if((x+5-1)/5+1<x&&x-(x+5-1)/5-1<=1.*LLONG_MAX/d)res=min(res,dfs((x+5-1)/5+1)+(x-(x+5-1)/5-1)*d);
	//-----------------------------------------------------------------------------------
	if(0<=x/2-1&&x/2-1<x)res=min(res,dfs(x/2-1)+x%2*d+2*d+a);
	if(0<=x/3-1&&x/3-1<x)res=min(res,dfs(x/3-1)+x%3*d+3*d+b);
	if(0<=x/5-1&&x/5-1<x)res=min(res,dfs(x/5-1)+x%5*d+5*d+c);
//	if(0<=x/2-1&&x/2-1<x&&x-x/2+1<=1.*LLONG_MAX/d)res=min(res,dfs(x/2-1)+(x-x/2+1)*d);
//	if(0<=x/3-1&&x/3-1<x&&x-x/3+1<=1.*LLONG_MAX/d)res=min(res,dfs(x/3-1)+(x-x/3+1)*d);
//	if(0<=x/5-1&&x/5-1<x&&x-x/5+1<=1.*LLONG_MAX/d)res=min(res,dfs(x/5-1)+(x-x/5+1)*d);
	return res;
}
void mian(){
	mp.clear();
	cin>>n>>a>>b>>c>>d;
	cout<<dfs(n)<<"\n";
}
signed main(){
	int testnum;
	cin>>testnum;
	while(testnum--)mian();
	return 0;
}

Measured memory_bytes: 5816
tile = input()

cor_list = ["10"*50000, "01"*50000]

diff_1 = int("0b"+tile, 2) ^ int("0b"+cor_list[0][:len(tile)], 2)  
diff_2 = int("0b"+tile, 2) ^ int("0b"+cor_list[1][:len(tile)], 2)

score = [0, 0]
score[0] = sum([int(s) for s in bin(diff_1)[2:]])
score[1] = sum([int(s) for s in bin(diff_2)[2:]])

print(min(score))

Measured memory_bytes: 4492
import java.util.Scanner;

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();
        }
        int count = bubbleSort(arr);
        printArray(arr);
        System.out.println(count);
    }

    static int bubbleSort(int[] arr) {
        int counter = 0;
        int n = arr.length;
        boolean flag = true;
        while (flag) {
            flag = false;
            for (int j = n - 1; j > 0; j--) {
                if (arr[j] < arr[j - 1]) {
                    int tmp = arr[j - 1];
                    arr[j - 1] = arr[j];
                    arr[j] = tmp;
                    counter++;
                    flag = true;
                }
            }
        }
        return counter;
    }


    static void printArray(int[] arr) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < arr.length - 1; i++) {
            sb.append(arr[i]);
            sb.append(" ");
        }
        sb.append(arr[arr.length - 1]);
        System.out.println(sb.toString());
    }
}



Measured memory_bytes: 26348
#include <cmath>

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

#include <set>

using namespace std;

typedef long long ll;

constexpr int sz = (int)2e5 + 10;

int n;

ll ans;

int a[sz];
ll b[sz];

int cnt[sz];

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

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

  cin >> n;

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

    cnt[a[i]]++;
  }

  for (int i = 1; i <= sz; ++i) {
    if (!cnt[i])
      continue;

    b[i] = (1ll * cnt[i] * (cnt[i] - 1)) / 2;

    ans += b[i];
  }

  for (int i = 0; i < n; ++i) {
    ll prev = ans;

    ans -= b[a[i]];

    cnt[a[i]]--;

    ans += (1ll * cnt[a[i]] * (cnt[a[i]] - 1)) / 2;

    cnt[a[i]]++;

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


Measured memory_bytes: 4736
using System;
using System.Collections.Generic;
class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]), m = int.Parse(input[1]);
            
            int ans = n * 100 + m * 1800;
            ans <<= m;

            Console.WriteLine(ans);
            
            


            
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 13140
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fill(x,c) memset(x,c,sizeof(x))
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=100000000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int SIZE = 1e6+10;
int main() {
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll h,n;
	cin>>h>>n;
	ll dp[10010];
	ll A[1010],B[1010]; 
	rep(i,1,n+1){
		cin>>A[i]>>B[i];
	}
	dp[0] = 0;
	for(int i=1;i<=h;i++){
		dp[i] = 1000000000;
		for(int j=1;j<=n;j++){
			dp[i] = min(dp[i],dp[max((ll)0,i-A[j])]+B[j]);
		}
	} 
	cout<<dp[h];
  	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int xp0 = sc.nextInt();
		int yp0 = sc.nextInt();
		int xp1 = sc.nextInt();
		int yp1 = sc.nextInt();

		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			int xp2 = sc.nextInt();
			int yp2 = sc.nextInt();

			int ax = xp1 - xp0;
			int ay = yp1 - yp0;
			int bx = xp2 - xp0;
			int by = yp2 - yp0;
			int dot = Geom.dot(ax, ay, bx, by);
			int cross = Geom.cross(ax, ay, bx, by);
			int a2 = Geom.sumofsquare(ax, ay);

			if (cross > 0) {
				System.out.println("COUNTER_CLOCKWISE");
			} else if (cross < 0) {
				System.out.println("CLOCKWISE");
			} else {
				if (dot < 0) {
					System.out.println("ONLINE_BACK");
				} else if (dot > a2) {
					System.out.println("ONLINE_FRONT");
				} else {
					System.out.println("ON_SEGMENT");
				}
			}
		}

		sc.close();
	}
	
	private static class Geom {
		static int dot(int xa, int ya, int xb, int yb) {
			return xa * xb + ya * yb;
		}

		static int cross(int xa, int ya, int xb, int yb) {
			return xa * yb - xb * ya;
		}
		
		static int sumofsquare(int xa, int ya) {
			return xa * xa + ya * ya;
		}
	}
}

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

const char NL = '\n';
const char SP = ' ';
#define loop(i, a, b) for (int i = a; i < b; i++)

int main () {
    ios_base::sync_with_stdio(false);
    int x;
	cin >> x;
	x /= 100;
	if (x < 6) {
		cout << "8\n";
	}
	else if (x < 8) {
		cout << "7\n";
	}
	else if (x < 10) {
		cout << "6\n";
	}
	else if (x < 12) {
		cout << "5\n";
	}
	else if (x < 14) {
		cout << "4\n";
	}
	else if (x < 16) {
		cout << "3\n";
	}
	else if (x < 18) {
		cout << "2\n";
	}
	else if (x < 20) {
		cout << "1\n";
	}
    
    return 0;
}

Measured memory_bytes: 3636
N = int(input())
A = []

for _ in range(N):
  A.append(int(input()))

ans = sum(A)

if ans % 10 == 0:
  A.sort()
  for i in A:
    if(i % 10 != 0):
      ans -= i
      break;

print(ans if (ans % 10 != 0) else 0)

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N;
    if (N == 1) {
        cout << "Hello World" << endl;
    } else {
        cin >> A >> B;
        cout << A + B << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
*a, = map(int,input().split())
bc =[list(map(int,input().split()))for _ in [0]*m]
 
a.sort()
bc.sort(key=lambda x:-x[1])
i =0
for b,c in bc:
    for j in range(i,min(n,i+b)):
        if a[j]< c:a[j]=c
    i = i+b
print(sum(a))

Measured memory_bytes: 36076
#include<bits/stdc++.h>
#define cs const
using namespace std;
cs int Mod = 1e9 + 7, iv2 = (Mod+1)>>1;
int add(int a, int b){ return a + b >= Mod ? a + b - Mod : a + b; }
int dec(int a, int b){ return a - b < 0 ? a - b + Mod : a - b; }
int mul(int a, int b){ return 1ll * a * b % Mod; }
void Add(int &a, int b){ a = add(a,b); }
void Dec(int &a, int b){ a = dec(a,b); }
void Mul(int &a, int b){ a = mul(a,b); }
cs int N = 3e3 + 50;
int n, m, a[N], dp[N][N];
int main(){
//	freopen("1.in","r",stdin);
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; i++) scanf("%d",&a[i]);
	for(int i=1; i<=n; i++)
	for(int j=1; j<=n; j++) 
	if(a[i]<a[j]) dp[i][j]=1; int coe=1;
	for(int i=1,x,y; i<=m; i++){
		scanf("%d%d",&x,&y); Mul(coe,2);
		dp[x][y]=dp[y][x]=mul(iv2,add(dp[x][y],dp[y][x]));
		for(int j=1; j<=n; j++) if(j!=x&&j!=y){
			dp[x][j]=dp[y][j]=mul(iv2,add(dp[x][j],dp[y][j]));
			dp[j][x]=dp[j][y]=mul(iv2,add(dp[j][x],dp[j][y]));
		} 
	} 
	int as = 0;
	for(int i=1; i<=n; i++)
	for(int j=1; j<i; j++) Add(as,dp[i][j]);
	cout<<mul(as,coe); return 0;
}

Measured memory_bytes: 35968
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k==x:
                ans+=1
print(ans)

Measured memory_bytes: 9192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

        Scanner sc= new Scanner( System.in );

		String str="";
		String in_str="";
		String w_str="";

        str = sc.nextLine();
        in_str = sc.nextLine();

        w_str = str + str;

		if ( w_str.contains( in_str ) ) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
		
		sc.close();
	}
}



Measured memory_bytes: 26272
#include<bits/stdc++.h>
	using namespace std;
	string a; 
	int cnt; 
	int ans; 
	int n, k, r, s, p; 
	int main (){
		cin >> n >> k; 
		cin >> r >> s >> p; 
		cin >> a; 
		for(int i = 0; i < n; i ++){
		  if(a[i] == 'r'){
				cnt = p; 
			}
			else if(a[i] == 's'){
				cnt = r; 
			}
			else if(a[i] == 'p'){
				cnt = s; 
			}
			if(i >= k and a[i] == a[i - k]){ 
	           		cnt = 0; 
	           		a[i] = ' ';
			}
			ans += cnt;
		}
		cout << ans; 
	}

Measured memory_bytes: 512
""" AtCoder """

S = input()
S = S[:-1]
s_len = len(S)
for i in range(s_len):
    S = S[:-1]
    ans = len(S)
    if ans % 2 == 0:
        if S[:ans//2] == S[ans//2:]:
            print(ans)
            exit()


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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;


int main() {

   int k,x;
   string s;
   cin>>k>>s;
   x=s.size();
   if(x<=k){
       cout<<s<<endl;
   }
   else{
       cout<<s.erase(k)<<"..."<<endl;
   }
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int TC = sc.nextInt();
        
        while (TC-- > 0) {
            String str = sc.next();
            int L = str.length();
            
            HashSet<String> set = new HashSet<String>();
            set.add(str);
            
            for (int i = 1; i < L; i++) {
                StringBuilder str1 = new StringBuilder(str.substring(0, i));
                StringBuilder str2 = new StringBuilder(str.substring(i));
                // System.out.println(str1.toString() + " " + str2.toString());
                
                String s1 = str1.toString();
                String s2 = str2.toString();
                String r1 = str1.reverse().toString();
                String r2 = str2.reverse().toString();
                
                set.add(s1 + r2);
                set.add(r1 + s2);
                set.add(r1 + r2);
                
                set.add(s2 + s1);
                set.add(s2 + r1);
                set.add(r2 + s1);
                set.add(r2 + r1);
            }
            
            System.out.println(set.size());
        }
    }
}




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

int main()
{
    string s,s1;//s=source s1=kid
    getline(cin,s);
    getline(cin,s1);
    const int lens=s.length();
    const int lens1=s1.length();
    int match=0;
    for(int i=0;i<lens-lens1+1;i++)
    {
        int temp_match=0;
        for(int j=0;j<lens1;j++)
        {
            if(s.at(i+j)==s1.at(j))
            temp_match++;
        }
        match=(temp_match>match)?temp_match:match;
    }
    cout<<lens1-match<<endl;


 return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in(),K = in();
    vector<int> l(N);
    REP(i,N)l[i] = in();
    sort(ALL(l),greater<>());
    ll answer = 0;
    REP(i,K)answer += l[i];
    cout << answer << "\n";
}

Measured memory_bytes: 256
#include <iostream>
typedef long long int ll;
using namespace std;
#define P 998244353
#define N_MAX 300000
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
    return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
    fac[0] = 1;
    finv[0] = 1;
    fac[1] = 1;
    finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i <= N_MAX; i++){
        fac[i] = (fac[i-1]*i)%P;
        inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
        finv[i] = (finv[i-1]*inv[i])%P;
    }
}

int main(){
    init();
    ll N, A, B, K, ans =0;
    std::cin >> N >> A >> B >> K;
    for(ll i=0;i<N+1;i++){
      ll j = (K - A * i)/B;
      if((K-A*i)%B == 0 && j <= N && j >= 0){
        ans = (ans + comb(N, i) * comb(N, j))%P;
      }
    }
    std::cout << ans << '\n';
}


Measured memory_bytes: 7296
#include <stdio.h>
#include <math.h>
 
int main(void){
  int A,B,C;
  scanf("%d\n",&A);
  scanf("%d\n",&B);
  scanf("%d\n",&C);
  if((A==B && A!=C)||(A==C && A!=B)||(B==C && B!=A)){
    printf("Yes");
  }
  else{
    printf("No");
  }
}

Measured memory_bytes: 128
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n, m;
	int s, g;
	LinkedList<E>[] es;

	@SuppressWarnings("unchecked")
	void run(){
		for(;;){
			n=sc.nextInt();
			m=sc.nextInt();
			if((n|m)==0){
				break;
			}
			es=new LinkedList[n];
			for(int i=0; i<n; i++){
				es[i]=new LinkedList<E>();
			}
			s=sc.nextInt()-1;
			g=sc.nextInt()-1;
			for(int i=0; i<m; i++){
				int x=sc.nextInt()-1;
				int y=sc.nextInt()-1;
				int d=sc.nextInt();
				int c=sc.nextInt();
				es[x].add(new E(y, d, c));
				es[y].add(new E(x, d, c));
			}
			solve();
		}
	}

	void solve(){
		double[][][] d=new double[n][n][40];
		PriorityQueue<P> que=new PriorityQueue<P>();
		for(int j=0; j<n; j++){
			for(int i=0; i<n; i++){
				fill(d[j][i], INF);
			}
		}
		// Uツタツーツδ督づ債凝鳴止
		// [ツ前][ツ債。][ツ陳つ「ツつスツ瞬ツ甘板づ個堕ャツ度]
		d[s][s][1]=0;
		que.offer(new P(s, s, 0, 0));
		for(; !que.isEmpty();){
			P p=que.poll();
			// debug(p.q, p.p, p.v,p.d);
			if(d[p.q][p.p][p.v]+EPS<p.d){
				continue;
			}
			for(E e : es[p.p]){
				if(p.q==e.to){
					continue;
				}
				for(int i=-1; i<=1; i++){
					if(p.v+i<=0||p.v+i>e.c){
						continue;
					}
					if(d[p.p][e.to][p.v+i]>p.d+(double)e.d/(p.v+i)+EPS){
						d[p.p][e.to][p.v+i]=p.d+(double)e.d/(p.v+i);
						que.offer(new P(p.p, e.to, p.v+i, d[p.p][e.to][p.v+i]));
					}
				}
			}
		}
		double min=INF;
		for(int i=0; i<n; i++){
			min=min(min, d[i][g][1]);
		}
		// debug(min);
		println(""+(min<INF/2?min:"unreachable"));
	}

	class E{
		int to, d, c;

		E(int to, int d, int c){
			this.to=to;
			this.d=d;
			this.c=c;
		}
	}

	class P implements Comparable<P>{
		int q, p, v;
		double d;

		P(int q, int p, int v, double d){
			this.q=q;
			this.p=p;
			this.v=v;
			this.d=d;
		}

		@Override
		public int compareTo(P p){
			if(d+EPS<p.d){
				return -1;
			}else if(d>p.d+EPS){
				return 1;
			}else{
				return 0;
			}
		}

	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
	int n;
	cin >> n;
	int s = 0;
	fori(n) { s += ((to_string(i + 1).size()) % 2); }
	cout << s;
	return 0;
}

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

int main() {
  int M,x,y;
  int L,R;
  cin >> y >> M;
  int i;
  x=0;
  for(i=0;i<M;i++){
    cin >> L >> R;
    if(x<L)
      x=L;
    if(y>R)
      y=R;
    if(x>y)
      break;
    }
  if(y>=x)
    cout << y-x+1 << endl;
  else
    cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
const int N = 2e3 + 5, M = 2e5;
vector<int> v;
void sieve(){
    bool prime[500000];
    int n = 500000;
    memset(prime, true, sizeof prime);
    prime[0] = prime[1] = false;
    for(int i = 2; i * i <= n; i++)
        if (prime[i])
            for (int j = i * i; j <= n; j += i)
                prime[j] = false;
    for(int i = 1; i <= n; i++)
        if(prime[i])
            v.push_back(i);
}
int main()
{
    Hello
    int x;
    cin >> x;
    sieve();
    for(int i = 0; i < v.size(); i++)
        if(v[i] >= x)
            return cout << v[i], 0;
    return 0;
}

Measured memory_bytes: 4220
import java.util.Scanner;
public class Main{
  public static void main(String[] args)
  {
    Scanner scan =new Scanner (System.in);
    String S =  scan.nextLine();
    if (S.equals("ABC")){
      System.out.println("ARC");
    }else{
      System.out.println("ABC");
    }
  }
}

Measured memory_bytes: 35640
from collections import Counter

import sys

def main():
    n = int(input())
    values = []
    for i in range(n):
        values.append(str(input()))

    c = Counter(values)
    if any(c[i] > 1 for i in c):
        print('No')
        return
    
    for i in range(n - 1):
        if values[i][-1] != values[i + 1][0]:
            print('No')
            return 

    print('Yes')

    

if __name__ == "__main__":
    main()

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9

using namespace std;

int main(){
  int x, y, s;
  while(cin >> x >> y >> s and x + y + s){
    int maxim = 0;
    REP(i, s){
      int ns1, ns2;
      if(i == 0) continue;
      ns1 = 100 * (i+1) / (100 + x);
      ns2 = 100 * (s-i+1) / (100 + x);
      if(ns1 * (100 + x) / 100 + ns2 * (100 + x) / 100 != s) continue;
      maxim = max(maxim, ns1 * (100 + y) / 100 + ns2 * (100 + y) / 100);
      // cout << maxim << " : " << ns1 << ", " << ns2 << endl;
    }
    cout << maxim << endl;
  }
  return 0;
}

Measured memory_bytes: 3092
/*
TASK: AGC143 - B - TAKOYAKI FESTIVAL 2019
LANG: C++
NAME: picolylamine
*/
#define _CRT_SECURE_NO_WARNINGS
#define N_MAX 50

#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	int N, d[N_MAX];
	scanf("%d", &N);
	for (int i = 0; i < N; i++){
		scanf("%d", d + i);
	}

	int ret = 0;
	for (int i = 0; i < N; i++){
		for (int j = i+1; j < N; j++){
			ret += d[i] * d[j];
		}
	}

	printf("%d", ret);

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define float double 
#define dg(x) cout<<#x<<" :"<<x;
#define dg_array(ar) for(auto x : ar) cout<<x<<" ";cout<<endl;
#define dg_2darray(ar) for(auto x : ar) {for(auto y : x) cout<< y<<" ";cout<<endl;}
#define endl '\n'
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
void solve()
{
    int n ;
    cin >> n;
    map<string,int>mp;
    for(int i =0  ;i <n; i++)
    {
        string str;
        cin >> str;
        mp[str]++;
    }
    cout<<mp.size()<<endl;
}   

void testcase()
{
    int t;
    cin>>t;
    while(t--)
        solve();
}
int32_t main(){
	fast;
//    testcase();           
   solve();              
}

Measured memory_bytes: 19184
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  ll H,W,N,a,b,ans[10];
  vector<pair<ll,ll>> v;
  set<pair<ll,ll>> s;
  cin >> H >> W >> N;
  ans[0] = (H-2)*(W-2);
  FOR(i,1,10)ans[i] = 0;
  ll dx[] = {-1,-1,-1,0,0,0,1,1,1};
  ll dy[] = {-1,0,1,-1,0,1,-1,0,1};
  FOR(i,0,N){
    cin >> a >> b;
    FOR(j,0,9)if(1<a+dx[j]&&a+dx[j]<H&&1<b+dy[j]&&b+dy[j]<W)v.push_back(make_pair(a+dx[j],b+dy[j]));
    FOR(j,0,9)if(1<a+dx[j]&&a+dx[j]<H&&1<b+dy[j]&&b+dy[j]<W)s.insert(make_pair(a+dx[j],b+dy[j]));
  }
  sort(ALL(v));
  for(auto p:s){
    ans[upper_bound(ALL(v),p)-lower_bound(ALL(v),p)]++;
    ans[0]--;
  }
  FOR(i,0,10)cout << ans[i] << endl;
}


Measured memory_bytes: 72036
import math
N = int(input())
X = []
ans = 0
for i in range(N):
    x = list(map(int, input().split()))
    X.append(x)
for j in range(N):
    for k in range(N):
        Y = (X[j][0]-X[k][0])**2 + (X[j][1]-X[k][1])**2
        ans += math.sqrt(Y)*math.factorial(N-1)
print(ans/math.factorial(N))

Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  int n,count=0,temp;
  cin>>n;
  int main[n];
  for(int i=0;i<n;i++) main[i]=0;
  for(int x=1;x*x<10000;x++){
      for(int y=1;y*y<10000;y++){
          for(int z=1;z*z<10000;z++){
            temp=(x+z+y)*(x+z+y)-x*y-x*z-y*z;
            if(temp<=n && temp>=1) main[temp-1]=main[temp-1]+1;
            
    }
  }
}
for(int i=0;i<n;i++) cout<<main[i]<<'\n';
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int N;
	cin >> N;
	int sum = 0, tempN = N;
	while (tempN > 0) {
		sum += tempN % 10;
		tempN /= 10;
	}
	if (N % sum == 0) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}	
	
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define MAXN 1000

int lcs(string s1, string s2)
{
	int m = s1.size();
	int n = s2.size();
	int C[MAXN + 1][MAXN + 1];
	C[0][0] = 0;
	s1 = ' ' + s1;
	s2 = ' ' + s2;
	int max_lcs = 0;
	for (int i = 1; i <= m; i++)
		C[i][0] = 0;
	for (int j = 1; j <= n; j++)
		C[0][j] = 0;
	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (s1[i] == s2[j]) C[i][j] = C[i - 1][j - 1] + 1;
			else C[i][j] = max(C[i - 1][j], C[i][j - 1]);
			max_lcs = max(max_lcs, C[i][j]);
		}
	}
	return max_lcs;
}

int main()
{
	string s1, s2;
	int q;
	cin >> q;
	while (q--)
	{
		cin >> s1 >> s2;
		cout << lcs(s1, s2) << endl;
	}
	return 0;
}


Measured memory_bytes: 6964
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#define MAX 36
typedef struct t{
  int val;
  char c;
}C;
int n;
void bubblesort(C sort[]){
  int i,j;
  C tmp;

  for(i=0;i<n;i++){
    for(j=n-1;j>=i+1;j--){
      if(sort[j].val<sort[j-1].val){
        tmp=sort[j]; sort[j]=sort[j-1]; sort[j-1]=tmp;
      }
    }
  }
}
void selectionsort(C sort[]){
  int i,j,minj;
  C tmp;

  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(sort[j].val<sort[minj].val) minj=j;
    }
    tmp=sort[i]; sort[i]=sort[minj]; sort[minj]=tmp;
  }
}
bool isStable(C c1[],C c2[]){
  int i;
  for(i=0;i<n;i++){
    if(c1[i].c!=c2[i].c) return false;
  }
  return true;
}

int main(){
  C c1[MAX],c2[MAX];
  int i,num;
  char m;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c%d",&c1[i].c,&c1[i].val);
  }
  for(i=0;i<n;i++) c2[i]=c1[i];
  bubblesort(c1);
  selectionsort(c2);

  for(i=0;i<n;i++) {
    if(i>0) printf(" ");
    printf("%c%d",c1[i].c,c1[i].val);
}
printf("\nStable\n");


  for(i=0;i<n;i++) {
    if(i>0) printf(" ");
    printf("%c%d",c2[i].c,c2[i].val);
}
printf("\n");
  if(isStable(c1,c2)) printf("Stable\n");
  else printf("Not stable\n");
  return 0;
}



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



class Solution {
  int n;
public:
  void run() {
    cin >> n;
    vector<int> A(n), ans;
    for (int i = 0; i < n; ++i) cin >> A[i];
    for (int i = 0; i < n; ++i) {
      for (int j = A.size() - 1; j >= 0; --j) {
        if (j + 1 == A[j]) {
          ans.push_back(1 + j);
          A.erase(A.begin() + j);
          break;
        }
      }
    }
    if (ans.size() == n) {
      for (int i = n - 1; i >= 0; --i) cout << ans[i] << '\n';
    }
    else cout << -1 << '\n';
  }
};


int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  Solution().run();
}


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

int main(){
  int n,x;
  cin>>n>>x;
  int sum=0;
  int mi=1e9;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    mi=min(mi,a);
    sum+=a;
  }
  int ans=n+(x-sum)/mi;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}
int main(){
string s;
cin >> s;
int n = s.size();
vector<ll>remain(n+1);
for(int i = 1;i<=n;i++){
    remain[i] = (remain[i-1]+modpow(10,i-1,2019)*(s[n-i]-'0'))%2019;
}
map<ll,ll>mp;
for(int i = 0;i<=n;i++) mp[remain[i]]++;
ll ans = 0;
for(auto it = mp.begin();it!=mp.end();it++){
    ans += (it->second-1)*it->second/2;
}
cout << ans;
return 0;
}

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

int main(){
  std::vector<int> a={1,3,5,7,8,10,12};
  std::vector<int> b={4,6,9,11};
  std::vector<int> c={2};

  int x, y;
  cin >> x >> y;

  bool xx=false;
  bool yy=false;
  for(int A:a) {
    if(A==x) xx=true;
    if(A==y) yy=true;
  }
  if(xx && yy){
    cout << "Yes" << endl;
    return 0;
  }
  bool xxx=false;
  bool yyy=false;
  for (int i = 0; i < b.size(); i++) {
    if(b.at(i)==x) xxx=true;
    if(b.at(i)==y) yyy=true;
  }
  if(xxx && yyy){
    cout << "Yes" << endl;
    return 0;
  }

  bool xxxx=false;
  bool yyyy=false;
  for (int i = 0; i < c.size(); i++) {
    if(c.at(i)==x) xxxx=true;
    if(c.at(i)==y) yyyy=true;
  }
  if(xxxx && yyyy){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


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

int main(){
  string s;
  cin >> s;
  int a,b,c,d;
  a = s.at(0) - '0';
  b = s.at(1) - '0';
  c = s.at(2) - '0';
  d = s.at(3) - '0';
  string p = "-+";
  for(int i=0;i< 1<<3;i++){
    int ans=0;
    char p1,p2,p3;
    bitset<3> n(i);
    if( n.test(0) ){
      ans += a+b;
      p1 = '+';
    }else{
      ans += a-b;
      p1 = '-';
    }
    if( n.test(1) ){
      ans += c;
      p2 = '+';
    }else{
      ans -= c;
      p2 = '-';
    }
    if( n.test(2) ){
      ans += d;
      p3 = '+';
    }else{
      ans -= d;
      p3 = '-';
    }
    if( ans == 7 ){
      cout << a << p1 << b << p2 << c << p3 << d << "=7" << endl;
      return 0;
    }
  }
    
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define N 250005

using namespace std;
typedef pair<int,int> Pair;

inline int input() {
	int x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

int n, num[N];
int x[N];

Pair a[N];

void Exit() { puts("No"); exit(0); }

int main() {
	n = input();
	for (int i = 1; i <= n; ++i) {
		x[i] = input();
		a[i].fi = x[i], a[i].se = i;
	}

	sort(a + 1, a + n + 1);

	int pos = 1, cnt;
	for (int i = 1; i <= n; ++i) {
		cnt = 0;
		if (num[a[i].fi]) Exit();
		num[a[i].fi] = a[i].se;
		if (a[i].se == 1) continue;
		while (pos <= a[i].fi) {
			if (!num[pos]) {
				num[pos] = a[i].se, ++cnt;
				if (cnt == a[i].se - 1) break;
			}
			++pos;
		}

		if (cnt < a[i].se - 1) Exit();
	}

	pos = n * n;
	for (int i = n; i; --i) {
		cnt = 0;
		if (a[i].se == n) continue;
		while (pos >= a[i].fi) {
			if (!num[pos]) {
				num[pos] = a[i].se, ++cnt;
				if (cnt == n - a[i].se) break;
			}
			--pos;
		}

		if (cnt < n - a[i].se) Exit();
	}

	puts("Yes");
	for (int i = 1; i < n * n; ++i)
		printf("%d ", num[i]);
	printf("%d\n", num[n * n]);
	return 0;
}


Measured memory_bytes: 2176