akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long
#define float long double
#define all(c) (c).begin(), (c).end()
#define endl '\n'
#define pi 3.14159265358979323846

ll power(ll a,ll p,ll m=mod)
{ll res=1;while(p>0){if(p&1)res=(res*a)%m;a=(a*a)%m;p>>=1;}
return res;}

int pow(int a,int b){
	if(b == 0)return 1;
	int res = pow(a,b/2);
	res = res*res;
	if(b&1)res *= a;
	return res;
}



int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0);
   	
 //    int t;
 //     cin >> t;

 //     while(t--){

     
 // }

int n;
cin >> n;
vi v(n+1);
fo(i,0,n-1){
	int x;
	cin >> x;
	v[x]++;
}
fo(i,1,n+1)cout << v[i] << endl;


return 0;
	
	}




Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
 
int dist[30][30][30][30][4];
int used[30][30],h,w;
bool v[30][30][4];

int ans[33][33];

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

string s[303];

void bfs(int Y,int X,int K){
    dist[h-1][w-1][Y][X][K]=0;
    queue<int>q;
    q.push((h-1)*1000+(w-1));
    while(!q.empty()){
        int now=q.front();q.pop();
        int y=now/1000;
        int x=now%1000;
        r(i,4){
            int ny=y+dy[i];
            int nx=x+dx[i];
            if(ny<0||nx<0||h<=ny||w<=nx)continue;
           // cout<<y<<' '<<x<<' '<<i<<endl;
            if(!v[y][x][i])continue;
            if(dist[ny][nx][Y][X][K]!=1e9)continue;

            dist[ny][nx][Y][X][K] = dist[y][x][Y][X][K]+1;
            q.push(ny*1000+nx);
        }
    }
    //cout<<dist[0][1][Y][X][K]<<endl;
}

int bfs2(){
    r(i,33)r(j,33)ans[i][j]=1e9;
    memset(used,-1,sizeof(used));
    priority_queue<P2,vector<P2>,greater<P2> >q;
    q.push(P2(0,P(h-1,w-1)));
    ans[h-1][w-1]=0;;
    while(!q.empty()){
        P2 now=q.top();q.pop();
        int cost=now.first;
        int y=now.second.first;
        int x=now.second.second;
        if(ans[y][x] < cost)continue;
        r(i,4){
            int ny=y+dy[i];
            int nx=x+dx[i];
            if(ny<0||nx<0||h<=ny||w<=nx)continue;
            if(!v[y][x][i])continue;
            int ncos=max(cost+1,dist[ny][nx][y][x][i]);
            if(ans[ny][nx] <= ncos)continue;
            ans[ny][nx] = ncos;
            q.push(P2(ncos,P(ny,nx)));
        }
    }
    return ans[0][0];
}

signed main(){
    while(cin>>h>>w,h){
        getline(cin,s[0]);
        r(i,h*2-1){
            getline(cin,s[i]);
        }
        r(a,30)r(b,30)r(c,30)r(d,30)r(e,4)dist[a][b][c][d][e]=1e9;
        memset(v,0,sizeof(v));
        for(int i=0;i<h*2-1;i+=2){
            for(int j=0;j<w*2-1;j+=2){
                for(int k=0;k<4;k++){
                    int y=i+dy[k];
                    int x=j+dx[k];
                    if(y<0||x<0|| h*2-1<=y || w*2-1<=x)continue;
                    if(s[y][x]=='0'){
                        v[i/2][j/2][k]=1;
                    }
                }
            }
        }
        r(i,h)r(j,w)r(k,4){
            if(!v[i][j][k])continue;
            v[i][j][k]=0;
            //exit(0);
            bfs(i,j,k);
            v[i][j][k]=1;
        }
        int ANS=bfs2();
        if(ANS==1e9)cout<<-1<<endl;
        else cout<<ANS<<endl;

    }
}


Measured memory_bytes: 15888
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N, K;
	cin >> N >> K;
	vector<ll> H(N);
	for(int i=0; i<N; i++) cin >> H[i];

	sort(H.begin(), H.end());

	ll ans = 0;
	for(int i=0; i<N-K; i++){
		ans += H[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1920
import java.io.*;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        final int n = Integer.valueOf(reader.readLine());

        long originalTotal = 0L; // used later
        int[] ts = new int[n+1]; // used later

        String[] tss = reader.readLine().split(" "); // dismissed
        for (int i = 1; i <= n; i++) {
            ts[i]= Integer.valueOf(tss[i-1]);
            originalTotal += ts[i];
        }

        final int m = Integer.valueOf(reader.readLine());
        long[] result = new long[m];

        PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));
        for (int i = 0; i < m; i++) {
            String[] values = reader.readLine().split(" ");
            int num = Integer.valueOf(values[0]);
            int val = Integer.valueOf(values[1]);
            result[i] = originalTotal - ts[num] + val;
        }

        for (int i = 0; i < m; i++)
            writer.println(result[i]);

        writer.close();

    }
}


