akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int main(void){
    int count[4],a,b,i;
    int count2=0;

    for(i=0;i<4;i++){
        count[i]=0;
    }

    for(i=0;i<3;i++){
        cin>>a>>b;
        count[a-1]++;
        count[b-1]++;
    }

    for(i=0;i<4;i++){
        if(count[i] == 0){
            cout<<"NO"<<endl;
            return 0;
        }
        if(count[i] <= 1){
            count2++;
        }
    }
    
    if(count2 <= 2){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }


    

    return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> t(n), a(n);
    rep(i, 0, n) cin >> t[i];
    rep(i, 0, n) cin >> a[i];
    vector<bool> bt(n, false), ba(n, false);
    ll pre = t[0];
    bt[0] = true;
    rep(i, 1, n){
        if(pre != t[i]) bt[i] = true;
        pre = t[i];
    }
    pre = a[n-1];
    ba[n-1] = true;
    for(ll i = n-2; i >= 0; i--){
        if(pre != a[i]) ba[i] = true;
        pre = a[i];
    }
    vector<ll> mx(n);
    rep(i, 0, n){
        mx[i] = min(t[i], a[i]);
        if(bt[i] && mx[i] != t[i]){
            cout << 0 << endl;
            return 0;
        }
        if(ba[i] && mx[i] != a[i]){
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    rep(i, 0, n) {
        if(!bt[i] && !ba[i]) ans *= mx[i];
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  while(1) {
    int n, x, ans = 0;
    cin >> n >> x;
    if(n == 0 && x == 0) {
      break;
    }
    int tmp[n];
    rep(i, n) {
      tmp[i] = i + 1;
    }
    for(int i = 0; i < n; i++) {
      for(int j = i + 1; j < n; j++) {
        for(int k = j + 1; k < n; k++) {
          if(tmp[i] + tmp [j] + tmp[k] == x) {
            ans++;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3032
n,k = map(int,input().split(' '))

h = []

#print(n)
#print(k)

for i in range(n):

    h.append(int(input()))

h.sort()

min = 9999999999

#print(h)

for j in range(n):

    z = j + k-1

    if z > n-1:
        break

    sa = h[z] - h[j]

    #print(sa)

    if sa < min:

        min = sa


print(min)


Measured memory_bytes: 7384
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    cs
    int k,q,l,r,t,qq;string s;char c;
    cin>>k>>s>>q;
    vector<set<int>> v(26,set<int> {M});
    rep(i,k) {
        v[s[i]-'a'].insert(i);
    }
    while(q--) {
        cin>>qq;qq--;
        if(!qq) {
            cin>>l>>c;l--;
            if(s[l]==c) continue;
            v[s[l]-'a'].erase(l);
            v[c-'a'].insert(l);
            s[l]=c; 
        }
        else {
            cin>>l>>r;
            l--;r--;
            t=0;
            rep(i,26) {
                auto it=v[i].lower_bound(l);
                if(it!=v[i].end()&&*it<=r) t++;
            }
            cout<<t<<'\n';
        }
    }
}

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

using namespace std;

const int N = 13;
const int M = 1e3 + 1;

int c[M], keys[M];
int dp[M][1 << N];
int n, m, k;

int solve(int i, int mask) {
    if (i == m) {
        if (mask == (1 << n) - 1) {
            return 0;
        }
        return 1e9;
    }
    int& ans = dp[i][mask];
    if (ans != -1) {
        return ans;
    }
    ans = min(solve(i + 1, mask), solve(i + 1, mask | keys[i]) + c[i]);
    return ans;

}

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> c[i] >> k;
        while (k--) {
            int key;
            cin >> key;
            keys[i] |= (1 << (key - 1));
        }
    }
    memset(dp, -1, sizeof dp);
    int ans = solve(0, 0);
    if (ans >= 1e9) {
        cout << -1;
    } else {
        cout << ans;
    }
    return 0;
}


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

using namespace std;

const int INF = 1 << 29;

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  int find(int k)
  {
    return (data[k] < 0 ? k : data[k] = find(data[k]));
  }

  void unite(int x, int y)
  {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
  }
};

vector< pair< int, int > > g[100001];
vector< int > leftt[100001], rightt[100001], just[100001];
vector< int > gg[100001], rgg[100001], order;
bool v[100000];
int cmp[100000];


void dfs(int idx)
{
  if(v[idx]++) return;
  for(auto &to : gg[idx]) dfs(to);
  order.push_back(idx);
}

void rdfs(int idx, int k)
{
  cmp[idx] = k;
  for(auto &to : rgg[idx]) if(cmp[to] == -1) rdfs(to, k);
}


int rec(int idx, int back = -1)
{
  if(back != -1) {
    int tmp = max(leftt[idx][back], rightt[idx][back + 1]);
    if(tmp != INF) return (tmp);
  }
  if(rightt[idx][0] == INF) {
    for(int i = 0; i < g[idx].size(); i++) {
      int to, rev;
      tie(to, rev) = g[idx][i];
      if(i == back) continue;
      just[idx][i] = rec(to, rev) + 1;
    }
    for(int i = 0; i < g[idx].size(); i++) {
      leftt[idx][i + 1] = max(leftt[idx][i], just[idx][i]);
    }
    for(int i = (int) g[idx].size() - 1; i >= 0; i--) {
      rightt[idx][i] = max(rightt[idx][i + 1], just[idx][i]);
    }
  }
  if(back == -1) return (rightt[idx][0]);
  return (max(leftt[idx][back], rightt[idx][back + 1]));
}


int main()
{
  int N, M;
  vector< pair< int, int > > edges, arcs;

  scanf("%d %d", &N, &M);

  UnionFind uf(N);

  for(int i = 0; i < M; i++) {
    int x, y, t;
    cin >> x >> y >> t;
    --x, --y;
    if(t == 1) {
      arcs.emplace_back(x, y);
      g[x].emplace_back(y, -1);
    } else {
      if(uf.find(x) == uf.find(y)) {
        cout << "Infinite" << endl;
        return (0);
      }
      uf.unite(x, y);
      edges.emplace_back(x, y);
      g[y].emplace_back(x, g[x].size());
      g[x].emplace_back(y, g[y].size() - 1);
    }
  }

  {
    for(auto &e : arcs) {
      gg[uf.find(e.first)].push_back(uf.find(e.second));
      rgg[uf.find(e.second)].push_back(uf.find(e.first));
    }
    for(int i = 0; i < N; i++) dfs(i);
    reverse(begin(order), end(order));
    memset(cmp, -1, sizeof(cmp));
    int kk = 0;
    for(auto &i : order) if(cmp[i] == -1) rdfs(i, kk++);
    if(kk != N) {
      cout << "Infinite" << endl;
      return (0);
    }
  }


  int ret = 0;
  for(int i = 0; i < N; i++) {
    int sz = g[i].size();
    just[i].assign(sz, INF);
    leftt[i].assign(sz + 1, INF);
    rightt[i].assign(sz + 1, INF);
    leftt[i][0] = rightt[i][sz] = 0;
  }
  for(int i = 0; i < N; i++) ret = max(ret, rec(i));
  cout << ret << endl;
}

Measured memory_bytes: 38784
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl

ll n, cnt, ans, a, b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k;
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s, ss;
bool fl;
struct edge
{
    int to, cost;
};

//-------------------------↓↓↓↓↓↓------------------------

std::vector<ll> enum_div(ll n) //nの約数を列挙
{
    std::vector<ll> ret;
    for (ll i = 1; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i != 1 && i * i != n)
            {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

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

    cin >> n;
    std::vector<ll> r = enum_div(n);
    s = to_string(n);
    ans = Size(s);
    for (auto i : r)
    {
        a = i;
        b = n / i;
        s = to_string(a);
        ss = to_string(b);
        ans = min(max((ll)Size(s), (ll)Size(ss)), ans);
    }
    Cout(ans);
    return 0;
}


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

#define OUT(x)  cerr << #x << " = " << x << endl;
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define piii    pair<int, pair<int, int>>

vector<int> g[10];
bool used[10];
int n;
int ans = 0;

void dfs(int v, int cnt) {
        if (cnt == n) {
                ans ++;
                return;
        }
        for (int u : g[v]) if (!used[u]) {
                used[u] = true;
                dfs(u, cnt + 1);
                used[u] = false;
        }
}
                                   
int main() {
        int i, j;
        int m;
        cin >> n >> m;
        for (i = 0; i < m; i ++) {
                int a, b;
                cin >> a >> b;
                a --, b --;
                g[a].push_back(b);
                g[b].push_back(a);
        }
        used[0] = true;
        dfs(0, 1);
        cout << ans << endl;
        return 0;
}



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

int fibonacci (int n) {
    if (n < 2) return n;
    else return fibonacci(n - 2) + fibonacci(n - 1);
}

void printSmile () {
    cout << ":)" << endl;
}

void printVectorBool (vector<bool> b) {
    for (int i = 0; i < b.size(); i++) {
        if (i == b.size() - 1)
            cout << b[i] << endl;
        else
            cout << b[i] << " ";
    }
    b['e' - 'a'] = false;
}

int pow (int base, int exp) {
    int r = 1;
    for(int i = 0; i < exp; i++){
        r *= base;
    
    }
return r;
}

int main () {
    int a, b;
    cin >> a >> b;
    if ( a - 2*b < 0){cout << 0 << endl;}
    else cout << a - 2*b << endl;
}

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

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<" "; out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define range(v)                v.begin(),v.end()
#define w(x)                    while(x--)
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

class BCommonRaccoonVsMonster {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int h,n;
	    s2(h,n);
	    int sum = 0;
	    f(i,0,n){
	        int v;
	        s(v);
	        sum+=v;
	    }
	    out<<(sum>=h?"Yes":"No")<<endl;

	}
};


integer main() {
	BCommonRaccoonVsMonster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

int main()
{
    int now = 0;
    string str;
    cin >> str;

    for (char ch : str)
        if (ch == '+')
            ++now;
        else --now;
    cout << now;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,M,a=0,b=0;
    cin>>N>>M;
    for(int i=1;i<N;i++){
        a+=i;
    }
    for(int i=1;i<M;i++){
        b+=i;
    }
    cout<<a+b<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	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);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	//sort(a.begin(),a.end());
	int x, a;
	cin >> x >> a;
	if (x < a) cout << 0;
	else cout << 10;
	return 0; 
}









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

using namespace std;

typedef pair<int, int> point;

int main(int argc, char *argv[]) {
	int N;
	vector<point> reds;
	vector<point> blues;

	cin >> N;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		reds.push_back(point(a, b));
	}

	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		blues.push_back(point(a, b));
	}

	sort(blues.begin(), blues.end());
	sort(reds.begin(), reds.end());

	int cnt = 0;
	for (point &b : blues) {
		int idx = -1;
		int max = -1;

		for (int i = 0; i < reds.size(); i++) {
			if (reds[i].first == -1) continue;;
			if (reds[i].first > b.first) break;
			if (reds[i].second > max && reds[i].second < b.second) {
				idx = i;
				max = reds[i].second;
			}
		}

		if (idx != -1) {
			reds[idx] = point(-1, -1);
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
# じゃあ全部保存していってやるよ
# atcoderのpython3のバージョンが古すぎて(3.4.3)TypeError: unhashable type: 'list'なるのでため息つきながら直した

n = int(input())
d = {}
arr = []
for _ in range(n):
    x = "".join(list(map(str, list(sorted(input())))))
    arr.append(x)
    if x not in d:
        d[x] = 1
    else:
        d[x] += 1

c = 0
for a in arr[:0:-1]:
    if d[a] > 0:
        c += d[a] - 1
        d[a] -= 1

print(c)


Measured memory_bytes: 18564
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define int ll
using pint = pair<int,int>;
using Graph = vector<vector<int>>;
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 1e10; //10^10
const double PI = acos(-1.0L);
const int dx[4] = {1, 0, -1, 0} , dy[4] = {0, 1, 0, -1};
/*mod逆元*/long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
template< typename T >T mod_pow(T x, T n, T p=MOD) {T ret = 1;while(n > 0) {if(n & 1) (ret *= x) %= p;(x *= x) %= p;n >>= 1;}return ret;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}

//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b; cin >> a >> b;
    Yn(a==b);

    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc134/tasks/abc134_c

#include <bits/stdc++.h>
using namespace std;

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

    vector<long> b(n);
    for (long i = 0; i < n; i++)
    {
        b[i] = a[i]; // copy
    }
    sort(b.begin(), b.end(), greater<long>());
    long first = b[0];
    long second = b[1];

    for (long i = 0; i < n; i++)
    {
        if (a[i] == first)
        {
            cout << second << endl;
        }
        else
        {
            cout << first << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()
// int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}

using namespace std;

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();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

long long m = 1e9+7, mod = 1e9+7;
//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

//約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


int main() {
  int A,B;
  cin >> A >> B;
  cout << 6 - A - B << endl;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;
#define debug(x) cerr << #x << ": " << (x) << "\n";

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
};

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
};

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

  int n;
  cin >> n;
  vi v(100005, 0);
  int a;
  rep(i, 0, n) {
    cin >> a;
    a++;
    v[a-1]++;
    v[a]++;
    v[a+1]++;
  }
  int ans = 0;
  rep(i, 0, v.size()) {
    ans = max(ans, v[i]);
  }

  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 640
H, W = map(int, input().split())
a = []
for i in range(H):
    a.append(list(input()))

row = [False] * H
col = [False] * W

for i in range(H):
    for j in range(W):
        if a[i][j] == '#':
            row[i] = True
            col[j] = True

for i in range(H):
    if row[i]:
        for j in range(W):
            if col[j]:
                print(a[i][j], end='')
        print()


Measured memory_bytes: 4596
//t秒間で初速V0, 最高速度Vm, 最終速度V1で走るときの最大の速度を求める
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

double area(double v0, double v1, double vm, double t){
    //(0, v0)から傾き1の直線を引き、(t, v1)から傾き-1の直線を引き、その交点を(tp, vp)とする。
    double tp = (t + v1 - v0)/2.0; 
    double vp = (t + v1 + v0)/2.0;
    if(vp > vm) {
        return vm * t - (vm - v0)*(vm - v0)/2.0 - (vm - v1)*(vm - v1)/2.0;
    }
    else {
        return vp*t - tp*tp/2.0 - (t - tp)*(t - tp)/2.0;
    }
}

int main()
{
    int N;
    cin >> N;
    int t[N+1], v[N+1];
    for(int i = 1; i <= N; ++i) cin >> t[i];
    for(int i = 1; i <= N; ++i) cin >> v[i];
    t[0] = 0; v[0] = 0;

    int kv[N+1]; // kv[i] -- 区間iが終わるときの終速度
    kv[0] = 0, kv[N] = 0;
    for(int i = 1; i < N; ++i) {
        kv[i] = min(kv[i-1] + t[i], min(v[i], v[i+1]));
    }
    for(int i = N-1; i > 0; --i) {
        kv[i] = min(kv[i+1] + t[i+1], kv[i]);
    }

    /*
    for(int i = 0; i <= N; ++i) cout << kv[i] << " ";
    cout << endl;
    */
    double res = 0;
    for(int i = 1; i <= N; ++i) {
        res += area(kv[i-1], kv[i], v[i], t[i]);
    }
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N, C = sc.nextInt()
    val A, B = map(N)(_ => sc.nextInt())
    val X = Array.ofDim[Long](401, C + 1)
    for {
      i <- 0 to 400
      j <- 0 to C
    } X(i)(j) = pow_mod(i, j, MOD)

    for {
      i <- 1 to 400
      j <- 0 to C
    } {
      X(i)(j) += X(i - 1)(j)
      X(i)(j) %= MOD
    }

    val dp = Array.ofDim[Long](N + 1, C + 1)
    dp(0)(0) = 1
    for {
      i <- 0 until N
      j <- 0 to C
      k <- 0 to j
    } {
      dp(i + 1)(j) += dp(i)(j - k) * (X(B(i))(k) - X(A(i) - 1)(k) + MOD)
      dp(i + 1)(j) %= MOD
    }

    val ans = dp(N)(C)
    out.println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

  private def rep(n: Int)(f: Int => Unit): Unit = (0 until n) foreach f

  private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    (0 until n) foreach (i => res(i) = f(i))
    res
  }

  private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(a => map.getOrElseUpdate(f(a), ArrayBuffer()) += a)
      map
    }

    def rep(f: A => Unit): Unit = {
      as.indices foreach (i => f(as(i)))
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(a => sum = num.plus(sum, f(a)))
      sum
    }
  }

  private implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }

  def pow_mod(x: Int, n: Int, m: Int): Int = {
    def step(x0: Long, n0: Int): Long = {
      n0 match {
        case 0 => 1
        case _ =>
          val r = step(x0 * x0 % m, n0 / 2)
          if (n0 % 2 == 1) r * x0 % m else r
      }
    }
    step(x.toLong, n).toInt
  }
}


Measured memory_bytes: 43992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll N, M;
    cin >> N >> M;

    ll innerN = 0;
    ll innerM = 0;
    if(N >= 3){
        innerN = N - 2;
    }else if(N == 1) {
        innerN = 1;
    }
    if(M >= 3){
        innerM = M - 2;
    }else if(M == 1) {
        innerM = 1;
    }

    cout << (innerN * innerM) << endl;

    return 0;
}

Measured memory_bytes: 256
// Digit Number
#include <stdio.h>

int main(void)
{
	int a, b;
	int output;
	
	while(scanf("%d %d", &a, &b) != EOF){
		a += b;
		b = 10;
		output = 1;
		
		while (a >= b){
			output++;
			b *= 10;
		}
		
		printf("%d\n", output);
	}
	return (0);
}

Measured memory_bytes: 0
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	if a+b == c+d {
		fmt.Println("Balanced")
		return
	}
	if a+b > c+d {
		fmt.Println("Left")
		return
	}
	fmt.Println("Right")
}


Measured memory_bytes: 512
//In The Name Of The God

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define F first
#define S second
#define X first.first
#define Y first .second
#define A second.first
#define B second.second
#define mp make_pair
#define pb push_back
#define pf push_front
#define P push
#define pob pop_back
#define pof pop_front
#define PO pop
#define rep(i,j,k) for(int i = j ; i <= k ; ++ i)
#define rrep(i,j,k) for(int i = j ; i>=k ; --i)
#define FR(i,j,k) for(int i = j ; i < k ; ++ i )
#define rFR(i,j,k) for(int i = j ; i > k ; -- i )
#define lb(x) x&-x;
#define SZ size()
#define LB lower_bound
#define UB upper_bound
#define IT iterator
#define RIT reverse_iterator
#define E end()
#define BE begin()
#define RE rend()
#define RBE rbegin()
#define UN unsigned

typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll ;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<int,pll> pipl;
typedef pair<pll,int> ppli ;
typedef pair<pll,pll> plpl ;
typedef pair<ll,pii> lpip;
typedef pair<pii,ll> lppi;
typedef pair<pii,pii> lppp;
typedef pair<ll,pll> lpipl;
typedef pair<pll,ll> lppli ;
typedef pair<pll,pll> lplpl ;
typedef vector<int> vi ;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii > stpi;
typedef set<pll> stpl;
typedef vi::IT vit;
typedef vl::IT vlt;
typedef vpi::IT vpit;
typedef vpl::IT vplt;
typedef sti::IT stit;
typedef stl::IT stlt;
typedef stpi::IT stpit;
typedef stpl::IT stplt;
typedef vpi::RIT rvpit;
typedef vpl::RIT rvplt;
typedef sti::RIT rstit;
typedef stl::RIT rstlt;
typedef stpi::RIT rstpit;
typedef stpl::RIT rstplt;

const int MAXN = 500000;
const int SUPERN = 5000000;
const int MD = 1e9+7;
//......Variables........
ll n,a[MAXN],mn,re,s;
bool f;
//......Funcs............

//......Code.............
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n;
    rep(i,1,n)cin>>a[i];
    f=true;
    rep(i,1,n)
    {
        s+=a[i];
        if(f)
        {
            f=!f;
            if(s>0)continue;
            re+=1-s;
            s+=1-s;
        }
        else
        {
            f=!f;
            if(s<0)continue;
            re+=s+1;
            s-=s+1;
        }
    }
    mn=re;
    f=false;
    re=s=0;
    rep(i,1,n)
    {
        s+=a[i];
        if(f)
        {
            f=!f;
            if(s>0)continue;
            re+=1-s;
            s+=1-s;
        }
        else
        {
            f=!f;
            if(s<0)continue;
            re+=s+1;
            s-=s+1;
        }
    }
    mn=min(mn,re);
    cout<<mn;
    return 0;
}


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

