akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
int main()
{
    fastIO;
    ll n;
    cin>>n;
    ll a[n],x;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    bitset<1000000001>b;
    for(int i=0;i<n;i++)
    {
        x=a[i];
        b[x]=true;
    }
    if(b.count()==n)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int k = sc.nextInt();

        int sum = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            sum += Math.min(Math.abs(x - k), x);
        }

        System.out.println(sum * 2);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 21332
s = gets.chomp.split("").uniq
size = s.size
t = "abcdefghijklmnopqrstuvwxyz".split("")
for i in 0..size-1
  if t.include?(s[i])
    t.delete(s[i])
  end
end
if t.size == 0
  puts "None"
else
  puts t[0]
end

Measured memory_bytes: 6908
/*やったぜ。　投稿者：変態糞土方 (8月16日（水）07時14分22秒)

昨日の8月15日にいつもの浮浪者のおっさん（60歳）と先日メールくれた汚れ好きの土方のにいちゃん

（45歳）とわし（53歳）の3人で県北にある川の土手の下で盛りあったぜ。

今日は明日が休みなんでコンビニで酒とつまみを買ってから滅多に人が来ない所なんで、

そこでしこたま酒を飲んでからやりはじめたんや。

3人でちんぽ舐めあいながら地下足袋だけになり持って来たいちぢく浣腸を3本ずつ入れあった。

しばらくしたら、けつの穴がひくひくして来るし、糞が出口を求めて腹の中でぐるぐるしている。

浮浪者のおっさんにけつの穴をなめさせながら、兄ちゃんのけつの穴を舐めてたら、

先に兄ちゃんがわしの口に糞をドバーっと出して来た。

それと同時におっさんもわしも糞を出したんや。もう顔中、糞まみれや、

3人で出した糞を手で掬いながらお互いの体にぬりあったり、

糞まみれのちんぽを舐めあって小便で浣腸したりした。ああ～～たまらねえぜ。

しばらくやりまくってから又浣腸をしあうともう気が狂う程気持ちええんじゃ。

浮浪者のおっさんのけつの穴にわしのちんぽを突うずるっ込んでやると

けつの穴が糞と小便でずるずるして気持ちが良い。

にいちゃんもおっさんの口にちんぽ突っ込んで腰をつかって居る。

糞まみれのおっさんのちんぽを掻きながら、思い切り射精したんや。

それからは、もうめちゃくちゃにおっさんと兄ちゃんの糞ちんぽを舐めあい、

糞を塗りあい、二回も男汁を出した。もう一度やりたいぜ。

やはり大勢で糞まみれになると最高やで。こんな、変態親父と糞あそびしないか。

ああ～～早く糞まみれになろうぜ。

岡山の県北であえる奴なら最高や。わしは163*90*53,おっさんは165*75*60、や

糞まみれでやりたいやつ、至急、メールくれや。

土方姿のまま浣腸して、糞だらけでやろうや。*/
#include "bits/stdc++.h"
#include <numeric>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define llMIN numeric_limits<long long>::min()
#define intMIN numeric_limits<int>::min()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double

