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

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int a,b;
    String s;
    a = scanner.nextInt();
    s = scanner.next();
    b = scanner.nextInt();
    char[] charArray = s.toCharArray();
    for(int i=0;i<a;i++){
    	if(charArray[b-1] != charArray[i])
    		charArray[i] = '*';
    	System.out.print(charArray[i]);
    }
  }
}

Measured memory_bytes: 22612
N=int(input())
S=[input() for i in range(N)]
if len(set(S))==1:
  print(S[0])
else:  
  T=sorted(S)
  A=[]
  cnt=1
  for i in range(N-1):
    if T[i+1]!=T[i]:
      A.append((cnt,T[i]))
      cnt=1
    else:
      cnt+=1
  A.append((cnt,T[-1]))
  X=sorted(A)[::-1]
  x=X[0][0]
  C=[]
  for i in range(N):
    if X[i][0]==x:
      C.append(X[i][1])
    else:
      break
  for i in sorted(C):
    print(i)

Measured memory_bytes: 39172
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;
int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}


int Mdist(pair<int,int>p1, pair<int,int>p2){
    return abs(p1.first - p2.first) +  abs(p1.second - p2.second);
}

int main() {

    int N = in(); int L = in();
    
    
    string S[N];
    
    priority_queue<string,vector<string>, greater<string > > pq;
    
    for(auto i = 0; i < N; i++){
        cin >> S[i];
        pq.push(S[i]);
    }
    
    while (pq.size() != 0){
        cout<<pq.top();
        pq.pop();
    }
    
    cout << endl;
    return 0;
    
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n,i,j,tmp,ans=1;

	scanf("%d",&n);

	int d[n];

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

	for(i=0;i<n-1;i++){
		for(j=n-1;j>i;j--){
			if(d[j-1]<d[j]){
				tmp=d[j-1];
				d[j-1]=d[j];
				d[j]=tmp;
			}
		}
	}

	for(i=0;i<n-1;i++){
		if(d[i]>d[i+1]){
			ans++;
        }
	}

	printf("%d",ans);

	return 0;

}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    
    vector<ll> L(87);
    L[0] = 2;
    L[1] = 1;
    for(int i = 2; i < 87;i++) L[i] = L[i-1] + L[i-2];
    ll N; cin >> N;
    cout << L[N] << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;

