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

using namespace std;

int n;
int a[101][101];
int flg[101];
int t[101];
int sum = 0;

void visit(){
    int ima = 0;
    int mine = 100000000;
    for (int k = 0; k < n-1; k++) {
        mine = 10000000;
        for (int i = 0; i < n; i++) {
            if (flg[i] == 0 && mine > t[i]) {
	            mine = t[i];
	            ima = i;
            }
        }
        sum += mine;
        flg[ima] = 1;
        for (int i = 0; i < n; i++){ 
            if (a[ima][i] != -1){ 
	            if (t[i] > a[ima][i]){
	                t[i] = a[ima][i];
	            }
            }
        }
    }
}

int main() {
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){ 
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < n; i++) {
        flg[i] = 0;
        t[i] = 100000000;
    }
    t[0] = 0;
    flg[0] = 1;
    for(int i = 0; i < n;i++){ 
        if(a[0][i] != -1){
            t[i] = a[0][i];
        }
    }
    visit();
    cout << sum << endl;
    return 0; 
}


Measured memory_bytes: 3124
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = input[0];
            int B = input[1];
            Console.WriteLine(B % A == 0 ? A + B : B - A);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <queue>
#include <cstdlib>
using namespace std;

const int INF = 1 << 30;

class State
{
public:
  int p, y, j, d;
  State(int _p, int _y, int _j, int _d)
    :p(_p), y(_y), j(_j), d(_d) {}
  bool operator < (const State& st) const
  {
    return this->d > st.d;
  }
};

int main()
{
  int n, m;
  while (cin >> n >> m) {
    if ((n|m) == 0)
      break;

    vector<vector<pair<int, int> > > s(n);
    for (int i = 0; i < n; ++i) {
      int k;
      cin >> k;
      for (int j = 0; j < k; ++j) {
	int x, d;
	cin >> x >> d;
	s[i].push_back(make_pair(x, d));
      }
    }

    priority_queue<State> que;
    for (int i = 0; i < s[0].size(); ++i)
      que.push(State(i, 0, 0, 0));
    if (m > 0) {
      for (int i = 0; i < s[1].size(); ++i)
	que.push(State(i, 1, 1, 0));
    }

    vector<vector<vector<int> > > dp(n, vector<vector<int> >(10, vector<int>(m+1, INF)));
    while (!que.empty()) {
      const State st = que.top();
      que.pop();

      if ((st.y == n-2 && st.j < m) || st.y == n-1) {
	cout << st.d << endl;
	break;
      }

      if (dp[st.y][st.p][st.j] < st.d)
	continue;
      dp[st.y][st.p][st.j] = st.d;

      for (int i = 0; i < s[st.y+1].size(); ++i) {
	int danger = st.d + (s[st.y][st.p].second + s[st.y+1][i].second) * abs(s[st.y][st.p].first - s[st.y+1][i].first);
	if (dp[st.y+1][i][st.j] > danger) {
	  dp[st.y+1][i][st.j] = danger;
	  que.push(State(i, st.y+1, st.j, danger));
	}
      }

      if (st.j < m && st.y+2 < n) {
	for (int i = 0; i < s[st.y+2].size(); ++i) {
	  int danger = st.d + (s[st.y][st.p].second + s[st.y+2][i].second) * abs(s[st.y][st.p].first - s[st.y+2][i].first);
	  if (dp[st.y+2][i][st.j+1] > danger) {
	    dp[st.y+2][i][st.j+1] = danger;
	    que.push(State(i, st.y+2, st.j+1, danger));
	  }
	}   
      }
    }
  }
  return 0;
}

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

typedef long long ll;
int main()
{
    string str;
    cin>>str;
    if(str=="Sunny")
    {
        cout<<"Cloudy"<<endl;
    }
    else if(str=="Cloudy")
    {
        cout<<"Rainy"<<endl;
    }
    else if(str=="Rainy")
    {
        cout<<"Sunny"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
# Aizu Problem 0205: Rock Paper Scissor
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

        
while True:
    try:
        game = [int(input()) for _ in range(5)]
    except EOFError:
        break
    if 1 in game and 2 in game:
        w = 1
    elif 1 in game:
        w = 3
    else:
        w = 2
    if len(set(game)) != 2:
        for g in game:
            print(3)
    else:
        for g in game:
            print(1 if g == w else 2)

Measured memory_bytes: 7692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



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

  ll n,k=0;cin>>n;
  vector<vector<ll> > e(n,vector<ll>());
  vector<PL> v(n-1);
  map<PL,int> ma;
  vector<bool> used(n,false);

  rep(i,0,n-1){
    int a,b;cin>>a>>b;a--;b--;
    v[i]={a,b};
    e[a].pb(b);
    e[b].pb(a);
  }

  queue<int> q;
  q.push(0);
  q.push(n);
  used[0]=true;
  while(!q.empty()){
    int now=q.front();
    q.pop();
    int mae=q.front();
    q.pop();

    int iro=1;
    rep(i,0,siz(e[now])){
      int next=e[now][i];

      if(!used[next]){
        used[next]=true;
        q.push(next);
        if(iro==mae)iro++;
        q.push(iro);
        chmax(k,iro);
        ma[{now,next}]=iro;
        iro++;
      }
    }
  }

  cout<<k<<endl;
  rep(i,0,n-1){
    cout<<ma[v[i]]<<endl;
  }
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define ABS(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x)))