ll digitpower(ll a,ll b){//aのb乗を計算
  if(b==1){
    return a;
  }else if(b==0){
    return 1;
  }
  if(b%2==1){
    ll tmp = digitpower(a,(b-1)/2);
    tmp%=d9_7;
    tmp*=tmp;
    tmp%=d9_7;
    tmp*=a;
    return (tmp)%d9_7;
  }else{
    ll tmp = digitpower(a,(b)/2);
    tmp%=d9_7;
    tmp*=tmp;
    tmp%=d9_7;
    return (tmp)%d9_7;
  }
}
//階乗
vl facs(1000000,-1);
ll Factrial(ll num){
  if(facs[num]!=-1){
    return facs[num];
  }
  if(num==1||num<=0){
    return 1;
  }else if(num<0){
    printf("ERROR_minus\n");
    return 0;
  }else{
    facs[num]=(num*Factrial(num-1))%d9_7;
    return facs[num];
  }
}
long long modinv(long long a, long long m) {//modの逆元
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
ll linercomb(ll n,ll k, ll mod){//n,kの線形時間で求める
  ll ans=Factrial(n);
  ans*=modinv(Factrial(k),mod);
  ans%=d9_7;
  ll k1=Factrial(k);
  k1%=mod;
  ans*=modinv(k1,mod);
  ans%=mod;
  return ans;
}
struct datas{
  ll x;
  ll l;

};
bool cmp(const datas &a, const datas &b)
{
    return a.x < b.x;
}

int main(void){
  ll n;
  cin>>n;
  vector<datas> d(n);
  rep(i,n){
    cin>>d[i].x>>d[i].l;
  }
  sort(d.begin(),d.end(),cmp);
  ll nowmostl=llMIN;
  int cnt=0;
  rep(i,n){
    //cout<<nowmostl<<endl;
    if(nowmostl<=d[i].x-d[i].l){
      cnt++;
      nowmostl=d[i].x+d[i].l;
    }else{
      if(nowmostl>d[i].x+d[i].l){
        nowmostl=d[i].x+d[i].l;
      }else{
        ;
      }
      //anti_count
    }
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 9600
def solve():
    N = int(input())
    p = list(map(int, input().split()))
    
    ans = 0
    for i in range(N - 1):
        if i + 1 == p[i]:
            p[i], p[i + 1] = p[i + 1], p[i]
            ans += 1
    if p[N - 1] == N:
        ans += 1
    print(ans)


if __name__ == '__main__':
    solve()


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int N = read(), min = N;
  REP(i, 5) { chmin(min, read()); }
  if (N == min) {
    print(5);
  } else {
    if (N % min) {
      print(5 + (N / min));
    } else {
      print(5 + (N / min) - 1);
    }
  }
}


Measured memory_bytes: 256
function main()
	N=parse(Int,readline())
	C=Int[]
	S=Int[]
	F=Int[]
	for s=readlines()
		c,s,f=map(x->parse(Int,x),split(s))
		push!(C,c)
		push!(S,s)
		push!(F,f)
	end
	for i=1:N
		now=0
		for j=i:N-1
			now=max(cld(now,F[j])*F[j],S[j])+C[j]
		end
		println(now)
	end
end
main()


Measured memory_bytes: 110856
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    { 
        int n;
        cin>>n;
        if(n==0)
        cout<<1;
        else
        cout<<0;
    }
}

    
// 🍪 🍪 🍪


Measured memory_bytes: 3604
import sys
#import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
nodes = [set() for _ in range(N+1)]

for _ in range(N-1):
    a, b = rl()
    nodes[a].add(b)
    nodes[b].add(a)

C = rl()
C.sort(reverse=True)
score = sum(C[1:])
deg = [len(x) for x in nodes]
deg_1 = [i for i, x in enumerate(deg) if x == 1]
answer = [0] * (N+1)

while deg_1:
    v = deg_1.pop()
    if not deg_1:
        answer[v] = C.pop()
        break
    w = nodes[v].pop()
    nodes[w].remove(v)
    deg[w] -= 1
    if deg[w] == 1:
        deg_1.append(w)
    answer[v] = C.pop()

print(score)
print(*answer[1:])


Measured memory_bytes: 7312
#include <iostream>
#include <string>
#include <numeric>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <random>

using namespace std; 

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int color[9] = { 0 };

	for (auto v : a)
	{
		if (v < 3200)
		{
			color[v / 400]++;
		}
		else
		{
			color[8]++;
		}
	}
	
	int num = 0;
	for (int i = 0; i < 8; i++)
	{
		if (color[i] != 0)
		{
			num++;
		}
	}
	if (num == 0)
	{
		cout << 1 << " " << color[8] << endl;
	}
	else
	{
		cout << num << " " << num + color[8] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

n = II()
aa = LI1()
dp = [[-10]*n for _ in range(n)]
mx = [-10]*(n+1)
nmx = [-10]*(n+1)
a, b = min(aa[:2]), max(aa[:2])
dp[a][b] = dp[b][a] = 0
mx[a] = mx[b] = mx[n] = 0

def chmax(i, j, val):
    if val < 0: return
    if val > dp[i][j]:
        dp[i][j] = dp[j][i] = val
        nmx[i] = max(nmx[i], val)
        nmx[j] = max(nmx[j], val)
        nmx[n] = max(nmx[n], val)

base = 0
for i in range(n-1):
    abc = aa[i*3+2:i*3+5]
    # print(abc)
    abc.sort()
    a, b, c = abc
    # 3枚とも同じ場合
    if a == c:
        base += 1
        continue
    # b==cのときa==bになるようにする
    if b == c: a, c = c, a
    # ペアがある場合
    if a == b:
        vc = dp[c][c]
        for x, v in enumerate(dp[a][:]): chmax(c, x, v+1)
        chmax(a, c, max(mx[n], dp[a][a]+1))
        chmax(a, a, max(mx[n], vc+1))
        for x in range(n): chmax(a, x, mx[x])
        for x in range(n): chmax(c, x, mx[x])
    # 3枚とも異なる場合
    else:
        # a,b,cから2枚残す場合
        chmax(b, c, max(dp[a][a]+1, mx[n]))
        chmax(a, c, max(dp[b][b]+1, mx[n]))
        chmax(a, b, max(dp[c][c]+1, mx[n]))
        # a,b,cから1枚残す場合
        for x in range(n):
            chmax(a, x, mx[x])
            chmax(b, x, mx[x])
            chmax(c, x, mx[x])

    for x in range(n+1): mx[x] = max(mx[x], nmx[x])
    # p2D(dp)
    # print(mx)
    # print()

a = aa[-1]
ans = max(mx[n], dp[a][a]+1)+base
print(ans)


Measured memory_bytes: 105088
N,M=map(int,input().split())
list_A=list(map(int,input().split()))
sum_A=sum(list_A)
count=0
for i in range(N):
    if list_A[i]>=sum_A/(4*M):
        count+=1
if count>=M:
    print("Yes")
else:
    print("No")

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

main()
{
    long long int sum=0,i,j,k,n;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i%3==0 || i%5==0)
        {
            
        }
        else
        {
            sum+=i;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3624
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 20-Apr-20 3:53:36 AM
	flamers will **** you
*/
//#include<flamers.h>

#include "bits/stdc++.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define POB pop_back

using namespace std;

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	int n, m;
	cin>>n>>m;
	int a[m];
	int sum = 0;
	for(int i = 0; i < m; i++) {
		cin>>a[i];
		sum += a[i];
	}
	if(sum > n) cout<<-1<<endl;
	else cout<<n - sum<<endl;
	return 0;
}


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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int H,W;
char s[350][350];
int ans[350][350];
int dy[4]={-1,1};

void solve(int sx,int sy,int num){
    queue<P> que;
    que.push({sx,sy});
    ans[sx][sy]=num;
    while(!que.empty()){
        P p=que.front(); que.pop();
        int x=p.first;
        int y=p.second;
        for(int i=0;i<2;i++){
            int nx=x;
            int ny=y+dy[i];
            if(nx>=0&&ny>=0&&nx<H&&ny<W&&s[nx][ny]=='.'){
                if(ans[nx][ny]!=-1) continue;
                ans[nx][ny]=num;
                que.push({nx,ny});
            } 
        }
    }
}


int main(){
    int K; cin >> H >> W >> K;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> s[i][j];
        }
    }
    int tmp=1;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            ans[i][j]=-1;
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(s[i][j]=='#'){
                solve(i,j,tmp);
                tmp++;
            }
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(ans[i][j]!=-1){
                for(int k=i-1;k>=0;k--){
                    if(ans[k][j]!=-1) break;
                    ans[k][j]=ans[i][j];
                }
                for(int k=i+1;k<H;k++){
                    if(ans[k][j]!=-1) break;
                    ans[k][j]=ans[i][j];
                }
            }
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  s=s+"S";
  int i,max=0,c=0;
  for(i=0; i<s.size(); i++)
  {
    if(s[i]=='R')
    {
      c++;
    }
    else
    {
      if(c>max)
      {
        max=c;
      }
      
      c=0;
    }
  }
  cout<<max;
}

