akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  998244353
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()
int nod(int x)
{
    int res=0;
    while(x>0)
    {
        x/=10;
        res++;
    }
    return res;
}

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int k;
   cin>>k;
   queue<int>q;
   for(int i=1;i<=9;i++)
    q.push(i);
   vector<int>v;
   while(v.size()<50000)
   {
       int p=q.front();
       q.pop();
       v.pb(p);
       int x=nod(p);
       int rem=(p % 10);
       for(int i=0;i<=9;i++)
       {
           if(abs(rem-i)<=1)
           {
               q.push(p*10 + i);
           }
       }
   }
   while(!q.empty())
   {
       int p=q.front();
       v.pb(p);
       q.pop();
   }
   sort(all(v));
   cout<<v[k-1]<<endl;

}


Measured memory_bytes: 4084
from typing import List, Tuple


def insertion_sort(A: List[int], n: int, g: int) -> int:
    count: int = 0
    for i in range(g, n):
        j = i - g
        while j >= 0 and A[j] > A[j + g]:
            A[j], A[j + g] = A[j + g], A[j]
            j -= g
            count += 1
    return count


def shell_sort(A: List[int], n: int) -> Tuple[int, List[int], int, List[int]]:
    cnt: int = 0
    G: List[int] = [1]
    h: int = 1

    while 3 * h + 1 < n:
        h = 3 * h + 1
        G.append(h)

    G.reverse()
    m = len(G)

    for i in range(m):
        count = insertion_sort(A, n, G[i])
        cnt += count

    return m, G, cnt, A


def main():
    n: int = int(input())
    A: List[int] = []
    for _ in range(n):
        A.append(int(input()))
    m, G, cnt, A_sorted = shell_sort(A[:], n)

    print(m)
    print(*G, sep=" ")
    print(cnt)
    print(*A_sorted, sep="\n")


if __name__ == "__main__":
    main()



Measured memory_bytes: 62788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define kk 1000000007
int n,m,k,a,b,c,tmp,cc[300005];
vector<int > ee;
map<int ,int > mm;
char g;
int main(){
	scanf("%d%c%c%d",&a,&g,&g,&b);
	if (g == '+') printf("%d\n",a+b);
	else printf("%d\n",a-b);
	return 0;
}

Measured memory_bytes: 3820
#![allow(unused)]

