akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
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; }

struct UnionFind{
  // 小さい方を大きいほうにくっつける
  // これのおかげでO(logN)になる
  // 親をたどる際に途中経路に結果を残しておくことで根に直接葉をつなげる
  vector<int> d;
  UnionFind(int n=0):d(n,-1){}
  int find(int x){
    // 根を返すfind関数
    // d[x] < 0 -> xは根
    if(d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x,int y){
    x = find(x); y = find(y);
    if(x == y) return false;
    if(d[x] > d[y]) swap(x,y);
    // 根には自分を含めた項の数が負の数で入っている
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x,int y){return find(x) == find(y);}
  int size(int x){return -d[find(x)];}
};

signed main(){
  int n,m;
  cin >> n >> m;
  UnionFind UF(n);
  vvint to(m);
  rep(i,0,n){
    int k;
    cin >> k;
    rep(j,0,k){
      int a;
      cin >> a;
      a--;
      to[a].push_back(i);
    }
  }
  rep(i,0,m){
    if(to[i].empty()) continue;
    int FIRST = to[i][0];
    rep(j,1,to[i].size()){
      UF.unite(FIRST,to[i][j]);
    }
  }
  rep(i,0,n-1){
    if(!UF.same(i,i+1)){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 7680
#include <iostream>
#include <cstdio>
#include <cmath>

double a, b, x;

int main() {
    scanf("%lf %lf %lf", &a, &b, &x);
    if (a * a * b / 2.0 > x)
        printf("%0.9lf", 90 - atan(2 * x / (a * b * b)) * 180 / acos(-1));
    else printf("%0.9lf", 90 - atan(a * a * a / 2 / (a * a * b - x)) * 180 / acos(-1));
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y, ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        if(y%2==0)
         return (p*p)%z;
        else
        return (x*((p*p)%z))%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
ll po(ll x)
{
    ll c=0;
    while(x>0)
    {
        x=x&(x-1);
        c++;
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll n;
    string s;
    cin>>n>>s;
    ll w=0,r=0;
    ll m;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='W')
        w++;
        else
        r++;
    }
    m=min(w,r);
    ll c=0,d=0;
    for(int i=0;i<n-1;i++)
    {
        if(s[i]=='W')
        c++;
        else
        d++;
        ll z=min(c,r-d);
        if(c>=r-d)
         z=z+c-r+d;
        else
        z=z+r-d-c;
        m=min(m,z);
    }
    cout<<m;
    }

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 10000000007


ll dp1[300][300],dp2[300][300];
int main() {
	ll n,m,l;
	cin>>n>>m>>l;
	for(ll i=0;i<300;i++){
		for(ll j=0;j<300;j++){
			if(i!=j){
			dp1[i][j]=dp2[i][j]=inf;
			}
		}
	}
	for(ll i=0;i<m;i++){
		ll x,y,c;
		cin>>x>>y>>c;
		x--;y--;
		dp1[x][y]=c;
		dp1[y][x]=c;
	}	
	for(ll k=0;k<n;k++){
		for(ll i=0;i<n;i++){
			for(ll j=0;j<n;j++){
				dp1[i][j]=min(dp1[i][j],dp1[i][k]+dp1[k][j]);
			}
		}
	}
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			if(i==j){
				continue;
			}
			if(dp1[i][j]<=l){
				dp2[i][j]=1;
			}
		}
	}
	for(ll k=0;k<n;k++){
		for(ll i=0;i<n;i++){
			for(ll j=0;j<n;j++){
				dp2[i][j]=min(dp2[i][j],dp2[i][k]+dp2[k][j]);
			}
		}
	}
	ll q;
	cin>>q;
	for(ll i=0;i<q;i++){
		ll x,y;
		cin>>x>>y;
		x--;y--;
	//	cout << x<<y;
	if(dp2[x][y]==inf){
		cout << -1<<endl;
	}
	else{
		cout <<dp2[x][y]-1<<endl;
	}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 1920
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]


X,Y,Z,K = (int(x) for x in input().split())

A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

abc = [[0,0,0,A[0]+B[0]+C[0]]]
list_abc = [[0,0,0]]
#next_abc = [[1,0,0],[0,1,0],[0,0,1]]
#print(A[abc[0][0]]+B[abc[0][1]]+C[abc[0][2]])

for i in range(K):
    max_v = 0
    for j in range(len(abc)):
        if abc[j][3] > max_v:
            max_v = abc[j][3]
            temp_j = j
            
    max_abc = abc.pop(temp_j)
    #print(max_abc)
    #print(A[max_abc[0]]+B[max_abc[1]]+C[max_abc[2]])
    print(max_v)
    
    if max_abc[0]<X-1:
        if not([max_abc[0]+1, max_abc[1], max_abc[2]] in list_abc):
            abc.append([max_abc[0]+1,max_abc[1],max_abc[2],A[max_abc[0]+1]+B[max_abc[1]]+C[max_abc[2]]])
            list_abc.append([max_abc[0]+1, max_abc[1], max_abc[2]])
    if max_abc[1]<Y-1:
        if not([max_abc[0], max_abc[1]+1, max_abc[2]] in list_abc):
            abc.append([max_abc[0],max_abc[1]+1,max_abc[2],A[max_abc[0]]+B[max_abc[1]+1]+C[max_abc[2]]])
            list_abc.append([max_abc[0], max_abc[1]+1, max_abc[2]])
    if max_abc[2]<Z-1:
        if not([max_abc[0], max_abc[1], max_abc[2]+1] in list_abc):
            abc.append([max_abc[0],max_abc[1],max_abc[2]+1,A[max_abc[0]]+B[max_abc[1]]+C[max_abc[2]+1]])
            list_abc.append([max_abc[0], max_abc[1], max_abc[2]+1])
    #abc = get_unique_list(abc)
    #print(abc)


Measured memory_bytes: 4724
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	vs := make([]int, n)
	for i := range vs {
		fmt.Scan(&vs[i])
	}

	even := map[int]int{}
	odd := map[int]int{}
	for i, v := range vs {
		if i%2 == 0 {
			even[v]++
		} else {
			odd[v]++
		}
	}

	ek1, ev1 := mapMax(even)
	ok1, ov1 := mapMax(odd)
	if ek1 != ok1 {
		fmt.Println(n - ev1 - ov1)
		return
	}

	delete(odd, ok1)
	delete(even, ek1)
	_, ov2 := mapMax(odd)
	_, ev2 := mapMax(even)
	if ev1 == ov1 {
		fmt.Println(n - ev1 - max(ov2, ev2))
	} else if ev1 > ov1 {
		fmt.Println(n - ev1 - ov2)
	} else {
		fmt.Println(n - ov1 - ev2)
	}
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func mapMax(m map[int]int) (mk int, mv int) {
	for k, v := range m {
		if v > mv {
			mv = v
			mk = k
		}
	}
	return
}


Measured memory_bytes: 9280
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int INF = 1e12;

int p[21], q[21][51], r[21][51];
int costTable[21][100010];
int d[21][110][110];

signed main(){
    int n, m, c, s, g;
    while(cin >> n >> m >> c >> s >> g, n){
        s--; g--;
        rep(i, 0, c + 1){
            rep(j, 0, n){
                rep(k, 0, n){
                    d[i][j][k] = INF;
                }
                d[i][j][j] = 0;
            }
        }
        memset(p, 0, sizeof(p));
        memset(q, 0, sizeof(q));
        memset(r, 0, sizeof(r));
        memset(costTable, 0, sizeof(costTable));
        rep(i, 0, m){
            int x, y, di, ci;
            cin >> x >> y >> di >> ci;
            x--; y--; ci--;
            d[ci][x][y] = min(d[ci][x][y], di);
            d[ci][y][x] = min(d[ci][y][x], di);
        }
        rep(i, 0, c){
            cin >> p[i];
        }
        rep(i, 0, c){
            rep(j, 0, p[i] - 1) cin >> q[i][j];
            rep(j, 0, p[i]) cin >> r[i][j];
        }
        rep(i, 0, c){
            int idx = 0;
            costTable[i][0] = 0;
            rep(j, 1, 100010){
                costTable[i][j] = costTable[i][j - 1] + r[i][idx];
                // if(j <= 10) cout << i << ' ' << j << ' ' << costTable[i][j] << endl;
                if(j == q[i][idx]) idx++;
            }
        }
        rep(l, 0, c){
            rep(k, 0, n){
                rep(i, 0, n){
                    rep(j, 0, n){
                        d[l][i][j] = min(d[l][i][j], d[l][i][k] + d[l][k][j]);
                    }
                }
            }
        }
        rep(i, 0, n){
            rep(j, 0, n){
                rep(k, 0, c){
                    if(d[k][i][j] >= 100010) continue;
                    int tmp = costTable[k][d[k][i][j]];
                    d[c][i][j] = min(d[c][i][j], tmp);
                }
                // cout << i << ' ' << j << ' ' << d[c][i][j] << endl;
            }
        }
        rep(k, 0, n){
            rep(i, 0, n){
                rep(j, 0, n){
                    d[c][i][j] = min(d[c][i][j], d[c][i][k] + d[c][k][j]);
                }
            }
        }
        if(d[c][s][g] >= INF) cout << -1 << endl;
        else cout << d[c][s][g] << endl;
    }
}


Measured memory_bytes: 21400
h,w,d=map(int,input().split())
l=[[0,0]]+[[]for _ in range(h*w)]
for i in range(h):
    for j,a in enumerate(map(int,input().split())):
        l[a]=[i,j]
for a in l[:d]:
    a.append(0)
for i,j in zip(l[d:],l):
    a,b=i
    x,y,v=j
    i.append(abs(x-a)+abs(y-b)+v)
l=[c for a,b,c in l]
for _ in range(int(input())):
    a,b=map(int,input().split())
    print(l[b]-l[a])

Measured memory_bytes: 20064
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
class UnionFind {
  private:
    vector<int> parent;
    vector<int> height;
    vector<int> m_size;

  public:
    UnionFind(int size_) : parent(size_), height(size_, 0), m_size(size_, 1) {
        for(int i = 0; i < size_; ++i)
            parent[i] = i;
    }
    void init(int size_) {
        parent.resize(size_);
        height.resize(size_, 0);
        m_size.resize(size_, 0);
        for(int i = 0; i < size_; ++i)
            parent[i] = i;
    }
    int find(int x) {
        if(parent[x] == x)
            return x;
        return parent[x] = find(parent[x]);
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y)
            return;
        int t = size(x) + size(y);
        m_size[x] = m_size[y] = t;
        if(height[x] < height[y])
            parent[x] = y;
        else
            parent[y] = x;
        if(height[x] == height[y])
            ++height[x];
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) {
        if(parent[x] == x)
            return m_size[x];
        return size(parent[x] = find(parent[x]));
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    REP(i, M) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    int res = 0;
    REP(i, M) {
        UnionFind tree(N);
        tree.init(N);
        REP(j, M) {
            if(j == i) {
                continue;
            }
            tree.unite(a[j], b[j]);
        }
        if(tree.size(0) != N) {
            // cout << tree.size(0) << endl;
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = input().split()
H = list(map(int, input().split()))
P = [input().split() for i in range(int(M))]
candi = [num + 1 for num in range(int(N))]

for p in P:
    if H[int(p[0])-1] < H[int(p[1])-1]:
        try:
            candi[int(p[0])-1] = 0
        except ValueError:
            pass
    elif H[int(p[0])-1] == H[int(p[1])-1]:
        try:
            candi[int(p[0])-1] = 0
            candi[int(p[1])-1] = 0
        except ValueError:
            pass
    else:
        try:
            candi[int(p[1])-1] = 0
        except ValueError:
            pass
print(str(int(N) - candi.count(0)))

Measured memory_bytes: 105380
import java.util.Scanner;
public class Main{
	public static void main (String[] args){
		Scanner s = new Scanner(System.in);
		String str = s.nextLine();
		String strArray[] = str.split(" ");
		int a = Integer.parseInt(strArray[0]);
		int b = Integer.parseInt(strArray[1]);
		System.out.println((a*b) +" "+ 2*(a+b));
	}
}

Measured memory_bytes: 25848
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  int x; cin >> x;
  cout << (x >= 30 ? "Yes": "No") << endl;

  return 0;
}

// EOF

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 

const ll INF = 2e9;
const ll large_P = 1e9 + 7;


int main(){
  ll N, K;
  cin >> N >> K;
  
  ll Q = N/K;
  ll res = INF;
  
  if(abs(N - Q*K) > abs(N - Q*K - K)){
    res = abs(N - Q*K - K);
  }else{
    res = abs(N - Q*K);
  }
  
  
  
  
  cout << res;
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    final static long mod = 1000000007;
    //
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        if(c >= a + b && (c - a - b) * (c - a - b) > 4 * a * b){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 25300
n = int(input())
a = list(map(int, input().split()))
a.sort()
mod = 10**9+7

def pow(x, n):
    ans = 1
    n_tmp = n
    while n:
        if n % 2:
            ans *= x
            ans %= mod
        x *= x
        n >>= 1
    return ans

if n % 2 == 0:
    for i in range(n):
        if a[i] != 2*(i//2)+1:
            print(0)
            exit()
    print(pow(2, n//2))
else:
    for i in range(n):
        if a[i] != 2*((i+1)//2):
            print(0)
            exit()
    print(pow(2, n//2))


Measured memory_bytes: 20452
n,m,c = map(int, raw_input().split())
b = map(int, raw_input().split())
ans = 0
for i in xrange(n):
	a = map(int, raw_input().split())
	x = c
	for j in xrange(m):
		x += a[j]*b[j]
	if x > 0:
		ans += 1
print ans

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

ll mod = 1e9+7;

ll mul(ll a, ll b) {
	return a * b % mod;
}
ll power(ll x, ll n) {
	ll res = 1;
	for (ll i = 1; i <= n; i <<= 1) {
		if (n & i) res = mul(res, x);
		x = mul(x, x);
	}
	return res;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll m, n; cin >> m >> n;
	cout << power(m, n) << endl;
}

Measured memory_bytes: 3164
<?php
list($H, $W, $K) = ints();
for($i = 0; $i < $H; $i++){
  $map[] = str();
}
$c = 1;
for($x = 0; $x < $W; $x++){
  for($y = 0; $y < $H; $y++){
    if($map[$y][$x] == "#"){
      $map2[$y][$x] = $c++;
    }else{
      $map2[$y][$x] = 0;
    }
  }
}
for($x = 0; $x < $W; $x++){
  $c = 0;
  for($y = 0; $y < $H; $y++){
    if($map2[$y][$x]){
      $c = $map2[$y][$x];
    }else{
      $map2[$y][$x] = $c;
    }
  }
}
for($x = 0; $x < $W; $x++){
  $c = 0;
  for($y = $H - 1; $y >= 0; $y--){
    if($map2[$y][$x]){
      $c = $map2[$y][$x];
    }else{
      $map2[$y][$x] = $c;
    }
  }
}
for($y = 0; $y < $H; $y++){
  $c = 0;
  for($x = 0; $x < $W; $x++){
    if($map2[$y][$x]){
      $c = $map2[$y][$x];
    }else{
      $map2[$y][$x] = $c;
    }
  }
}
for($y = 0; $y < $H; $y++){
  $c = 0;
  for($x = $W - 1; $x >= 0; $x--){
    if($map2[$y][$x]){
      $c = $map2[$y][$x];
    }else{
      $map2[$y][$x] = $c;
    }
  }
}
for($y = 0; $y < $H; $y++){
  echo implode(" ", $map2[$y]), "\n";
}


function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 11256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int a = S[0] - '0';
    int b = S[1] - '0';
    int c = S[2] - '0';
    int d = S[3] - '0';
    if(a + b + c + d == 7) cout << a << "+" << b << "+" << c << "+" << d <<"=7" << endl;
    else if(a + b + c - d == 7) cout << a << "+" << b << "+" << c << "-" << d <<"=7" << endl;
    else if(a + b - c + d == 7) cout << a << "+" << b << "-" << c << "+" << d <<"=7" << endl;
    else if(a + b - c - d == 7) cout << a << "+" << b << "-" << c << "-" << d <<"=7" << endl;
    else if(a - b + c + d == 7) cout << a << "-" << b << "+" << c << "+" << d <<"=7" << endl;
    else if(a - b + c - d == 7) cout << a << "-" << b << "+" << c << "-" << d <<"=7" << endl;
    else if(a - b - c + d == 7) cout << a << "-" << b << "-" << c << "+" << d <<"=7" << endl;
    else if(a - b - c - d == 7) cout << a << "-" << b << "-" << c << "-" << d <<"=7" << endl;
    

    return 0;
}


Measured memory_bytes: 256
nm = input().split(" ")
n = int(nm[0])
m = int(nm[1])
inputlist = list()
count = 0
total = 0
if n >= m and m >= 1 and n >= 1 and n <= 100 and m <= 100:
    inputlist = input().split(" ")
    for i in inputlist:
        total = total + int(i)
    con = total / (m *4)
    for i in inputlist:
        i = int(i)
        if i >= con:
            count = count + 1
        else:
            count = count
    if count >= m:
        print("Yes")
    else:
        print("No")
else:
    print()
    
    


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  for(int i=0;i<w+2;++i) cout<<'#';
  cout<<endl;
  for(int i=0;i<h;++i){
    string s;
    cin>>s;
    cout<<'#'<<s<<"#\n";
  }
  for(int i=0;i<w+2;++i) cout<<'#';
  cout<<endl;
  return 0;
}


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

int main() {
  ios_base :: sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  ll x, y; cin >> x >> y;
  if( x == 1 or y == 1 ) {
    cout << 1;
    exit(0);
  }
  ll res = 0;
  ll p = x / 2, q = y / 2;
  if( x & 1 ) {
    res += ((p + 1) * q);
    if( y & 1 ) res += (p + 1);
    res += (p * q);
  }
  else {
    res += (p * y);
  }
  cout << res << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	string a, b, ans; cin >> a >> b;
    if (a.size() > b.size())
    {
        ans = "GREATER";
    }
    else if (a.size() < b.size())
    {
        ans = "LESS";
    }
    else
    {
        for (int i = 0; i < a.size(); i++)
        {
            if (a[i] - '0' > b[i] - '0')
            {
                ans = "GREATER";
                break;
            }
            else if (a[i] - '0' < b[i] - '0')
            {
                ans = "LESS";
                break;
            }
            else
            {
                if (i == a.size() - 1)
                {
                    ans = "EQUAL";
                }
            }
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const ll  MOD = 1000000007LL;
/*メモ 
*/
const int MAX = 500000;
long long fac[MAX], finv[MAX], inv[MAX]; 
void COMinit() {  //MOD combの計算を行う．COMinitを宣言してから以下のCOMルーチンを実行すればよい
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0ll;
    if (n < 0ll || k < 0ll) return 0ll;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
int main(){
    COMinit();
    ll n,k;
    std::cin >> n>>k;
    ll ans=COM(2*n-1,n);
   // std::cout << ans << std::endl;
    for (ll i = k+1; i <= n-1; i++) {
        /* code */
        ll dum=COM(n-1,n-i-1)*COM(n,n-i);
        dum%=MOD;
        ans-=dum;
        if(ans<0)ans+=MOD;
    }
    std::cout << ans << std::endl;
}
 



Measured memory_bytes: 11904
#include <iostream>
#include <string.h>
#define M 1046527
#define L 13

using namespace std;

char H[M][L];

int getChar(char c) {
    if(c == 'A') return 1;
    else if(c == 'C') return 2;
    else if(c == 'G') return 3;
    else if(c == 'T') return 4;
    else return 0;
}

long long getKey(char str[]) {
    long long p = 1, sum = 0;
    for(int i=0; i < strlen(str); i++) {
        sum += p * getChar(str[i]);
        p *= 5;
    }
    return sum;
}

int h1(int key) { return key % M; }

int h2(int key) { return 1 + (key % (M-1)); }

long long h(long long key, int i) { return (h1(key) + i * h2(key)) % M; }

void insert(char str[]) {
    long long key, idx;
    key = getKey(str);
    for(int i; i <= M; i++) {
        idx = h(key, i);
        if(strlen(H[idx]) == 0) {
            strcpy(H[idx], str);
            break;
        }
    }
}

int search(char str[]) {
    long long key, idx;
    key = getKey(str);
    for(int i; ; i++) {
        idx = h(key, i);
        if(!strcmp(H[idx], str)) return 1;
        else if(strlen(H[idx]) == 0) return 0;
    }
}

void initTable() { for(int i; i < M; i++) H[i][0] = '\0'; }

int main() {
    int n;
    string com;
    char str[L];
    initTable();
    cin >> n;
    for(int i=0; i < n; i++) {
        cin >> com >> str;
        if(com[0] == 'i') insert(str);
        else if(com[0] == 'f') {
            cout << (search(str) ? "yes" : "no") << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 16460
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int compare(string s, string t){
	int n = (int)s.length();
	int m = (int)t.length();
	if (n != m){
		if (n < m){
			return 1;
		}else{ // if (n > m)
			return -1;
		} // end if
	}else{
		rep (i, n){
			if (s[i] != t[i]){
				if (s[i] < t[i]){
					return 1;
				}else{ // if (s[i] > t[i])
					return -1;
				} // end if
			} // end if
		} // end rep
	} // end if

	return 0;
}
				
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	string A, B; cin >> A >> B;

	int res = compare(A, B);

	cout << (res == -1 ? "GREATER" : (res == 1 ? "LESS" : "EQUAL")) << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    s = input()

    if s == 'Sunny':
        print('Cloudy')
        sys.exit()
    elif s == 'Cloudy':
        print('Rainy')
        sys.exit()
    else:
        print('Sunny')


if __name__ == '__main__':
    main()

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int n;
	while(cin >> n&&n!=0){
		vector<int> v(n);
		for(int i=0;i<n;i++){
			cin >> v[i];
		}
		int mx = 0;
		for(int i=1;i<501;i++){
			vector<int>p;
			for(int j=0;j<n;j++){
				for(int k=0;k<9;k++){
					if(v[j]==(i*(1<<k))){
						p.push_back(v[j]/i);
					}
				}
			}
			int s=0;
			for(int j=0;j<p.size();j++){
				s+=p[j];
			}
			vector<int> dp(s+10,-1);
			dp[0] = 0;
			for(int j=0;j<p.size();j++){
				for(int k = (s/p[j])*p[j];k>0;k-=p[j]){
					if(dp[k-p[j]]!=-1){
						dp[k] = max(dp[k],dp[k-p[j]]+1);
					}
				}
			}
			for(int j=1;j<=s;j=j<<1){
				mx = max(mx,dp[j]);
			}
		}
		cout << mx << endl;
	}
	return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
//#include <unordered_map>
//#include <unordered_set>
#include <stack>
#include <set>
#include <queue>
#include <list>

using namespace std;
int ti[100005];
int main()
{
    int n,c,k,co=0,f=0,st=0;
    scanf("%d%d%d",&n,&c,&k);
    for(int i=0;i<n;++i) scanf("%d",&ti[i]);
    sort(ti,ti+n);
    st=ti[0];
    for(int i=0;i<n;++i)
    {
        if(ti[i]<=st+k)
        {
            ++f;
            if(f==c)
            {
                ++co;
                f=0;
                st=ti[i+1];
            }
        }
        else
        {
            ++co;
            f=1;
            st=ti[i];
        }
    }
    if(f) ++co;
    printf("%d",co);
    return 0;
}


Measured memory_bytes: 640
program main
Implicit None
	integer(8)::n,i,p1=0,p2=0
	character(len=100000)::s
	
	read*,s
	n = len_trim(s)
	
	do i =1,n
		if(mod(i,2)== 0)then
			if(s(i:i) == "0")then
				p1 = p1+1
			endif
			else
			if(s(i:i) == "1")then
				p1 = p1+1
			endif
		endif
	enddo
	
	do i =1,n
		if(mod(i,2)== 0)then
			if(s(i:i) == "1")then
				p2 = p2+1
			endif
			else
			if(s(i:i) == "0")then
				p2 = p2+1
			endif
		endif
	enddo
	
	print"(i0)",min(p1,p2)
end program main

Measured memory_bytes: 700
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func gcd(x, r int) int {
	if x < r {
		x, r = r, x
	}
	if x%r == 0 {
		return r
	}
	return gcd(r, x%r)
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a, b, c, d := nextInt(), nextInt(), nextInt(), nextInt()
	a--
	cd := (c * d) / gcd(c, d)
	fmt.Println((b - ((b / c) + (b / d) - (b / cd))) - (a - ((a / c) + (a / d) - (a / cd))))
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y,z;
	cin >> x >> y >> z;
	int ans=0;
	while(1){
		x-=z;
		x-=y;
		if(x>=z){
			ans++;
		}else{
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::collections::HashMap;

static MOD: usize = 1_000_000_007;

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

fn dfs(i: usize, s: &Vec<char>, n: usize, memo: &mut Vec<HashMap<Vec<char>, usize>>) -> usize {
    if i == n {
        return 1;
    }
    // println!("{:?}", memo);
    if memo[i].contains_key(s) {
        // println!("{:?}, {}", s, *memo[i].get(s).unwrap());
        return *memo[i].get(s).unwrap();
    }
    let mut candidates: Vec<char> = Vec::new();
    if s[1] == 'A' && s[2] == 'G' {
        candidates.push('A');
        candidates.push('T');
        candidates.push('G');       
    } else if s[0] == 'A' && s[2] == 'G' {
        candidates.push('A');
        candidates.push('T');
        candidates.push('G'); 
    } else if s[1] == 'G' && s[2] == 'A' {
        candidates.push('A');
        candidates.push('T');
        candidates.push('G'); 
    } else if s[1] == 'A' && s[2] == 'C' {
        candidates.push('A');
        candidates.push('T');
        candidates.push('C'); 
    } else if s[0] == 'A' && s[1] == 'G' {
        candidates.push('A');
        candidates.push('T');
        candidates.push('G'); 
    } else {
        candidates.push('A');
        candidates.push('T');
        candidates.push('G'); 
        candidates.push('C'); 
    }
    let mut sum = 0;
    for c in candidates {
        sum += dfs(i+1, &vec!(s[1], s[2], c).into_iter().collect(), n, memo);
    }
    sum %= MOD;

    let n = memo[i].entry(s.to_vec()).or_insert(0);
    *n = sum;
    return sum;
}

fn main() {
    let n: usize = input();
    let s: Vec<char> = "TTT".chars().collect();
    let mut memo: Vec<HashMap<Vec<char>, usize>> = vec![HashMap::new(); n];
    println!("{}", dfs(0, &s, n, &mut memo));
}


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

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  auto d = c - a - b;
  cout << (d > 0 && d * d > 4 * a * b ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<string> s(n);
    ll ac = 0, wa = 0, tle = 0, re = 0;
    rep(i, n) cin >> s[i];
    rep(i, n) {
        if (s[i] == "AC") ac++;
        else if (s[i] == "WA") wa++;
        else if (s[i] == "TLE") tle++;
        else if (s[i] == "RE") re++;
    }
    printf("AC x %lld\n", ac);
    printf("WA x %lld\n", wa);
    printf("TLE x %lld\n", tle);
    printf("RE x %lld\n", re);
    return 0;
}


Measured memory_bytes: 6364
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

ll A, B;

ll f(ll x) {
  ll f_x = 0;

  if ((x + 1) % 2 == 0) {
    ll one_cnt = (x + 1) / 2;
    f_x = one_cnt % 2;
  } else {
    ll one_cnt = (x + 1) / 2;
    f_x = one_cnt % 2;
    f_x ^= x;
  }

  return f_x;
}

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

  if (A == 0 && B == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (A == 0) {
    cout << f(B) << endl;
    return 0;
  }

  A--;

  // F(0, A-1)
  ll f_a = f(A);

  // F(0, B)
  ll f_b = f(B);

  cout << (f_a ^ f_b) << endl;
  return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int N, x;
    scanf("%d", &N);
    for(int i=1; i<=N; i++){
        x = i;
        if(i % 3 == 0)
            printf(" %d", i);
        else{
            while(x){
                if(x % 10 == 3){
                    printf(" %d", i);
                    break;
                }
                x /= 10;
            }
        }
    }
    printf("\n");
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N+1);
  A.at(0) = 1;
  for (int i=1; i<=N; i++) {
    cin >> A.at(i);
  }
  vector<int> A_num(N+1);
  A_num.at(0) = 1;
  int num = 0;
  for (int j=1; j<=N; j++) {
    A_num.at(j) = A.at(A_num.at(j-1));
    num ++;
    if (A_num.at(j) == 2) {
      cout << num << endl;
      break;
    }
    else if (j == N && A_num.at(N) != 2) {
      cout << -1 << endl;
    }
  }
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    int ans = 0;
    for (int i = 0; i < N; i++){
        for (int j = i + 1; j < N;j++){
            ans = max(ans, abs(A.at(i) - A.at(j)));
        }
    }
    cout << ans << endl;
}

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 argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> v;
    REP(i, 2 * N) {
        int tmp; cin >> tmp;
        v.push_back(tmp);
    }
    sort(v.begin(),v.end());
    int res = 0;
    REP(i, N) {
        res += v[2*i];
    }
    cout << res << endl;
    return 0;
}


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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int a, b, c;
	cin >> a >> b >> c;
	int cur = min(b, c);
	LL ans = 2 * cur;
	b -= cur;
	c -= cur;
	if(c > 0)
	{
		ans += min(c, a + 1);
	}
	else
	{
		ans += b;
	}
	cout << ans;
	return 0;
}

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

int main() {
  double a, b, n;
  cin >> a >> b >> n;
  double x = min(n,b-1);
  cout << floor(a*x/b) - a*floor(x/b) << endl;
  return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong N;
  vector<llong> A;

  cin >> N;
  A.resize(N + 1);
  map<llong, llong> m;
  llong ans = 0;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    ans += m[i - A[i]];
    m[i + A[i]]++;
  }

  cout << ans << endl;

  return 0;
}

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

int main(){
    int N, X;
    cin >> N >> X;
    vector<int> m(N);
    for(int i = 0; i < N; i ++){
        cin >> m.at(i);
    }
    int nokori = X;
    int mini = 100000;
    for(int i = 0; i < N; i ++){
        nokori -= m.at(i);
        mini = min (m.at(i), mini);
    }
    int num = nokori / mini;
    cout << N + num << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    int p, q, r; cin >> p >> q >> r;

    cout << min({p + q, q + r,  r + p}) << endl;

    return 0;
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
	lli n, i, j, k;
	bool c;
	
	cin >> n;

	c = true;

	k = n / 11 * 2;
	j = n % 11;
	if (j != 0) {
		if (j <= 6)
			k++;
		else
			k += 2;
	}

	cout << k;

	return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  for(int i = 0 ;i<n;i++){
    if(i != k-1){
      cout << s.at(i);
    }
    else {
      if(s.at(i) == 'A'){
        cout << 'a';
      }
      else if(s.at(i) == 'B'){
        cout << 'b';
      }
      else {
        cout << 'c';
      }
    }
  }
  
  cout << endl;
}


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


using namespace std;

int main() {
	string inp;
	cin>>inp;
	if (inp[0]!=inp[1]){
		cout<<"Yes"<<endl;
	}else if(inp[0]!=inp[2]){
		cout<<"Yes"<<endl;
	}else {cout<<"No"<<endl;}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int cup[3]={1,0,0}, temp=0, count=0;
  char cup_str[5]="ABC,";
  char cup1, cup2, cup3;

  while(1){
    cin>>cup1>>cup2>>cup3;

    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
        if(cup1==cup_str[j] && cup3==cup_str[i]){
          temp=cup[j];
          cup[j]=cup[i];
          cup[i]=temp;
        }
      }
    }

    count++;
    if(count==50)
      break;
  }

  for(int i=0;i<3;i++){
    if(cup[i]==1)
      cout<<cup_str[i]<<endl;
  }

  return 0;
}



Measured memory_bytes: 3072
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <iomanip>
#include <time.h>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    ll money=1000,stock=0;
    for(int i=0; i<N-1; i++){
        money+=stock*A[i];
        if(A[i]>A[i+1]) stock=0;
        else{
            stock=money/A[i];
            money-=stock*A[i];
        }
    }
    cout << money+stock*A[N-1] << endl;

    
    

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){

	for(int i=0;i<3;i++){
		int h1, m1, s1, h2, m2, s2;
		cin>>h1>>m1>>s1>>h2>>m2>>s2;
		int h3, m3, s3;
		if(s1 > s2 && m1 > m2) h3 = h2 - h1 - 1, m3 = m2 - m1 + 59, s3 = s2 - s1 + 60;
		if(s1 > s2 && m1 < m2) h3 = h2 - h1, m3 = m2 - m1 - 1, s3 = s2 - s1 + 60;
		if(s1 > s2 && m1 == m2) h3 = h2 - h1 - 1, m3 = m2 - m1 + 59, s3 = s2 - s1 + 60;
		if(s1 <= s2 && m1 > m2) h3 = h2 - h1 - 1, m3 = m2 - m1 + 60, s3 = s2 - s1;
		if(s1 <= s2 && m1 <= m2) h3 = h2 - h1, m3 = m2 - m1, s3 = s2 - s1;
		cout<<h3<<" "<<m3<<" "<<s3<<endl;
	}

	return 0;
} 



Measured memory_bytes: 3076
#include<stdio.h>
#include<stdlib.h>

struct node{
  int right;
  int left;
  int parent;
  int id;
};

#define MAX 500001
#define N 2000000001

struct node T[MAX];

int n;

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

void insert(){
  int i;
  for(i = 1; i <= n/2; i++){
    T[2*i].parent = parent(i);
    T[2*i].left = left(i);
    T[2*i].right = right(i);
  }
}

void maxHeapify(int i){
  int h, l, r, largest;
  l = left(i);
  r = right(i);
  if(l <= n && T[l].id > T[i].id) largest = l;
  else largest = i;
  if(r <= n && T[r].id > T[largest].id) largest = r;
  if(largest != i){
    h = T[i].id;
    T[i].id = T[largest].id;
    T[largest].id = h;
    maxHeapify(largest);
  }
}

void buildMaxHeap(){
  int i;
  for(i=n/2; i>0; i--) maxHeapify(i);
}

void print(){
  int i;
  buildMaxHeap();
  for(i=1; i<=n; i++) printf(" %d", T[i].id);
}

int main(){
  int i;

  scanf("%d", &n);
  for( i = 1; i <= n; i++ ) scanf("%d", &T[i].id);
  insert();
  print();
  printf("\n");
  return 0;
}

Measured memory_bytes: 8412
#include<iostream>
    #include<string>
    using namespace std;
     
    int a,b;
    string s;
     
    int main(){
        cin >> a >> b >> s;
        for(int i = 0; i < s.size(); i++){
            if( (i != a) && s[i] == '-'){
                cout << "No" << endl;
                return 0;
            }else if((i == a) && s[i] != '-'){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  string s;
  cin >> s;
  ll n = s.size();
  // dp[i][s] .. the count for [0, i). If s is 1, using + 1 in i-1.
  vector<vector<ll>> dp(n+1, vector<ll>(2));
  dp[0][1] = 1;
  rep(i, n) {
    int d = s[i] - '0';
    dp[i+1][0] = min(dp[i][0] + d,     dp[i][1] + 10 - d); // same
    dp[i+1][1] = min(dp[i][0] + d + 1, dp[i][1] + 10 - d - 1); // + 1
    // cout << "dp["<<i+1<<"][0]: " << dp[i+1][0] << endl;
    // cout << "dp["<<i+1<<"][1]: " << dp[i+1][1] << endl;
  }
  cout << dp[n][0] << endl;
}


Measured memory_bytes: 55964
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[int(input()) for i in range(n)]
    light=0
    cnt=0
    while True:
        if l[light]==2:
            cnt+=1
            print(cnt)
            break
        else:
            if cnt>n:
                print(-1)
                break
            else:
                light=l[light]-1
                cnt+=1
            
resolve()


Measured memory_bytes: 43612
/*{{{*/
#include<bits/stdc++.h>

typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORR(i,a,b) for(ll i=b-1;i>=a;i--)

#define vl vector<ll>
#define pll pair<ll,ll>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;
/*}}}*/

int main() {
  ll n;
  cin >> n;
  ll ans = n + n*n + n*n*n;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
int A[1000000],n;
int main(){
  int i,q,k,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(binarySearch(k)==1){
      sum++;
    }
  }
  printf("%d\n",sum);
  return 0;
}
 
int binarySearch(int key){
  int a=0,b=n,c;
  while(a < b){
    c=(a+b)/2;
    if(key==A[c]){
      return 1;
    }
    if(key>A[c]){
      a=c+1;
    }
    else if (key<A[c]){
      b=c;
    }
  }
  return 0;
}

Measured memory_bytes: 988
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    deque<ll> a(n);
    FOR(i, 0, n)cin >> a[i];

    multiset<ll> set;
    set.insert(a[0]);
    FOR(i, 1, n) {
        set.insert(a[i]);
        if (*set.begin() < a[i]) {
            auto itr = set.find(a[i]);
            set.erase(--itr);
        }
    }
    cout << set.size() << "\n";
}

Measured memory_bytes: 5760