#define MOD(x, y) ((x) % (y))
#define DIVCEIL(x, y) (((x) + ((y) - 1)) / (y))
#define DIVFLOOR(x, y) (((x) + ((y) / 2)) / (y))
#define DIVROUND(x, y) ((x) - MOD(x, y) >= MOD(x, y) ? DIVCEIL(x, y) : DIVFLOOR(x, y))

int main() {
  int K, S;
  cin >> K >> S;

  int count{};
  for (int x{}; x <= MIN(K, S); ++x) {
    for (int y{}; y <= MIN(K, S-x); ++y) {
      if (S >= x + y && S - (x + y) <= K) {
        ++count;
      }
    }
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int ans = N * (N - 1) / 2 + M * (M - 1) / 2;
		System.out.println(ans);
	}
}

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

const int MX = 32;
ll x[MX];
ll rg[MX][2];
int bit[MX];
void dfs(int mbit, int n)
{
  int i;
  int flag = false;
  for (i = mbit - 1; 0 <= i; i--) {
    if (rg[i][0] <= n && n <= rg[i][1]) {
      flag = true;
      break;
    }
  }
  dump(n, flag, i, x[i]);
  if (flag) {
    bit[i] = 1;
    dfs(i, n - x[i]);
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  int N;
  cin >> N;
  x[0] = 1;
  for (int i = 1; i < MX; i++) {
    x[i] = x[i - 1] * -2;
  }
  for (int i = 0; i < MX; i++) {
    int low = 0;
    int high = 0;
    for (int j = 0; j < i; j++) {
      if (x[j] < 0)
        low += x[j];
      else
        high += x[j];
    }
    rg[i][0] = x[i] + low;
    rg[i][1] = x[i] + high;
  }
  // dumpv(x, 32);
  // dumpv(rg, 32, 2);
  dfs(MX, N);
  dumpv(bit, MX);
  int one = false;
  for (int i = MX - 1; 0 <= i; i--) {
    if (bit[i]) {
      cout << "1";
      one = true;
    } else if (one) {
      cout << "0";
    }
  }
  if (one)
    cout << endl;
  else
    cout << "0" << endl;
  return 0;
}

Measured memory_bytes: 256
a=int(input())
b=list(map(int,input().split()))
c=int(input())
d=[]
for i in range(c):
  d.append(list(map(int,input().split())))

for i in range(c):
  f=b.copy()
  p=d[i][0]-1
  f[p]=d[i][1]
  print(sum(f))


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

bool cmp(string a, string b) {
    return stoi(a) < stoi(b);
}

int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    vector<string> a(n), ans;
    rep(i, 0, n) cin >> a[i];
    sort(all(a), cmp);
    rep(i, 1, n) {
        ans.pb(a[0] + a[i]);
        ans.pb(a[i] + a[0]);
    }
    sort(all(ans), cmp);
    cout << ans[2] << endl;
    return 0;
}


Measured memory_bytes: 4360
/*
https://blog.csdn.net/litble/article/details/83118814

图论神啊，好题好题好题！！！
i 向 pi 连条边，构成的图简化以后就都是 “i 向 ai 连条边” 这个图了！！！

注意：是由一个环和若干条指向环的链组成的基环内向树，至于为什么是链，详见样例4

现在手上只有 a，那么就**倒推**有多少种可能图吧
*/
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int mod = 1e9 + 7, N = 1e5 + 10;
typedef long long ll;
int n, a[N], deg[N], vis[N], cir[N], L[N], sum[N];
ll ans, f[N];

void calc(int x) {
    int now = 0, fr = 0, ed = 0, l = 0;
    // fr: 第一个脚的位置  ed: 上一个脚的位置  l: 第一个脚的长度  now: 当前节点是从 x 开始走环走到的第几个点
    while (cir[x]) {
        ++now, cir[x] = 0;
        if (L[x]) {
            if (!fr) ed = fr = now, l = L[x];
            else {
                int tmp = (L[x] < now - ed) + (L[x] <= now - ed);
                ans = 1ll * ans * tmp % mod, ed = now;
            }
        }
        x = a[x];
    }
    if (!fr) ++sum[now];
    else {
        int tmp = (l < now - ed + fr) + (l <= now - ed + fr);
        ans = 1ll * ans * tmp % mod;
    }
}

