akhauriyash/Code-Regression huggingface dataset:
a,b = map(int,input().split())
if a==0:
    print(b)
    exit()
ab = bin(a-1)[2:]
bb = bin(b)[2:]
# print(ab)
# print(bb)
sa = []
sb = []
if int(bb[-1]):
    sb = [1]
else:
    for i in bb:
        sb += [int(i)]
if a>0:
    if int(ab[-1]):
        sa = [1]
    else:
        for i in ab:
            # print(2)
            sa += [int(i)]
sa[-1] = (a//2)%2
sb[-1] = ((b+1)//2)%2
# print(sa)
# print(sb)
# print(ab)
ta = "".join([str(i) for i in sa])
tb = "".join([str(i) for i in sb])
ta = int(ta,2)
tb = int(tb,2)
# print(ta)
# print(tb)
ans = ta^tb
# print(ta)
# print(tb)
print(ans)

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

using namespace std;

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

    int d = a / b;
    int r = a % b;
    double f = (double)a / b;

    cout << d << " " << r << " " << fixed << setprecision(5) << f << endl;

    return 0;
}


Measured memory_bytes: 3232
from itertools import product


def violates(w_flags):
    prev_flag = w_flags[0]
    for flag in w_flags[1:]:
        if flag and prev_flag:
            return True
        prev_flag = flag
    return False


H, W, K = [int(elem) for elem in input().split()]
MOD = 10**9 + 7

if W == 1:
    print(1)
    exit(0)

dp = [[0] * W for _ in range(H + 1)]
dp[0][0] = 1

for h in range(1, H + 1):
    for w_flags in product((False, True), repeat=W-1):
        if violates(w_flags):
            continue
        for w in range(W):
            if w == 0:
                if w_flags[0]:
                    dp[h][0] += dp[h - 1][1]
                else:
                    dp[h][0] += dp[h - 1][0]
            elif w == W - 1:
                if w_flags[W - 2]:
                    dp[h][W - 1] += dp[h - 1][W - 2]
                else:
                    dp[h][W - 1] += dp[h - 1][W - 1]
            else:
                if w_flags[w - 1] == True:
                    dp[h][w] += dp[h - 1][w - 1]
                elif w_flags[w] == True:
                    dp[h][w] += dp[h - 1][w + 1]
                else:
                    dp[h][w] += dp[h - 1][w]
            dp[h][w] %= MOD

print(dp[-1][K - 1])


Measured memory_bytes: 46448
k = int(input())
li = [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]
print(li[k-1])

Measured memory_bytes: 3060
#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];
    }
    
    if (N % 2 == 0) {
        sort(a.begin(), a.end());
        bool flg = true;
        for (int i = 0; i < N/2; i++) {
            if(a[2 * i] != a[2 * i + 1]) {
                flg = false;
                break;
            }
        }
        cout << (flg ? "Yes" : "No") << endl;
    } else {
        int exsum = 0;
        for (int i = 0; i < N; i ++) {
            exsum ^= a[i];
        }
        cout << (exsum == 0 ? "Yes" : "No") << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

char s[110];

int main() {
    scanf("%s", s);
    int n = strlen(s);
    int ans = 0;
    for (int i = 0; i < n / 2; i++) {
        ans += (s[i] != s[n - i - 1]);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

 ll n,sum=0;
 cin>>n;
 for(int i=1;i<=n;i++)
 {
     cin>>A[i];
     myMap[A[i]]++;
     sum+=A[i];
 }
 ll q;
 cin>>q;
 while(q--)
 {
     ll b,c;
     cin>>b>>c;
     sum-=(b*myMap[b]);
     sum+=(c*myMap[b]);
     myMap[c]+=myMap[b];
     myMap[b]=0;
     cout<<sum<<endl;
 }
return 0;
}



Measured memory_bytes: 10380
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(int[]);

    auto p = new int[](n + 1);

    foreach (i ; 1 .. n + 1) {
        p[i] = gcd(p[i - 1], a[i - 1]);
    }

    auto s = new int[](n + 1);

    foreach_reverse (i ; 0 .. n) {
        s[i] = gcd(s[i + 1], a[i]);
    }

    auto ans = 0;

    foreach (i ; 0 .. n) {
        ans = max(ans, gcd(p[i], s[i + 1]));
    }

    writeln(ans);
}

























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 4348
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int k;
	cin>>k;
	set<ll> num;
	auto dfs=[&](auto &dfs,string now,int pre)->void{
		if(now.size()==12) return ;
		if(now.size()) num.insert(stoll(now));
		int a=pre+1;
		if(0<=a && a<=9){
			char c=a+'0';
			string t=c+now;
			dfs(dfs,t,a);
		}
		a=pre-1;
		if(0<=a && a<=9){
			char c=a+'0';
			string t=c+now;
			dfs(dfs,t,a);
		}
		a=pre;
		if(0<=a && a<=9){
			char c=a+'0';
			string t=c+now;
			dfs(dfs,t,a);
		}
	};
	rep(i,10) dfs(dfs,"",i);
	auto itr=num.begin();
	rep(i,k){
		itr++;
	}
	cout<<*itr<<endl;
}

