akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}

func countBounding(x int, ls []int) (boundNum int) {
	boundNum = 1
	n := len(ls)
	d := make([]int, n+1)
	d[0] = 0
	for i, l := range ls {
		next := d[i] + l
		if x < next {
			break
		}
		boundNum++
		d[i+1] = next
	}
	return
}

func main() {
	n, x := nextInt(), nextInt()
	ints := nextInts(n)
	r := countBounding(x, ints)
	fmt.Println(r)
}


Measured memory_bytes: 640
#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;
	cin >> n;
	vector<int> x(n),y(n);
	rep(i,n){
		cin >> x[i] >> y[i];
	}
	ll k = 1;
	for(int i(1);i<=n;++i){
		k *= i;
	}
	ll m = k*2/n;
	long double s(0);
	rep(i,n){
		rep(j,n){
			if(i>j){
				s += sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
			}
		}
	}
	long double ans = s*m/k;
	cout << setprecision(20)<<ans << endl;
	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i = 0; i < N; i++) cin >> h.at(i);
  int count = 0;
  for(int i = 0; i < N; i++){
    if(h.at(i) >= K) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 640
#include "stdio.h"

typedef struct {
	int Arrive[3];
	int Leave[3];
}Time;

void timecal(int arrive[3], int leave[3], int result[3])
{
	int temp;
	for (temp = 2; temp > 0; temp--) {
		result[temp] = (leave[temp] - arrive[temp]);
		if (result[temp] < 0) {
			result[temp] = 60 + result[temp];
			leave[temp - 1]--;
		}

		result[0] = leave[0] - arrive[0];
	}
}

int main(void) {
	int temp;
	int res1[3], res2[3], res3[3];
	Time A;
	Time B;
	Time C;
	for (temp = 0; temp < 3; temp++)
	{
		scanf("%d", &A.Arrive[temp]);

	}	
	for (temp = 0; temp < 3; temp++) {
		scanf("%d", &A.Leave[temp]);
	}
	for (temp = 0; temp < 3; temp++)
	{
		scanf("%d", &B.Arrive[temp]);
	}
	for (temp = 0; temp < 3; temp++) {
		scanf("%d", &B.Leave[temp]);
	}
	for (temp = 0; temp < 3; temp++)
	{
		scanf("%d", &C.Arrive[temp]);
	}
	for (temp = 0; temp < 3; temp++) {
		scanf("%d", &C.Leave[temp]);
	}
	timecal(A.Arrive, A.Leave,res1);
	printf("%d %d %d\n", res1[0], res1[1], res1[2]);
	timecal(B.Arrive, B.Leave,res2);
	printf("%d %d %d\n", res2[0], res2[1], res2[2]);
	timecal(C.Arrive, C.Leave,res3);
	printf("%d %d %d\n", res3[0], res3[1], res3[2]);
	return 0;
	}

Measured memory_bytes: 1808
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  vi s(n);
  REP(i, n) { cin >> s[i]; }
  int q;
  cin >> q;
  int ans = 0;
  REP(i, q) {
    int t;
    cin >> t;

    int ok = 0;
    int ng = n;
    while (abs(ok - ng) > 1) {
      int mid = (ok + ng) / 2;
      if (s[mid] <= t) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    if (s[ok] == t)
      ans++;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3120
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(Math.min(c, a + b + 1) + b);
    }
}

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

int main(){
    int r, c;
    cin >> r >> c;
    
    vector<int> sum_c, sum_r;
    sum_c.resize(c);
    sum_r.resize(r);
  
  	int sum = 0;
    
    int tmp = 0;
    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
          	tmp = 0;
            cin >> tmp;
            sum_r[i] += tmp;
            sum_c[j] += tmp;
          	sum += tmp;
            if(j!=0) cout << " ";
            cout << tmp;
        }
      	cout << " " << sum_r[i] << "\n";
    }
    for(int j=0; j<c; j++){
        if(j!=0) cout << " ";
        cout << sum_c[j];
    }
  	cout << " " << sum << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
	ll n;
	scanf("%lld",&n);
	ll ans=n-1;
	ll tmp=n;
	ll tmp2=1;
	for(ll i=(int)sqrt(n);i>=2;i--){
		while(tmp%i==0){
			tmp/=i;
			tmp2*=i;
			ans=min(ans,tmp2+tmp-2);
		}
	}
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 256
#a,b=map(int,input().split())
#p_3,p_4=map(int,input().split())
n=int(input())
#S=input()
#T=input()
#recipe=[list(input().split())for _ in range(n)]
#m=int(input())
#have=[list(input().split())for _ in range(m)]
#s=[list(input())for _ in range(n)]
#h=list(map(int,input().split()))
#v=list(map(int,input().split()))
#c=list(map(float,input().split()))
#n=int(input())
#s=[list(map(int,input().split()))for _ in range(n)]
#s=[list(input().split())for _ in range(n)]
#s=[input()for _ in range(n)]
print(n**3)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
const ll INF = 1ll << 60;