#[allow(unused_imports)]
use std::{cmp, collections, fmt, io, iter, ops, str};
use cmp::Ordering::*;
use collections::{HashMap, HashSet};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($fmt: expr) => { eprintln!($fmt) };
    ($fmt: expr, $($arg: tt)*) => { eprintln!($fmt, $($arg)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($fmt: expr) => {};
    ($fmt: expr, $($arg: tt)*) => {};
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if buf.len() > 0 {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn main() {
    let n = parse_word::<usize>();
    let m = parse_word::<usize>();
    let x = parse_word::<usize>();

    // cell: 0 .. a1 .. a2 ..   a_m ..  n
    // fee:  0    1     1       1       0
    let fee = {
        let mut fee = vec![0; n + 1];
        for _ in 0..m {
            let a = parse_word::<usize>();
            fee[a] = 1;
        }
        fee
    };

    let fee_0 = fee[..x].iter().sum::<i32>();
    let fee_n = fee[(x + 1)..].iter().sum::<i32>();

    println!("{}", cmp::min(fee_0, fee_n));
}


Measured memory_bytes: 4352
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
 
class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        char[] s = Console.ReadLine().ToCharArray();
        int opening = 0, closing = 0;
        for (int i = 0; i < n; i++)
        {
            if (s[i] == '(') opening++;
            else if (s[i] == ')')
            {
                if (opening >= 1) opening--;
                else closing++;
            }
        }
        // for (int i = 0; i < closing; i++) Console.Write('(');
        // Console.Write(s);
        // for (int i = 0; i < opening; i++) Console.Write(')');
        // Console.WriteLine();
        var result = new string(Enumerable.Concat(Enumerable.Concat(Enumerable.Repeat('(', closing), s), Enumerable.Repeat(')', opening)).ToArray());
        Console.WriteLine(result);
    }
}


Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
using System.Linq;
class Method
{
    bool[] seen;
    int sum;
    int count = 0;
  
    public Method(int s, int n){
        seen = new bool[n];
        for(int i=0; i<n; i++){
            seen[i] = false;
        }
        sum = s;
    }
  
  	public int get(){
  		return count;    
    }
  
    public void dfs(int[,] pass, int v, int c){
        seen[v-1] = true;
        for(int i=0; i<pass.Length/2; i++){
            int thisV = pass[i,0];
            if(thisV != v) continue;
            int nextV = pass[i,1];
            if(seen[nextV-1]) continue;
            dfs(pass, nextV, c+nextV);
        }
        seen[v-1] = false;
        if(c == sum) count++;
    }
}

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
        int s = 0;
        for(int i=1; i<=n; i++){
            s += i;
        }
        int[,] pass = new int[m*2, 2];
        for(int i=0; i<m; i++){
            string[] input2 = Console.ReadLine().Split(' ');
            pass[i,0] = int.Parse(input2[0]);
            pass[i,1] = int.Parse(input2[1]);
            pass[i+m,0] = int.Parse(input2[1]);
            pass[i+m,1] = int.Parse(input2[0]);
        }
        /*int start = 0;
        for(int i=0; i<m; i++){
            if(pass[i,0] == 1) {
                start = pass[i,1];
                break;
            }
        }*/
        Method me = new Method(s, n);
        me.dfs(pass, 1, 1);
        Console.WriteLine(me.get());
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;


int main(){
    int n;
    string s;
    cin>>n>>s;
    int x=0;
    int ans=0;
    for(int i=0;i<n;i++){
        if(s[i]=='I')x++;
        else x--;
        ans=max(ans,x);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
/***
	chauhan176's code

	DO WHATEVER IT TAKES!!!
	Nothing happens , nothing happens and then everything happens.
	But the thing is nothing happens in air:)-
***/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long int
#define fi first
#define se second
#define mod 1000000007
#define maxn 200005
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define stringio cin.ignore(256, '\n')  //to take string input after taking integer inputs
#define go_t int t;cin>>t;while(t--)
#define go_pt int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef pair<int,int>pii;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    //freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    //freopen("output.txt", "w", stdout);
    #endif

    fastio;
    int k,x;
    cin>>k>>x;
    int le=x-k+1;
    for(int i=1;i<=2*k-1;i++)
    {
        cout<<le++<<" ";
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> arr;
int min(int a,int b)
{
    return a<b?a:b;
}
int main()
{
    int n;
    cin>>n;
    arr.resize(n);
    for(int i=0;i<n;i++)
    cin>>arr[i];
    vector<int> ans(n);
    ans[0]=0;
    ans[1]=abs(arr[0]-arr[1]);
    for(int i=2;i<n;i++)
    {
        ans[i]=min(abs(arr[i]-arr[i-1])+ans[i-1],abs(arr[i]-arr[i-2])+ans[i-2]);
    }
    cout<<ans[n-1];
    return 0;
}

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

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    if(a%k == 0 || b%k == 0){
        cout << "OK" << endl;
        return 0;
    }
    if(b/k - a/k == 0){
        cout << "NG" << endl;
    } else {
        cout << "OK" << endl;
    }
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
int main()
{
    long long co,len,l,i,j,b;
    char s[1000001],t[1000001];
    gets(s);
    gets(t);
    len=strlen(s);
    l=strlen(t);
    co=0;
    for(i=0;i<len;i++){
        for(i=0;i<l;i++){
            if(s[i]!=t[i]){
                co++;
            }
        }
    }
    printf("%lld\n",co);

    return 0;
}


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

typedef long long ll;

long long gcd(long long a, long long b) {
  return b != 0 ? gcd(b, a % b) : a;
}
long long lcm(long long a, long long b) {
  return a * b / gcd(a, b);
}
// a x + b y = gcd(a, b)
long long extgcd(long long a, long long b, long long &x, long long &y) {
  long long g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}

int f(long long x){
    int res;
    for(res = 0;!((x >> res)&1);res++);
    return res;
}

int main(int argc, char const *argv[])
{
    ll n,m;scanf("%lld %lld",&n,&m);
    vector<ll> a(n);
    for(int i = 0;i < n;i++)scanf("%lld",&a[i]);
    for (int i = 0; i < n; ++i)
    {
        a[i] /= 2;
    }

    ll L = a[0];
    for (int i = 0; i < n; ++i)
    {
        if((L = lcm(L,a[i])) > m){
            printf("0\n");return 0;
        }
    }
    int k = f(a[0]);
    for (int i = 0; i < n; ++i)
    {
        if(k != f(a[i])){
            printf("0\n");return 0;
        }
    }

    printf("%lld\n",(1+m/L)/2);

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=102;
short dp[N][N][N][N],sum[N][N];
char a[N][N];
int X,Y,n,m;
short getsum(int a,int b,int c,int d)
{
    if(a>c)swap(a,c);if(b>d)swap(b,d);
    return sum[c][d]-sum[a-1][d]-sum[c][b-1]+sum[a-1][b-1];
}
void getmx(short &a,short b){if(a<b)a=b;}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",a[i]+1);
        for(int j=1;j<=m;j++)
            a[i][j]=='E'?X=i,Y=j:(sum[i][j]=(a[i][j]=='o'));
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
    short ans=0;
    for(int a=X;a;a--)
        for(int b=Y;b;b--)
            for(int c=X;c<=n;c++)
                for(int d=Y;d<=m;d++)
                {
                    ans=max(ans,dp[a][b][c][d]);
                    int A=c-X+1,B=d-Y+1,C=n-X+a,D=m-Y+b;
                    if(a>A)getmx(dp[a-1][b][c][d],dp[a][b][c][d]+getsum(a-1,max(b,B),a-1,min(d,D)));
                    if(b>B)getmx(dp[a][b-1][c][d],dp[a][b][c][d]+getsum(max(a,A),b-1,min(c,C),b-1));
                    if(c<C)getmx(dp[a][b][c+1][d],dp[a][b][c][d]+getsum(c+1,max(b,B),c+1,min(d,D)));
                    if(d<D)getmx(dp[a][b][c][d+1],dp[a][b][c][d]+getsum(max(a,A),d+1,min(c,C),d+1));
                }
    printf("%d\n",(int)ans);
}


Measured memory_bytes: 209152
X = int(input())

if 400<=X and X<600:
  print(8)
elif 600<=X and X<800:
  print(7)
elif 800<=X and X<1000:
  print(6)
elif 1000<=X and X<1200:
  print(5)
elif 1200<=X and X<1400:
  print(4)
elif 1400<=X and X<1600:
  print(3)
elif 1600<=X and X<1800:
  print(2)
elif 1800<=X and X<2000:
  print(1)


Measured memory_bytes: 9092
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

int n;
vector<int> G[1 << 17];

int mostfar(int root) {
	int ret = root;
	queue<int> q; q.push(root);
	vector<bool> used(n,false);
	used[root] = true;
	while (!q.empty()) {
		int x = q.front(); q.pop();
		ret = x;
		rep(j, G[x].size()) {
			int to = G[x][j];
			if (used[to])continue;
			q.push(to);
			used[to] = true;
		}
	}
	return ret;
}
vector<int> path(int l, int r) {
	vector<int> dl(n, mod);
	queue<int> q;
	dl[l] = 0; q.push(l);
	while (!q.empty()) {
		int x = q.front(); q.pop();
		rep(j, G[x].size()) {
			int to = G[x][j];
			if (dl[x] + 1 < dl[to]) {
				dl[to] = dl[x] + 1;
				q.push(to);
			}
		}
	}
	int len = dl[r];
	vector<int> ret;
	vector<bool> used(n, false);
	q.push(r); used[r] = true; int cnt = 0;
	while (!q.empty()) {
		int sz = q.size();
		rep(aa, sz) {
			int x = q.front(); q.pop();
			if (dl[x] == len - cnt) {
				ret.push_back(x);
			}
			rep(j, G[x].size()) {
				int to = G[x][j];
				if (used[to])continue;
				q.push(to); used[to] = true;
			}
		}
		cnt++;
	}
	return ret;
}
int main() {
	cin >> n;
	rep(i, n-1) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b); G[b].push_back(a);
	}
	int l = mostfar(0), r = mostfar(l);
	vector<int> c = path(l, r);
	vector<bool> onpath(n, false);
	rep(i, c.size())onpath[c[i]] = true;
	vector<int> ans,ans2;
	int cnt = 1;
	rep(i, c.size()) {
		int id = c[i];
		int r = 1;
		rep(j, G[id].size()) {
			int to = G[id][j];
			if (onpath[to])continue;
			else {
				ans.push_back(cnt + r);
				r++;
			}
		}
		ans.push_back(cnt); cnt += r;
	}
	cnt = 1;
	per(i, c.size()) {
		int id = c[i];
		int r = 1;
		rep(j, G[id].size()) {
			int to = G[id][j];
			if (onpath[to])continue;
			else {
				ans2.push_back(cnt + r); r++;
			}
		}
		ans2.push_back(cnt); cnt += r;
	}
	if (ans > ans2)swap(ans, ans2);
	if (ans.size() == n) {
		rep(i, n) {
			if (i > 0)cout << " ";
			cout << ans[i];
		}
		cout << endl;
	}
	else {
		cout << -1 << endl;
	}
	//stop
	return 0;
}


Measured memory_bytes: 8952
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {

    public static void main(String[] args) throws Exception {
	    String line = Io.read();
	    int[] parsed = parse(line);

	    if (parsed[0] + parsed[1] == 15) {
	        Io.write("+");
        } else if (parsed[0] * parsed[1] == 15) {
	        Io.write("*");
        } else {
            Io.write("x");
        }
    }

    private static int[] parse(String line) {
        String[] split = line.split(" ");
        int[] parsed = new int[split.length];

        for (int i = 0; i < split.length; i++) {
            parsed[i] = Integer.parseInt(split[i]);
        }
        return parsed;
    }
}

class Io {

    public static String read() throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        br.close();
        return line;
    }

    public static void write(String answer)
    {
        System.out.println(answer);
    }
}

Measured memory_bytes: 21332
#include<iostream>
using namespace std;
long mod=1e9+7,dp[51][51][2505];
int N,K;
main()
{
	cin>>N>>K;
    if (K%2==1) {
      cout << 0 << '\n';
      return 0;
    }
    K/=2;
	dp[0][0][0]=1;
	for(int i=0;i<N;i++)for(int j=0;j<=i;j++)
	{
		for(int k=0;k<=K-j+2;k++)
		{
			if(dp[i][j][k]==0)continue;
			(dp[i+1][j][k+j]+=dp[i][j][k]*(2*j+1)%mod)%=mod;
			if(j>0)(dp[i+1][j-1][k+j-1]+=dp[i][j][k]*j*j%mod)%=mod;
			(dp[i+1][j+1][k+j+1]+=dp[i][j][k])%=mod;
		}
	}
	cout<<dp[N][0][K]<<endl;
}


Measured memory_bytes: 48128
#include <cstdio>

int main(){
	int a, b; scanf("%d%d", &a, &b);
	if((a+b) % 2 == 1){
		printf("IMPOSSIBLE\n");
	}
	else{
		printf("%d\n", (a + b) / 2);
	}
	return 0;	
}


Measured memory_bytes: 128
import java.util.Scanner;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    
    int n=sc.nextInt();
    int arr[]=new int[n];
     double sum=0;
    for (int i=0;i<n;i++)
    {
      arr[i]=sc.nextInt();
      sum+=1/(double)arr[i];
    }
      System.out.println(1/sum);
  }
}