Measured memory_bytes: 27528
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=200000 +117;
const int MM=200000 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
char s[NN]={};
bool a[NN]={};
LL f[NN]={};
const int mod=1e9+7;
void simple(int n){
	f[0]=1;
	f[1]=1;
	for(int i=2;i<=n;++i){
		f[i]=(f[i-1]+f[i-2])%mod;
	}
	LL ans=1+f[n-2];
	for(int i=2;i<=n;++i){
		ans+=f[n-i];
		ans%=mod;
	}
	printf("%lld\n",ans);
}
void solve(int n,int lim){
	if(n%2!=0){
		printf("0\n");
		return ;
	}
	n/=2;
	lim=(lim+1)/2;
	f[0]=1;
	LL ans=0;
	for(int i=1;i<=n;++i){
		f[i]=2*f[i-1];
		if(i-lim-1>=0)f[i]-=f[i-lim-1];
		f[i]%=mod;
	}
	for(int i=1;i<=min(n,lim);++i){
		ans+=2*i*(f[n-i]-f[n-i-1]);
		ans%=mod;
	}
	ans=(ans+mod)%mod;
	printf("%lld\n",ans);
}
int main(){
	//open();
	n=read();
	m=read();
	scanf("%s",s+1);
	bool same=1;
	for(int i=1;i<=m;++i){
		a[i]=(s[i]==s[1]);
		if(!a[i])same=0;
	}
	int lim=0;
	if(same){
		simple(n);
	}
	else{
		int pos=1;
		int cnt=0;
		bool first=0;
		int lim=0;
		for(pos=1;pos<=m;++pos){
			if(a[pos])++cnt;
			else{
				if(!first){
					first=1;
					lim=cnt+1-(cnt&1);
				}
				else{
					if(cnt&1)lim=min(lim,cnt); 
				}
				cnt=0;
			}
		}
		solve(n,lim);
	}
	close();
	return 0;
}

Measured memory_bytes: 2176
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))
count = [0] * (m-1)
ans = 0

if n > m:
    ans += 0
else:
    for i in range(1, m):
        count[i-1] = x[i] - x[i-1]
    count = sorted(count, reverse=True)
    ans = sum(count[n-1:])

print(ans)

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

int main(){
	int n;
	cin >> n;
	int f = 0;
	while(n != 0){
		if(n%10 == 9) f = 1;
		n /= 10;
	}
	if(f == 1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define sz(x)       (int)x.size()
#define f			first
#define debug		cout<<"##########3"<<endl
#define mod			1000000007
#define ll			long long int
#define lMax		LLONG_MAX
// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == precedence gretaer then &
// Experiment of Code EoC !!
ll n,m;
ll w[200], v[200];
ll dp[200][100005];//say
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);

    ll i,j,k,c=0,ans=0,t,z,x=0,y;
	cin>>n>>m;//N W
	rep(i,0,n){
		cin>>w[i]>>v[i];//wt and val
		x +=v[i];
	}

	for(i=0;i<=105;i++)
		for(j=0;j<100002;j++){
			dp[i][j] = INT_MAX;
		}
	dp[0][0] = 0;
	
	for(i=1;i<=n;i++){
		for(j=0;j<=x;j++){
			if(j>=v[i-1])
				dp[i][j] = dp[i-1][j-v[i-1]]+w[i-1];
			dp[i][j] = min(dp[i][j], dp[i-1][j]);
			if(dp[i][j]<=m){
				ans = max(ans,j);
			}
		}
	}
	//wt the eck is ans?
	cout<<ans;

 	return 0;
}

Measured memory_bytes: 84352
n = int(input())
char = list(input())
n_half = round(n/2)

if n%2!=0 :
    print("No")
else :
    word1 = ""
    word2 = ""
    for i in range(n_half) :
        word1 += char[i]
        word2 += char[n_half + i]
    
    if word1==word2 :
        print("Yes")
    else :
        print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll n;
    cin >> n;
    vector<pair<pair<string, ll>, ll>> v(n);
    rep(i, n) {
        string s;
        ll p;
        cin >> s >> p;
        v[i].first.first = s;
        v[i].first.second = -p;
        v[i].second = i + 1;
    }
    sort(all(v));
    rep(i, n) { cout << v[i].second << endl; }
}


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