// In ASCII, the upper case begin with num in 65,
// while the lower case begin with 97.

int main() {
    //freopen("in.txt", "r", stdin);

    char tmp, a[1201] = {'0'};
    int len = 0;

    while ((tmp = getchar()) != '\n' && tmp != -1) {
        if (tmp >= 65 && tmp <= 90) {  // is upper case
            a[len++] = (char) tmp + 32;
        } else if (tmp >= 97 && tmp <= 122) {  // is lower case
            a[len++] = (char) tmp - 32;
        } else {
            a[len++] = (char) tmp;
        }
    }
    for (int i = 0; i < len; ++i) {
        cout << a[i];
    }
    cout << endl;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int par[100010], sz[100010];
void init(int n) {
  rep(i,n)
  {
    par[i] = i;
    sz[i] = 1;
  }
}
int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y)
    return;
  par[y] = x;
  sz[x] += sz[y];
}
bool same(int x, int y) {
  return find(x) == find(y);
}
int size(int x) {
  return sz[find(x)];
}
int main() {
  ll n, m;
  cin >> n >> m;
  vector<pair<int, int>> p(m);
  ll ans[m];
  rep(i,m)
    scanf("%d%d", &p[i].first, &p[i].second);
  init(n + 1);
  ll now = n * (n - 1) / 2;
  ans[m - 1] = now;
  for (int i = m - 1; i > 0; i--) {
    if (!same(p[i].first, p[i].second)) {
      now -= size(p[i].first) * size(p[i].second);
      unite(p[i].first, p[i].second);
    }
    ans[i - 1] = now;
  }
  rep(i,m)
    cout << ans[i] << endl;
}