Measured memory_bytes: 21844
/*
                       ::
                      :;J7, :,                        ::;7:
                      ,ivYi, ,                       ;LLLFS:
                      :iv7Yi                       :7ri;j5PL
                     ,:ivYLvr                    ,ivrrirrY2X,
                     :;r@Wwz.7r:                :ivu@kexianli.
                    :iL7::,:::iiirii:ii;::::,,irvF7rvvLujL7ur
                   ri::,:,::i:iiiiiii:i:irrv177JX7rYXqZEkvv17
                ;i:, , ::::iirrririi:i:::iiir2XXvii;L8OGJr71i
              :,, ,,:   ,::ir@mingyi.irii:i:::j1jri7ZBOS7ivv,
                 ,::,    ::rv77iiiriii:iii:i::,rvLq@huhao.Li
             ,,      ,, ,:ir7ir::,:::i;ir:::i:i::rSGGYri712:
           :::  ,v7r:: ::rrv77:, ,, ,:i7rrii:::::, ir7ri7Lri
          ,     2OBBOi,iiir;r::        ,irriiii::,, ,iv7Luur:
        ,,     i78MBBi,:,:::,:,  :7FSL: ,iriii:::i::,,:rLqXv::
        :      iuMMP: :,:::,:ii;2GY7OBB0viiii:i:iii:i:::iJqL;::
       ,     ::::i   ,,,,, ::LuBBu BBBBBErii:i:i:i:i:i:i:r77ii
      ,       :       , ,,:::rruBZ1MBBqi, :,,,:::,::::::iiriri:
     ,               ,,,,::::i:  @arqiao.       ,:,, ,:::ii;i7:
    :,       rjujLYLi   ,,:::::,:::::::::,,   ,:i,:,,,,,::i:iii
    ::      BBBBBBBBB0,    ,,::: , ,:::::: ,      ,,,, ,,:::::::
    i,  ,  ,8BMMBBBBBBi     ,,:,,     ,,, , ,   , , , :,::ii::i::
    :      iZMOMOMBBM2::::::::::,,,,     ,,,,,,:,,,::::i:irr:i:::,
    i   ,,:;u0MBMOG1L:::i::::::  ,,,::,   ,,, ::::::i:i:iirii:i:i:
    :    ,iuUuuXUkFu7i:iii:i:::, :,:,: ::::::::i:i:::::iirr7iiri::
    :     :rk@Yizero.i:::::, ,:ii:::::::i:::::i::,::::iirrriiiri::,
     :      5BMBBBBBBSr:,::rv2kuii:::iii::,:i:,, , ,,:,:i@petermu.,
          , :r50EZ8MBBBBGOBBBZP7::::i::,:::::,: :,:,::i;rrririiii::
              :jujYY7LS0ujJL7r::,::i::,::::::::::::::iirirrrrrrr:ii:
           ,:  :@kevensun.:,:,,,::::i:i:::::,,::::::iir;ii;7v77;ii;i,
           ,,,     ,,:,::::::i:iiiii:i::::,, ::::iiiir@xingjief.r;7:i,
        , , ,,,:,,::::::::iiiiiiiiii:,:,:::::::::iiir;ri7vL77rrirri::
         :,, , ::::::::i:::i:::i:i::,,,,,:,::i:i:::iir;@Secbone.ii:::
		 
-->
*/

