akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        private static long mod = 1000000007;

        static void Main(string[] args)
        {
            var n = Read().Long();
            var a = Read().Long();
            var b = Read().Long();
            var c = Read().Long();
            var d = Read().Long();
            var e = Read().Long();
            var min = new List<long>() { a, b, c, d, e }.Min();
            var ans = 0L;
            if (n % min == 0)
            {
                ans = n / min;
            }
            else
            {
                ans = n / min + 1;
            }
            ans += 4;
            WriteRead(ans);
        }
        
        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 13268
int main(){
int a,b,c,i,n;
n=0;
scanf("%d%d%d\n", &a, &b, &c);

for (i=a;i<=b; i++){
if(c%i==0){
n=n+1;
}
else{
n=n+0;
}
}
printf("%d\n", n);
return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
    int n;

    cin >> n;
    if (n % 10 == 7 || (n / 10) % 10 == 7 || n / 100 == 7)cout << "Yes";
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3620
def find(vals,l):
    ans = -float('inf')
    for i in range(len(vals)//2):
        curr = vals[i+l-1]
        if i-1 >= 0:
            curr -= vals[i-1]

        ans = max(ans,curr)

    #print(ans,l)
    return ans

def dfs(edges,node,k,costs,visited):
    nodes = []
    stack = [node]
    while stack:
        node = stack.pop()
        if node not in visited:
            visited.add(node)
            nodes.append(node)
            stack.append(edges[node])

    vals = []
    for node in nodes:
        vals.append(costs[node-1])

    vals.extend(vals)
    for i in range(1,len(vals)):
        vals[i] += vals[i-1]

    total = vals[-1]//2
    if total >= 0:
        ans = total*(k//(len(vals)//2))
    else:
        ans = 0

    max_val = -float('inf')
    #print('here',len(vals)//2,total)
    val = -float('inf')
    if k >= len(vals)//2:
        for i in range(1,len(vals)//2+1):
            max_val = max(max_val,find(vals,i))

        if total >= 0:
            max_val += ans-total

    #print(max_val)
    val = -float('inf')
    #print(total)
    k %= (len(vals)//2)
    
    for i in range(1,k+1):
        val = max(val,find(vals,i))

    return max(max_val,ans+val)

def main():
    n,k = map(int,input().split())
    perm = list(map(int,input().split()))
    costs = list(map(int,input().split()))
    edges = [-1]*(n+1)
    for i in range(n):
        edges[i+1] = perm[i]

    ans = -float('inf')
    visited = set()
    for i in range(1,n+1):
        if i not in visited:
            ans = max(ans,dfs(edges,i,k,costs,visited))

    print(ans)

main()


Measured memory_bytes: 69712
def main():
    from math import factorial
    n, a, b = map(int, input().split())
    p = 1000000007

    # 1:花束の組み合わせ総数の(mod p)
    n_all = pow(2, n, p) -1

    # 2:aとbの組み合わせ数の(mod p)を出す。
    a_comb = 0      # aの組み合わせ数
    a_comb_x = 1    # aの組み合わせ数計算の分子。n*(n-1)*…*(n-r+1)のmod p
    a_comb_y = 1    # aの組み合わせ数計算の分母。r!のmod pにおける逆元
    for i in range(n, n-a ,-1):
        a_comb_x *= i
        a_comb_x %= p
    a_comb_y = factorial(a)
    a_comb_y = pow(a_comb_y, p-2,p)
    a_comb = (a_comb_x * a_comb_y) % p

    b_comb = 0      
    b_comb_x = 1    
    b_comb_y = 1    
    for i in range(n, n-b ,-1):
        b_comb_x *= i
        b_comb_x %= p
    b_comb_y = factorial(b)
    b_comb_y = pow(b_comb_y, p-2,p)
    b_comb = (b_comb_x * b_comb_y) % p

    # 3: 1の結果から２のそれをマイナスする。結果が負になったら+p
    r = n_all - a_comb
    if r < 0:
        r += p
    r -= b_comb
    if r < 0:
        r += p
    print(r)

main()

Measured memory_bytes: 5424
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,j,k,l,f1,f2,f3;
    string s1,s2;
    cin>>s1;
    cin.ignore();
    cin>>s2;
    f1=0;
    f2=0;f3=0;
    if(s1.size()>s2.size())
    {
        f1=1;
    }
    else if(s1.size()<s2.size())
    {
        f2=1;
    }
    else if(s1.size()==s2.size())
    {
        for(i=0;i<s1.size();i++)
        {
            j=s1[i]-'0';
            k=s2[i]-'0';
            if(j>k)
            {
                f3=0;
                f1=1;
                break;
            }
            else if(j<k)
            {
                f3=0;
                f2=1;
                break;
            }
            else if(j==k)
            {
                f3=1;
            }

        }
    }
    if(f1==1)
    {
        cout<<"GREATER"<<endl;
    }
    else if(f2==1)
    {
        cout<<"LESS"<<endl;
    }
    else if(f3==1)
    {
        cout<<"EQUAL"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	n, m := readI(), readI()
	s, c := make([]int, m), make([]int, m)
	for i := 0; i < m; i++ {
		s[i], c[i] = readI(), readI()
		s[i]--
	}
	for i := 0; i < 1000; i++ {
		ia := strconv.Itoa(i)
		if len(ia) != n {
			continue
		}
		br := false
		for j := 0; j < m; j++ {
			if int(ia[s[j]]-'0') != c[j] {
				br = true
				break
			}
		}
		if br {
			continue
		}
		fmt.Println(i)
		return
	}
	fmt.Println(-1)
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> dp(3, 0);
    for(int d = 0; d < n; d++) {
        vector<int> c(3);
        vector<int> new_dp(3, 0);
        for(int i = 0; i < 3; i++) {
            cin >> c[i];
        }
        for(int i = 0; i < 3; i++) {
            for(int j = 0; j < 3; j++) {
                if(i != j) {
                    new_dp[j] = max(new_dp[j], c[j] + dp[i]);
                }
            }
        }
        dp = new_dp;
    }
    int res = max({dp[0], dp[1], dp[2]});
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var inputList = cin.ReadIntArray(5);
            int result = 0;
            int max = 0;
            foreach (var item in inputList)
            {
                if (item % 10 == 0)
                {
                    result += item;
                }
                else
                {
                    result += item + (10 - item % 10);
                    if (max < (10 - item % 10))
                    {
                        max = (10 - item % 10);
                    }
                }
            }
            result = result - max;
            Console.Write(result);
        }
    }
    public class deci
    {
        public bool IsFinish { get; set; } = false;
        public int Len { get; set; }
    }
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    long long n,k,s;
    int a=1e9;
    cin >> n >> k >> s;
    if(s!=1e9){
        for(int i=0; i<k; i++)cout << s << " ";
        for(int i=k; i<n; i++)cout << a << " ";
    }else {
        for(int i=0; i<k; i++)cout << s << " ";
        for(int i=k; i<n; i++)cout << a-1 << " ";
    }

    return 0;
}

Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main{

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//		Scanner s = new Scanner(System.in);
		int[] S = new int[2000000];
		int tailIndex = 0;
		for(int i= 0 ; i<S.length ; i++) {
			S[i] = -1;
		}
		while(true) {
			String[] input = br.readLine().split(" ");
			if("insert".equals(input[0])) {
				tailIndex++;
				insert(S, Integer.parseInt(input[1]), tailIndex);
			}else if("extract".equals(input[0])) {
				System.out.println(extract(S, tailIndex));
				tailIndex--;
			}else if("end".equals(input[0])) {
				System.exit(0);
			}
		}
	}

	public static void insert(int[] S, int value, int tail) {
		S[tail] = value;
		int parent = -1;
		if(tail==1)
			return;
		else{
			parent = tail/2;
		}
		while((S[parent] < S[tail]) && parent>0) {
			int tmp = S[parent];
			S[parent] = S[tail];
			S[tail] = tmp;
			tail = parent;
			parent = tail/2;
		}
	}

	public static int extract(int[] S, int tail) {
		int returnValue = S[1];
		S[1] = S[tail];
		S[tail] = -1;
		if(S[1]<S[2] || S[1]<S[3])
			maxHeapify(S, 1);
//			buildMaxHeap(S, tail+1);
		return returnValue;
	}


	public static void maxHeapify(int[] maxHeap, int index) {
		int leftChild = index*2;
		int rightChild = (index*2)+1;
		int max = maxHeap[index];
		if(maxHeap.length>=leftChild && maxHeap[leftChild]>maxHeap[index]) {
			max = maxHeap[leftChild];
		}
		if(maxHeap.length>=rightChild && maxHeap[rightChild]>max) {
			max = maxHeap[rightChild];
		}
		if(max!=maxHeap[index]) {
			if(max==maxHeap[leftChild]) {
				int tmp = maxHeap[leftChild];
				maxHeap[leftChild] = maxHeap[index];
				maxHeap[index] = tmp;
				maxHeapify(maxHeap, leftChild);
			}else if(max==maxHeap[rightChild]) {
				int tmp = maxHeap[rightChild];
				maxHeap[rightChild] = maxHeap[index];
				maxHeap[index] = tmp;
				maxHeapify(maxHeap, rightChild);
			}
		}
	}

	public static void buildMaxHeap(int[] maxHeap, int tail) {
		for(int i=(tail/2) ; i>0 ; i--) {
			maxHeapify(maxHeap, i);
		}
	}
}

Measured memory_bytes: 544452
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>

using namespace std;

int main() {
    long long a, b;
    cin >> a >> b;
    long long x = __gcd(a, b);
    int cnt = 1;
    for (long long i = 2; i < 1e6 + 5; ++i) {
        if (x % i == 0) {
            while(x % i == 0)
                x /= i;
            ++cnt;
        }
    }
    if (x > 1)
        ++cnt;
    cout << cnt << '\n';
    return 0;
}


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

#include <iostream>

class AFiveVariables {
public:
    void solve(std::istream &in, std::ostream &out) {
        int a;
        for (int i = 1; i <= 5; i++) {
            in >> a;
            if (a == 0) {
                out << i;
                return;
            }
        }
    }
};


int main() {
    AFiveVariables solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
    ld R;
    cin >> R;
    ld PI = 3.14159265358979323846;
    cout << 2 * PI*R << endl;
    
    return 0;
}

Measured memory_bytes: 3268
import math

n = int(input())
d = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for i in range(n):
    inp = input()
    if inp in d:
        d[inp] += 1

print("AC", "x", d["AC"])
print("WA", "x", d["WA"])
print("TLE", "x", d["TLE"])
print("RE", "x", d["RE"])


Measured memory_bytes: 9204
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
 ll n;
  cin >> n;
 vll x(n),y(n),h(n); 
 ll index;
  rep(i,0,n) {
    cin >> x[i] >> y[i] >> h[i];
    if(h[i]>0) index=i;
  }
  
  rep(i,0,101){
   rep(j,0,101){
    ll t=h[index]+abs(i-x[index])+abs(j-y[index]);
    ll f=1; 
    rep(k,0,n){
      ll u=max(t-abs(i-x[k])-abs(j-y[k]),0ll);   
      if(u!=h[k]) f=0;
    }
     if(f) {
       cout << i<< " " << j << " "<<  t << endl;
       return;
     }
   }
  }
  
  
}

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

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main(void){
    
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    rep(i, n){cin >> a[i];}
    rep(i, n){cin >> b[i];}
    rep(i, n-1){cin >> c[i];}
    int sum=0;
    rep(i, n){
        sum += b[a[i]-1];
    }
    
    rep(i, n-1){
        if(a[i+1]-a[i] == 1){
            sum += c[a[i]-1];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3536
#include<iostream>
#include<vector>

template<class T,class F>
struct segment_tree{
  std::vector<T> data;
  int n;F f;T identity;
  segment_tree(){}
  segment_tree(int sz,T ide,F _f):f(_f),identity(ide){
    n=1;while(n<sz)n<<=1;
    data.resize(2*n,identity);
  }
  segment_tree(std::vector<T> const& v,T ide,F _f):f(_f),identity(ide){
    build(v);
  }
  void build(std::vector<T> const& v){
    int sz=v.size();
    n=1;while(n<sz)n<<=1;
    data.resize(2*n,identity);
    for(int i=0;i<sz;++i)data[i+n]=v[i];
    for(int i=n-1;i>0;--i)data[i]=f(data[i<<1|0],data[i<<1|1]);
  }
  void set(int i,T x){
    i+=n;data[i]=x;
    while(i,i>>=1)data[i]=f(data[i<<1|0],data[i<<1|1]);
  }
  T fold(int l,int r)const{
    l+=n,r+=n;
    T fold_l=identity,fold_r=identity;
    while(l<r){
      if(l&1)fold_l=f(fold_l,data[l++]);
      if(r&1)fold_r=f(data[--r],fold_r);
      l>>=1,r>>=1;
    }
    return f(fold_l,fold_r);
  }
  T operator[](int i)const{return data[i+n];}
  template<class Cond>
  int bserch(int l,Cond& cond){
    // return min idx 
    // s.t. l<=idx and cond(fold(l,idx))=false and cond(fold(l,idx+1))=true
    // if cond(fold(0,n)) = false,return -1;
    l += n;
    T x = identity;
    do{
      while(!l&1)l>>=1;
      if(cond(f(x,data[l]))){
        while(l<n){
          l <<= 1;
          if(!cond(f(x,data[l]))){
            x = f(x,data[l++]);
          }
        }
        return l-n;
      }
      x = f(x,data[l++]);
    }while((l&-l)!=l);
    return -1;
  }
};
template<class T,class F>
auto make_segtree(int n,T ide,F f){
  return segment_tree<T,F>(n,ide,f);
}
template<class T,class F>
auto make_segtree(std::vector<T>const& v,T ide,F f){
  return segment_tree<T,F>(v,ide,f);
}

int main(){
  using namespace std;
  using ll = int64_t;
  cin.tie(0);
  ios::sync_with_stdio(false);
  constexpr char newl = '\n';

  int n,q;
  cin>>n>>q;
  vector<ll> a(n);
  for(auto& ai:a)cin>>ai;

  auto seg = make_segtree<ll>(a,0,[](ll a,ll b){return a<b?b:a;});
  while(q--){
    int t;cin>>t;
    if(t==1){
      int x,v;cin>>x>>v;x--;
      seg.set(x,v);
    }
    if(t==2){
      int l,r;cin>>l>>r;l--;r--;
      cout<<seg.fold(l,r+1)<<newl;
    }
    if(t==3){
      int x,v;cin>>x>>v;x--;
      auto c = [&v](ll aj){return v<=aj;};
      int res = seg.bserch(x,c);
      cout<<(res==-1?n+1:res+1)<<newl;
    }
  }

}

Measured memory_bytes: 8984
from math import factorial as f
s = int(input())
div = s // 3
mod = s % 3
a = 10 ** 9 + 7
res = 0
while div != 0:
    res = (res + f(div - 1 + mod) // (f(div - 1) * f(mod))) % a
    div -= 1
    mod += 3

print(res)


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    bool f = false;
    for(int i = 0; i < b; i++){
        if((i * a%b)%b == c){
            f = true;
            break;
        }
    }
    if(f) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 3600
N = int(input())
A = list(map(int, input().split()))

B = [(A[i], i) for i in range(N)]
B.sort(key = lambda x: x[0], reverse = True)

DP = [[0] * (N + 1) for _ in range(N + 1)]

for i in range(N):
    a = B[i][0]
    tmp = B[i][1]
    for x in range(i + 1):
        DP[x + 1][i - x] = max(DP[x + 1][i - x], DP[x][i - x] + a * abs(tmp - x))
        DP[x][i - x + 1] = max(DP[x][i - x + 1], DP[x][i - x] + a * abs((N - tmp - 1) - (i - x)))

ans = 0
for i in range(N + 1):
    ans = max(ans, DP[i][N - i])

print (ans)

# for tmp in DP:
#     print (tmp)

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

int main() {
  int N, P;
  cin >> N >> P;
  int od = 0;
  int ev = 0;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (x%2 == 0) ev += 1;
    else od += 1;
  }
  if (od == 0) {
    if (P == 1) {
      cout << 0 << endl;
      return 0;
    }
    else od = 1;
  }
  cout << setprecision(16);
  cout << powl(2,od+ev-1) << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
int d[1000][1000];
//main
signed main(){
  int H,W,K;cin>>H>>W>>K;
  std::vector<string> s(H);
  for(int i=0;i<H;i++)cin>>s[i];
  int sx,sy;
  for(int i=0;i<H;i++)for(int j=0;j<W;j++)if(s[i][j]=='S')sy=i,sx=j;
  for(int i=0;i<H;i++)for(int j=0;j<W;j++)d[i][j]=LINF;
  int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
  d[sy][sx]=0;
  typedef pair<int,int> P;
  queue<P> que;
  que.push(P(sy,sx));
  while(que.size()){
    P p=que.front();que.pop();
    for(int i=0;i<4;i++){
      int y=p.first+dy[i],x=p.second+dx[i];
      if(y<0||y>=H||x<0||x>=W)continue;
      if(s[y][x]=='#')continue;
      if(d[y][x]>d[p.first][p.second]+1){
        d[y][x]=d[p.first][p.second]+1;
        que.push(P(y,x));
      }
    }
  }
  int ans=INF;
  for(int i=0;i<H;i++)for(int j=0;j<W;j++)if(d[i][j]<=K)ans=min({ans,i,H-1-i,j,W-1-j});
  int res=ans/K+1;if(ans%K)res++;
  fin(res);
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll inf=1000000007;
const ll maxinput=3005;
const ll mod=998244353;
#define mp make_pair
string x,y,z;
int n,m;
int dp[maxinput][maxinput];
char dir[maxinput][maxinput];
int lcs(int i,int j)
{
    if(i<0||j<0)
        return(0);

    if(dp[i][j]!=-1)
        return(dp[i][j]);
    if(x[i]==y[j])
    {
        dir[i][j]='d'; //d for diagonally left
        return(dp[i][j]=1+lcs(i-1,j-1));
    }
    else
    {
        int temp1,temp2;
        temp1=lcs(i-1,j);
        temp2=lcs(i,j-1);
        if(temp1>temp2)
            dir[i][j]='u'; //up
        else
            dir[i][j]='l'; //left

        return(dp[i][j]=max(lcs(i-1,j),lcs(i,j-1)));
    }

}
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>x>>y;
    n=x.length();m=y.length();
    lcs(n-1,m-1);

    int i=n-1;int j=m-1;
    while(!(i<0||j<0))
    {
        if(dir[i][j]=='d')
            z+=x[i],i--,j--;
        else if(dir[i][j]=='u')
            i--;
        else if(dir[i][j]=='l')
            j--;
    }

    reverse(z.begin(),z.end());
    cout<<z<<"\n";

}

Measured memory_bytes: 44800
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		ArrayList<Integer> D = new ArrayList<Integer>();
		for(int i = 0; i < N * 2; i ++) {
			D.add(stdIn.nextInt());
		}
		
		int keepCnt = 0;
		boolean ans = false;
		for(int i = 0; i < N; i ++) {
			if(D.get(2 * i) == D.get(2 * i + 1)) {
				keepCnt ++;
			}else {
				keepCnt = 0;
			}
			if(keepCnt == 3) {
				ans = true;
				break;
			}
		}
		
		if(ans){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35964
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  double a,b,x;
  double res=0;
  cin >> a >> b >> x;

  if ( 2 * x >= a*a*b) {
    double y = 2*x/(a*a) - b;
    res = atan2(b-y, a);
  }
  else {
    res = atan( 2 * x / (a * b * b) );
    res = M_PI/2 - res;
  }
  res *= 180/M_PI;

  printf("%.8f\n", res);
}


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

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#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(i,0,(n))
#define rrep(i,n) RFOR(i,0,(n))

int main() {
	int N;
	cin >> N;
	vector<pii> a(N), b(N);
	rep(i,N)
		cin >> a[i].fi >> a[i].se;
	rep(i,N)
		cin >> b[i].fi >> b[i].se;
	sort(all(a));
	sort(all(b));

	rep(i,N) {
		int e = -1;
		rep(j,a.size()) {
			if(a[j].fi < b[i].fi && a[j].se < b[i].se) {
				if(e<0 || a[j].se > a[e].se) {
					e = j;
				}
			}
		}
		if(e >= 0) 
			a.erase(a.begin()+e,a.begin()+e+1);
	}

	cout << N - a.size() << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<set>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
#include <iterator>     // std::back_inserter
const double PI = acos(-1);
using namespace std;
using ll =long long;
#define rep(i,n)for(ll i=0;i<(n);i++)
const int mod = 1000000007;
const ll inf = 1e18 + 1;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
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;
}

/*コンビネーション*/

//ll f[101010], rf[101010];
//ll inv(ll x) {
//	ll res = 1;
//	ll k = mod - 2;
//	ll y = x;
//	while (k) {
//		if (k & 1) res = (res * y) % mod;
//		y = (y * y) % mod;
//		k /= 2;
//	}
//	return res;
//}
//void init() {
//	f[0] = 1;
//	for (ll i = 1; i < 101010;i++) f[i] = (f[i - 1] * i) % mod;
//	for(ll i = 0; i < 101010; i++) rf[i] = inv(f[i]);
//}
////---------------------------------------------------------------------------------------------------
//ll C(int n, int k) {
//	ll a = f[n]; // = n!
//	ll b = rf[n - k]; // = (n-k)!
//	ll c = rf[k]; // = k!
//
//	ll bc = (b * c) % mod;
//
//	return (a * bc) % mod;
//}

/*コンビネーション*/

/*Union Find*/
#define MAX_N 200000
#define MAX_M 200000
vector<ll>par(MAX_N);
vector<ll>ran(MAX_N);
void init(ll N) {
	rep(i, N) {
		par[i] = i;
		ran[i] = 0;
	}
}
ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(ll x,ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (ran[x] < ran[y]) {
		par[x] = y;

	}
	else {
		par[y] = x;
		if (ran[x] == ran[y])ran[x]++;
	}
}
bool same(ll x, ll y) {
	return find(x) == find(y);
}
/*Union Find*/
//小文字=大文字+32
int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll>A(M), B(M);
	init(N);
	rep(i, M)cin >> A[i] >> B[i];
	rep(i, M) {
		unite(A[i], B[i]);
	}
	vector<ll>m(N);
	rep(i, N) {
		m[find(i)]++;
	}
	sort(m.begin(), m.end());
	reverse(m.begin(), m.end());
	cout << m[0];
}

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

int main() {
  int n, cnt = 0;
  string ans = "No";
  cin >> n;
  for(int i = 0; i < n; i++) {
    int d1, d2;
    scanf("%d %d", &d1, &d2);
    if(d1 == d2) cnt++;
    else {
      cnt = 0;
      continue;
    }
    if(cnt == 3) {
      ans = "Yes";
      break;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3688
n = gets.to_i
w = gets.chomp.split.map(&:to_i)

before = 0
after = w.inject(&:+)
score = after+1

n.times do |i|
  before += w[i]
  after -= w[i]
  tmp = (after - before).abs
  if tmp < score
    score = tmp
  else
    break
  end
end

print score

Measured memory_bytes: 3836
n = gets.to_i
n.times do
    x, y, b, p = gets.split.map(&:to_i)
    ans = (x + y) * 6
    (0..6).each do |i|
        (0..6).each do |j|
            next if i < b or j < p
            total = x * i + y * j
            total = total / 50 * 40 if i >= 5 and j >= 2
            ans = [ans, total].min
        end
    end
    puts ans
end

Measured memory_bytes: 6120
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on
void main()
{
    auto input = stdin.byLine.map!split.joiner;

    long x;
    x = input.front.to!long;
    input.popFront;

    solve(x);
}

void solve(long x)
{
    writeln(x ? 0 : 1);
}


Measured memory_bytes: 3696
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define REP(i,n) for(i=0;i<(n);++i)
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807

using namespace std;

long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main() {
	int A,B,C,X,Y,i;
	ll ans = LL_MAX,sum;
	cin >> A >> B >> C >> X >> Y;
	REP(i, max(X, Y)+1) {
		sum = C * 2 * i + A * max(0,(X - i)) + B * max(0,(Y - i));
		ans = min((ll)sum, ans);
	}
	cout << ans << endl;
}

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

int main(){
  int a,b,c,kotae=0;
  cin>>a>>b>>c;
  if(a==b){
    kotae++;
  }
  if(b==c){
    kotae++;
  }
  if(c==a){
    kotae++;
  }
  if(kotae==1){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}

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

using namespace std;

int main() {
	int a, b;
	char op;
	for (;;) {


		cin >> a >> op >> b;

		if (op == '+') {
			cout << a + b << endl;
		}
		else if (op == '-') {
			cout << a - b << endl;
		}
		else if (op == '/') {
			cout << a / b << endl;
		}
		else if (op == '*') {
			cout << a * b << endl;
		}
		else {
			break;
		}
	}
}


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

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

	for (int i = 0; i < s.size(); i++) {
		char target = s[i];
		target += n;
		if (target > 'Z') {
			target -= 26;			
		}
		cout << target;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
s = gets.chomp!
k = gets.to_i

a = []

s.each_char do |c|
  a.push(c)
end
a.sort!.uniq!
b = a
a = []
n = 0

loop do
  s.size.times do |i|
    if s[i] == b[n]
      a.push(s[i..-1])
    end
  end

  a.sort!.uniq!

  ans = []
  k.times do |i|
    a.each do |aa|
      ans.push(aa[0..i])
    end
  end

  ans.sort!.uniq!

  if ans.size <= k-1
    n += 1
  else
    puts ans[k-1]
    exit
  end
end


Measured memory_bytes: 4372
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();
		int ans = 0;
		
		int[] B = new int[M];
		for(int i = 0;i < M;i++){
			B[i] = sc.nextInt();
		}
		for(int i = 0;i < N;i++){
			int sum = 0;
			for(int j = 0;j < M;j++){
				sum += sc.nextInt() * B[j];
			}
			sum += C;
			if(sum > 0){
				ans++;
			}
		}
		System.out.print(ans);
		
		
	}
	
	
}



Measured memory_bytes: 23892
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7+7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int cnt[N];
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    // stack<int>s,ss;
    // int n,m,k;
    // cin>>n>>m>>k;
    // vi v,vv;
    // lp(i,n){
    //     int x;
    //     cin>>x;
    //     v.pb(x);
       
    // }
    // lp(i,m){
    //     int x;
    //     cin>>x;
    //     vv.pb(x);
       
    // }
    // int cnt =0,idx1=0 ,idx2=0;
    // while(k>0&&(idx1<n||idx2<m)){
        
    //     if(idx1<n&&idx2<m&&v[idx1]<=vv[idx2]){
    //         k-=v[idx1];
    //         idx1++;
    //     }else if(idx1<n&&idx2<m&&v[idx1]>=vv[idx2]){
    //         k-=vv[idx2];
    //         idx2++;
    //     }else if(idx1==n&&idx2<m){
    //         k-=vv[idx2];
    //         idx2++;
    //     }else if(idx2==m&&idx1<n){
    //         k-=v[idx1];
    //         idx1++;
    //     }
    //     if(k>=0)cnt++;
    //     else break;
    // }
    // printf("%d",cnt);
    int n;
    scanf("%d",&n);
    for(int i = 1 ; i < N ; i++)
        for(int j = i ; j < N ; j += i)
           cnt[j]++;
 
    ll res = 0;
    range(i,1,n)
        res += 1ll * i * cnt[i];
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 42824
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;    

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int out[200]={};
    string s;
    cin>>s;
    rep(i,s.size()){
	int a=(int)s[i];
	out[a]++;
    }
    for(int i=97;i<=122;i++){
	if(out[i]%2!=0){
	    cout<<"No"<<'\n';
	    return 0;
	}
    }
    cout<<"Yes"<<'\n';
    
    return 0;
}


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

using namespace std;

const int maxn=1e6;

int n;

int a[maxn],b[maxn];

int mx[2],mw[2];

int main() {
	scanf("%d",&n);
	for (int l=1;l<=n;l++) {
		int wy;
		scanf("%d",&wy);
		if (l&1) a[wy]++;
		else b[wy]++;
	}
	for (int l=1;l<=1e5+10;l++) {
		int wyx=a[l],wyw=l;
		for (int j=0;j<=1;j++) {
			if (wyx>mx[j]) {
				swap(wyx,mx[j]);
				swap(wyw,mw[j]);
			}
		}
	}
	int ans=1e9;
	for (int l=1;l<=1e5+10;l++) {
		int wy;
		if (a[l]==mx[0]) wy=mx[1];
		else wy=mx[0];
		wy=n-wy-b[l];
		ans=min(ans,wy);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 4556
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
int n;
cin>>n;
int ans=0;
V<int> a(n);
for(int i=0;i<n;i++)cin>>a[i];
sort(all(a));
for(int i=0;i<n-1;i++)ans+=(a[i+1]-a[i]);
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
int a, b, c;
int i;
int n;
scanf("%d %d %d", &a, &b, &c);
scanf("%d", &n);
if(a>=b && a>=c){
  for(i=0;i<n;i++){
    a *= 2;
  }
}else if(b>=a && b>=c){
  for(i=0;i<n;i++){
    b *= 2;
  }
}else if(c>=a && c>=b){
  for(i=0;i<n;i++){
    c *= 2;
  }
}
 
printf("%d",a+b+c);
return 0;
}

Measured memory_bytes: 128
object Main {
    def mk(l: Iterator[String]) = l.map(s => (s.head + s.zip(s.tail).filter(p => "aiueo".contains(p._1)).map(_._2).mkString))

    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines
        for (n <- in if n != "0") {
            val l = mk(in.take(n.toInt)).toList
            (1 to 50).find(d => {val t = l.map(_.take(d)); t.size == t.distinct.size}) match {
                case Some(x) => println(x)
                case None => println(-1)
            }
        }
    }
}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

int main(){
    int n,m;
    cin>>n>>m;

    vector<vector<int>>s(m,vector<int>(10));
    vector<int>p(m);

    rep(i,m){
        int k;
        cin>>k;

        rep(j,k){
            int S;
            cin>>S;

            S--;
            s[i][S]=1;
        }
    }

    rep(i,m)cin>>p[i];

    int ans=0;

    rep(bit,1<<n){
        bool jdg=true;

        rep(i,m){
            int cnt=0;

            rep(j,s[i].size()){
                if(s[i][j]==1){
                    if(bit&(1<<j)){
                        cnt++;
                    }
                }
            }

            if(cnt%2!=p[i])jdg=false;
        }

        if(jdg)ans++;

    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int ex(int a){
    int j,k;
    j=1;
    k=2;
    while(k<10){
        for(j=1;j*j<=a;j++){
            if(pow(j,k)==a) return 1;
        }
        k++;
        
    }
    return 0;
}
    
int main(){
    int X;
    int i,m;
    scanf("%d",&X);
    m=1;
    for(i=X;i>0;i--){
        if(ex(i)==1){
            m=i;
            break;
        }
    }
    printf("%d",m);
}

Measured memory_bytes: 512
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	//int n; cin >> n;
	string s; cin >> s;
	int co[26] = {};
	REP(i, s.size()) co[s[i]-'a']++;
	bool ch = true;
	REP(i, 26){
		if(co[i] %2 !=0) ch = false;
	}
	if (ch) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	//cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(void){
 string s;
  int cnt=0;
  cin>>s;
  for(int i=0;i<4;i++){
  	if(s.at(i)=='+') cnt++;
    else if(s.at(i)=='-') cnt--;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N, A, B, C;
	cin >> N >> A >> B >> C;
	vector<string> S(N);
	for (auto& x : S) cin >> x;
	int t = 0;
	if (!A || !B || !C) {
		vector<map<vector<int>, pair<int,int>>> a(1);
		a[0][{A,B,C}] = {-1,-1};
		vector<int> cc;
		for (t = 0; t < N; ++ t) {
			a.push_back({});
			int i = S[t][0]-'A';
			int j = S[t][1]-'A';
			for (auto p : a[t]) {
				if (p.first[i]) {
					auto c = p.first;
					-- c[i];
					++ c[j];
					if (!a.back().count(c)) a.back()[c] = {i,j};
					if (c[0] && c[1] && c[2]) {
						cc = c;
						goto out;
					}
				}
				if (p.first[j]) {
					auto c = p.first;
					-- c[j];
					++ c[i];
					if (!a.back().count(c)) a.back()[c] = {j,i};
					if (c[0] && c[1] && c[2]) {
						cc = c;
						goto out;
					}
				}
			}
			if (a.back().empty()) {
				cout << "No" << endl;
				return 0;
			}
		}
		out:;
		if (cc.empty()) {
			cc = a[N].begin()->first;
			t = N-1;
		}
		vector<int> res;
		for (int tt = t+1; tt > 0; -- tt) {
			auto ij = a[tt][cc];
			res.push_back(ij.second);
			--cc[ij.second];
			++cc[ij.first];
		}
		reverse(res.begin(), res.end());
		cout << "Yes" << endl;
		for (auto i : res) cout << "ABC"[i] << endl;
		t = (int)res.size();
	} else {
		cout << "Yes" << endl;
	}
	vector<int> b(3);
	for (; t < N; ++ t) {
		int x = 0, y = 1;
		if (b[S[t][x]-'A'] < b[S[t][y]-'A']) swap(x, y);
		cout << S[t][x] << endl;
		-- b[S[t][x]-'A'];
		++ b[S[t][y]-'A'];
	}
}


Measured memory_bytes: 25708
#include <cstdio>
#include <cmath>
#include <vector>

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

typedef std::vector<int> v;
typedef std::vector<std::vector<int>> vv;
typedef unsigned long long ull;

int main(void)
{
    ull x;
    scanf("%lld", &x);
    ull p = 100;
    int i = 0;
    while (true)
    {
        ++i;
        p += p / 100;
        if (p >= x)
        {
            printf("%d\n", i);
            return 0;
        }
    }
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define faster_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
#define bug(a)       cerr << #a << " : " << a << endl;
#define sc(a) scanf("%d",&a)
#define sc1(a) scanf("%d",&a)
template<class T>void ExEuclid(T n, T m, T &a, T &b, T &gcd){if(m==0){gcd=n;a=1;b=0;return;}ExEuclid(m,n%m,a,b,gcd);T x=a;a=b;b=x-(n/m)*a;}
template<class T>T gcd(T n, T m){if(m==0){return n;}gcd(m,n%m);}
template<class T>T lcm(T n, T m){return (n*m)/gcd(n,m);}
template<class T>string to_string(T n){string s="";while(n)s+=((n%10)+'0'),n/=10;reverse(s.begin(),s.end());return s;}
template<class T>ll to_int(T s){ll num=0,power=0;for(int i=s.size()-1; i>=0; i--)num+=(pow(10.0,power++)*(s[i]-'0'));return num;}
template<class T>bool is_mod(T n, T m){if(n%m==0)return true;return false;}
template<class T>bool is_upper(T s){for(int i=0; i<s.size(); i++)if(s[i]>90 || s[i]<65)return false;return true;}
template<class T>bool is_lower(T s){for(int i=0; i<s.size(); i++)if(s[i]>122 || s[i]<97)return false;return true;}
template<class T>bool is_palindrome(T s){T s1=s;reverse(s1.begin(),s1.end());if(s==s1)return true;return false;}
template<class T>T mod(T n, T m){return ((n%m)+m)%m;}
template<class T>T Big_mod(T base, T power, T MOD){
    if(power==1)return base;
    if(power & 1)return ((base%MOD)*(Big_mod(base,power-1,MOD))%MOD)%MOD;
    else {T temp=(Big_mod(base,power>>1,MOD));return ((temp%MOD)*(temp%MOD))%MOD;}
}



int main()
{
    faster_io;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,m;
    cin>>n>>m;
    int x=0,p,cnt=1;
    for(int i=0; i<n; i++){
        cin>>p;
        x+=p;
        if(x<=m)cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}





Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long cnt = 0;
void merge(int* arr, int left, int mid, int right) {
	int len1 = mid - left + 1;
	int len2 = right - mid;
	int* tempL = new int[len1];
	int* tempR = new int[len2];
	for (int i = 0; i < len1; i++)tempL[i] = arr[left + i];
	for (int i = 0; i < len2; i++)tempR[i] = arr[mid+1 + i];
	int i = 0, j = 0;
	for (int k = left; k <= right; k++)
		if (i < len1 && (j >= len2 || tempL[i] <= tempR[j]))
			arr[k] = tempL[i++];
		else {
			arr[k] = tempR[j++];
			cnt += (len1 - i);
		}
	delete[]tempL;
	delete[]tempR;
}
void mergeSort(int* arr, int left, int right) {
	int mid = (left + right) / 2;
	if (left < mid) {
		mergeSort(arr, left, mid);
		mergeSort(arr, mid + 1, right);
	}
	merge(arr, left, mid, right);
}
int main() {
	int len;
	cin >> len;
	int* arr = new int[len];
	for (int i = 0; i < len; i++)
		cin >> arr[i];
	mergeSort(arr, 0, len - 1);
	cout << cnt << endl;
	delete[]arr;
	return 0;
}


Measured memory_bytes: 4308
#include <stdio.h>

int main(void) {
	int N, M;
	char A[55][55], B[55][55];
	int i, j;

	scanf("%d %d", &N, &M);
	for(i = 0; i < N; i++) {
		scanf("%s", A[i]);
	}
	for(i = 0; i < M; i++) {
		scanf("%s", B[i]);
	}

	for(i = 0; i < N - M + 1; i++) {
		for(j = 0; j < N - M + 1; j++) {
			int k, l;
			int flag = 0;
			for(k = 0; k < M; k++) {
				for(l = 0; l < M; l++) {
					if(A[i+k][j+l] != B[k][l]) {
						flag = 1;
						break;
					}
				}
				if(flag) break;
			}
			if(!flag) {
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");

	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n=s.size();
  bool b=false;
  for(int i=0;i<n;i++){
    if(s.substr(i,7)=="keyence"){
      b=true;
    }
  }
  for(int i=1;i<=6;i++){
    if(s.substr(0,i)+s.substr(n-7+i,7-i)=="keyence"){
      b=true;
    }
  }
  if(b){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int Linearsearch(int *,int,int);

int main(){
  int i,j=0,n,q;
  int S[10000+1],T[10000+1];

  scanf("%d",&n);

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

  scanf("%d",&q);

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

for(i=0;i<q;i++){
if(Linearsearch(S,n,T[i])==1)j++;
}

printf("%d\n",j );
return 0;
}


int Linearsearch(int S[],int n,int key){
  int i;

  for(i=0;i<n;i++){
    if(S[i] == key)return 1;
  }
  return 0;
}



Measured memory_bytes: 2144
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
    std.range, std.container, std.bigint, std.ascii, std.typecons;

// }}}
// nep.scanner {{{
class Scanner
{
    import std.stdio : File, stdin;
    import std.conv : to;
    import std.array : split;
    import std.string : chomp;

    private File file;
    private char[][] str;
    private size_t idx;

    this(File file = stdin)
    {
        this.file = file;
        this.idx = 0;
    }

    private char[] next()
    {
        if (idx < str.length)
        {
            return str[idx++];
        }

        char[] s;
        while (s.length == 0)
        {
            s = file.readln.chomp.to!(char[]);
        }

        str = s.split;
        idx = 0;

        return str[idx++];
    }

    T next(T)()
    {
        return next.to!(T);
    }

    T[] nextArray(T)(size_t len)
    {
        T[] ret = new T[len];

        foreach (ref c; ret)
        {
            c = next!(T);
        }

        return ret;
    }

    void scan()()
    {
    }

    void scan(T, S...)(ref T x, ref S args)
    {
        x = next!(T);
        scan(args);
    }
}
// }}}

void main()
{
    auto cin = new Scanner;
    int n;
    cin.scan(n);
    char[] s = cin.next!(char[]);
    int[Tuple!(string, string)] chie;
    reverse(s[n .. $]);
    foreach (S; 0 .. 1 << n)
    {
        string a, b;
        foreach (i; 0 .. n)
        {
            if ((S >> i) & 1)
            {
                a ~= s[i];
            }
            else
            {
                b ~= s[i];
            }
        }
        chie[tuple(a, b)]++;
    }

    long ans;

    foreach (S; 0 .. 1 << n)
    {
        string a, b;
        foreach (i; 0 .. n)
        {

            if ((~S >> i) & 1)
            {
                a ~= s[i + n];
            }
            else
            {
                b ~= s[i + n];
            }
        }
        if (tuple(b, a) in chie)
            ans += chie[tuple(b, a)];
    }
    ans.writeln;
}


Measured memory_bytes: 49532