Measured memory_bytes: 3712
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<string>
typedef long long ll;
typedef unsigned long long llu;
#define Q 1000000007

ll powmod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) {
		res = res * x % Q;
	}
	return res;
}

int main() 
{
	int n;

	int d[100][2];
	scanf("%d", &n);
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &d[i][0]);
		scanf("%d", &d[i][1]);
		if (d[i][0] == d[i][1]) {
			if (++cnt == 3) {
				printf("Yes\n");
				return 0;
			}
		}
		else {
			cnt = 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

struct edge {
    int from, cost;
};

int n, m, p, a, b, c;
vector<edge> G[3000];
bool ok[3000];

void dfs(int x) {
    ok[x] = 1;
    for(auto [y, ignore] : G[x])
        if(!ok[y]) dfs(y);
}

int d[3000];

bool BellmanFord(int s) {
    fill(ALL(d), 1 << 30);

    d[s] = d[n] = 0;
    bool update;
    rep(i, n) {
        update = false;
        rep(j, n) {
            if(!ok[j + 1]) continue;
            for(auto [from, cost] : G[j + 1]) {
                if(d[from] == 1 << 30) continue;
                if(chmin(d[j + 1], d[from] + cost)) update = true;
            }
        }
        if(!update) break;
    }
    return update;
}

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

    cin >> n >> m >> p;

    rep(i, m) {
        cin >> a >> b >> c;
        G[b].push_back(edge{a, p - c});
    }

    dfs(n);

    if(BellmanFord(1))
        cout << -1 << endl;
    else
        cout << -d[n] << endl;

    return 0;
}