int main()
{
	LL N;
	in >> N;
	std::vector<LL>A(N);
	rep(i, N) in >> A[i];

	std::vector<LL>cnt(61);
	rep(i, 61)
	{
		rep(j, N) cnt[i] += ((A[j] & (1LL << i)) ? 1 : 0);
	}

	LL ans = 0;
	rep(i, 61)
	{
		LL a = cnt[i], b = N - cnt[i];
		(ans += (((a * b) % mod) * ((1LL << i) % mod)) % mod) %= mod;
	}

	out << ans << std::endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

int alpha_box[26] = {0};

int main()
{
    int h, w;
    cin >> h >> w;
    rep(i, h){
        string s; cin >> s;
        rep(j, w){
            int c = s[j] - 'a';
            alpha_box[c]++;
        }
    }
    if (h==1&&w==1) {cout <<"Yes" << endl; return 0;}
    int div4 = 0;
    int div2only = 0;
    int divnone = 0;
    rep(i, 26){
        if (alpha_box[i]==0) continue;
        if (alpha_box[i]%2==0){
            if (alpha_box[i]%4==0) div4++;
            else div2only++;
        } else {
            divnone++;
        }
    }
    //rep(i, 26) cout << alpha_box[i] << endl;

    if (h==1||w==1){
        if (divnone<=1) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
    }
    int x = 0;
    int y = 0;
    if(h%2) x+=w/2;
    if(w%2) x+=h/2;
    if(h%2&&w%2) y+=1;
    //cout << x << div2only << div4 << endl;
    if (x>=div2only && y>=divnone) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <cstring>
#include <cmath>

using namespace std;
#define inputInt(a) int a;cin >> a; 
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define output(answer) cout << answer << endl;
#define f(i,s,e) for(int i=s; i<=e; i++)

int main()
{
    //input
    inputLong(a);inputLong(b);inputLong(c);inputLong(d);
    
    //main
    long ans = 1e9;
    long c2=c,d2=d;
    long l = 1;
    long mod = 1e9;
  
    while(mod != 0){
      if(d2>c2){long e; e=d2; d2=c2; c2=e;}//swapしてc>=dに
      mod = c2%d2;
      c2=mod;
    }
    l = c*d/d2;
    
    ans = (b-a+1) - (b/c-(a-1)/c) - (b/d-(a-1)/d) + (b/l-(a-1)/l);
  
    // 出力
    output(ans);
    return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

ll calc(ll a, ll b){
    // std::cout << a << ", " << b << std::endl;
    // if(a == 0){return 0;}
    // if(a == 1){return b * 2 - 1;}
    // if(a == b){return a;}

    if(b % a == 0){
        return a * (2ll * (b / a) - 1);
    }
    return (b / a) * a * 2 + calc(b % a, a);
}

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

    ll N, X;
    std::cin >> N >> X;

    std::cout << (N + calc(X, N-X)) << std::endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b,int m) {
    if (b==0) return 1;
    ll c = power(a,b>>1,m);
    c = (c*c)%m;
    if (b&1) return (c*a)%m;
    return c;
}
ll powerwithoutmod(ll a,ll b) {
    if (b==0) return 1;
    ll c = powerwithoutmod(a,b>>1);
    c = (c*c);
    if (b&1) return (c*a);
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e5+5;
const int Q = 301;
const int logN = 16;

void solve() {
    string s;
    cin>>s;
    int a=0, b=0;
    REP(i,1,3) {
        if (s[i-1]=='A') a++;
        else b++;
    }
    if (a>0 && b>0) cout<<"Yes";
    else cout<<"No";
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

/////////////         UnionFind
//    バラバラの要素を結合してグループにまとめる際に使える構造。
//    グループ番号、要素数の取得が可能だが、グループに属する要素の列挙はO(N)かかる。

class unionFindClass {
public:
	unionFindClass() {
		N = 0;
		parent = NULL;
		size = NULL;
	}
	~unionFindClass() {
		if (parent != NULL) {
			delete[] parent;
		}
		if (size != NULL) {
			delete[] size;
		}
	}

	void activate(int n) {// 要素の数N
		N = n;
		parent = new int[N];
		size = new int[N];
		for (int i = 0; i < N; i++) {
			parent[i] = -1;
			size[i] = 1;
		}
	}

	int getParent(int x) {// グループの親の番号を得る
		if (parent[x] == -1) {
			return x;
		}
		else {
			int y = getParent(parent[x]);
			parent[x] = y;
			return y;
		}
	}
	int getSize(int x) {// 自分が属するグループのサイズを得る
		x = getParent(x);
		return size[x];
	}
	bool connect(int x, int y) {// 二つの要素を結ぶ。２グループ間を繋いだ場合trueを返す
		x = getParent(x);
		y = getParent(y);
		if (x == y) { return false; }
		int xsize = getSize(x), ysize = getSize(y);
		if (xsize < ysize) {
			parent[x] = y;
			size[y] += size[x];
			size[x] = 0;
		}
		else {
			parent[y] = x;
			size[x] += size[y];
			size[y] = 0;
		}
		return true;
	}

	//データ
	int N;// 個数
	int* parent;// 親の番号。自分自身が親なら-1。
	int* size;// 親のみ有効。自分のグループのサイズ。
};

void swap(ll* x, ll* y) {
	ll c = *y;
	*y = *x;
	*x = c;
}

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

	ll* a = new ll[N];
	ll* b = new ll[N - 1];
	ll* c = new ll[N - 1];
	bool* flag = new bool[N - 1];

	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (i != N - 1) {
			b[i] = i;
			c[i] = 0;
			flag[i] = false;
		}
	}

	cin >> M >> K;

	for (int i = 0; i < M; i++) {
		int k; cin >> k;
		swap(&b[k - 2], &b[k - 1]);
	}
	
	unionFindClass uf;
	uf.activate(N - 1);

	for (int i = 0; i < N - 1; i++) {
		if (flag[i] == false) {
			int k = i;
			while (flag[k] == false) {
				flag[k] = true;
				uf.connect(k, b[k]);
				k = b[k];
			}
		}
	}

	for (int i = 0; i < N - 1; i++) {
		flag[i] = false;
	}
	for (int i = 0; i < N - 1; i++) {
		if (flag[i] == false) {
			ll size = uf.getSize(i);
			ll r = K % size;
			int p = i;
			int q = p;
			for (int j = 0; j < r; j++) {
				q = b[q];
			}
			for (int j = 0; j < size; j++) {
				flag[p] = true;
				c[p] = q;
				p = b[p];
				q = b[q];
			}
		}
	}
	for (int i = 0; i < N - 1; i++) {
		b[i] = a[i + 1] - a[i];
	}

	ll buf = 0;
	for (int i = 0; i < N; i++) {
		if (i == 0) { buf = a[0]; }
		else {
			buf += b[c[i - 1]];
		}
		cout << buf << endl;
	}

	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
    ll mod = 1000000007;
    int n;
    cin >> n;
    map<int,int> mp;
    rep(i,n){
        int a;
        cin >> a;
        mp[a]++;
    }
    ll ans=0;
    bool flag = true;
    //奇数のとき
    if(n%2!=0){
        if(mp[0]!=1){
            flag = false;
        }
        for(int i=2;i<=n;i+=2){
            if(mp[i]!=2){
                flag = false;
                break;
            }
        }
        if(flag){
            ans=1;
            rep(i,n/2){
                ans*=2LL;
                ans%=mod;
            }
        }
    }
    //偶数
    if(n%2==0){
        for(int i=1;i<n;i+=2){
            if(mp[i]!=2){
                flag = false;
                break;
            }
        }
        if(flag){
            ans = 1;
            rep(i,n/2){
                ans*=2LL;
                ans%=mod;
            }
        }
    }
    cout << ans << endl;
	return 0;
}



Measured memory_bytes: 6468
/*****************************************************
 				*	Logged in : HABIBUR RAHMAN						 *
				*	Dept	  : COMPUTER SCIENCE AND ENGINEERING	 *
				*													 *
				*	KHULNA UNIVERSITY OF ENGINEERING AND TECHNOLOGY  *
				******************************************************/


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<string> vs;
typedef pair<ll,ll> pll;
#define fast_io 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) 				v.begin(),v.end()
#define allr(v) 			v.rbegin(),v.rend()
#define rep(i,a,b) 			for(ll i=a;i<=b;i++)
#define rep0(i,n)			for(ll i=0;i<n;i++)
#define rrep0(i, n) 		for(ll i=(ll)(n);i>0;--i)
#define rrep(i, a, b) 		for(ll i=(ll)(a);i>=(ll)(b);--i)
#define pb(z) 				push_back(z)
#define ff					/first
#define ss 					second
#define caset 				int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define sz(X) 				((ll)(X).size())
#define scan(X) 			scanf("%s", (X))
#define ms(v,val)			memset((v),(val),sizeof((v)))
#define ms0(X) 				memset((X), 0, sizeof((X)))
#define ms1(X) 				memset((X), -1, sizeof((X)))
#define m_p(a,b)            make_pair(a,b)
#define get_pos(c,x) 		(lower_bound(c.begin(),c.end(),x)-c.begin())
#define lcm(a,b)            (a*b)/__gcd(a,b)
#define INF9                1000000010
#define INF18               4000000000000000010
#define bpll(a)             __builtin_popcountll(a)
#define sqr(a)              ((a)*(a))
#define nl					"\n"
//#define mod					1e9+7;
#define mx_el(v)			*max_element(all(v));
#define mn_el(v)			*min_element(all(v));
#define pcase(z,x)    		cout<<"Case "<<z<<": "<<x<<"\n"
const double pi = 2*acos(0) ;
#define display(v)			vi :: iterator it;for(it=(v).begin();it!=(v).end();it++){cout << *it << " " ;}cout << endl;
#define taking(n,v) 		for(ll i=0;i<(n);i++){ll inp;cin>>inp;(v).push_back(inp);}

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

void solve()
{
 	 ll a,b,t;cin>>a>>b>>t;
 	 ll cnt=0,c=a;
 	 while(a<=t){
 	 	cnt+=b;
 	 	a+=c;
	  }
	  cout << cnt << nl;
}

int main() {
	fast_io
	//start();
    //caset{
    	//cout << "Case " << tt << ": ";

		  solve();
	//}
	
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int n, m;
int x, y;
int main(){
    cin >> n >> m >> x >> y;
    for (int i = 0; i< n; i++){
        int l;
        cin >> l;
        x = max(x, l);
    }
    for (int i = 0; i< m; i++){
        int l;
        cin >> l;
        y = min(y, l);
    }
    puts(x < y ? "No War" : "War");
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

		int count_bef=0;
		int count_aft=0;
		int ans=0;

		int[] A=new int[N+1];	//全部でN+1個の配列を準備

		for(int i=0;i<=N;i++) A[i]=0;	//初期条件で全部の配列に0を入れる

		for(int i=1;i<=M;i++){
			//料金所には1を格納
			int a=sc.nextInt();
			A[a]=1;
		}

		for(int j=1;j<=X;j++) {
			if(A[j]==1) count_bef++;
		}

	    for(int j=X+1;j<=N;j++) {
			if(A[j]==1) count_aft++;
		}

		if(count_bef<count_aft) ans=count_bef;
		else ans=count_aft;

		System.out.println(ans);

	}
}

Measured memory_bytes: 23764
import           Control.Monad
import           Text.Printf
import           Data.List

getLines :: Int -> IO [String]
getLines n = replicateM n getLine

getLinesInt :: Int -> IO [Int]
getLinesInt n = fmap read <$> getLines n

getInts :: IO [Int]
getInts = map (read :: String -> Int) . words <$> getLine

getDoubles :: IO [Double]
getDoubles = map (read :: String -> Double) . words <$> getLine

splitOn :: (Char -> Bool) -> String -> [String]
splitOn p s = case dropWhile p s of
    "" -> []
    s' -> w : splitOn p s'' where (w, s'') = break p s'

toInt :: [String] -> [Int]
toInt = map ((read :: String -> Int) . dropZero)

dropZero :: String -> String
dropZero s = if head s == '0' then drop 1 s else s

main :: IO ()
main = do
    [d] <- getInts
    putStrLn $ "Christmas" ++ (concat . replicate (25 - d) $ " Eve")

Measured memory_bytes: 508
def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1


n = int(input())
A = list(map(int, input().split()))

q =partition(A, 0, len(A) - 1)

print(*A[:q], end = ' ')
print('[{0}]'.format(A[q]), end = ' ')
print(*A[q + 1:])

Measured memory_bytes: 18436
#!/usr/bin/env python
# coding: utf-8

# In[1]:


N,A,B = map(int, input().split())
X = list(map(int, input().split()))


# In[2]:


c = 0
for i in range(N-1):
    dist = X[i+1] - X[i]
    if dist*A > B:
        c += B
    else:
        c += dist*A
print(c)


# In[ ]:






Measured memory_bytes: 19992
def f(b):
    a = [0, 0]
    for p in b:
        if p > a[1]:
            a[1] = p
        elif p > a[0]:
            a[0] = p
        else:
            return False
        a.sort()
    return True

for i in range(int(raw_input())):
    print 'YES' if f(map(int, raw_input().split())) else 'NO'

Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5000 * 5000 + 5;
int n;
int a[6][6];
long long dp[maxn];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n;
	for(int i = 0; i < 2; ++i) {
		for(int j = 0; j < 3; ++j) {
			cin >> a[i][j];
		}
	}
	for(int i = 1; i <= n; ++i) {
		dp[i] = i;
	}
	for(int i = 0; i < 3; ++i) {
		for(int j = a[0][i]; j <= n; ++j) {
			dp[j] = max(dp[j], dp[j - a[0][i]] + a[1][i]);
		}
	}
	int lim = dp[n];
	long long ans = dp[n];
	for(int i = 1; i <= lim; ++i) {
		dp[i] = i;
	}
	for(int i = 0; i < 3; ++i) {
		for(int j = a[1][i]; j <= lim; ++j) {
			dp[j] = max(dp[j], dp[j - a[1][i]] + a[0][i]);
		}
	}
	cout << max(ans, dp[lim]) << '\n';
	return 0;
}

Measured memory_bytes: 195584
<?php
$N = fgets(STDIN);
$arr = explode(" ", fgets(STDIN));
$ans = -999999999;
for ($i=0; $i < count($arr); $i++) {
    for ($j=0; $j < count($arr); $j++) {
        if ($i === $j) {
            continue;
        }
        $ans = max($ans, abs($arr[$i] - $arr[$j]));
    }
}
echo $ans."\n";


Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

bool kaibun(string s){
    int n = s.size();
    bool flag = true;
    if(n%2 == 0){
        int i = 0, j = n-1;
        for(; j >= n/2 && flag;){
            if(s[i] == s[j])    flag = true;
            else                flag = false;
            ++i;    --j;
        }
    }else{
        int i = 0, j = n-1;
        for(; j >= (n+1)/2 && flag;){
            if(s[i] == s[j])    flag = true;
            else                flag = false;
            ++i;    --j;
        }
    }
    return flag;
}

int main(){
    string s;   cin >> s;
    int n = s.size();
    if(kaibun(s) && kaibun(s.substr(0, (n-1)/2)) && kaibun(s.substr((n+3)/2-1))){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

signed main(void){
  int n; cin >> n;
  vector<int> to(n);
  for(int i = 1; i < n; i++){ 
    int a; cin >> a; a--;
    to[a]++;
  }
  
  for(int i = 0; i < n; i++){ 
    cout << to[i] << endl;
  }
  
  return 0;
}

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

using namespace std;

int main()
{
	int n,k;cin>>n>>k;
	vector<int> v(n);
	for(int i=0;i<n;++i) cin>>v[i];

	int a=(n-k);
	int b=0,c=k,count=0;

	while(count<a)
	{
		if(v[c]>v[b]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		count++;
		b++;
		if(c<n) c++;
	}

}

Measured memory_bytes: 3980
#include <bits/stdc++.h>
    using namespace std;
    
    long long gcd(long long a, long long b) {
        if(b == 0)
            return a;
        else
            return gcd(b, a % b);
    }
    
    long long lcm (long long a, long long b) {
        return a / gcd(a, b) * b;
    }

    int main(){
        long long n , m ;
        string s , t;
        cin >> n >> m >> s >> t ;
        long long ans = -1;
        if(s[0] != t[0]){
            cout << ans << endl;
            return 0;
        }
        if(n == m){
            if(s == t){
                cout << n << endl;
                return 0;
            }else{
                cout << ans << endl;
            }
        }
        ans = lcm(n , m);
        long long n2 , m2;
        n2 = ans / m;
        m2 = ans / n;
        vector<long long> v1 , v2;
        for(long long i = 0 ; i < n ; i = i + n2){
            v1.push_back(s[i]);
        }
        for(long long i = 0 ; i < m ; i = i + m2){
            v2.push_back(t[i]);
        }
        for(long long i = 0; i < v1.size() ; i++){
            if(v1[i] != v2[i]){
                cout << -1 << endl;
                return 0;
            }
        }
        cout << ans << endl;
        return 0;
    }

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> cnt(N, 0);
    vector<bool> accepted(N, false);
    rep(i, M) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (!accepted[p]) {
            if (s == "AC")accepted[p] = true;
            else cnt[p]++;
        }
    }
    int accnt = 0;
    int penalty = 0;
    rep(i, N)if (accepted[i]) {
        accnt++;
        penalty += cnt[i];
    }
    cout << accnt << " " << penalty << endl;
    return 0;
}


Measured memory_bytes: 640
#AGC047-A Integer Product
"""
小数または整数が与えられるので、その積が整数となるペアの個数を求めよ。

まず入力に10**9をかけることで、
問題を「その積が10**18の倍数となるペアの個数を求めよ」
とする。
その場合、とりあえず10**18を素因数分解すると2**18と5**18なので、
片方が因数分解済みであるとした時に、
dp[i][j] : 2**iかつ5**jの個数
として、もう片方を2**aかつ5**bであると考えた時に、
2**(i+a)>=18かつ5**(j+b)>=18となるならば、それは条件を満たす
と考えられる。

よってこの個数を数えることで問題が解けた。
"""
import sys
from decimal import Decimal
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n = int(readline())

dp = [[0]*100 for _ in range(100)]

ans = 0

for i in range(n):
    s = readline().rstrip().decode('utf-8')
    res = int(Decimal(s)*(10**9))
    t,f = 0,0
    while True:
        if res%2==0:
            res //= 2
            t += 1
        else:
            break
    while True:
        if res%5==0:
            res //= 5
            f += 1
        else:
            break
    #i+t>=18かつj+f>=18であるような場所からカウント
    #最悪10**13になるので、2**44,5**19の用意が必要
    for i in range(18-t,45):
        for j in range(18-f,20):
            ans += dp[i][j]
    dp[t][f] += 1

print(ans)

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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par,sz,vis;
vector<vi> graph;

void init(li n)
{
    par.resize(n);
    sz.resize(n);
    vis.resize(n);
    graph.resize(n);

    f(i,0,n-1)
    {
        par[i]=i;
        sz[i]=1;
    }
}

li root(li a)
{
    while(a!=par[a])
    {
        par[a]=par[par[a]];
        a=par[a];
    }

    return a;
}

void unio(li a,li b)
{
    li r_a=root(a);
    li r_b=root(b);

    if(par[r_a]!=r_b)
    { 
        if(sz[r_a]<sz[r_b])
        {
            par[r_a]=par[r_b];
            sz[r_b]+=sz[r_a];
            sz[r_a]=0;
        }
        else
        {
            par[r_b]=par[r_a];
            sz[r_a]+=sz[r_b];
            sz[r_b]=0;
        }
    }
}

li gcd(li a,li b)
{
    if(b==0)
    {
        return a;
    }
    
    return gcd(b,a%b);
}

li MA=10000001;

vector<li> prime(MA);

void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (int i = 2; i < MA; i++) { 
        if (prime[i] == 0) { 
            for (int j = i * 2; j < MA; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
} 

int main()
{  

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li n,M=1e9+7;

    cin>>n;

    li a[n];

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

    sieve();

    u_map<li,li> mxm;

    f(i,0,n-1)
    {
        u_map<li,li> tp;

        li num=a[i];

        while(num>1)
        {
            li fact=prime[num];

            tp[fact]++;

            num/=fact;
        }

        for(auto it:tp)
        {
            mxm[it.F]=max(mxm[it.F],it.S);
        }
    }

    li ans=1;

    for(auto it:mxm)
        {
            ans= (ans * fastpow(it.F,it.S,M))%M;
        }

    li cnt=0;

    f(i,0,n-1)
    {
        cnt = (cnt + (ans*fastpow(a[i],M-2,M))%M)%M;
    }

    cout<<cnt;

    return 0;
}

Measured memory_bytes: 78848
#include <cstdio>
#include <algorithm>
using namespace std;
int main(void)
{
  int n;
  for(;;){
    int ma,mi; ma=0; mi=500;
    scanf("%d",&n); if(!n)break;
    for(int i=0;i<n;i++){
      int s=0;
      for(int j=0;j<5;j++){
        int a; scanf("%d",&a);
        s+=a;
      }
      ma=max(ma,s);
      mi=min(mi,s);
    }
    printf("%d %d\n",ma,mi);
  }
}

Measured memory_bytes: 0
using System;
class Program
{
	static void Main(string[] args)
	{
		// パラメータ準備
		int N = int.Parse(Console.ReadLine()); 
		string[] input1 = Console.ReadLine().Split(' ');
		int T = int.Parse(input1[0]);	
		int A = int.Parse(input1[1]);	
		string[] input2 = Console.ReadLine().Split(' ');
		int[] H = new int[N];			
		
		for( var i = 0; i < N; i++ ){
			H[i] = int.Parse(input2[i]);
		}
		
		int index = 0;
		double MinDiffT = A - ( T - H[0] * 0.006 );
		for( var i = 1; i < N; i++ ){
			double t = T - H[i] * 0.006;
			double diff = A - t;
			if(  Math.Abs(diff) < Math.Abs(MinDiffT) ){
				MinDiffT = diff;
				index = i;
			}
		}
		Console.WriteLine(index + 1);
	}
}
		


Measured memory_bytes: 13204
// Problem : D - RGB Triplets
// Contest : AtCoder - AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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


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

    long n;
    string s;
    cin >> n;
    cin >> s;
    long long r = 0, g = 0, b = 0;
    for (long i = 0; i < n; i++) {
        if (s[i] == 'R') r++;
        else if (s[i] == 'G') g++;
        else b++;
    }
    long long count = r * g * b;
    for (long i = 0; i < n; i++) {
        for (long j = i + 1; j < n; j++) {
            long k = j + (j - i);
            if (k < n) {
                if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) count--;
            }
        }
    }
    cout << count;
    
    return 0;
}


Measured memory_bytes: 3664
import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

N行M列の初期化
dp = [[INF] * M for i in range(N)]

'''

"""""""""""""""""""""""""""""""""
 最大公約数 O()
"""""""""""""""""""""""""""""""""
# fractions.gcd(a,b)
def gcd(a, b):
    return fractions.gcd(a, b)

"""""""""""""""""""""""""""""""""
 最小公倍数 O()
"""""""""""""""""""""""""""""""""
def lcm(a,b):
    return (a*b) // fractions.gcd(a,b)


N, M = map(int, input().split())
A = list(map(int,input().split()))


twice = 1
while True:
    if A[0] % (twice*2) == 0:
        twice*=2
    else:
        break

for a in A:
    if a%twice != 0:
        print(0)
        sys.exit()
    elif a%(twice*2) == 0:
        print(0)
        sys.exit()

               

koubais = [] # 隣り合った２つの最小公倍数のリスト
for i in range(0, N, 2):
    if i == N-1:
        koubais.append(A[i]//2)
        break

    A[i] //= 2
    A[i+1] //= 2
    koubais.append(lcm(A[i+1], A[i]))

half = 1
for i in range(len(koubais)):
    half = lcm(half, koubais[i])

ans = (M//half + 1) // 2
print(int(ans))





Measured memory_bytes: 16348
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;


int main(){
    int n, d, x;
    cin >> n >> d >> x;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        for(int j = 0; ; j++){
            if(j*a+1 <= d){
                cnt++;
            }else{
                break;
            }
        }
    }
    cout << x + cnt << endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
static const int MAX=10;
 
int n,m;
int d[MAX]={};
int R[MAX][MAX]={};
bool all_visit;
 
int dfs(int x){
    all_visit=true;
    for(int i=0;i<n;i++){
        if(d[i]==0){
            all_visit=false;
        }
    }
 
    if(all_visit) return 1;
 
    int ans=0;
 
    for(int i=0;i<n;i++){
        if(d[i]==0&&R[x][i]!=0){
            d[i]=1;
            ans+=dfs(i);
            d[i]=0;
        }
    }
    return ans;
}
 
int main(){
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        R[a][b]++;
        R[b][a]++;
    }
    d[0]=1;
    cout << dfs(0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void solve()
{
	int n;
	cin>>n;
	int rem=n%1000;
	int ans;
	if(rem!=0)
		ans=1000-rem;
	else
		ans=0;
	cout<<ans<<endl;
}
int main()
{
	solve();
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;
const int FIVE = 101010;

//=============================
int N,M,K;
string S,T;
vector<int> A;
vector<int> B;
//=============================
void input()
{
    cin>>S;
}
//=============================
void func(){}
//=============================
void solve()
{
    int N = S.size();
    int l = 77;
    vector<vector<int> > DP(l+1, vector<int>(N,-1));
    rep(i,N){
        DP[0][i] = i + (S[i]=='R' ? 1 : -1);
    }

    for (int k = 0; k<l ; ++k){
        rep(i,N){
            if (DP[k][i] == -1){
                DP[k+1][i] = -1;
            }
            else {
                DP[k+1][i] = DP[k][DP[k][i]];
            }
        }
    }
    vector<int> ans(N,0);
    rep(i,N){
        int p = i;
        for (int k = l-1; k>=0; --k){
            if (p == -1) {
                break;
            }
            if ((100000 >> k) & 1){
                p = DP[k][p];
            }
        }
        ans[p]++;
    }

    rep(i,N){
    cout<<ans[i]<<(i==N-1 ? "\n" : " ");
    }

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

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

int main()
{
    int N, K, Q;
    cin >> N >> K >> Q;
    int Qi[N];
    for (int i = 0; i < N; i++)
    {
        Qi[i] = 0;
    }
    for (int i = 0; i < Q; i++)
    {
        int player;
        cin >> player;
        Qi[player - 1]++;
    }
    for (int i = 0; i < N; i++)
    {
        if (Qi[i] > Q - K)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 1024
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 100002;

int n;

int a[N_MAX];

ll pref[N_MAX];

bool suff[N_MAX];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n; i++)
        pref[i] = pref[i - 1] + a[i];
    int pos = n - 1;
    while(pos > 0 && pref[pos] * 2 >= a[pos + 1])
        pos--;
    cout << n - pos << "\n";
    return 0;
}


Measured memory_bytes: 4788
#include <iostream>
#include <fstream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <queue>
#include <bits/stl_numeric.h>

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;


int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;
    cin >> c;
    char res;

    res = c + 1;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//ダイクスト①
//O(n^2)
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

#define V_MAX   1010
#define E_MAX   V_MAX(V_MAX-1)/2

int N, M;
int A, B, C;
int s, g;
int p[V_MAX][V_MAX];
int d[V_MAX];
bool flag[V_MAX];
int MIN;
int idx;

void dijkstra( int S ){
	fill( flag, flag+V_MAX, 1 );
	fill( d, d+V_MAX, -1 );
	d[S] = 0;
	REP( i, N ){
		MIN = mod;
		FOR( j, 1, N+1 ){
			if( 0 <= d[j] && d[j] < MIN && flag[j] ){
				MIN = d[j];
				idx = j;
			}
		}
		flag[idx] = 0;
		FOR( j, 1, N+1 ){
			if( p[idx][j] < 0 || !flag[j] ) continue;
			if( d[j] < 0 ) d[j] = d[idx]+p[idx][j];
			d[j] = min( d[j], d[idx]+p[idx][j] );
		}
	}
}

int ans = 0;

int main(){
	
	cin>>N>>M;
	//cin>>s>>g;
	
	fill( p[0], p[V_MAX], -1 );
	
	REP( i, M ){
		scanf("%d %d %d", &A, &B, &C);
		p[A][B] = C;
		p[B][A] = C;
	}
	
	FOR( a, 1, N+1 ){
		dijkstra( a );
		FOR( b, a+1, N+1 ){
			if( p[a][b] != d[b] && p[a][b] >= 0 ) ans++;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
	
}

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

#define int long long
const int N = 3005;
int dp[N][N];
pair<int,int> state[N][N];

int32_t main(){
    string s,t;
    cin >> s >> t;
    int n = s.length(), m = t.length();
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            state[i][j] = {0,0};
            if(i==0 || j==0){
                continue;
            }
            if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1]+1;
                state[i][j] = {i-1,j-1};
            }
            else{
                if(dp[i-1][j] > dp[i][j]){
                    dp[i][j] = dp[i-1][j];
                    state[i][j] = state[i-1][j];
                }
                if(dp[i][j-1] > dp[i][j]){
                    dp[i][j] = dp[i][j-1];
                    state[i][j] = state[i][j-1];
                }
            }
        }
    }
    // for(int i=0;i<=n;i++){
    //     for(int j=0;j<=m;j++){
    //         cout<<"{ "<<state[i][j].first<<" "<<state[i][j].second<<" "<<dp[i][j]<<" }"<<" ";
    //     }
    //     cout<<endl;
    // }
    int x = n,y = m;
    string ans = "";
    if(dp[n][m] == 0){
        cout<<ans<<endl;
        return 0;
    }
    while(x > 0 && y > 0){
        if(dp[x][y] == 0){
            break;
        }
        if(x == state[x][y].first && y == state[x][y].second){
            break;
        }
        // if(state[x][y].first == x-1 && state[x][y].second == y-1){
        //     ans += t[y-1];
        // }
        // cout<<"x : "<<x<<endl;
        // cout<<"y : "<<y<<endl;
        // cout<<"state : "<<state[x][y].first<<" "<<state[x][y].second<<endl;
        ans += t[state[x][y].second];
        
        int tempx,tempy;
        tempx = state[x][y].first;
        tempy = state[x][y].second;
        x = tempx;
        y = tempy;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    // cout<<dp[n][m]<<endl;
}



Measured memory_bytes: 214956
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;


 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);
  
 

ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 


 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

ll modpow(ll a,ll n,ll mod){
  ll ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  //vll segtree(524287);
  //ll N=262144;
  ll n,m;
    cin>>n>>m;
  ll ans=0;
  if(2*n>m){
     cout<<m/2<<endl;
     return;
  }

  cout<<n+(m-2*n)/4<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define Rrep(i,n) for(int i=((int)n-1); i>=0; i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e15
#define MOD 10e9+7

typedef vector<int> vint;
typedef long long ll;



int main()
{
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(15);

        ll k;
        cin>>k;
        vector <ll> a(k,0);

        a[0]=7%k;
        if(a[0]==0){cout<< 1 <<endl; return 0;}

        for(ll i = 1; i < k ; i++){
                a[i] = (10*a[i-1]+7)%k;
                if(a[i] == 0){cout<< i+1 <<endl; return 0;}
        }
        cout<< -1 <<endl;

        return 0;
}


Measured memory_bytes: 11036
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int f(int a, int b, int x){
	int ans = 0;
	int l = x*(a/x)+x*(!!(a%x));
	int r = x*(b/x);
	return (r-l)/x+1;
}
int32_t main(){
	int a,b,x,y;
	cin>>a>>b>>x>>y;
	int ans = b-a+1;
	//cout<<ans<<endl;
	ans -= f(a,b,x);
	//cout<<ans<<endl;
	ans -= f(a,b,y);
	//cout<<ans<<endl;
	ans += f(a,b,(x*y)/__gcd(x,y));
	cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
int main()
{
    ///"In the name of Allah,most gracious and most merciful"///

    ll i,j,y,count=1,sum=0,n,ans=0;
    string s;
    cin>>s;

    for(i=s.size()-3; i>=0; i-=2)
    {
        string w,q;
        ll x;
        x=i/2;
        w=s.substr(0,x);
        q=s.substr(x+1,x);
        if(w==q)
        {
            y=x+x;
            break;
        }

    }
    cout<<y+2<<endl;

    return 0;
}






Measured memory_bytes: 3632
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

class SegmentTree:
    def __init__(self, func, arr, default):
        self.func = func
        self.arr = arr
        self.default = default
        
        self.arrlen = len(self.arr)
        self.bitlen = (len(self.arr)-1).bit_length() + 1
        self.bottomlen = pow(2, self.bitlen-1)
        self.bottomst = pow(2, self.bitlen-1) - 1
        
        self.segtree = [self.default] * (2*self.bottomlen - 1)
        self.segtree[self.bottomst:self.bottomst+self.arrlen] = self.arr
        
        for idx in range(self.bottomst-1, -1, -1):
            self.segtree[idx] = self.func(self.segtree[2*idx+1],
                                          self.segtree[2*idx+2])
    
    # idx番目の値をxに変更(0-indexed)
    def update(self, idx:int, x:int):
        idx += self.bottomst
        self.segtree[idx] = x
        while idx > 0:
            idx = (idx-1)//2
            self.segtree[idx] = self.func(self.segtree[2*idx+1],
                                          self.segtree[2*idx+2])
        
    # [a,b) の値を取得(0-indexed)
    def query(self, a:int, b:int, idx:int, l:int, r:int):
        if r <= a or b <= l:
            return self.default
        
        elif a <= l and r <= b:
            return self.segtree[idx]
        
        else:
            return self.func(self.query(a,b, 2*idx+1, l, (l+r)//2),
                             self.query(a,b, 2*idx+2, (l+r)//2, r))

    # リセット
    def reset(self):
        self.segtree = [self.default] * (2*self.bottomlen - 1)
        self.segtree[self.bottomst:self.bottomst+self.arrlen] = self.arr
        
        for idx in range(self.bottomst-1, -1, -1):
            self.segtree[idx] = self.func(self.segtree[2*idx+1],
                                          self.segtree[2*idx+2])
            

n,q = li()
default = pow(2,31)-1
arr = [default]*n
segtree = SegmentTree(min, arr, default)
nbit = pow(2, (n-1).bit_length())

for _ in range(q):
    command, a, b = li()
    
    if command == 0:
        segtree.update(a,b)
    
    elif command == 1:
        print(segtree.query(a,b+1,0,0,nbit))
        



Measured memory_bytes: 10220
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    n,k = LI()
    s = set(LS())
    for i in range(n,n*100):
        t = set(_ for _ in str(i))
        if not (t & s):
            return i

    return 0


print(main())


Measured memory_bytes: 5416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair < ll, ll > PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e4+7;
int main() {
    int n;
    cin >> n;
    bool odd = false;
    rep(i, n) {
        ll tmp_a;
        cin >> tmp_a;
        if ( tmp_a & 1 ) odd = true;
    }
    if ( odd ) cout << "first" << endl;
    else       cout << "second" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
using namespace std;
#define int long long
#define inf 1145141919
#define mod 1000000007
struct edge {int to, cost;};
typedef pair<int, int> P;
int a[114514];

signed main(){
	int k;
	cin >> k;
	for (int i = 0; i < k; i++)cin >> a[i];
	if (a[k - 1] != 2)puts("-1");
	else {
		int mn = 2, mx = 3;
		for (int i = k - 2; i > -1; i--) {
			int na = (mn + a[i] - 1) / a[i];
			na *= a[i];
			int xa = mx / a[i];
			xa *= a[i];
			xa += a[i] - 1;
			mn = na, mx = xa;
		}
		if (mn > mx)puts("-1");
		else cout << mn << ' ' << mx << endl;
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> T(N);
    for(int i=0; i<N; i++) {
        cin >> T[i];
    }
    int sum =accumulate(T.begin(), T.end(), 0);
    
    int M;
    cin >> M;
    while(M--) {
        int P, X;
        cin >> P >> X;
        cout << sum - T[P-1] + X << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val t = s[0].toString().repeat(s.length)
    if (s <= t) {
        println(t)
    } else {
        println((s[0] + 1).toString().repeat(s.length))
    }
}

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

int main(){
 vector <int> vec(9);
 int N ;
    
 for(int i = 0; i<9 ; i++){
   cin >> vec.at(i);
 }
    cin >> N;
 for(int i = 0; i<N ;i++){
   int x;
   cin >> x;
   for(int j = 0; j < 9 ;j++){
     if(x == vec.at(j)){
       vec.at(j) = 'a';
     }
   }
 }
    if(vec.at(0) == 'a' && vec.at(1) == 'a' && vec.at(2) == 'a'){
        cout << "Yes" << endl;
    }
    
    else if(vec.at(3) == 'a' && vec.at(4) == 'a' && vec.at(5) == 'a'){
     cout << "Yes" << endl;
    }
    
    else if(vec.at(6) == 'a' && vec.at(7) == 'a' && vec.at(8) == 'a'){
        cout << "Yes" << endl;
    }
    
    else if(vec.at(0) == 'a' && vec.at(3) == 'a' && vec.at(6) == 'a'){
        cout << "Yes" << endl;
    }
    
    else if(vec.at(1) == 'a' && vec.at(4) == 'a' && vec.at(7) == 'a'){
        cout << "Yes" << endl;
    }
    
    else if(vec.at(2) == 'a' && vec.at(5) == 'a' && vec.at(8) == 'a'){
        cout << "Yes" << endl;
    }
    
    else if(vec.at(0) == 'a' && vec.at(4) == 'a' && vec.at(8) == 'a'){
        cout << "Yes" << endl;
    }
    
    else if(vec.at(2) == 'a' && vec.at(4) == 'a' && vec.at(6) == 'a'){
        cout << "Yes" << endl;
    }
    
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256