akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int H, W;
    cin >> H >> W;
    auto A = make_v<int>(H, W), B = A;
    auto dp = make_v<int>(H, W, 20000);
    for (size_t i = 0; i < H; i++)
    {
        for (size_t j = 0; j < W; j++)
        {
            cin >> A[i][j];
        }
    }
    for (size_t i = 0; i < H; i++)
    {
        for (size_t j = 0; j < W; j++)
        {
            cin >> B[i][j];
        }
    }
    dp[0][0][abs(A[0][0] - B[0][0])] = true;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            for (int k = 0; k < 13000; k++)
            {
                if ((i+1 == H - 1 and j == W-1) or (i == H-1 and j+1 == W - 1))
                {
                    int g = 0;
                }
                if (i + 1 < H)
                {
                    dp[i + 1][j][abs(k + A[i + 1][j] - B[i + 1][j])] |= dp[i][j][k];
                    dp[i + 1][j][abs(k + B[i + 1][j] - A[i + 1][j])] |= dp[i][j][k];
                }
                if (j + 1 < W)
                {
                    dp[i][j + 1][abs(k + A[i][j + 1] - B[i][j + 1])] |= dp[i][j][k];
                    dp[i][j + 1][abs(k + B[i][j + 1] - A[i][j + 1])] |= dp[i][j][k];
                }
            }
        }
    }
    int ans = INT_MAX;
    for (size_t k = 0; k < 13000; k++)
    {
        if (dp[H - 1][W - 1][k])
        {
            cout << k;
            return 0;
        }
    }

    return 0;
}

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

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys
import bisect

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float('inf')


N = int(input())
A = list(map(int, input().split()))

dict_A = defaultdict(int)
for a in A:
    dict_A[a] += 1

Q = int(input())
query = []
for _ in range(Q):
    b, c = map(int, input().split())
    query.append([b, c])

current_sum = sum(A)

for b, c in query:
    if b in dict_A:
        diff = c * dict_A[b] - b * dict_A[b]
        current_sum += diff
        dict_A[c] += dict_A[b]
        dict_A[b] = 0
    print(current_sum)


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

int main(){
    int n;
    int q;
    string x;
    int ptime;
    queue<int> process;
    queue<string> pname;
    cin >> n >> q;
    for (int i=0;i<n;i++){
        cin >> x >> ptime;
        process.push(ptime);
        pname.push(x);
    }
    ptime=0;
    while(!pname.empty()){
        if (process.front()<=q){
            ptime+=process.front();
            cout << pname.front() <<" "<< ptime << endl;
            process.pop();
            pname.pop();
        }else{
            ptime+=q;
            process.push(process.front()-q);
            pname.push(pname.front());
            process.pop();
            pname.pop();
        }
//        cout << x << opers.top() << endl;
    }
//    cout << opers.top() <<endl;
    return 0;
}


Measured memory_bytes: 6012
n = int(input())
s = input()

a = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
    'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
           'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']

ans = ""
for i in range(len(s)):
    for j in range(len(a)):
        if s[i] == a[j]:
            ans += a[j+n]
            break

print(ans)


Measured memory_bytes: 42476
eval"N,C,*D="+`dd`.split*?,
r=*0...C
s,t,u=*(0...N*N).group_by{|i|(i/N+i%N)%3}.map{|_,v|r.map{|t|s=0;v.map{|f|s+=D[~-D[~f]*C+t]};s}},0,0
p r.permutation(3).map{|x,y,z|s[x]+t[y]+u[z]}.min