Measured memory_bytes: 3848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 2e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;
 
template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

map<ll,ll> memo;

ll solve(ll a,ll b,ll c,ll d,ll cnt) {
    if(cnt == 0) {
        return 0;
    }
    if(cnt == 1) {
        return d;
    }
    if(memo.count(cnt)) {
        return memo[cnt];
    }
    ll res = INF;
    if(cnt < res / d) {
        res = cnt * d;
    }
    res = min(res,d * llabs((cnt / 5) * 5 - cnt) + c + solve(a,b,c,d,cnt / 5));
    res = min(res,d * llabs(((cnt + 4) / 5) * 5 - cnt) + c + solve(a,b,c,d,(cnt + 4) / 5));
    res = min(res,d * llabs((cnt / 3) * 3 - cnt) + b + solve(a,b,c,d,cnt / 3));
    res = min(res,d * llabs(((cnt + 2) / 3) * 3 - cnt) + b + solve(a,b,c,d,(cnt + 2) / 3));
    res = min(res,d * llabs((cnt / 2) * 2 - cnt) + a + solve(a,b,c,d,cnt / 2));
    res = min(res,d * llabs(((cnt + 1) / 2) * 2 - cnt) + a + solve(a,b,c,d,(cnt + 1) / 2));
    memo[cnt] = res;
    return res;
}