Measured memory_bytes: 3596
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

struct Edge {
    int to, id;
    Edge(int to, int id): to(to), id(id) {};
};

class FTreeAndConstraints {
    vector<vector<Edge>> edges_;
    vector<ll> conditionSet_;

    bool dfs(const int current, const int parent, const int goal, vector<int>& paths) {
        if (current == goal) return true;
        for (const auto& edge : edges_[current]) {
            if (edge.to == parent) continue;
            if (dfs(edge.to, current, goal, paths)) {
                paths.emplace_back(edge.id);
                return true;
            }
        }
        return false;
    }

public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    in >> N;
	    edges_ = vector<vector<Edge>>(N+1);
	    REP(i,0,N-1) {
	        int from, to;
	        in >> from >> to;
	        edges_[from].emplace_back(to, i);
	        edges_[to].emplace_back(from, i);
	    }
	    int M;
	    in >> M;
	    conditionSet_ = vector<ll>(N); // store whether which condition will visit each edge.
	    REP(i,0,M) {
	        int u, v;
	        in >> u >> v;
	        vector<int> paths;
	        dfs(u, -1, v, paths);
	        for (const auto& id : paths) {
	            conditionSet_[id] += 1LL << i;
	        }
	    }
	    // the number of cases that all the conditions are satisfied
	    // = 2^(N-1) - (the number of cases that one or more conditions are not satisfied)
	    ll answer = 1LL << N-1;
	    // for each combination, calculate C and modify answer
	    for (ll i=1; i<(1LL<<M); i++) {
	        ll white = 0; // C
	        int mCnt = 0;
	        // calculate C. count the number of edges if one or more conditions in i are included.
	        REP(j,0,N-1) {
	            if (i & conditionSet_[j]) white++;
	        }
	        // the number of conditions which should not be satisfied.
	        REP(j,0,M) {
	            if (i & (1LL<<j)) mCnt++;
	        }
	        answer += (1LL << (N-white-1)) * (mCnt % 2 == 1 ? -1 : 1);
	    }
	    out << answer << "\n";
	}
};


