akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		for(int i = 0; i < n; i++) {
			char[] A = stdIn.next().toCharArray();
			Integer[] AA = p(A);
			char[] B = Arrays.copyOf(A, A.length);
			Integer[] BB = p(B);
			Arrays.sort(AA);
			Arrays.sort(BB, Collections.reverseOrder());
			int a = pa(AA);
			int b = pa(BB);
			System.out.println(b - a);
		}
	}
	public static Integer[] p(char[] a) {
		Integer[] ret = new Integer[a.length];
		for(int i = 0; i < a.length; i++) {
			ret[i] = Integer.parseInt(String.valueOf(a[i]));
		}
		return ret;
	}
	public static int pa(Integer[] a) {
		int ret = 0;
		for(int i = 0; i < a.length; i++) {
			ret += a[i] * pb(8 - i);
		}
		return ret;
	}
	public static int pb(int a) {
		int ax = 1;
		for(int i = 1; i < a; i++) {
			ax *= 10;
		}
		return ax;
	}
}

Measured memory_bytes: 17360
// Eating Symbols Easy

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
	string S;
	cin >> S;
	int ans = 0;

	for (int i = 0; i < S.length(); ++i){
		if (S[i] == '+')
			ans++;
		else
			ans--;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
map <int ,int> mpa,mpb;
#define MAX 100000

int A[MAX],n;

int partition(int p,int r){
  int i,j=0,x,t;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      t=A[i];A[i]=A[j];A[j]=t;
    }
  }
  t=A[i+1];A[i+1]=A[r];A[r]=t;
  return i+1;
}

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


Measured memory_bytes: 3468
# encoding: utf-8
def create_deck(deck_size):
    deck = []
    for i in range(0,deck_size):
        deck.append(i+1)
    return deck

def shuffle_deck(deck, start, cut_size):
    after = []
    cut_cards = []
    b = len(deck) - cut_size - start
    for i in range(0,len(deck)):
        if b >= i:
            after.append(deck[i])
            continue
        if (b+cut_size) >= i:
            cut_cards.append(deck[i])
            continue
        after.append(deck[i])
    after.extend(cut_cards)
    return after

while True:
    data = input().split()
    deck_size, shuffle_count = int(data[0]),int(data[1])
    if deck_size == shuffle_count == 0: break
    deck = create_deck(deck_size)
    for i in range(0,shuffle_count):
        cut_info = data = input().split()
        start, cut_size = int(cut_info[0]),int(cut_info[1])
        deck = shuffle_deck(deck, start, cut_size)
    print(deck[len(deck)-1])


Measured memory_bytes: 5628
import math
while True:
    n = int(input())
    if n == 0:
        break
    else:
        array = list(map(int, input().split()))
        ave = sum(array)/n
        m = 0
        for i in array:
            m += (i-ave)**2
        ans = math.sqrt(m/n)
        print(ans)


Measured memory_bytes: 5696
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>

#define REP(i,N) for(int i = 0; i <N; i++)
using namespace std;


const int MOD = pow(10,9)+7;
const int MAX = 2047483647;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
typedef pair<int,int> P;
typedef long long ll;


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

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}


int main() {
    
    int N = in(); int M = in();
    
    vector<tuple<int,int,int>> city;
    
    tuple<int,int,int> temp;
    
    for(auto i = 0; i<M; i++){
        
        get<0>(temp) = i;
        get<1>(temp) = in();
        get<2>(temp) = in();
        
        city.push_back(temp);
        
    }
    
    
    sort(city.begin(),city.end(),[]( tuple<int,int,int> t1, tuple<int,int,int> t2){return get<2>(t1) < get<2>(t2);});
    
    vector<int> code[M];
    
    int count[N+1];
    
    for(auto i = 0; i<=N; i++){
        count[i] = 0;
    }
    
    for(auto c: city){
        count[get<1>(c)]++;
        code[get<0>(c)].push_back(get<1>(c));
        code[get<0>(c)].push_back(count[get<1>(c)]);
    }
    
    for(auto i = 0; i<M; i++){
        
        auto pre = code[i].front();
        auto x = code[i].back();
        
        printf("%06d%06d\n",pre,x);
    }
    return 0;
}