int main() {
    int T;
    cin >> T;
    for(int i = 0;i < T;i++) {
        ll N,A,B,C,D;
        cin >> N >> A >> B >> C >> D;
        cout << solve(A,B,C,D,N) << endl;
        memo.clear();
    }
}

Measured memory_bytes: 4360
word = input()
if word == 'SSS':
  print(0)
if word == 'SSR':
  print(1)
if word == 'SRS':
  print(1)
if word == 'RSS':
  print(1)
if word == 'SRR':
  print(2)
if word == 'RRS':
  print(2)
if word == 'RSR':
  print(1)
if word == 'RRR':
  print(3)


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

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

    while (1) {
        int n;
        cin >> n;
        if (!n) break;
        vector<int> imosu(90000, 0);
        for (int i = 0; i < n; i++) {
            string start, end;
            cin >> start >> end;
            int s = stoi(start.substr(0, 2)) * 3600 + stoi(start.substr(3, 2)) * 60 + stoi(start.substr(6, 2));
            int e = stoi(end.substr(0, 2)) * 3600 + stoi(end.substr(3, 2)) * 60 + stoi(end.substr(6, 2));
            imosu[s] += 1;
            imosu[e] -= 1;
        }
        for (int i = 1; i < imosu.size(); i++) {
            imosu[i] = imosu[i] + imosu[i - 1];
            // cout << imosu[i - 1];
        }
        // cout << endl;
        int ans = 0;
        for (auto i : imosu)
            ans = max(i, ans);
        cout << ans << endl;
    }
}