int main() {
	FTreeAndConstraints solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

//Left Hand Rule
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int INF = 1<<29;
		int[][] d = {{0,1},{1,0},{0,-1},{-1,0}};
		for(;;){
			int w = sc.nextInt(), h = sc.nextInt(), n = sc.nextInt();
			if((w|h|n)==0)break;
			boolean[][][] wall = new boolean[w][h][4];
			for(int x=0;x<w;x++)wall[x][0][2] = wall[x][h-1][0] = true;
			for(int y=0;y<h;y++)wall[0][y][3] = wall[w-1][y][1] = true;
			while(n--!=0){
				int x1 = sc.nextInt(), y1 = sc.nextInt(), x2 = sc.nextInt(), y2 = sc.nextInt();
				if(x1==x2){
					for(int y=Math.min(y1, y2);y<Math.max(y1, y2);y++)wall[x1][y][3] = wall[x1-1][y][1] = true;
				}
				else{
					for(int x=Math.min(x1, x2);x<Math.max(x1, x2);x++)wall[x][y1][2] = wall[x][y1-1][0] = true;
				}
			}
			boolean[][][] u = new boolean[w][h][4];
			int px = 0, py = 0, pk = 0, step = 1, res = INF;
			int x1 = sc.nextInt(), y1 = sc.nextInt(), x2 = sc.nextInt(), y2 = sc.nextInt(), gx = sc.nextInt(), gy = sc.nextInt();
			if(x2<x1||(x1==x2&&y2<y1)){
				int tx = x1, ty = y1;
				x1 = x2; y1 = y2; x2 = tx; y2 = ty;
			}
			if(x1==x2){
				if(x1==0){
					wall[x1][y1][3] = false;
					u[x1][y1][1] = true;
					px = x1; py = y1; pk = 1;
				}
				else{
					wall[x1-1][y1][1] = false;
					u[x1-1][y1][3] = true;
					px = x1-1; py = y1; pk = 3;
				}
			}
			else{
				if(y1==0){
					wall[x1][y1][2] = false;
					u[x1][y1][0] = true;
					px = x1; py = y1; pk = 0;
				}
				else{
					wall[x1][y1-1][0] = false;
					u[x1][y1-1][2] = true;
					px = x1; py = y1-1; pk = 2;
				}
			}
			for(boolean f=true;f;step++){
				if(px==gx&&py==gy){
					res = step; break;
				}
				for(int k=3;k<7;k++){
					int nk = (pk+k)%4;
					if(!wall[px][py][nk]){
						px+=d[nk][0]; py+=d[nk][1]; pk=nk;
						if(0<=px&&px<w&&0<=py&&py<h&&!u[px][py][pk]){
							u[px][py][pk] = true;
						}
						else{
							f = false; break;
						}
						break;
					}
				}
			}
			System.out.println(res==INF?"Impossible":res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 16000
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Deque<Integer> ad= new ArrayDeque<Integer>();
		while(sc.hasNextInt()){
			int n=sc.nextInt();
			if(n==0){
				System.out.println(ad.pop());

			}else{
				ad.push(n);
			}
		}
	}

}

Measured memory_bytes: 25936
import java.io.*;
import java.util.*;
public class Main {
    
    static int solve(int[][] arr, int i, int a, HashMap<String, Integer> map) {
        if(i >= arr.length)
            return 0;
            
        String key = i + "," + a;
        if(map.containsKey(key))
            return map.get(key);
        
        int sum = 0;
        for(int ac = 0; ac < 3; ac++) {
            if(ac != a) {
                sum = Math.max(sum, solve(arr, i + 1, ac, map) + arr[i][ac]);
            }
        }
        
        map.put(key, sum);
        return sum;
    }
    
    public static void main(String args[]) {
        int n = 0, k = 0;
        int[][] arr = null;
        try (Scanner scanner = new Scanner(System.in)) {
            n = scanner.nextInt();
            
            arr = new int[n][3];
            for (int i=0; i < n; i++) {
                for(int j = 0; j < 3 ; j++) {
                    arr[i][j] = scanner.nextInt();
                }
            }
        }
        
        System.out.println(solve(arr, 0, -1, new HashMap()));
        
    }
}

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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll, ll> P;


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

	vector<P> pl;

	for (int i = 0; i < n; i++) {
		ll tmpa, tmpb;
		cin >> tmpa >> tmpb;
		P p(tmpa,tmpb);
		pl.push_back(p);
	}
	sort(pl.begin(), pl.end());

	ll sum = 0;
	for (int i = 0; i < pl.size(); i++) {
		sum += pl[i].second;
		if (k<=sum) {
			cout << pl[i].first << "\n";
			return 0;
		}
	}
}


Measured memory_bytes: 2420
def main():
  n, k = map(int, input().split())
  
  rate = 0.0
  
  for i in range(1,n+1):
    count = 0
    score = i
    while score < k:
      count += 1
      score *= 2
      
    rate += 1 / (2 ** count)
    
  
  print(rate/n)
    
main()

Measured memory_bytes: 2940
// stones atcoder
#include<bits/stdc++.h>
using namespace std;
bool true_if_p1_wins(bool true_if_p1_plays, int stones_left,
                     int min, vector<int>&v, vector<vector<int>> &m) {
	/*if (m.find(make_pair(true_if_p1_plays, stones_left)) != m.end()) {
		return m[make_pair(true_if_p1_plays, stones_left)];
	}*/
	if (m[stones_left][true_if_p1_plays] != -1)return m[stones_left][true_if_p1_plays];
	int &res = m[stones_left][true_if_p1_plays];

	if (stones_left < min) {
		return res = !true_if_p1_plays;
	}
	else if (true_if_p1_plays) {
		bool or_of_all{false};
		for (auto x : v) {
			if (x <= stones_left) {
				or_of_all = or_of_all ||
				            true_if_p1_wins(false, stones_left - x, min, v, m);
			}
		}
		return res = or_of_all;
	}
	else {
		bool and_of_all{true};
		for (auto x : v) {
			if (x <= stones_left) {
				and_of_all = and_of_all &&
				             true_if_p1_wins(true, stones_left - x, min, v, m);
			}
		}
		return res = and_of_all;
	}
}
int main() {
	int n, initial_stones;
	cin >> n >> initial_stones;
	vector<int> v(n);
	for (int i{}; i < n; i++) {
		cin >> v[i];
	}
	int min{*min_element(v.begin(), v.end())};
	// unordered_map<pair<bool, int>, bool> m;
	vector<vector<int>> m(initial_stones + 1, vector<int>(2, -1));
	if (true_if_p1_wins(true, initial_stones, min, v, m)) {
		cout << "First" << endl;
	}
	else {
		cout << "Second" << endl;
	}
}

