akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
    string s, s2;
    int cnt = 0;

    cin >> s;
    cin >> s2;


    for(unsigned int i = 0; i < s.size(); i++) {
        cnt++;
        if(s.at(i) != s2.at(i)) {
            cout << "No" << endl;
            return 0;
        }
    }

    if(s2.size() != s.size() + 1) {
        cout << "No" << endl;
        return 0;
    }

    if(s2.at(s.size()) < 'a' || s2.at(s.size()) > 'z') {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    return 0;
}


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

#define F first
#define S second
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << endl;}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]";cout<<endl;}

vi p, r, a;
vector<priority_queue<int, vi, greater<int>>> pq;
priority_queue<ii, vector<ii>, greater<ii>> overall;

int get(int i) {
	if (p[i] != i)p[i] = get(p[i]);
	return p[i];
}

int connect(int i, int j) {
	int x = get(i), y = get(j);
	if (x == y) return 0;
	if (r[x] > r[y]) swap(x, y);
	p[x] = y;
	while (!pq[x].empty()) pq[y].push(pq[x].top()), pq[x].pop();
	if (r[x] == r[y]) ++r[y];
	return 1;
}


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

	int n, m; cin >> n >> m;
	if (m == n - 1) {
		cout << "0\n";
		return 0;
	}
	a.resize(n); FOR (i, 0, n - 1) cin >> a[i];
	pq.resize(n), p.resize(n), r.resize(n);
	iota(all(p), 0);
	FOR (i, 0, n - 1) pq[i].push(a[i]);

	FOR (_, 1, m) {
		int x, y; cin >> x >> y;
		connect(x, y);
	}
	int sum = 0;
	ll ans = 0;
	priority_queue<int, vi, greater<int>> PQ;
	FOR (i, 0, n - 1) if (i == get(i)) {
		sum += sz(pq[i]);
		ans += pq[i].top();
		pq[i].pop();
		while (!pq[i].empty()) PQ.push(pq[i].top()), pq[i].pop();
	}
	int no = n - m;

	if (sum < 2*(no-1)) {
		cout << "Impossible\n";
		return 0;
	}

	FOR (i, 1, no - 2) {
		ans += PQ.top();
		PQ.pop();
	}
	

	
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 9464
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int a,b,c;
    cin>> a>>b>>c;

    string ans="No";

    if(a==b && b==c && c==a) ans="Yes";

    cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

char mp[1000][1000];
ll val[1000][1000];

int main() {
	cin >> H >> W;
	queue<Pa> que;
	rep(i, H) {
		rep(j, W) {
			cin >> mp[i][j];
			if (mp[i][j] == '#') {
				que.push(Pa(i, j));
				val[i][j] = 0;
			}
		}
	}
	int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
	ll ans = 0;
	while (!que.empty()) {
		Pa curr = que.front(); que.pop();
		int x = curr.second, y = curr.first;
		rep(j, 4) {
			int next_x = x + dx[j], next_y = y + dy[j];
			if (0 <= next_x && next_x < W && 0 <= next_y && next_y < H && mp[next_y][next_x] != '#') {
				que.push(Pa(next_y, next_x));
				val[next_y][next_x] = val[y][x] + 1;
				mp[next_y][next_x] = '#';
			}
		}
	}
	rep(i, H) {
		rep(j, W) {
			ans = max(ans, val[i][j]);
		}
	}
	cout << ans;
}

Measured memory_bytes: 25396
def F(a,b):
 A=len(a);r=[0]*A
 for i in range(A):
  f=1
  for j in range(min(A-i,len(b))):
   if len(set([a[i+j],b[j],'?']))>2:f=0
  r[i]=f
 return r+[1]
def T(ix):
 i1,i2,i3=ix;ab,bc,ac=M[i1][i2],M[i2][i3],M[i1][i3];A,B,C=map(len,[S[i]for i in ix]);q=A+B+C
 for l in range(A+1):
  if ab[l]!=0:
   for r in range(l,A+B+1):
    if (B<r-l or bc[r-l]==1) and ac[min(A,r)]==1:q=min(q,max(A,l+B,r+C))
 return q
S=[input()for i in'abc']
M=[[F(S[i],S[j]) if i!=j else []for j in range(3)]for i in range(3)]
print(min([T(i)for i in [(0,1,2),(0,2,1),(1,0,2),(1,2,0),(2,1,0),(2,0,1)]]))

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

int main() {
    int n, h[30];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> h[i];

    int ans = 1, max_h = h[0];
    for (int i = 1; i < n; i++) {
        if (h[i] >= max_h) {
            ans++;
            max_h = h[i];
        }
    }
    
    cout << ans << endl;

}

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