Measured memory_bytes: 3568
n,x= map(int,input().split())
m = []
for i in range(n):
    a = int(input())
    m.append(a)
m.sort()
ans = 0
for i in range(n):
     x -= m[i]
     ans += 1
while x >= 0:
    x -= m[0]
    ans += 1
print(ans-1)



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

int main(){

    int N;
    cin >> N;

    N %= 1000;

    if (N == 0) cout << '0' << endl;
    else cout << 1000 - N << endl; 

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
 
  if ((a+b) == (c+d)) {
    cout << "Balanced" << endl;
  } else {
    if ((a+b) < (c+d)) {
      cout << "Right" << endl;
    } else {
      cout << "Left" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, H: "List[int]"):
    
    # 可能な限り低くしておく前処理
    for i in range(1, N):
        if(H[i] - H[i-1] >= 1):
            H[i] -= 1
        elif(H[i] == H[i-1]):
            continue
        else:
            print(NO)
            exit()

    # 判定
    t = 0
    for i in range(N):
        if(H[i] < t):
            print(NO)
            exit()
    
    print(YES)

    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, H)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15288
#include <iostream>
#include <vector>
#include <map>
#include <string>
using namespace std;

    typedef long long ll;
    ll comb(ll n , ll r){
    //cout << "comb_n:" << n << " comb_r:" << r << endl;
    if(n < 0 || r < 0 || r > n){
    cout << "comb-error" << endl;
    }
    if(n - r < r) r = n - r;
    if(r == 0) return 1;
    if(r == 1) return n;
    vector<ll> num, deno;
    for(ll k = 0 ; k < r; k++){
    num.push_back(n-r+k+1);
    deno.push_back(k+1);
    }
    ll pivot , offset;
     for(ll p = 2; p <= r ; p++){
    pivot = deno[p-1];
    if(pivot > 1){
    offset = (n - r) % p;
    for(ll k = p - 1 ; k < r; k+= p){
    num[k - offset] /= pivot;
    deno[k] /= pivot; 
    }
    }
    }
    ll result = 1;
    for(ll k = 0; k < r ; k++){
    if(num[k] > 1) result *= num[k];
    result = result;
    }
    //cout << "comb:" << result << endl;
    return result;
    }



int main()
{
    long n ;
    vector<long> v;
    cin >> n ;
    ll ans = 0;
    string s , key;
    map<string , int> ma;
    for(long i = 0 ; i < n ; i++){
        cin >> s;
        map<char, int> ma2;
        key = "";
        for(int k = 0 ; k < 10 ; k++){
            ma2[s[k]] += 1;
        }
        for(auto itr3 = ma2.begin(); itr3 != ma2.end(); ++itr3) {
            key = key + itr3->first + to_string(itr3->second) ; 
        }
        ma[key] += 1;
    }
    for(auto itr4 = ma.begin(); itr4 != ma.end(); ++itr4) {
        if(itr4->second > 1){
            ans += comb(itr4->second , 2);
        } 
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13568
N = int(input())

# {city1 : {(p1, n1), ...},...}
d = {}

for n in range(N):
  S, P = input().split()
  P = int(P)

  if S not in d:
    d[S] = {P: n+1}
  else:
    d[S][P] = n+1

keys = d.keys()
keys = list(keys)
keys.sort()

for k in keys:
  lis = d[k]
  
  ks = list(lis.keys())
  ks.sort()
  ks.reverse()
  for t in ks:
    print(lis[t])


Measured memory_bytes: 3060
using System;
using System.Linq;

namespace _1_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine((x[0] * x[1]).ToString()+" "+((x[0]+x[1])*2).ToString());
        }
    }
}

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