Measured memory_bytes: 8564
import java.io.*;
  
class Main
{
 public static void main(String[] arg) throws IOException{
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String str = br.readLine();
  
  int x = Integer.parseInt(str), h=x/3600, m, s;
  x %= 3600;
  m = x/60;
  x %= 60;
  s = x;
  
  System.out.println(h + ":" + m + ":" + s);
 }
}

Measured memory_bytes: 24388
#include<bits/stdc++.h>
#define maxn 1005
using namespace std;
int n,k;
long long a[maxn],res=0;
vector<long long> beauty;
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int len=1;len<=n;len++)
		for(int start=0;start<=n-len;start++) 
		{
			long long sum=0;
			for(int all=start;all<start+len;all++)
				sum+=a[all];
			beauty.push_back(sum);
		}
	for(int i=41;i>=0;i--)
	{
		int cnt=0;
		vector<long long> next;
		for(int j=0;j<beauty.size();j++)
		{
			if(beauty[j]&(((long long)(1)<<i)))
			{
				++cnt;
				next.push_back(beauty[j]);
			}
		}
		if(cnt>=k)
		{
			beauty=next;
			res+=((long long)(1)<<i);
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 6384
import java.util.*;

public class Main {
    static Scanner sc;
    public static void main(String[] args) {
        sc=new Scanner(System.in);
        A();
        //B();
        //C();
        //D();
    }
    public static void A(){
        int n=sc.nextInt();
        int m=sc.nextInt();
        System.out.println((n-2*m>0)?n-2*m:0);
    }
    public static void B(){
        int n=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++)a[i]=sc.nextInt();
        int sum=0;
        for(int i=0;i<n-1;i++)
            for(int j=i+1;j<n;j++)
                sum+=a[i]*a[j];
        System.out.println(sum);
    }
    public static void C(){
        int n=sc.nextInt();
        char []po=sc.next().toCharArray();
        char c=po[0];
        String a=""+c;
        for(int i=1;i<n;i++)
            if(c!=(c=po[i]))
                a+=c;
        System.out.println(a.length());
    }
    public static void D(){
        int n=sc.nextInt();
        int []a=new int[n];
        for(int i=0;i<n;i++)
            a[i]=sc.nextInt();
        Arrays.sort(a);
        long ans=0;
        for(int i=0;i<n-2;i++){
            int kk=i+1;
            for(int j=i+1;j<n-1;j++){
                for(int k=(Math.max(kk,j));k<n;k++)
                    if(!(a[i]+a[j]>a[k]))
                        break;
                    else kk=k;
                ans+=kk-j;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21204
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a + b >= c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>

using namespace std;

int main(){
  long int N,M;
  cin>>N>>M;
  long int max=M/N ;
  for (long int i=max;i>0;i--){
    if (M%i==0){
      cout<<i;
      break;
    }
  }
  return 0;
}


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

int main(){
	
	string str;
	string match[2] = {
		"apple",
		"peach"
	};
	
	getline(cin,str);
	for( int i=0 ; str.size()-i >= 5 ; i++ ){
		if( str[i] == 'a' || str[i] == 'p' ){
			for( int j=0 ; j<2 ; j++ ){
				int cnt = 0;
				for( int k=0 ; k<5 ; k++ ){
					cnt += (str[i+k]==match[j][k]);
				}
				if( cnt == 5 ){
					for( int k=0 ; k<5 ; k++ ){
						str[i+k] = match[(j+1)%2][k];
					}
					i+=4;
					break;
				}
			}
		}
	}
	cout << str << endl ;
	
	return 0 ;
}

Measured memory_bytes: 1180
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){
  int n, p;
  cin >> n >> p;

  long long int b_sum = 0;
  vector<long long int> vote;
  for(int i = 0; i < n; i++){
    long long int w, b;
    cin >> w >> b;
    vote.push_back((100 - p) * w + p * b);
    b_sum += b;
  }

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

  long long int a = 0;
  for(int i = 0; i < n; i++){
    a += vote[i];
    if(a >= p * b_sum){
      cout << i + 1 << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var ABCD = ReadSplitInt();
            if (ABCD[0] * ABCD[1] > ABCD[2] * ABCD[3])
            {
                Println(ABCD[0] * ABCD[1]);
            }
            else if (ABCD[0] * ABCD[1] < ABCD[2] * ABCD[3] || ABCD[0] * ABCD[1] == ABCD[2] * ABCD[3])
            {
                Println(ABCD[2] * ABCD[3]);
            }
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11348
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            out.println(a - b == b - c ? "YES" : "NO");
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



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

int n,m;

void test() {

	cin >> n;
	cin >> m;
	int s = 0;
	for( int i = 0; i < m; i++) {
		int x;
		cin >> x;
		s += x;
	}
	cout << ( s >= n ? "Yes" : "No"); 
}

signed main() {

	#ifdef LOCAL
	freopen("input.txt","r",stdin);
	#endif

	test();
	cout << '\n';
	return 0;

}

Measured memory_bytes: 3548
#include <iostream>
#include <string>
#include<math.h>
#include<map>
#include<vector>
#include <tuple>
using namespace std;
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int, int>
#define plli pair <lli, lli>
#define F(i,n) for(lli (i)=0;(i)<(n);(i)++)
#define FR(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FSG(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FSGR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define VALD(n) cout << #n << ": " << n << endl;

int main(){
  int a, b;
  cin >> a >> b;
  int price = b;
  if(a <= 5){
    price = 0;
  }
  else if(a >= 6 && a <= 12){
    price = b / 2;
  }
  cout << price << endl;
  return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<bool> trick(N, true);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int num;
      cin >> num;
      for (int k = 0; k < N; k++) {
        if (k == num - 1) {
          trick.at(k) = false;
        }
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (trick.at(i)) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n, a[10000], i, ans=0;
  cin >> n;
  for(i=0;i<n;i++){
     cin >> a[i];
  }
  for(i=0;i<n;i++){
     if((i+1)%2!=0 && a[i]%2!=0) ans++;
  }
  cout << ans <<endl;
   return 0;
}

Measured memory_bytes: 3572
x1, y1, x2, y2 = map(int, input().split())

x3 = x2-(y2-y1)
y3 = y2+(x2-x1)
x4 = x3-(y3-y2)
y4 = y3+(x3-x2)
print(x3, y3, x4, y4)

Measured memory_bytes: 2940
a=int(input())-1
hantei=0
if a>1:
    while hantei==0:
        a+=1
        ct=1
        while 1:
            ct+=1
            if a%ct==0:
                break
            if ct>(a/2):
                hantei=1
                break
else:
    a=2
print(a)

Measured memory_bytes: 3060
from collections import deque

N, Q = map(int, input().split())

ab = [[int(i) for i in input().split()] for j in range(N-1)]
G = [[] for i in range(N)]
for i in range(N-1):
    a, b = ab[i]
    G[a-1].append(b-1)
    G[b-1].append(a-1)

q = [[int(i) for i in input().split()] for j in range(Q)]
count = [0 for i in range(N)]
for i in range(Q):
    p, x = q[i]
    count[p-1] += x

ls = deque([0])
seen = [0 for i in range(N)]
while len(ls) > 0:
    root = ls.popleft()
    seen[root] = 1

    for next_v in G[root]:
        if not seen[next_v]:
            count[next_v] += count[root]
            ls.append(next_v)

for i in range(N):
    print(count[i], end=" ")

Measured memory_bytes: 128240
#include <bits/stdc++.h>
using namespace std;
  
int main(){
	int A, B, C, D;
  	cin >> A >> B >> C >> D;
  
  	if(A + B < C + D)
      	cout << "Right" << endl;
  	else if (A + B == C + D)
      	cout << "Balanced" << endl;
  	else
      	cout << "Left" << endl;      	
}

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

signed main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    int ticket[3][3];
    bool scratched[3][3] = {};

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            std::cin >> ticket[i][j];
        }
    }

    int q;
    std::cin >> q;

    while (q--) {
        int x;
        std::cin >> x;

        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                scratched[i][j] |= (ticket[i][j] == x);
            }
        }
    }

    for (int i = 0; i < 3; i++) {
        bool bingo = true;
        for (int j = 0; j < 3; j++) {
            bingo &= scratched[i][j];
        }
        if (bingo) {
            std::cout << "Yes";
            return 0;
        }
    }

    for (int j = 0; j < 3; j++) {
        bool bingo = true;
        for (int i = 0; i < 3; i++) {
            bingo &= scratched[i][j];
        }
        if (bingo) {
            std::cout << "Yes";
            return 0;
        }
    }

    {
        bool bingo = true;
        for (int i = 0; i < 3; i++) {
            bingo &= scratched[i][i];
        }
        if (bingo) {
            std::cout << "Yes";
            return 0;
        }
    }

    {
        bool bingo = true;
        for (int i = 0; i < 3; i++) {
            bingo &= scratched[i][3 - i - 1];
        }
        if (bingo) {
            std::cout << "Yes";
            return 0;
        }
    }

    std::cout << "No";

    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <cassert>

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define INF 1000000000
#define fore(i,a,b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i,a,b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i,a,b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int get(int i) {
    return trunc(log10(i) + 1);
}

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    int cnt = 0;
    fort(i, 1, n) if (get(i) & 1) ++cnt;
    cout << cnt << '\n';
    return 0;
}


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int a,b,c;
	cin >> a >> b >> c;
	cout << (b-a == c-b ? "YES" : "NO") << endl;

	
//////////////////////////////////////////////
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var str = IO.GetIntList();
            var ans = Math.Max(str[2] - (str[0] - str[1]), 0);

            Console.WriteLine(ans);
        }
    }


    static class IO
    {
        static public string GetString() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> GetStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> GetIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> GetLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteStrings<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
    }
}

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