void solve() {
    rep(i, 1, n) {
        if (deg[i]) continue;
        int x = i, len = 0; while (!cir[x]) ++len, x = a[x];
        L[x] = len;
    }
    ans = 1;
    rep(i, 1, n) if (cir[i]) calc(i);
    rep(i, 1, n) {
        f[0] = 1;
        rep(j, 1, sum[i]) {
            if (i > 1 && (i & 1)) f[j] = f[j - 1] * 2 % mod;
            else f[j] = f[j - 1];
            if (j > 1) f[j] = (f[j] + f[j - 2] * (j - 1) % mod * i % mod) % mod;
        }
        ans = 1ll * ans * f[sum[i]] % mod;
    }
}

int main() {
    cin >> n;
    rep(i, 1, n) scanf("%d", &a[i]), ++deg[a[i]];
    rep(i, 1, n) {
        if (vis[i]) continue;
        int x = i;
        while (!vis[x]) vis[x] = i, x = a[x];
        if (vis[x] != i) continue;
        while (!cir[x]) cir[x] = 1, x = a[x];
    }
    rep(i, 1, n)
        if ((!cir[i] && deg[i] > 1) || (cir[i] && deg[i] > 2)) return puts("0"), 0;
    solve();
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007LL;
const double INF=1000000000;
const int MAX=100001;
int main(){
    ll n,l,t;
    cin>>n>>l>>t;
    ll w[100010],x[100010];
    vector<ll> v;
    for(int i=0;i<n;i++){
        cin>>x[i]>>w[i];
        if(w[i]==1){
            v.push_back((x[i]+t)%l);
        }else{
            v.push_back(((x[i]-t)%l+l)%l);
        }
    }
    ll c=0;
    for(int i=0;i<n;i++){
        if(w[i]==1){
            c+=(x[i]+t)/l;
        }else{
            c-=(t-x[i]-1+l)/l;
        }
    }
    c=(c%n+n)%n;
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        cout<<v[(i+c)%n]<<endl;
    }   
    return 0;
}

                           


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  int n;
  cin >> n;
  string str;
  cin >> str;
  deque<char> que;
  rep(i, n){
    que.push_back(str[i]);
  }
  while(!que.empty() && que.front() == '.'){
    que.pop_front();
  }
  while(!que.empty() && que.back() == '#'){
    que.pop_back();
  }
  vector<char> checkVec;
  while(!que.empty()){
    checkVec.push_back(que.front());
    que.pop_front();
  }
  int ans = 0;
  int smallest = 1000000007;
  for(int i=0; i<checkVec.size(); i++){
    if(checkVec[i] == '.') ans++;
  }
  smallest = ans;
  for(int i=0; i<checkVec.size(); i++){
    if(checkVec[i] == '.') ans--;
    else ans++;
    smallest = min(smallest, ans);
  }
  cout << smallest << endl;
  return 0;
}
  
  

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<int(n); i++)
typedef long long ll;

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    
    priority_queue<int> q;

    REP(i,n){
        int tmp;
        cin >> tmp;
        q.push(tmp);
    }
    REP(i,m){
        int tmp = q.top(); q.pop();
        q.push(tmp/2);
    }

    ll ans = 0;
    REP(i,n){
        ans += q.top(); q.pop();
    }
    cout << ans << '\n';
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < (n); i++)
#define forr(i,a,b) for (int i = (a); i <= (b); i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ii> vii;

string s;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> s;
	for (int i = 0; i < s.size(); i += 2)
		if (s[i] != 'h') {
			cout << "No" << endl;
			return 0;
		}

	for (int i = 1; i < s.size(); i += 2)
		if (s[i] != 'i') {
			cout << "No" << endl;
			return 0;
		}

	if (s.size() % 2 == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

int main()
{
    int x;
    cin >> x;
    cout << x*x*x<< endl;
    return 0;
}
/*
int main(int arg, char *argv[])
{
    int n = stoi(argv[1]);
    int ans = n * n * n;
    cout << ans << endl;
    return 0;
}
*/

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

int main() {
	
	int n, m;
	scanf("%d %d", &n, &m);
	vector<int> l(m);
	vector<int> r(m);
	for(int i = 0; i < m; i++) {
		scanf("%d %d", &l[i], &r[i]);
	}
	int mi = 1e6;
	int ma = 0;
	for(int i = 0; i < m; i++) {
		mi = min(mi, r[i]);
		ma = max(ma, l[i]);
	}
	int ans = mi - ma;
	if(ans < 0) {
		printf("%d\n", 0);
	}else {
		printf("%d\n", ans + 1);
	}
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
    int i,j,k,num,ans,def;
    ans = 0;
    scanf("%d",&num);
    int a[num],b[num];
    for(i=0;i<num;i++){
        scanf("%d",&a[i]);
    }
    for(j=0;j<num;j++){
        scanf("%d",&b[j]);
    }
    for(k=0;k<num;k++){
        def = a[k] - b[k];
        if(def > 0){
            ans+=def;
        }
    }
    printf("%d",ans);
    return 0;
}

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

namespace arc101_a
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int[] sum = new int[x[0]];
			for (int i = 1; i < x[0]; i++)
			{
				sum[i] = sum[i - 1] + (a[i] - a[i - 1]);
			}
			int min = int.MaxValue;
			for (int i = 0; i + x[1] - 1 < x[0]; i++)
			{
				min = Math.Min(min, sum[i + x[1] - 1] - sum[i] + Math.Min(Math.Abs(a[i]), Math.Abs(a[i + x[1] - 1])));
			}
			Console.WriteLine(min);
		}
	}
}