typedef pair<long long, long long> ii;

int main(){
	//freopen("i.txt","r",stdin);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	
	if(n % 2 == 1){
		cout << "No\n";
		return 0;
	}
	
	int h = n/2;
	for(int i = 0;i < h;i++){
		if(s[i] != s[i+h]){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}


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

typedef long long LL;
inline LL sqr(const LL &v) { return v * v; }

struct PT
{
	LL x, y;
	PT(LL x = 0, LL y = 0) : x(x), y(y) {}
	PT operator+(const PT &d) const { return PT(x + d.x, y + d.y); }
	PT& operator+=(const PT &d) { x += d.x, y += d.y; return *this; }
	PT operator-(const PT &d) const { return PT(x - d.x, y - d.y); }
	PT& operator-=(const PT &d) { x -= d.x, y -= d.y; return *this; }
	bool operator<(const PT &o) { return x != o.x ? x < o.x : y < o.y; }
};

LL norm2(const PT &v) { return sqr(v.x) + sqr(v.y); }
LL norm2(const PT &p1, const PT &p2) { return norm2(p1 - p2); }
LL vect(const PT &v1, const PT &v2) { return v1.x * v2.y - v2.x * v1.y; }
LL vect(const PT &p, const PT &p1, const PT &p2) { return vect(p1 - p, p2 - p); }

const int maxn = 100100;
int n, hn1, hn2, xn, x[maxn];
LL area, db1[maxn], db2[maxn];
PT p[maxn], h1[maxn], h2[maxn];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) scanf("%lld%lld", &p[i].x, &p[i].y), x[xn++] = p[i].x;
	sort(p, p + n);
	sort(x, x + xn), xn = unique(x, x + xn) - x;
	hn1 = hn2 = area = 0;
	for (int i = 0, j; i < n;) {
		for (j = i; j < n; ++j) {
			if (p[i].x != p[j].x) break;
			for (; hn1 >= 2 && vect(h1[hn1 - 2], h1[hn1 - 1], p[j]) <= 0; --hn1)
				area -= vect(h1[hn1 - 2], h1[hn1 - 1]);
			if (hn1) area += vect(h1[hn1 - 1], p[j]);
			h1[hn1++] = p[j];
			for (; hn2 >= 2 && vect(p[j], h2[hn2 - 1], h2[hn2 - 2]) <= 0; --hn2)
				area -= vect(h2[hn2 - 1], h2[hn2 - 2]);
			if (hn2) area += vect(p[j], h2[hn2 - 1]);
			h2[hn2++] = p[j];
		}
		int id = lower_bound(x, x + xn, p[i].x) - x + 1;
		db1[id] = area;
		i = j;
	}
	hn1 = hn2 = area = 0;
	for (int i = n - 1, j; i >= 0;) {
		for (j = i; j >= 0; --j) {
			if (p[i].x != p[j].x) break;
			p[j].x = -p[j].x;
			for (; hn1 >= 2 && vect(h1[hn1 - 2], h1[hn1 - 1], p[j]) <= 0; --hn1)
				area -= vect(h1[hn1 - 2], h1[hn1 - 1]);
			if (hn1) area += vect(h1[hn1 - 1], p[j]);
			h1[hn1++] = p[j];
			for (; hn2 >= 2 && vect(p[j], h2[hn2 - 1], h2[hn2 - 2]) <= 0; --hn2)
				area -= vect(h2[hn2 - 1], h2[hn2 - 2]);
			if (hn2) area += vect(p[j], h2[hn2 - 1]);
			h2[hn2++] = p[j];
			p[j].x = -p[j].x;
		}
		int id = lower_bound(x, x + xn, p[i].x) - x + 1;
		db2[id] += area;
		i = j;
	}
	LL ans = 8e18;
	for (int i = 0; i <= xn; ++i) ans = min(ans, db1[i] + db2[i + 1]);
	printf("%lld\n", (ans + 1) / 2);
	return 0;
}


