akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int A = reader.nextInt();
		int B = reader.nextInt();
		int C = reader.nextInt();
		int D = reader.nextInt();
		int ans = Math.min(B, D) - Math.max(A, C);

		System.out.println(Math.max(ans, 0));
		reader.close();
	}


}





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

const ll mod=1e9+7;
ll p(ll a, ll n)
{
    if(n == 0) return 1;
    ll x = p(a, n/2);
    ll ans = x * x % mod;
    if(n % 2 == 1) ans = ans *a % mod;
    return ans%mod;
}

ll C(ll n,ll m) {
    if(n < m) return 0;
    ll res = 1;
    for(ll i=1; i<=m; i++) {
        ll a = (n+i-m)%mod;
        ll b = i%mod;
        res = res*(a*p(b,mod-2)%mod)%mod;
    }
    return res;
}

ll Lucas(ll n,ll m) {
    if(m == 0) return 1;
    return C(n%mod, m%mod) * Lucas(n/mod,m/mod)%mod;
}

ll n,a,b;
int main(){
    cin>>n>>a>>b;
    ll ans=p(2,n)-Lucas(n,a)-Lucas(n,b)-1;
   while(ans<0) {
        ans+=mod;
    }
    cout<<ans%mod;
    return 0;
}


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

void solve(){
    string s,t;
    cin>>s>>t;
    int j=0;
    int c=0;
    int ans=s.length();
    for(int i=0;i<=s.length()-t.length();i++){
        int c=0;
        for(int j=i;j<i+t.length();j++){
            if(s[j]!=t[j-i]) {
//                cout<<s[j]<<" "<<t[j-i]<<endl;
                c += 1;
            }
        }
//        cout<<"hi"<<endl;
        ans=min(ans,c);
    }
    cout<<ans<<endl;
}

int main()
{
    int t;
    solve();
}

Measured memory_bytes: 3608
import java.io.*;
public class Main {
	public static void main(String[] args)throws IOException {
		int m = 0,f=0,r=0;
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String str = br.readLine();
			String[] i=str.split(" ");
				m=Integer.parseInt(i[0]);
				f=Integer.parseInt(i[1]);
				r=Integer.parseInt(i[2]);
				if(m==(-1)&&f==(-1)&&r==(-1)){break;}
				if(m==(-1)||f==(-1)){System.out.println("F");}
				else if(m+f>=80){System.out.println("A");}
				else if(m+f>=65){System.out.println("B");}
				else if(m+f>=50){System.out.println("C");}
				else if(m+f>=30){if(r>=50){System.out.println("C");}
								 else{System.out.println("D");}}
				else {System.out.println("F");}
		}
	}
}

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

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

const long long MOD = 1000000007;

int main(){
  int n;
  ll t=2;
  cin >> n;
  vector<double> a(n);
  rep(i,n) cin >> a.at(i);
  sort(a.begin(),a.end());
  double ans = 0;
  
  for(int i=n-1;i>=0;i--){
    ans += a.at(i)/t;
    if(i!=1) t*=2;
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
#define pb  push_back
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST

int n;
cin>>n;
double a[n],s=0,ans=0;
FOR(i,n)
{
	cin>>a[i];
	s+=a[i];
}
s/=n;
if(s-floor(s)>0.5)
{
	s=ceil(s);
}
if(s-floor(s)<=0.5)
{
	s=floor(s);
}

FOR(i,n)
{
	ans+=pow((abs(a[i]-s)),2);
}
cout<<ans<<endl;

return  0;
}




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

class RollingHash{
    private:
    string B[5]={"u_shi","ta_pu","ni_chi_a","ku_n","wara"};
    long long M[5]={1000000007,1000000007,1000000007,1000000007,1000000007};
    long long Bint[5],Binv[5];
    
    public:
    string S;
    vector<long long> H[5],Hsum[5],Power[5];
    
    //繰り返し二乗法
    long long BE(long long b,int e,int m){
        long long r=1;
        while(e){
            if(e&1){
                r=(r*b)%M[m];
            }
            b=(b*b)%M[m];
            e >>=1;
        }
        return r;
    }

    
    
    void init(string cs){
        S=cs;
        int n=S.size();
        
        //もちろんそのままでは使えないので使えるようにする
        for(int i=0;i<5;i++){
            Bint[i]=0;
            for(int j=0;j<B[i].size();j++){
                Bint[i]+=(int)B[i][j];
            }
            Bint[i]%=M[i];
        }
        
        //逆元は一定なので前計算(near 575)
        for(int i=0;i<5;i++){
            Binv[i]=BE(Bint[i],M[i]-2,i);
        }
        
        //本体
        for(int i=0;i<5;i++){
            H[i].assign(n+1,0);
            long long b=1;
            for(int j=n-1;j>=0;j--){
                H[i][j]=(b*(int)S[j])%M[i];
                b=(b*Bint[i])%M[i];
            }
        }
        
        //累積和すると嬉しいと思いませんか？僕は思います
        for(int i=0;i<5;i++){
            Hsum[i].assign(n+1,0);
            for(int j=0;j<n;j++){
                Hsum[i][j+1]=(Hsum[i][j]+H[i][j])%M[i];
            }
        }
    }
    
    //外からハッシュ値を呼びたい
    long long get(int l,int r,int m){
        long long R=(Hsum[m][r+1]-Hsum[m][l])%M[m];
        R=(R+M[m])%M[m];
        R=(R*BE(Binv[m],(S.size())-r-1,m))%M[m];
        return R;
    }
    
    
};

signed main() {
    int N,M;
    string S,Q;
    cin >> N >> M;
    cin >> S;
    int l=0,r=0;
    set<vector<long long>> R;
    RollingHash roliha;
    roliha.init(S);
    
    for(int i=0;i<M;i++){
        cin >> Q;
        if(Q=="L++"){l++;}
        else if(Q=="L--"){l--;}
        else if(Q=="R++"){r++;}
        else{r--;}
        vector<long long> K;
        for(int j=0;j<5;j++){
            long long k=roliha.get(l,r,j);
            K.push_back(k);
        }
        R.insert(K);
        
    }
    cout << R.size() << endl;
    return 0;
}


Measured memory_bytes: 59648
/* nothing is impossible */
#pragma comment(linker, "/stack:227420978")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h> 
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;                                                                                                 
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}             

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
///  freopen("input.txt", "r", stdin);
  ll n,k;
  cin>>n>>k;
  if(n%k==0)
  {
    cout<<"0";
  }
  else cout<<1;