int mat[2][510][510];
bool u[1001000];

vector<int> cards;

int n,p[2],m;
int f(int l,int id){
	for(int i = 0 ; i < min<int>(cards.size(),l) ; i++)
		u[cards[i]]=true;
	int ans = 0;
	for(int i = 0 ; i < n ; i++){
		int ok = 1;
		for(int j = 0 ; j < n ; j++) ok &= u[mat[id][i][j]];
		ans += ok;
		if( n != 1 ){
			ok = 1;
			for(int j = 0 ; j < n ; j++) ok &= u[mat[id][j][i]];
			ans += ok;
		}
	}
	if( n != 1 )
	{
		int ok = 1;
		for(int j = 0 ; j < n ; j++) ok &= u[mat[id][j][j]];
		ans += ok;
	}
	if( n != 1 )
	{
		int ok = 1;
		for(int j = 0 ; j < n ; j++) ok &= u[mat[id][n-j-1][j]];
		ans += ok;
	}
	for(int i = 0 ; i < min<int>(cards.size(),l) ; i++)
		u[cards[i]]=false;
	return ans;
}

int bins(int id){
	int l = 0 , r = m+1;
	while( l != r ){
		int mi = (l+r)/2;
		if( f(mi,id) >= p[id] ) r = mi;
		else l = mi+1;
	}
	
	return l;
}
int main(){
	cin >> n >> p[0] >> p[1] >> m;
	for(int j = 0 ; j < 2 ; j++){
		for(int i = 0 ; i < n ; i++){
			for(int k = 0 ; k < n ; k++){
				scanf("%d",&mat[j][i][k]);
			}
		}
	}
	for(int i = 0 ; i < m ; i++){
		int t;
		cin >> t;
		cards.push_back(t);
		
	}
	int a = bins(0);
	int b = bins(1);
	if( a == b ){
		cout << "DRAW" << endl;
	}else if( a < b ){
		cout << "USAGI" << endl;
	}else{
		cout << "NEKO" << endl;
	}
}