Measured memory_bytes: 23904
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long ll;
ll a[300000],b[300000],c[300000],imo[300001];
int main(){
	int N;
	cin>>N;
	rep(i,N) cin>>a[i];
	sort(a,a+N);
	rep(i,N) imo[i+1]=imo[i]+a[i];
	int M;
	cin>>M;
	rep(i,M) cin>>b[i];
	rep(i,M) cin>>c[i];
	rep(i,M){
		int id=upper_bound(a,a+N,b[i])-a;
		if(imo[id]>=c[i]) puts("Yes");
		else puts("No");
	}
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long
#define ld long double
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)

#define xx first
#define yy second
#define mp make_pair
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define pdd pair<double,double>
#define ALL(v) (v).begin(), (v).end()

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

#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define put(x) cout<<#x<<" = "<<x<<endl;

ll power(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a);
        n>>=1;
        a=(a*a);
    }
    return ans;
}


ll powerMod(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%MOD;
        n/=2;
        a=(a*a)%MOD;
    }
    return ans;
}

ll powerMod1(ll a,ll n,ll mod){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%mod;
        n>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

ll lcm(ll a,ll b){
    return a*(b/__gcd(a,b));
}

ll sumdigit(ll n){
    ll sum=0;
    while(n){
        sum+=n%10;
        n=n/10;
    }
    return sum;
}

ll countSetBit(ll a){
    return __builtin_popcount(a);
}
ll countBit(ll a){
    ll sum=0;
    while(a){
        sum++;
        a>>=1;
    }
    return sum;
}

ll length(ll a){
    ll ans=0;
    while(a){
        ans++;
        a=a/10;
    }
    return ans;
}

bool isVowel(char c){
	if(c=='a' or c=='e' or c=='i' or c=='o' or c=='u')
		return true;
	return false;
}


int main()
{
    fast;
    ll t;
    //~ cin>>t;
    t=1;
    while(t--){
			ll n;
			cin>>n;
			cout<<ceil(1.0*n/2);
    }
    return 0;
}


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

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

vector<int> v;

void solve(int pos, int num) {
	if (pos != 0) {
		v.push_back(num);
	}
	if (pos >= 10) return;
	int from = ((pos == 0) ? 1 : 0);
	for (int i = from; i <= 9; i++) {
		if (pos != 0 && abs(num % 10 - i) > 1) continue;
		solve(pos + 1, num * 10 + i);
	}
}

signed main(){
    IOS;
    int n;
    cin >> n;
    solve(0, 0);
    sort(v.begin(), v.end());
    cout << v[n-1] << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=0,tmp=0;
  cin >> n;
  long long a[n];
  vector<long long> small,big;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  if(n%2==0){
    for(int i=0;i<n/2;i++){
      small.push_back(a[i]);
    }
    for(int i=n-1;i>=n/2;i--){
      big.push_back(a[i]);
    }
    for(int i=0;i<n/2-1;i++){
      ans+=big[i]-small[i];
    }
    for(int i=0;i<n/2-1;i++){
      ans+=big[i]-small[i+1];
    }
    ans+=max(big[n/2-1]-small[0], big[n/2-1]-small[n/2-1]);

    for(int i=0;i<n/2-1;i++){
      tmp+=big[i]-small[i];
    }
    for(int i=0;i<n/2-1;i++){
      tmp+=big[i+1]-small[i];
    }
    tmp+=max(big[0]-small[n/2-1], big[n/2-1]-small[n/2-1]);
  }

  else{
    for(int i=0;i<=(n-1)/2;i++){
      small.push_back(a[i]);
    }
    for(int i=n-1;i>(n-1)/2;i--){
      big.push_back(a[i]);
    }
    for(int i=0;i<(n-1)/2;i++){
      ans+=big[i]-small[i];
    }
    for(int i=0;i<(n-1)/2-1;i++){
      ans+=big[i+1]-small[i];
    }
    ans+=max(big[0]-small[(n-1)/2], small[(n-1)/2]-small[(n-1)/2-1]);

    for(int i=0;i<(n-1)/2;i++){
      tmp+=big[i]-small[i];
    }
    for(int i=0;i<(n-1)/2-1;i++){
      tmp+=big[i]-small[i+1];
    }
    tmp+=max(small[(n-1)/2]-small[0], big[(n-1)/2-1]-small[(n-1)/2]);

  }

  cout << max(ans,tmp) << endl;
  return 0;
}


Measured memory_bytes: 2168
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(void) {
    vector<int> v;
    for (int i = 0; i < 10; i++) {
        int input;
        scanf("%d", &input);
        v.push_back(input);
    }
    sort(v.rbegin(), v.rend());
    for (int i = 0; i < 3; i++) {
        printf("%d\n", v[i]);
    }
}

Measured memory_bytes: 1056
#include <iostream>

using namespace std;

int main(void)
{
    int N,X,T;
    cin >> N >> X >> T;
    int num;
    num = N/X;
    int num1;
    num1 = N%X;
    if(num1>0) num++;
    int time;
    time = num*T;
    cout << time << endl;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
const int N=5005;
int dp[N],c[N],n,M;
int main(){
	scanf("%d%d",&n,&M);
	for (int i=1;i<n;i++)
		if (i*2<n)c[i]=1;
		else if (i*2>n)c[i]=-1;
	for (int i=n-2;i;i--)c[i]+=c[i+1];
	for (int i=1;i<n;i++)c[i]--;
	for (int i=1;i<n;i++)c[i]=-c[i];
	dp[0]=1;
	for (int i=1;i<n;i++)
		for (int j=c[i];j<n;j++)(dp[j]+=dp[j-c[i]])%=M;
	int ans=0;
	for (int i=0;i<n;i++)(ans+=(long long)dp[i]*(n-i)%M)%=M;
	printf("%d\n",ans);
}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
a = l()

a = list(set(a))
if len(a) == n:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 32104
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  ll a;
  map<ll, ll> Xcnt;
  rep(i, N){
    cin >> a;
    Xcnt[a - 1]++;
    Xcnt[a]++;
    Xcnt[a + 1]++;
  }

  ll max_cnt = -(ll)pow(10, 10);
  for(auto it = Xcnt.begin(); it != Xcnt.end(); it++){
    max_cnt = max(max_cnt, it->second);
  }

  cout << max_cnt << endl;
  
  return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

template<typename T>
T gcd(T a, T b) 
{
    if (b < a) { //! make sure a <= b
        T tmp = b;
        b = a;
        a = tmp;
    }

    T r = b % a;
    while (r) {
        b = a;
        a = r;
        r = b % a;
    }

    return a;
}


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

    int K;
    cin >> K;

    LL ans = 0;
    for (int a = 1; a <= K; ++a) {
        for (int b = 1; b <= K; ++b) {
            int g = gcd(a, b);
            for (int c = 1; c <= K; ++c) {
                ans += gcd(g, c);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

const int maxn = 1e5+5;
int t[maxn];

int main()
{
    int n, c, k;
    cin >> n >> c >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> t[i];
    }

    sort(t, t+n);

    int tim, pass, ans;
    tim = pass = ans = 0;
    for (int i = 0; i < n; i++)
    {
        if(t[i] > tim || pass >= c)
        {
            ans++;
            tim = t[i] + k;
            pass = 1;
        }
        else pass++;
    }

    cout << ans;
    return 0;
}



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


int main() {
    //input
    int n;
    cin >> n;
    int mi = 1000000000;
    int ma = 0;

    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        mi = min(mi,a);
        ma = max(ma,a);
    }

    cout << ma - mi << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int n;

void CountingSort(int *,int *,int);
int main(){
  unsigned int *A, *B;
  int i,k=0;

  scanf("%d",&n);

  A = malloc(sizeof(int)*n+1);
  B = malloc(sizeof(int)*n+1);
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(k<A[i]){
      k = A[i];
    }
  }

  CountingSort(A,B,k);

  for(i=0;i<n-1;i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[n-1]);
  
  return 0;
}

void CountingSort(int *A,int *B,int k){
  int i,j,C[VMAX+1];

  for(i=0;i<=k;i++){
    C[i] = 0;
  }

  for(j=0;j<n;j++){
    C[A[j]]++;
  }

  for(i=1;i<=k;i++){
    C[i] = C[i]+C[i-1];
  }

  for(j=n-1;j>=0;j--){
    B[C[A[j]]-1] = A[j];
    C[A[j]]--;
  }
}
  
//1 2 4 6 6 7  
   



Measured memory_bytes: 17384
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long 
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mkp make_pair
  #define pb push_back
  #define inf INT_MAX

  int32_t main()
  { 
  
    #ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif
    IOS
    int n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
      if(i%3==0 or i%5==0 or i%15==0)
        continue;
      else sum+=i;
    }
    cout<<sum;
    return 0;
   
}


Measured memory_bytes: 3640
N, K = map(int, input().split())
l = []
for i in range(N):
  a, b = map(int, input().split())
  l.append([a, b])
  
l.sort()
cnt = 0
ans = 0
i = 0
while cnt < K:
  ans = l[i][0]
  cnt += l[i][1]
  i += 1
print(ans)

Measured memory_bytes: 24476
#include<stdio.h>
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	int max = a + b;
	if (max < a - b)max = a - b;
	if (max < a * b)max = a * b;
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
#include<stack>
using namespace std;
int b[200000];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",b+i);
	stack<int> S;
	int ret=0;
	for(int i=0;i<a;i++){
		while(S.size()&&S.top()>b[i]){
			S.pop();
		}
		if(S.size()==0||S.top()!=b[i]){
			ret++;
			S.push(b[i]);
		}
	}
	printf("%d\n",ret);
}

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

#define ll long long

main() {
	string s;
	cin >> s;
	ll ans = 0;
	ll res = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'W') {
			ans += res;
		} else {
			res++;
		}
	}
	cout << ans;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;