int main()
{

    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    rep(i, n)
    {
        if (v[i] % 2 == 0)
        {
            if (v[i] % 3 != 0 && v[i] % 5 != 0)
            {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
int dp[2][3];

int main() {
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j  < 3; j++) cin >> dp[1][j];
        dp[1][0] += max(dp[0][1],dp[0][2]);
        dp[1][1] += max(dp[0][0],dp[0][2]);
        dp[1][2] += max(dp[0][1],dp[0][0]);
        for(int j = 0; j < 3; j++) dp[0][j] = dp[1][j];
    }
    cout << max({dp[0][0],dp[0][1],dp[0][2]}) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <cassert>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <cstdlib>
#include <string>
#include <unordered_map>
#include <map>
#include <sstream>
#include <bitset>
#include <random>
#include <tuple>
#include <array>
#include <tgmath.h>
#include <functional>
#include <climits>
#include <complex>
#include <unistd.h>
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef pair<lli, lli> plli;
typedef unsigned char byte;
typedef unsigned int uint;
typedef unsigned long long int ulli;

typedef tuple<lli, lli, lli, lli> tl4;

plli maxes[300100];
lli arr[300100];

void insert_plli(plli &v, lli vv) {
    if (v.first == vv || v.second == vv) return;
    if (v.first < vv) {
        v.second = v.first;
        v.first = vv;
    } else if (v.second < vv) {
        v.second = vv;
    }
}

void insert_plli(plli &v, plli vv) {
    insert_plli(v, vv.first);
    insert_plli(v, vv.second);
}

int main() {
    int n;
    scanf("%d", &n);
    int N = 1 << n, i, j;
    for (i=0; i<N; ++i) {
        scanf("%lld", arr+i);
        arr[i] = (arr[i] << n) | i;
    }
    maxes[0] = plli(arr[0], 0);
    for (i=0; i<N; ++i) {
        for (j=0; j<n; ++j) {
            if (i & (1 << j)) {
                insert_plli(maxes[i], maxes[i & ~(1 << j)]);
            }
        }
        insert_plli(maxes[i], arr[i]);
    }
    lli now_v = 0;
    for (i=1; i<N; ++i) {
        printf("%lld\n", now_v = max(now_v, (maxes[i].first >> n) + (maxes[i].second >> n)));
    }
    return 0;
}


Measured memory_bytes: 9472
// ?????????????????????

#include<iostream>
#include<vector>
#include<map>

using namespace std;
#define int long long
#define repeat(i,n) for(int i=0;i<(n);i++)
#define reveat(i,n) for(int i=(n)-1;i>=0;i--)

class SegmentTree{

public:
   static const int N=1<<20;
   vector<int> seg;
   SegmentTree(){
      seg.resize(2*N-1, 0);
   }

   void add(int i, int x){
      i+=N-1;
      seg[i]+=x;
      while(i){
         i=(i-1)/2;
         seg[i]=seg[2*i+1]+seg[2*i+2];
      }
   }

   int getsum(int a, int b, int i=0, int l=0, int r=N){
      if(b<=l or r<=a){
         return 0;
      }else if(a<=l and r<=b){
         return seg[i];
      }else{
         int m=(r+l)/2;
         return getsum(a, b, 2*i+1, l, m)+getsum(a, b, 2*i+2, m, r);
      }
   }
};

signed main(){

   int N, Q;
   cin>> N>> Q;

   SegmentTree st;
   while(Q--){
      int c, a, b;
      cin>> c>> a>> b;
      if(c==0){
         st.add(a-1, b);
      }else{
         printf("%lld\n", st.getsum(a-1, b));
      }
   }

   return 0;
}

Measured memory_bytes: 19176
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
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; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int N,M,A[200000]={},B[200000]={};
  cin >> N >> M;
  rep(i,M){
    int a,b;
    cin >> a >> b;
    if(a==1) A[b]++;
    if(b==N) B[a]++;
  }
  rep(i,N+1){
    if(A[i]!=0 && B[i]!=0){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 3456
// +build ignore
package main

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

func solve(sc *scanner, wr *bufio.Writer) int {
	N := sc.i()

	ans := map[int]int{}

	nmax := 10050
	for x := 1; x*x <= nmax; x++ {
		for y := 1; (x*x + y*y + x*y) <= nmax; y++ {
			for z := 1; x*x+y*y+z*z+x*y+y*z+x*z <= nmax; z++ {
				v := x*x + y*y + z*z + x*y + y*z + x*z
				if v < nmax {
					ans[v]++
				}
			}
		}
	}

	for i := 1; i <= N; i++ {
		fmt.Println(ans[i])
	}

	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}


Measured memory_bytes: 2564
from bisect import bisect_right, bisect_left
from itertools import groupby, permutations, combinations
from fractions import gcd
import numpy as np
from sys import stdin, stderr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def main():
    N, K, S = [int(x) for x in input().split()]
    if S < 10**9:
        return ([S] * K) + ([S+1] * (N-K))
    else:
        return ([S] * K) + ([1] * (N-K))


if __name__ == "__main__":
    print(" ".join([str(x) for x in main()]))

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

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

  long long ans = 0;
  vector<long long> a(s.size() + 1), b(s.size() + 1);

  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '<') a[i + 1] = a[i] + 1;
  }

  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == '>') b[i] = b[i + 1] + 1;
  }

  for (int i = 0; i <= s.size(); i++) ans += max(a[i], b[i]);
  cout << ans << endl;
}