Measured memory_bytes: 3876
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

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

    int n = s.size() - t.size() + 1;
    int nt = t.size();

    int ans = 100100;

    for(int i = 0; i < n; i++) {
        int cnt = 0;
        for(int j = 0; j < nt; j++) {
            if(s[i + j] != t[j]) cnt++;
        }
        if(ans > cnt) ans = cnt;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
import sys


def _s(): return sys.stdin.readline().strip()


def _i(): return int(sys.stdin.readline().strip())


def main():
    k = _i()
    s = _s()
    if len(s) <= k:
        return s
    else:
        return s[:k] + "..."


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 61608
#include<stdio.h>
#include<string.h>
#define LIM 1200

int main()
{
  char str[LIM];
  int i, j=0, strnum;
  int num[26];


  for(i=0; i < 26; i++){
    num[i] = 0;
  }

  while( scanf("%c", &str[j]) != EOF){

    if('A'<=str[j] && str[j] <= 'Z'){
      str[j] += 'a'-'A';
    }
 
    strnum = str[j]-'a';
      num[strnum]++;
      j++;

  }

  for(i=0; i<26; i++){
    printf("%c : %d\n", 'a'+i, num[i]);
  }

return 0;
}

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

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    int n; cin >> n;
    vector <int> as;
    REP(i, n+1){
        int a; cin >> a;
        as.push_back(a);
    }
    ll ans = 0;
    REP(i, n){
        int b; cin >> b;
        if (as[i] <= b){
            ans += as[i];
            b -= as[i];
        } else {
            ans += b;
            b -= b;
        }
        ans += min(as[i+1], b);
        as[i+1] -= min(as[i+1], b);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h> 
#define ll                 long long                            
#define ra                 return a;                                          
#define pb                 push_back                                                     
#define sti                stack<ll>
#define spi                stack<pair<ll,ll>>
#define S                  second
#define msi                map<string,ll >
#define msi                map<string,ll >
#define mii                map<ll ,ll >
#define dbg(x)             { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y)          { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z)        { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define mis                map<ll , string>
#define rep(i,a,b)         for(ll  i=a;i<b;i++)
#define mpi                map<pair<ll ,ll >,ll >                                                
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define F                  first 
#define vi                 vector<ll >
#define vii                vector<pair<ll , ll >>
#define pqi                priority_queue<ll>
#define si                 set <ll>
#define vs                 vector<string>
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define hell               1000000007
#define bs                 binary_search
#define mp                 make_pair
#define qi                 queue<ll>
#define qs                 queue<string>
#define qpi                queue<pair<ll,ll>>
#define qps                queue<pair<ll,string>> 
#define endl               '\n' 
#define itr(a,it)          for(typeof(a.begin()) it=a.begin();it!=a.end();it++)// This will produce const_iterator for const object and normal iterator for non-const object
#define ss                 set<string>
using namespace std;
#define N  1005
ll dp[N][N];
char table[N][N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
//    cin>>t;
    while(t--)
{
	ll h,w;
	cin>>h>>w;
	rep(i,0,h)
	{
		rep(j,0,w)
		{
			cin>>table[i][j];
		}
	}
	dp[0][0]=1;
	rep(i,0,h)
	{
		rep(j,0,w)
		{
			if(i==0&&j==0);
			else if(i==0)
			{
				if(table[i][j-1]=='.')dp[i][j]=dp[i][j-1];
			}
			else if(j==0)
			{
				if(table[i-1][j]=='.')dp[i][j]=dp[i-1][j];
			}
			else 
			{
				if(table[i-1][j]=='.'&&table[i][j-1]=='.')
				{
					dp[i][j]=dp[i-1][j]+dp[i][j-1];
				}
				else if(table[i-1][j]=='.')
					dp[i][j]=dp[i-1][j];
				else if(table[i][j-1]=='.')
					dp[i][j]=dp[i][j-1];
			}
			dp[i][j]%=hell;
		}
	}
	cout<<dp[h-1][w-1];
}
    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
///                    BISMILLAHIR RAHMANIR RAHIM

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

/// A L H A M D U L I L L A H


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n, s[300005], ans = 1e9;

char a[300005];

int main()
{
	scanf("%d%s",&n,a+1);
	for(int i=1;i<=n;i++) {
		s[i] = s[i-1] + (a[i] == 'E');
	}
	for(int i=1;i<=n;i++) {
		ans = min(ans, (i-1-s[i-1]) + (s[n]-s[i]));
	}
	printf("%d",ans);
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >>N;
  int a=N/1000,c=N/10;
  if(c%111==0)
    cout << "Yes" <<endl;
  else if((N-a*1000)%111==0)
    cout << "Yes" <<endl;
  else
    cout <<"No" <<endl;
  
}

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

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

  int ans = 0;
  int active = 0;
  rep(i,n) {
    if (active >= h[i]) {
      active = h[i];     
    } else {
      ans += h[i]-active;
      active = h[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	lint n, s;
	cin >> n >> s;
	for (int i = 2; i <= sqrt(n); i++)
	{
		lint copy_n = n;
		lint tmp = 0;
		for (; copy_n != 0;)
		{
			tmp += copy_n % i;
			copy_n /= i;
		}

		if (s == tmp)
		{
			cout << i << endl;
			return;
		}
	}
	for (lint i = sqrt(n); 0 < i; i--)
	{
		if (i * i == n)
			continue;
		lint tmp, max, min;
		lint a = n / i;
		lint b = n / (i + 1) + 1;

		if (a == b)
		{
			tmp = n / a + n % a;
			if (s == tmp)
			{
				cout << a << endl;
				return;
			}
		}
		else
		{
			min = i + n % a;
			max = i + n % b;

			if (s < min)
				continue;

			if (max < s)
				continue;

			if ((s - min) % i == 0)
			{
				//a 12 b 10 min 3 max 9    9 10  6 11  3 12
				//cout << i << " " << a << " " << b << " " << max << " " << min << endl;
				cout << b + (max - s) / i << endl;
				return;
			}
		}
	}
	if (n == s)
		cout << n + 1 << endl;
	else
		cout << -1 << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

int main(void){
	int n,m,a,ans = 0;
	cin >> n >> m;
	for(int i = 0; i < m; ++i){
		cin >> a;
		if(a > m){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

const ll B = 40;

ll N, K;
vi A;

int main()
{
    cin >> N >> K;
    A = vi(N);
    REP(i, N)
    {
        cin >> A[i];
    }

    ll ans = 0;
    REP(i, B)
    {
        ll X = 0;
        REP(j, B)
        {
            ll b = (1LL << (B - 1 - j));
            ll z = 0;
            REP(k, N)
            {
                if ((A[k] & b) == 0)
                {
                    ++z;
                }
            }
            if ((X | b) <= K and 2 * z > N and j != i)
            {
                X |= b;
            }
        }
        ll f = 0;
        REP(k, N)
        {
            f += X ^ A[k];
        }
        ans = max(ans, f);
    }

    OUT(ans);
}

Measured memory_bytes: 1024
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    long a = sc.nextLong();
	    long b = sc.nextLong();
	    long c = sc.nextLong();
	    long d = sc.nextLong();
	    long ac = a * c;
	    long ad = a * d;
	    long bc = b * c;
	    long bd = b * d;
	    long returnval = Math.max(Math.max(Math.max(ac, ad), bc), bd);
	    System.out.println(returnval);
	}
}

Measured memory_bytes: 35656
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int r, g, b, sum=0;
	cin >> r >> g >> b;
	sum = r * 100 + g * 10 + b;
	if (sum % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

} 

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

int main() {
  char C;
  cin >> C;


    if (C == 'a'){
      cout << "vowel" <<endl;
    }
  
      else if (C == 'i'){
      cout << "vowel" <<endl;
    }
        else if (C == 'u'){
      cout << "vowel" <<endl;
    }
        else if (C == 'e'){
      cout << "vowel" <<endl;
    }
        else if (C == 'o'){
      cout << "vowel" <<endl;
    }
    else {
  cout << "consonant" << endl;
    }

}


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

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

   vector<long long> A(5);
   for (int i = 0; i < 5; i++)
      cin >> A.at(i);
   sort(A.begin(), A.end());
   
   cout << (N + A.at(0) - 1)/ A.at(0) + 4 << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10*7)

def bit_fullsearch(target):
    n = len(target)
    ret = []
    for i in range(2**n):
        tmp = []
        for j in range(n):
            if (i>>j)&1:
                tmp.append(target[j])
        ret.append(tmp)
    return ret

n,m,x = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(n)]
ans = float('inf')

for l in bit_fullsearch(lst):
    tmp = [0 for _ in range(m+1)]
    for k in l:
        for i in range(m+1):
            tmp[i] += k[i]
    if min(tmp[1:]) >= x:
        ans = min(ans, tmp[0])
print(ans if ans!=float('inf') else -1)

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

int main(void) {
  int N;
  cin >> N;
  vector<int> X(N);
  int sum = 0;
  int summin = 1000000;
  for (int i = 0; i < N; i++) cin >> X.at(i);
  for (int i = 1; i <= 100; i++) {
    sum = 0;
    for (int j = 0; j < N; j++) {
      sum += pow(X.at(j) - i, 2);
    }
    if (summin > sum) {
      summin = sum;
    }
  }
  cout << summin << endl;
}

Measured memory_bytes: 3612
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
map <int,int> sum;
int n,a[200001],ans;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
		if(a[i]<i)
		{
			++sum[i-a[i]];
		}
	}
	for(int i=1;i<=n;++i)
	{
		if(a[i]<i)
		{
			--sum[i-a[i]];
		}
		ans+=sum[i+a[i]];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 18916
#include <iostream>
#include <stdio.h>

using namespace std;
int d[100] = {}, f[100] = {}, ans[100][100] = {};
int now = 1, n;
int dfs(int i) {
	d[i] = now;
	++now;
	for (int u = 0; u < n; ++u) {
		if (ans[i][u] == 1 && d[u] == 0) {
			dfs(u);
		}
	}
	f[i] = now;
	++now;
	return 0;
}
int main() {
	int u, k, tmp, now=0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> u >> k;
		for (int j = 0; j < k; j++)
		{
			cin >> tmp;
			ans[u - 1][tmp - 1] = 1;
		}
	}
	/*
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n;++j) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
	*/
	for (int i = 0; i < n; ++i) {
		if (d[i] == 0) {
			dfs(i);
		}
	}
	for (int i = 0; i < n; i++)
	{
		cout << i+1 << " " << d[i] << " " << f[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3100
n, dimension = gets.split.map(&:to_i)

points = n.times.map do |i|
  gets.split.map(&:to_i)
end

res = 0

(0...(n-1)).each do |i|
  ((i + 1)...n).each do |j|
    ddouble = 0
    dimension.times do |d|
      ddouble += (points[i][d] - points[j][d]) ** 2
    end

    res += 1 if (Math.sqrt(ddouble).floor ** 2 == ddouble)
  end
end

puts res

Measured memory_bytes: 1788
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func main() {
	scanner.Split(bufio.ScanWords)
	n, _ := nextInt()
	m, _ := nextInt()
	a := make([][]int, n)

	for i := 0; i < n; i++ {
		t := make([]int, m)
		for j := 0; j < m; j++ {
			t[j], _ = nextInt()
		}
		a[i] = t
	}

	b := make([]int, m)
	for j := 0; j < m; j++ {
		b[j], _ = nextInt()
	}

	c := make([]int, n)
	for i := 0; i < n; i++ {
		c[i] = 0
		for j := 0; j < m; j++ {
			c[i] += a[i][j] * b[j]
		}
	}

	// fmt.Println(a, b, c)
	fmt.Println(strings.Replace(stringifyArray(c), " ", "\n", -1))
}



Measured memory_bytes: 1300
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

const int mod = 1000000007;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
	FIO
	
	ll S;cin >> S;
	cout << "0 0 1000000000 1 ";
	const int n = 1e9;
	int x3 = (n - S % n) % n;
	int y3 = (S + x3) / n;
	cout << x3 << " " << y3;
	return 0;
}


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

using namespace std;

int main(void){
  int n = 0;
  while(cin >> n){
    int num = 0;
  for(int i=0; i<10; i++)
    for(int j=0; j<10;j++)
      for(int k=0; k<10; k++)
	for(int l=0; l<10; l++)
	  if(i+j+k+l == n)
	    num ++;
  cout << num << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <deque>
#include <cstdlib>
#include <limits>
#include <algorithm>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    uint N;
    cin >> N;
    vector<ll> as(N, 0);
    for (auto &&i: irange(0U, N)){
        cin >> as.at(i);
    }
    deque<ll> left_sum(N+1,0);
    for (auto &&i: irange(0U, N)){
        left_sum.at(i+1) = left_sum.at(i) + as.at(i);
    }
    left_sum.pop_back();
    left_sum.pop_front();
    ll s{0};
    for (auto &&i: irange(0U, N)){
        s+=as.at(i);
    }
    vector<ll> diff(N-1, 0);
    for (auto &&i: irange(0U, N-1)){
        diff.at(i) = abs(2*left_sum.at(i)-s);
    }
//    for (auto &&i: irange(0U, N-1)){
//        cout << diff.at(i) << " ";
//    }
//    cout << endl;
    sort(diff.begin(), diff.end());
    cout << diff.front();

    return 0;
}

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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf("%.12lf\n",mid);
// __builtin_popcount(int) count 1's in binary
// get decimal pert of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = "And I feel fine...";
    istringstream iss(sentence);
*/  

double eps = .000000001;

int main ()
{
  prep();
  int n;
  cin >> n;
  int count = 0;
  for (int i=1; i<=n; i++){
      if ((int)(log10(i))%2 == 0){
          count++;
      }
  }
  cout << count;
  return 0; 
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
 int main (){
     int H,W;
     cin >> H >> W;
     vector<vector<char>> A(H, vector<char>(W));
     for (int i=0; i<H; i++){
         for (int j=0; j<W; j++) {
             cin >> A.at(i).at(j);
         }
     }
     int ans;
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++){
            if (A.at(i).at(j) == '#') ans++;
        }
    }
    if (ans == H+W-1){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
     

 }

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
MAX = max(A)
dic = {}
for i in range(N):
  if A[i] not in dic:
    dic[A[i]] = 1
  else:
    dic[A[i]] += 1

ans = []
for i in range(MAX+1):
  mae = 0;ima=0;tsugi = 0
  if i in dic:
    ima = dic[i]
  if i-1 in dic:
    mae = dic[i-1]
  if i+1 in dic:
    tsugi = dic[i+1]
  temp = mae + ima + tsugi
  ans.append(temp)
print(max(ans))  
    

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

string lcs(string s, string t)
{
    vector<vector<int>> dp(s.size()+1, vector<int>(t.size()+1, 0));
    string res = "";
    for(int i=1; i<=s.size(); i++){
        for(int j=1; j<=t.size(); j++){
            if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1]+1;
            }
            else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    int i=s.size(), j=t.size();
    while(dp[i][j] > 0){
        if((dp[i][j] > dp[i-1][j]) && (dp[i][j] > dp[i][j-1])){
            res += s[i-1];
            i--; j--;
        }
        else if(dp[i-1][j] > dp[i][j-1]){
            i--;
        }
        else{
            j--;
        }
    }
    reverse(res.begin(), res.end());
    return res;
}

int main()
{
    string s, t;
    getline(cin, s);
    getline(cin, t);
    cout << lcs(s, t) << endl;
}

Measured memory_bytes: 35584
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int MAXN = 1005;
const int MAXV = MAXN*(MAXN-1)/2;

vector<int> to[MAXV];
int id[MAXN][MAXN];
bool visited[MAXV];
bool calculated[MAXV];
int dp[MAXV];

int toId(int i, int j) {

    if(i > j) {
        swap(i, j);
    }
    return id[i][j];
}

int dfs(int v) {

    if(visited[v]) {
        if(!calculated[v]) {
            return -1;
        }
        return dp[v];
    }

    visited[v] = true;

    dp[v] = 1;
    for(int u : to[v]) {
        int res = dfs(u);
        if(res == -1) {
            return -1;
        }
        dp[v] = max(dp[v], res+1);
    }
    
    calculated[v] = true;
    return dp[v];
}

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

    vector<vector<int>> a(n, vector<int>(n-1));
    rep(i, n) {
        rep(j, n-1) {
            cin >> a[i][j];
            a[i][j]--;
        }
    }

    int V = 0;
    rep(i, n) {
        rep(j, n) {
            if(i < j) {
                id[i][j] = V++;
            }
        }
    }

    rep(i, n) {
        rep(j, n-1) {
             a[i][j] = toId(i, a[i][j]);
        }
        rep(j, n-2) {
            to[a[i][j]].push_back(a[i][j+1]);
        }
    }

    int ans = 0;
    rep(i, V) {
        int res = dfs(i);
        if(res == -1) {
            cout << -1 << endl;
            return 0;
        }
        ans = max(ans, dfs(i));
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 38528
//Moh_K_Imar .......
//24/08/2020  ... 5,47.
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    string a,b;
    cin>>a>>b;
    cout<<b<<a<<endl;

    return 0;
}



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

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

    int num{0};

    for(int i{1}; i<=N; i+=2){
        int yakusu{0};

        for(int j{1}; j<=i; ++j){
            if(i%j == 0){
                ++yakusu;
            }
        }

        if(yakusu==8){
            ++num;
        }

    }
    cout << num << endl;
}


Measured memory_bytes: 3504
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N, D;
		N = sc.nextInt();
		D = sc.nextInt();
		int[][] X = new int[N][D];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < D; j++) {
				X[i][j] = sc.nextInt();
			}
		}

		int cnt = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = i + 1; j < N; j++) {
				int sum = 0;
				for (int k = 0; k < D; k++) {
					sum += Math.abs(X[i][k] - X[j][k]) * Math.abs(X[i][k] - X[j][k]);
				}
				if (Math.sqrt(sum) % 1 == 0) {
					cnt++;
				}
			}
		}

		System.out.println(cnt);
	}
}

