akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int n, k; cin >> n >> k;
	vector<bool>bunny(n + 1, false);
	vector<int>boat(n+1,-1);
	rep(i, 0, k) {
		int m; cin >> m;
		rep(j, 0, m) {
			int b; cin >> b;
			boat[b] = i;
		}
	}

	int r; cin >> r;
	vector<vector<bool>>hate(n + 1, vector<bool>(n + 1, false));
	rep(i, 0, r) {
		int q, p; cin >> p >> q;
		hate[p][q] = true;
		hate[q][p] = true;
	}
	rep(i, 1, n + 1) {
		rep(j, i + 1, n + 1) {
			if (boat[i] == boat[j] && hate[i][j]) {
				bunny[i] = bunny[j] = true;
			}
		}
	}
	cout << accumulate(all(bunny), 0) << endl;
	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
long N,u,v,color;
vector<long>G[1<<17],a,b;
bool s[1<<17];
map<pair<long,long>,long>m;
long mmax(long x,long y){
  if(x>y)return x;
  else return y;
}
void dfs(long n,long c){
  s[n]=true;
  long i=1;
  for(auto e:G[n]){
    if(i==c)i++;
    if(!s[e]&&i!=c){
      m[mp(n,e)]=i;
      dfs(e,i);
      i++;
    }
  }
  color=mmax(color,i);
}
inline void solve(void){
  in(N);
  rep(i,N-1){
    in(u,v);
    u--;v--;
    G[u].pb(v);
    G[v].pb(u);
    a.pb(u);
    b.pb(v);
  }
  dfs(0,0);
  out(color-1);
  rep(i,N-1){
    out(m[mp(a[i],b[i])]);
  }
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 18200
import heapq

n,m = map(int, input().split())
a = list(map(int, input().split()))
a = [-x for x in a]

heapq.heapify(a)

for i in range(m):
    x = heapq.heappop(a)
    x = -(-x//2)
    heapq.heappush(a,x)
print(-sum(a))

Measured memory_bytes: 73196
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int i,j,k,n,m,l,x,y,build[1001][2],assign[1001],assign2[1001],prev[1001][1001];
double route[11][1001][1001];

void backtrack(int from,int to){
	int z=prev[from][to];
	if(z==from){
		printf("%d ",assign[from]);
		return;
	}
	backtrack(from,z);
	backtrack(z,to);
}

int main(){
	while(scanf("%d",&n)*n){
		for(i=0;i<n;i++){
			scanf("%d %d %d",&assign[i],&build[i][0],&build[i][1]);
			assign2[assign[i]]=i;
		}
		for(i=0;i<n;i++){
			for(j=i;j<n;j++){
				l=(build[i][0]-build[j][0])*(build[i][0]-build[j][0])+(build[i][1]-build[j][1])*(build[i][1]-build[j][1]);
				if(l<=2500){
					route[0][i][j]=sqrt((double)l);
					route[0][j][i]=sqrt((double)l);
					prev[i][j]=i;
					prev[j][i]=j;
				}
				else{
					route[0][i][j]=999999999;
					route[0][j][i]=999999999;
				}
			}
		}

		for(l=1;pow(2.0,l)<n-1;l++){
			for(i=0;i<n;i++){
				for(j=0;j<n;j++){
					route[l%2][i][j]=route[(l+1)%2][i][j];
					for(k=0;k<n;k++){
						if(route[l%2][i][j]>route[(l+1)%2][i][k]+route[(l+1)%2][k][j]){
							route[l%2][i][j]=route[(l+1)%2][i][k]+route[(l+1)%2][k][j];
							prev[i][j]=k;
						}
					}
				}
			}
		}

		l--;

		for(scanf("%d",&m);m>0;m--){
			scanf("%d %d",&x,&y);
			x=assign2[x];
			y=assign2[y];
			if(x==y){
				printf("%d\n",assign[y]);
			}
			else if(route[l%2][x][y]<999999999){
				backtrack(x,y);
				printf("%d\n",assign[y]);
			}
			else printf("NA\n");
		}

	}
	return 0;
}

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

int dp[100001];
int a[100000];
int k;
int fun(int i){
if(i<1)return 1000000000;
if(i==1)return 0;
if(dp[i]!=-1)return dp[i];
dp[i]=1000000000;
int q=min(k,i-1);
for(int j=1;j<=q;j++){
dp[i]=min(dp[i],abs(a[i]-a[i-j])+fun(i-j));
}
return dp[i];
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n>>k;
memset(dp,-1,sizeof dp);
for(int i=1;i<=n;i++){
cin>>a[i];
}
cout<<fun(n);
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9;

int main(){
  int N,M,A[100000],B[100000],C[100000];
  cin>>N>>M;
  for (int i(0);i<N;i++) cin>>A[i];
  vector <pair<int,int>> p(M);
  for (int i(0);i<M;i++) cin>>p[i].second>>p[i].first;
  sort(A,A+N);
  sort(p.rbegin(),p.rend());
  int ptrp(0);
  for (int i(0);i<N;i++){
    if (p[ptrp].second == 0) ptrp++;
    if (ptrp == M) break;
    if (p[ptrp].first>A[i]){
      A[i] = p[ptrp].first;
      p[ptrp].second--;
    }
  }
  //for (int i(0);i<N;i++) cout << A[i] << " ";
  ll ans(0);
  for (int i(0);i<N;i++) ans+=A[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    long long int n;
    cin>>n;
    long long int a[n],sum=0;
    for(long long int i=0;i<n;i++)
    cin>>a[i];
    for(long long int i=1;i<n;i++)
    {
        if(a[i]<a[i-1])
        {
            sum+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 5180
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<string> VS;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<typeof((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)

// constant
// const ll MOD = 1e9 + 7;
const int INF = 1e9;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// --------------------------------------------------------


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

    int F[N][10];
    REP(i, N)
    {
        REP(j, 10)
        {
            cin >> F[i][j];
        }
    }

    int P[N][11];
    REP(i, N)
    {
        REP(j, 11)
        {
            cin >> P[i][j];
        }
    }

    int MAXG = -INF;
    FOR(b, 1, 1 << 10)
    {
        int G = 0;

        REP(i, N)
        {
            int c = 0;
            REP(j, 10)
            {
                if ((b >> j & 1) && F[i][j]) {
                    c++;
                }
            }
            G += P[i][c];
        }

        MAXG = max(MAXG, G);
    }

    cout << MAXG << endl;
    return 0;
}

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

using namespace std;
int main()
{
    long long int n , a , b;
    cin>>n>>a>>b;
    long long int r = n%(a+b) , s = n/(a+b);
    if(r>a) r=a;
    cout<<a*s+r<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9
 
int main() {
  long long int L, R;
  cin >> L >> R;
  
  R = min(R, L+673);
  
  long long int result = INF;
  for (long long int i=L; i<R; i++) {
    for (long long int j=i+1; j<=R; j++) {
      result = min((i * j) % 2019, result);
    }
  }
  
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
Node treeMinimum(Node x){
  while(x->left != NIL)
    x=x -> left;
  return x;
}
 
Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k<u->key)
      u=u ->left;
    else
      u=u->right;
  }
  return u;
}
 
Node treeSuccessor(Node x){
  Node m;
  if(x -> right != NIL)
    return treeMinimum(x->right);
  m = x->parent;
  while(m!= NIL && x == m -> right){
    x = m;
    m = m->parent;
  }
  return m;
 
}
 
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z -> right == NIL)
    y=z;
  else
    y=treeSuccessor(z);
  if(y->left !=NIL)
    x = y->left;
  if(x != NIL)
    x->parent =y->parent;
  if(y->parent == NIL)
    root=x;
  else if(y==y->parent->left)
    y->parent->left=x;
  else
    y->parent->right=x;
  if(y!=z)
    z->key =y->key;
   
 
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x !=NIL){//loop
    y=x;
    if(z->key < x-> key)
      x=x->left;
    else
      x=x->right;
  }
  z->parent=y;
  if(y == NIL)
    root =z;
  else if(z->key < y->key)
    y->left =z;
  else
    y->right=z;
}
 
void inorder(Node u){
  if(u !=NIL){
    if(u->left !=NIL)
      inorder(u->left);
    printf(" %d",u->key);
    if(u->right != NIL)
      inorder(u->right);
  }
}
void preorder(Node u){
  if(u !=NIL){
    printf(" %d",u->key);
    if(u->left !=NIL)
      preorder(u->left);
    if(u->right != NIL)
      preorder(u->right);
  }
} 
int main(){
   int n, i, x;
   char com[20];
   scanf("%d ", &n);
    
   for ( i = 0; i < n; i++ ){
     scanf("%s", com);
     if ( com[0] == 'f' ){
       scanf("%d", &x);
       Node t = treeSearch(root, x);
       if ( t != NIL ) printf("yes\n");
       else printf("no\n");
     } else if ( com[0] == 'i' ){
       scanf("%d", &x);
       insert(x);
     } else if ( com[0] == 'p' ){
       inorder(root);
       printf("\n");
       preorder(root);
       printf("\n");
    } else if ( com[0] == 'd' ){
       scanf("%d", &x);
       treeDelete(treeSearch(root, x));
     }
   }
    
   return 0;
} 

Measured memory_bytes: 24036
fun main(args : Array<String>) {
    val s = readLine()!!
    val t = readLine()!!

    if (s.contains(t)) {
        println(0)
        return
    }

    var max = 0

    for (i in 0..s.length - t.length) {
        var cnt = 0
        for (j in t.indices) {
            if (s[i+j] == t[j]) {
                cnt++
            }
        }
        if (cnt == t.length) {
            println(0)
            return
        }
        max = Math.max(cnt, max)
    }

    println(t.length-max)
}

Measured memory_bytes: 37672
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,bool> Pair;

int main(){

double A,B,H,M;
double Ax,Ay,Bx,By;
double time;
double ans;

cin >> A >> B >> H >> M;

time = H+(M/60.0);

Ay = A*cos( (acos(-1.0)/6.0)*time);
Ax = A*sin( (acos(-1.0)/6.0)*time);

//cout << Ax << " " << Ay << endl;

By = B*cos( 2.0*(acos(-1.0)*time));
Bx = B*sin( 2.0*(acos(-1.0)*time));

//cout << Bx << " " << By << endl;

double xdiff = (Ax - Bx);
double ydiff = (Ay - By);

ans = sqrt((xdiff*xdiff) +(ydiff*ydiff));

printf("%15.9lf",ans);


return 0;

}   


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

int main()
{

    string b;
    cin >> b;

    if( b == "A" ){
        cout << "T" << endl;
    }else if(b == "G"){
        cout << "C" << endl;
    }else if( b == "T" ){
        cout << "A" << endl;
    }else if (b == "C" ){
        cout << "G" << endl;
    }

    return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  if (S.at(0) == S.at(1) && S.at(1) == S.at(2)) {
    cout << "No" << endl;
  }
  
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
def main():
    n, q = map(int, input().split())
    s = list(input())
    lr = [list(map(int, input().split())) for i in range(q)]
    ruiseki = [0 for i in range(n)]

    for i in range(n - 1):
        if s[i] == "A" and s[i + 1] == "C":
            ruiseki[i + 1] = ruiseki[i] + 1
        else:
            ruiseki[i + 1] = ruiseki[i]
    ruiseki = [0] + ruiseki

    for l, r in lr:
        print((ruiseki[r] - ruiseki[l]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 73592
#include <stdio.h>

int main(void)
{
        int b,c,d,n,q,i,j;
        long int sum=0;
        scanf("%d",&n);

        int a[2000000]={0};

        for(i=0;i<n;i++){
                scanf("%d",&d);
                a[d]++;
                sum+=d;
        }
        scanf("%d",&q);

        long int s[q];
        for(i=0;i<q;i++)
                s[i]=0;

        for(i=0;i<q;i++){
                scanf("%d%d",&b,&c);
                if(a[b]>=1){
                       sum=sum+(c-b)*a[b];
                       a[c]=a[c]+a[b];
                       a[b]=0;
                }
                printf("%ld\n",sum);
        }
        return 0;
}


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

from scipy.misc import comb
import sys
sys.setrecursionlimit(10 ** 7)


class UnionFind:

    def __init__(self, n):
        # parent[x] < 0 means x is root and abs(parent[x]) == size[x]
        self.parent, self.depth = [-1] * (n + 1), [0] * (n + 1)

    def find(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def isSame(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)

        if self.depth[x] > self.depth[y]:
            self.parent[x] += self.parent[y]
            self.parent[y] = x
        else:
            self.parent[y] += self.parent[x]
            self.parent[x] = y
            if self.depth[x] == self.depth[y]:
                self.depth[y] += 1

    def count(self, x):
        return - self.parent[self.find(x)]


N, M = map(int, input().split())

AB = [tuple(map(int, input().split())) for _ in range(M)]
AB.reverse()

groups = UnionFind(N)
ans = [comb(N, 2, exact=True)]
for i in range(M):
    if groups.isSame(AB[i][0], AB[i][1]):
        ans.append(ans[-1])
    else:
        ans.append(ans[-1] - groups.count(AB[i][0]) * groups.count(AB[i][1]))
        groups.unite(AB[i][0], AB[i][1])

for i in range(M):
    print(ans[-(i + 2)])


Measured memory_bytes: 33980
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
//using namespace __gnu_pbds;
#define rep(i,a,b) for(i=(a);i<=(b);i++)
#define ll int
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 200005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define ps(x,y) fixed<<setprecision(y)<<x
//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
    return out <<  "(" << a.F << ", " << a.S << ")";
}
 
template<class A> ostream& operator << (ostream& out, const vector<A> &a) {
    out << "[";
    for (auto it = a.begin(); it != a.end(); ++it) {
        if (it != a.begin())
            out << ", ";
        out << *it;
    }
    return out << "]";
}
ll a[maxn],ans[maxn];
vector<ll>adj[maxn];
multiset<ll>s;
void dfs(ll i,ll par){
    s.insert(a[i]);
    auto it = s.lower_bound(a[i]);
    it++;
    ll e=-1;
    if(it != s.end()){
        e=*it;
        s.erase(it);
    }
    ans[i]=s.size();
    for(auto p:adj[i]){
        if(p!=par) dfs(p,i);
    }
    if(e!=-1) s.insert(e);
    s.erase(s.find(a[i]));
}
int main()
{
    boost;
    ll n,i,j,x,t,y;
    cin>>n;
    for(i=1;i<=n;i++) cin>>a[i];
    for(i=1;i<n;i++){
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    dfs(1,0);
    for(i=1;i<=n;i++) cout<<ans[i]<<"\n";
}


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

int main(void){
  int H, W;
  cin >> H >> W;
  string a[H];
  for(int i=0; i<H; i++) cin >> a[i];
  
  bool tf = true;
  int h = H;
  int w = W;
  while(tf){
    // 行の抜き取り
    bool tf_R = true;
    for(int i = 0; i < h; i++){
      tf_R = true;
      for(int j = 0; j < w; j++){
        if(a[i][j] == '#') {
          tf_R = false;
          break;
        }
      }
      if(tf_R){
        for(int k=i; k<h-1; k++) swap(a[k], a[k+1]);
        h--;
        break;
      }
    }
    
    // 列の抜き取り
    bool tf_C = true;
    for(int i = 0; i < w; i++){
      tf_C = true;   
      for(int j = 0; j < h; j++){
        if(a[j][i] == '#') {
          tf_C = false;
          break;
        }
      }
      if(tf_C){
        for(int k=i; k<w-1; k++){
          for(int l=0; l<h; l++) swap(a[l][k], a[l][k+1]);
        }
        w--;
        break;
      }
    }
    tf = tf_R | tf_C;    
  }
  
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++){
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

int main(){
  string S;
  cin >> S;
  if(S == "ABC"){
    cout << "ARC" << endl;
  }
  else if(S == "ARC"){
    cout << "ABC" << endl;
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int n,a,b,c,a0,b0,c0;
vector<string> v;
string k;
int rr(string x){
    if(x=="AB") return 1;
    if(x=="AC") return 2;
    if(x=="BC") return 3;
}
int main()
{
    cin>>n>>a>>b>>c;
    a0=a;b0=b;c0=c;
    for(int i=0;i<n;i++){
        cin>>k;
        v.push_back(k);
    }
    for (int i=0;i<n;i++){
        switch(rr(v[i])){
            case 1:if (a==0&&b==0){cout<<"No";return 0;}
                if (a>b){a--;b++;}
            else if(a<b) {b--;a++;}
            else if (i==n-1) ;
            else if ((v[i+1]=="AC")) {b--;a++;}
            else {a--;b++;}
            break;
            case 2:if (a==0&&c==0){cout<<"No";return 0;}
                if (a>c){a--;c++;}
            else if(a<c) {c--;a++;}
            else if (i==n-1) ;
            else if ((v[i+1]=="AB")) {c--;a++;}
            else {a--;c++;}
            break;
            case 3:if (c==0&&b==0){cout<<"No";return 0;}
                if (b>c){b--;c++;}
            else if(b<c) {c--;b++;}
            else if (i==n-1) ;
            else if ((v[i+1]=="AB")) {c--;b++;}
            else {b--;c++;}
            break;
        }
    }

        a=a0;b=b0;c=c0;
        cout<<"Yes"<<endl;
        for (int i=0;i<n;i++){
        switch(rr(v[i])){
            case 1:if (a>b){a--;b++;cout<<"B"<<endl;}
            else if(a<b) {b--;a++;cout<<"A"<<endl;}
            else if (i==n-1) {b--;a++;cout<<"A"<<endl;}
            else if ((v[i+1]=="AC")) {b--;a++;cout<<"A"<<endl;}
            else {a--;b++;cout<<"B"<<endl;}break;
            case 2:
                if (a>c){a--;c++;cout<<"C"<<endl;}
            else if(a<c) {c--;a++;cout<<"A"<<endl;}
            else if (i==n-1) {c--;a++;cout<<"A"<<endl;}
            else if ((v[i+1]=="AB")) {c--;a++;cout<<"A"<<endl;}
            else {a--;c++;cout<<"C"<<endl;}break;
            case 3:
                if (b>c){b--;c++;cout<<"C"<<endl;}
            else if(b<c) {c--;b++;cout<<"B"<<endl;}
            else if (i==n-1) {c--;b++;cout<<"B"<<endl;}
            else if ((v[i+1]=="AB")) {c--;b++;cout<<"B"<<endl;}
            else {b--;c++;cout<<"C"<<endl;}break;



}
        }
}


Measured memory_bytes: 7472
#include<stdio.h>
 
int main(void){
  int N,a,b;
  
  scanf("%d",&N);
  
  if(N==1){
    printf("Hello World");
  }
  
  if(N==2){
    scanf("%d%d",&a,&b);
    printf("%d",a+b);
  }
  
  return 0;
}

Measured memory_bytes: 128
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	

	long long N,M;
	cin>>N>>M;
	multiset<long long> V;
	vector<pair<long long,long long>> B(M);
	for (long long i = 0; i < N; ++i)
	{
		long long x;
		cin>>x;
		V.insert(x);
	}
	for (long long i = 0; i < M; ++i)
	{
		cin>>B[i].second>>B[i].first;		
	}
	sort(B.begin(), B.end(),greater<pair<long long,long long>>());
	for (long long i = 0; i < M; ++i)
	{
		long long x=0;
		auto it=V.begin();
		while(x<B[i].second && (*it)<B[i].first && x<N)
		{
			long long nv=B[i].first;
			V.erase(it);
			V.insert(nv);
			it=V.begin();
			x++;
		}
	}
	long long sum=0;
	while(V.size()>0)
	{
		auto it=V.begin();
		sum=sum+(*it);
		V.erase(it);
	}
	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 6528
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define MAXI(vec)                                                              \
  std::distance(vec.begin(), *std::max_element(vec.begin(), vec.end()));
#define MINI(vec)                                                              \
  std::distance(vec.begin(), *std::min_element(vec.begin(), vec.end()));
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define MATMUL(a, b, c)                                                        \
  REP(i, a.size())                                                             \
  REP(j, b[0].size()) REP(k, a[0].size()) c[i][j] ^= a[i][k] & b[k][j];
#define CLA2(a) REP(i, a.size()) REP(j, a[0].size()) a[i][j] = 0;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ll N, M;
  string S, T;
  cin >> N >> M >> S >> T;
  ll a = N;
  ll b = M;
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  ll x = N * M / b;
  REP(i, N) {
    if ((i * x * M / N) % x == 0 && (i * x * M / N) / x < M) {
      if (S[i] != T[i * x * M / (N * x)]) {
        x = -1;
        break;
      }
    }
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
    using namespace std;
    int main(){
     int a,b;
     cin>>a>>b;
     if(a==1)a=14;
     if(b==1)b=14;
     
     if(a>b)cout<<"Alice"<<endl;
     else if(a==b)cout<<"Draw"<<endl;
     else cout<<"Bob"<<endl;
     return 0;
    }

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


int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(h.rbegin(),h.rend());
    ll ans = 0;
    if(n <= k){
        ans = 0;
    }
    else{
        for(int i=n-1; i>=k; i--){
            ans += h[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define irp(i,s,e) for(int i=(int)(s);i>(int)(e);--i)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define chmin(x,y) x=min(x,(y));
#define chmax(x,y) x=max(x,(y));
using VL = vector<ll>;
using VVL = vector<VL>;

int main(){
	ll inf = 1e18;
	int N,M,X;
	cin>>N>>M>>X;
	VVL A(N);
	rep(i, N){rep(j, M+1){ll a; cin>>a;A[i].push_back(a);}}

	// for(auto v:A){for(auto a:v){cout<<a<<" ";}puts("");}
	// puts("---");

	ll ans = inf;
	rep(bit, 1<<N){ // [0,(2^N)-1] full search
		ll cost = 0;
		VL a(M,0);
		rep(book, N){ // [0,N-1]
			if(bit>>(N-1-book) & 1){ // buy
				cost += A[book][0];
				rep(j, M){
					a[j] += A[book][j+1];
				}
			}
		}
		bool ok = true;
		rep(i, M){
			if(a[i] < X){
				ok = false;
				break;
			}
		}
		if(ok){
			chmin(ans, cost);
		}
	}

	if(ans == inf) ans=-1;
	cout<< ans <<endl;
}


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

using namespace std;

#define endl "\n"
typedef long long int lli;

#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);

int hap[100001][3];
int memo[100001][3];
int n;

lli dp(int act, int pos){
	if(pos == n-1)
		return hap[pos][act];

	if(memo[pos][act] != -1)
		return memo[pos][act];

	lli ans = hap[pos][act];
	if(pos+1 < n)
		ans += max(dp((act+1)%3,pos+1), dp((act+2)%3,pos+1));
	return memo[pos][act] = ans;
}

int main(){
	cin >> n;
	for(int i=0; i<n; i++)
		cin >> hap[i][0] >> hap[i][1] >> hap[i][2];

	memset(memo, -1, sizeof(memo));
	lli mx = dp(0, 0);
	memset(memo, -1, sizeof(memo));
	mx = max(mx, dp(1,0));
	memset(memo, -1, sizeof(memo));
	mx = max(mx, dp(2,0));

	cout << mx << endl;
	return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#if ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define foreach(i, vec) for(auto &&i : vec)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) cerr << #x << ": " << (x) << endl
using namespace std;
typedef long long LL;
typedef long long int64;
typedef std::vector<int> VI;
typedef std::vector<VI> VVI;
typedef std::vector<LL> VL;
typedef std::vector<VL> VVL;
typedef std::vector<string> VS;
typedef std::pair<int, int> PII;
typedef std::pair<int64, int64> PLL;
typedef std::queue<int> QI;
typedef std::priority_queue<int> PQI;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>inline void vcinpb(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}

const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;
// M_PI 3.1415...

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cill(n);
    cill(m);
    LL ans = 0;
    VVI vvi(11);
    VI p;
    rep(i, m){
        cii(k);
        vcinpb(vvi[i], k);
    }
    vcinpb(p, m);
    rep(bit, (1<<n)){
        bool flag = true;
        rep(i, m){
            int sum = 0;
            for(auto&& j : vvi[i]){
                if(bit & (1<<j-1)){
                    sum++;
                }
            }
            flag = flag && (p[i] == sum % 2);
        }
        if(flag) ans++;
    }
    co(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

double dp[303][303][303];
int n;
int ct[4];

double calc(int c1, int c2, int c3){
	if(c1==0 && c2==0 && c3==0){
		return 0;
	}
	if(dp[c1][c2][c3]>0)
		return dp[c1][c2][c3];
	int c0 = n-(c1+c2+c3);
	double p0 = (double)c0/(double)n;
	double p1 = (double)c1/(double)n;
	double p2 = (double)c2/(double)n;
	double p3 = (double)c3/(double)n;
	double val = 1.0;
	if(c1){
		val += p1*calc(c1-1, c2, c3);
	}
	if(c2){
		val += p2*calc(c1+1, c2-1, c3);
	}
	if(c3){
		val += p3*calc(c1, c2+1, c3-1);
	}
	val /= (1-p0);
	dp[c1][c2][c3]=val;
	return val;
}

signed main()
{
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    cin>>n;
    For(i, 0, n){
    	int a; cin>>a;
    	ct[a]++;
    }
    double ans = calc(ct[1], ct[2], ct[3]);
    printf("%.10f\n", ans);
    return 0;
}





Measured memory_bytes: 217344
import java.util.Scanner;
class Main{
    public static void main(String arg[]){
        Scanner scn=new Scanner(System.in);
        int n= scn.nextInt();
        if(n%2==0){
            System.out.println(n);
        }else{
            System.out.println(n*2);
        }
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int m;
    cin >> m;
    ll ans = 0;
    ll sum = 0;
    for(int i = 0; i < m; i++)
    {
        ll d, c;
        cin >> d >> c;
        ans += c;
        sum += d * c;
    }
    ans--;
    ans += (sum-1) / 9;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())


int par[100010];  //親
int _rank[100010]; //木の深さ

// n要素で初期化
void init(int n){
      REP(i, n){
		par[i] = i;
          _rank[i] = 0;
	}
}
//木の根を求める
int find(int x){
	if(par[x] == x) return x;
	else return par[x] = find(par[x]);
}
//xとyの属する集合を結合
void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	if(_rank[x] < _rank[y]) par[x] = y;
	else{
		par[y] = x;
		if(_rank[x] == _rank[y]) _rank[x]++;
	}
}

int n, x[100010], y[100010];
set<int> xs[100010], ys[100010];

map<int, int> mapx;
map<int, int> mapy;

void solve() {
  cin >> n;
  init(n);
  REP(i, n) {
    cin >> x[i] >> y[i];
    if (mapx.count(x[i])) unite(i, mapx[x[i]]);
    mapx[x[i]] = i;
    if (mapy.count(y[i])) unite(i, mapy[y[i]]);
    mapy[y[i]] = i;
  }
  REP(i, n) {
    xs[find(mapx[x[i]])].insert(x[i]);
    ys[find(mapy[y[i]])].insert(y[i]);
  }
  LL res = 0;
  REP(i, n) {
    res += (LL)SZ(xs[i]) * SZ(ys[i]);
  }
  cout << res - n  << endl;
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 20608
from datetime import datetime as dt
S = input()
Sd = dt.strptime(S, '%Y/%m/%d')
Sd1 = dt.strptime("2019/04/30",'%Y/%m/%d')
if Sd > Sd1:
  r = 'TBD'
else:
  r = 'Heisei'
print(r)

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

typedef long long ll;
using namespace std;

int main() {
  int e;
  while(1){
    cin >> e;
    if(e == 0) break;
    int ans = e;
    for(int y = 0;y*y <= e; y++){
      for(int z = 0;z*z*z+y*y <= e; z++){
        int x = e -y*y-z*z*z;
        ans = min(ans,x+y+z);
      }
    }
    pout(ans);
  }
  return 0;
}


Measured memory_bytes: 3116
import java.util.*;

public class Main {

	public static int[] moveX = {0,0,-1,1};
	public static int[] moveY = {-1,1,0,0};
	public static char[][] map;
	public static boolean[][] check;
	public static int ans = 0;
	public static int x, y;

	public static void main (String[] args) {
		new Main().calc();
	}

	void calc () {
		Scanner sc = new Scanner(System.in);
		while (true) {
			x = sc.nextInt();
			y = sc.nextInt();

			if (x == 0) break;

			ans = 0;
			map = new char[y][x];
			check = new boolean[y][x];

			for (int i = 0; i < y; i++)
				map[i] = sc.next().toCharArray();

			main:
			for (int i = 0; i < y; i++) {
				for (int j = 0; j < x; j++) {
					if (map[i][j] == '@') {
						ans = 1;
						check[i][j] = true;
						dfs(i, j);
						break main;
					}
				}
			}
			System.out.println(ans);
		}
	}
	void dfs (int y, int x) {
		for (int i = 0; i < moveX.length; i++) {
			int nextX = x + moveX[i];
			int nextY = y + moveY[i];

			if (0 <= nextX && nextX < map[0].length &&
				0 <= nextY && nextY < map.length &&
				map[nextY][nextX] == '.' &&
				!check[nextY][nextX]) {

				ans++;
				check[nextY][nextX] = true;
				dfs(nextY,nextX);
			}
		}
	}
}

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

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    if(N % 2 != 0){
        cout << "No" << endl;
        return 0;
    }
    int half = S.size() / 2;
    for(int i=0;i<S.size()/2;i++){
        if(S[i] != S[i+half]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int n, m;	cin >> n >> m;
	vector<int> a(n);
	for (int i = 0; i < n; i++)	cin >> a[i];
	int cur = 0, ret = 0;
	do{
		int sml = 100, big = 0;
		for (int i = 0; i < m; i++) {
			sml = min(sml, a[cur]);
			big = max(big, a[cur]);
			cur = (cur + 1) % n;
		}
		ret += big - sml;
	} while (cur != 0);
	cout << ret << endl;
}

Measured memory_bytes: 3100
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#define lli long long int
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);


using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;
const int M = 1e6 + 500;

lli dp[N];

void solve()
{
    lli n;
    cin>>n;
    lli a[n];
    for(int i = 1; i <= n; i ++)
        cin>>a[i];
    for(int i = 1; i < n + 500; i ++)
        dp[i] = 1e9;
    dp[1] = 0;
    for(int i = 1; i <= n; i ++)
    {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i] - a[i + 1]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i] - a[i + 2]));
    }
    cout<<dp[n]<<endl;
    return ;
}
/*
10
6
10 3 2 5 7 8
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    lli t;
    t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


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

int main(){
	int n;
	double ans = 0;
	double max = 0;
	double x;
	
	cin >> n;
	while(n--){
		cin >> x;
		if(x > max) max = x;
		ans+=x;
	}
	ans-=max/2;
	
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL=int64_t;
const int INF=0x3f3f3f3f;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string a,b,c;
    cin>>a>>b>>c;
    int lena=a.length(),lenb=b.length();
    if(a[lena-1]==b[0]&&b[lenb-1]==c[0]) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define nl cout<<'\n';
int main()
{
    char a,b;
    cin>>a>>b;
    if(a>b)
      cout<<'>';
    else if(a==b)
      cout<<'=';
    else
      cout<<'<';
    nl;
    return 0;
}


Measured memory_bytes: 256
#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;
  }
   if(A+B<C+D){
     cout << "Right"<< endl;
   }
  
   if(A+B>C+D){
      cout << "Left" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int N, A, B;
	cin >> N >> A >> B;

	vector<int> X;
	inputVector(X, N);

	int ret = 0;

	rep(i, N - 1) {
		ret += min(A * (X[i + 1] - X[i]), B);
	}
	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = [int(x) for x in input().split()]


def check(a, t):
    ans = 0
    x = 0
    for i in a:
        x += i
        if t == True and x < 1:
            ans += 1 - x
            x = 1
        elif t == False and x > -1:
            ans += x + 1
            x = -1
        t = not t
    return ans


print(min(check(a, True), check(a, False)))


Measured memory_bytes: 14332
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1e18 + 10;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){ 
    int a, b; char op; cin >> a >> op >> b;
    if(op=='+')cout << a+b << ln;
    else cout << a-b << ln;
}

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

using namespace std;

using i64 = long long;

const i64 INF = 1e18 + 7;


i64 maxSubarrayXOR(vector<i64>& set, i64 n)
{
    // Initialize index of
    // chosen elements
    i64 index = 0;

    // Traverse through all
    // bits of i64eger
    // starting from the most
    // significant bit (MSB)
    for (i64 i = 62; i >= 0; i--)
    {
        // Initialize index of
        // maximum element and
        // the maximum element
        i64 maxInd = index;
        i64 maxEle = INT_MIN;
        for (i64 j = index; j < n; j++)
        {
            // If i'th bit of set[j]
            // is set and set[j] is
            // greater than max so far.
            if ( (set[j] & (1LL << i)) != 0
                     && set[j] > maxEle )
                maxEle = set[j], maxInd = j;
        }

        // If there was no
        // element with i'th
        // bit set, move to
        // smaller i
        if (maxEle == INT_MIN)
        continue;

        // Put maximum element
        // with i'th bit set
        // at index 'index'
        swap(set[index], set[maxInd]);

        // Update maxInd and
        // increment index
        maxInd = index;

        // Do XOR of set[maxIndex]
        // with all numbers having
        // i'th bit as set.
        for (i64 j=0; j<n; j++)
        {
            // XOR set[maxInd] those
            // numbers which have the
            // i'th bit set
            if (j != maxInd &&
               (set[j] & (1LL << i)) != 0)
                set[j] = set[j] ^ set[maxInd];
        }

        // Increment index of
        // chosen elements
        index++;
    }

    // Final result is
    // XOR of all elements
    i64 res = 0;
    for (i64 i = 0; i < n; i++)
        res ^= set[i];
    return res;
}

signed main(){
    i64 n;
    cin >> n;
    vector<i64> a(n);
    i64 xor_sum = 0;
    for(auto& x : a){
        cin >> x;
        xor_sum ^= x;
    }
    vector<i64> s;
    i64 ans = 0;
    for(i64 i = 0; i <= 61; ++i){
        if(bool(xor_sum & (1LL << i)) == 1){
            ans += xor_sum & (1LL << i);
            // always ok
        }else{
            s.emplace_back(i);
        }
    }
    for(auto& x : a){
        i64 i = 0;
        i64 x2 = 0;
        for(auto& y : s){
            x2 |= i64(bool(x & (1LL << y))) << i++;
        }
        x = x2;
    }
    i64 res = maxSubarrayXOR(a, n);
    i64 i = 0;
    for(auto& y : s){
        ans += 2 * (i64(bool(res & (1LL << i++))) << y);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int ans = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int m = sc.nextInt();
            ans += (d - 1) / m + 1;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 20820
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long h, long long w, std::vector<std::vector<long long>> a, std::vector<std::vector<long long>> b){
    int m = 12900;
    vector<bitset<25800>> dp(w);
    dp[0].set(m);
    dp[0] = (dp[0] << abs(a[0][0] - b[0][0]))
     | (dp[0] >> abs(a[0][0] - b[0][0]));

    for(int i = 0; i < h; ++i){
        decltype(dp) nex(w);
        for(int j = 0; j < w; ++j){
            if(j != w - 1){
                dp[j + 1] |= dp[j] << abs(a[i][j + 1] - b[i][j + 1]);
                dp[j + 1] |= dp[j] >> abs(a[i][j + 1] - b[i][j + 1]);
            }
            if(i != h - 1){
                nex[j] |= dp[j] << abs(a[i + 1][j] - b[i + 1][j]);
                nex[j] |= dp[j] >> abs(a[i + 1][j] - b[i + 1][j]);
            }
        }
        if(i != h - 1)
            dp = move(nex);
    }
    int ans = 1e9;
    for(int i = 0; i < 25600; ++i)
        if(dp.back()[i])
            ans = min(ans, abs(m - i));
        cout << ans << endl;
}


signed main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    std::vector<std::vector<long long>> A(H, std::vector<long long>(W));
    for(int i = 0 ; i < H ; i++){
        for(int j = 0 ; j < W ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    std::vector<std::vector<long long>> B(H, std::vector<long long>(W));
    for(int i = 0 ; i < H ; i++){
        for(int j = 0 ; j < W ; j++){
            scanf("%lld",&B[i][j]);
        }
    }
    solve(H, W, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 904
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi pair<ll,int> 
#define pii pair<int,ll>
 
ll mod = 1e9+7;
ll INF = 1e17;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
int main()
{
    IOS
    string s;
    cin>>s;
    ll q,t,f;
    char c;
    cin>>q;
    bool flag=0;
    string s1,s2;
    while(q--)
    {
        cin>>t;
        if(t==1)
        flag=!flag;
        else
        {
            cin>>f>>c;
            if(flag^(--f))
            s2+=c;
            else
            s1+=c;
        }
    }
    reverse(s1.begin(),s1.end());
    s1+=s;
    s1+=s2;
    if(flag)
    reverse(s1.begin(),s1.end());
    cout<<s1<<endl;
    return(0);
}


Measured memory_bytes: 1300