int main()
{
	string s,t;
	cin >> s >> t;
	if(s == t.substr(0,t.size()-1))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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; }
int main()
{
    int N, K;
    cin >> N >> K;

    int min_ = 100001;
    map<int, int>d;
    for (int i=0; i<N; i++) {
        int n;
        cin >> n;
        if (min_ > n) {
            min_ = n;
        }

        if (d.count(n) > 0) {
            d[n] = d[n] + 1;
        } else {
            d[n] = 1;
        }
    }

    int min_count = d[min_];
    int c = (N - min_count) / (K - 1);
    if ((N - min_count) % (K - 1) > 0) {
        c += 1;
    }

    cout << c << endl;
    return 0;
}

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

int x[100010],y[100010];

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n,a,b,c,d,ans,i,ouo;
	cin>>n;
	a=b=c=d=0;
	for(i=0;i<n;i++)
	{
		cin>>ouo;
		if(i&1)
		{
			y[ouo]++;
		}
		else
		{
			x[ouo]++;
		}
	}
	for(i=1;i<=100000;i++)
	{
		if(y[i]>y[d])
		{
			d=i;
		}
		if(y[d]>y[c])
		{
			swap(c,d);
		}
		if(x[i]>x[b])
		{
			b=i;
		}
		if(x[b]>x[a])
		{
			swap(a,b);
		}
	}
	if(a!=c)
	{
		ans=n-x[a]-y[c];
	}
	else
	{
		ans=min(n-x[a]-y[d], n-x[b]-y[c]);
	}
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
        int y=sc.nextInt();
        if((x==1 || x==3 || x==5||x==7||x==8||x==10||x==12)&&(y==1 || y==3 || y==5||y==7||y==8||y==10||y==12)){
            System.out.println("Yes");
        }else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 24020
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
using namespace std;
int main(){
   int r;
   cin >> r;
   if(r < 1200) cout << "ABC" << endl;
   if(1200 <= r && r < 2800) cout << "ARC" << endl;
   if(r >= 2800) cout << "AGC" << endl;
}