Measured memory_bytes: 23764
#include <iostream>
using namespace std;
void comp(int x,int y)
{
    if(x>y){cout<<"safe"<<endl;}
    else {
        cout << "unsafe" << endl;
    }
}
int main() {
    int x,y;
    cin>>x>>y;
    comp(x,y);
    return 0;
}


Measured memory_bytes: 3624
n , k = map(int , input().split())
arr = []
for i in range(0 , n):
	arr.append(list(map(int , input().split())))
# sort according the element of the array first value
arr.sort()
cur =0
# continue to add the frequency of every element in increasing order upto k
for i in range(0 , n):
	if cur + arr[i][1]<k:
		cur = cur+arr[i][1]
	else:
		print(arr[i][0])
		exit()

Measured memory_bytes: 89792
import sys

s = sys.stdin.readline().rstrip()

def main():
    if s[0] == s[1]:
        return 1, 2
    for i in range(1, len(s)-1):
        if s[i-1] == s[i+1]:
            return i, i+2
        elif s[i] == s[i+1]:
            return i+1, i+2

    return -1, -1

if __name__ == '__main__':
    ans = main()
    print(*ans, sep=' ')

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

typedef long long ll;


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

    int N, K;

    cin >> N >> K;

    vector<ll> V(N);

    for(int i = 0; i < N; i++) {
        cin >> V[i];
    }

    ll max = 0;

    for(int i = 1; i <= K; i++) {
        for(int j = (i + 1) / 2; j <= i; j++) {
            if(N < j) {
                break;
            }
            for(int k = 0; k <= j; k++) {
                ll c = 0;
                vector<ll> x;
                for(int l = 0; l < k; l++) {
                    x.push_back(V[l]);
                    c += V[l];
                }
                for(int r = 0; r < j - k; r++){
                    x.push_back(V[N - 1 - r]);
                    c += V[N - 1 - r];
                }
                sort(x.begin(), x.end());

                for(int m = 0; m < i - j; m++) {
                    c -= x[m];
                }

                if(c > max) max = c;
            }
        } 
    }

    cout << max << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Akash
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARedOrNot solver = new ARedOrNot();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARedOrNot {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            String clr = in.nextLine();
            String s = in.nextLine();
            out.println(a < 3200 ? "red" : s);
        }

    }
}