Measured memory_bytes: 9932
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

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

	int n, k;
	cin >> n >> k;
	int result = 0;
	for (int i = 0; i < n; i++)
	{
		int h; cin >> h;
		if (h >= k)
			result++;
	}
	cout << result << endl;

	return 0;
}

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


int main(){
    long long n;
    cin >> n;
    int note = 100;
    for (int i=1; i <= sqrt(n)+1;i++){
        if (n%i == 0){
			long long a = n/i;
			int b = to_string( max((long long)i,a) ).length();
			note = min(note,b);
        }
    }
    cout << note << endl;
}

Measured memory_bytes: 3712
MOD = 10**9+7
S=input()
dp_old=[0]*13
dp_new=[0]*13
dp_old[0]=1
for c in S:
    if c == '?':
        for i in range(10):
            for j in range(13):
                dp_new[(j*10+i)%13]+=dp_old[j]
    else:
        for i in range(13):
            dp_new[(i*10+int(c))%13]+=dp_old[i]
    dp_old = [i%MOD for i in dp_new]
    dp_new = [0]*13
print(dp_old[5])


Measured memory_bytes: 43244
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

ll f(ll b, ll n) {
    if (n < b) return n;
    else return f(b, n / b) + n % b;
}

int main()
{
    ll n, s;
    cin >> n >> s;
    if (n == s) {
        cout << n + 1 << endl;
        return 0;
    }
    else if (n < s) {
        cout << -1 << endl;
    }
    else {
        for (ll b = 2; b * b <= n; b++) {
            if (f(b, n) == s) {
                cout << b << endl;
                return 0;
            }
        }
        ll ip = sqrt(n) / 1;
        if (ip * ip == n) ip--;
        for (ll p = ip; p >= 1; p--) {
            if ((n - s) % p == 0 && n - s > 0) {
                ll b = (n - s) / p + 1;
                if (b >= 2 && f(b, n) == s) {
                    cout << b << endl;
                    return 0;
                }
            }
        }
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256