void solve() {
	cin >> N;
	int res = 0;
	rep(i, 0, N) {
		int a; cin >> a;
		res ^= (a % 2);
	}
	cout << (res == 0 ? "YES\n" : "NO\n");
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


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


Measured memory_bytes: 764
n=int(input())
L=sorted([int(input()) for i in range(n)])
S=sum(L)
if S%10!=0:
    print(S)
    exit()
else:
    for i in range(n):
        if (S-L[i])%10!=0:
            print(S-L[i])
            exit()
print(0)

Measured memory_bytes: 3060
#!/usr/bin/env python3

N, M = list(map(int, input().split()))
xy_table = []

for _ in range(M):
    x, y = list(map(int, input().split()))
    xy_table.append((x, y))

red_box_dict = {i: False for i in range(1, N + 1)}
red_box_dict[1] = True
# 添字0はダミー
# 添字 = 箱の番号として扱う
n_box_list = [0] + [1] * N

for xy in xy_table:
    x, y = xy
    n_box_list[x] -= 1
    n_box_list[y] += 1
    if red_box_dict[x]:
        red_box_dict[y] = True

        if n_box_list[x] == 0:
            red_box_dict[x] = False

ans = len([v for v in red_box_dict.values() if v])

print(ans)


Measured memory_bytes: 28500
#include <iostream>
#include <string>
#include <map>

using namespace std;


int main() {

  string str;

  map<string,string> encode;
  map<string,string> decode;

  encode[" "] = "101";
  encode["'"] = "000000";
  encode[","] = "000011";
  encode["-"] = "10010001";
  encode["."] = "010001";

  encode["?"] = "000001";
  encode["A"] = "100101";
  encode["B"] = "10011010";
  encode["C"] = "0101";
  encode["D"] = "0001";
  encode["E"] = "110";
  encode["F"] = "01001";
  encode["G"] = "10011011";

  encode["H"] = "010000";
  encode["I"] = "0111";
  encode["J"] = "10011000";
  encode["K"] = "0110";
  encode["L"] = "00100";
  encode["M"] = "10011001";
  encode["N"] = "10011110";

  encode["O"] = "00101";
  encode["P"] = "111";
  encode["Q"] = "10011111";
  encode["R"] = "1000";
  encode["S"] = "00110";
  encode["T"] = "00111";
  encode["U"] = "10011100";

  encode["V"] = "10011101";
  encode["W"] = "000010";
  encode["X"] = "10010010";
  encode["Y"] = "10010011";
  encode["Z"] = "10010000";

  decode["00000"] = "A";
  decode["00001"] = "B";
  decode["00010"] = "C";
  decode["00011"] = "D";
  decode["00100"] = "E";
  decode["00101"] = "F";
  decode["00110"] = "G";

  decode["00111"] = "H";
  decode["01000"] = "I";
  decode["01001"] = "J";
  decode["01010"] = "K";
  decode["01011"] = "L";
  decode["01100"] = "M";
  decode["01101"] = "N";

  decode["01110"] = "O";
  decode["01111"] = "P";
  decode["10000"] = "Q";
  decode["10001"] = "R";
  decode["10010"] = "S";
  decode["10011"] = "T";
  decode["10100"] = "U";

  decode["10101"] = "V";
  decode["10110"] = "W";
  decode["10111"] = "X";
  decode["11000"] = "Y";
  decode["11001"] = "Z";

  decode["11010"] = " ";
  decode["11011"] = ".";
  decode["11100"] = ",";
  decode["11101"] = "-";
  decode["11110"] = "'";
  decode["11111"] = "?";

  while(getline(cin,str)) {

    string enc="";

    for(int i=0;i<str.size();i++) {

      enc+=encode[str.substr(i,1)];

    }

    enc+="0000";

    string dec="";

    for(int i=0;i+5<=enc.size();i+=5) {

      dec+=decode[enc.substr(i,5)];

    }

    cout << dec << endl;

  }

  return 0;

}

Measured memory_bytes: 0
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
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);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