Measured memory_bytes: 21716
#include <iostream>

int main() {
    int x, sum;
    x = 9;
    sum = 0;
    bool state = false;
    for (int i=0; i<5; i++) {
        int A;
        scanf("%d", &A);
        int y = A%10;
        if (x > y && y != 0) x = y;
        A = A-y;
        sum += A;
        if (y != 0) {
            sum += 10;
            state = true;
        }
    }
    if (state) sum += x-10;
    printf("%d\n", sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    
    auto f = [](int n, bool flag){
        int pre = n % 10;
        while(n/10){
            n /= 10;
        }
        int suf = n;
        if(flag) return pii(pre, suf);
        else return pii(suf, pre);
    };

    map<pii, int> m;
    REP(i, N){
        auto p = f(i+1, true);
        m[p]++;
    }

    ll ans = 0;
    REP(i, N){
        auto s = f(i+1, false);
        ans += m[s];
    }
    pr(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>    // find
using namespace std;

vector<int> pre, in, post;

// preorder の [fp, lp) の範囲と，inorder の [fi, li) の範囲について
// 木を postorder で表示
void recover(int fp, int lp, int fi, int li) {
    // preoder[fp] == inorder[root] となるような root を求める
    int root = distance(in.begin(), find(in.begin(), in.end(), pre[fp]));
    if (fi != root) {       // 左側が存在すれば
        recover(fp + 1, fp + 1 + (root - fi), fi, root);    // 左側を表示
    }
    if (root + 1 != li) {   // 右側が存在すれば
        recover(fp + 1 + (root - fi), lp, root + 1, li);    // 右側を表示
    }
    post.push_back(in[root]);   // root を表示
}

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int t; cin >> t; pre.push_back(t);
    }
    for (int i = 0; i < n; i++) {
        int t; cin >> t; in.push_back(t);
    }
    recover(0, n, 0, n);
    for (int i = 0; i < n; i++) {
        cout << post[i] << " \n"[i == n - 1];
    }
    return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    ll N; cin >> N;
    ll b = N;
    for (ll i = 2; i * i <= N; i++) {
        if (N % i == 0) b = N / i;
    }

    string s = to_string(b);
    int ans = s.size();

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3688
import java.io.*;

public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String buf;
        double weight;
        while((buf = br.readLine())!=null){
            weight = Double.parseDouble(buf);
            System.out.println(
                    weight <= 48.0 ? "light fly" : weight <= 51.0? "fly"
                    : weight <= 54.0 ?"bantam" :weight <=57.00?"feather"
                    : weight <= 60.0 ?"light" : weight <=64.00?"light welter"
                    : weight <= 69.0 ?"welter": weight <=75.00?"light middle"
                    : weight <= 81.0 ?"middle": weight <=91.00?"light heavy" : "heavy");
        }
    }
}