#include<bits/stdc++.h>

using namespace std;

int p[20],c[20];

int f[20][1010]={0};

int main() {
	int n,g,sum=0;
	cin>>n>>g;
	for (int i=1;i<=n;i++) {
		cin>>p[i]>>c[i];
		sum+=p[i];
	}
	for (int i=1;i<=n;i++) {
		for (int k=0;k<p[i];k++)
			for (int j=k;j<=sum;j++) {
				f[i][j]=max(f[i-1][j],f[i-1][j-k]+i*k*100);
			}
		for (int j=p[i];j<=sum;j++) {
			f[i][j]=max(f[i-1][j],f[i-1][j-p[i]]+100*i*p[i]+c[i]);
		}
	}
	for (int i=0;i<=sum;i++)
		 {
		if (f[n][i]>=g) {
			cout<<i<<endl;
			break;
		}
	}
//	system("pause");
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  int a = 0, b = 0, c = 0;
  for (auto tmp : A) (tmp % 4 == 0) ? a++ : (tmp % 2 == 0) ? b++ : c++;
  b %= 2;
  c += b;
  cout << ((c - a <= 1) ? "Yes" : "No") << "\n";
}

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

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

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;

using ll=long long;
using R=long double;
struct P{
	ll x,y,z;
	P operator - (const P &arg)const{
		P ret={x,y,z};
		ret.x-=arg.x,ret.y-=arg.y,ret.z-=arg.z;
		return ret;
	}
};
using L=struct{P a,b;};
inline ll dot(P a,P b){return a.x*b.x+a.y*b.y+a.z*b.z;}
inline ll norm(ll a){return a*a;}
inline ll norm(P a,P b){return norm(b.x-a.x)+norm(b.y-a.y)+norm(b.z-a.z);}