template<class Abel>
struct wUnionFind {
    vector<int> par;
    vector<Abel> diff_weight;
    wUnionFind(int n):par(n, -1), diff_weight(n) {}
    int root(int x) {
        if(par[x] < 0) return x;
        int r = root(par[x]);
        diff_weight[x] += diff_weight[par[x]];
        return par[x] = r;
    }
    bool unite(int x, int y, Abel w) { //weight(y) - weight(x) = w となるようにする
        w += weight(x)-weight(y);
        x = root(x); y = root(y);
        if(x == y) {
            assert(diff(x, y) == w);
            return false;
        }
        if(par[x] > par[y]) swap(x, y), w = -w;
        par[x] += par[y];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }
    bool same(int x, int y) {return root(x) == root(y);}
    bool size(int x) {return -par[root(x)];}
    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }
    Abel diff(int x, int y) {
        assert(same(x, y));
        return weight(y)-weight(x);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    while(n) {
        wUnionFind<int> wft(n);
        char c;
        rep(i, m) {
            cin >> c;
            if(c == '!') {
                int a, b, w;
                cin >> a >> b >> w;
                --a; --b;
                wft.unite(a, b, w);
            } else {
                int a, b;
                cin >> a >> b;
                --a; --b;
                if(wft.same(a, b)) {
                    cout << wft.diff(a, b) << '\n';
                } else {
                    cout << "UNKNOWN" << '\n';
                }
            }
        }
        cin >> n >> m;
    }
}


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int N;
string name;