Measured memory_bytes: 9352
#include"bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> d(N);
	for (int i = 0;i < N;++i) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	int count = 1;
	for (int i = 1;i < N;++i) {
		if (d[i] != d[i - 1]) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func readInts(n int) []int64 {
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		x, _ := strconv.Atoi(sc.Text())
		a[i] = int64(x)
	}
	return a
}

func max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := readInts(n)
	sa := make([]int64, n+1)
	sb := make([]int64, n+1)
	for i := 0; i < n; i++ {
		sa[i+1] = sa[i] + a[i]
		sb[i+1] = sb[i] + max(a[i], 0)
	}
	ans := int64(-1 << 63)
	for i := 0; i <= n-k; i++ {
		sum := sb[n] - (sb[i+k] - sb[i]) + max(sa[i+k]-sa[i], 0)
		ans = max(ans, sum)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4736
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

const int MAXN = 200005;
const int INF = 1001001001;

int a[MAXN];

int n;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	int v = a[1], d = INF;
	for (int i = 1; i < n; i++)
		if (abs(2 * a[i] - a[n]) < d)
			d = abs(2 * a[i] - a[n]), v = a[i];
	cout << a[n] << " " << v << endl;
	return 0;
}


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

#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end();

ll gcd(ll a, ll b){
   if(b == 0) return a;
   
   return gcd(b, a % b);
}