Measured memory_bytes: 72328
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<"!"<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  for(int i=0;i<n;i++){
    ll a,b;cin>>a>>b;
    if(a==b)cout<<a*2-2<<endl;
    else{
      ll mx=a*b-1;
      ll le=1,ri=INF*3;
      while(ri-le>1){
	ll mid=(le+ri)/2;
	ll x = (mid+1)/2;
	ll hg = x*(mid+1-x);
	if(hg>mx)ri=mid;
	else le=mid;
      }
      cout<<le-1<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include <string.h>
using namespace std;
int a[100005];
int main() {
	int a, b, k;
	cin >> a >> b >> k;
	set<int> ii;
	for (int i = 0; i < k; i++) {
		if ((a + i) <= b)
			ii.insert(a + i);
	}
	for (int i = k - 1; i >= 0; i--) {
		if ((b - i) >= a)
			ii.insert(b - i);
	}
	vector<int> v;
	for (auto i : ii) {
		v.push_back(i);
	}
	sort(v.begin(), v.end());
	for (auto t : v) {
		cout << t << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF=1001001001;
using ll=long long;
 
int main() {
  ll h,w;
  cin>>h>>w;
  ll x=h*w;
  if(h==1||w==1){
  cout<<1<<endl;
  }else{
  cout<<(x+1)/2<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
 
using namespace std;
const int MAX = 1000;
const double INF = 1 << 30;

int main(){
    int N,T,A;
    int H[MAX];
    int ans = 0;
    double md = INF;

    cin >> N >> T >> A;
    for(int i = 0;i < N;i++){
        cin >> H[i];
    }

    for(int i = 0;i < N;i++){
        double t = (double)T - (double)H[i] * 0.006;
        double d = t - A;

        if(d < 0)d = -d;

        if(md > d){
            md = d;
            ans = i;
        }
    }

    cout << ans + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
nk = list(map(int,input().split()))
n,k= nk[0],nk[1]
h = list(map(int,input().split()))
dp = [0] * (n)
if n >= k:
    for i in range(k):#初期条件の定義
        dp[i] = abs(h[i] - h[0])
    for l in range(n-k):#漸化式の定義
        lis = []
        for m in range(k):
            lis.append(dp[l+m] + abs(h[l+k]-h[l+m]))
        dp[l+k] = min(lis)
    print(dp[n-1])
else:#n < k
    print(abs(h[n-1]-h[0]))

Measured memory_bytes: 52448
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str,str1;
    cin>>str>>str1;
    int count=0;
    for(int i=0;i<str.length();i++)
    {
        if(str[i]!=str1[i])
        {
            count++;
        }
    }
cout<<count<<endl;
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int d(long n){
  long i;
  for(i=0;n>0;i++){
      n = n/10;
  }
  return i;
}

int main(){
  int N,K,Q;
  cin >> N >> K >>Q;
  vector<int>ch(N,0),pt(N,K),A(Q);
  for(int i=0;i<Q;i++){
      cin >> A[i];
  }
  for(int i=0;i<Q;i++){
      ch[A[i]-1]++;
  }
  for(int i=0;i<N;i++){
      pt[i] -= Q-ch[i];
  }
  for(int i=0;i<N;i++){
      if(pt[i]>0){
          cout << "Yes" << endl;
      }else{
          cout << "No" << endl;
      }
  }
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    private const int INF = 1000000007;
    public static void Main()
    {
        long[] Nx = LongLine();
        long[] a = LongLine();
        long ans = 0;
        for (int i = 1; i < Nx[0]; i++)
        {
            if (a[i - 1] + a[i] > Nx[1])
            {
                var c = a[i - 1] + a[i] - Nx[1];
                if (a[i] >= c) a[i] -= c;
                else { a[i] = 0; }
                ans += c;
            }
        }
        Console.WriteLine(ans);
    }
}

public class AtCoder
{
    public static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int GCD(int a, int b)
    {
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (b != 0)
        {
            d = a % b;
            a = b;
            b = d;
        }
        return a;
    }
    public static long LCM(int a, int b)
    {
        return (long)a * b / GCD(a, b);
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static long[] LSRead()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static long Combination(int n, int r)
    {
        if (n == r) return 1;
        return
            Enumerable.Range((n - r + 1), r).ToList().Aggregate((now, next) => now * next) /
            Enumerable.Range(1, r).ToList().Aggregate((now, next) => now * next);
    }
    public static long Permutation(int n, int r)
    {
        if (n == r) return 1;
        return
            Enumerable.Range((n - r), r).ToList().Aggregate((now, next) => now * next);
    }
    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }
    public static long LongRead()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] LongLine()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static int[] IntLine()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
}


Measured memory_bytes: 31452
n = STDIN.gets.chomp.to_i

r0 = STDIN.gets.chomp.to_i
r_min = r0

r1 = STDIN.gets.chomp.to_i
r_min = r1 if r_min > r1

r_diff = r1 - r0

2.upto(n-1) { |i|
	ri = STDIN.gets.chomp.to_i
	r_diff = ri - r_min if r_diff < ri - r_min
	r_min = ri if r_min > ri
}

print r_diff, "\n"



Measured memory_bytes: 6868
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	a := make([]int, 4)
	for i, r := range s {
		a[i] = int(r - '0')
	}

	switch {
	case a[0]+a[1]+a[2]+a[3] == 7:
		fmt.Printf("%v+%v+%v+%v=7\n", a[0], a[1], a[2], a[3])
	case a[0]+a[1]+a[2]-a[3] == 7:
		fmt.Printf("%v+%v+%v-%v=7\n", a[0], a[1], a[2], a[3])
	case a[0]+a[1]-a[2]+a[3] == 7:
		fmt.Printf("%v+%v-%v+%v=7\n", a[0], a[1], a[2], a[3])
	case a[0]+a[1]-a[2]-a[3] == 7:
		fmt.Printf("%v+%v-%v-%v=7\n", a[0], a[1], a[2], a[3])
	case a[0]-a[1]+a[2]+a[3] == 7:
		fmt.Printf("%v-%v+%v+%v=7\n", a[0], a[1], a[2], a[3])
	case a[0]-a[1]-a[2]+a[3] == 7:
		fmt.Printf("%v-%v-%v+%v=7\n", a[0], a[1], a[2], a[3])
	case a[0]-a[1]+a[2]-a[3] == 7:
		fmt.Printf("%v-%v+%v-%v=7\n", a[0], a[1], a[2], a[3])
	case a[0]-a[1]-a[2]-a[3] == 7:
		fmt.Printf("%v-%v-%v-%v=7\n", a[0], a[1], a[2], a[3])
	}
}


Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
  int64_t x;
  mint(int64_t x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(int64_t t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  //for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

//head

string k;
int d;
int n;
mint dpl[100], dpr[100];
mint *now = dpl, *pre = dpr;
int dp;

inline int num(int i) {return i%d;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> k >> d;
  n = k.size();
  rep(i, n) {
    memset(now, 0, sizeof(dpl));
    rep(j, k[i]-'0') {
      now[num(dp+j)] += 1;
    }
    rep(j, d) {
      rep(k, 10) {
        now[num(j+k)] += pre[j];
      }
    }
    dp += k[i]-'0';
    dp %= d;
    swap(now, pre);
    //rep(j, d) cout << pre[j] << (j == d-1?'\n':' ');
  }
  if(dp == 0) pre[0] += 1;
  cout << pre[0]-1 << endl;
}

Measured memory_bytes: 3624
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

bool iskaibun(string s){
	return s == string(rall(s));
}

void Main(){
	string s;
	cin >> s;
	string s1 = s.substr(0, s.size()/2);
	if(!iskaibun(s) || !iskaibun(s1)) {
		puts("No");
		return;
	};
	puts("Yes");
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

using namespace std;

int main()
{
	int score[201][3];
	int member;
	int i, j;
	int num[201] = {0};
	int ans[201] = {0};
	
	cin >> member;
	
	for (i = 0; i < member; i++){
		for (j = 0; j < 3; j++){
			cin >> score[i][j];
		}
	}
	
	for (j = 0; j < 3; j++){
		for (i = 0; i < member; i++){
			num[score[i][j]]++;
		}
		
		for (i = 0; i < member; i++){
			if (num[score[i][j]] == 1){
				ans[i] += score[i][j];
			}
		}
		for (i = 0; i < 101; i++){
			num[i] = 0;
		}
	}
	
	for (i = 0; i < member; i++){
		cout << ans[i] << endl;
	}
	
	return (0);
}

Measured memory_bytes: 3088
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main()
{
	ll X;
	ll i =100;
	ll count = 0;
	//string S;
	cin >> X;
	//vector<int> a(N);
	while(1)
	{
		i += i * 0.01;
		count++;
		if (i>=X)
		{
			cout << count << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
}


Measured memory_bytes: 3632
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()

	xs := make([]int, n)
	for i := range xs {
		xs[i] = nextInt()
	}

	ys := make([]int, n)
	copy(ys, xs)
	sort.Ints(ys)
	mid1 := ys[len(ys)/2-1]
	mid2 := ys[len(ys)/2]

	ans := make([]string, n)
	for i, x := range xs {
		if x <= mid1 {
			ans[i] = strconv.Itoa(mid2)
		} else {
			ans[i] = strconv.Itoa(mid1)
		}
	}
	fmt.Println(strings.Join(ans, "\n"))
}


Measured memory_bytes: 17920
N = int(input())
#A = list(map(int, input().split()))
amount = (N+1) * N // 2
three = N // 3
three = (three + 1) * 3 * three // 2 if three > 0 else 0
five = N // 5
five = (five + 1) * 5 * five // 2 if five > 0 else 0
fifteen = N // 15
fifteen = (fifteen + 1) * 15 * fifteen // 2 if fifteen > 0 else 0
print(amount-three-five+fifteen)


Measured memory_bytes: 61608
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int N; cin >> N;
VI A(N); rep(i, 0, N) cin >> A[i];
sort(ALL(A));

while(any_of(RANGE(A, 0, N-1), [](int i) {return i > 0;})){
    VI::iterator nonzero = upper_bound(ALL(A), 0);
    for (VI::iterator i = nonzero+1; i != A.end(); ++i)
        *i %= *nonzero;
    sort(ALL(A));
}

cout << A[N-1] << endl;

}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void app() {
  int n,a[3];
  cin>>n>>a[0]>>a[1]>>a[2];

  vector<string> sv(n);
  rep(i,n){
    cin>>sv[i];
  }

  string ans;
  rep(i,n){
    string s=sv[i];
    int c=s[0]-'A';
    int d=s[1]-'A';

    if(a[c]<a[d]){
      ans+='A'+c;
      a[c]++;a[d]--;
    }else if(a[c]>a[d]){
      ans+='A'+d;
      a[d]++;a[c]--;
    }else if(i==n-1 || sv[i]==sv[i+1]){
      ans+='A'+c;
      a[c]++;a[d]--;
    }else{
      string sn=sv[i+1];
      int e=sn[0]-'A';
      int f=sn[1]-'A';
      if(c==e||c==f){
        ans+='A'+c;
        a[c]++;a[d]--;
      }else{
        ans+='A'+d;
        a[d]++;a[c]--;
      }
    }

    if(a[0]<0||a[1]<0||a[2]<0){
      cout<<"No"<<endl;
      return;
    }
  }

  cout<<"Yes"<<endl;
  rep(i,n){
    cout<<ans[i]<<endl;
  }
}

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


Measured memory_bytes: 6644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int a[10005],b[10005];
ll sum1,sum2;
ll delta,qwq;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i],sum1+=a[i];
	for(int i=1;i<=n;i++) cin>>b[i],sum2+=b[i];
	if(sum1>sum2) {
		cout<<"No";return 0;
	}
	delta=sum2-sum1;
	for(int i=1;i<=n;i++)
	if(b[i]>a[i])
	qwq+=(b[i]+1-a[i])/2;
	if(qwq>delta) cout<<"No";
	else cout<<"Yes";
	return 0;
}

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

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

using namespace std;

typedef long double ld;

double calc(int k, ld prob, ld r, ld l, ld lw, ld up, ld p) {
  if (lw <= r && l <= up) return prob;
  else if (up < r || lw > l) return 0;
  ld mid = (r + l) / 2.0;
  if (k == 0) {
    if (lw <= mid && mid <= up) return prob;
    else return 0;
  }
  ld pr, pl;
  if (mid < (lw+up)/2.0) {
    pr = p;
    pl = 1-p;
  } else {
    pr = 1-p;
    pl = p;
  }
  return (calc(k-1, prob * pr, r, (r+l)/2.0, lw, up, p) +
      calc(k-1, prob * pl, (r+l)/2.0, l, lw, up, p));
}

int main() {
  int k;
  cin>>k;
  ld r,l,p,e,t;
  cin>>r>>l>>p>>e>>t;
  cout <<setprecision(10) << fixed<< calc(k, 1.0, r, l, t-e, t+e, p) << endl;
  return 0;
}

Measured memory_bytes: 1292
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>
 
const int MAX_N = 100;
long long a[MAX_N];
const int N = 50;
long long K;
 
int main(int argc, char **argv) {
    std::cin >> K;
    
    long long res = K % 50;
    long long base = K / 50;

    for (int i = 1; i <= N; i++) {
        a[i] = 49 + base;
    }

    if (res != 0) {
        for (int i = 1; i <= N; i++) {
            a[i]++;
        }
        for (int n = 1; n <= 50 - res; n++) {
            for (int i = 1; i <= N; i++) {
                if (i == n) {
                    a[i] -= 50;
                } else {
                    a[i]++;
                }
            }
        }
    }

    std::cout << N << std::endl;
    for (int i = 1; i <= N; i++) {
        std::cout << a[i];
        if (i == N) {
            std::cout << std::endl;
        } else {
            std::cout << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 256
N,W=map(int,input().split())
w=[]
v=[]
for i in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)
dp=[[0 for i in range(W+1)] for j in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j>=w[i]:
            dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j])
        else:
            dp[i+1][j]=dp[i][j]
print(dp[N][W])
       


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

ll modpow(ll a,ll n){
    ll res = 1;
    while(n>0){
        if(n&1)res = res * a % mod;
        a = a*a%mod;
        n>>=1; 
    }
    return res;
}

ll choose(ll n,ll b){
    ll x = 1,y = 1;
    rep(i,b){
        x *= n-i; x %= mod;
        y *= i+1; y %= mod;
    }
    return x * modpow(y,mod-2) % mod;
}

int main(){
    ll n,a,b;
    ll ans;
    cin >> n >> a >> b;
    ans = modpow(2,n);
    ans -= 1;
    ans -= choose(n,a);
    ans -= choose(n,b);
    while(ans < 0) ans += mod;
    cout << ans << endl;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;
using static Read;

class Program
{
    public static void Main()
    {
        var n = IntArray();
        Sort(n);
        int count = 1;
        for(int i = 1; i < n.Length; i++)
        {
            if(n[i - 1] != n[i])
            {
                count++;
            }
        }
        WriteLine($"{count}");
    }
}

static class Read
{
    static Queue<string> queue = new Queue<string>();
    static void Enqueue()
    {
        ReadLine().Split(' ').ToList().ForEach(a => queue.Enqueue(a));
    }
    public static int Int()
    {
        if(queue.Count == 0)
            Enqueue();
        return int.Parse(queue.Dequeue());
    }
    public static long Long()
    {
        if(queue.Count == 0)
            Enqueue();
        return long.Parse(queue.Dequeue());
    }
    public static double Double()
    {
        if(queue.Count == 0)
            Enqueue();
        return double.Parse(queue.Dequeue());
    }
    public static string String()
    {
        if(queue.Count == 0)
            Enqueue();
        return queue.Dequeue();
    }
    public static int[] IntArray()
    {
        return ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }
    public static long[] LongArray()
    {
        return ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
    }
    public static double[] DoubleArray()
    {
        return ReadLine().Split(' ').Select(a => double.Parse(a)).ToArray();
    }
    public static string[] StringArray()
    {
        return ReadLine().Split(' ');
    }
}


Measured memory_bytes: 13396
#include <stdio.h>
#include<math.h>
#include<string.h>

int substr(char *t,const char *s,int pos,int len )
{
    if(pos < 0||len < 0||len > strlen(s))
        return -1;
    for(s += pos;*s!='\0' && len>0;len--)
        *t++ = *s++;
    *t = '\0';
    return 0;
}

int main(void){
    int N,k;
    char s[100];
    char t[100];
    char u[200];
    char r[200];

    scanf("%d",&N);
    scanf("%s",&s);
    scanf("%s",&t);
  
    for(k=0;k <= 2*N;k++){
        if(k%2==0){
            u[k]=s[k/2];
        }

        if(k%2==1){
            u[k]=t[(k-1)/2];
        }
    }
    
    substr(r,u,0,2*N);
  
    printf("%s",r);
  
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){

int n;
int i,j,k;//制御
long killsum=0;

scanf("%d",&n);

int a[n+1];//モンスターの数
int b[n];//夕社が殺せる数
int c[n];

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

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

for(i=0;i<n;i++){
    if(a[i]<b[i]){
        c[i]=b[i]-a[i];
        killsum=killsum+a[i];
        //printf("勇者%dはステージ%dで%d隊殺しました。\n",i,i,a[i]);
        if(a[i+1]-c[i]>=0){
            a[i+1]=a[i+1]-c[i];
            killsum=killsum+c[i];
           //  printf("勇者%dはステージ%dで%d隊殺しました。",i,i+1,c[i]);
        } 
        else if(a[i+1]<=c[i]){
            killsum=killsum+a[i+1];
            a[i+1]=0;
            // printf("勇者%dはステージ%dで%d隊殺しました。",i,i+1,a[i]);
        }
    }
    else if(b[i]<=a[i]){
        killsum=killsum+b[i];
        a[i]=a[i]-b[i];
        
        // printf("勇者%dはステージ%dで%d隊殺しました。",i,i,b[i]);
         b[i]=0;
    }
}
printf("%ld",killsum);
   
    

    return 0;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll x, a, b;
	cin>>x>>a>>b;
	cout<<(x-a)%b<<endl;
	return 0;
}


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


using namespace std;

int N, K, X;
string S;


int main()
{

    cin >> X;

    int con500 = 0;
    int con5   = 0;
    int con    = 0;
    int a = 0;

    con500 = X / 500;
    a      = X % 500;

    con5 = a / 5 ;


    con = con500*1000 + con5*5;

    cout << con << "\n";


}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
  priority_queue<int> PQ;
  int N, M;
  cin >> N >> M;

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    PQ.push(a);
  }

  for (int i = 0; i < M; i++) {
    int cur = PQ.top();
    PQ.pop();
    cur /= 2;
    PQ.push(cur);
  }

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ans += PQ.top();
    PQ.pop();
  }
  cout << ans << endl;
  return 0;
}

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

#ifdef LOCAL
#include "../debug.h"
#else
#define debug(x...) 141
#endif
#define forn(i,x,n) for(int i = x; i < n; ++i)
#define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it)
typedef long long ll;

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

    cin>>n;
    vector<int> a(n+1);
    forn(i,1,sqrt(n)+2)
    	forn(j,1,sqrt(n)+2)
    		forn(k,1,sqrt(n)+2)
    			if(i*i+j*j+k*k+i*j+i*k+j*k<=n)
    				a[i*i+j*j+k*k+i*j+i*k+j*k]++;

    forn(i,1,n+1)
    	cout<<a[i]<<'\n';
    
    return 0;
}

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

string s,t,lcs="";
int dp[3005][3005];

signed main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>s>>t;
    for(int i=1;i<=s.length();++i) {
        for(int j=1;j<=t.length();++j) {
            if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int i=s.length(),j=t.length();
    while(i>0&&j>0) {
        if(s[i-1]==t[j-1]) {
            lcs=s[i-1]+lcs;
            --i;--j;
        }
        else {
            if(dp[i][j-1]>dp[i-1][j]) --j;
            else --i;
        }
    }
    cout<<lcs;
    return 0;
}


Measured memory_bytes: 35456
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

void init(){
	
}

bool solve(){
	int n,m;
	int i,j,k;
	int a,b,c,d;
	string sa[70];
	vector<int> path[10];
	map<char,int> m1;
	bool used[11][11];
	memset(used,false,sizeof(used));
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>sa[i];
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(sa[i][j]=='.')continue;
			if(m1.find(sa[i][j])==m1.end()){
				a=m1.size();
				m1[sa[i][j]]=a;
			}
		}
	}
	for(auto node:m1){
		a=100,b=0,c=100,d=0;
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				if(sa[i][j]!=node.first)continue;
				a=min(a,i),b=max(b,i);
				c=min(c,j),d=max(d,j);
			}
		}
		for(i=a;i<=b;i++){
			for(j=c;j<=d;j++){
				if(sa[i][j]=='.')return false;
				if(sa[i][j]==node.first || used[node.second][m1[sa[i][j]]])continue;
				used[node.second][m1[sa[i][j]]]=true;
				path[m1[sa[i][j]]].push_back(node.second);
			}
		}
	}
	vector<int> path_cnt(10,0);
	queue<int> q1;
	n=10;
	for(i=0;i<10;i++){
		for(auto to:path[i])path_cnt[to]++;
	}
	for(i=0;i<10;i++){
		if(path_cnt[i]==0)q1.push(i);
	}
	while(!q1.empty()){
		a=q1.front(),q1.pop();
		n--;
		for(auto to:path[a]){
			path_cnt[to]--;
			if(path_cnt[to]==0)q1.push(to);
		}
	}
	if(n)return false;
	return true;
}

int main(){
	int n,i;
	init();
	cin>>n;
	for(i=0;i<n;i++){
		if(solve())cout<<"SAFE"<<endl;
		else cout<<"SUSPICIOUS"<<endl;
	}
}


Measured memory_bytes: 3232
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int x,y;
int ans;
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[1000005],R[1000005];
void make(){
	F[0] = 1;
	for(int i=1;i<1000005;i++) F[i] = F[i-1]*i%mod;
	for(int i=0;i<1000005;i++) R[i] = modpow(F[i],mod-2);
}
ll C(int a,int b){
	return F[a]*R[b]%mod*R[a-b]%mod;
}
int main(){
	cin>>x>>y; make();
	for(int i=0;i<=1000000;i++){
		if(x < i || y < 2*i) continue;
		int X = x-i;
		int Y = y-2*i;
		if(X == Y*2) ans+=C(i+Y,i);
	}
	cout<<(ans%mod+mod)%mod<<endl;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int x;
	cin >> x;
	if (x >= 30) cout << "Yes\n";
	else cout << "No\n";
}



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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int ans = 0;
    for (int i = 1; i <= 100; ++i) {
        for (int j = 0; i + j <= n; ++j) {
            if (i <= p[j]) {
                ans = max(ans, i);
                break;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


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

using namespace std;

const int mod=1000000007;
int n,x,f[1<<20],lst[1<<20];

int main(){
	scanf("%d",&n);
	f[0]=1;
	for (int i=1;i<=n;++i){
		scanf("%d",&x);
		f[i]=f[i-1];
		if (lst[x]&&lst[x]!=i-1){
			f[i]=(f[i]+f[lst[x]])%mod;
		}
		lst[x]=i;
	}
	printf("%d\n",f[n]);
	
	return 0;
}
			

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
	string str;
	cin>>str;
	int mid = str.length()/2;
	int len = str.length();
	int counter{};
	for(int i=0;i<mid;i++)
		if(str[i] != str[len - 1 - i])
			counter++;
	cout<<counter;
	return 0;
}

Measured memory_bytes: 3636
#pragma GCC positionimize(3,"Otrst","inline")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<algorithm>
#include<tr1/unordered_map>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e6+10;
const int INF=0x3fffffff;
const double pi = 3.141592653;
const double E = 2.71828182846;
//const ll mod=9999991;
const int M=2e4+5;
const double eps=1e-8;
const ll MMod=1ll<<32;
#define ci(x) scanf("%d",&x)
#define co(x) printf("%d\n",x)

inline int read()
{
    int f=1,x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
        if(c=='-')
            f=-1;
        c=getchar();
    }
    while(c>='0' && c<='9')
    {
        x=x*10+c-'0';
        c=getchar();
    }
    return f*x;
}

ll fast_muttki(ll m, ll n,ll mod)//快速乘法
{
    ll cnt = 0;//注意初始化是0，不是1
    while (n)
    {
        if (n & 1)
        {
            cnt += m;
            cnt %= mod;
        }
        m = (m + m) % mod;//和快速幂一样，只不过这里是加
        n >>= 1;
    }
    return cnt;
}
ll fast_get(ll a, ll n,ll mod)//快速幂
{
    ll cnt = 1;
    while (n)
    {
        if (n & 1)
            cnt = fast_muttki(cnt,a,mod);//不能直接乘
        a = fast_muttki(a, a,mod);
        cnt %= mod;
        a %= mod;
        n >>= 1;
    }
    return cnt;
}
char s[M];
char t[M];
int ans;
int n;
void dfs(int res)
{
    for(int i=res,j=1;i<=n;i++,j++)
    {
        if(s[i]!=t[j])
            return dfs(res+1);
    }
    ans=res+n-1;

}
int main()
{
    ci(n);
    scanf("%s%s",s+1,t+1);
    dfs(1);
    co(ans);
    return 0;
}
// 5 5 2 1 5 4  = 9
// 5 2 1 5 4 5  = 7
// 5 5 2 1 4 5  = 8


Measured memory_bytes: 768
import java.io.*;
import java.util.StringTokenizer;



public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		long sum=0;
		for(int i=1; i<=n ; i++) {
			if(i%3!=0 && i%5!=0) {
				sum+=i;
			}
		}
		System.out.println(sum);
		
	}


	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    float k,n;
    
    cin>>k>>n;
    int x;
    if(n==1){
        cout<<0;
        return 0;
    }
    float y = (n-1)/(k-1);
    x = ceil(y);
    cout<<x;
    return 0;
}

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