bool dlp(L l,P p,ll r){
	const ll dr=r*r;
	const ll da=norm(l.a,p),db=norm(l.b,p);
	const ll dl=norm(l.a,l.b);
	const ll cdot=norm(dot(l.b-l.a,p-l.a));

	vector<int> res;	
	res.push_back(da<dr);
	res.push_back(db<dr);
	if(dot(l.b-l.a,p-l.a)>=0 && dot(l.a-l.b,p-l.b)>=0) res.push_back(da*dl-cdot<dr*dl);
	sort(_all(res));
	return res.front()^res.back();
}


int main(void){
	int n,m,r;
	while(cin >> n >> m >> r,n){
		P sp[2010],tp[16],e;
		ll sr[2010],tb[16];
		
		rep(i,n) cin >> sp[i].x >> sp[i].y >> sp[i].z >> sr[i];
		rep(i,m) cin >> tp[i].x >> tp[i].y >> tp[i].z >> tb[i];
		cin >> e.x >> e.y >> e.z;

		R ans=0.0;

		int used[2010];
		rep(i,n){
			used[i]=0;
			rep(j,m) if(dlp({e,tp[j]},sp[i],sr[i])) used[i]|=bit(j);
		}

		rep(mask,1,1<<m){
			vector<int> idx;
			int num=0;
			rep(i,n) if(mask&used[i]) num++;

			//cout << mask << " " << num << endl;
			if(num<=r){
				R cur=0.0;
				rep(i,m) if(mask&bit(i)) cur+=1.0*tb[i]/norm(e,tp[i]);
				chmax(ans,cur);
			}
		}
		cout.precision(20);
		cout << fixed << ans << endl;
 	}	
	return 0;
}

Measured memory_bytes: 3304
#include <bits/stdc++.h>
#define ll long long
#define arena ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

ll solve(ll arr[],ll n,ll s,ll dp[])
{
    if(s==n-1)
    return 0;
    
    if(dp[s]!=-1)
    return dp[s];
    
    ll x,y;
    x=y=LONG_MAX;
    if(s+1<=n-1)
    x=abs(arr[s]-arr[s+1])+solve(arr,n,s+1,dp);
    if(s+2<=n-1)
    y=abs(arr[s]-arr[s+2])+solve(arr,n,s+2,dp);
    
    dp[s]=min(x,y);
    return dp[s];
}

int main() 
{
    arena
    ll n;
    cin>>n;
    ll arr[n];
    
    ll dp[n];
    for(ll i=0;i<n;i++)
    dp[i]=-1;
    
    for(ll i=0;i<n;i++)
    cin>>arr[i];
    
    ll s=0;
    ll x=solve(arr,n,s,dp);
    cout<<x<<'\n';
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int i = 1; i < N; ++i) {
    string head = S.substr(0, i);
    string tail = S.substr(i);
    set<char> a(head.begin(), head.end());
    set<char> b(tail.begin(), tail.end());
    set<char> intersection;
    set_intersection(a.begin(), a.end(), b.begin(), b.end(),
                     inserter(intersection, intersection.end()));
    ans = max(ans, (int)intersection.size());
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF (1e10)
#define mp make_pair
#define pb push_back
#define A 0
#define B 1
#define C 2
using namespace std;
typedef long long int lo;
lo dp[10000005][3],arr[10000005][3],n;
lo f(lo i,lo c){
	if(i == n)return dp[i][c] = arr[i][c];
	if(dp[i][c] != 0) return dp[i][c];
	if(c == A){
		return dp[i][c] = max(f(i + 1,B) + arr[i][c],f(i+1,C) + arr[i][c]);
	}
	else if(c == B){
		return dp[i][c] = max(f(i + 1,A) + arr[i][c],f(i+1,C) + arr[i][c]);
	}
	else{
		return dp[i][c] = max(f(i + 1,A) + arr[i][c],f(i+1,B) + arr[i][c]);
	}
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	cin >> n;
	for(lo i=1;i<=n;i++){
		lo a,b,c;
		cin >> a >> b >> c;
		arr[i][A] = a;
		arr[i][B] = b;
		arr[i][C] = c;
	}
	cout << max(f(1,A),max(f(1,B),f(1,C)));
}


Measured memory_bytes: 13056
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    vector<ll> x(n);
    rep(i,n) cin >> x[i];

    vector<ll> ans(100,0);

    ll kotae = INF;

    reps(i,100){
        reps(j,n){
            int a = i - x[j-1];
            ans[i-1]+=a*a;
        }
        if(ans[i-1]<kotae) kotae = ans[i-1];
    }

    cout << kotae << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String[] line;
      MyList list = new MyList();

      for(int i=0; i<n; i++) {
        line = br.readLine().split(" ");
        switch( line[0] ) {
          case "insert" :
            list.insertFirst( Integer.parseInt(line[1]) );
            break;
          case "deleteFirst" :
            list.deleteFirst();
            break;
          case "deleteLast" :
            list.deleteLast();
            break;
          case "delete" :
            list.delete( Integer.parseInt(line[1]) );
            break;
          default :
            System.out.println("n:" + i + " is failed.");
        }
      }

      System.out.println ( list.getAllElements() );
    }
  }
}