int main()
{
    int N, M;
    cin >> N >> M;

    int ball[100005];
    for (int n = 1; n <= N; n++)
    {
        ball[n] = 1;
    }
    bool red_ball[100005] = {};
    red_ball[1] = true;

    for (int m = 1; m <= M; m++)
    {
        int x, y;
        cin >> x >> y;

        if (ball[x] != 1 && red_ball[x] == true)
        {
            red_ball[y] = true;
        }
        else if (ball[x] == 1 && red_ball[x] == true)
        {
            red_ball[x] = false;
            red_ball[y] = true;
        }

        ball[x]--; ball[y]++;

        /*
        cout << "ball == ";
        for (int n = 1; n <= N; n++)
        {
            cout << ball[n] << " ";
        }
        cout << endl;
        cout << "red_ball == ";
        for (int n = 1; n <= N; n++)
        {
            cout << red_ball[n] << " ";
        }
        cout << endl;
        cout << endl;
        */
    }

    int ans = 0;

    for (int n = 1; n <= N; n++)
    {
        if (red_ball[n] == true) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <bits/stdc++.h>
#include <algorithm>
#include <set>

using namespace std;


int main()
{
    int n;
    cin>>n;
    long int arr[n];
    for (int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int maxi(0);
    int ctr(0);
    for (int i=0;i<n-1;i++)
    {
        if (arr[i]>=arr[i+1])
        {
            ctr++;
            if (ctr>maxi)
                maxi=ctr;
        }
        else
        {

            ctr=0;
        }
    }
    cout<<maxi<<endl;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()

typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;

const int INF = 1000000000;
const int B = 101000;
int d[310000];
int n,x;
int w[16],c[16];
priority_queue<pii,vector<pii>,greater<pii> > que;

int main() {
	cin>>n>>x;
	rep(i,n)cin>>w[i]>>c[i];
	for(int i=0;i<310000;++i)d[i]=INF;
	d[B]=0;
	que.push(make_pair(0,B));
	while(!que.empty()){
		pii p=que.top();que.pop();
		int v=p.second;
		if(p.first>d[v])continue;
		rep(i,n){
			int nd=v+w[i];
			if(nd<310000&&d[nd]>d[v]+c[i]){
				d[nd]=d[v]+c[i];
				que.push(make_pair(d[nd],nd));
			}
			nd=v-w[i];
			if(nd>=0&&d[nd]>d[v]+c[i]){
				d[nd]=d[v]+c[i];
				que.push(make_pair(d[nd],nd));
			}
		}
	}
	if(d[x+B]==INF)d[x+B]=-1;
	cout<<d[x+B]<<endl;
}


Measured memory_bytes: 7124
import java.util.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int cnt;
		Boolean flag = false;
		char[][] str = new char[h][w];
		int [][] wea = new int[h][w];
		for(int i = 0; i < h; i++){
			str[i] = sc.next().toCharArray();
		}
		for(int i = 0; i < h; i ++){
			cnt = -1;
			flag = false;
			for(int k = 0; k < w; k++){
				if(str[i][k] == 'c'){
					cnt = 0;
					flag = true;
				}
				else if(str[i][k] == '.' && flag == true) cnt++;
				else if(str[i][k] == '.')cnt = -1;
				wea[i][k] = cnt;
			}
		}
		for(int i = 0; i < h; i++){
			for(int k = 0; k < w; k++){
				System.out.print(wea[i][k]);
				if(k + 1 != w) System.out.print(" "); 
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 36588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n , x) for (int i = (int)(x); i < (int)(n); ++i)
#define repB(i, n) for (int i = n; i >= 1; --i)
#define repBX(i, n , x) for (int i = (int)(n); i >= int(X); --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int in = 0;
    rep(i,5){
        int x;
        cin >> x;
        in += x;
    }
    cout << 15-in << endl;
    
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N) {
  for (int i = N;; i++)
    if (i % 111 == 0) {
      cout << i << endl;
      return;
    }
}

int main() {
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
from heapq import heappop, heappush

q = int(input())
ans = 0

mid_1 = 0
mid_2 = 0
mid = 0
left_q = []
right_q = []
left_sum = 0
right_sum = 0
const_b = 0
ansl = []

first_flag = True
double_mid = False
for _ in range(q):
    row = list(input().split())
    if row[0] == '2':
        half_n = len(left_q)
        if double_mid:
            q_left_sum = mid_1*half_n - left_sum
            q_right_sum = right_sum - mid_1*half_n
            ans_v = q_left_sum + q_right_sum + (mid_2-mid_1) + const_b
            ans_x = mid_1
            ansl.append((ans_x, ans_v))
        else:
            q_left_sum = mid*half_n - left_sum
            q_right_sum = right_sum - mid*half_n
            ans_v = q_left_sum + q_right_sum + const_b
            ans_x = mid
            ansl.append((ans_x, ans_v))
    
    else:
        a,b = int(row[1]), int(row[2])
        const_b += b

        if first_flag:
            mid = a
            first_flag = False

        elif double_mid:
            double_mid = False
            if a <= mid_1:
                heappush(left_q, a*(-1))
                left_sum += a
                heappush(right_q, mid_2)
                right_sum += mid_2
                mid = mid_1
            elif a >= mid_2:
                heappush(left_q, mid_1*(-1))
                left_sum += mid_1
                heappush(right_q, a)
                right_sum += a
                mid = mid_2
            else:
                heappush(left_q, mid_1*(-1))
                left_sum += mid_1
                heappush(right_q, mid_2)
                right_sum += mid_2
                mid = a
            # print(left_q, mid, right_q)
            # print(left_sum, right_sum)


        else:
            double_mid = True
            if a <= mid:
                heappush(left_q, a*(-1))
                left_sum += a
                mid_1 = heappop(left_q)*(-1)
                left_sum -= mid_1
                mid_2 = mid
            else:
                heappush(right_q, a)
                right_sum += a
                mid_1 = mid
                mid_2 = heappop(right_q)
                right_sum -= mid_2
            # print(left_q, mid_1, mid_2, right_q)
            # print(left_sum, right_sum)



for ax,av in ansl:
    print(ax,av)

Measured memory_bytes: 92536
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
#include <queue>
#include <vector>
#include <set>
#include <stdio.h>
#include <cstdio>
#include <cmath>
#include <complex> 
using namespace std;
typedef complex<double> xy_t;
xy_t P[30];
int N;
double x,y;
int main() {
cin >> N;
double s =0.0;
for(int i = 0;i < N;i++) {
	cin >> x >> y;
	P[i] = xy_t(x,y);
}
for ( int i = 0; i+2 < N;i++ ){
	xy_t a = P[i+1] - P[0], b = P[i+2]-P[0];
	s += - (a.real()*b.imag()-a.imag()*b.real())/2;
}
printf("%.1f\n", abs(s));
}

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

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

using ll = long long;
using grid = vector<vector<int>>;

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

ll pow(ll a, ll n, ll m) {
  	if(n<0) return 0;
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a % m) {
		if (n % 2LL == 1LL) {
			ret = ret * a % m;
		}
	}
	return ret;
}

ll P(ll a, ll b){
    return (a*pow(3LL,b,mod)+b*pow(3LL,b-1,mod))%mod;
}

int main() {
    string S;
    cin >>S;
    ll N = S.size();
    vector<ll> A(N+1,0LL),B(N+1,0LL),C(N+1,0LL),D(N+1,0LL);
    ll a=0,b=0,c=0,d=0;
    rep(i,N){
        if(S[i]=='A') A[i+1] = 1LL;
        if(S[i]=='B') B[i+1] = 1LL;
        if(S[i]=='C') C[i+1] = 1LL;
        if(S[i]=='?') D[i+1] = 1LL; 
    }
    rep(i,N){
        A[i+1] += A[i];
        B[i+1] += B[i];
        C[i+1] += C[i];
        D[i+1] += D[i];
    }
    ll ans = 0LL;
    rep(i,N-1){
        if(S[i]=='B'||S[i]=='?'){
            ans += (P(A[i],D[i]) * P(C[N]-C[i+1],D[N]-D[i+1]))%mod;
            ans %=mod;
        }
    }
    if(ans<0) ans += mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 6700
#include <iostream>
#include <complex>

int main() {
    std::string num;
    std::cin >> num;
    int ans = 10000;
    if (num.find("753") != std::string::npos) {
        std::cout << 0 << std::endl;
        return 0;                                         
    }   
    for (unsigned int i = 0; i < num.size() - 2; i++) {
        std::string tmp_num;
        tmp_num = num.substr(i, 3);
        int tmp = stoi(tmp_num);
        if (std::abs(tmp - 753) <= ans) {
            ans = std::abs(tmp - 753); 
        }       
        // std::cout << tmp_num << std::endl;
    }       
    std::cout << ans << std::endl;
}


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

int Sn(int n){
    int S = 0;
    for(int i = 1; i <= n; i++){
        S += i;
    }
    return S;
}

int main() {
    int a, b;
    cin >> a >> b;
    int height = Sn(b - a);
    cout << height - b;
}




Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	static void solve(){//Here is the main function
		int D = nextInt();
		ArrayList<Integer> clist = nextIntArray();
		String[] output = new String[D];
		for(int i = 1; i <= D; i++){
			output[i - 1] = String.valueOf((i % 26) + 1);
		}
		myout(myconv(output, 9));
	}
	//Method addition frame start



	//Method addition frame end

	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
}


Measured memory_bytes: 25980
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<stdio.h>
using namespace std;
int main(){
int A, B, C, D ,E ,F, N,M;
long long V[10000000] = {};
long long G[10000000] = {};
string S,Sa,Sb,Sc;
int ans = 0;
A = 0, B = 0;
cin >> A >> B;
for(int i = A;i <= B;i++){
string str = to_string(i);
  if(str[0] == str[4]){
	if(str[1] == str[3])ans++;
}
	
}
cout << ans << endl;
return 0; 
}


Measured memory_bytes: 256
n, w = map(int, input().split())
wvs = [[0, 0] for _ in range(n)]  # 0がw 1がv
for i in range(n):
    wi, vi = map(int, input().split())
    wvs[i][0] = wi
    wvs[i][1] = vi
dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)]
for i in range(1, n + 1):
    for wi in range(1, w + 1):
        if wi - wvs[i - 1][0] >= 0:
            dp[i][wi] = max(dp[i - 1][wi],
                            dp[i - 1][wi - wvs[i - 1][0]] + wvs[i - 1][1])
        else:
            dp[i][wi] = dp[i - 1][wi]
print(dp[i][wi])

Measured memory_bytes: 173576
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	string s;
	getline(cin, s);
	ll n = s.size(),t = 0;
	ll ts = 0;
	ll ans (0);
	bool f = 0;
	const ll zer = 0;
	for ( int i = 0; i<s.size() ; i++ ){
		//cout << s[i] << " " << ts << endl;
		if ( s[i] == 'T' ) {
			if ( ts == 0 )
				continue;
			ts = max(ts - 1,zer);
			ans++;
			f = 1;
			continue;
		}
		else {
			ts++;
		}
			
		
	}
	cout << n - ans * 2;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
  char s[4], t[4];
  scanf("%s", s);
  scanf("%s", t);
  int count = 0;
  for(int i=0; i<3; i++)
    if(s[i] == t[i])
      count++;

  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

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

        double angleMinute = ((double)m) * 6;
        double angleHours = (((double)h) * 60 + m) / 2;
        double diff = Math.abs(angleHours - angleMinute);
        diff = diff > 180 ? 360 - diff : diff;

        double result = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(diff * (Math.PI / 180)));

        System.out.println(String.format("%.16f", result));
    }

}

