akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 200000000
#define mod 1000000007
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 1005

ll mark[ma][ma],cost[ma][ma];
string t[ma];
ll a[ma*ma];
ll bfs(ll x,ll y,ll cn)
{
    ll ans=0,i,j;
    queue<ll>q;
    q.push(x);q.push(y);
    mark[x][y]=cn;
    while(q.sz)
    {
        ll ur=q.front();q.pop();
        ll uc=q.front();q.pop();
        for(i=0;i<4;i++)
        {
            ll vr=dr2[i]+ur;
            ll vc=dc2[i]+uc;
            if(t[vr][vc]=='*')
            {
                ans++;
                continue;
            }
            if(mark[vr][vc]==cn)continue;
            mark[vr][vc]=cn;
            q.push(vr);q.push(vc);
        }
    }
    a[cn]=ans;
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,q,i,j,m,g,r,u,v,k;
    while(cin>>n)
    {
        vector<ll>v;
        for(i=1;i<=sqrt(n);i++)
        {
            if(n%i==0)
            {
                if(i!=1)v.pb(i);
                if(i*i!=n)v.pb(n/i);
            }
        }
        sort(v.begin(),v.end());
        ll m=n-1;
        for(i=1;i<=sqrt(m);i++)
        {
            if(m%i==0)
            {
                if(i!=1)
                v.pb(i);
                if(i*i!=m)v.pb(m/i);
            }
        }
        ll ans=0;
        for(i=0;i<v.sz;i++)
        {
            ll m=n;
            while(m%v[i]==0)m/=v[i];
            if(m%v[i]==1)ans++;
        }
        cout<<ans<<endl;

    }
    return 0;
}


Measured memory_bytes: 3720
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100000+50;
int A,B,C,X,Y;
long long p[maxn],q[maxn],r[maxn];
int main()
{
    scanf("%d %d %d %d %d",&X,&Y,&A,&B,&C);
    for(int i=1;i<=A;i++)
    {   
        int tp;
        scanf("%d",&tp);
        p[i]=tp;
    }
    for(int i=1;i<=B;i++)
    {   
        int tp;
        scanf("%d",&tp);
        q[i]=tp;
    }
    for(int i=1;i<=C;i++)
    {   
        int tp;
        scanf("%d",&tp);
        r[i]=tp;
    }
    sort(p+1,p+1+A);
    sort(q+1,q+1+B);
    sort(r+1,r+1+C);
    long long ans=0;
    for(int i=A-X+1;i<=A;i++) ans+=p[i];
    for(int i=B-Y+1;i<=B;i++) ans+=q[i];
    int now=C,nowi=A-X+1,nowj=B-Y+1;
    while(1)
    {   
        bool flag=0;
        if(nowi<=A&&nowj<=B)
        {
            if(p[nowi]<q[nowj]&&p[nowi]<r[now])
            {
                ans+=r[now]-p[nowi];
                nowi++;
                now--;
                flag=1;
            }
            else
            if(p[nowi]>=q[nowj]&&q[nowj]<r[now])
            {
                ans+=r[now]-q[nowj];
                nowj++;
                now--;
                flag=1;
            }
        } 
        else
        {
            if(nowi<=A)
            {
                if(p[nowi]<r[now])
                {
                    ans+=r[now]-p[nowi];
                    nowi++;
                    now--;
                    flag=1;
                }
            }
            else
            if(nowj<=B&&q[nowj]<r[now])
            {
                ans+=r[now]-q[nowj];
                nowj++;
                now--;
                flag=1;
            }
        }
        if(!flag) break;
        if(now==0||nowi>A&&nowj>B) break;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
    private static int n;
    private static long a, b;
    private static long[] enemy;

    private static boolean C(long k) {
        long cnt = 0;
        for (long hp : enemy) {
            hp -= b * k;
            if (hp > 0) {
                cnt += Math.ceil((double) hp / (a - b));
            }
        }

        if (cnt > k) return false;
        else return true;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        n = Integer.parseInt(str[0]);
        a = Long.parseLong(str[1]);
        b = Long.parseLong(str[2]);

        enemy = new long[n];
        for (int i = 0; i < n; i++) enemy[i] = Long.parseLong(br.readLine());

        long l = 0, r = (long) 1e9+1, med = -1;
        while (r - l > 0) {
            med = (r + l) / 2;
            if (C(med)) {
                r = med;
            } else {
                l = med + 1;
            }
        }
        System.out.println(l);
    }
}


Measured memory_bytes: 32468
import java.util.*;

class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String[] args){
    int  n = sc.nextInt();
    int[] h = new int[n+1];
    for(int i=0;i<n;i++){
      h[i]=sc.nextInt();
    }
    h[n]=Integer.MAX_VALUE;
    int max=0;
    int ple=h[0];
    int pdx=0;
    for(int i=1;i<=n;i++){
      if(ple>=h[i]){
        ple=h[i];
      }else{
        max=Math.max(i-pdx-1,max);
        ple=h[i];
        pdx=i;
      }
    }
    System.out.println(max);
  }
}


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

class Program
{

    public static void Main( )
    {
        var input = Console.ReadLine( ).Split( ).Select( long.Parse ).ToArray( );
        long A = input[ 0 ];
        long B = input[ 1 ];
        long N = input[ 2 ];
        long x = Math.Min( B - 1, N );
        Console.WriteLine( Convert.ToInt64( A * x / B ) );

    }

}