int main() {
	cin >> N >> name;
	int ans = 0;
	rep(n, N) {
		string s;
		cin >> s;
		rep(i, s.size()) {
			if(name[0] == s[i]) {
				int space = 1;
				bool flag = false;
				while(1) {
					int cnt = 1;
					if(space >= s.size()) break;
					for(int j = i + space; j < s.size(); j += space) {
						if(name[cnt] != s[j]) break; 
						else ++cnt;
						if(cnt == name.size()) {
							++ans;
							flag = true;
							break;
						}
					}
					if(flag) break;
					++space;
				}
			if(flag) break;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3252
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func main() {
	var N int
	fmt.Scanf("%d\n", &N)
	cnt := 0
	for i := 1; i <= N; i++ {
		if len(fmt.Sprint(i))%2 != 0 {
			cnt++
		}
	}
	fmt.Println(cnt)

}


Measured memory_bytes: 2176
#include <cstdio>
typedef long long ll;
inline int rd(){
    int x=0,p=1;
    char a=getchar();
    while((a<48||a>57)&&a!='-')a=getchar();
    if(a=='-')p=-p,a=getchar();
    while(a>47&&a<58)x=(x<<1)+(x<<3)+(a&15),a=getchar();
    return x*p;
}
const int N=200002;
int n;
int a[5];
char s[N][3],ans[N];
int main(){
	n=rd();
	for(int i=0;i<=2;i++)a[i]=rd();
	for(int i=1;i<=n;i++)
		scanf("%s",s[i]);
	for(int i=1;i<=n;i++){
		int x=s[i][0]-'A',y=s[i][1]-'A';
		if(a[x]<a[y])a[x]++,a[y]--,ans[i]=x+'A';
		else if(a[x]>a[y])a[y]++,a[x]--,ans[i]=y+'A';
		else{
			int z=3-x-y;
			if(a[x]==1&&a[z]==0){
				if(i==n||(s[i+1][0]!=z+'A'&&s[i+1][1]!=z+'A'))a[y]++,a[x]--,ans[i]=y+'A';
				else{
					int xx=s[i+1][0]-'A',yy=s[i+1][1]-'A';
					if(x==xx||x==yy)a[x]++,a[y]--,ans[i]=x+'A';
					else a[y]++,a[x]--,ans[i]=y+'A';
				}
			}
			else a[y]++,a[x]--,ans[i]=y+'A';
		}
		if(a[x]<0||a[y]<0)return puts("No"),0;
	}
	puts("Yes");
	for(int i=1;i<=n;i++)printf("%c\n",ans[i]);
    return 0;
}

Measured memory_bytes: 2132
let nil = -1

type t = { mutable parent : int; mutable left : int; mutable right : int }

let make () = { parent = nil; left = nil; right = nil }

let search_root t n =
  let rec doit i =
    if i = n then nil
    else if t.(i).parent = nil then i
    else doit (i + 1) in
  doit 0

let preorder t root f =
  let rec doit i =
    if i = nil then ()
    else begin
      f i;
      doit t.(i).left;
      doit t.(i).right
    end in
  doit root

let inorder t root f =
  let rec doit i =
    if i = nil then ()
    else begin
      doit t.(i).left;
      f i;
      doit t.(i).right
    end in
  doit root

let postorder t root f =
  let rec doit i =
    if i = nil then ()
    else begin
      doit t.(i).left;
      doit t.(i).right;
      f i
    end in
  doit root

let () =
  let n = read_int () in
  let t = Array.init n (fun _ -> make ()) in
  for _ = 0 to n - 1 do
    let (id, l, r) = Scanf.scanf "%d %d %d\n" (fun id l r -> (id, l, r)) in
    t.(id).left <- l;
    t.(id).right <- r;
    if l <> nil then t.(l).parent <- id;
    if r <> nil then t.(r).parent <- id;
  done;
  let root = search_root t n in
  print_endline "Preorder";
  preorder t root (fun i -> print_string " "; print_int i);
  print_newline ();
  print_endline "Inorder";
  inorder t root (fun i -> print_string " "; print_int i);
  print_newline ();
  print_endline "Postorder";
  postorder t root (fun i -> print_string " "; print_int i);
  print_newline ()

Measured memory_bytes: 2308
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i = (s);i<(int)(n);i++)

int main(){
    string s , t;
    cin >> s >> t;
    int n = s.size();
    bool a = 0;
    rep(i , n){
        if(s[i] != t[i]){
            a = 1;
            break;
       }
    }
    if(a == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
}
    


Measured memory_bytes: 3592
n=int(input())
xy=[[] for i in range(n)]
for i in range(n):
  a=int(input())
  for j in range(a):
    x,y=map(int,input().split())
    xy[i].append([x,y])
ans=0
for b in range(1<<n):
  cnt=bin(b).count("1")
  if cnt<=ans:continue
  for j in range(n):
    if b&(1<<j):
      for x,y in xy[j]:
        if y==1 and b&(1<<x-1): continue
        if y==0 and b&(1<<x-1)==0: continue
        break
      else:
        continue
      break
  else:
    ans=cnt
print(ans)



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <climits>

using namespace std;

int a[3];
int main() {
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a + 3);

    cout << abs(a[1] - a[0]) + abs(a[2] - a[1]) << endl;
}

Measured memory_bytes: 764
s=input()
l=s[:(len(s)-1)//2]
r=s[(len(s)+3)//2-1:]
for i in range((len(s)-1)//2):
  if s[i]==s[-i-1] and l[i]==r[i]:
    if i==(len(s)-1)//2-1:
      print("Yes")
      exit()
    continue
  else:
    print("No")
    break

Measured memory_bytes: 3060
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S;
	cin >> S;

	if (S == "AAA" || S == "BBB")
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  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;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)

using namespace std;

int Q;

int main()
{
	cin >> Q;
	int ans = 0;
	int num1, num2, num3;
	
	REP(i, Q)
	{
		ans = 0;
		cin >> num1 >> num2 >> num3;
		while (true)
		{
			if (num1 >= 1 && num2 >= 1 && num3 >= 1)
			{
				num1--; num2--; num3--;
				ans++;
			}
			else if (num1 >= 2 && num2 >= 1)
			{
				num1 -= 2; num2--;
				ans++;
			}
			else if (num1 >= 3)
			{
				num1 -= 3;
				ans++;
			}
			else
				break;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3132
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Clone>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0].clone(), v[1].clone())
}

fn main() {
    let (s, t) = read_touple::<String>();
    let (mut a, mut b) = read_touple::<usize>();
    let u = read::<String>();

    if s == u {
       a -= 1;
    } else {
      b -= 1;
    }

    println!("{} {}", a, b);
}


Measured memory_bytes: 4352
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner(s.lock());
    let n: usize = sc.read();
    let t: usize = sc.read();

    let mut tv = (0..n)
        .map(|_| (sc.read::<usize>(), sc.read::<u64>()))
        .collect::<Vec<_>>();
    tv.sort();

    let mut dp = vec![0; t + 1];
    for (time, value) in tv.into_iter() {
        for cur_time in (0..t).rev() {
            if cur_time + time <= t {
                dp[cur_time + time] = cmp::max(dp[cur_time + time], dp[cur_time] + value);
            }
            if cur_time == t - 1 {
                dp[t] = cmp::max(dp[t], dp[cur_time] + value);
            }
        }
    }
    let ans = dp.into_iter().max().unwrap();
    println!("{}", ans);
}

pub struct Scanner<R>(R);

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4476
// B.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt[256] = {};
	for (char c : s) {
		cnt[c] += 1;
	}
	bool ans = cnt['R'] > cnt['B'];
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256