return 0;
}         

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int m, f, r;

	while(true) {
		cin >> m >> f >> r;
		if(m == -1 && f == -1 && r == -1) {
			break;
		}
		if(m == -1 || f == -1) {
			cout << "F" << endl;
		}else if(m+f >= 80) {
			cout << "A" << endl;
		}else if(m+f >= 65) {
			cout << "B" << endl;
		}else if(m+f >= 50) {
			cout << "C" << endl;
		}else if(m+f >= 30) {
			if(r >= 50) {
				cout << "C" << endl;
			}else {
				cout << "D" << endl;
			}
		}else {
			cout << "F" << endl;
		}
	}

	return 0;
}


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

#define INF int(1e9)
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=200005;
int n,ans;
int p[maxn],q[maxn];
class Dsu{
public:
	int f[maxn];
	void clear(){
		rep(i,n)f[i]=i;
	}
	int find(int x){
		return f[x]==x?x:f[x]=find(f[x]); 
	}
	void merge(int x,int y){
		f[find(x)]=find(y);
	}
}P,Q;

namespace Flow{
	int tot,S,T,V;
	int head[maxn],nxt[maxn*2],to[maxn*2],cap[maxn*2];
	int lvl[maxn],cur[maxn],q[maxn];
	void init(){
		tot=0;
		memset(head,-1,sizeof(head));
	}
	void addedge(int u,int v,int c){
		nxt[tot]=head[u];to[tot]=v;cap[tot]=c;head[u]=tot++;
		nxt[tot]=head[v];to[tot]=u;cap[tot]=0;head[v]=tot++;
	}
	void bfs(){
		rep(i,V)lvl[i]=-1;
		lvl[S]=0;
		int l=0,r=0;
		q[r++]=S;
		while(l<r){
			int x=q[l++];
			for(int i=head[x];~i;i=nxt[i]){
				if(lvl[to[i]]<0&&cap[i]){
					lvl[to[i]]=lvl[x]+1;
					q[r++]=to[i];
				}
			}
		}
	}
	int dfs(int x,int f){
		if(x==T)return f;
		for(int &i=cur[x];~i;i=nxt[i]){
			if(lvl[to[i]]==lvl[x]+1&&cap[i]){
				int d=dfs(to[i],min(f,cap[i]));
				if(d>0){
					cap[i]-=d;
					cap[i^1]+=d;
					return d;
				}
			}
		}
		return 0;
	}
	int work(){
		int res=0;
		for(;;){
			bfs();
			if(lvl[T]<0)break;
			rep(i,V)cur[i]=head[i];
			for(;;){
				int f=dfs(S,INF);
				if(!f)break;
				res+=f;
			}
		}
		return res;
	}
}

int main(){
	scanf("%d",&n);
	P.clear();
	Q.clear();
	rep(i,n){
		scanf("%d",&p[i]);
		P.merge(i,p[i]);
	}
	rep(i,n){
		scanf("%d",&q[i]);
		Q.merge(i,q[i]); 
	}
	Flow::init();
	Flow::S=2*n;Flow::T=2*n+1;Flow::V=2*n+2;
	ans=n;
	rep(i,n){
		int u=P.find(i),v=Q.find(i)+n;
		if(p[i]==i&&q[i]==i)ans--;
		else if(p[i]==i&&q[i]!=i)Flow::addedge(Flow::S,v,1);
		else if(p[i]!=i&&q[i]==i)Flow::addedge(u,Flow::T,1);
		else if(p[i]==q[i])Flow::addedge(u,v,1),Flow::addedge(v,u,1);
		else Flow::addedge(u,v,1);
	}
	printf("%d\n",ans-Flow::work());
	return 0;
}

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

using namespace std;