const int MAX_N = 3000;

int n;
double f[MAX_N][MAX_N];

int main()
{
	std::cin >> n;
	f[0][0] = 1.0;
	for (int i = 0; i < n; ++i)
	{
		double p; std::cin >> p;
		for (int j = 0; j <= i; ++j)
		{
			f[i + 1][j + 1] += f[i][j] * p;
			f[i + 1][  j  ] += f[i][j] * (1.0 - p);
		}
	}
	std::cout << std::fixed << std::setprecision(10);
	std::cout << std::accumulate(f[n] + n / 2 + 1, f[n] + n + 1, 0.0) << '\n';
}

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

vector<vector<int>> g;
vector<int> d;
vector<int> f;
int t;

void dfs( int v )
{
	d[v] = ++t;
	for( int u : g[v] ) {
		if( d[u] ) continue;
		dfs( u );
	}
	f[v] = ++t;
}

int main()
{
	int n;
	cin >> n;
	g = vector<vector<int>>( n );
	d = vector<int>( n );
	f = vector<int>( n );
	for( int i = 0; i < n; i++ ) {
		int u, k;
		cin >> u >> k;
		u--;
		for( int j = 0; j < k; j++ ) {
			int v;
			cin >> v;
			v--;
			g[u].push_back( v );
		}
	}

	for( int i = 0; i < n; i++ ) {
		if( d[i] ) continue;
		dfs( i );
	}

	for( int i = 0; i < n; i++ ) {
		cout << i + 1 << " " << d[i] << " " << f[i] <<  endl;
	}
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
int main(){
  long int n;
  cin >> n;
  int A,B;
  A = B = 0;
  vector<int> num(7,0); 
  for(int i = 0;;i++){
    int num = n%10;
    A += num/2;
    B += num-(num/2);
    n /= 10;
    if(n == 0) break;
  }
  int answer = A + B;
  if(answer == 1) answer = 10;
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int l;
  cin>>l;
  long long a[l];
  REP(i,l){
    cin>>a[i];
  }
  vector<vector<long long>> dp(l, vector<long long>(5, INF));
  auto cost = [&](int i, int t)->long long{
    if(t == 0 || t == 4){
      return a[i];
    }else if(t == 1 || t == 3){
      if(a[i]%2 == 0){
        if(a[i] == 0){
          return 2;
        }else{
          return 0;
        }
      }else{
        return 1;
      }
    }else{
      if(a[i]%2 == 0){
        return 1;
      }else{
        return 0;
      }
    }
  };
  REP(i,l){
    REP(t,5){
      if(i == 0){
        dp[i][t] = cost(i,t);
        continue;
      }
      for(int j = 0; j<=t; j++){
        dp[i][t] = min(dp[i][t], dp[i-1][j] + cost(i,t));
      }
    }
  }
  long long ans = INF;
  REP(t,5){
    ans = min(ans, dp[l-1][t]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 15872
#include <cstdio>
#include <cstring>
#define max(a,b) a>b?a:b
#define N_MAX 1000
int main() {
    int w, n, cnt = 1;
    int val[N_MAX],g[N_MAX],dp[N_MAX+1];

    while (scanf("%d%d", &w, &n), w){
        for (int i = 0; i < n; i++) {
            scanf("%d,%d", val+i, g+i);
        }
        memset(dp, -1, sizeof(dp));
        dp[0] = 0;
        for (int i = 0; i < n; i++){
            for (int j = w-g[i]; j>= 0; j--)
                if (dp[j]>=0) dp[j+g[i]] = max(dp[j+g[i]], dp[j]+val[i]);
        }
        int p = 0, q = 0;
        for (int i = 0; i <= w; i++) {
            if (dp[i]>p) {
                p = dp[i];
                q = i;
            }
        }

        printf("Case %d:\n%d\n%d\n", cnt++, p, q);
    }
    return 0;
}

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

#define pb push_back
#define all(a) (a).begin(), (a).end()

using ll = long long;
using pii = pair<int, int>;

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    ll a, b; cin >> a >> b;
    cout << (a / __gcd(a, b)) * b;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        System.out.println(Math.max(a + b, Math.max(a - b, a * b)));
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>                
using namespace std;
#define REP(i,n) for(auto i = 0; i < (n); ++i)
#define REP1(i,n) for(auto i = 0; i <= (n); ++i)
#define REPO(i,o,n) for(auto i = (o); i < (n); ++i)
#define REPR(i,n) for(auto i = (n)-1; i >= 0; --i)
#define REPI(itr,v) for(auto itr=v.begin(); itr != v.end(); ++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin(); itr != v.rend(); ++itr)
#define ALL(v) v.begin(), v.end()
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}
#define push_back pb;
#define push_front pf; 
#define make_pair mp;
#define first fi;
#define second se;
typedef long long ll;

int N, tmp;
int main(void){
	REP(i,3){
		cin >> tmp;
		N = N * 10 + tmp;
	}
	if(N % 4) cout << "NO" << endl;
	else cout << "YES" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

int N, K;
string S;
int main(void){
    cin >> N >> K;
    cin >> S;
    int count = 0;
    REP(i, N){
        if(S[i] == S[i+1]) count++;
    }
    cout << min(count+2*K, N-1) << endl;
    return 0;
}



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

int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    
    cout << a + b + c + d + e + f - min(min(a,b),min(d,c)) - min(e,f) << endl;
    
}



Measured memory_bytes: 3096
li=input()
n=len(li)
child_li=[0]*n

ruiseki=0
#まず、RRRRRRRLのようにRが連続してLが最後に来る場合のRLを考える。左から
for i in range(n-1):
    if li[i]=='R':
        ruiseki+=1
        if li[i+1]=='L':
            child_li[i+1]=ruiseki//2#------Lについて、Rが連続の分の半分（こっちは切り捨て）
            child_li[i]=(ruiseki+1)//2#----Rについて、Rが連続の分の半分（こっちは奇数の場合切り上げ）
    else:
        ruiseki=0

#同様に、LLLLLLRのようにLが連続してLが最後に来る場合のRLを考える。右から
ruiseki=0
for i in range(n-1, 0, -1):
    if li[i]=='L':
        ruiseki+=1
        if li[i-1]=='R':
            child_li[i-1]+=ruiseki//2#-----Rについて、Lが連続の分の半分（こっちは切り捨て）
            child_li[i]+=(ruiseki+1)//2#---Lについて、Lが連続の分の半分（こっちは奇数の場合切り上げ）
    else:
        ruiseki=0

print(*child_li)

Measured memory_bytes: 47684
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,a[1010],b[1010],x,dp[5000],tmp;
vector <int> c[1010];

int main()
{
	cin>>n>>m;
	rep(i,m)
	{
		cin>>a[i]>>b[i];
		rep(j,b[i])
		{
			scanf("%d",&x);
			c[i].pb(x-1);
		}
	}
	rep(i,4900) dp[i]=1e9;
	dp[0]=0;
	rep(i,m)
	{
		rep(j,1<<n)
		{
			if(dp[j]==1e9) continue;
			tmp=j;
			rep(k,b[i]) tmp|=(1<<c[i][k]);
			dp[tmp]=min(dp[tmp],dp[j]+a[i]);
		}
	}
	if(dp[(1<<n)-1]==1e9) puts("-1");
	else cout<<dp[(1<<n)-1]<<endl;
	return 0;
}

Measured memory_bytes: 384
x1, y1, x2, y2 = map(int, input().split())

dx, dy = x2 - x1, y2 - y1

x3, y3 = (x2 - dy, y2 + dx)
x4, y4 = (x1 - dy, y1 + dx)

print(x3, y3, x4, y4)

Measured memory_bytes: 3060