Measured memory_bytes: 8708
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

func generate(tick, limitBase float64, numPerTick int) int {
	limit := limitBase + 0.5
	pass := 0.0

	num := 0

	for pass+tick <= limit {
		num += numPerTick
		pass += tick
	}
	return num
}

func main() {
	a, b, t := nextInt(), nextInt(), nextInt()
	r := generate(float64(a), float64(t), b)
	fmt.Println(r)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll i,j;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n;
    cin>>n;
    ll a[100];
    a[0]=2,a[1]=1;
    for(i=2;i<=n;i++)
        a[i]=a[i-1]+a[i-2];
    cout<<a[n]<<endl;
}



Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = float('inf')
    for k in range(min(A), max(A)+1):
        cost = 0
        for a in A:
            cost += (a-k)**2
        ans = min(ans, cost)
        if ans == 0:
            break
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
//for(int i = 0; i < n; i++)
 
int main() {
  int a, b, ans = 0, m1, d1, m2;
  double ntax, n;
  //string s;
  cin >> n;
  ntax = n / 1.08;
  if(ntax - floor(ntax) <= 0.1 && ntax - floor(ntax) >= 0.001) {
    cout << ":(\n";
    return 0;
  }
  //vector<int> v(n), c(n);
  //if(m1 != m2) {}
  //for(int i = 0; i < n; i++){}
  cout << ceil(ntax) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

inline int read()
{
	int x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}

const int N=200009;

int n,m;
vector<int> g[N];
int stk[N],top;

int main()
{
	n=read();
	m=read();

	for(int i=1,u,v;i<=m;i++)
	{
		u=read();
		v=read();
		g[u].push_back(v);
		g[v].push_back(u);
	}

	for(int i=0;i<g[1].size();i++)
		stk[++top]=g[1][i];
	for(int i=0;i<g[n].size();i++)
		stk[++top]=g[n][i];

	sort(stk+1,stk+top+1);
	int tmp=top;
	top=unique(stk+1,stk+top+1)-stk-1;

	if(tmp!=top)
		puts("POSSIBLE");
	else
		puts("IMPOSSIBLE");

	return 0;
}


Measured memory_bytes: 12784
#include <stdio.h>
#include <math.h>
#include <cmath>
#include <iostream>

using namespace std;

typedef long long int ll;

const long long INF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9; 
 
int main(void){
    int n,k;
    // int n;
    scanf("%d", &n);
    scanf("%d", &k);

    ll h[n];
    ll costs[n];
    costs[n - 1] = 0;

    for( int i = 0; i < n; ++i ){
        ll height;
        scanf("%lld", &height);
        h[i] = height;
    }
    for( int i = n - 2; i >= 0; --i ){
        // printf("%s\n", "========");
        ll c;
        c = INF;

        for (int a = 1; a <= k && a < n - i; ++a) {
            // printf("%s\n", "---");
            // printf("jump_range: %d\n", a);
            // printf("current: %d\n", i);

            int jump_to;
            jump_to = i + a;
            ll jump_cost;
            jump_cost = abs(h[jump_to] - h[i]) + costs[jump_to];

            // printf("jump_to: %d\n", jump_to);
            // printf("jump_cost: %lld\n", jump_cost);

            if (c > jump_cost)
            {
                c = jump_cost;
            }
        }
        // printf("%d\n", i);
        // printf("%lld\n", c);
        costs[i] = c;
    }
    // printf("result: %lld", costs[0]);
    printf("%lld", costs[0]);
    return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }


int solve(int N, int M) {
    set<int> y;
    for (int d=1; d<=M/d; ++d) {
        if (M % d == 0) {
            y.insert(d);
            y.insert(M/d);
        }
    }
    for (auto it=y.rbegin(); it!=y.rend(); ++it) {
        int d = *it;
        if (N <= M/d) return d;
    }
    return 1;
}

int main() {
    int N, M; cin >> N >> M;
    cout << solve(N, M) << endl;
    return 0;
}


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

int main() {
  string S1,S2,S3;
  cin >> S1 >> S2 >> S3;
  S1[0] -= 32;
  S2[0] -= 32;
  S3[0] -= 32;
  cout << S1[0] << S2[0] << S3[0] << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics; 

class _Class
{
  void _Do()
  {
    var NK = Split.ints();
    var N = NK[0];
    var K = NK[1];
    var Ai = Split.ints();

    //
    int mini = 0;
    {
      for (int j = 0; j < N; j++)
      {
        if (Ai[j] < Ai[mini])
          mini = j;
      }
    }

    //
    int ret = int.MaxValue;

    //
    for (int scan=mini-K+1;scan<mini+K-2 ;scan++ )
    {
      int z = 1;

      //
      for (int kk=0;;kk-=K-1)
      {
        var left = mini-scan + kk;
        if (left<=0)
          break;

        z++;
      }

      //
      for (int kk=0;;kk+=K-1)
      {
        var right = mini-scan + kk;
        if (right+K>= Ai.Length)
          break;

        z++;
      }
      ret = Math.Min(z,ret);

    }

    Console.WriteLine(ret);

  }


  //
  static void Main(string[] args)
  {
    _(args);
    new _Class()._Do();
  }

  [Conditional("DEBUG")]
  static void _(string[] args)
  {
    if (args.Length != 0 && File.Exists(args[0]))
      Console.SetIn(new StreamReader(args[0]));
    else
      Console.Error.WriteLine("in");
  }
}

static class Split
{


  // 1
  public static string[] strings()
  {
    return Console.ReadLine().Split();
  }


  // [2.1] -2,147,483,648 ~ +2,147,483,647
  public static int[] ints()
  {
    var _s = Console.ReadLine().Split();

    var x = new int[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = int.Parse(_s[i]);

    return x;
  }

  // [2.2] 
  // -9,223,372,036,854,775,808 ~ 
  // +9,223,372,036,854,775,807
  public static long[] longs()
  {
    var _s = Console.ReadLine().Split();

    var x = new long[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = long.Parse(_s[i]);

    return x;
  }

  public static double[] doubles()
  {
    var _s = Console.ReadLine().Split();

    var x = new double[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = double.Parse(_s[i]);

    return x;
  }

  public static BigInteger[] bigs()
  {
    var _s = Console.ReadLine().Split();

    var x = new BigInteger[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = BigInteger.Parse(_s[i]);

    return x;
  }
}




Measured memory_bytes: 18784
import java.util.*;

public class Main {


    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int time_1 = 50;
        int time_2 = 15;

        int D = sc.nextInt();
        int[] c = new int[27];
        int[] t = new int[D + 1];
        int[] last_day = new int[27];
        Arrays.fill(last_day, 0);
        int[][] s = new int[D + 1][27];
        for (int i = 1; i <= 26; i++) {
            c[i] = sc.nextInt();
        }
        for (int i = 1; i <= D; i++) {
            for (int j = 1; j <= 26; j++) {
                s[i][j] = sc.nextInt();
            }
        }

        for (int i = 1; i <= D; i++) {
            Random random = new Random();
            t[i] = 1 + random.nextInt(26);
        }
        int[] last_array = t;

        long last_sum = 0;
        for (int j = 0; j < time_1; j++) {
            long tmp_sum = 0;
            for (int k = 0; k < time_2; k++) {
                Random random = new Random();
                int d = 1 + random.nextInt(D);
                int q = 1 + random.nextInt(D/2);
                int tmp = t[d];
                t[d] = t[q];
                t[q] = tmp;
            }
            for (int i = 1; i <= D; i++) {
                last_day[t[i]] = i;
                tmp_sum += calcS(c, s, t[i], i, last_day);
            }
            if (tmp_sum > last_sum) {
                last_array = t;
                last_sum = tmp_sum;
            } else {
                t = last_array;
            }
        }


        for (int i = 1; i <= D; i++) {
            System.out.println(t[i]);
        }

    }

    private static long calcS(int[] c, int[][] s, int kaisai, int day, int[] last_day) {

        long loss = 0;
        for (int i = 1; i <= 26; i++) {
            if (i == kaisai) {
                last_day[i] = day;
                continue;
            }
            loss -= c[i] * (day - last_day[i]);
        }

        long plus = s[day][kaisai];
        return plus + loss;
    }

}


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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

int main() {
  int n;
  cin >> n;
  cout << (n % 2 == 0 ? n : 2 * n) << endl;
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

int main()
{
    int x, a, b; cin >> x >> a >> b;

    cout << ((abs(x - a) < abs(x - b)) ? "A" : "B") << endl;

    return 0;
}

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

int main(){
    int n,x;
    int m;
    for (m=1;m>0;m++){
        
        cin >> n >> x;
        if((n==0)and(x==0)){
            break;
        }
        else{
            int num;
            num = 0;
            int i,j,l;
            for(i = 1;i<n-1;i++){
                for(j=2;j<n;j++){
                    for(l=3;l<n+1;l++){
                        if ((i+j+l == x)and(i<j)and(j<l)){
                            num = num + 1;
                        }
                    }
                }
            }
                
            cout << num <<endl;
        }
        
    }
    
}


Measured memory_bytes: 3092
//          ★★ ASHWINI SHARMA ★★ 
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define ull unsigned long long int
#define ll long long int
#define ui unsigned int
#define pb push_back
 
#define PI 3.1415926535897932385
#define INF 1e18
#define EPS 1e-7
#define MAXN 1000000005
#define MOD 1000000007
                              //          ★★ ASHWINI SHARMA ★★      
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}



int main() {
    
    fastio;
    string s;
    int n;
    cin >> n;
    ll L[n];
    rep(i, n)
    {
        cin >> L[i];
    }
    

    int cnt = 0;
    rep(i, n)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(L[i] == L[j] || L[j] == L[k] || L[k] == L[i])
                    continue;
                if(L[i]+L[j] > L[k] && L[k]+L[i] > L[j] && L[k]+L[j] > L[i])
                    cnt++;
                
                    
            }
        }
    }
    cout << cnt;
    return 0; 

}

Measured memory_bytes: 3660
//BROWNIE TK

#include <bits/stdc++.h>

typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

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

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second

#define forz(i, n) for (int i = 0; i < n; i++)
#define forzm(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rforzm(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order

using namespace std;

/*STD fucntions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        //y must be even now
        y = y >> 1; //y=y/2
        x = (x * x) % p;
    }
    return res;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{
    return a * b / gcd(a, b);
}
lli modi(lli a, lli m)
{
    // fermat little thm where m is prime
    return power(a, m - 2, m);
}
/*CODE BEGINS*/
int main()
{
    kira;
    lli n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  int
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define inf 100000000000000000LL
#define fast_io	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
using namespace std;
ll n;
ll dp[22][1<<22+1];
ll match(vector<vector<ll> > &mat,ll pos,ll d,ll flag)
{
//	cout<<"pos= "<<pos<<" "<<bitset< 5 >(flag).to_string()<<" "<<endl;
	if(mat[pos][d]==0)
	{
//		dp[pos][flag]=0;
		return 0;
	}
	if(pos==1)
	{
		return 1;
	}
	if(pos!=n+1&&dp[pos][flag]!=-1)
	{
//			cout<<"xxpos= "<<pos<<" "<<"i= null "<<" "<<bitset< 5 >(flag).to_string()<<" "<<dp[pos][flag]<<endl;
		return dp[pos][flag];
	}
	ll s=0;

	for(ll i=1;i<=n;i++)
	{

		if(((1<<i)&flag)==0)
		{
			ll f=flag|(1<<i);
			ll x=match(mat,pos-1,i,f);
			s=(s%mod+x%mod)%mod;
//			cout<<"pos= "<<pos-1<<" "<<"i= "<<i<<" "<<bitset< 5 >(f).to_string()<<" "<<x<<endl;
		}
		
	}
	
	dp[pos][flag]=s;
	
	return dp[pos][flag];
	
}
int main()
{
	memset(dp,-1,sizeof(dp));
	fast_io;
	cin>>n;
	vector<vector<ll> > mat(n+2,vector<ll>(n+2,0));
	
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=n;j++)
		{
			cin>>mat[i][j];
		}
	}
	
//	for(ll i=1;i<=n;i++)
//	{
//		for(ll j=1;j<=n;j++)
//		{
//			cout<<dp[i][j]<<"\t";
//		}
//		cout<<endl;
//	}
	mat[n+1][n+1]=1;
	cout<<match(mat,n+1,n+1,0LL)<<endl;
//	for(ll i=0;i<=16;i++)
//	{
//		cout<<i<<" "<<bitset< 5 >(i).to_string()<<"\n\n";
//		for(ll j=1;j<=n;j++)
//		{
//			cout<<dp[j][i]<<"\t";
//		}
//		cout<<endl;
//	}
	
}

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

int main(void){
  int check = 0, i, x = 0, y = 0;
  char str[256], ch[2];

  gets(str);
  for( i=0; str[i] != '\0'; i++){
    ch[0] = str[i];
    if (check == 0){
      if (str[i] == ' '){
        check = 1;
      }else{
        x = 10 * x + atoi(ch);
      }
    }else{
      if (str[i] == '\0'){

      }else{
        y = 10 * y + atoi(ch);
      }
    }
  }

  for (i=0; i<=x; i++){
    if (2*i + 4*(x-i) == y){
      printf("Yes");
      break;
    }else if(i == x){
      printf("No");
    }else{}
  }

  return 0;
}


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

#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define cot cout.tie(0)

using namespace std;

int main()
{
    int a,b;

    cin>>a>>b;
    if(a >=13)
        cout<<b;
    else if ( a>=6 && a<=12 )
        cout<<b/2;
    else
        cout<<0;
    

return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Problems 1232
Problem A: Calling Extraterrestrial Intelligence Again
"""
import math
def eratosthenes(n):
    """
    エラトステネスのふるい
    """
    primes = [i for i in range(n+1)]
    primes[1] = 0 # 1は素数ではない
    for prime in primes:
        if prime > math.sqrt(n):
            break
        if prime == 0:
            continue
        for non_prime in range(2 * prime, n, prime): # primeの分、合成数をふるいかけていく
            primes[non_prime] = 0 # 素数でない要素は0にする
    prime_list = []
    for prime in primes:
        if prime != 0:
            prime_list.append(prime)
    return prime_list

# 素数を生成
primes = eratosthenes(100000)
while True:
    m, a, b = map(int, input().split())
    if m <= 4 or a == 0 or b == 0:
        break
    p = 0
    q = 0
    max_s = 0
    for i in range(len(primes)):
        for j in range(i, len(primes)):
            if (primes[i]*primes[j] <= m) and (a / b <= primes[i] / primes[j] <= 1):
                if primes[i]*primes[j] >= max_s:
                    max_s = primes[i]*primes[j]
                    p = primes[i]
                    q = primes[j]
            else:
                break
    print("{0} {1}".format(p, q))



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

using namespace std;

int n;
int a[200010];
int pos[200010];
int d[200010];

main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++){
        pos[a[i]] = i;
    }
    for(int i = 0; i < n; i++){
        d[a[i]] = d[a[i] - 1] + 1;
    }
    int mx = 0;
    for(int i = 1; i <= n; i++) mx = max(mx, d[i]);
    cout << n - mx << endl;
}


Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("100 17");
            //83
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("48 58");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1000000000 1000000000");
            //0
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(A => int.Parse(A)).ToArray();
        int X = wkArr[0];
        int t = wkArr[1];

        Console.WriteLine(Math.Max(0, X - t));
    }
}


Measured memory_bytes: 11348
#include<stdio.h>
#define NIL -1

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j, k, c;
  int M[MAX][MAX];
  int d[MAX];
  int visited[MAX];
  int min = INFTY;
  int v, u;


  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }

  for(i = 0; i < n; i++){
    d[i] = INFTY;
    visited[i] = 0;
  }
  d[0] = 0;

  while(1){
    u = NIL;
    min = INFTY;

    for(i = 0; i < n; i++){
      if(d[i] < min && !visited[i]){
	u = i;
	min = d[i];
      }
    }

    if(u == NIL) break;
    visited[u] = 1;

    for(v = 0; v < n; v++){
      if(d[v] >= d[u] + M[u][v]){
	d[v] = d[u] + M[u][v];
      }
    }
  }


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

  return 0;
}

Measured memory_bytes: 804
#include <stdio.h>
int main(void){
    
    int i, x;
    i = 1;
    while(1){
        scanf("%d\n", &x);
        if(x == 0) break;
        printf("Case %d: %d\n", i, x);
        i++;
    }
    
    return 0;
}


Measured memory_bytes: 2108
#include<stdio.h>
int main(){
	int a[4][2],b[4][2];
	int x,y,h,l;
	for(;;){
		for(x=0;x<4;x++){
			a[x][1]=1;
			b[x][1]=1;
		}
		if(scanf("%d %d %d %d",&a[0][0],&a[1][0],&a[2][0],&a[3][0])==EOF){break;}
		h=0;
		l=0;
		scanf("%d %d %d %d",&b[0][0],&b[1][0],&b[2][0],&b[3][0]);
		for(x=0;x<4;x++){
			if(a[x][0]==b[x][0]){
				a[x][1]=0;
				b[x][1]=0;
				h++;
			}
		}
		for(x=0;x<4;x++){
			if(a[x][1]==1){
				for(y=0;y<4;y++){
					if(b[y][1]==1 && b[y][0]==a[x][0]){
						a[x][1]=0;
						b[y][1]=0;
						l++;
						break;
					}
				}
			}
		}
		printf("%d %d\n",h,l);
	}
	return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

bool check(pair<int, int> a) {
    return a.first == a.second;
}
void solve() {
    int n;
    cin >> n;

    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i].first >> v[i].second;
    }
    for (int i = 0; i + 2 < v.size(); i++) {
        if (check(v[i]) and check(v[i + 1]) and check(v[i + 2])) {
            cout << "Yes";
            return;
        }
    }
    cout << "No";
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve()
{
  llong ans=0;

  int n; cin >> n;
  vector<llong> a(n); REP(i, n) cin >> a[i];
  for (int i = 0; i < n; i++)
  {
    for (int j = i; j < n; j++)
    {
      ans = max(ans, abs(a[i]-a[j]));
    }

  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin>>n;
  ll a[n];ll dp[n];
  ll sum=0;
  for(int i=0;i<n;i++){cin>>a[i];dp[i]=100000007;}
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
    {
      dp[i]=min(dp[i-2]+abs(a[i-2]-a[i]),dp[i-1]+abs(a[i-1]-a[i]));
  }
  
  cout<<fixed;
  cout<<dp[n-1]<<endl;
  }

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)


li n;

li aa[22];
pair<li, li> a[22][22];

int main(void)
{
	cin >> n;
	rep(i, n) {
		cin >> aa[i];
		rep(j, aa[i]) {
			cin >> a[i][j].first >> a[i][j].second;
			a[i][j].first--;
		}
	}

	li res = 0;
	rep(i, 1 << n) {
		bitset<20> bs(i);
		li cnt = 0;
		bool ok = true;
		rep(j, n) {
			if (!bs[j]) {
				continue;
			}
			cnt++;
			rep(k, aa[j]) {
				if (a[j][k].second != bs[a[j][k].first]) {
					ok = false;
					break;
				}
			}
		}
		if (ok) {
			res = max(res, cnt);
		}
	}
	cout << res << endl;


	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc129/tasks/abc129_e
MOD = (10**9) + 7
a = 1
b = 0
gets.chomp.bytes do |c|
  if c == 49
    b = (a + (b * 3)%MOD)%MOD
    a = (a * 2)%MOD
  else
    b = (b * 3)%MOD
  end
end

puts (a+b)%MOD

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
static auto faster_iostream = []() { ios::sync_with_stdio(0); cin.tie(0); return 0; }();void print(){cout<<'\n';}template<class T,class ...U>void print(T x, U ...y){cout<<x<<' ';print(y...);}
typedef long long ll; typedef long double db;
const int N = 1e5 + 5, M = 1e9 + 7;
ll qpow(ll x, ll n) { ll res = 1; for (; n; n >>= 1, x = x * x % M) if (n & 1) res = res * x % M; return res; }

int main() {
  int n, a[3];
  cin >> n >> a[0] >> a[1] >> a[2];
  vector<string> q(n);
  for (auto &s : q) cin >> s;
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    int u = q[i][0] - 'A', v = q[i][1] - 'A';
    if (a[u] == 0 && a[v] == 0) {
      cout << "No\n";
      exit(0);
    }
    if (!a[u]) a[u]++, a[v]--, ans.push_back(u);
    else if (!a[v]) a[u]--, a[v]++, ans.push_back(v);
    else if (a[u] == 1 && a[v] == 1 && i + 1 < n) {
      int w = 0, x = q[i+1][0] - 'A', y = q[i+1][1] - 'A';
      while (w == u || w == v) w++;
      if (a[w] || w != x && w != y) {
        a[u]++, a[v]--;
        ans.push_back(u);
        continue;
      }
      if (w == x && u == y || w == y && u == x) {
        a[u]++, a[v]--, ans.push_back(u);
      } else {
        a[v]++, a[u]--, ans.push_back(v);
      }
    } else if (a[u] >= a[v]) {
      a[v]++, a[u]--, ans.push_back(v);
    } else {
      a[u]++, a[v]--, ans.push_back(u);
    }
  }
  cout << "Yes" << '\n';
  for (int i = 0; i < n; i++) {
    cout << (char)(ans[i] + 'A') << '\n';
  }
}


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

const int INF = 1001001001;

int main() {
  int N, M, X;
  cin >> N >> M >> X;

  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; i++) {
    cin >> C.at(i);
    for (int j = 0; j < M; j++) {
      cin >> A.at(i).at(j);
    }
  }

  int ans = INF;
  for (int mask = 0; mask < (1 << N); mask++) {
    int cost = 0;
    vector<int> d(M);

    for (int i = 0; i < N; i++) {
      if (mask >> i & 1) {
        cost += C.at(i);
        for (int j = 0; j < M; j++) {
          d.at(j) += A.at(i).at(j);
        }
      }
    }
    bool ok = true;
    for (int j = 0; j < M; j ++) {
      if (d.at(j) < X) ok = false;
    }
    if (ok) ans = min(ans, cost);
  }
  if (ans == INF) cout << -1 << endl;
  else cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>

int search(int S[], int n, int T){
  int i=0;
  S[n] = T;
  while(S[i] != T){ i++; }
  return i != n;
}

int main(){
  int S[10000], T[500];
  int i, n, q;
  int count=0;

  std::cin >> n;
  for(int i=0; i<n; i++){
    std::cin >> S[i];
  }
  std::cin >> q;
  for(int i=0; i<q; i++){
    std::cin >> T[i];
    if(search(S, n, T[i])) {count++;}
  }

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



Measured memory_bytes: 3100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int h = sc.nextInt(), w = sc.nextInt(), k = sc.nextInt();
		char[][] a = new char[h][w];
		for(int i = 0; i < h; i++) {
			a[i] = sc.next().toCharArray();
		}
		int[][] b = list(h,w);
		int ans = 0;
		for(int i = 0; i < (int)Math.pow(2, h+w); i++) {
			int[] wi = b[i];
			int nk = 0;
			for(int j = 0; j < h; j++) {
				if(wi[j] == 0) {
					for(int l = h; l < h+w; l++) {
						if(wi[l] == 0 && a[j][l-h] == '#') {
							nk++;
						}
					}
				}
				
			}
			if(nk == k) {
				ans++;
			}
		}
		System.out.println(ans);
	}
	
	static int[][] list(int h, int w) {
		int all = (int)Math.pow(2, h+w);
		int[][] li = new int[all][h+w];
		for(int i = 0; i < all; i++) {
			int x = i;
			int p = 0;
			while(x >= 2) {
				li[i][p] = x%2;
				x /= 2;
				p++;
			}
			li[i][p] = x;
		}
		return li;
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 33228
#include<bits/stdc++.h>
using namespace std;
signed main()
{
  int a,b,c,d=0;
  cin>>a>>b>>c;
  if(a==b && a==c && b==c){
    cout<<"1\n";
  }else{
  	if(a!=b){
       d++;
  	}if(a!=c){
       d++;
  	}if(b!=c){
	   d++;
 	 }
	cout<<d<<"\n";
  }
}

Measured memory_bytes: 256
while True:
    N = input()
    if N == 0:
        break
    W, H = map(int, raw_input().split())
    field = [[False] * W for _ in xrange(H)]
    for _ in xrange(N):
        x, y = map(int, raw_input().split())
        field[y-1][x-1] = True
    table = [[0] * (W+1) for _ in xrange(H+1)]
    for y in xrange(1,H+1):
        for x in xrange(1,W+1):
            table[y][x] = table[y-1][x] + table[y][x-1] - table[y-1][x-1]
            if field[y-1][x-1]:
                table[y][x] += 1    
    S, T = map(int, raw_input().split())
    ans = 0
    for y in xrange(T, H+1):
        for x in xrange(S, W+1):
            tmp = table[y][x] + table[y-T][x-S] - table[y-T][x] - table[y][x-S]
            ans = max(ans, tmp)
    print ans            

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

int main()
{
  ll n; cin >> n;
  string s; cin >> s;

  ll r = 0;
  ll g = 0;
  ll b = 0;
  for (auto c:s) {
    if (c == 'R') r++;
    if (c == 'G') g++;
    if (c == 'B') b++;
  }
  ll ans = r * g * b;
  for (int i=0; i<n; i++) {
    for (int j=i+1; j<n; j++) {
      int k = 2*j - i;
      if (n <= k) continue;
      if (s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i]) ans--;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
function main(input){
  let lines = input.split("\n");
  let N = lines[0].split(" ")[0];
  let s = 1<<30;
  s = (s-1) * 2;
  let ret = -s;
  for(let i = 1; i <= N; i++){
    ret = Math.max(ret, Number(lines[i]) - s);
    s = Math.min(s, Number(lines[i]));
  }
  console.log(ret);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));



Measured memory_bytes: 34180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    
    ll N;
    cin >> N;
    map<ll, ll>cnt;
    for(ll i = 0; i < N; i++){
        ll x;
        cin >> x;
        cnt[x]++;
    }
    ll ans = 0;
    for(map<ll, ll>::iterator it = cnt.begin(); it != cnt.end(); it++){
        ll x = (*it).first;
        ll y = (*it).second;
        if(y < x)ans += y;
        if(y > x)ans += (y - x);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 6272