class Node {
  Node next,prev;
  int key;

  public Node(int key) {
    this.key = key;
  }
}

class MyList {
  Node nil;
  Node current;
  int size;

  public MyList() {
    nil = new Node(0);
    nil.next = nil.prev = nil;
    size = 0;
  }

  public String getAllElements() {
    StringBuilder buf = new StringBuilder(size*3);

    if(size > 0){
      current = nil.next;
      for(int i=0; i<size; i++){
        buf.append(current.key).append(" ");
        current = current.next;
      }
    }
    buf.setLength(buf.length()-1);

    return buf.toString();
  }
  public void insertFirst(int x) {
    if(size == 0) {
      current = new Node(x);
      nil.next = current;
      nil.prev = current;
      current.prev = nil;
      current.next = nil;
      size++;
    }
    else {
      Node add = new Node(x);
      
      current.prev.next = add;
      add.prev = current.prev;

      add.next = current;
      current.prev = add;

      current = add;
      size++;
    }
  }
  public void deleteFirst() {
    nil.next = current.next;
    current.next.prev = current.prev;

    current = current.next;
    size--;
  }
  public void deleteLast() {
    current = nil.prev;

    nil.prev = current.prev;
    current.prev.next = current.next;

    current = nil.next;
    size--;
  }
  public void delete(int x) {
    Node target = findFirst(x);

    if(target == nil) current = current.next;
    else {
      current.prev.next = target.next;
      current.next.prev = target.prev;
      current = nil.next;
      size--;
    }
  }
  private Node findFirst(int x) {
    while(current != nil) {
      if(current.key == x) break;
      current = current.next;
    }

    return current;
  }
}


Measured memory_bytes: 189052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  
  vector<vector<char>> a(H,vector<char>(W));
  for(int i=0; i<H; i++){
   for(int j=0; j<W; j++){
     cin >> a[i][j];
   }
  }
  
  int count=0;
  
  for(int i=0; i<H; i++){
    int row=0;
   for(int j=0; j<W; j++){
     if(a[i][j]=='.') row++;
   }
   if(row==W){
     count++;
    for(int j=0; j<W; j++){
     a[i][j]=0; 
    }
   }
  }
  
  for(int j=0; j<W; j++){
    int ver=0;
   for(int i=0; i<H; i++){
     if(a[i][j]=='.') ver++;
   }
   if(ver==H-count){
    for(int i=0; i<H; i++){
     a[i][j]=0; 
    }
   }
  }
  
  
  
  for(int i=0; i<H; i++){
   bool dele=false;
   for(int j=0; j<W; j++){
     if(a[i][j]=='.' || a[i][j]=='#'){
      cout << a[i][j];
       dele = true;
     }
   }
    if(dele==true) cout << endl;
  }
  
  
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef set<int> SI;
typedef map<string, int> MSI;
typedef map<int, int> MII;
typedef pair<ll, ll> PLL;
typedef pair<ll, pair<ll, ll>> PLLL;

#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MP make_pair
#define PB push_back
#define FF first
#define SS second
#define MOD 1000000007
#define test ll t;cin>>t;while(t--)

void solve()
{
	int x;cin >> x;
	if(x)cout << 0 << "\n";
	else cout << 1 << "\n";
	return;
}

int main()
{
	flash;

	// test
	// {
	// 	solve();
	// }
	solve();

	return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
    static class Solution {
        public void find() {

        }

    }

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

        System.out.println(c + " " +a + " " +b);
    }
}


Measured memory_bytes: 22996
n = int(input())
a = [0] * (n + 1)
for i in range(1, n + 1):
	if i*i > n:
		break
	for j in range(1, n + 1):
		z = i*i + j*j + i*j
		if z > n:
			break
		for k in range(1, n + 1):
			
			if (z + k * k + k*i + k * j) > n:
				break
			a[z + k * k + k*i + k * j] += 1
for i in a[1:]:
	print(i)

Measured memory_bytes: 74092
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func main() {
	defer w.Flush()

	var n int
	fmt.Fscanf(r, "%d\n", &n)
	var s string
	fmt.Fscanf(r, "%s\n", &s)
	var k int
	fmt.Fscanf(r, "%d\n", &k)

	target := rune(s[k-1])
	ret := strings.Map(func(c rune) rune {
		if c == target {
			return c
		}
		return '*'
	}, s)

	fmt.Fprintln(w, ret)
}

Measured memory_bytes: 640
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
d = Counter(a)
lg = 0
lt = 0
for k in d.keys():
  if d[k]>=2 and k>lg:
    lg = k
d[lg] -= 2
for k in d.keys():
  if d[k]>=2 and k>lt:
    lt = k
print(lg*lt)