map<int, bool> mark;
int x, n, d;
int main( ) {
	scanf("%d %d", &x, &n);
	for (int i = 1; i <= n; i ++) {
		scanf("%d", &d);
		mark[d] = true;
	}
	for (int i = 0; i <= 200; i ++) {
		if (!mark.count(x - i)) {
			printf("%d\n", x - i);
			break;
		}
		if (!mark.count(x + i)) {
			printf("%d\n", x + i);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3804
#include<stdio.h>
#include<queue>
using namespace std;
int head[262144],now[262144],last[1048576],to[1048576],c[1048576],cnt=1;
void add(int u,int v,int cc)
{
	cnt++;
	last[cnt]=head[u];
	head[u]=cnt;
	to[cnt]=v;
	c[cnt]=cc;
}
int n;
queue<int> q;
int d[262144],pre[262144];
void bfs()
{
	for(int i=1;i<=(n<<1)+1;i++)
	{
		now[i]=head[i];
		d[i]=-1;
	}
	d[(n<<1)]=0;
	q.push(n<<1);
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(int i=head[u];i;i=last[i])
		{
			if(c[i]==0)
			{
				continue;
			}
			int v=to[i];
			if(d[v]<0)
			{
				d[v]=d[u]+1;
				pre[v]=u;
				q.push(v);
			}
		}
	}
}
int dfs(int u,int a)
{
	if(u==(n<<1)+1||a==0)
	{
		return a;
	}
	int flow=0;
	for(int& i=now[u];i;i=last[i])
	{
		int v=to[i];
		if(d[v]<=d[u])
		{
			continue;
		}
		int flow2;
		if(c[i]<a)
		{
			flow2=dfs(v,c[i]);
		}
		else
		{
			flow2=dfs(v,a);
		}
		c[i]-=flow2;
		c[i^1]+=flow2;
		a-=flow2;
		flow+=flow2;
		if(a==0)
		{
			break;
		}
	}
	return flow;
}
int dinic()
{
	int ans=0;
	while(1)
	{
		bfs();
		if(d[(n<<1)+1]<0)
		{
			break;
		}
		ans+=dfs(n<<1,1000000000);
	}
	return ans;
}
int s[131072],t[131072];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		add((n<<1),i,1);
		add(i,(n<<1),0);
	}
	for(int i=n+1;i<(n<<1);i++)
	{
		add(i,(n<<1)+1,1);
		add((n<<1)+1,i,0);
		int num;
		scanf("%d",&num);
		while(num--)
		{
			int u;
			scanf("%d",&u);
			add(u,i,1);
			add(i,u,0);
		}
	}
	if(dinic()<n-1)
	{
		printf("-1\n");
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		if(d[i]<0)
		{
			printf("-1\n");
			return 0;
		}
		if(d[i]==1)
		{
			continue;
		}
		s[pre[i]-n]=i;
		t[pre[i]-n]=pre[pre[i]];
	}
	for(int i=1;i<n;i++)
	{
		printf("%d %d\n",s[i],t[i]);
	}
	return 0;
}

Measured memory_bytes: 18560
#include <cstdio>
int a,b,c,d,e;
int main(void){
  scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
  printf("%d\n",a-(((b+d-1)/d>(c+e-1)/e)?(b+d-1)/d:(c+e-1)/e));
  return 0;
}

Measured memory_bytes: 1024
import collections

# 入力
N = int(input())
S = []
for i in range(N):
    S.append(input())

Scol = collections.Counter(S).most_common()
Sset = set([Si[0] for Si in Scol if Si[1]==Scol[0][1]])

print("\n".join(sorted(Sset)))

Measured memory_bytes: 49644
#include <iostream>


constexpr int32_t N_MAX = 10000;
constexpr int32_t INF = 10000*N_MAX+9999;

int32_t N;
int32_t t[N_MAX];
int32_t dp[2][N_MAX+1][2];//0:a
int main()
{
	std::cin >> N;
	for(int i = 1;i<N;++i){
		std::cin >> t[i];
	}
	
	uint8_t mode = 0;
	for(int n = 1;n <= N;++n)
	{
		auto last_mode = mode;
		mode ^= 1;
		dp[mode][0][0] = INF;dp[mode][0][1] = 0;
		dp[mode][n][0] = 0;dp[mode][n][1] = INF; 
		for(int a = 1;a < n;++a){
			dp[mode][a][0] = std::min(
				dp[last_mode][a-1][0],
				dp[last_mode][a-1][1] + t[n-1]
				);
			dp[mode][a][1] = std::min(
				dp[last_mode][a][0] + t[n-1],
				dp[last_mode][a][1]
				);
		}
	}
#if 0
std::cout<<"------------0-----------------\n";
	for(int n = 1;n <= N;++n){
	for(int a = 0;a <= n;++a){
		std::cout << dp[n][a][0] << ' ';
	}std::cout<<'\n';}
std::cout<<"------------1-----------------\n";
	for(int n = 1;n <= N;++n){
	for(int a = 0;a <= n;++a){
		std::cout << dp[n][a][1] << ' ';
	}std::cout<<'\n';}
#endif
	std::cout << std::min(dp[0][N/2][0], dp[0][N/2][1]) << std::endl;
}

Measured memory_bytes: 3284
N = int(input())
A = [list(input().split()) for _ in range(N)]
A = sorted([(A[i][0],int(A[i][1]),i+1) for i in range(N)],key=lambda x:x[1],reverse=True)
A = sorted(A,key=lambda x:x[0])
for i in range(N):
    print(A[i][2])

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


void solve(long long N, std::vector<std::string> S){
    vector<ll> rec(5, 0);
    for(ll i=0; i< N; i++){
        if(S[i].at(0) == 'M')
            rec[0]++;
        if(S[i].at(0) == 'A')
            rec[1]++;
        if(S[i].at(0) == 'R')
            rec[2]++;
        if(S[i].at(0) == 'C')
            rec[3]++;
        if(S[i].at(0) == 'H')
            rec[4]++;
    }
    ll ans = 0;
    ans += rec[0]*rec[1]*rec[2];
    ans += rec[0]*rec[1]*rec[3];
    ans += rec[0]*rec[1]*rec[4];
    ans += rec[0]*rec[2]*rec[3];
    ans += rec[0]*rec[2]*rec[4];
    ans += rec[0]*rec[3]*rec[4];
    ans += rec[1]*rec[2]*rec[3];
    ans += rec[1]*rec[2]*rec[4];
    ans += rec[1]*rec[3]*rec[4];
    ans += rec[2]*rec[3]*rec[4];
    cout << ans << endl;
}

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