Measured memory_bytes: 20820
#include <iostream>
#include <string>
using namespace std;
int main(){
    int N;
    int j_sum = 0;
    double b_sum = 0.0;
    cin >> N;
    for (int i = 0; i < N; i++){
        string x, u;
        cin >> x >> u;
        if (u == "JPY") j_sum += stoi(x);
        else b_sum += stod(x);
    }
    long double a = j_sum + b_sum * 380000.0;
    cout << a << endl;
}

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

int main() {
  int s, w;
  cin >> s >> w;
  if(s > w) cout << "safe" << endl;
  else cout << "unsafe" << endl;
  return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	ll N=in();
	ll start=0,end=N;
	ll H = (start+end)/2;

	auto func = [](ll P,string& S){
		cout.flush();
		out(P);
		S=in<string>();
		if(S=="Vacant"){
			out(P);
			exit(0);
		}
	};

	string SS,SE,SH;
	func(start,SS);
	SE=SS;
	func(H,SH);

	REP(i,17){
		if((H-start)%2){
			if(SS!=SH){
				start = H;
				SS = SH;
				H = (start+end)/2;
			}
			else{
				end = H;
				SE = SH;
				H = (start+end)/2;
			}
		}
		else{
			if(SS==SH){
				start = H;
				SS = SH;
				H = (start+end)/2;
			}
			else{
				end = H;
				SE = SH;
				H = (start+end)/2;
			}
		}

		func(H,SH);
	}
	return 0;
}


Measured memory_bytes: 852
n = int(input())
a = list(map(int,input().split()))
MOD = 10**9 + 7
a.sort()
ans = 1
if n%2 == 1:
    for i in range(n):
        if i%2 == 0:
            if a[i] != i:
                print(0)
                exit()
        else:
            if a[i] != i+1:
                print(0)
                exit()

else:
    for i in range(n):
        if i%2 == 0:
            if a[i] != i+1:
                print(0)
                exit()
        else:
            if a[i] != i:
                print(0)
                exit()