Measured memory_bytes: 28000
#include<bits/stdc++.h>
    using namespace std;
    int main(){
      	int n,k;
        cin >> n >> k;
      	vector<int> a(n);
      	for(int i = 0;i<n;++i)
             cin >> a[i];
      	sort(a.begin(),a.end());
        long long moves = 0;
        for(int  i = 0;i<n-k;++i)
          moves+=a[i];
        cout << moves<<"\n";
    	return 0;
    }

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,place,num,i,stack,count = 0;
  cin >> n;
  cin >> place;
  for (i = 1; i <= n;i++){
    cin >> num;
    stack = abs(num - place);
    if(stack <= num){
      count = count + 2 * stack;
    }
    else{
      count = count + 2 * num;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#122 b
s=list(input())

c=["A","T","C","G"]
ans=0
i=0
while s:
    cnt=0
    if s[0] not in c:
        s.pop(0)
        continue
    while s[0] in c:
        s.pop(0)
        cnt+=1
        if s==[]:
            break
    if ans<cnt:
        ans=cnt
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main() {
    string s;cin>>s;
    if(s.size()==2)cout<<s<<endl;
    else{
        reverse(all(s));cout<<s<<endl;
    }
}

Measured memory_bytes: 256
N,M=map(int,input().split())
x=[]
y=[]
z=[]
for i in range(0,N):
    X,Y,Z=map(int,input().split())
    x.append(X)
    y.append(Y)
    z.append(Z)

ans=0

list1=[[x[i]+y[i]+z[i],x[i],y[i],z[i]] for i in range(0,N)]
list1.sort(reverse=True)
X=sum(list1[i][1] for i in range(0,M))
Y=sum(list1[i][2] for i in range(0,M))
Z=sum(list1[i][3] for i in range(0,M))
if X>=0 and Y>=0 and Z>=0:
    test=sum(list1[i][0] for i in range(0,M))
    ans=max(ans,test)
X=sum(list1[-i-1][1] for i in range(0,M))
Y=sum(list1[-i-1][2] for i in range(0,M))
Z=sum(list1[-i-1][3] for i in range(0,M))
if 0>=X and 0>=Y and 0>=Z:
    test=sum(-list1[-i-1][0] for i in range(0,M))
    ans=max(ans,test)

list2=[[-x[i]+y[i]+z[i],x[i],y[i],z[i]] for i in range(0,N)]
list2.sort(reverse=True)
X=sum(list2[i][1] for i in range(0,M))
Y=sum(list2[i][2] for i in range(0,M))
Z=sum(list2[i][3] for i in range(0,M))
if 0>=X and Y>=0 and Z>=0:
    test=sum(list2[i][0] for i in range(0,M))
    ans=max(ans,test)
X=sum(list2[-i-1][1] for i in range(0,M))
Y=sum(list2[-i-1][2] for i in range(0,M))
Z=sum(list2[-i-1][3] for i in range(0,M))
if X>=0 and 0>=Y and 0>=Z:
    test=X-Y-Z
    ans=max(ans,test)

list3=[[x[i]-y[i]+z[i],x[i],y[i],z[i]] for i in range(0,N)]
list3.sort(reverse=True)
X=sum(list3[i][1] for i in range(0,M))
Y=sum(list3[i][2] for i in range(0,M))
Z=sum(list3[i][3] for i in range(0,M))
if X>=0 and 0>=Y and Z>=0:
    test=sum(list3[i][0] for i in range(0,M))
    ans=max(ans,test)
X=sum(list3[-i-1][1] for i in range(0,M))
Y=sum(list3[-i-1][2] for i in range(0,M))
Z=sum(list3[-i-1][3] for i in range(0,M))
if 0>=X and Y>=0 and 0>=Z:
    test=-X+Y-Z
    ans=max(ans,test)

list4=[[x[i]+y[i]-z[i],x[i],y[i],z[i]] for i in range(0,N)]
list4.sort(reverse=True)
X=sum(list4[i][1] for i in range(0,M))
Y=sum(list4[i][2] for i in range(0,M))
Z=sum(list4[i][3] for i in range(0,M))
if X>=0 and Y>=0 and 0>=Z:
    test=sum(list4[i][0] for i in range(0,M))
    ans=max(ans,test)
X=sum(list4[-i-1][1] for i in range(0,M))
Y=sum(list4[-i-1][2] for i in range(0,M))
Z=sum(list4[-i-1][3] for i in range(0,M))
if 0>=X and 0>=Y and Z>=0:
    test=-X-Y+Z
    ans=max(ans,test)

print(ans)


Measured memory_bytes: 46064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int a[N];
    string ans="second";
    rep(i,N){
        cin>>a[i];
        if(a[i]%2!=0) ans="first";
    }
    cout << ans << endl;

    



}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const ll INF=1<<30;
ll copy(ll x){
	return x;
}

int main(){
	ll n;cin>>n;
	vector<ll> a(n);
	for(ll i = 0; i < n; i++) {
		cin>>a[i];
	}
	if (a[0] != 0LL){
		cout << -1 << endl;
		return 0;
	}

	for (ll i = 1; i < n; i++) {
         if (a[i] - a[i - 1] > 1) {
             cout << -1 << endl;
             return 0;
         }
     }
	ll l = 0LL;
	ll ans = 0LL;
	for(ll i = 1; i < n; i++) {
		if (a[i] == 0LL){
			l = copy(i);
		}
		else{
			if ((a[i] - a[i - 1]) == 1LL){
				ans++;
			}
			else{
				if ((i - l) >= a[i]){
					ans += a[i];
				}
				else{
					cout << -1 << endl;
					return 0;
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
n, m = list(map(int, input().split()))
abm = [list(map(int, input().split())) for _ in range(m)]
abm = set(tuple(sorted(item)) for item in abm)
edges = {}
for a, b in abm:
    if a not in edges:
        edges[a] = [b]
    else:
        edges[a].append(b)
    if b not in edges:
        edges[b] = [a]
    else:
        edges[b].append(a)

import collections
vis = [False for _ in range(n + 1)]
gr = {}
def create_group(s):
    if vis[s]:
        return None
    
    deq = collections.deque()
    deq.append(s)
    group = []
    while len(deq):
        node = deq.popleft()
        if vis[node]:
            continue
        group.append(node)
        vis[node] = True
        for e in edges.get(node, []):
            deq.append(e)

    for g in group:
        gr[g] = s
    return group


groups = [create_group(i) for i in range(1, n + 1)]
groups = list(filter(lambda x:x, groups))

ans = max(map(len, groups))
print(ans)


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    bool yes = false;
    while(n > 0) {
        yes |= n % 10 == 7;
        n /= 10;
    }
    
    cout << (yes ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3648
use proconio::input;
use std::cmp::{max, min};

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }

    if k >= n - 1 {
        println!("{}", a.iter()
            .map(|_| n.to_string())
            .collect::<Vec<_>>()
            .join(" ")
        );
        return;
    }

    let mut b = a;
    for _ in 0..k {
        let mut s = vec![0isize; n + 1];
        for i in 0..n {
            s[max(b[i], i) - b[i]] += 1;
            s[min(n, i + b[i] + 1)] -= 1;
        }
        b = vec![0; n];
        let mut t = 0;
        let mut f = true;
        for i in 0..n {
            t += s[i];
            b[i] = t as usize;
            if b[i] < n {
                f = false;
            }
        }
        if f {
            break;
        }
    }

    let b = b.iter()
        .map(|bi| bi.to_string())
        .collect::<Vec<_>>()
        .join(" ");
    println!("{}", b);
}


Measured memory_bytes: 17276
length = int(input())
target = [int(n) for n in input().split(" ")]
if max(target) - min(target) > 1:
    print("No")
elif max(target) >= length:
    print("No")
elif max(target) - min(target) == 1 and (target.count(min(target)) == min(target) and target.count(max(target)) > 1 or (target.count(min(target)) <= min(target) and target.count(max(target)) // 2 >= max(target) - target.count(min(target)) )  ):
    print("Yes")
elif max(target) - min(target) == 0 and ( (length % 2 == 0 and min(target) * 2 <= length) or (length % 2 == 1 and 2 * (min(target) - 1) + 3 <= length)  or min(target) + 1 == length):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 13964
#include<stdio.h>
int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	int i,j;
	while(h!=0||w!=0){
		
		for(i=0;i<h;i++){
			int flg=0;
			if(i!=0||i!=h-1) flg=1;
			if(flg==0){
				for(j=0;j<w;j++) printf("#");
			}
			
			else{
				for(j=0;j<w;j++){
					if(i==0||i==h-1||j==0||j==w-1) printf("#");
					else printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
		scanf("%d%d",&h,&w);
	}
	return 0;
}



Measured memory_bytes: 2104
#include "iostream"
#include "random"
#include "string"
#include "bitset"
#include "algorithm"
#include "map"
#include "queue"
#include "list"
#include "set"
#include "climits"
#include "iomanip"
#include "stack"
#include "functional"

using namespace std;

int N, M, K, L, R, H, W;

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

	cin >> N;
	while (N) {
		N *= 2;
		for (int i = 100000; i >= 1; i--) {
			if (N%i)continue;
			M = N / i;
			M -= i - 1;
			if (M <= 0||M&1)continue;
			cout << M /2<< " " << i << endl;
			break;
		}
		cin >> N;
	}
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
 
/*------------------------------------------------------------------*/
 
int main(){
    int n; cin >> n;
    vector<int> a(n);
    int sum = 1;
    rep(i, n){
        cin >> a[i];
        if(a[i] % 2 == 0) sum *= 2;
    }
    cout << pow(3, n) - sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>	
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
#define INF 2000000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
#define int ll
#define P pair<int,int>

#define MAX 100005
P p[MAX];
	
signed main(){
	vector<int> ve[MAX];
	int n,m; cin>>n>>m;
	
	for(int i=0; i<m; i++){
		cin>>p[i].first>>p[i].second;
		ve[p[i].first].push_back(p[i].second);
	}
	
	for(int i=0; i<=n; i++) sort(ve[i].begin(), ve[i].end());
	for(int i=0; i<m; i++){
		int fir=p[i].first,sec=lower_bound(ve[fir].begin(), ve[fir].end(), p[i].second)-ve[fir].begin()+1;
		int a=log10(fir)+1;
		for(int i=0; i<6-a; i++) cout<<0;
		cout<<fir;
		a=log10(sec)+1;
		for(int i=0; i<6-a; i++) cout<<0;
		cout<<sec<<en;
	}
}
	
	
	

Measured memory_bytes: 8576
import java.util.*;
 
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int ans = 0;
    Map<Integer,Integer> a=new HashMap<Integer,Integer>();
    for(int i=0;i<N;i++){
      int num=sc.nextInt();
      int cnt=a.getOrDefault(num, 0);
      a.put(num, cnt+1);
    }
    List<int[]> list=new ArrayList<int[]>();
    for(int i:a.keySet()){
      list.add(new int[]{i,a.get(i)});
    }
    Collections.sort(list,((i1,i2)->(i1[1]-i2[1])));
    for(int i=0;i<list.size()-K;i++){
      ans += list.get(i)[1];
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 99192
n = int(raw_input())
h = raw_input()
h = [int(i) for i in h.split(" ")]
flowers = [0 for i in h]

# check if it is finished
def is_finished(flowers, h):
	for i in range(len(flowers)):
		if flowers[i]!=h[i]:
			return False
	return True

c = 0
while is_finished(flowers, h)==False:
	i = 0
	while i<len(flowers):
		if flowers[i]<h[i]:
			break
		i += 1
	l = i
	while i<len(flowers):
		if flowers[i]>=h[i]:
			break
		i += 1
	r = i-1

	for i in range(l,r+1):
		flowers[i] += 1
	c += 1
print(c)

Measured memory_bytes: 2692
#include <cstdio>
#include <algorithm>

using namespace std;

int m,n;

int main()
{
	scanf("%d%d",&n,&m);
	if (m==1) swap(n,m);
	if (n==1) if (m==1) printf("%d",1); else printf("%d",m-2);
	else printf("%lld",1LL*(n-2)*(m-2));
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a-(a/b)*b);
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll K;
  IN(K);
  ll ans = 0;
  FOR(a,1,K+1) FOR(b,1,K+1) FOR(c,1,K+1){
    ans += gcd(gcd(a, b), c);
  }

  OUT(ans);

  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int a[maxn];

int main()
{
    fastio();
    int n,m,L,R; cin>>n>>m;
    rep(i,1,m){
        cin>>L>>R;
        a[L]++;a[R+1]--;
    }int ans = 0;
    rep(i,1,n){
        a[i] += a[i-1];
        if(a[i]==m) ans++;
    }cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4040
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> A(N), B(N);
  multiset<ll> bs;
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  for (ll i = 0; i < N; ++i) {
    cin >> B.at(i);
    bs.insert(B.at(i));
  }
  vector<ll> ans1(N);
  for (ll i = 0; i < N; ++i) {
    auto index = bs.upper_bound(A.at(i));
    if (index == bs.end()) {
      ans1.at(i) = *(bs.begin());
      bs.erase(bs.begin());
    }
    else {
      ans1.at(i) = *index;
      bs.erase(index);
    }
  }
  bool ok = true;
  for (ll i = 0; i < N; ++i) {
    if (ans1.at(i) == A.at(i)) {
      ok = false;
    }
  }
  if (ok) {
    cout << "Yes" << "\n";
    for (ll i = 0; i < N; ++i) {
      cout << ans1.at(i) << " ";
    }
    cout << "\n";
    return 0;
  }

  ll cnt1 = 0;
  ll cnt2 = 0;
  for (ll i = 0; i < N; ++i) {
    cnt1 = max(cnt1, (ll)(upper_bound(B.begin(), B.end(), A.at(i)) - lower_bound(B.begin(), B.end(), A.at(i))));
    cnt2 = max(cnt2, (ll)(upper_bound(A.begin(), A.end(), B.at(i)) - lower_bound(A.begin(), A.end(), B.at(i))));
  }
  vector<ll> ans(N);
  ok = true;
  for (ll i = 0; i < N; ++i) {
    ans.at((i + cnt2) % N) = B.at(i);
    if (A.at((i + cnt2) % N) == ans.at((i + cnt2) % N)) {
      ok = false;
    }
  }
  if (ok) {
    cout << "Yes" << "\n";
    for (ll i = 0; i < N; ++i) {
      cout << ans.at(i) << " ";
    }
    cout << "\n";
    return 0;
  }
  ok = true;
  for (ll i = 0; i < N; ++i) {
    ans.at((i + cnt1) % N) = B.at(i);
    if (A.at((i + cnt1) % N) == ans.at((i + cnt1) % N)) {
      ok = false;
    }
  }
  if (ok) {
    cout << "Yes" << "\n";
    for (ll i = 0; i < N; ++i) {
      cout << ans.at(i) << " ";
    }
    cout << "\n";
    return 0;
  }
  else {
    cout << "No" << "\n";
  }
}


Measured memory_bytes: 17180
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
	
	int n,m1;
	cin>>n>>m1;

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

	sort(a.begin(),a.end());
	map<int,int>m;
	std::vector<int> v;
	int x,y;
	for(int i=0;i<m1;i++){
		cin>>x>>y;
		v.push_back(y);
		m[y] += x;
	}

	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());

	int mx = v[0];

	int xx = lower_bound(a.begin(),a.end(),mx) - a.begin();
	//cout<<xx<<endl;

	for(int i=0,j =0;j<v.size() and i<xx;){
		//cout<<i<<" "<<j<<endl;
		if(m[v[j]]){
			a[i] = max(a[i],v[j]);
			m[v[j]]--;
			i++;
		}else{
			j++;
		}
	}
	ll sum  =0;
	for(int i=0;i<n;i++){
		//cout<<a[i]<<" ";
		sum += a[i];
	}//cout<<endl;

	cout<<sum<<endl;
	

	return 0;
}


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

const int N = 2e5 + 5;
vector<int> g[N];

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 2; i <= n; i++) {
        int x;
        cin >> x;
        g[x].push_back(i);
    }
    for (int i = 1; i <= n; i++) {
        cout << (int) g[i].size() << '\n';
    }   
}

Measured memory_bytes: 14520
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = Math.abs(sc.nextLong());
        long k = sc.nextLong();
        long d = sc.nextLong();

        long ans = 0;
        if(x/d>=k) {
            System.out.println(x - d*k);
        } else {
            long nk = k - x/d;
            long nx = x % d;
            if(nk%2==0) System.out.println(nx);
            else System.out.println(Math.abs(nx-d));
        }
    }
}


Measured memory_bytes: 35800
def resolve():
    N = int(input())
    ans = 1
    for i in range(1000000):
        if N == 1 or N == 2 or N == 4:
            break
        elif N % 2 == 0 :
            N = N//2
            ans = ans + 1
        else:
            N = 3*N+1
            ans = ans+1 
    print(ans + 3)
resolve()

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
N, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
T_A = 0
T_A_all = 0
for i,a in enumerate(A):
    T_A += len([1 for x in A[i+1:] if a > x])
    T_A_all += len([1 for x in A if a > x])
a = T_A
z = T_A + T_A_all * (K -1)
print(int((T_A*K+T_A_all*K*(K-1)//2)%((10**9)+7)))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,p;
    scanf("%lld%lld",&n,&p);
    ll key=p;
    if(p==1){
        printf("1\n");
        return 0;
    }
    if(n==1){
        printf("%lld\n",p);
        return 0;
    }
    long long ans=1;
    for(ll i=2; i*i<=p;i++)
    {
        if(p%i==0)
        {
            ll cnt=0;
            while(p%i==0)
            {
                p/=i;
                cnt++;
            }
            if(cnt>=n) ans=(long long)ans*(long long)pow(i,cnt/n);
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
if __name__ == '__main__':
    quarter, half, single, double = list(map(int, input().split()))
    N = int(input())
    new_single = min(4 * quarter, 2 * half, single)
    new_double = min(2 * new_single, double)

    if N % 2 == 1:
        print(new_double * (N // 2) + new_single)
    else:
        print(new_double * (N // 2))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main() {

    string s;
    cin >> s;

    if(s == "Sunny")cout << "Cloudy" << endl;
    
    if(s == "Cloudy")cout << "Rainy" << endl;
    
    if(s == "Rainy")cout << "Sunny" << endl;

}




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

#define rep(i,a,b)                for(ll i=a;i<b;i++)
#define re(i,b)                for(ll i=0;i<b;i++)
#define repr(i,n)                for(ll i=n-1;i>=0;i--)
#define ll long long
#define ld long double
#define llu long long unsigned
#define vll std::vector<ll>
#define mll std::map<ll, ll>
#define pll std::pair<ll, ll>
#define mpll std::map<pair<ll,ll>, ll>
#define sll std::set<ll>
#define fi first
#define se second
#define msll std::multiset<ll>
#define all(c) c.begin(), c.end()
#define allr(c) c.rbegin(), c.rend()
#define srt(x) sort(all(x))
#define rsrt(x) sort(allr(x))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define s(yy) ll yy;cin>>yy
#define mod 1000000007
#define maxlong 9223372036854775808


/*
###################################################### 
#                                                    #
#                     @author                        #
#                  Parth Lathiya                     #
#      https://www.cse.iitb.ac.in/~parthiitb/        #
#                                                    #
###################################################### 
*/

// vll primes;
// vll primefac[10000001];

// void sieve(ll n)
// {
// 	rep(i,2,n+1)
// 	{
// 		if(primefac[i].empty())
// 		{	
// 			primes.pb(i);
// 			for(ll j=i;j<=n;j+=i)
// 				primefac[j].pb(i);
// 		}
// 	}
// }


int main()
{

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

	#ifdef PARTH_LATHIYA_HOME

		freopen("A_in.txt","r",stdin);
	
		ll ttt,bkkk;
		cin>>ttt;
		bkkk=ttt;
		while(ttt--) {
			cout<<"Testcase - "<<bkkk-ttt<<"\n";
	#endif

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


	ll r,g,b;
	cin>>r>>g>>b;
	if((g*10+b)%4==0)
		cout<<"YES";
	else
		cout<<"NO";


//--------------------------------------------------------------------------------------
	
	#ifdef PARTH_LATHIYA_HOME
		cout<<"\n"; }
	#endif

	return 0;
}

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

int main()
{
  int n,count;
  cin>>n;
  count=0;
  for(int i=1;i<=n;i++)
  {
    if(1<=i&&i<=9)
      count++;
    else if(100<=i&&i<=999)
      count++;
    else if(10000<=i&&i<=99999)
      count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[101],b[101];
int main()
{
	int n;
	cin>>n;
	cin>>a>>b;
	for(int i=0;i<n;i++)
	{
		cout<<a[i]<<b[i];
	}
	cout<<endl;
	return 0;
}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}
#define ncinp(n, p)         REP(i,0,n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }
#define ncin1_1(n, x)       REPE(i, 1, n) {cin1(x[i]);}
#define ncin2_1(n, x, y)    REPE(i, 1, n) {cin2(x[i], y[i]);}
#define ncin3_1(n, x, y, z) REPE(i, 1, n) {cin3(x[i], y[i], z[i]);}
#define ncinp_1(n, p)       REPE(i,1,n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;


lli dp[3001][6001]; // i 個目まで使える状態で、j 分での最大の幸福度

// firstだけ見て小さい順
class OnlyFirstLessCompare
{
public:
    bool operator()(P n1, P n2) {
        return n1.first<=n2.first;
    }
};

int main() {
    lli n,t;
    cin2(n,t);
    P p[n+1];
    ncinp_1(n,p);
    sort(p+1, p+n+1, OnlyFirstLessCompare());
    //REPE(i,1,n) {
    //    coutp(p[i]);
    //}

    REPE(i,1,n) {
        REPE(j,1,t+p[n].first-1) {
            if (j - p[i].first >= 0 && j - p[i].first < t) {
                dp[i][j] = max({dp[i][j-1], dp[i-1][j], dp[i-1][j-p[i].first] + p[i].second});
            }
            else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    lli ans = 0;
    cout << dp[n][t+p[n].first-1] << endl;
}




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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	bool flag = true;
	rep(i, n) {
		int a; cin >> a;
		if (a % 2 == 0 and (a % 3 != 0 and a % 5 != 0)) {
			flag = false;
		}
	}
	cout << (flag ? "APPROVED" : "DENIED") << endl;
	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();
		List<Long> list = new ArrayList<>();
		int count1 = 0;
		int count2 = 0;
		int count4 = 0;
		for (int i = 0; i < N; i++) {
			long num = sc.nextLong();
			int index = 0;
			while (true) {
				if ((num & 1) == 1) {
					break;
				}
				index++;
				num/=2;
			}
			if (index == 0) {
				count1++;
			} else if (index == 1) {
				count2++;
			} else {
				count4++;
			}
		}
		if (0 < count2) {
			count1++;
			count2 = 0;
		}
		System.out.println(count1 <= count4+1 ? "Yes" : "No");
	}
}

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

int main() {
  int n;cin>>n;
  vector<tuple<string,int,int>> vec(n+1);
  for(int i=1;i<=n;i++){
    string s;
    int p;
    cin>>s>>p;
    p=-p;
    vec[i]=make_tuple(s,p,i);
  }
  sort(all(vec));
  for(int i=1;i<=n;i++){
    cout<<get<2>(vec[i])<<endl;
  }
}

Measured memory_bytes: 3560
#include<stdio.h>
int main(void){
  int n,m,i,j,k;
  scanf("%d %d",&n,&m);
  int a[n][m];
  for(i=1;i<=n;i++){
    for(j=1;j<=m;j++){
      scanf("%d",&a[i-1][j-1]);
    }
  }
  int b[m];
  for(j=1;j<=m;j++){
    scanf("%d",&b[j-1]);
  }
  int c[n];
  /*  for(k=1;k<=n;k++){
      c[k-1]=0; //????????????0???
      }
  */
  for(i=1;i<=n;i++){
    c[i-1]=0;
    for(j=1;j<=m;j++){
      c[i-1]+=a[i-1][j-1]*b[j-1];
    }
    printf("%d\n",c[i-1]);
  }
  return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    bool[] answers = new bool[n];
    List<int> answersList = new List<int>();

    for(int i = n; i >= 1; i--)
    {
      int countMemo = 0;
      for(int j = 2*i; j <= n; j+=i)
      {
        if(answers[j-1]) countMemo++;
        countMemo %= 2;
      }
      
      if(countMemo != nums[i-1])
      {
        answers[i-1] = true;
        answersList.Add(i);
      }
    }

    int nn = answersList.Count();
		Console.WriteLine(nn);
    int[] answersArray = new int[nn];
    for(int i = 0; i < nn; i++)
    {
      answersArray[i] = answersList[i];
    }
    Console.WriteLine(string.Join(" ", answersArray));
	}
}

Measured memory_bytes: 32220
// Problem : A - A?C
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		string s;
		cin>>s;
		if(s=="ABC")
		cout<<"ARC";
		else
		cout<<"ABC";    	
    }
    return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll  long long  
#define pb push_back
#define fi first
#define se second
using namespace std;
ll mo=1e9+7;
ll i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
 while(tc--)
 {
	ll a,b,c;
	cin>>a>>b>>c;
	ll k;
	cin>>k;
	ll ans=0;
	ll x=min(k,a);
	ans+=x;
	a-=x;
	k-=x;
	if(k>0)
	{
		ll x=min(k,b);
	ans+=0*x;
	b-=x;
	k-=x;
	}
	if(k>0)
	{
		ll x=min(k,c);
	ans+=-1*x;
	c-=x;
	k-=x;
	}
	cout<<ans;
	cout<<"\n";
 } 
}


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

int main() {
    int r;
    cin >> r;
    cout << r*r << endl;
    return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int x;
  cin>>x;
  puts(x==3||x==5||x==7 ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 768
package main

import (
	"fmt"
	"strconv"
	"strings"
)

var count int

func main() {
	var n int
	fmt.Scan(&n)
	if n < 357 {
		fmt.Println(0)
		return
	}
	l := len(strconv.Itoa(n))
	for i := 1; i < l+1; i++ {
		counter("", i, n)
	}

	fmt.Println(count)

}

func counter(num string, l, n int) {
	if l == len(num) {
		if strings.Index(num, "7") < 0 || strings.Index(num, "5") < 0 || strings.Index(num, "3") < 0 {
			return
		}

		if len(num) == l {
			i, _ := strconv.Atoi(num)
			if i > n {
				return
			}

			count++
			return
		}

	}
	counter(num+"3", l, n)
	counter(num+"5", l, n)
	counter(num+"7", l, n)

	return
}

Measured memory_bytes: 1152
fun read(d:String = " ") = readLine()!!.split(d)
fun <T> readList(d:String = " ",f:String.()->T) = read(d).map {f(it)}

fun main() {
	val (n,m) = readList {toInt()}
	val neighbor = Array(n) {mutableSetOf<Int>()}

	for(i in 1..m) {
		val (a,b) = readList {toInt()-1}
		neighbor[a].add(b)
		neighbor[b].add(a)
	}

	val parent = IntArray(n) {-1}

	val o = mutableSetOf(0)
	while(o.isNotEmpty()) {
		val p = o.toSet()
		o.clear()
		for(i in p) {
			neighbor[i].filter {parent[it]<0}.forEach {
				parent[it] = i+1
				o.add(it)
			}
		}
	}

	println("Yes")
	parent.drop(1).forEach(::println)
}


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

class Main{
    public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        // input
        int j = 0;
        int max = 100000;
        int max_prime = 0;
        int N = Integer.parseInt(br.readLine());

        // for output
        int result = 0;

        // for prime_table
        boolean[] prime_table = new boolean[max + 1];
        Arrays.fill(prime_table, true);
        prime_table[0] = prime_table[1] = false;

        for(int i = 2; i <= max; i++){
          if(prime_table[i]){
            j = i + i;
            while(j <= max){
              prime_table[j] = false;
              j = j + i;
            }
          }
        }

        for(int i = max; i > 1; i--){
          if(prime_table[i]){
            max_prime = i;
            break;
          }
        }

        // algorithm
        for(int t = N; t <= max; t++){
          if(N > max_prime){
            result = 100003;
            break;
          }else{
            if(prime_table[t] == false){
              continue;
            }else{
              result = t; 
              break;
            }
          }
        }
    
        System.out.println(result);

      }
    }
}

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

using namespace std;

#define MAX_S 1000001
#define MAX_T 10001
typedef unsigned long long ull;
const ull B = 1000000007ULL;

vector<ull> p;

vector<ull> rollingHash(char *s,int N){
    vector<ull> hash(N+1);
    hash[0] = 0;
    for(int i = 0 ; i < N ; i++){
        hash[i+1] = hash[i]*B + s[i];
    }
    return hash;
}

int main(){
    char S[MAX_S],T[MAX_T];
    scanf("%s %s",S, T);
    int N = strlen(S);
    int M = strlen(T);
    p.resize(N+1);
    p[0] = 1;
    for(int i = 0 ; i < N ; i++){
        p[i+1] = p[i]*B;
    }
    if(N < M) return 0;
    vector<ull> h = rollingHash(S,N);
    vector<ull> h2 = rollingHash(T,M);
    for(int i = 0 ; i < N ; i++){
        if(i+M > N) continue;
        int L = i, R = i+M-1;
        if(h[R+1]-h[L]*p[R-L+1] == h2[M]){
            printf("%d\n",i);
        }
    }
    return 0;
}

Measured memory_bytes: 17844
#include<bits/stdc++.h>
using namespace std;
#define int             long long int
#define pb              push_back
#define se              second
#define mp              make_pair
#define fi              first
#define del(a,vec)      vec.erase(std::remove(vec.begin(), vec.end(), a), vec.end());
#define search(f,l,v)   binary_search(f,l,v)
#define iter(a,b)       vector<int>::iterator a,b
#define lower(v,num)    lower_bound (v.begin(), v.end(), num);
#define upper(v,num)    upper_bound (v.begin(), v.end(), num); 
#define removecopy(a)   unique(a.begin(), a.end()); 
#define vi              vector<int> 
#define pi              pair<int,int>    
#define vpi             vector<pi>      
#define mlbb            ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)    
int mod =1000000007;
namespace Rahul{
    bool isPrime(int n) 
    {if (n <= 1)  return false; if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; }
    int pow (int x, int n,int mod) {//calculate x^n
    if (n == 0) return 1;
 
    int res = pow (x, n / 2,mod);
 
    res = (res * res) % mod;
    if (n % 2) res = (res * x ) % mod;
 
    return res;
    }
    int _gcd(int a,int b)
    {
        if(a==0)
            return b;
        else    
            return _gcd(b%a,a);
    }
    //s.erase(s.find(2)) where s={1,2,3,3,2}; 
};
using namespace Rahul;
int32_t main()
{
        
	     mlbb;   
    	char c;
  cin>>c;
  cout<<char(c+1)<<endl;
}


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

int main() {
  int N;
  int time=0;
  int ans=0;
  cin >> N;
  for(int i=1;i<=N;i++){
    int tmp_time = 0;
    int tmp_N = i;
    while(tmp_N%2 == 0){
      tmp_time += 1;
      tmp_N /= 2;
    }
    if(tmp_time >= time){
      time = tmp_time;
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int N, K;
int l[50];

void solve() {
    sort(l, l + N, greater<int>());
    int num = 0;
    for (int i = 0; i < K; ++i) {
        num += l[i];
    }
    printf("%d\n", num);
}

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; ++i) {
        cin >> l[i];
    }
    solve();
    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[]) {
  int n,k;
  cin >> n >> k;
  int ara[10] = {0};
  for(int i = 0;i<k;i++){
    int x;
    cin >> x;
    ara[x] = 1;
  }
  for(;true;n++){
    int temp = n;
    int cnt = 0;
    while(temp>0){
      int d = temp%10;
      temp/=10;
      if(ara[d] != 0){
        cnt++;
        break;
      }
    }
    if(cnt == 0){
      break;
    }
  }
  cout << n << endl;
  return 0;
}


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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int a, b, t;
  cin >> a >> b >> t;
  cout << b * (t/a) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		int a,b,c;
		Scanner scan = new Scanner(System.in);

	    a= Integer.parseInt(scan.next());
	    b= Integer.parseInt(scan.next());
	    c= Integer.parseInt(scan.next());
	    
	    if(a<b&&b<c)
	    {
	    	System.out.println("Yes");
	    }
	    else {
	    	System.out.println("No");
	    }
	    
	}

}

Measured memory_bytes: 26096
from math import factorial
class Facts():
    def __init__(self, max_num=10**5, p=10**9 + 7):
        self.p = p
        self.max_num = max_num
        self.fact = [1] * (self.max_num + 1)
        for i in range(1, self.max_num + 1):
            self.fact[i] = self.fact[i-1] * i
            self.fact[i] %= self.p

    def comb(self, n, k):
        """ nCk mod p を求める """
        """ 計算量 O(log(p)) """
        """ n! / (n-k)! / k! mod p """
        """ フェルマーの小定理 a^(-1) ≡ a^(p-2) """
        """ n! * k!^(p-2) * (n-k)!^(p-2) mod p """
        if n < 0 or k < 0 or n < k:
            return 0
        if n == 0 or k == 0:
            return 1
        a = self.fact[n]
        b = self.fact[k]
        c = self.fact[n-k]
        return (a*self.power_func(b, self.p-2) *
                self.power_func(c, self.p-2)) % self.p

    def perm(self, n, k):
        """ nPk mod p を求める """
        """ 計算量 O(b - a)? """
        """ n! / (n-k)! mod p """
        """ n! * (n-k)!^(p-2) mod p """
        if n < 0 or k < 0 or n < k:
            return 0
        if n == 0 or k == 0:
            return 1
        a = self.fact[n]
        b = self.fact[n-k]
        return (a * self.power_func(b, self.p-2)) % self.p

    def power_func(self, a, b):
        """ a^b mod p　を繰り返し二乗法で求める """
        """ 計算量 O(log(b)) """
        if b == 0:
            return 1
        if b % 2 == 0:
            d = self.power_func(a, b//2)
            return d*d % self.p
        if b % 2 == 1:
            return (a*self.power_func(a, b-1)) % self.p

MOD = 10**9 + 7

fact = Facts()
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
# pos
for i in range(n-1):
    c = fact.comb(n-1-i, k-1)
    ans += a[n-1-i] * c
    ans %= MOD
    ans -= a[i] * c
    ans %= MOD
print(ans)



Measured memory_bytes: 18524
#include <iostream>
#include<vector>
using namespace std;
#define ll long long
ll frog1(ll d[],ll b){
    //if b==0 no steps to jump
    if(b<=1)
    return 0;
    
    //he may jump 1 or 2 steps
    //with minimum cosst
      int p=abs(d[b-1]-d[b-2])+frog1(d,b-1);
      int r=(b<=2)? 10000:abs(d[b-1]-d[b-3])+frog1(d,b-2);
     return min(p,r);
}
ll frog(ll d[],ll b,ll k){
    //if b==0 no steps to jump
    vector<ll> dp(b+1);
    //he may jump 1 or 2 steps
    //with minimum cost
    dp[1]=0;
    for(ll i=2;i<=b;i++){
         dp[i]=1000000000;
        for(ll j=i-1;j>=1 && (i-j)<=k;j--){
      dp[i]=min(dp[i],abs(d[i]-d[j])+dp[j]);

    // cout<<dp[i]<<" ";
        }
       // cout<<dp[i]<<" ";
    }
     return dp[b];
}
int main(){
    ll b,l;
	    cin>>b>>l;
	    ll d[b+1];
	    for(ll i=1;i<=b;i++)
	    cin>>d[i];
	    cout<<frog(d,b,l)<<endl;
	
	return 0;
}

Measured memory_bytes: 1792