Measured memory_bytes: 6144
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let N = xs[0];
   let tax = 1.08;
   let ans1 = [];
   let ans2 = 0;
  
   for(let i=0; i<=N; i++){
      ans1.push(Math.floor(i*tax));
      if(ans1[i]==N){
        ans2 = Math.ceil(N/tax);
        break;
      }else{
        ans2 = -1;
      }
   }
   if(ans2==-1){
     console.log(":(")
   }else{
     console.log(ans2);
   }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 34104
import java.util.Scanner;

public class Main {
	public static int gcd(int a, int b) {
		if (b == 0) 
			return a;
		return gcd(b, a % b);
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		System.out.println(gcd(a,b));
	}
}



Measured memory_bytes: 26140
(defvar mod-number 1000000007)

(defun main ())

(defun iota (c &optional (s 0) (step 1) (acc nil))
  (if (zerop c)
      (reverse acc)
      (iota (1- c) (+ s step) step (cons s acc))))

(defun sum (list &optional (init 0))
  (reduce #'+ list :initial-value init))

(defmacro debug-print (x)
  `(let ((y ,x))
    (format t "~A: ~A~%" ',x y)
	y))

(defparameter n (read))
(defparameter k (read))

(defparameter s
  (make-array (+ 2 n)
    :initial-contents (reverse
	                    (reduce
						  (lambda (acc n)
						    (cons (+ n (car acc))
							      acc))
						  (iota (1+ n))
	                      :initial-value '(0)))))

(defun high (pick-num)
  (- (aref s (1+ n)) (aref s (- (1+ n) pick-num))))

(defun low (pick-num)
  (aref s pick-num))

(defun solve (pick-num)
  (1+ (- (high pick-num) (low pick-num))))

(format t "~A~%" (reduce (lambda (x y) (rem (+ x y) mod-number)) (mapcar #'solve (iota (- (1+ n) (1- k)) k))))

Measured memory_bytes: 48120
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

int n,a[N];
ll dp[N][5];
ll rec(int i,int j){
    if(i==n and j==4) return 0;
    if(i>n) return 0;
    ll &cache=dp[i][j];
    if(cache!=1e18) return cache;
    if(j==4) return cache=a[i]+max({rec(i+4,2),rec(i+3,3),rec(i+2,4)});
    if(j==3) return cache=a[i]+max(rec(i+3,2),rec(i+2,3));
    else return cache=a[i]+rec(i+2,2);
}
signed main(){
    FastIO;
    cin>>n;
    rep(i,1,n){
        cin>>a[i];
        rep(j,0,4) dp[i][j]=1e18;
    }
    if(n==3) return cout<<max({a[1],a[2],a[3]}),0;
    ll ans;
    if(n&1) ans=max({rec(1,4),rec(2,3),rec(3,2)});
    else ans=max(rec(1,3),rec(2,2));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 20052
s = int(input())

if s == 1 or s == 2:
    print(4)
else:
    a = [s]
    for i in range(1000):
        if a[-1] % 2 == 0:
            a.append(int(a[-1] / 2))
        else:
            a.append(int(a[-1] * 3 + 1))

    print(a.index(4) + 4)

Measured memory_bytes: 3060
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    String s = sc.next();
    String f ,b;
    if(N%2!=0){
      System.out.print("No");
    }else{
      f = s.substring(0,N/2);
      b = s.substring(N/2,N);
      if(f.equals(b)){
        System.out.print("Yes");
      }else{
        System.out.print("No");
      }
    }
    System.out.flush();
    
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int main()
{
    string S;
    cin >> S;
    int N = S.size();
    int K;
    cin >> K;
    char Min = 'z';

    rep(i, N)
    {
        if (Min > S[i])
        {
            Min = S[i];
        }
    }
L:
    set<string> sub;
    rep(i, N)
    {

        if (S[i] == Min)
        {
            for (int j = 1; j <= 5 and j + i <= N; j++)
            {
                sub.insert(S.substr(i, j));
            }
        }
    }
    if (sub.size() >= K)
    {
        auto itr = sub.begin();
        rep(i, K - 1)
        {
            itr++;
        }
        cout << *itr;
        return 0;
    }
    else
    {
        K -= sub.size();
        Min++;
        goto L;
    }

    return 0;
}

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

int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    int max;
    if(a>b){
        max=a;
    }else{
        max=b;
    }
    for(int i=0; i<max; i++){
        if(abs(a-i)==abs(b-i)){
            printf("%d\n", i);
            return 0;
        }
    }
    printf("IMPOSSIBLE\n");
    return 0;
}

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

using namespace std;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    int x = 0;
    for (char i : s) {
        x += i - '0';
    }
    cout << (x % 9 ? "No" : "Yes") << endl;
    return 0;
}



Measured memory_bytes: 3712
#include<stdio.h>
#include<iostream>
using namespace std;
int main( void )
{
    int a,b,c;
    cin >> a >> b >> c;
    if((a+b+c)>=22){cout << "bust"<<endl;}
    if((a+b+c)<=21){cout << "win"<<endl;}
    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <inttypes.h>

int32_t N;
int64_t T;
int64_t t[271828];

int main(void) {
	int32_t i;
	int64_t answer = 0;
	if (scanf("%" SCNd32 "%" SCNd64, &N, &T) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%" SCNd64, &t[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		int64_t delta = T;
		if (i + 1 < N && t[i + 1] - t[i] < T) delta = t[i + 1] - t[i];
		answer += delta;
	}
	printf("%" PRId64 "\n", answer);
	return 0;
}


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

int main() {
	int n, a;
	cin >> n;
	int A[n];
	
	for ( int i = 0 ; i < n; i++) {
		cin >> a;
		A[i] = a;
	}
	
	for ( int j = n - 1; j > 0; j--) {
		cout << A[j] << " ";
	}
	
	cout << A[0] << endl;
	
	return 0;
}


Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
#include <cmath>
#include <iostream>

using namespace std;

typedef long long int ll;

const long long INF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9; 
 
int main(void){
    int n,k;
    // int n;
    scanf("%d", &n);
    scanf("%d", &k);

    ll h[n];
    ll costs[n];

    for( int i = 0; i < n; ++i ){
        ll height;
        scanf("%lld", &height);
        h[i] = height;
    }
    for( int i = n - 1; i >= 0; --i ){
        // printf("%s\n", "========");
        ll c;
        c = 0;
        ll min_c = INF; 

        for (int a = 1; a <= k && a < n - i; ++a) {
            // printf("%s\n", "---");
            // printf("jump_range: %d\n", a);
            // printf("current: %d\n", i);
            int jump_to;
            jump_to = i + a;
            ll jump_cost;
            jump_cost = abs(h[jump_to] - h[i]) + costs[jump_to];
            // printf("jump_to: %d\n", jump_to);
            // printf("jump_cost: %lld\n", jump_cost);
            if (min_c > jump_cost)
            {
                min_c = jump_cost;
            }
            c = min_c;
        }
        // printf("%d\n", i);
        // printf("%lld\n", c);
        costs[i] = c;
    }
    // printf("result: %lld", costs[0]);
    printf("%lld", costs[0]);
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	int n,k,x,y,sum=0;
scanf("%d %d %d %d",&n,&k,&x,&y);
if(n<=k)
{
	sum=n*x;
}
else
{
	sum=k*x+(n-k)*y;
}
printf("%d",sum);
return 0;
}

Measured memory_bytes: 128
q, h, s, d = map(int, input().split())
n = int(input())

qq = 4 * q
hh = 2 * h
# 1リットルの買い方
one = min(qq, min(hh, s))
# 1リットルずつ買う方が安い
if one < d / 2:
    print(n * one)
else:
    print((n // 2) * d + (n % 2) * one)


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

int main(){
    ll n;
    cin >> n;
    vector<char> ans;
    while(n > 0){
        char c;
        if(n % 26 == 0){
            c = (char)122;
            n /= 26;
            n -= 1;
        }else{
            c = (char)(n%26+96);
            n /= 26;
        }
        ans.push_back(c);
    }
    reverse(ans.begin(),ans.end());
    for(auto c: ans) cout << c;
    cout << endl;
}

Measured memory_bytes: 3628
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2e5+5;
const int mod=1e9+7;
ll k,n,a[maxn],ans,s=-0x3f3f3f3f;

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

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstdlib>
#include <vector>
#include <cstdint>
#include <numeric>

#define _rep_overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _rep_overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define _rrep_overload3(_1,_2,_3,name,...) name
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _rrep_overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

using namespace std;

// Globals

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int N;
  cin >> N;
  vector<int> xs(N);
  rep (i, N) cin >> xs[i];

  //int min_x = min(xs.begin(), xs.end());
  //int max_x = max(xs.begin(), xs.end());

  int max_i = 0, min_i = 0;
  rep (i, 1, N) {
    int x = xs[i];
    if (x < xs[min_i]) min_i = i;
    if (x > xs[max_i]) max_i = i;  
  }

  int max_x = xs[max_i], min_x = xs[min_i];
  bool pos = abs(max_x) >= abs(min_x);

  //cout << "max: " << max_x << " min: " << min_x << endl; 
  cout << 2*N-2 << endl;

  if (pos) {
    rep (i, N) {
      if (i == max_i) continue;
      cout << max_i+1 << " " << i+1 << "\n";
      //xs[i] += xs[max_i];
    }
    rep (i, N-1) {
      cout << i+1 << " " << i+2 << "\n";
      //xs[i+2] += xs[i+1];
    }
  } else {
    rep (i, N) {
      if (i == min_i) continue;
      cout << min_i+1 << " " << i+1 << "\n";
    }
    rrep (i, N-1) {
      cout << i+2 << " " << i+1 << "\n";
    }  
  }

  //rep (i, N) cout << xs[i] << " ";
  cout << flush;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define MOD 1000000007
#define PSET(x,y) fixed<<setprecision(y)<<x
#define ll long long
#define ld long double
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define lop(i,a,b) for(ll i=a;i<b;i++)
#define lopr(i,a,b) for(ll i=a;i>=b;i--)
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define ff first
#define ss second
#define pi pair<int,int>
#define pll pair<ll, ll>
#define si set<int>
#define sll set<ll>
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
#define state tuple<int,int,int>
#define graph map<ll,list<ll>>

const ld PI = asin(1) * 2;
inline int sbt(int x){return __builtin_popcount(x);} //returns number of set bits

using namespace std;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define deb(...)
#endif

#define SIZE 100010
int n;
int h[SIZE];
int dp[SIZE];

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    fast_io()
    
    cin>>n;

    lop(i,1,n+1)
    	cin>>h[i];

    lop(i,1,n+1){
    	if(i==1)
    		dp[i] = 0;
    	else if(i==2){
    		dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
    	}
    	else{
    		dp[i] = min(
    			dp[i-1] + abs(h[i]-h[i-1]),
    			dp[i-2] + abs(h[i]-h[i-2])
    			);
    	}
    }

    cout<<dp[n];

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main() {
  long int N;
  long int i;
  scanf("%ld", &N);
  long int temp;

  for (i = 1; i * i <= N ; i++) {
    if (N % i == 0) {
      temp = i;
    }
  }
  long int j = N / temp;

  printf("%ld\n", temp + j - 2);
}


Measured memory_bytes: 128
H,W=map(int,input().split())
N=int(input())
A=[int(i) for i in input().split()]
M=[[-1 for _ in range(W)] for _ in range(H)]
i,j=0,0
direc=0
circ=0

class solve:
    def __init__(self, L):
        self.L=L
        self.i=0
        self.len=len(L)
    def get(self):
        if self.L[self.i] != 0 :
            self.L[self.i] -= 1
            return self.i+1
        else:
            self.i += 1
            self.L[self.i] -= 1
            return self.i+1
ans=solve(A)    
#螺旋状のiteration
for _ in range(H*W):
    M[i][j]=ans.get()
    if direc == 0:
        if i == H-1-circ:
            direc = 1
            j += 1
        else:
            i += 1
    elif direc == 1:
        if j == W-1-circ:
            direc = 2
            i -= 1
        else:
            j += 1
    elif direc == 2:
        if i == circ:
            direc = 3
            j -= 1
        else:
            i -= 1
    elif direc == 3:
        if j == 1+circ:
            direc = 0
            circ += 1
            i += 1
        else:
            j -= 1
for m in M:
    print(*m)

Measured memory_bytes: 3828
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{
    int a,b,c;
    while(~scanf("%d%d%d",&a,&b,&c))
    {
        if(a+b>=c&&a<=c)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

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

typedef long long ll;

int main(void)
{
    int n;
    cin>>n;
    int i, val = 0;
    vector<int> v1;
    for(i = 0; i < n; i++)
    {
        cin>>val;
        v1.push_back(val);
    }
    vector<int> v2 = v1;
    sort(v2.begin(), v2.end());
    int track = 0;
    for(i = 0; i < n; i++)
    {
        if(v1[i] != v2[i])
            track++;
    }
    if(track == 2 || track == 0)
        cout<<"YES\n";
    else
        cout<<"NO\n";

    return 0;
}


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

using namespace std;

int main() {
    
    int a,b,c;
    cin>>a>>b>>c;
    int r = c%b;
    for(int i=0; i<b;i++)
    {
        if (a*i%b == r)
        {
            cout<<"YES\n";
            return 0;
        }
    }
    cout<<"NO\n";
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int k;
	cin >> k;
	char ans = s[k - 1];
	rep(i, s.size()) {
		if (s[i] != ans) {
			s[i] = '*';
		}
	}
	cout << s << endl;
}


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

int main()
{
    int n,m,x,y,i,j,redpos[100000],ans = 0,box[100000];

    scanf("%d %d",&n,&m);
    for (i = 0; i < n; i++)
    {
        redpos[i] = 0;
        box[i] = 1;
    }

    redpos[0] = 1;
    for (i = 0; i < m; i++)
    {
        scanf("%d %d",&x,&y);
        if(redpos[x - 1] != 0)redpos[y -1] = 1;
        box[x - 1]--;
        box[y - 1]++;
        if(box[x - 1] == 0)redpos[x - 1] = 0;
    }
    for (i = 0; i < n; i++)
    {
        ans += redpos[i];
    }
    printf("%d",ans);
}

Measured memory_bytes: 896
n, k = input().split()
n = int(n)
k = int(k)
xs = input().split()
xs = [int(x) for x in xs]
ans = 1e9
for i in range(0, n-k+1):
    l = xs[i]
    r = xs[i + k - 1]
    if l < 0 and r > 0:
        ans = min(ans, abs(l) + 2 * r)
        ans = min(ans, abs(l) * 2 + r)
    else:
        ans = min(ans, max(abs(l), abs(r)))
print(ans)

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

int main() {
  int n;
  cin >> n;
  int odd_number = 0;
  rep(i, n) {
    int num;
    cin >> num;
    if(num % 2 == 1)odd_number++;
  }
  if(odd_number % 2 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  ll a, b;
  cin >> a >> b;
  cout << lcm(a, b);
  return 0;
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)

def main():
    n = int(input().strip())
    a = list(map(int, input().strip().split()))
    b = list(map(int, input().strip().split()))
    cnt = 0

    k = sum(max(0, a[i]-b[i]) for i in range(n))
    l = sum(max(0, (b[i] - a[i])//2) for i in range(n))
    if k <= l:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 42480
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    int n, m; cin>>n>>m;
    vector<int> shops(n+10, 0);
    for(int i=0; i<m; i++){
        int c, d; cin>>c>>d;
        for(int j=c; j<d; j++){
            shops[j]++;
        }
    }

    int ans=n+1;
    for(int i=1; i<n; i++){
        int length=0;
        while(i<n && shops[i]>0){
            length++;
            i++;
        }
        ans+=length*2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3116
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n, k;
    sc(n) sc(k)
    int x, d[10];
    fill(d, d + 10, 0);
    REP(i, k){
        sc(x)
        d[x] = 1;
    }

    int check, ans = n;
    while(1){
        check = ans;
        while (check > 0){
            if (d[check % 10] == 1){
                ans++;
                break;
            }else check /= 10;
        }
        if (check == 0) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
ans = 0
start = 0
end = 1

def acgt(s):
    count = 0
    for i in ["A","T","G","C"]:
        count += s.count(i)
    return count

while start < len(s):
    check = s[start:end]
    while len(check) == acgt(check) and end <= len(s):
        end += 1
        check = s[start:end]
    lenth = end - start -1
    ans = max(ans, lenth)
    start = end
print(ans)

Measured memory_bytes: 61956
#include <bits/stdc++.h>
using namespace std;
#define ri register int
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	// no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} 
using io :: gi;
using io :: putc;
using io :: print;
const int N=1e5+5;
int n,p[N],q[N];
struct node{
	int a[N];
	inline node operator *(const node &rhs)const{
		node ans;
		for(ri i=1;i<=n;++i) ans.a[i]=a[rhs.a[i]];
		return ans;
	}
};
inline node inv(node p){
	node ans;
	for(ri i=1;i<=n;++i)
		ans.a[p.a[i]]=i;
	return ans;
}
inline node fpow(node a,ri b){
	node ans;
	for(ri i=1;i<=n;++i) ans.a[i]=i;
	for(;b;b>>=1,a=a*a)
		if(b&1)
			ans=ans*a;
	return ans;
}
int main(){
	ri k,i,f,g;
	node p,q,invp,invq,A,B,invA,ans; 
	gi(n);gi(k);
	for(i=1;i<=n;++i) gi(p.a[i]);
	for(i=1;i<=n;++i) gi(q.a[i]);
	invp=inv(p);
	invq=inv(q);
	f=(k-1)/6;
	g=k-f*6;
	A=q*invp*invq*p;
	if(g==1){
		B=p;
	}
	else if(g==2){
		B=q;
	}
	else if(g==3){
		B=q*invp;
	}
	else if(g==4){
		B=q*invp*invq;
	}
	else if(g==5){
		B=A*invq;
	}
	else if(g==6){
		B=A*p*invq;
	}
	A=fpow(A,f);
	invA=inv(A);
	ans=A*B*invA; 
	for(i=1;i<=n;++i) print(ans.a[i]),putc(' ');
	putc('\n');
    return 0;
}

Measured memory_bytes: 13184
//Burn It Dowwwnnnnn.....................
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int i,j,k,l,a,b,c,d,q,s,n,o,m,t=1;
//    cin>>t;
    for(j=0;j<t;j++)
    {
        vector<long long int>vv;
        map<long long int,long long int>uu;
       cin>>n;
   for(i=1;i<n;i++)
   {
       cin>>o;
       uu[o]++;
   }
   for(i=1;i<=n;i++)
   {
       cout<<uu[i]<<endl;
   }

    }
}



Measured memory_bytes: 16124
n = int(input())
aa = list(map(int, input().split()))
q = int(input())

A = dict()
for i in range(n):
    a = aa[i]
    if a not in A.keys():
        A[a] = 1
    else:
        A[a] += 1

bc = [list(map(int, input().split())) for _ in range(q)]

ans = sum(aa)
for b, c in bc:
    if b in A.keys() and c in A.keys():
        A[c] += A[b]
        ans = ans - b * A[b] + c * A[b]
        A[b] = 0
    elif b in A.keys() and c not in A.keys():
        A[c] = A[b]
        ans = ans - b * A[b] + c * A[b]
        A[b] = 0
    print(ans)

Measured memory_bytes: 35312
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

signed main(){
    int H,W,h,w;
    cin >> H >> W >> h >> w;
    
    cout << H*W-W*h-H*w+h*w << endl;
    
    return 0;
}


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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 1000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll H,W,K;

int d[2]{-1,1};
char field[310][310];
bool frags[310];
int ans[310][310];
bool done[310][310];
int cnt = 1;

void bfs(int y,int x){
    ans[y][x] = cnt;
    for(int i = x+1;i < W;i++){
        if(field[y][i] != '#' && !done[y][i]){
            ans[y][i] = cnt;
        }else{
            break;
        }
    }
    for(int i = x-1;i >= 0;i--){
        if(field[y][i] != '#' && !done[y][i]){
            ans[y][i] = cnt;
        }else{
            break;
        }
    }
    cnt++;
    return;
}

int main(){
  cin >> H >> W >> K;
  for(int i = 0;i < H;i++){
      for(int j = 0;j < W;j++){
          cin >> field[i][j];
          if(field[i][j] == '#'){
              frags[i] = true;
          }
      }
  }
  for(int i = 0;i < H;i++){
      for(int j = 0;j < W;j++){
          if(field[i][j] == '#'){
              bfs(i,j);
          }
      }
  }

      for(int i = 0;i < H;i++){
          for(int j = 0;j < 2;j++){
              int ny = i + d[j];
              if(0 <= ny && ny < H){
                  if(!frags[ny]){
                      for(int k = 0;k < W;k++){
                          ans[ny][k] = ans[i][k];
                      }
                      //frags[ny] = true;
                  }
              }
          }
      }
      for(int i = H-1;i >= 0;i--){
          for(int j = 0;j < 2;j++){
              int ny = i + d[j];
              if(0 <= ny && ny < H){
                  if(!frags[ny]){
                      for(int k = 0;k < W;k++){
                          ans[ny][k] = ans[i][k];
                      }
                      //frags[ny] = true;
                  }
              }
          }
      }

  for(int i = 0;i < H;i++){
      for(int j = 0;j < W;j++){
          cout << ans[i][j] << ' ';
      }
      cout << endl;
  }
}


Measured memory_bytes: 1280
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")

#pragma GCC target("popcnt,abm,mmx,tune=native")

#include <bits/stdc++.h>

#define ll long long

#define fi first

#define se second

#define pb push_back

#define sqr(x) (ll)(x)*(x)

#define inf LLONG_MAX

#define $ ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

#define mod 1000000007

#define Mod 998244353

#define MOD 1234567891

#define pi acos(-1)

using namespace std;

ll a, b;

main()
{$
    cin >> a >> b;

    if (a>=1 && a<=9 && b>=1 && b<=9) cout << a*b; else cout << -1;
}

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

using namespace std;

int main(){
        int a, b, c;
        cin>>a>>b>>c;
        if(a==b&&b==c){
                cout<<1<<endl;
        }
        else if(a!=b&&b!=c&&a!=c){
                cout<<3<<endl;
        }
        else{
                cout<<2<<endl;
        }
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

ll d[3] = {3,5,7};
ll n;
int dfs(ll x=0) {
  if(x>n) return 0;

  int res = 0;
  rep(i,3) res += dfs(x*10+d[i]);
  set<int> s;
  while(x>0){
    s.emplace(x%10);
    x /= 10;
  }
  if(s.size()==3) ++res;
  return res;
}
int main() {
  cin >> n;
  cout << dfs() << endl;
}


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

using namespace std;

using ll = long long;
#define long long long

int main(void) {
    ll n, m;
    cin >> n >> m;

    ll s = 0;
    for(ll i=0; i<m; i++) s |= 1ll << i;

    while(n--) {
        ll k;
        cin >> k;
        ll t = 0;
        while(k--) {
            ll a;
            cin >> a;
            a--;
            t |= 1ll << a;
        }
        s &= t;
    }
    cout << __builtin_popcountl(s) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>

using namespace std;

vector<int> primes;
void gen(int N){
    N = N + 1;
    bool find[N];
    for(int i=0;i<N;i++){
        find[i] = false;
    }
    for(int i=2;i*i<=N;i++){
        if(find[i]) continue;
        for(int j=i+1;j<N;j++){
            if(find[j])continue;
            if(j%i==0)find[j]=true;
        }
    }
    for(int i=2;i<N;i++){
        if(!find[i])primes.push_back(i);
    }
}

void solve(int n){
    int p,q;
    for(int i=1;;i++){
        if(primes[i] > n) break;
        if(primes[i] - primes[i-1] == 2){
            p = primes[i];q=primes[i-1];
        }
    }
    cout << q << " " << p << endl;
}

int main(){
    gen(10000);
    while(true){
        int n;
        cin >> n;
        if(n==0)break;
        solve(n);
    }
    return 0;
}

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

int main(){
  int n;
  int h, _h = 0;
  int r = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> h;
    if(_h < h) r += h - _h;
    _h = h;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 256
n,q = map(int,input().split())
s = input()
    
ans = 0
ls = [0]
for i in range(len(s)-1):
    if s[i] == "A" and s[i+1] == "C":
        ans += 1
        ls.append(1+ls[i-1])
    else:
        ls.append(ls[i])
        
for i in range(q):
    l,r = map(int,input().split())
    print(ls[r-1]-ls[l-1])     

        

Measured memory_bytes: 6100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int a,b;
  	cin >> a;
  	cin >> b;
  	if( (a*b)%2 == 0){
      	cout << "Even" << endl;
    }else{
     	cout << "Odd" << endl; 
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int main(){
    int n;
    cin>>n;
    map<string,int> p;
    int max=0;
    rep(i,n){
        string s;
        cin>>s;
        p[s]++;
        if(p[s]>=max){
            max=p[s];
        }
    }
    vector<string> t;
    for(auto c:p){
        string v = c.first;
        int count = c.second;
        if(count == max){
        //cout<<v<<endl;
        t.push_back(v);
        }
    }
    all(t);
    rep(i,t.size()){
        cout<<t[i]<<endl;
    }

}

Measured memory_bytes: 26868
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long
#define MAX_N 300001

using namespace std;

long long MOD = 998244353;

long long fact[MAX_N];
void factorial(int N){
    fact[0]=1;
    for(int i=0; i<N; i++){
        fact[i+1]=(i+1)*fact[i]%MOD;
    }
}

map<long long, long long> inv;
long long inverse(long long x){
    if (inv.count(x)){
        return inv[x];
    }
    long long p=MOD-2;
    long long ret=1;
    long long tmp=x;
    while(p>0){
        if(p%2==1)ret=ret*tmp%MOD;
        tmp=tmp*tmp%MOD;
        p/=2;
    }
    inv[x]=ret;
    return ret;
}

long long comb(int a, int b){
    long long ret=fact[a]*inverse(fact[a-b])%MOD;
    return ret*inverse(fact[b])%MOD;
}

int main(){
    ll N, A, B, K;
    cin >> N >> A >> B >> K;

    factorial(N);

    ll ans=0;
    for(ll i=0; i<=N; i++){
        ll j=(K-i*A)/B;
        if((K-i*A)%B!=0)continue;
        if(j<0 || N<j)continue;

        ans=(ans+comb(N,i)*comb(N,j)%MOD)%MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 24700
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String str = lines[0];
        String[] str1 = str.split(" ");
        long a = Long.parseLong(str1[0]);
        long b = Long.parseLong(str1[1]);
        long d;
        long r;
        double f;
        d = a / b;
        r = a % b;
        f = (double) a / (double) b;
        System.out.printf("%d %d %.8f", d, r, f);
    }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
}


Measured memory_bytes: 26440