Measured memory_bytes: 17944
def resolve():
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    ans = 0
    diff = []
    for i in range(M):
        P, X = list(map(int, input().split()))
        print(sum(T) - T[P-1] + X)

    return

resolve()

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

int main(){
    int H,W;
    int h,w;
    cin >> H >> W >> h >> w;
    cout << (H-h)*(W-w) <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

ll lds(vector<ll> a){
 ll n=a.size() ;
 deque<ll> d;
 rep(i,n){
    ll p=lower_bound(d.begin(),d.end(),a[i])-d.begin();
    if(p==0) d.push_front(a[i]) ;
    else d[p-1]=a[i] ;
 }
 return d.size() ;
}
 
 int main(){
  ll n;
  cin>>n ;
  vector<ll> A(n) ;rep(i,n) cin>>A[i] ;
  cout<< lds(A) <<endl ;
   return 0;
  }

Measured memory_bytes: 2688
N = int(input())
A = [[0 if x == "." else 1 for x in input()] for i in range(N)]

if sum([sum(x) for x in A]) == 0:
    print(-1)
else:
    sum_list = [0] * N
    for i in range(N):
        s = 0
        for j in range(N):
            s += A[j][i]
        sum_list[i] = s

    count = N + 1
    index = []
    for i in range(N):
        tmp = 0
        flag = False
        for j in range(N):
            if A[i][j] == 0:
                tmp += 1
            if sum_list[i] == 0:
                flag = True

        if flag:
            tmp += 1

        count = min(count, tmp)

        if count == 0:
            break

    for i in range(N):
        for j in range(N):
            if A[j][i] == 0:
                count += 1
                break

    print(count)




Measured memory_bytes: 5236
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
using namespace std;

int main(){
  
  int n,m; cin >> n >> m;
  vector<int> L(m);
  vector<int> R(m);
  
  for (int i=0; i<m; i++) cin >> L[i] >> R[i];
  sort(L.begin(), L.end());
  sort(R.begin(), R.end());
  
  cout << max(R[0]-L[m-1]+1,0);
  
  return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  rep(i, n) p[i]--;
  vector<int> idx(n);
  rep(i, n) idx[p[i]] = i;
  ll ans = 0;
  set<int> s;
  for (int x = n-1; x >= 0; --x){
    int i = idx[x];
  	ll c = 0;
    s.insert(i);
    vector<int> lv(2, -1);
    vector<int> rv(2, n);
    {// calc c
      auto itr = s.find(i);
      rep(j, 2){
        if ( itr == s.begin()) break;
        --itr;
        lv[j] = *itr;
      }
    }
    {
      auto itr = s.find(i);
      rep(j, 2){
        ++itr;
        if (itr == s.end()) break;
        rv[j] = *itr;
      }
    }
    vector<int> ld(2);
    ld[0] = i - lv[0]; ld[1] = lv[0] -lv[1];
    vector<int> rd(2);
    rd[0] = rv[0] - i; rd[1] = rv[1] - rv[0];
    c = ld[0]*rd[1] + ld[1]*rd[0];
    
   	ans += c*(x + 1);
  }
   
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;cin >> k;
    cout << arr[k-1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#define  ll  long long
#define ull unsigned long long
#define  sl(a)  scanf("%lld",&a);
using namespace std;
ll dp[100005],fr[100005];
int main()
{
    ll n,i,j,k,l,m;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>fr[i];
    }
    dp[1]=0;
    dp[2]=abs(fr[1]-fr[2]);
    for(i=3;i<=n;i++)
    {
        l=dp[i-1]+abs(fr[i]-fr[i-1]);
        m=dp[i-2]+abs(fr[i]-fr[i-2]);
        dp[i]=min(l,m);
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n;
    cin>>n;
    ll h[n];
    for(ll i=0;i<n;i++){
        cin>>h[i];
    }ll cost[n];

    cost[0]=0;
    cost[1]=abs(h[1]-h[0]);
    for(ll i=2;i<n;i++){
        ll t1=abs(h[i]-h[i-1])+cost[i-1];
        ll t2=abs(h[i]-h[i-2])+cost[i-2];
        cost[i]=min(t1, t2);
    }

    cout<<cost[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 5172
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int[] h = new int[N];

        for (int i = 0; i < N; i++) {

            h[i] = Integer.parseInt(sc.next());
        }

        sc.close();

        System.out.println(upperIsOK(h, K));

    }

    public static int upperIsOK(int[] array, int K) {

        int count = 0;

        for (int i = 0; i < array.length; i++) {

            if (array[i] >= K) {

                count++;
            }
        }

        return count;
    }

}

Measured memory_bytes: 45980
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << "\n"; }
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using ti3 = tuple<int, int, int>;
using tl3 = tuple<ll, ll, ll>;

int main() {
	int N, P; cin >> N >> P;
	string S; cin >> S; reverse(all(S));
	ll ans = 0;
	if (P != 2 and P != 5) {
		map<int, ll> m;
		// P = 2, 5のときは別
		int d = 1; // 10^i mod P
		int x = (S[0] - '0') % P;
		m[x] = 1;
		rep2(i, 1, N) {
			d = 10 * d % P; 
			x = (x + (S[i] - '0') * d) % P;
			if (m.count(x)) m[x]++;
			else m[x] = 1;
		}		
		for (pii p : m) {
			int r; ll n; tie(r, n) = p;
			db(r); dbl(n);
			if (r == 0) ans += n;
			ans += n * (n - 1) / 2;
		}
	} else rep(i, N) if ((S[i] - '0') % P == 0) ans += N - i;	
	std::cout << ans << endl;
}

Measured memory_bytes: 1028
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll x;
	cin >> x;
	ll ans = (x / 500) * 1000;
	x %= 500;
	ans += (x / 5) * 5;
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
// ABC160 A

#include <iostream>
#include <string>

using namespace std;

int main(){
    string str;
    cin >> str;
    if(str.at(2) == str.at(3) && str.at(4) == str.at(5)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#define ll long long
#define INF 10000000

using namespace std;

//ifstream cin ("input.txt"); ofstream cout ("output.txt");

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    cout << max(0ll, a-b);
}

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

const string dream = "maerd";
const string dreamer = "remaerd";
const string erase = "esare";
const string eraser = "resare";

const array<string, 4> words = {dream, dreamer, erase, eraser};

int main() {
  char c;
  string S;

  while (cin >> c) {
    S.insert(0, 1, c);
  }

  while(1) {
    const string current = S;
    for(const auto w: words) {
      if (S.find(w) == 0) {
        S.erase(0, w.length());
      }
    }
    if (S.empty()) {
      cout << "YES";
      return 0;
    } else if(current == S) {
      cout << "NO";
      return 0;
    }
  }


  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int ans[12];
int n;
void dfs(int pos, int ma) {
	if (pos == n + 1) {
		for (int i = 1; i <= n; ++i)
			printf("%c", ans[i] + 'a');
		printf("\n");
		return;
	}
	int maa;
	for (int i = 0; i <= ma + 1 and i < pos; i++) {
		ans[pos] = i;
		maa = max(i, ma);
		dfs(pos + 1, maa);
	}
}
int main() {
	cin >> n;
	dfs(1, 0);
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    // Your code here!
    vector<string> YN{"NO","YES"};
    vector<string> yn{"No","Yes"};
    int a,b,c;
    cin>>a>>b;
    cout<<(a-b<0?0:a-b)<<endl;
}


Measured memory_bytes: 256
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed() ios::sync_with_stdio(0);cin.tie(0);
#define file() freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(v)   v.begin(),v.end()
#define rall(v)   v.rbegin(),v.rend()
#define pb push_back
#define pf push_front
#define mp make_pair
#define pi acos(-1)
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>mi;
typedef pair<ll,ll>pll;
typedef vector<pll> vll;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] = {-1,+1,0,0,+1,-1,+1,-1};
ll dy[] = {0,0,-1,+1,+1,+1,-1,-1};
const ll mx = 1e5+123;
const ll MOD = 1e9+7;

template <class T> T power(T a,T b){a%=MOD;if(!a) return 0;T p=1;while(b>0){if(b&1){p*=a;p%=MOD;}a*=a;a%=MOD;b=b>>1;}return p;}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class T> T gcd(T a, T b){return (b!=0?gcd<T>(b,a%b):a);}
template <class T> T lcm(T a, T b){return (a/gcd<T>(a,b)*b);}

ll BS(ll l,ll r,ll a[],ll k){ll mid,i=-1;while(l<=r){mid=(l+r)>>1;if(a[mid]==k){return i=mid;/*r=mid-1;*/}if(a[mid]<k) l=mid+1;if(a[mid]>k) r=mid-1;}return i;}

ll a,b,dp[123][mx],w[123],c[123];
ll solve(ll i,ll j)
{
    if(i>a-1)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    ll x=0,y=0;
    if(j+w[i]<=b)
    {
        x = c[i]+solve(i+1,w[i]+j);
    }
    y = solve(i+1,j);
    return dp[i][j] = max(x,y);
}

int main()
{
    speed();
    cin>>a>>b;
    rep(i,a)
    {
        cin>>w[i]>>c[i];
    }
    mem(dp,-1);
    cout<<solve(0,0)<<endl;

}



Measured memory_bytes: 99836
n, m = map(int, input().split())
C = [1]*n
X = [0]*n
X[0] = 1
for i in range(m):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    if X[x] == 1:
        C[x] -= 1
        C[y] += 1
        X[y] = 1
        if C[x] == 0:
            X[x] = 0
    else:
        C[x] -= 1
        C[y] += 1
#print(C)
#print(X)
print(sum(X))


Measured memory_bytes: 4596
x,k,d=map(int,input().split())
if x<=0:
  x=x*(-1)
if d>=x:
  if k%2==0:
    print(x)
    exit()
  else:
    print(d-x)
    exit()
else:
  if x//d>=k and x>d:
    print(x-k*d)
    exit()
  elif x<=d:
    if k%2==0:
      print(x)
      exit()
    else:
      print(d-x)
    exit()
  else:
    if (x//d)%2==k%2:
      print(x%d)
      exit()
    else:
      print(d-x%d)
      exit()


Measured memory_bytes: 9072
#include <stdio.h>
#include <stdbool.h>

int main(void) {
    int N;
    long long K;
    int A[200000];
    long long F[200000];
    int now, next;

    scanf("%d %lld", &N, &K);
    for(int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        A[i]--;
        F[i] = -1;
    }

    now = 0;
    F[0] = 0;
    for(long long i = 0; i < K; i++) {
        next = A[now];
        if(F[next] != -1) {
            i += ((K - i - 1) / (i + 1 - F[next]) ) * (i + 1 - F[next]);
        }
        else {
            F[next] = i + 1;
        }
        now = next;
    }

    printf("%d\n", ++now);

    return 0;
}


Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,K=0; cin >> A >> B;
  for(int i=1; i<1000000000; i++) {
    if(abs(A-i)==abs(B-i)) {
      K = i;
      break;
    }
  }
  if(K==0) cout << "IMPOSSIBLE" << endl;
  else cout << K << endl;
}

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

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int n;
      double t, a;
      n=Integer.parseInt(sc.next());
      t=Integer.parseInt(sc.next());
      a=Integer.parseInt(sc.next());
      double[] h = new double[n];
      for(int i=0; i<n; i++){
        h[i]=t-Integer.parseInt(sc.next())*0.006;
      }

      int ans=0;
      for(int i=1; i<n; i++){
        if(Math.abs(a-h[i])<Math.abs(a-h[ans])){
          ans=i;
        }
      }

      System.out.println(ans+1);
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
}


Measured memory_bytes: 22868
//＃いんｃぅで＜ｓｔぢお。ｈ＞
#include<stdio.h>
#include<iostream>
using namespace std;
int n=0,u=0;
int k[101],v[101][101],d[101];
int lptr=0,fptr=0;//lptr==enqueue,fptr==dequeue...
int t1[10000];
int s1[10000];
int c=0;//current
int nx=sizeof(t1)/sizeof(t1[0]);
void Enqueue(int s,int t){
	t1[lptr]=t;
	s1[lptr]=s;
	lptr=(lptr+1)%nx;
}
void bfs(int l){
	while(fptr!=lptr){
		l=t1[fptr];
		c=s1[fptr];
		fptr=(fptr+1)%nx;
		if(d[l]!=-1){
			continue;
		}
		for(int i=0;i<k[l];i++){
			if(v[l][i]){
				Enqueue(c+1,v[l][i]);
			}
		}
		d[l]=++c;
	}
}
int main(void){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>u;
		cin>>k[u];
		for(int j=0;j<k[u];j++){
			cin>>v[u][j];
		}
	}
	Enqueue(-1,1);
	for(int i=0;i<n+1;i++){
		d[i]=-1;
	}
	bfs(0);
	
	for(int i=1;i<n+1;i++){
		cout<<i<<" "<<d[i]<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int N;
	int quotient;
	int remainder;
	int tempSum = 0;
	string answer = "No";

	cin >> N;

	quotient = N;
		
	// 各桁の和を求める
	while ( quotient > 0 ) {
		remainder = quotient % 10;
		tempSum += remainder;
		quotient /= 10;
	}
		
	if ( N % tempSum == 0 ) {
		answer = "Yes";
	}

	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair <long long,long long> ii;


ll mod = 1e9+7;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin >> n >> k;
    vector <ll> arr(n);
    for (int z=0;z<n;z++){
        cin >> arr[z];
    }
    ordered_multiset <ll> s;
    vector <ll> count(n,0);
    s.insert(arr[n-1]);
    ll sum = 0;
    for (int z=n-2;z>-1;z--){
        sum += s.order_of_key(arr[z]);
        s.insert(arr[z]);
    }
    s.clear();
    ll sum1 = 0;
    s.insert(arr[0]);
    for (int z=1;z<n;z++){
        sum1 += s.order_of_key(arr[z]);
        s.insert(arr[z]);
    }
    if (k % 2 == 0){
        ll i = ((sum)*(((((k)/2)*(k+1))%mod))%mod)%mod;
        ll j = ((sum1)*(((((k)/2)*(k-1))%mod))%mod)%mod;
        cout << (i+j)%mod << endl;
    } else {
        ll i = ((sum)*((((k)*((k+1)/2))%mod))%mod)%mod;
        ll j = ((sum1)*((((k)*((k-1)/2))%mod))%mod)%mod;
        cout << (i+j)%mod << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;
const ll inf = 1LL<<60;

int main() {
    ll N;cin >> N;
    priority_queue<ll> L;
    priority_queue<ll,vector<ll>,greater<ll>>F;
    vector<ll> M(N);
    ll fval=0,lval=0;
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        F.push(a);
        fval+=a;
    }
    for(int i=0;i<N;i++){
        cin >> M[i];
    }
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        L.push(a);
        lval+=a;
    }
    vector<ll> resf(N+1),resl(N+1);
    resf[0]=fval;
    resl[N]=lval;
    for(int i=0;i<N;i++){
            fval+=M[i];
            F.push(M[i]);
            fval-=F.top();
            F.pop();
            resf[i+1]=fval;

            lval+=M[N-1-i];
            L.push(M[N-1-i]);
            lval-=L.top();
            L.pop();
            resl[N-i-1]=lval;
    }
    ll ans=-inf;
    for(int i=0;i<=N;i++){
        ans=max(ans,resf[i]-resl[i]);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4340
#include<bits/stdc++.h>
#define f(i,p,q) for(int i=p;i<q;i++)
using namespace std;
typedef long long ll;
long long int ar[64];
int main()
{//freopen("in.txt","r",stdin);
 //freopen("out.txt","w",stdout);
  long long  int n,k;cin>>n>>k;
  long long  int t; int l=0;
	long long  int m=n;
  long long int kk=k;
   
  while(kk!=0)
    { kk=kk>>1;
      l++;
    }
	vector<long long int>v;
   for(int i=0;i<n;i++)
   {  long long int x;cin>>x;
      v.push_back(x);
     t=x;
  long long int index=0;
   	 while(t!=0)
   	 {   
		if((t&1)==1)
   	      ar[index]++;
   	 	index++;
        t=t>>1;
		}
   }
  long long  int ans=0;
  
  
   for(int i=l-1;i>=0;i--)
   { long long int u=(1ll<<i);
      if(m-ar[i]>ar[i]&&((ans^u)<=k))
          ans=ans^u;
   	  
   	   //cout<<i<<" "<<ar[i]<<"  "<<ans<<"\n";
   }  
  
 
  long long  int res=0;
   for(int i=0;i<m;i++)
     res+=ans^v[i];
      cout<<res;
}

Measured memory_bytes: 1400
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <iostream>

     using namespace std;

    int main()
    {
int N;
    scanf("%d", &N);
std::vector<int> nodes(N);
int val;
for(int i=0; i<N; i++)
{
scanf("%d", &val);
nodes[i] = val;
}

    int sum = abs(nodes[0]) + abs(nodes[N-1]);
     
    std::vector<int> dist_ad;
    dist_ad.resize(N+1);
   std::vector<int> dist_jump;
    dist_jump.resize(N);

    dist_ad[0] = abs(nodes[0]);
    dist_ad[N] = abs(nodes[N-1]);
    dist_jump[0] = abs(nodes[1]);
    dist_jump[N-1] = abs(nodes[N-2]);
    for(int i=1; i<N; i++) {
    dist_ad[i] = abs(nodes[i] - nodes[i-1]);
        sum += dist_ad[i];
    if(i < N-1)
    {
    dist_jump[i] = abs(nodes[i+1] - nodes[i-1]);
    }
    }
     
    for(int i=0; i<N; i++) {
        int tmp_sum = sum - dist_ad[i] - dist_ad[i+1] + dist_jump[i];
        std::cout<<tmp_sum<<std::endl;
    }
     return 0;
    }

Measured memory_bytes: 2432
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	char ch;

	cin >> ch;

	cout << (char)(ch + 1) << endl;






	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		System.out.println(Math.min(n * a, b));

		sc.close();

	}

}


Measured memory_bytes: 35424
//16:53:00

#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace  std;
using ll=long long;
using pii=pair<int,int>;

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	int mx=0;
	int tot=0;
	int t;
	while(n--)
	{
		cin>>t;
		mx=max(mx,t);
		tot+=t;
	}
	cout<<tot-mx/2<<"\n";
	return 0;
}

















Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	char s[4];
	char t[4];
	int n=0;
	scanf("%s%s",s,t);
	for(int i=0; i<3; i++){
		if(s[i]==t[i])
		n++;
	}
	printf("%d",n);	
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
int main(){
    int k,x;
    cin>>k>>x;
    rep(i,max(-1000000,x-k+1),min(1000000,x+k)){
        cout<<i<<" ";
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define ll long long int
    using namespace std;
    int main()
    {
      ll a,b,c;
      cin>>a>>b>>c;
      if(a==b && b==c)
      cout<<"No"<<endl;
      else if(a!=b && b!=c && c!=a)
      cout<<"No"<<endl;
      else
        cout<<"Yes"<<endl;
        return 0;
    }

Measured memory_bytes: 256