Measured memory_bytes: 35828
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N, K, x, sum = 0;
  cin >> N >> K;
  for (int i = 0; i < N; i++)
  {
    cin >> x;
    if(x<K-x)
      sum+=2*x;
    else
      sum+=2*(K-x);
  }
  cout << sum << endl;
}

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

template<class T>
using least_queue = priority_queue<T, vector<T>, greater<T>>;

ULL gcd(ULL a, ULL b) { return b ? gcd(b, a % b) : a; }

UL N, R;
double D[100][100];
double P[100][2];
UL UF[100];

int main() {
	scanf("%u%u", &N, &R);
	rep(i, N) {
		int x, y; scanf("%d%d", &x, &y);
		P[i][0] = x; P[i][1] = y;
	}
	rep(s, N) rep(t, N) {
		double dx = P[s][0] - P[t][0];
		double dy = P[s][1] - P[t][1];
		D[s][t] = sqrt(dx * dx + dy * dy);
	}
	rep(i, N) UF[i] = i;
	double ans = 0.0;
	{
		double V[2] = { 0.0, 1.0 };
		UL nx = 0;
		vector<UL> O;
		for (UL i = 1; i < N; i++) if (P[nx][0] > P[i][0]) nx = i;
		O.push_back(nx);
		do {
			double M = -2.0;
			UL p = O.back();
			nx = 0;
			rep(t, N) {
				if (t == p) continue;
				double W[2] = { (P[t][0] - P[p][0]) / D[p][t], (P[t][1] - P[p][1]) / D[p][t] };
				if (V[0] * W[0] + V[1] * W[1] > M) {
					M = V[0] * W[0] + V[1] * W[1];
					nx = t;
				}
			}
			double NV[2] = { (P[nx][0] - P[p][0]) / D[p][nx], (P[nx][1] - P[p][1]) / D[p][nx] };
			V[0] = NV[0]; V[1] = NV[1];
			O.push_back(nx);
		} while (O.front() != O.back());
		for (UL o : O) UF[o] = O.front();
		rep(i, O.size() - 1) ans += D[O[i]][O[i + 1]];
	}

	least_queue<pair<double, pair<UL, UL>>> Q;
	rep(i, R) {
		UL u, v; scanf("%u%u", &u, &v); u--; v--;
		Q.push({ D[u][v], {u,v} });
	}
	while (Q.size()) {
		UL u = Q.top().second.first;
		UL v = Q.top().second.second;
		Q.pop();
		if (UF[u] == UF[v]) continue;
		ans += D[u][v];
		UL ufv = UF[v];
		rep(i, N) if (UF[i] == ufv) UF[i] = UF[u];
	}
	cout << setprecision(10) << fixed << ans << endl;
	return 0;
}