using namespace std;


int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   int a,b,c,d;cin>>a>>b>>c>>d;
   if(a+b > c+d){
      cout << "Left";
   }else if(a+b < c+d){
      cout << "Right";
   }else{
      cout << "Balanced";
   }
   return 0;
}


Measured memory_bytes: 256
N, T = [int(a) for a in input().split()]

minc = 9999

for i in range(N):
    c, t = [int(a) for a in input().split()]
    if t <= T:
        minc = min(c, minc)

if minc == 9999:
    print("TLE")
else:
    print(minc)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D;
  cin >> D;
  vector<int> C(26);
   for (int i = 0; i < 26; i++) {
    cin >> C.at(i);
  }
  vector<vector<int>> S(D, vector<int>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> S.at(i).at(j);
    }
  }
  for (int i = 0; i < D; i++) {
    int memo = 0;
    int ans = 0;
    for (int j = 0; j < 26; j++) {
      if (S.at(i).at(j) > memo) {
        memo = S.at(i).at(j);
        ans = j + 1;
      }
    }
    cout << ans << endl; 
  }
}
  
  

Measured memory_bytes: 3688
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String card = "";
		int h;
		int m;
		ArrayList<String> al = new ArrayList<>();
		int cnt = 0;
		while(!(card.equals("-"))) {
			card = sc.next();
			char[] cardArray = card.toCharArray();
			if(card.equals("-")) {
				break;
			} else {
				m = sc.nextInt();
				for(int i = 0; i < m; i++) {
					h = sc.nextInt();
					char[] tmp = new char[h];
					for(int j = 0; j < h; j++) {
						tmp[j] = cardArray[j];
					}
					for(int k = 0; k < cardArray.length - h; k++) {
						cardArray[k] = cardArray[k + h];
					}
					for(int l = 0; l < h; l++) {
						cardArray[cardArray.length - h + l] = tmp[l];
					}
				}
				
			}
			cnt++;
			al.add(String.valueOf(cardArray));
		}
		for(int i = 0; i < cnt; i++) {
			System.out.println(al.get(i));
		}

	}
}

