akhauriyash/Code-Regression huggingface dataset:
from itertools import chain
import sys

A, B, K = map(int, input().split())
diff = B - A

if diff == 0:
    print(A)
    sys.exit()

if K > diff:
    K = diff

ans = [x for x in chain(range(A, A + K), range(B - K + 1, B + 1))]
ans = sorted(list(set(ans)))

print('\n'.join(map(str, ans)))

Measured memory_bytes: 3064
N = int(input())
L = list(map(int,input().split()))

L.sort()
ans = 0

for i in range(N-2):
    for j in range(i+1,N-1):
        if L[i]==L[j]:
            continue
        for k in range(j+1,N):
            if L[j]==L[k]:
                continue
            elif L[i]+L[j]<=L[k]:
                break
            else:
                ans += 1

print(ans)


Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    REP1(i, n - 1) {
        vi a(26);
        REP(j, i) a[s[j] - 'a']++;
        int x = 0;
        FOR(j, i, n) if (a[s[j] - 'a']) {
            x++;
            a[s[j] - 'a'] = 0;
        }
        chmax(ans, x);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
s = input()
t = input()
import collections
import sys
c_s = collections.Counter(s)
c_t = collections.Counter(t)
l_s = c_s.most_common()
l_t = c_t.most_common()
for i in range(len(l_s)):
    if l_t[i][1] != l_s[i][1]:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 3888
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    string N;
    cin >> N;
    int64_t n_size = N.size();
    int64_t sum = 0;
    for (int64_t i=0; i<n_size; i++) {
        char c = N[i];
        int num = c - '0';
        sum += num;
    }

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

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

void read() {
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

void run() {

}

void write() {

}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  string s;
  cin >> s;
  cout << 700 + 100 * count(s.begin(), s.end(), 'o') << endl;
}



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

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

const long long MOD = 1000000007;

int main(){
  int n,t;
  cin >> n;
  vector<int> a(n);
  vector<vector<int>> sa(2*1e5,vector<int>(0));
  rep(i,n){
    cin >> t;
    int y=i-t+1;
    a.at(i)=t;
    if(y>0) sa.at(y).push_back(i+1);
  }
  ll ans=0;             
  rep(i,n){
    int x=i+1+a.at(i);
    if(x>=2*1e5) continue;
    else{
      if(sa.at(x).size()){
        auto itr = lower_bound(sa.at(x).begin(), sa.at(x).end(), i+2);
        ans+=distance(itr,sa.at(x).end());
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 12548
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int sum(string s,int& i);
int mul(string s,int& i);
int bracket(string s,int& i);
int num(string s,int& i);

bool isdigit(char c){
    int x=c-'0';
    return 0<=x&&x<=9;
}

int sum(string s,int& i){
    int ret=mul(s,i);
    while(s[i]=='+'||s[i]=='-'){
        char op=s[i];
        i++;
        int res=mul(s,i);
        if(op=='+')ret+=res;
        else ret-=res;
    }
    return ret;
}
int mul(string s,int& i){
    int ret=bracket(s,i);
    while(s[i]=='*'||s[i]=='/'){
        char op=s[i];
        i++;
        int res=bracket(s,i);
        if(op=='*')ret*=res;
        else ret/=res;
    }
    return ret;
}

int bracket(string s,int& i){
    if(isdigit(s[i]))return num(s,i);
    i++;
    int ret=sum(s,i);
    i++;
    return ret;
}

int num(string s,int& i){
    int ret=s[i]-'0';
    i++;
    while(isdigit(s[i])){
        ret=10*ret+(int)(s[i]-'0');
        i++;
    }
    return ret;
}

int main(){
    int n;
    cin>>n;
    rep(j,n){
        string s;
        cin>>s;
        int i=0;
        cout<<sum(s,i)<<endl;
    }
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) v.erase(unique(ALL(v)), v.end())
#define bit(i) (1LL<<i)
#define sz(v) ((LLI)(v).size())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

template <typename T> T max_rectangle_in_histogram(const vector<T> &h){
  stack<pair<T,int>> st;
  T ret = 0;

  REP(i,(int)h.size()){
    if(st.empty()) st.push({h[i],i});
    else if(st.top().fst < h[i]) st.push({h[i],i});
    else if(st.top().fst > h[i]){
      int j = i;
      while(not st.empty() and st.top().fst > h[i]){
	chmax(ret, (st.top().fst+1) * (T)(i-st.top().snd+1));
	j = st.top().snd;
	st.pop();
      }
      st.push({h[i],j});
    }
  }

  while(not st.empty()){
    chmax(ret, (st.top().fst+1) * ((int)h.size()-st.top().snd+1));
    st.pop();
  }
  
  return ret;
}

int max_rectangle(const vector<vector<int>> &d){
  int H = d.size();
  int W = d[0].size();
    
  vector<vector<int>> c(d);
  FOR(i,1,H){
    REP(j,W){
      if(c[i][j]){
	c[i][j] += c[i-1][j];
      }
    }
  }
  int ret = 0;
  REP(i,H){
    int t = max_rectangle_in_histogram(c[i]);
    chmax(ret, t);
  }
  return ret;
}



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

  int H,W;
  while(cin >> H >> W){
    vector<string> S(H); cin >> S;

    vector<vector<int>> c(H-1, vector<int>(W-1, 0));
    REP(i,H-1){
      REP(j,W-1){
	int t = 0;
	if(S[i][j] == '#') ++t;
	if(S[i+1][j] == '#') ++t;
	if(S[i][j+1] == '#') ++t;
	if(S[i+1][j+1] == '#') ++t;

	if(t%2==0) c[i][j] = 1;
      }
    }

    int ans = max(H,W);
    chmax(ans, max_rectangle(c));
    
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 35968
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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



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

	LL seisu = s[0] - '0';
	LL syousu;
	if (s.size() == 4) {
		 syousu= (s[2] - '0') * 10LL + (s[3] - '0');
	}
	else {
		syousu= (s[2] - '0') * 10LL;
	}
	

	LL hyaku = 100;

	LL g = gcd(hyaku, syousu);
	LL bunbo = hyaku/ g;
	LL bunsi = syousu / g;

	LL ans = a * seisu + (a*bunsi) / bunbo;
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3628
N,M=map(int,input().split())
edge=[set([]) for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    edge[a-1].add(b-1)
    edge[b-1].add(a-1)

cedge=[[] for i in range(N)]
for i in range(N):
    for j in range(N):
        if j not in edge[i] and j!=i:
            cedge[i].append(j)

ans=[]
def is_bipartgraph():
    color=[0]*N
    used=[False]*N
    for i in range(N):
        if not used[i]:
            stack=[(i,1)]
            black=0
            white=0
            while stack:
                v,c=stack.pop()
                color[v]=c
                black+=(not used[v])*(c==1)
                white+=(not used[v])*(c==-1)
                used[v]=True
                for nv in cedge[v]:
                    if color[nv]==color[v]:
                        return False
                    elif color[nv]==0:
                        stack.append((nv,-c))
            ans.append([black,white])
    return True

if is_bipartgraph():
    dp=[[False for i in range(0,N+1)] for j in range(len(ans))]
    a,b=ans[0]
    dp[0][a],dp[0][b]=True,True
    for i in range(1,len(ans)):
        a,b=ans[i]
        for j in range(0,N+1):
            test=False
            if j>=a:
                test=test|dp[i-1][j-a]
            if j>=b:
                test=test|dp[i-1][j-b]
            dp[i][j]=test
    ans=0
    for i in range(0,N+1):
        if dp[-1][i] and abs(ans-N/2)>abs(i-N/2):
            ans=i
    ans2=N-ans
    print(ans*(ans-1)//2+ans2*(ans2-1)//2)
else:
    print(-1)


Measured memory_bytes: 82008
import collections
n = int(input())
d = list(map(str, input().split()))
m = int(input())
t = list(map(str, input().split()))
c_d = collections.Counter(d)
c_t = collections.Counter(t)
ans = ''
for e in c_t:
  if c_t[e] <= c_d[e]:
    next
  else:
    ans = 'NO'
if ans == '':
  ans = 'YES'
print(ans)

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

int power(int x,int n){
  if(x==0) return 0;
  if(n==0) return 1;
  if(n==1) return x;
  int res = power(x,n/2);
  res = (res*res)%mod;
  if(n%2) return (res*x)%mod;
  return res;
}

int nCr(int n, int r)
{ 
    if (r == 0) 
        return 1; 
    vector <int> f(n + 1); 
    f[0] = 1; 
    for (int i = 1; i <= n; i++) 
        f[i] = (f[i-1]*i)%mod; 
  
    return ((f[n]*power(f[r],mod-2))%mod * power(f[n-r],mod-2))%mod; 
} 
  
const int MAX = 1000001; 
  
// array to store prime factors 
int factor[MAX] = { 0 }; 
  
// function to generate all prime factors 
// of numbers from 1 to 10^6 
void generatePrimeFactors() 
{ 
    factor[1] = 1; 
  
    // Initializes all the positions with their value. 
    for (int i = 2; i < MAX; i++) 
        factor[i] = i; 
  
    // Initializes all multiples of 2 with 2 
    for (int i = 4; i < MAX; i += 2) 
        factor[i] = 2; 
  
    for (int i = 3; i * i < MAX; i++) { 
        // check if it has no prime factor. 
        if (factor[i] == i) { 
            // Initializes of j starting from i*i 
            for (int j = i * i; j < MAX; j += i) { 
                // if it has no prime factor before, then 
                // stores the smallest prime divisor 
                if (factor[j] == j) 
                    factor[j] = i; 
            } 
        } 
    } 
} 
  
int no_of_fac(int n) 
{ 
    if (n == 1) 
        return 1; 
  
    int ans = 1; 
    int dup = factor[n]; 
    int c = 1; 
    int j = n / factor[n]; 
  
    while (j != 1) { 
        if (factor[j] == dup) 
            c += 1; 
        else { 
            dup = factor[j]; 
            ans = ans * (c + 1); 
            c = 1; 
        } 
       
        j = j / factor[j]; 
    } 
       ans = ans * (c + 1); 
  
    return ans; 
} 
  

int32_t main(){
     int n; cin>>n;
     int ans = 0;
     generatePrimeFactors();
     for(int c=1 ; c<n ; c++){
        int ab = n-c;
        ans += no_of_fac(ab);
     }
        cout<<ans;
}

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

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

int main() {
	string t; cin >> t;
	string s; cin >> s;
	int N = s.length();
	vector<int> a(N + 1);
	a[0] = -1;
	int k = -1;
	rep(i, N) {
		for (; k != -1 && s[k] != s[i]; k = a[k]);
		a[i + 1] = ++k;
	}
	int M = t.length();
	int i = 0, j = 0;
	while (j <= M)
		if (i < N && j < M && s[i] == t[j])
			i++, j++;
		else {
			if (i == N) printf("%d\n", j - N);
			if (i) i = a[i];
			else j++;
		}
}

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

int main(){
    long long X = 0;
    cin >> X;

    long long T = 100;

    int Y = 0;

    while( T < X ){
       T = T * 1.01; 
       // cout << T << endl;
       Y = Y+1;
    }

    cout << Y << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
typedef double db;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;
int main()
{
	LL a ,b , c;
	LL x , y ,ans;
	cin >> a >> b >> c ;
	x = a / c;
	y = b / c;
	ans = y - x;
	if(a % c == 0)ans++;
	cout << ans << endl;
	return 0;
	}

Measured memory_bytes: 256
D_ = [int(input()) for i in range(5)]

min = 10
index = 0
for i in range(len(D_)):
    if D_[i]%10 > 0 and D_[i]%10 <= min:
        min = D_[i]%10
        index = i

for i in range(len(D_)):
    if D_[i]%10 > 0 and index != i:
        D_[i] = (D_[i]//10 )*10 + 10

print(sum(D_))

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

int main()
{

	int64_t a,b,k;

	cin >> a >> b >> k;

	int64_t eat_takahashi=min(a,k);
	a-=eat_takahashi;
	k-=eat_takahashi;

	if (k==0)
	{
		cout << a << " " << b << endl;
		return 0;
	}

	int64_t eat_aoki=min(b,k);
	b-=eat_aoki;
	k-=eat_aoki;

	cout << a << " " << b << endl;
	return 0;
}






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

int n,m;
int p[100001],y[100001];
vector<int> city[100001]; 

int main()
{
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> p[i] >> y[i];
        city[p[i]].push_back(y[i]);
    }

    for(int i = 0; i < n; i++) sort(city[i+1].begin(),city[i+1].end());

    for(int i = 0; i < m; i++) printf("%012lld\n",ll(p[i])*1000000+int(lower_bound(city[p[i]].begin(),city[p[i]].end(),y[i])-city[p[i]].begin()+1));

    return 0;
}

Measured memory_bytes: 7808
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

class path{
public:
  long long int to, dist;
  
  path(long long int t, long long int d){
    to = t;
    dist = d;
  }
  
  bool operator > (const class path &another) const{
    return dist > another.dist;
  }
};

long long int dijkstra(std::vector<std::vector<long long int> > &G, std::vector<long long int> &distance, long long int N, long long int start);

int main(){
  
  long long int N, M, S, T, tmp1, tmp2;
  scanf("%lld%lld", &N, &M);
  std::vector<std::vector<long long int> > G(3*N);;
  
  for(long long int i = 0; i < M; i++){
    scanf("%lld%lld", &tmp1, &tmp2);
    G[3*tmp1-3].push_back(3*tmp2-2);
    G[3*tmp1-2].push_back(3*tmp2-1);
    G[3*tmp1-1].push_back(3*tmp2-3);
  }
  scanf("%lld%lld", &S, &T);
  
  //std::cerr << "reading problem is done" << std::endl;
  
  std::vector<long long int> distance(3*N);
  //std::cerr << "start dijkstra" << std::endl;
  dijkstra(G, distance, 3*N, 3*(S-1));
  
  std::cerr << "Answer:" << std::endl;
  if(distance[3*(T-1)] < 0){
    std::cout << -1 << std::endl;
  }
  else{
    std::cout << distance[3*(T-1)]/3 << std::endl;
  }
  
  return 0;
}

long long int dijkstra(std::vector<std::vector<long long int> > &G, std::vector<long long int> &distance, long long int N, long long int start){
  
  // initialize distance table
  for(long long int i = 0; i < N; i++){
    distance[i] = -1;
  }
  
  // prepare priority queue
  std::priority_queue<class path, std::vector<class path>, std::greater<class path> > que;
  
  distance[start] = 0;
  for(int i = 0; i < G[start].size(); i++){
    que.push(path(G[start][i], 1));
  }
  
  class path tmp_path = path(0,0);
  long long int tmp_pos, tmp_dist;
  
  while(!que.empty()){
    // get current position
    tmp_path = que.top();
    que.pop();
    tmp_pos = tmp_path.to;
    tmp_dist = tmp_path.dist;
    
    // update distance
    if(distance[tmp_pos] < 0){
      distance[tmp_pos] = tmp_dist;
      
      // further proceed
      for(long long int i = 0; i < G[tmp_pos].size(); i++){
        if(distance[G[tmp_pos][i]] < 0){
          que.push(path(G[tmp_pos][i], tmp_dist + 1));
        }
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 18944
#include<set>
#include<iostream>
using namespace std;
int main() {
    int T;
    cin >> T;
    set<int> s;
    while (T--) {
        int a;
        cin >> a;
        if (a==0) {int t; cin >> t;s.insert(t);
            cout << s.size() << endl;
        }
        else if (a==1) {
            int t;
            cin >> t;
            cout << (s.find(t) != s.end()) << endl;
        } else {
            int t;
            cin >> t;
            s.erase(t);
        }
    }
    return 0;
}


Measured memory_bytes: 12388
void main(){
	int n, m;
	readf("%d %d\n", &n, &m);
	int[] arr = _scanln();
	int sum = arr.sum();
	writeln( (arr.filter!(a => (4*a*m) >= sum).count>=m)? "Yes": "No" );

}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2840
#include <stdio.h>
int main(void) {
    int i,j;
    char board[9][9];
    while (scanf(" %s\n",board[0])!=EOF) {
        for (i=1; i<8; i++) scanf(" %s",board[i]);
        for (i=0; ; i++) {
            for (j=0; j<8; j++) {
            	if (board[i][j]=='1') break;
            }
            if (board[i][j]=='1') break;
        }
        if (i<7&&j<7&&board[i][j+1]=='1'&&board[i+1][j]=='1'&&board[i+1][j+1]=='1') printf("A\n");
        if (i<5&&board[i+1][j]=='1'&&board[i+2][j]=='1'&&board[i+3][j]=='1') printf("B\n");
        if (j<5&&board[i][j+1]=='1'&&board[i][j+2]=='1'&&board[i][j+3]=='1') printf("C\n");
        if (i<6&&j>0&&board[i+1][j]=='1'&&board[i+1][j-1]=='1'&&board[i+2][j-1]=='1') printf("D\n");
        if (i<7&&j<6&&board[i][j+1]=='1'&&board[i+1][j+1]=='1'&&board[i+1][j+2]=='1') printf("E\n");
        if (i<6&&j<7&&board[i+1][j]=='1'&&board[i+1][j+1]=='1'&&board[i+2][j+1]=='1') printf("F\n");
        if (i<7&&j>0&&j<7&&board[i][j+1]=='1'&&board[i+1][j]=='1'&&board[i+1][j-1]=='1') printf("G\n");
    }
    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
long long a[200001];
int main(){
 int n;
 int op=0;
 long long sum=0;
 long long sum2=0;
 long long ap=0;
 cin >> n;
 for(int i=1;i<=n;i++){
	 cin >> a[i];
 }
 for(int i=1;i<=n;i++){
 	while(op<n&&(sum2^a[op+1])==sum+a[op+1]){
 		sum=sum+a[op+1];
 		sum2=sum2^a[op+1];
 		op++;
	 }
	 ap+=op-i+1;
	 sum-=a[i];
	 sum2=sum2^a[i];
 }
 cout <<ap << endl;
 return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

struct UnionFind {
  vector<int> par;
  vector<int> rank;
  vector<ll> Size;
  UnionFind(int n = 1) { init(n); }

  void init(int n = 1) {
    par.resize(n + 1);
    rank.resize(n + 1);
    Size.resize(n + 1);
    for (int i = 0; i <= n; ++i)
      par[i] = i, rank[i] = 0, Size[i] = 1;
  }

  int root(int x) {
    if (par[x] == x) {
      return x;
    } else {
      int r = root(par[x]);
      return par[x] = r;
    }
  }

  bool is_same(int x, int y) { return root(x) == root(y); }

  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (rank[x] < rank[y])
      swap(x, y);
    if (rank[x] == rank[y])
      ++rank[x];
    par[y] = x;
    Size[x] += Size[y];
    return true;
  }

  ll size(int x) { return Size[root(x)]; }
};

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

  ll n, m;
  cin >> n >> m;

  vector<P> v(m);
  rep(i, 0, m) cin >> v[i].first >> v[i].second;

    UnionFind uf(n);
  vector<ll> ansv;
  ll ans = (n * (n - 1)) / 2;
  ansv.push_back(ans);

  repr(i, 1, m) {
    if (!uf.is_same(v[i].first, v[i].second)) {
      ll x = uf.size(v[i].first);
      ll y = uf.size(v[i].second);
      ans -= x * y;
    }
    uf.merge(v[i].first, v[i].second);
    ansv.push_back(ans);
  }

  repr(i, 0, m) cout << ansv[i] << endl;
}


Measured memory_bytes: 6596
a = gets
b = a.split()

for w in 0 ... 1 do
  unless -1000 <= b[w].to_i && b[w].to_i <= 1000
    return
  end
end

if b[0].to_i < b[1].to_i then
  puts "a < b"
elsif b[0].to_i == b[1].to_i then
  puts "a == b"
elsif b[0].to_i > b[1].to_i then
  puts "a > b"
end


Measured memory_bytes: 6876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

int main() {
	FAST_IO();
	int N, K, Q; cin >> N >> K >> Q;
	vector<int> correct(N);
	rep(i, Q) {
		int player; cin >> player;
		correct[player - 1]++;
	}
	rep(i, N) {
		if(K - Q + correct[i] <= 0) cout << "No\n";
		else cout << "Yes\n";
	}
}

Measured memory_bytes: 1024
# coding: utf-8
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

D=[]

for i in range(N):
    D.append(A[i]-B[i])

D.sort()

k=0
need=0
ans=0
while D[k]<0 and k!=N:
    need+=D[k]
    k+=1
    ans+=1

l=-1
while need<0 and D[l]>0:
    need+=D[l]
    ans+=1
    l-=1

if need<0:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 97576
// #include <stdio.h>
// #include <string.h>
//#include <iostream>
#include <math.h>
#include <iostream>
#include <utility>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <map>
#include <string>
#include <set>


using namespace std;
typedef pair<int, int> XY;// Pair型変数の宣言
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
    

int main()
{
  	int Nmax = 100000;
    char String[Nmax];
    int N;
    int i,j,k;
    int len;   // 文字列の長さ
    int flag=0;
 //   int t[Nmax];
   // int x[Nmax];
   // int y[Nmax];
    int M,D;
    int count = 0;
    int d1,d10;
    int d,m;
    ll K;
 /*  
    // int型スタック
    stack<int> stack;   
    stack.push(777);
    stack.push(778);
    stack.push(779);
  
	int tmpsl = stack.top();  // LAST要素の参照
 // 	int tpmsf = stack.back(); // FIRST要素の参照
 //	printf("%d %d \n",tmpsl,tmpsf);
    stack.pop();// LAST要素の削除（取出しではない）
 // 	if( stack.empty() == true) printf("empty stack\n");
     
    // int型キュー
    queue<int> que;
  	que.push(999);
  	que.push(998);   
  	que.push(997);    
  	int tmpqs = que.front(); // FIRST要素の参照
  	int tmpqe = que.back();  // LAST要素の参照
 //	printf("%d %d \n",tmpqs,tmpqe);
  	que.pop();  // FIRST要素の削除（取出しではない）
  //	if( que.empty() == true) printf("empty que\n");
    
    // ２次元座標を扱うキュー
    queue<XY> xyque; // ２次元座標型変数のキュー
  	XY p; 
  	xyque.pop();	// FIRST要素の削除。キューが空のときは削除が予約されて次のPOPが即削除される
  	xyque.push( XY(5,5) );
    xyque.push( XY(5,5) );
   	p = xyque.front();  // FIRST要素からのコピー
 // 	printf("%d %d\n", p.first, p.second);
  	
    
  que.back();
  //  sort(&(que.front()), &(que.back()));
        
   
*/
    
    // 入力読込
    // 文字列
 //   scanf("%s", String);   
    
    // 数列

    scanf("%d ", &N);
 //   scanf("%lld", &K);
//    for(i=1;i<=N;i++){
//        scanf("%d %d %d",&t[i],&x[i],&y[i]);
//    }
    
    // 文字列の長さをチェック
    // 文字列は配列の0からlen-1に格納されてる
//    len = strlen( String );
//  	printf("%d\n",len);
    
/*
    
    for(m=1;m<=M;m++){
        for(d=1;d<=D;d++){
            d1 = d%10;
            d10 = d/10;
            if((m == d1*d10) && (d1>=2) && (d10 >=2))  count++;
        }
    }
 */   
    
    // 結果出力
    printf("%d",N*N*N);
//  	cout << count  << endl;
/*    
    if(flag == -1)
        printf("NO \n");
    else
        printf("YES \n");
  */      
  
  return 0;
   
}

Measured memory_bytes: 888
import std.stdio, std.string, std.conv;
import std.algorithm, std.array;
import std.math, core.bitop;
 
auto solve(string s_)
{
    immutable N = s_.to!int();
    immutable xs = readln.split.map!(to!int).array();
    immutable L = readln.chomp.to!int();
    immutable Q = readln.chomp.to!int();
    auto ab = new int[2][Q];
    foreach(ref v;ab) v = readln.split.map!(to!int).array();
    immutable D = (xs[$-1]-xs[0]+L-1)/L;
    immutable M = bsr(D)+((D&D-1)?0:1)+1;
    auto ld = new int[][](N+1,M);
    for(int i=0,j=0; i<N; ++i)
    {
        while(j<i && (xs[i]-xs[j])>L) ld[j++][0]=i-1;
        if(i+1==N) while(j<N) ld[j++][0]=i;
    }
    ld[N-1][0]=N;
    ld[N][]=N;
    foreach(i;1..M) foreach(j;0..N) ld[j][i]=ld[ld[j][i-1]][i-1];
    int[] r; r.reserve(Q);
    foreach(ref v;ab)
    {
        auto a=v[0]-1,b=v[1]-1;
        if(a>b) swap(a,b);
        int d=0;
        while(a<b)
        {
            int lo=0, hi=M;
            while(lo+1<hi)
            {
                immutable m = (lo+hi)/2;
                if(ld[a][m]<=b) lo=m;
                else            hi=m;
            }
            d+=1<<lo;
            a=ld[a][lo];
        }
        r~=d;
    }
    return r.map!(to!string).join("\n");
}

void main(){ for(string s; (s=readln.chomp()).length;) writeln(solve(s)); }

Measured memory_bytes: 19760
#include<bits/stdc++.h>
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl;
#define mod 1000000007
#define pb push_back
#define endl '\n'

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(0);
	
	
	long long h,n;
	cin>>h>>n;

	long long a[n];
	for(long long i=0;i<n;i++)
	{
		cin>>a[i];
	}
	long long sum=0;
	for(auto it:a)
	{
		sum+=it;
	}
	if(sum>=h) cout<<"Yes"<<endl;
	else cout<<"No"<<endl; 


}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
#define REP(i,n)for((i)=0;(i)<(int)(n);(i)++)
#define M 2000
bool ab[100000],ac[100000],bc[100000];
bool match(char c1,char c2){
  return(c1== '?' ||c2== '?' ||c1==c2);
}
int main(void){
  int i,j;string a,b,c;
  cin>>a>>b>>c;
  int A=a.length();
  int B=b.length();
  int C=c.length();
  
  REP(i,A)REP(j,B)if(!match(a[i],b[j]))ab[i-j+50000] =true;
  REP(i,A)REP(j,C)if(!match(a[i],c[j]))ac[i-j+50000] =true;
  REP(i,B)REP(j,C)if(!match(b[i],c[j]))bc[i-j+50000] =true;
  
  int ans= 3 *M;
  for(i=-2*M;i<=2*M;i++)
    for(j=-2*M;j<=2*M;j++)
      if(!ab[i+50000] && !ac[j+50000] &&!bc[j-i+50000]){
        int L=min(0,min(i,j));
        int R=max(A,max(B+i,C+j));
        ans=min(ans,R-L);
      }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 384
n, m, x = list(map(int, input().split()))

a = []
for i in range(n):
    b = list(map(int, input().split()))
    a.append(b)


def calcPoint(point, n):
    for i in range(m):
        point[i] += a[n][i+1]
    return point


def judgePoint(point):
    for i in range(m):
        if point[i] < x:
            return False
    return True


ans = []
for i in range(2**n):  # patarn数
    buy = []
    for j in range(n):  # n bit
        if((i >> j) & 1):  # iをj bit 右にずらして1ならば
            buy.append(1)
        else:
            buy.append(0)
    price = 0
    point = [0]*m
    for i in range(n):
        if buy[i] == 1:
            calcPoint(point, i)
            price += a[i][0]
    if judgePoint(point):
        ans.append(price)
if len(ans) == 0:
    print(-1)
else:
    print(min(ans))


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

using namespace std;

int main(){

    long long int n,m,i,j,k,l;

    cin>>n>>m;

    long long int a[n][m];

    char c;

    for(i=0;i<n;i++){
        for(j=0;j<m;j++){

            cin>>c;

            if(c=='.')
                a[i][j]=0;
            else if(c=='#')
                a[i][j]=-1;
        }
    }

    long long int count1=0,count2=0;

    i=0;
    for(j=0;j<m;j++){
        if(a[i][j]!=-1 && count1==0){
            a[i][j]=1;
        }
        else{
            a[i][j]=-1;
            count1++;
        }
    }

    j=0;
    for(i=0;i<n;i++){
        if(a[i][j]!=-1 && count2==0){
            a[i][j]=1;
        }
        else{
            a[i][j]=-1;
            count2++;
        }
    }

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

            long long int p=0;

          //  cout<<"col_i:"<<i<<",row_j:"<<j<<"\n";
            if(a[j][i-1]!=-1){
                p=(p+(a[j][i-1])%1000000007)%1000000007;
            }
            if(a[j-1][i]!=-1){
                p=(p+(a[j-1][i])%1000000007)%1000000007;
            }

            if(a[j][i]!=-1)
                a[j][i]=p;
        }
    }

    /*for(i=0;i<n;i++){
        for(j=0;j<m;j++)
            cout<<a[i][j]<<"  ";
        cout<<"\n";
    }*/

    cout<<a[n-1][m-1]<<"\n";

    return 0;
}


Measured memory_bytes: 8064
def main():
    a_price, b_price, ab_price, a_num, b_num = map(int, input().split())
    chukan_price = (a_price + b_price) / 2
    min_num = min(a_num, b_num)

    ans = 0

    if chukan_price > ab_price:
        ans += min_num * 2 * ab_price
        a_num -= min_num
        b_num -= min_num
        # print(ans, a_num, b_num)
        if a_price > 2 * ab_price:
            ans += a_num * 2 * ab_price
        else:
            ans += a_num * a_price
        if b_price > 2 * ab_price:
            ans += b_num * 2 * ab_price
        else:
            ans += b_num * b_price
    else:
        ans += a_num * a_price
        ans += b_num * b_price

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38464
# -*- coding: utf-8 -*-


def main():
    s = input()

    # See:
    # https://atcoder.jp/contests/abc175/submissions/15907467
    # Pythonのシンタックスを活用
    if 'RRR' in s:
        print(3)
    elif 'RR' in s:
        print(2)
    elif 'R' in s:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8924
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int64_t n;
  cin>>n;
  std::vector<int64_t> a(n),b(n);
  for (int i = 0; i < n; ++i)
  {
    cin>>a[i]>>b[i];
  }
  int64_t cnt=0;
  for (int i = n-1; i >= 0; --i)
  {
    a[i]+=cnt;
    if(a[i]%b[i]!=0){
      cnt+=(a[i]/b[i]+1L)*b[i]-a[i];
    }
    else continue;
  }
  cout<<cnt;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<vector>

int main()
{
	int D;

	std::cin >> D;

	std::cout << "Christmas";
  for(int i=0;i<(25-D);i++){
		std::cout << " Eve";
	}
	std::cout << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//


// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    ll ans=0;
    vec(B,N-1); 
    
    rep(i,N-1){
    
      cin>>B[i];
      if(i==0){
        ans+=B[i];
      }else{
        ans+=min(B[i],B[i-1]);
      }
    }
    ans+=B[N-2];
    op(ans)
    return 0;
}


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

#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,x,y;
    cin>>n;
    ll a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    x=b[(n-1)/2];
    y=b[n/2];
    for(int i=0;i<n;i++){
        if(a[i]>x){
            cout <<x<<endl;
        }
        else{
            cout <<y<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5376
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    int64_t X;
    std::cin >> X;

    for (int64_t i = 0;; ++i) {
        if (i*(i+1)/2 >= X) {
            std::cout << i << std::endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, m;
string s[505];
bool v1[505][505];
bool v2[505][505];

int main()
{
    scanf("%lld%lld", &n, &m);
    for(ll i = 0; i < n; i++)
    {
        cin>>s[i];
    }
    for(ll i = 0; i < n; i++)
    {
        for(ll j = 0; j < m; j++)
        {
            if(i == 0 || s[i][j] == '#' || j % 2 == 0 && i != n - 1) v1[i][j] = true;
            if(i == n - 1 || s[i][j] == '#' || j % 2 == 1 && i != 0) v2[i][j] = true;
        }
    }
    for(ll i = 0; i < n; i++)
    {
        for(ll j = 0; j < m; j++)
        {
            if(v1[i][j]) printf("#");
            else printf(".");
        }
        puts("");
    }
    puts("");
    for(ll i = 0; i < n; i++)
    {
        for(ll j = 0; j < m; j++)
        {
            if(v2[i][j]) printf("#");
            else printf(".");
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 1536
n = int(input())
A = list(map(int,input().split()))
nums = {}
nums2 = {}
mod = 10**9 +7
for i in range(1,n+1):
    left = i -1
    right = n -i
    a = abs(left - right)
    if a in nums:
        nums[a] +=1
    else:
        nums[a] = 1

for a in A:
    if a in nums2:
        nums2[a] +=1
    else:
        nums2[a] = 1

if nums==nums2:
    if n%2==1:
        print(2**(len(nums)-1)%mod)
    else:
        print(2**(len(nums))%mod)
else:
    print(0)

Measured memory_bytes: 17784
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#define L 20
#define Gard NULL

struct Tree{
  int nodekey;
  struct Tree *parent;
  struct Tree *leftch;
  struct Tree *rightch;
};

typedef struct Tree  *Search;
Search road;

void Insert(int );
void Pre(Search );
void In(Search );

int main(){
  int loop,numnode;
  char order[L];
  int i;
    
  scanf("%d",&loop);
  
  for(i=0;i<loop;i++){
    scanf("%s",order);
    
    if(order[0]=='i'){
      scanf("%d",&numnode);
      Insert(numnode);
    }
    
    if(order[0]=='p'){
      In(road);
      printf("\n");
      Pre(road);
      printf("\n");
    }
  }
  
  return 0;
}

void Insert(int numnode){
  Search x,y,z;
  
  x=road;
  y=Gard;
  z=malloc(sizeof(struct Tree));
  z->nodekey=numnode;
  z->leftch=Gard;
  z->rightch=Gard;
  
  while(x!=Gard){
    y=x;
    
    if(z->nodekey<x->nodekey){
      x=x->leftch;
    }
    
    else{
      x=x->rightch;
    }
  }
  
  z->parent=y;
  
  if(y==Gard){
    road=z;
  }
  
  else if(z->nodekey<y->nodekey){
    y->leftch=z;
  }
  
  else{
    y->rightch=z;
  }
    
}

void Pre(Search road){

  if(road==Gard){
    return;
  }
  
  printf(" %d",road->nodekey);
 
  Pre(road->leftch);
  Pre(road->rightch);
  
}

void In(Search road){

  if(road==Gard){
    return;
  }
  
  In(road->leftch);
  
  printf(" %d",road->nodekey);
  
  In(road->rightch);
}



Measured memory_bytes: 25160
S = input()

flag = [0]*26

if S == 'zyxwvutsrqponmlkjihgfedcba':
  print(-1)
  exit()

if len(S) < 26:
  for s in S:
    flag[ord(s)-ord('a')] = 1
  print(S + chr(flag.index(0)+ord('a')))
  
else:
  a = 0
  for i in range(len(S)-1,-1,-1):
    if a < ord(S[i]):
      flag[ord(S[i])-ord('a')] = 1
      a = ord(S[i])
    else:
      print(S[:i]+chr(flag[ord(S[i])-ord('a'):].index(1)+ord(S[i])))
      break

Measured memory_bytes: 38404
n, m = map(int, input().split())

food = [0 for i in range(m)]

for i in range(n):
    line = [int(t) for t in input().split()]
    k = line[0]
    a = line[1:]
    for item in a:
        food[item - 1] += 1
        
cnt = 0
for item in food:
    if item == n:
        cnt += 1

print(cnt)




Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>

using namespace std;

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

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

	if(a<=111)ans = 111;
	else if(a<=222)ans = 222;
	else if(a<=333)ans = 333;
	else if(a<=444)ans = 444;
	else if(a<=555)ans = 555;
	else if(a<=666)ans = 666;
	else if(a<=777)ans = 777;
	else if(a<=888)ans = 888;
	else ans = 999;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
 public static void main(String args[]) {
   Scanner sc = new Scanner(System.in);
   int n = sc.nextInt();
   char[] nChar = String.valueOf(n).toCharArray();
   int sn = 0;
   for (int i = 0; i < nChar.length; i++) {
          sn += Integer.parseInt(String.valueOf(nChar[i]));
   }
   if(n % sn == 0) {
      System.out.println("Yes");
      return;
   } 
   System.out.println("No");
 }
}

Measured memory_bytes: 25172
#include <iostream>
#include <cmath>
#include <climits>

int main(int argc, char *argv[])
{
    int n, l;
    int ans;
    int absmin;

    std::cin >> n >> l;

    ans = 0;
    absmin = INT_MAX;
    for (int i = 1; i <= n; i++) {
        int taste = l + i - 1;
        ans += taste;
        if (std::abs(taste) < std::abs(absmin)) {
            absmin = taste;
        }
    }

    ans -= absmin;

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(X) ((int)(X).size())
#define all(X) (X).begin(),(X).end()
#define ll long long
#define pi pair<int,int>
const int N=3e5+5,MOD=1e9+7;
 
using namespace std;
int n,m;
int main()
{
	//freopen("tst.txt","r",stdin);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	scanf("%d %d",&n,&m);
	std::vector<pi> a(n);
	for(int i=0;i<n;i++)scanf("%d %d",&a[i].first,&a[i].second);
	ll ans =0;
	sort(all(a));
	for(int i=0;i<n;i++){
		int del = min(m,a[i].second);
		ans += (ll)del*a[i].first;
		m-=del;
	}	
	printf("%lld\n",ans );
}
//AGC is the problem

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

int main(){
  int n;
  cin >> n;
  
  if(n%10==3) cout << "bon" << endl;
  else if(n%10==0||n%10==1||n%10==6||n%10==8) cout << "pon" << endl;
  else cout << "hon" << endl;
   return 0; 
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        System.out.println( solve(N, A) );
    }

    private static int solve(int N, int[] A) {
        Set<Integer> set = new HashSet<>();

        for (int i = 0; i < N; i++) {
            int a = A[i];
            if( set.contains(a) ) {
                set.remove(a);
            } else {
                set.add(a);
            }
        }

        return set.size();
    }
}


Measured memory_bytes: 54472
#include<stdio.h>
#include<string.h>
int main(void){
  int a=0,b=0;
  char s[100000];
  scanf("%s",s);
  for(int i=0;i<strlen(s);i++){
    if(i%2==0 && s[i]=='1'){
      a+=1;
    }else if(i%2!=0 && s[i]=='0'){
      a+=1;
    }else{
      b+=1;
    }
  }
  printf("%d\n",(a>b) ? b : a);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define MOD 1000000007

ll dp[100000];
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,i,ans=0;
	cin>>n;
	ll a[n];
	for(i=0;i<n;i++)
		cin>>a[i];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 5144
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 3e3+10;
#define int ll

vector<ll> a(n_max);
vector<vector<ll>> memo(n_max, vector<ll>(n_max));
ll dfs(ll left, ll right, ll turn = 0){
    if(memo[left][right])return memo[left][right];
    if(left == right)return 0;
    ll ans;
    if(turn & 1){
        ans = min(dfs(left+1, right, turn + 1) - a[left], dfs(left, right-1, turn + 1) - a[right-1]);
    }
    else{
        ans = max(dfs(left+1, right, turn + 1) + a[left], dfs(left, right-1, turn + 1) + a[right-1]);
    }

    return memo[left][right] = ans;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n; cin >> n;

    rep(i,n) cin >> a[i];

    cout << dfs(0, n, 0) << endl;
}

Measured memory_bytes: 71424
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//Block
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] move = {{0,1},{0,-1},{1,0},{-1,0}};
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if((w|h)==0)break;
			int[][] m = new int[h][w];
			int sj = sc.nextInt()-1;
			int si = sc.nextInt()-1;
			int gj = sc.nextInt()-1;
			int gi = sc.nextInt()-1;
			int n = sc.nextInt();
			while(n--!=0){
				int c = sc.nextInt();
				int d = sc.nextInt();
				int tj = sc.nextInt()-1;
				int ti = sc.nextInt()-1;
				if(d==0)for(int i=0;i<2;i++)for(int j=0;j<4;j++)m[ti+i][tj+j]=c;
				else for(int i=0;i<4;i++)for(int j=0;j<2;j++)m[ti+i][tj+j]=c;
			}
			if(m[si][sj]==0||m[gi][gj]==0||m[si][sj]!=m[gi][gj]){
				System.out.println("NG");
				continue;
			}
			int x = m[si][sj];
			boolean f = false;
			boolean[][] v = new boolean[h][w];
			v[si][sj] = true;
			List<int[]> l = new ArrayList<int[]>();
			l.add(new int[]{si,sj});
			while(!l.isEmpty()){
				List<int[]> next = new ArrayList<int[]>();
				for(int a[] : l){
					int i = a[0];
					int j = a[1];
					if(i==gi&&j==gj){
						f = true;
						next.clear();
						break;
					}
					for(int k=0;k<4;k++){
						int ni = i+move[k][0];
						int nj = j+move[k][1];
						if(0<=ni&&ni<h&&0<=nj&&nj<w&&!v[ni][nj]&&m[ni][nj]==x){
							v[ni][nj] = true;
							next.add(new int[]{ni,nj});
						}
					}
				}
				l = next;
			}
			System.out.println(f?"OK":"NG");
		}
	}
}

Measured memory_bytes: 12000