for k in range(n//2):
    ans *= 2
    ans%= MOD

print(ans)

Measured memory_bytes: 52332
str = input()
len = len(str)
count = 0
list = []
list.append(int(str[0]))
for i in range(len-1):
  if list[i] == int(str[i+1]):
    if list[i] == 0:
      list.append(1)
    else:
      list.append(0)
    count += 1
  else:
    list.append(int(str[i+1]))
print(count)

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

int main() {
    ll n, d;
    cin >> n >> d;

    ll ans = 0;
    for (int i=0; i<n; i++) {
        ll x, y;
        cin >> x >> y;
        if (d*d >= x*x + y*y) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
#define fin return 0
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e19;

int r[100], l[100];
int a, b;

#define MAX 9223372036854775807
//////////////////////////////////////////////////////////////////////

int main() {
	ll a; cin >> a;
	cout << 3 * a*a << endl;
	return 0;
}

Measured memory_bytes: 256
/* ***************************************
Author        :Scau.ion
Created Time  :2016/09/24 19:59:28 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

using namespace std;

int main()
{
	char s[20];
    scanf("%s",&s);
    for (int j=0;j<4;++j)
    {
        printf("%c",s[j]);
    }
    printf(" ");
    for (int j=4;j<12;++j)
    {
        printf("%c",s[j]);
    }
    printf("\n");
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n) cin >> a[i];
  int ans = 0;
  rep(i,n) {
    if((i % 2 == 0) && a[i] % 2) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
x,n=map(int,input().split())
if(n==0):
  print(x)
  exit(0)
a=list(map(int,input().split()))
f=set(a)
mi=1000000
r=100000000
for i in range(-1000,1001):
  if(i in f):
    continue
  if(abs(x-i)<mi):
    mi=abs(x-i)
    r=i
print(r)

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    map<string, int> mp;

    rep(i, n)
    {
        string s;
        cin >> s;
        if (mp.find(s) == mp.end())
            mp[s] = 1;
        else
            mp[s]++;
    }
    int m;
    cin >> m;
    rep(i, m)
    {
        string t;
        cin >> t;
        if (mp.find(t) == mp.end())
            mp[t] = -1;
        else
            mp[t]--;
    }
    int ans = 0;

    for (auto x : mp)
    {
        ans = max(ans, x.second);
    }

    OP(ans);
    return 0;
}

Measured memory_bytes: 256
import os
import heapq
import sys,threading
import math as mt
import operator
from copy import copy
from collections import defaultdict,deque
from io import BytesIO, IOBase

sys.setrecursionlimit(2*10 ** 5)
#threading.stack_size(2**27)


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


"""def pw(a,b):
    result=1
    while(b>0):
        if(b%2==1): result*=a
        a*=a
        b//=2
    return result"""


def inpt():
    return [int(k) for k in input().split()]

def main():
    n=int(input())
    ans=n^1
    print(ans)





BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()
    #threading.Thread(target=main).start()


Measured memory_bytes: 74820
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 1e+6+5;
const int mo = 1e+9+7;


int f[N],pre[N];
int n;

int add(int x,int y){return x+y>=mo?x+y-mo:x+y;}

int main(){
	n=get();
	f[0]=1;
	pre[0]=1;
	fo(i,1,n){
		if (i>=3)f[i]=pre[i-3];
		f[i]=add(f[i],f[i-1]);
		pre[i]=add(pre[i-1],f[i]);
	}
	LL ans=(1ll*f[n]+1ll*f[n-1]*(n-1)%mo)%mo;
	fo(i,0,n-2)ans=(ans+1ll*f[i]*(n-1)%mo*(n-1)%mo)%mo;
	fo(i,0,n-2)ans=(ans+1ll*f[i]*(i+1)%mo)%mo;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
li = list(map(int, input().split()))
li.sort()
if len(li) == 0:
    print(x)
    exit()
x1 = x
while x1 in li:
    x1 -= 1
x2 = x
while x2 in li:
    x2 += 1
if x-x1 > x2-x:
    print(x2)
else:
    print(x1)

Measured memory_bytes: 9192
// finish date: 2018/07/19
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


//足し算
int add(int a, int b) {
    return (int) (((ll) a + b + bigmod) % bigmod);
}

//引き算
int sub(int a, int b) {
    return (int) (((ll) a - b + bigmod) % bigmod);
}

//掛け算
int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int main() {
    int N;
    cin >> N;
    vi T(N);
    vi A(N);
    rep(i, N) cin >> T[i];
    rep(i, N) cin >> A[i];
    vi h(N, -1);
    if(N==1 &&A[0] != T[0]){
        cout<<0<<endl;
        return 0;
    }
    h[0] = T[0];
    FOR(i, 1, N) {
        if (T[i] != T[i - 1]) h[i] = T[i];
    }
    h[N - 1] = A[N - 1];
    for (int i = N - 1; i >= 0; i--) {
        if (A[i] < h[i]) {
            cout << 0 << endl;
            return 0;
        }
        if (A[i] != A[i + 1]) {
            if (h[i] != -1 && h[i] != A[i]) {
                cout << 0 << endl;
                return 0;
            } else {
                h[i] = A[i];
                if (h[i] > T[i]) {
                    cout << 0 << endl;
                    return 0;
                }
            }
        }
    }
    int ans = 1;
    rep(i, N) {
        if (h[i] != -1) continue;
        ans = mul(ans, min(T[i], A[i]));
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1408
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

template<typename T>
struct SegmentTree{
private:
    int N;
    vector<T> node;
    function<T(T, T)> F;
    T E;
public:
    void init(int n, function<T(T, T)> f, T e, T def){
        F = f;
        E = e;
        N = 1;
        while(N < n) N = (N<<1);
        node.assign(2*N-1, e);
        for(int i=0; i<n; i++) node[N-1+i] = def;
        for(int i=N-2; i>=0; i--) node[i] = F(node[(i<<1)+1], node[(i<<1)+2]);
    }
    T& operator [](int a){
        return node[N-1+a];
    }
    void update(int a, T x){
        a += N-1;
        node[a] = x;
        while(a > 0){
            a = (a-1)>>1;
            node[a] = F(node[(a<<1)+1], node[(a<<1)+2]);
        }
    }
    T query(int a, int b, int k=0, int l=0, int r=-1){
        if(r == -1) r = N;
        if(b <= l || r <= a) return E;
        if(a <= l && r <= b) return node[k];
        return F(query(a, b, (k<<1)+1, l, (l+r)>>1), query(a, b, (k<<1)+2, (l+r)>>1, r));
    }
};

int N, Q;
int C[500000];
pair<pair<int,int>, int> query[500000];

SegmentTree<int> st;
int p[500000];
int ans[500000];

signed main(){
    cin >> N >> Q;
    rep(i, N){
        cin >> C[i];
        C[i]--;
    }
    rep(i, Q){
        int l, r;
        cin >> l >> r;
        query[i] ={ { l-1,r },i };
    }
    sort(query, query+Q);
    reverse(query, query+Q);

    memset(p, -1, sizeof(p));
    st.init(N, [](int a, int b){ return a+b; }, 0, 0);
    int L = N;
    rep(i, Q){
        while(L > query[i].first.first){
            if(p[C[L-1]] != -1){
                st.update(p[C[L-1]], 0);
            }
            st.update(L-1, 1);
            p[C[L-1]] = L-1;
            L--;
        }
        ans[query[i].second] = st.query(query[i].first.first, query[i].first.second);
    }

    rep(i, Q) cout << ans[i] << endl;
}

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

int main()
{
	string s; cin >> s;
	
	int i = 2;
	while (true) {

		string tmp_s = s.substr(0, s.size() - i);
		string tmp_front = tmp_s.substr(0, tmp_s.size() / 2);
		string tmp_back = tmp_s.substr(tmp_s.size() / 2, tmp_s.size() / 2);

		if (tmp_front == tmp_back) break;

		i += 2;


	}
	
	cout << s.size() - i << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vi> vvi;

ll D[200000];
vvi vex;

void dfs(int i, int p) {
    for(int r : vex[i])
        if(r != p) {
            D[r] += D[i];
            dfs(r, i);
        }
    
    return ;
}

int main() {
    int n, q; cin >> n >> q;
    vex.resize(n);
    int u, v;
    for(int i = 1; i < n; ++i) {
        cin >> u >> v;
        u -= 1; v -= 1;
        vex[u].push_back(v);
        vex[v].push_back(u);
    }
    
    while(q--) {
        cin >> u >> v;
        D[u - 1] += v;
    }
    
    dfs(0, 0);
    
    for(int i = 0; i < n; ++i)
        cout << D[i] << ' ';
    return 0;
}

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

int keta(long a) {
    int ret = 1;

    while (a /= 10) {
        ret++;
    }

    return ret;
}

int f(long a, long b) {
    return max(keta(a), keta(b));
}

int main() {
    long n;
    cin >> n;

    int ans = 11;
    for (long a = 1; a <= sqrt(n); a++) {
        if (n % a > 0) continue;

        ans = min(ans, f(a, n /a));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64, u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2], vec[3])
}

fn main() {
    let (h, w, a, b) = input_tuple();
    for i in 0..h {
        for j in 0..w {
            if i < b {
                if j < a {
                    print!("0");
                } else {
                    print!("1");
                }
            } else {
                if j < a {
                    print!("1");                    
                } else {
                    print!("0");
                }        
            }
        }
        println!();
    }
}


Measured memory_bytes: 5244
#include <bits/stdc++.h>
using namespace std;
const int MAX_V = 1000000000;

int main(){
    int n; cin >> n;
    vector<int> x(n),l(n),left(n),right(n);
    for(int i=0;i<n;++i) cin >> x[i] >> l[i];
    vector <pair<int,int> > p(n);
    for(int i=0;i<n;++i){
        left[i]=x[i]-l[i];
        right[i]=x[i]+l[i];
        p[i] = make_pair(right[i],left[i]);
    }
    int ans=0;
    int cur = -MAX_V;
    sort(p.begin(),p.end());
    for(int i=0;i<n;++i){
        if(cur<=p[i].second){
            ans++;
            cur = p[i].first;
        } 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
t=int(input())
s=input()
s1=''
for i in s:
    if((ord(i)+t)>90):
        a=(ord(i)+t)-90
        if(a==1):
            s1+=chr(ord('A')+a-1)
        else:
            s1+=chr(ord('A')+a-1)
    else:
        s1+=chr(ord(i)+t)
print(s1)


Measured memory_bytes: 3060
//Maximum Heap
#include <iostream>

using namespace std;

int parent(int i) {
    return i / 2;
}

int left(int i) {
    return 2 * i;
}

int right(int i) {
    return 2 * i + 1;
}

void maxHeapify(int A[], int H, int i) {
    int l = left(i);
    int r = right(i);

    int largest = i;
    if(l < (H + 1) && A[largest] < A[l]) largest = l;
    if(r < (H + 1) && A[largest] < A[r]) largest = r;

    if(largest != i) {
        swap(A[i], A[largest]);
        maxHeapify(A, H, largest);
    }
}

void buildMaxHeap(int A[], int H) {
    for(int i = H / 2; i > 0; i--) maxHeapify(A, H, i);
}

int main() {
    int H;
    cin >> H;
    int A[H + 1];
    for(int i = 1; i < H + 1; i++) cin >> A[i];

    buildMaxHeap(A, H);

    for(int i = 1; i < H + 1; i++) {
        cout << " " << A[i];
    }
    cout << endl;
}


Measured memory_bytes: 5084
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int num[] = new int[5];
        int result = 0;
        for(int i = 0; i < 5; i++){
            num[i] = sc.nextInt();
            if(num[i] == 0){
                result = i + 1;
            }
        }
        System.out.println(result);
    }
}

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

int main(void){

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

    return 0;
}


Measured memory_bytes: 256
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n,m = inp
a = []
lin = na2(n+1,0)
m.times do |i|
  a.push(inp)
  lin[a[i][0]].push(a[i][1])
  lin[a[i][1]].push(a[i][0])
end
ans = 0
m.times do |i|
  lin[a[i][0]].shift
  lin[a[i][1]].shift
  log = copy(lin[1])
  save = na(n+1,false)
  save[0] = true
  while (log.size > 0)
    d = log.shift
    next if(save[d])
    lin[d].each do |dd|
      log.push(dd)
    end
    save[d] = true
  end
  lin[a[i][0]].push(a[i][1])
  lin[a[i][1]].push(a[i][0])
  ans += 1 unless save.all?
end
p ans

Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  string S; cin >> S;
  string result = "Yes";
  rep(i, S.length()) {
    if (i%2==0 && (S[i]=='R'||S[i]=='U'||S[i]=='D')) continue; 
    if (i%2==1 && (S[i]=='L'||S[i]=='U'||S[i]=='D')) continue; 
    result = "No";
  }
  cout << result << endl;
  return 0;
}

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

int main()
{
	
	string s,t;
	cin >> s >> t;
	int n=s.length(),i,c=0;
	for(i=0;i<n;i++)
	{
		if(s[i]!=t[i])
			c++;
	}
	cout << c;

}

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

#define IOS cin.tie(0);ios::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template <class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?' ':'\n'); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);}//最小公倍数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

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

const int NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}

signed main(){
    IOS;
    CIN(x1,y1,x2,y2);
    int x=x2-x1,y=y2-y1;
    printf("%d %d %d %d\n",x2-y,y2+x,x1-y,y1+x);    

    return 0;
}

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

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)   __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)   __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)   __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define ll long long
#define pb push_back
#define PI M_PI
#define endl "\n"
#define sc scanf
#define pf printf
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main()
{
     IOS
     ll a,b,c;
     int i;
     map<char,int> m1,m2;
     string s2,s1;
     cin>>s1>>s2;
     //sort(s1.begin(),s1.end());
     //sort(s2.begin(),s2.end());
     for(i = 0; i < s1.size(); i++)
          {
               if(s1[i]!=s2[i])
               {
                    cout<<"No\n";
                    return 0;
               }
          }

          cout<<"Yes\n";


     return 0;
}



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

int main(void){
	ll a,b,k;
	cin>>a>>b>>k;

	ll A = max(0LL,a-k);
	k = max(0LL,k-a);
	cout<<A<<" "<<max(0LL,b-k)<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a[100], b[100], c1[100], d1[100],c2[100],d2[100],cans[100],dans[100];
    int i, h, w, x, y, num, lot;
    lot = 0;
    for (i = 0; i < 100; i++)
    {
        scanf("%d %d", &a[i], &b[i]);
        if (a[i] == b[i] && b[i] == 0)
        {
            break;
            num = i;
        }
        num = i;
    }
 
    for (i = 0; i <= num; i++)
    {
        x = a[i];
        y = b[i];
        c1[i] = x;
        d1[i] = y;
        c2[i] = x;
        d2[i] = y;
        for (w = 150; w >= 2; w--)
        {
            for (h = w - 1; h >= 1; h--)
            {
                if (w == 150 && h == 149)
                {
                    if (x*x + y*y<h*h+w*w)
                    {
                        c1[i] = h;
                        c1[i] = w;
                    }
                }
                if ((x*x + y*y )<( h*h + w*w)&&(h*h+w*w)<(c1[i]*c1[i]+d1[i]*d1[i]))
                {
                    c1[i] = h;
                    d1[i] = w;
                }
            }
        }
 
            for (w = 150; w >= 2; w--)
            {
                for (h = 1; h < w; h++)
                {
                    if ((c1[i] != h&&d1[i] != w) && (c1[i] * c1[i] + d1[i] * d1[i]) == h*h + w*w&&h <= c1[i])
                    {
                        c1[i] = h;
                        d1[i] = w;
                        w = 1;
                        h = 152;
                     
 
                    }
                }
            }
 
         
 
        for (w = 150; w >= 2; w--)
        {
            for (h = 1; h < w; h++)
            {
                if ((x!= h&&y!= w) &&( x * x + y * y)== h*h + w*w&&h > a[i])
                {
                    c2[i] = h;
                    d2[i] = w;
                    w = 1;
                    h = 152;
                }
            }
        }
    }
     
    for (i = 0; i <= num; i++)
    {
        if (c2[i] != a[i] || d2[i] != b[i])
        {
            printf("%d %d\n", c2[i], d2[i]);
        }
        else
        {
            printf("%d %d\n", c1[i], d1[i]);
        }
         
    }
 
    return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
    char mp[3][3];
    int i,j;
    for(i = 0; i < 2; i++){
        for(j = 0; j < 3; j++){
            scanf("%c",&mp[i][j]);
        }
        getchar();
    }
    int flag = 1;
    for(i = 0,j = 2; i < 3; i++,j--){
        if(mp[0][i] != mp[1][j]){
            flag = 0;
            break;
        }
    }
    if(flag)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <numeric>
#define ll long long
using namespace std;
int main() {
  ll N;
  cin>>N;
  ll a=N/1.08;
  ll A=a*1.08,B=(a-1)*1.08,C=(a+1)*1.08;
  if(A==N) cout<<a<<endl;
  else if(B==N) cout<<a-1<<endl;
  else if(C==N) cout<<a+1<<endl;
  else cout<<":("<<endl;
}


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

int main()
{
    int n,m,k;cin>>n>>m>>k;
    bool can = false;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            if(i*m+j*n-2*i*j == k) can = true;
        
        }
    }
    cout << (can ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    float n;
    cin>>n;
    if(n<=1000)
    {
        cout<<1000-n<<endl;
    }
    else
    {
        //cout<<ceil(float(n/1000))<<endl;
        cout<<ceil(float(n/1000))*1000-n<<endl;
    }
}


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

int main(){
    ll N, T;
     cin >> N >> T;
     ll ans = 1e18;
     rep(i, 0, N){
         ll c, t;
         cin >> c >> t;
         if(t <= T) ans = min(ans, c);
     }
     if(ans == 1e18) cout << "TLE" << endl;
     else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int N,K;
char S[11];

scanf("%d",&N);
scanf("%s",S);
scanf("%d",&K);

for(int i=0;i<N;i++){
if(S[i]!=S[K-1]) S[i]='*';
}

printf("%s",S);
return 0;
}

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

int main(){
  int a, b, c;
  cin>>a>>b>>c;

  int cnt = 0;
  for(int x = a; x <= b; x++){
    if(c % x == 0) cnt++;
  }

  cout<<cnt<<endl;
  
  return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int n,m,sum,a[10010];
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    for(int i=n-m;i<n;i++) sum+=a[i];
    cout<<sum<<endl;
    return 0;
}

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

int main() {
	// your code goes here
	int a[5];
	for(int i=0;i<5;i++)
	    cin >>a[i];
	for(int i=0;i<5;i++){
	    if(a[i]==0){
	        cout << i+1 << endl;
	        break;
	    }
	}
	return 0;
}


Measured memory_bytes: 3584
#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[i];
	}

	sort(a.begin(),a.end());

	int count=0;

	for(int i=0;i<n-2;i++){

		for(int j=i+1;j<n-1;j++){

			for(int k=j+1;k<n;k++){

				if(a[k]<a[i]+a[j] && a[i]!=a[j] && a[i]!=a[k] && a[k]!=a[j]){
					count++;
					//cout<<a[i]<<" "<<a[j]<<" "<<a[k]<<endl;
				}
			}
		}
	}

	cout<<count<<endl;

	return 0;
}

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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    /* code */
    int N;
    cin >> N;
    vector<int> hs(N);
    REP(i, N) { cin >> hs[i]; }
    vector<int> dp(N);
    dp[0] = 0;
    dp[1] = abs(hs[0] - hs[1]);
    for (int i = 2; i < N; i++) {
        dp[i] = min(abs(hs[i - 2] - hs[i]) + dp[i - 2],
                    abs(hs[i - 1] - hs[i]) + dp[i - 1]);
    }
    cout << dp[N - 1] << endl;
    return 0;
}

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

int main(){
	int a[4][3][10];
	int n, b, f, r, v;

		for (int i = 0; i < 4; i++){
			for (int j = 0; j < 3; j++){
				for (int k = 0; k < 10; k++){
					a[i][j][k] = 0;
				}
			}
		}

		cin >> n;
		for (int i = 0; i < n; i++){
			cin >> b >> f >> r >> v;
			a[b-1][f-1][r-1] += v;
		}

		for (int i = 0; i < 4; i++){
			for (int j = 0; j < 3; j++){
				for (int k = 0; k < 10; k++){
					cout <<" "<< a[i][j][k];
				}
				cout << endl;
			}
			if (i != 3){
				cout << "####################" << endl;
			}
		}

	return 0;
}

Measured memory_bytes: 3076
package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func main() {
	defer write.Flush()

	var s string
	fmt.Fscan(read, &s)

	if s == "AAA" || s == "BBB" {
		fmt.Fprintln(write, "No")
	} else {
		fmt.Fprintln(write, "Yes")
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(std::vector<long long> A){
  if (A[0] + A[1] + A[2] > 21) {
    std::cout << "bust" << std::endl;
  } else {
    std::cout << "win" << std::endl;
  }
}

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


Measured memory_bytes: 256
n,k=map(int,input().split())
a=[list(map(int,input().split()))for i in range(n)]
l,r=2*(10**18)+1,0
while l-r>1:
    t=(l+r)//2
    c=0
    for i,j in a:
        c+=max(0,(t-i)//j+1)
    if c<k:
        r=t
    else:
        l=t
print(l)

Measured memory_bytes: 63448
#include<stdio.h>
int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a,b,c>=-100 && a,b,c<=100)
    {
        if(c>=a && c<=b)
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define max 101
#define INF -1
#define WHITE 0
#define GRAY -1
#define BLACK 1
int n,color[max],d[max];
int varry[max][max];
void bfs(int s){
  queue<int>q;
  int u;
  for(int i=1;i<=n;i++){
    d[i]=INF;
  }
  color[s]=GRAY;
  d[s]=0;
  q.push(s);
  while(!q.empty()){
    u=q.front();
    q.pop();
    for(int i=1;i<varry[u][0]+1;i++){
      if(color[varry[u][i]]==WHITE){
	color[varry[u][i]]=GRAY;
	d[varry[u][i]]=d[u]+1;
	q.push(varry[u][i]);
      }
    }
    color[u]=BLACK;
  }

}
int main(){
  int u;
  cin>>n;
  for(int k=0;k<n;k++){
    cin>>u;
    cin>>varry[u][0];
    for(int i=0;i<varry[u][0];i++)
      cin>>varry[u][i+1];
  }
  bfs(1);
  for(int i=1;i<=n;i++)
    cout<<i<<" "<<d[i]<<endl;


  return 0;
}



Measured memory_bytes: 3124
# -*- coding: utf-8 -*-
"""
Created on Mon Sep  7 17:36:58 2020

@author: liang
"""
"""
全探索
"""
N, M = map(int, input().split())

test = list()
for _ in range(M):
    s,c =  map(int,input().split()) 
    test.append((s,c))

#print(test)
tmp = [0]*3
for i in range(10**N):
    tmp[0] = i//100
    tmp[1] = i//10%10
    tmp[2] = i%10
    #print(tmp)
    for tup in test:
        s, c = tup[0], tup[1]
        if tmp[(3-N)+s-1] != c:
            break
    else:
        #最上位の桁が0でないか
        if tmp[-N] == 0 and N != 1:
            continue
        print(i)
        break
else:
    print(-1)

Measured memory_bytes: 9132
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

int main() {
	long long X, Y; std::cin >> X >> Y;
	int ans = 0;
	while (X <= Y) {
		X *= 2;
		++ans;
	}
	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 3576
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<map>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int main(){
  ll N,M,ans;
  cin>>N>>M;
  if(N>M)swap(N,M);
  if(N==1){
    if(M==1) ans=1;
    else ans=M-2;
  }else if(N==2) ans=0;
  else{
    ans=(N-2)*(M-2);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
    vector<int> p(3);
    REP(i, 3)
    cin >> p[i];

    sort(ALL(p));

    for (int i = 0; i < p.size() - 1; i++)
    {
        cout << p.at(i) << " ";
    }
    cout << p.at(p.size() - 1) << endl;
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

//　if文
// if (num == 0)
// {
//     cout << "0";
// }
// else if (num == 1)
// {
//     cout << "1"; // 1が表示される
// }
// else
// {
//     cout << "01以外";
// }


Measured memory_bytes: 3156
#include <iostream>

using namespace std;

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (a - b >= 0) {
    cout << "delicious" << endl;
  } else if (x + (a - b) >= 0) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
  return 0;
}


Measured memory_bytes: 3124
l, r = map(int, input().split())
r = min(r, l + 4038)
ans = 2018
for i in range(l, r):
  for j in range(i + 1, r + 1):
    ans = min((i * j) % 2019, ans)
    #割り切れた場合はそれが最小値なので探索終了とする
    if ans == 0:
      break

print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <complex>
#include <cmath>
#include <vector>

using namespace std;

typedef complex<double> xy_t;

double cross_product(xy_t a, xy_t b) {
	return (conj(a) * b).imag();
}

int main() {
	int n;
	double x, y;
	double s = 0;
	scanf("%d", &n);
	vector<xy_t> vertex;
	while (scanf("%lf %lf", &x, &y) != EOF) {
		vertex.push_back(xy_t(x, y));
	}
	for (int i = 1; i < vertex.size() - 1; i++) {
		s += cross_product(vertex[i] - vertex[0], vertex[i + 1] - vertex[0]) / 2;
	}
	printf("%.1f\n", s);
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main(){

    int d,t,s;
    cin >> d >> t >> s;
    if(d<=t*s) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x,y;
cin>>x>>y;
if( y&1)
{
     cout<<"No"<<endl;
}
else if(2*x>y || x*4<y)
{
     cout<<"No"<<endl;
}
else
cout<<"Yes"<<endl;
}

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

typedef long long int ll;

typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;

#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define Precision(i) cout << fixed << setprecision(i)

const double PI=3.14159265358979323846;
const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;

int main() {

  int n;
  cin >> n;
  vector<Pll> a(n);
  REP(i,n) cin >> a.at(i).first >> a.at(i).second;
  vector<int> v;
  REP(i,n) v.push_back(i);
  long double ans = 0;
  ll count=0;
  do{
    REP(i,v.size()-1){
      ll x1=a.at(v.at(i)).first;
      ll y1=a.at(v.at(i)).second;
      ll x2=a.at(v.at(i+1)).first;
      ll y2=a.at(v.at(i+1)).second;

      ans += sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    }
    count++;
  }while(next_permutation(v.begin(), v.end()));

  ans /= (long double)count;
  Precision(12);
  cout << ans << endl;
}

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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;




signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	deque<int> d;
	while (1) {
		int k;
		cin >> k;
		if (cin.eof()) break;
		if (k == 0) {
			cout << d.back() << endl;
			d.pop_back();
		}
		else {
			d.push_back(k);
		}
	}
}



Measured memory_bytes: 3152
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



string lcs(const string& a, const string& b)
{
	const int dx[] = { -1, 0, -1 };
	const int dy[] = { 0, -1, -1 };

	vector<vector<int> > dp(a.size() + 1, vector<int>(b.size() + 1, 0));
	vector<vector<int> > path(a.size() + 1, vector<int>(b.size() + 1, -1));
	for (int i = 0; i < a.size(); ++i)
	{
		for (int j = 0; j < b.size(); ++j)
		{
			if (a[i] == b[j])
			{
				dp[i + 1][j + 1] = dp[i][j] + 1;
				path[i + 1][j + 1] = 2;
			}
			else
			{
				if (dp[i + 1][j] > dp[i][j + 1])
				{
					dp[i + 1][j + 1] = dp[i + 1][j];
					path[i + 1][j + 1] = 0;
				}
				else
				{
					dp[i + 1][j + 1] = dp[i][j + 1];
					path[i + 1][j + 1] = 1;
				}
			}
		}
	}

	stringstream ss;
	for (int i = a.size(), j = b.size(); path[i][j] != -1; )
	{
		int p = path[i][j];
		if (p == 2)
		{
			ss << a[i - 1];
		}

		i += dy[p];
		j += dx[p];
	}
	string res = ss.str();
	reverse(all(res));
	return res;
}
int main()
{
	static char buf[2048];
	while (~scanf("%s", buf))
	{
		string a(buf), b(buf);
		reverse(all(b));
		cout << lcs(a, b) << endl;
	}
}

Measured memory_bytes: 31000