Measured memory_bytes: 26204
from functools import reduce

n, m = map(int, input().split())
if abs(n-m) > 1:
    print(0)
    exit()
mod = 10**9 + 7
mul_mod = lambda x, y : x*y % mod
ans = reduce(mul_mod, range(1, n+1)) * reduce(mul_mod, range(1, m+1)) % mod
if abs(n-m) == 0:
    ans *= 2
print(ans%mod)


Measured memory_bytes: 3572
using System;
using System.IO;

class Solve{
    static void Main(string[] args){
        var arr = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
        int M = arr[1], X = arr[2];
        var A = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var i = 0;
        for (; i < M; i++) 
            if (A[i] > X) break;
        var answer = i < M - i ? i : M - i;
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 27504
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int D; cin >> D;
	if (D == 25) cout << "Christmas" << endl;
	else if (D == 24) cout << "Christmas Eve" << endl;
	else if (D == 23) cout << "Christmas Eve Eve" << endl;
	else cout << "Christmas Eve Eve Eve" << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(x,y) for(ll i=x;i<y;i++)
#define vll vector<ll>
#define sll set<ll>
#define pb push_back
#define in insert
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define tc ll t;cin>>t;while(t--)
#define rev(x) reverse(all(x))
#define low_str(x) transform(all(x),x.begin(),::tolower)
#define up_str(x) transform(all(x),x.begin(),::toupper)
int main()
{
ll n;
cin>>n;
string s,t;
cin>>s>>t;
ll j=0;
rep(0,n+n)
{
    if(i%2==0)
        cout<<s[j];
    else
    {
        cout<<t[j];
        j++;
    }
}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s-1);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    ll x, y; cin>>x>>y;

    ll ans = 1, a = x;
    while (a * 2 <= y) {
        a *= 2;
        ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<int, ii>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define mp make_pair
#define fi first
#define se second
// #define multicase
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e3 + 5;

ll a, b, c, d;

void solve() {
    int T = 1;
  #ifdef multicase
    cin >> T;
  #endif
    while(T--) {
        cin >> a >> b >> c >> d;
        cout << max(a * c, max(b * d, max(a * d, b * c))) << "\n";
    }
}

int main() {
 
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
 
    solve();
 
}

Measured memory_bytes: 3652
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

class SlidingWindowAggretgation:
    def __init__(self, default = float("inf"), f = min):
        self.default = default
        self.f = f
        self.front_stack = deque()
        self.back_stack = deque()

    def get(self):
        res = self.default
        if self.front_stack:
            res = self.f(res, self.front_stack[-1][1])
        if self.back_stack:
            res = self.f(res, self.back_stack[-1][1])
        return res

    def append(self, x):
        fx = x
        if self.back_stack:
            fx = self.f(self.back_stack[-1][1], x)
        self.back_stack.append((x, fx))

    def popleft(self):
        if not self.front_stack:
            x, fx = self.back_stack.pop()
            self.front_stack.append((x, x))
            while self.back_stack:
                x, fx = self.back_stack.pop()
                fx = self.f(x, self.front_stack[-1][1])
                self.front_stack.append((x, fx))
        self.front_stack.pop()

def solve():
    n,l = LI()
    a = LI()
    swag = SlidingWindowAggretgation()
    ans = []
    for i in range(n):
        swag.append(a[i])
        if i+1 >= l:
            ans.append(swag.get())
            swag.popleft()
    print(*ans)
    return

#Solve
if __name__ == "__main__":
    solve()



Measured memory_bytes: 124640
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    int a,b;
    cin >> a;
    cin >> b;
    if(a<b){
        cout << "a < b";
    }else if(a>b){
        cout << "a > b";
    }else{
        cout << "a == b";
    }
    cout << endl;
}


Measured memory_bytes: 3084