Measured memory_bytes: 3416
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main(void) {
    string N;
    cin >> N;

    uint k = 0;

    for(u64 i=0; i<N.size(); i++) {
        uint c = N[i] - '0';
        k = (k * 10 + c) % 9;
    }

    if(k % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3732
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int L[110];
int main()
{
	int N, X;
	cin >> N >> X;
	for (int i = 0; i < N; i++) cin >> L[i];
	int ans = 1;
	int D = 0;
	for (int i = 0; i < N; i++) {
		D  += L[i];
		if (D <= X) ans++;
		else break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int Mod = 998244353;
int add(int a, int b){ return a + b >= Mod ? a + b - Mod : a + b; }
int mul(int a, int b){ return 1ll * a * b % Mod; }
int dec(int a, int b){ return a - b < 0 ? a - b + Mod : a - b; }
void Add(int &a, int b){ a = add(a,b); }
void Mul(int &a, int b){ a = mul(a,b); }
void Dec(int &a, int b){ a = dec(a,b); }
int ksm(int a, int b){ int as=1; for(;b;b>>=1,Mul(a,a)) if(b&1) Mul(as,a); return as; }
map<string, int> f[2];
string S;
int dp(int typ, string S){
	if(f[typ].count(S)) return f[typ][S];
	if(typ){
		int as = 0;
		for(int i=0,len=S.length(); i<len; i++)
		Add(as, mul(dp(1,S.substr(0,i)),dp(0,S.substr(i,len))));
		return f[typ][S] = as;		
	} else{
		int as = 0;
		for(int i=1,len=S.length(); i<len; i++)
		if(len % i == 0){
			string T="";
			for(int j=0; j<i; j++) T+='1';
			for(int j=0; j<i; j++) 
			for(int k=0; k<len; k+=i) 
			if(S[k+j] == '0') T[j]='0';
			Add(as,dp(1,T));
		} return f[typ][S] = as;
	}
}
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	f[0][""] = f[1][""] = 1;
	f[0]["0"] = f[1]["0"] = 1;
	f[0]["1"] = f[1]["1"] = 2;
	cin >> S; cout << dp(1,S); return 0;
}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

const int MAX = 1e5 + 5;
const ll INF = (ll) 0x3F3F3F3F3F3F3F3F;
ll a[MAX], b[MAX], c[MAX], lft[MAX], rgt[MAX];
int ord[MAX];
int x, y, z;

int main() {
	scanf("%d %d %d", &x, &y, &z);
	int n = x + y + z;
	ll ans = 0;
	fori(i, 1, x + y + z + 1) {
		scanf("%lld %lld %lld", a + i, b + i, c + i);
		ord[i] = i;
		ans += c[i];
	}

	sort(ord + 1, ord + n + 1, [] (int lhs, int rhs) {
		return a[lhs] - b[lhs] < a[rhs] - b[rhs];
	});
	
	memset(lft, 0x8F, sizeof lft);
	memset(rgt, 0x8F, sizeof rgt);
	ll sum = 0;
	priority_queue<ll, vector<ll>, greater<ll> > pq;
	fori(i, 1, n + 1) {
		int id = ord[i];
		pq.push(b[id] - c[id]);
		sum += b[id] - c[id];
		if((int) pq.size() == y + 1) {
			sum -= pq.top();
			pq.pop();
		}
		lft[i] = (int) pq.size() == y ? sum : -INF;
	}
	while(!pq.empty()) {
		pq.pop();
	}
	sum = 0;
	ford(i, n, 1) {
		int id = ord[i];
		pq.push(a[id] - c[id]);
		sum += a[id] - c[id];
		if((int) pq.size() == x + 1) {
			sum -= pq.top();
			pq.pop();
		}
		rgt[i] = (int) pq.size() == x ? sum : -INF;
	}

	ll tmp = -INF;
	fori(i, 1, n + 1) {
		tmp = max(tmp, lft[i] + rgt[i + 1]);
	}

	printf("%lld\n", ans + tmp);

	return 0;
}



Measured memory_bytes: 5752
import itertools
n = int(input())
a = [0]
b = [0]
for i in range(1, 101):
    if i % 4 == 0:
        a.append(i)
    if i % 7 == 0:
        b.append(i)
arr = list(itertools.product(a, b))
ans = [sum(i) for i in arr]
if n in ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pi pair<ll,ll>
using namespace std;
int main(){
	//	freopen("in.txt","r",stdin);
	char c;
	string s = "aiueo";
	cin >> c;
  if((int)s.find(c)>=0) cout << "vowel" << endl;
  else cout << "consonant" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    for i in range(n):
        a[i] -= i + 1
    a.sort()
    t = 0
    for v in a:
        t += abs(a[n // 2] - v)
    print(t)


if __name__ == '__main__':
    solve()


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

#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

int Q[N], M[N][N], color[N], d[N], f = 1, c = 1;

void Enqueue(int n) {
  Q[f] = n;
  f++;
  if ( f == N ) f = 1;
}

int Dequeue() {
  int x = c;
  c++;
  if ( c == N ) c = 1;
  return Q[x];
}

void BFS ( int s ) {
  int u;
  for ( int i = 1; i <= N; i++ ) {
    color[i] = WHITE;
    d[i] = -1;
  }
  color[s] = GRAY;
  d[s] = 0;
  Enqueue(s);
  while(f!=c ) {
    u = Dequeue();
    for ( int i = 1; i <= N; i++ ) {
      if ( color[i] == WHITE && M[u][i] == 1 ) {
	color[i] = GRAY;
	d[i] = d[u] + 1;
	Enqueue(i);
      }
    }
    color[u] = BLACK;
  }
}

int main() {
  int n,u,k,v;
  for ( int i = 1; i < N; i++ ) {
    for ( int j = 1; j < N; j++ ) {
      M[i][j] = 0;
    }
  }
  cin >> n;
  for ( int i = 1; i <= n; i++ ) {
    cin >> u >> k;
    for ( int j = 0; j < k; j++ ) {
      cin >> v;
      M[u][v] = 1;
    }
  }
  BFS(1);
  for ( int i = 1; i <= n; i++ ) {
    cout << i << " " << d[i] << endl;
  }
  return 0;
}

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


int main(){
    string S, T;   cin >> S >> T;
    int A, B;  cin >> A >> B;
    string U;  cin >> U;
    if(U == S) A--;
    if(U == T) B--;
    cout << A << " " << B << endl;

}

Measured memory_bytes: 256
import math

class Vector:
    def __init__(self,x,y):
        self.x = x
        self.y = y
        
    def __add__(self,other):
        return Vector(self.x+other.x,self.y+other.y)
    
    def __sub__(self,other):
        return Vector(self.x-other.x,self.y-other.y)
    
    def __mul__(self,scalar):
        return Vector(self.x*scalar,self.y*scalar)
    def __rmul__(self, scalar):
        return Vector(self.x*scalar,self.y*scalar)
    
   
    def __repr__(self):
        return str([self.x,self.y])
        
    def norm_2(self):
        return dot(self,self)
    
    def norm(self):
        return math.sqrt(self.norm_2())
    
def v_sum(v1,v2):
    return Vector(v1.x+v2.x,v1.y+v2.y) 
def scalar_multi(k,v):
    return Vector(k*v.x,k*v.y)
def v_diff(v1,v2):
    return v_sum(v1,scalar_multi(-1,v2))
    
def dot(vector1,vector2):
    return vector1.x*vector2.x+vector1.y*vector2.y

def cross(vector1,vector2):
    return vector1.x*vector2.y-vector1.y*vector2.x


import bisect

class EndPoint(Vector):
    def __init__(self,x,y,state):
        super().__init__(x,y)
        self.state = state
        '''
        state 0 bottom
        state 1 top
        state 2 left
        state 3 right
        '''
        return
    
class Segment:
    def __init__(self,p1,p2):
        if p1.x<p2.x:
            self.p1 = p1
            self.p2 = p2
        else:
            self.p1 = p2
            self.p2 = p1
        return
    
    
def sorting(p):
    if isinstance(p,Segment):
        return p.p1.y+0.1
    else:
        if p.state == 0:
            return p.y
        elif p.state == 1:
            return p.y+0.2
    
    
    

n = int(input())
points = []
for i in range(n):
    x1,y1,x2,y2 = map(int,input().split())
    if x1 == x2:
        if y1<y2:
            points.append(EndPoint(x1,y1,0))
            points.append(EndPoint(x2,y2,1))
        else:
            points.append(EndPoint(x1,y1,1))
            points.append(EndPoint(x2,y2,0))
    else:
        if x1<x2:
            points.append(Segment(EndPoint(x1,y1,2),EndPoint(x2,y2,3)))
        else:
            points.append(Segment(EndPoint(x1,y1,3),EndPoint(x2,y2,2)))
        
points.sort(key = lambda x:sorting(x))

T = []
count = 0
for i in range(len(points)):
    if isinstance(points[i],Segment):
        left = bisect.bisect_left(T,points[i].p1.x)
        right = bisect.bisect_right(T,points[i].p2.x)
        count += right-left
    else:
        if points[i].state == 0:
            bisect.insort(T,points[i].x)
        elif points[i].state == 1:
            index=bisect.bisect_left(T,points[i].x)
            T.pop(index)

print(count)


Measured memory_bytes: 65724
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <cmath>
using namespace std;

#define INF 1e18
#define int long long
#define MAX 2000000

int h, a[MAX + 1];

void maxHeapify(int i) {
    int l = 2 * i;
    int r = 2 * i + 1;
    int largest = i;

    if(l <= h && a[largest] < a[l]) largest = l;
    if(r <= h && a[largest] < a[r]) largest = r;

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

signed main() {
    cin >> h;
    for(int i = 1; i <= h; i++) {
        cin >> a[i];
    }

    for(int i = h / 2; i >= 1; i--) {
        maxHeapify(i);
    }

    for(int i = 1; i <= h; i++) {
        cout << " " << a[i];
    }
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 6948
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)


int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i, n)cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    int cnt = 2;
    ll ans = a[0];
    int j = 0;
    while (cnt < n) {
        j++;
        rep(i, 2) {
            cnt++;
            if (cnt > n)break;
            ans += a[j];
       }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[100], res = 0;
int main(void){
    // Your code here!
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    sort(a, a + n, greater<int>());
    
    for (int i = 0; i < n; i++) res += a[i] * (i % 2 == 0 ? 1 : -1);
    cout << res << endl;
}


Measured memory_bytes: 256
n,d = list(map(int,input().split()))

a = list(map(str,input().split()))
ans = 0
b = 0
for i in range(n,100001):
    for j in str(i):
        if not j in a:
            b += 1
    if b == len(str(i)):
        ans = i
        break
    else:
        b = 0
print(ans)

Measured memory_bytes: 3060
N = int(input())
T,A = map(int, input().split())
H = list(map(int, input().split()))

risuto = []
for i in range(N):
    kion = T - H[i] * 0.006
    cnt = abs(A - kion)
    risuto.append(cnt)

print(risuto.index(min(risuto)) + 1)
    

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

string s;

bool ck(string st,ll id){
	if(id-1<=0 || id+1>=st.size()-1)return false;
	if(st[id-1]==st[id+1]){
		return false;
	}else{
		return true;
	}
}


ll test(string &s,ll typ){
	string pre = s;
	ll rev;
	if(typ==1)rev = 2;
	else rev = 1;
	ll ans = rev;
	rep(i,s.size()){
		if(ck(s,i)){
			s.erase(i,1);
			ll tmp = test(s,rev);
			s = pre;
			if(tmp==typ){
				ans = typ;
				break;
			}
		}
	}
	return ans;
}


int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>s;
	ll ans = 0;
	if(s[0]==s[s.size()-1]){
		if(s.size()%2==1)ans = 2;
		else ans = 1;
	}else{
		if(s.size()%2==1)ans = 1;
		else ans = 2;
	}
	if(ans == 1){
		print("First");
	}else{
		print("Second");
	}
	//print(test(s,1));
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N;
	cin >> N;

	string S;
	cin >> S;

	int wtob_cost = 0;
	int btow_cost = 0;

	for (int i = 0; i < N; i++)
	{
		if (S[i] == '.') wtob_cost++;
	}

	int result = wtob_cost;
	for (int i = 0; i < N; i++)
	{
		if (S[i] == '.') wtob_cost--;
		else if (S[i] == '#') btow_cost++;

		result = min(result, wtob_cost + btow_cost);
	}

	cout << result;

	return 0;
}

Measured memory_bytes: 720