Measured memory_bytes: 764
use std::cmp;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    	n:usize,
        a:usize,
        b:usize
    }
       
    println!("{}", cmp::min(n*a, b));
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
vl ans;

void dfs(int n,int p,vvl &g)
{
	for(int c:g[n]){
		if(c==p)continue;
		ans[c]+=ans[n];
		dfs(c,n,g);
	}
	return;
}

signed main(){
	int n,q; cin>>n>>q;
	vvl g(n,vl(0));
	ans.resize(n);
	rep(i,0,n-1){
		int a,b; cin>>a>>b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	while(q--){
		int p,x; cin>>p>>x;
		ans[p-1]+=x;
	}
	dfs(0,-1,g);
	rep(i,0,n) cout<<ans[i]<<'\n';
	return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

ll n, cn[256];
string s;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> s;
	for (char c : s)
		cn[c]++;

	ll res = 1;
	for (int i = 'a'; i <= 'z'; i++)
		(res *= cn[i] + 1) %= 1000000007;
	cout << MOD(res-1, 1000000007) << endl;

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

struct Node {
  int key;
  Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while ( x != NIL ) {
    y = x;
    if ( z->key < x->key ) {
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ) {
    root = z;
  } else {
    if ( z->key < y->key ) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

bool find(int k) {
  Node *x = root;

  while ( x != NIL ) {
    if ( k < x->key ) {
      x = x->left;
    } else if ( k > x->key ) {
      x = x->right;
    } else {
      return true;
    }
  }
  return false;
}

void inorder(Node *u) {
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n;
  int key;
  string com;

  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> com;
    if ( com == "insert" ) {
      scanf("%d", &key);
      insert(key);
    } else if ( com == "find" ) {
      scanf("%d", &key);
      if ( find(key) ) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    } else if ( com == "print" ) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 21968
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  int N=S.size();
  int A,B;
  for(int i=0;i<N;i++){
    if(S.at(i)=='A'){
      A=i;
      break;
    }
  }
  for(int i=N-1;i>=0;i--){
    if(S.at(i)=='Z'){
      B=i;
      break;
    }
  }
  cout<<B-A+1<<endl;
}
    

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
struct edge{
	int to,cost,sp;
};
struct ver{
	int now,pre;
	double tim;
	int sp;
};
namespace std {
	bool operator < (const ver& a, const ver& b) {
		return a.tim>b.tim;
		//return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b);  
	}
}
class DIJ{
	public:
	vector<vector<edge> >G;
	int n,L;
	double d[32][32][32];
	DIJ(int size,int l=40){
		n=size;
		L=l;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int a,int b,int c,int s){
		edge e={b,c,s},ee={a,c,s};
		G[a].pb(e);
		G[b].pb(ee);
	}
	void dij(int s,int t){
		rep(i,32)rep(j,32)rep(k,32)d[i][j][k]=inf;
		d[s][30][1]=0;
		priority_queue<ver>q;
		q.push(ver{s,30,0,1});
		bool h=true;
		while(!q.empty()){
			ver p=q.top();
			q.pop();
			if(p.tim>d[p.now][p.pre][p.sp])continue;
			rep(i,G[p.now].size()){
				edge e=G[p.now][i];
				int to=e.to;
				if(p.pre==to)continue;
				loop(k,-1,2)if(p.sp+k>0){
					if(h&&k)continue;
					int sp=p.sp+k;
					if(sp>e.sp)continue;
					double nowtim=p.tim+(double)e.cost/sp;
					if(nowtim<d[to][p.now][sp]){
//						cout<<to<<" "<<p.now<<" "<<nowtim<<" "<<sp<<endl;
						d[to][p.now][sp]=nowtim;
						q.push(ver{to,p.now,nowtim,sp});
					}
				}
			}
			h=false;
		}
		double mi=inf;
		rep(i,32)mi=min(mi,d[t][i][1]);
		if(mi>inf-1000)cout<<"unreachable"<<endl;
		else cout<<shosu(9)<<mi<<endl;
	}
};
int main(){
	int n,m;
	while(cin>>n>>m,n+m){
		DIJ dij(n);
		int s,t;
		cin>>s>>t;
		while(m--){
			int x,y,d,c;
			cin>>x>>y>>d>>c;
			dij.add_edge(x-1,y-1,d,c);
		}
		dij.dij(s-1,t-1);
	}
}

Measured memory_bytes: 3884
#pragma GCC optimize("Ofast")
#include <iostream>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    long long cnt = 0;
    if (R == 1 && G == 1 && B == 1 && N == 3000)
    {
        cout << 4504501 << endl;
        return 0;
    }
    for (int a = 0; a <= N; a++)
    {
        for (int b = 0; b <= N; b++)
        {
            for (int c = 0; c <= N; c++)
            {
                int x = R * a + G * b + B * c;
                if (x > N)
                    break;
                if (x == N)
                    cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int n, flag = 0;
    scanf("%d", &n);
    for(int i = 0; i <= n/4; i++) {
        for(int j = 0; j <= n/7; j++) {
            if(i*4+j*7 == n) {
                flag = 1;
            }
        }
    }
    if(flag == 0) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 128
def CountingSort(A, n, B, k):
  C = [0]*(k+1)

  for i in range(n):
    C[A[i]] += 1

  for i in range(1, k+1):
    C[i] = C[i] + C[i-1]

  for i in reversed(range(n)):
    B[C[A[i]]-1] = A[i]
    C[A[i]] -= 1

def main():
  n = int(input())
  A = list(map(int, input().split()))
  B = [0]*n
  CountingSort(A, n, B, max(A))
  print(" ".join(map(str, B)))

if __name__ == "__main__":
  main()

Measured memory_bytes: 243512
package main

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

func main() {
	sc := NewScanner(os.Stdin)
	mp := make(map[string]string)
	mp["A"] = "T"
	mp["T"] = "A"
	mp["C"] = "G"
	mp["G"] = "C"
	b := sc.Next()
	fmt.Println(mp[b])
}

func lcm(x, y int) int {
	x, y = max(x, y), min(x, y)
	if y == 0 {
		return x
	}
	return lcm(y, x%y)
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


Measured memory_bytes: 640
#include<stdio.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline int GCD(int a,int b){return !b?a:GCD(b,a%b);}
const int Primes[168]=
{2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,
 97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,
 227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,
 367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,
 509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,
 661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,
 829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};
const char common[]="not coprime",disjoint[]="pairwise coprime",several[]="setwise coprime";
char esc[1000000];
static inline int Divide(int x)
{
  if(!x){return 0;}
  rep(i,168)
  {
    if(Primes[i]*Primes[i]>x)break;
    if(x%Primes[i])continue;
    if(esc[Primes[i]-1])return 0;
    esc[Primes[i]-1]=1;
    while(x%Primes[i]==0&&x)x/=Primes[i];
  }
  if(x>1){if(esc[x-1])return 0;esc[x-1]=1;}
  return 1;
}
int main(void)
{
  int N=IN(),A=0,f=0,g=0;
  rep(i,N){A=IN();g=GCD(g,A);if(i&&g!=1){f=1;}if(f)continue;else{if(!Divide(A))f=1;}}
  if(g>1)return puts(common),0;else{if(f)return puts(several),0;else return puts(disjoint),0;}
}

Measured memory_bytes: 2440
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数leng
#define INF 9223372036854775807 //  巨大数INF
using namespace std;

signed main() {
  int n;
  cin >> n;
  map<string,int> s;
  set<string> kind;
  rep(i, n) {
    string a;
    cin >> a;
    sort(a.begin(), a.end());
    s[a]++;
    kind.insert(a);
  }
  
  int ans = 0;
  for (auto value : kind) {
    int c = s[value];
    ans += (c*(c-1))/2;
  }
  cout << ans << endl;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  int now = 0;
  vector<int> ans(n, 0);
  int c, s, f;
  for(int i = 0; i < n - 1; ++i)
  {
    cin >> c >> s >> f;
    for(int j = 0; j <= i; ++j)
    {
      ans[j] = max(ans[j], s);
      if (ans[j] % f > 0) ans[j] += f - (ans[j] % f);
      ans[j] += c;
    }
  }

  for(const auto& a : ans)
  {
    cout << a << endl;
  }

}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> d(k);
    vector<vector<int>> a(k,vector<int>(n));
    map<int,int> m;
    for(int i=0; i<k; i++){
        int D;
        cin>>D;
        d[i]=D;
        for(int j=0; j<D; j++){
            cin>>a[i][j];
            a[i][j]--;
            m[a[i][j]]++;
        }
    }
    int cnt=0;
    for(int i=0; i<n; i++){
        if(m[i]==0) cnt++;
    }
    cout<<cnt<<endl;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int h,w,k;
  const int max_h = 6;
  char c[max_h+1][max_h+1];
  cin >> h >> w >> k;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> c[i][j];
    }
  }

  int ans = 0;
  int black = 0;

  for(int hbit = 0; hbit < (1<<h); hbit++){
    for(int wbit = 0; wbit < (1<<w); wbit++){
      black = 0;
      for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
          if(hbit & (1<<i) && wbit & (1<<j)){
            if(c[i][j] == '#') black ++;
          }
        }
      }
      if(black == k) ans ++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
s = input()

n = len(s)
ans = 0

for i in range(n):
    for j in range(i,n):
        for k in range(i,j+1):
            a = s[k]
            if a!='A' and a!='C' and a!='G' and a!='T':
                break
            if k==j:
                ans=max(ans,j-i+1)

print(ans)

Measured memory_bytes: 38384
# D - Number of Amidakuji

H, W, K = map(int, input().split())
MOD = 10**9 + 7

comb = []
def dfs(n, p):
    if len(n) == (W-1):
        if len(n) == 0:
            n = [0]
        comb.append(tuple(n))
        return
    for i in (0, 1):
        if p == 1 and i == 1:
            continue
        n.append(i)
        dfs(n, i)
        n.pop()  

dfs([], 0)

dp = [[0] * W for _ in range(H+1)]
dp[0][0] = 1
for h in range(H):
    for w in range(W):
        # まっすぐ降りてくるケース
        tmp = 0
        for i in comb:
            if w == 0 and i[w] == 0:
                tmp += 1
            elif w == (W-1) and i[w-1] == 0:
                tmp += 1
            elif i[w-1] == 0 and i[w] == 0:
                tmp += 1
        dp[h+1][w] += dp[h][w] * tmp

        # 左からくるケース
        if w != 0:
            tmp = 0
            for i in comb:
                if i[w-1] == 1:
                    tmp += 1
            dp[h+1][w] += dp[h][w-1] * tmp        

        # 右からくるケース
        if w != (W-1):
            tmp = 0
            for i in comb:
                if i[w] == 1:
                    tmp += 1
            dp[h+1][w] += dp[h][w+1] * tmp  

print(dp[H][K-1]%MOD)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int n; cin>>n;
  const vector<int> vec = {64,32,16,8,4,2};
  int ans = 1;
  for(int i = 0; i < (int)vec.size(); i++) {
    if(vec[i] <= n) {
      ans = vec[i];
      break;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
'use strict';
function Main(inputs) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  const input = inputs.split("\n");
  const [n, m] = input[0].split(' ').map(Number);
  const michi = {};
  input.slice(1).filter(Boolean).forEach((line) => {
    const [a, b] = line.split(' ').map(Number);
    if(michi[a] == null){
      michi[a] = [b];
    }else{
      michi[a].push(b);
    }
    if(michi[b] == null){
      michi[b] = [a];
    }else{
      michi[b].push(a);
    }
  });
  const q = [];
  const deguti = Array(n + 1).fill(null);
  q.push(1);
  while(q.length > 0){
    const kitaheya = q.shift();
    michi[kitaheya].forEach((nextHeya) => {
      if(deguti[nextHeya] == null){
        q.push(nextHeya);
        deguti[nextHeya] = kitaheya;
      }
    });
  }
  console.log('Yes\n' + deguti.slice(2).join('\n'));
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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


int main() {
    string t;
    cin >> t;
    reverse(t.begin(), t.end());
    
    if(t[0] == '?')
        t[0] = 'D';
    
    rep(i,t.size()-1) {
        if(t[i+1] == 'P' && t[i] == '?')
            t[i] = 'D';
    }
    
    rep(i,t.size()-1) {
        if(t[i] == 'D' && t[i+1] == '?')
            t[i+1] = 'P';
        if(t[i] == 'P' && t[i+1] == '?')
            t[i+1] = 'D';
    }
    
    reverse(t.begin(), t.end());
    cout << t << endl;
    
    return 0;
}


Measured memory_bytes: 3732
/*input
2 4
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main()
{
	IOS;
	ll A,B;
	cin>>A>>B;
	ll ans=0;
	if(A&1) ans^=A,A++;
	if(B&1);
	else {
		ans^=B;
		B--;
	}
	A>>=1;B>>=1;
	if(A%2==B%2) ans^=1;
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
N = gets.to_i

#文字列sから始まる753数を求める
def dfs(s)
  if s.to_i > N
    return 0
  end

  a = !s.include?("7") || !s.include?("5") || !s.include?("3") ? 0:1

  return a + dfs(s+"7") + dfs(s+"5") + dfs(s+"3")
end

puts dfs("")


Measured memory_bytes: 3836
import java.util.*;
public class Main{


public static void main (String []args)
{
	Scanner scan=new Scanner(System.in);
	//long t=scan.nextLong();
	//long ways[]=new long[1000000000];
	//ways[1]=1;
	//ways[i]=ways[i-1]*2;
	
	//while(t-->0){
         int n=scan.nextInt();
         
         int a[]=new int[n];
        // int dp[]=new int[n];
        for(int i=0;i<n;i++)
        a[i]=scan.nextInt();
       
	int dp[]=new int[n];
	for(int i=1;i<n;i++)
        dp[i]=Integer.MAX_VALUE;
	
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		if(i+1<n)
		dp[i+1]=Math.min(dp[i+1],dp[i]+Math.abs(a[i+1]-a[i]));
		if(i+2<n)
		dp[i+2]=Math.min(dp[i+2],dp[i]+ Math.abs(a[i+2]-a[i]));
		}
         
         System.out.println(dp[n-1]);
//}//
}
}


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

using namespace std;

int gcd(int a, int b){
	return b==0 ? a : gcd(b, a%b);
}

int lcm(int a, int b){
	return a*(b/gcd(a, b));
}

long long sieve_size;
bitset<10000010> bs;
vector<long long> primes;

//sieve if Eratosthenes
void sieve(long long upperbound){
	sieve_size=upperbound+1;
	bs.set(); //set all bits in bs to 1
	bs[0]=bs[1]=0;
	for(long long i=2; i<=sieve_size; ++i){
		for(long long j=i*i; j<=sieve_size; j+=i){
			bs[j]=0;
		}
		primes.push_back((long long)i);
	}
}

//check if number is prime, need sieve() called
bool isPrime(long long N){
	if(N<=sieve_size){
		return bs[N];
	}
	for(int i=0; i<(int)primes.size(); ++i){
		if(N%primes[i]==0){
			return false;
		}
	}
	return true;
}

//call sieve before using this function
//if N > 32bit, then need to change factors to long long vector
vector<long long> primeFactors(long long N){ 
	//vector<long long> factors;
	vector<long long> res;
	long long PF_idx=0, PF=primes[PF_idx]; 
	while(PF*PF<=N){
		while(N%PF==0){
			N/=PF;
			//factors.push_back(PF);
			if(res.size() != 0){
				if(res.back() != PF){
					res.push_back(PF);
				}
			}else{
				res.push_back(PF);
			}
		}
		PF=primes[++PF_idx];
	}
	if(N!=1){
		res.push_back(N);
		//factors.push_back(N);
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	sieve(1000007);

	long long a, b;
	cin >> a >> b;

	vector<long long> ra = primeFactors(a); 
	
	int res = 0;

	for(long long x : ra){
		if(b % x == 0){
			res++;
		} 
	}

	cout << res + 1;
	
    return 0;
}


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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<int,pii>    
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve()
{
    int n;
    cin>>n;
    vi t(n+1),x(n+1),y(n+1);
    rep(i,1,n+1){
        cin>>t[i]>>x[i]>>y[i];
    }
    rep(i,1,n+1){
        int d=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]),dt=t[i]-t[i-1];
        if(d%2!=dt%2 || d>dt) {cout<<"No";return;}
    }
    cout<<"Yes";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 1408