Measured memory_bytes: 22140
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    string s;
    cin >> s;
    int ans = MOD;

    for (int i = 0; i < s.size() - 2; i++)
    {
        int x = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + s[i + 2] - '0';

        ans = min(ans, abs(x - 753));
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
typedef long long ll;
using namespace std;
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
inline int rd(){
	int res=0,sign=1;char ch;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')sign=-1;res=res*10+ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;
	return res*sign;
}
int t;
int a;
int main(){
	cin>>t;
	for(int i=1;i<=t;i++){
		cin>>a;
		if(a%2==0){
			if(a%3!=0&&a%5!=0){
				puts("DENIED");
				return 0;
			}
			 
		}
	}
	puts("APPROVED");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using longlong=long long;

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    std::string s;std::cin>>s;
    std::cout<<(s[1]==s[2]&&(s[0]==s[1]||s[2]==s[3])?"Yes":"No")<<std::endl;
}

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

#define REP(i,n) for(long long i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(long long i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9


int main(){
  int M, D;
  cin >> M >> D;
  int ans = 0;
  FOR(i, 1, M+1){
    FOR(j, 1, D+1){
      int d1 = j%10, d2 = j/10;
      if(d1>=2 && d2 >=2 && d1*d2 == i){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long N,K;
long long a[200005];

int check(long long x)
{
	long long now=0;
	double p=x/10.;
	for(int i=1;i<=N;++i) 
	   now+=(a[i]-1)/p;
	//cout<<now<<" "<<x<<" "<<p<<endl;
	return now <= K ;
}

int main()
{
	scanf("%lld%lld",&N,&K);
	for(int i=1;i<=N;++i)
	    scanf("%lld",&a[i]);
	long long l=1,r=1e10;
	while(l<r)
	{
		long long mid =(l + r )/ 2;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	//cout<<l<<endl;
	double p=l/10.;
    l=ceil(p);
	printf("%lld\n",l);
	return 0;
}

Measured memory_bytes: 5440
#include<bits/stdc++.h>
#include<boost/range/irange.hpp>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/algorithm/string/classification.hpp>
#include<boost/algorithm/string/split.hpp>
#include<boost/algorithm/string/join.hpp>
#include<boost/algorithm/string/replace.hpp>
#include<boost/math/tools/minima.hpp>
#include<boost/pending/disjoint_sets.hpp>
using namespace std;
using boost::irange;
using boost::multiprecision::cpp_int;
using boost::algorithm::split;
using boost::is_any_of;
using boost::algorithm::join;
using boost::algorithm::replace_all;
using boost::math::tools::brent_find_minima;
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}
int main(){
    int n;
    cin >> n;
    vector<pair<int, int>>p(n);
    for(int i = 0; i < n; i++){
        int temp;
        cin >> temp;
        pair<int, int>a;
        a.first = temp;
        a.second = i;
        p[i] = a;
    }
    sort(p.begin(), p.end());
    for(int i = 0; i < n; i++){
        cout << p[i].second + 1<< " ";
    }cout << endl;
}   



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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


int main() {
    string s;
    cin>>s;

    int b=0,w=0;

    rep(i,s.size()){
        if(i%2==0){
            if(s[i]=='0')w++;
            else b++;
        }
        else{
            if(s[i]=='1')w++;
            else b++;
        }
    }

    cout<<min(w,b)<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long A,B;
long long XOR(long long x){//0とのXORを効率よく求める
    if(x%2==0){
        if((x/2)%2==0)return x;
        else return x+1;
    }else{
        if(((x+1)/2)%2==0)return 0;
        else return 1;
    }
}
int main(void){
    cin>>A>>B;
    if(A==B){
        cout<<A<<endl;
        return 0;
    }
    long long X=XOR(A-1),Y=XOR(B);
    //cout<<X<<" "<<Y<<endl;
    if(X>Y)swap(X,Y);
    long long now=1,res=0;
    while(Y>0){
        int a=X%2,b=Y%2;
        if(a+b==1)res+=now;
        now*=2;
        X/=2;Y/=2;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b = map(int, readline().split())

    x = b - a
    y = x * (x - 1) // 2

    print(y - a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61844
#include<bits/stdc++.h>
#define int long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
#define mod 1000000007
using namespace std;
int depth[100000],parent[100000];
vector<int> g[100000];
void Onigiri()
{
  int n,m;
  cin>>n>>m;
  while(m--)
  {
    int x,y;
    cin>>x>>y;
    x--,y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }

  rep(i,0,n)
    depth[i]=INT64_MAX;
  
  depth[0]=0;
  parent[0]=0;
  
  set<pair<int,int>>s;
  s.insert({0,0});
  while(!s.empty()){
    int v=(*s.begin()).second;
    int dist=(*s.begin()).first;
    s.erase(s.begin());
    for(auto x:g[v])
    {
      if(depth[x]>dist+1)
       { s.insert({dist+1,x}); depth[x]=dist+1;parent[x]=v;}
    }
  }



  if(count(depth,depth+n,-1)>0)
    cout<<"No";
  else{
    cout<<"Yes\n";
    rep(i,1,n)
    {
      cout<<parent[i]+1<<'\n';
    }
  }

}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("in", "r", stdin);freopen("out", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

Measured memory_bytes: 19128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
   

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H,W; cin >> H >> W;
    vector<string> field(H);
    rep(i,H) cin >> field[i];
    
    bool isAns = true;
    
    
    
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            
            int nowH = i;
            int nowW = j;
            
            
            if( field[nowH][nowW]!='#') continue;
            
            bool ispart = false;
            
            rep(k,4) {
                
                int newH = nowH + dx4[k];
                int newW = nowW + dy4[k];
                
                if( !( 0<=newH&&newH<H && 0<=newW&&newW<W ) ) continue;
                if( field[newH][newW] == '#') ispart = true;
            }
            
            if(!ispart) isAns = false;
            ispart = false;
        }
    }
    
    
    if(isAns) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    
    
    
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

int main() {
    // source
    string s;
    cin >> s;

    int ans = 0;
    rep(i, 3) {
        if (s[i] == '1') {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
A1, A2, A3 = map(int, input().split())
a1 = abs(A1 - A2)
a2 = abs(A1 - A3)
a3 = abs(A2 - A3)

alist = [a1, a2, a3]
#print(alist)
min1 = min(alist)
index = alist.index(min1)
alist.pop(index)

#print(alist)
min2 = min(alist)
print(min1 + min2)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N, M;
  cin >> N >> M;
  vector<long> p(M);
  vector<string> S(M);

  for(int i=0; i<M; i++){
    cin >> p.at(i) >> S.at(i);
  }

  vector<bool> result(N, false);
  long ac = 0;
  long wa = 0;
  for(int i=0; i<M; i++){
    long num = p[i]-1;
    if(S[i] == "AC"){
      if(!result[num]){
        ac++;
        result[num] = true;
      }
    }
  }

  vector<bool> result2(N, false);
  for(int i=0; i<M; i++){
    long num = p[i]-1;
    if(S[i] == "WA"){
      if(result[num]){
        if(!result2[num]){
          wa++;
        }
      }
    }else{
      if(!result2[num]){
          result2[num] = true;
        }
    }
  }

  cout << ac << " " << wa << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define pb push_back
#define ppb pop_back()

using namespace std;

int main()
{/*
	int q;cin>>q;
	while(q--)
	{
		int n;cin>>n;
		string s;cin>>s;
		string str="";
		for(int i=0 ; i<s.length() ; i++)
		{
			if(!str.empty() and str.back()=='1' and s[i]=='0')
			{
				while(str.back()=='1') str.ppb;
			}
			str+=s[i];
		}
		cout << str<<endl;
	}*/
	int n;cin>>n;
	cout<<n+n*n+n*n*n;

	return 0;

}

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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  for(int i=A; i<=B; i++) {
    if(i%K==0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(void){
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans;
    ll d = abs(A-B);
    if(d%2==0){
        ans = d/2;
    }else{
        ans = min(A,(N-B+1))+(d-1)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iostream>
using namespace std;

int main()
{
	int i, j, k, l, m, x;
	int ans;
	ans = 0;
	char S[51];
	char T[51];
	bool flag[51];
	for (i = 0; i <= 50; i++) {
		flag[i] = true;
	}

	cin >> S >> T;
	for (i = 0; i < strlen(S); i++) {
		if (i + strlen(T) - 1 >= strlen(S)) {
			flag[i] = false;
		}else if (S[i] == '?') {
			for (j = i; j < strlen(T) + i; j++) {
				if (S[j] != '?'&&S[j] != T[j - i]) {
					flag[i] = false;
				}
			}
		}
		else if (S[i] == T[0]) {
			for (j = i; j < strlen(T) + i; j++) {
				if (S[j] != '?'&&S[j] != T[j - i]) {
					flag[i] = false;
				}
			}
		}
		else
			flag[i] = false;

	}
	for (i = strlen(S) - 1; i >= 0; i--) {
		if (flag[i]) {
			for (j = 0; j < i; j++) {
				if (S[j] == '?')
					cout << "a";
				else
					cout << S[j];
			}
			for (j = i; j < i + strlen(T); j++) {
				cout << T[j-i];
			}
			for (j = i + strlen(T); j < strlen(S); j++) {
				if (S[j] == '?')
					cout << "a";
				else
					cout << S[j];
			}
			ans = 1;
			break;
		}
	
	}
	if (ans == 0) {
		cout << "UNRESTORABLE" << endl;
	}


    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<numeric>

using namespace std;

int Sum10(int n);
int euclid( int a, int b );

int main()
{
    // 入力
    int n,xx;
    cin >> n >> xx;
    int x[n];
    
    for (int i = 0; i < n ; i++){
        cin >> x[i];
    }
    int d = abs(x[0] - xx);
    for (int i = 0; i < n ; i++){
        d = euclid(d,abs(x[i]-xx));
        //cout << d <<endl;
    }

    cout << d <<endl;

    return 0;
}

int Sum10(int n){
    int sum = 0;
    while (n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int euclid( int a, int b )
{
    int temp;

    if( a < b ) { temp = a; a = b; b = temp; }
    if( b < 1 ) return -1;

    if( a % b == 0 ) return b;
    return euclid( b, a % b );
}

Measured memory_bytes: 640
A = []
 
for i in range(3):
    A.append(list(map(int, input().split())))
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))
 
for i in range(3):
    if A[i][0] in b and A[i][1] in b and A[i][2] in b:
        print('Yes')
        exit()
for i in range(3):
    if A[0][i] in b and A[1][i] in b and A[2][i] in b:
        print('Yes')
        exit()
if A[0][0] in b and A[1][1] in b and A[2][2] in b:
    print('Yes')
    exit()
if A[2][0] in b and A[1][1] in b and A[0][2] in b:
    print('Yes')
    exit()
 
 
 
print('No')


Measured memory_bytes: 3064