akhauriyash/Code-Regression huggingface dataset:
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

typedef db T;
const db eps = 1e-8;
int sgn(T x){return (x>eps)-(x<-eps);}
struct P{
    T x,y;
    P(){} P(T x,T y):x(x),y(y){}
    void read(){scanf("%lf%lf",&x,&y);}
    P operator - (const P&b) const {return P(x-b.x,y-b.y);}
    P operator + (const P&b) const {return P(x+b.x,y+b.y);}
    T operator * (const P&b) const {return x*b.x+y*b.y;}
    P operator * (const T&k) const {return P(x*k,y*k);}
    T operator ^ (const P&b) const {return x*b.y-y*b.x;}
    bool operator < (const P&b) const {return sgn(x-b.x)?x<b.x:y<b.y;}
    P rot90() {return P(-y,x);}
};
T norm(P x){return x*x;}
T abs(P x){return sqrt(x*x);}
struct C{
    P o;T r;
    void read(){o.read();scanf("%lf",&r);}
};
vector<P> insCC(C c1,C c2){
    db x = norm(c1.o - c2.o) ,
       y = ((c1.r * c1.r - c2.r * c2.r) / x + 1) / 2 ,
       d = c1.r * c1.r / x - y * y;
    vector<P> res;
    if(sgn(d) < 0) return res;
    d = max(d,0.);
    P mid = (c2.o - c1.o) * y + c1.o ,
      del = ((c2.o - c1.o) * sqrt(d)).rot90();
    return {mid + del , mid - del};
}

int main(){
    C o1,o2;
    o1.read();o2.read();
    vector<P> ans = insCC(o1,o2);
    sort(all(ans));
    for(auto p : ans) printf("%.10f %.10f ",p.x,p.y);
    return 0;
}

Measured memory_bytes: 3224
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i,n)   for (int i = 0; i < (n); ++i)
#define SORT(a)    sort((a).begin(), (a).end());
#define UNIQ(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define FIND(a,x)  find((a).begin(), (a).end(), (x)) != (a).end()
#define REVERSE(a) reverse((a).begin(), (a).end());
#define OUT(d) cout << (d)
#define OUT_L(d) std::cout<<(d)<<"\n";
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define CEIL(x, y) ((x + y - 1) / (y))

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));

	int N, Q; cin >> N >> Q;
	string S; cin >> S;
	int sum[N + 1]; memset(sum, 0, sizeof(sum));
	for (int i = 1; i <= N; i++) {
		sum[i + 1] = sum[i];
		if (S[i - 1] == 'A' && S[i] == 'C') sum[i + 1]++;
	}
	for (int i = 0; i < Q; i++) {
		int l, r; cin >> l >> r;
		OUT_L(sum[r] - sum[l])
	}
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  for(int i=0; i<N; i++){
    cin >> B[i];
  }
  vector<int> C;
  long S=0, S1=0;
  int ans=0;
  for(int i=0; i<N; i++){
    if(A[i]>=B[i]){
      S1+=A[i]-B[i];
      C.push_back(A[i]-B[i]);
    }else{
      S+=B[i]-A[i];
      ans++;
    }
  }
  if(ans==0){
    cout << "0" << endl;
    return 0;
  }else if(S1<S){
    cout << "-1" << endl;
    return 0;
  }
  sort(C.begin(), C.end(), greater<int>());
  for(int i=0; i<C.size(); i++){
    S=S-C[i];
    ans++;
    if(S<=0) break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1660
import random
a,b,n=map(int,input().split())
def f(x):
    return int(a*x/b)-a*int(x/b)
if n<b:
    ans =f(n)
else:
    t = n
    u = b - 1
    v=min(t,u)
    ans=f(v)
print(ans)

Measured memory_bytes: 76848
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    Q, H, S, D = map(int, input().split())
    N = int(input())
    ans = INF
    ans = min(ans, N * 4 * Q)
    ans = min(ans, N * 2 * H)
    ans = min(ans, N * 1 * S)
    d = N // 2
    if N % 2 == 0:
        ans = min(ans, d * D)
    else:
        ans = min(ans, d * D + Q * 4)
        ans = min(ans, d * D + H * 2)
        ans = min(ans, d * D + S)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
N,M = map(int,input().split())
H = list(map(int,input().split()))
L = [1]*N
for i in range(M):
    A,B = map(int,input().split())
    if H[A-1] > H[B-1]:
        L[B-1] = 0
    elif H[B-1] > H[A-1]:
        L[A-1] = 0
    else:
        L[B-1] = 0
        L[A-1] = 0
print(sum(L))


Measured memory_bytes: 20104
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> p;
typedef long long ll;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;
const ll MOD=1e9+7;
struct edge{
    int to;
    int cost;
};

int main(){
    string L;cin>>L;
    int N=(int)L.size();
    ll DP[N+1][2];
    for(int i=0;i<=N;++i){
        for(int j=0;j<2;++j){
            DP[i][j]=0;
        }
    }
    DP[0][0]=1;
    for(int i=0;i<N;++i){
        if(L[i]=='0'){
            DP[i+1][0]=DP[i][0];
            DP[i+1][1]=DP[i][1]*3%MOD;
        }else{
            DP[i+1][0]=DP[i][0]*2%MOD;
            DP[i+1][1]=(DP[i][0]+DP[i][1]*3)%MOD;
        }
    }
    cout<<(DP[N][0]+DP[N][1])%MOD<<endl;
    return 0;
}

Measured memory_bytes: 5304
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int main(void) {
	int N;
	scanf("%d", &N);
	int W[110];
	int a = 0;
	int b = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &W[i]);
		a += W[i];
	}
	int ans = a;
	for (int i = N; i > 0; i--) {
		ans = min(ans, abs(a - b));
		a -= W[i - 1];
		b += W[i - 1];
	}
	printf("%d", ans);

	return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
 
 
class FactorialMod{
    void calc_inverse(){
        inverse[0] = 0;
        inverse[1] = 1;
        for(int i=2; i<=max_num; i++){
            inverse[i] = MOD-((MOD/i)*inverse[MOD%i]%MOD);
        }
    }
 
    void calc_factorial_inverse(){
        factorial[0] = factorial_inverse[0] = 1;
        for (int i=1; i<=max_num; i++) {
            factorial[i] = (factorial[i-1]*i)%MOD;
            factorial_inverse[i] = (factorial_inverse[i-1]*inverse[i])%MOD;
        }
    }
 
    public:
        int max_num;
        vector<ll> inverse; 
        vector<ll> factorial;
        vector<ll> factorial_inverse;
        FactorialMod(int _max_num){
            max_num = _max_num;
            inverse = vector<ll>(max_num+1);
            factorial = vector<ll>(max_num+1);
            factorial_inverse = vector<ll>(max_num+1);
            calc_inverse();
            calc_factorial_inverse();
        }
 
        ll combination(int n, int k){
            return (((factorial[n]*factorial_inverse[k])%MOD)*factorial_inverse[n-k])%MOD;
        }
 
        ll multiChoose(int n, int k){
            return combination(n+k-1, k);
        }
        
};
 
ll modpow(ll x, ll n){
    ll res=1, dig=x;
    while(n){
        if(n&1) res = res*dig%MOD;
        dig = dig*dig%MOD;
        n /= 2;
    }
    return res;
}
 
int main(){
    ll k;   cin >> k;
    string s;   cin >> s;
 
    ll res=0, n=s.size();
    FactorialMod calc_mod(n+k);
    REP(i, k+1){
        res += modpow(26, i)*modpow(25, k-i)%MOD*calc_mod.multiChoose(n, k-i)%MOD;
        res %= MOD;
    }
    cout << res << endl;
  
}

Measured memory_bytes: 51228
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	m := map[int]bool{1: true, 2: true, 3: true}
	delete(m, a)
	delete(m, b)
	for k, _ := range m {
		fmt.Println(k)
		break
	}
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() 
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(b <= c &&  c<= a)
        cout << b << " " << c << " " << a << endl;
    else if(b <= a &&  a<= c)
        cout << b<< " " << a << " " << c << endl;
    else if(c <= a &&  a<= b)
        cout << c<< " " << a << " " << b << endl;
    else 
        cout << c<< " " << b << " " << a << endl; 
}


Measured memory_bytes: 3084
a,b,k=map(int,input().split())

if b-a+1<=2*k:
    for i in range(a,b+1):
        print(i)

else:
    aa=[a+i for i in range(k)]
    bb=[b-j for j in range(k)]
    cc=sorted(aa+bb)
    for s in cc:
        print(s)


Measured memory_bytes: 3060
import java.util.Scanner;

class Main {

    static int calc(int sum){
	return Math.min(sum, 18 - sum) + 1;
    }

    public static void main(String[] args){
	Scanner stdin = new Scanner(System.in);
	while(stdin.hasNextInt()){
	    int sum = stdin.nextInt();
	    int ab = 0;
	    int cd = 0;
	    int ans = 0;
	    for(ab = 0; ab <= 18 && ab + cd <= sum; ab++){
		for(cd = 0; cd <= 18 && ab + cd <= sum; cd++){
		    if(ab + cd == sum){
			ans += calc(ab) * calc(cd);
		    }
		}
		cd = 0;
	    }
	    System.out.println(ans);
	}
    }
}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,k,maxx=0;
	int l[50];
	int t;
	cin >> n >> k;
	for(t=0;t<n;t++)
	{
		cin >> l[t];
	}
	sort(l,l+n);
	for(t=0;t<k;t++)
		maxx += l[n-1-t];
	cout << maxx << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] h = new int[N+1];
    for(int i = 1; i <= N; i++) h[i] = sc.nextInt();
    int[] dp = new int[N+1];
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = Math.abs(h[2] - h[1]);
    for(int i = 3; i <= N; i++) {
      int num = Integer.MAX_VALUE;
      for(int k = 1; k <= K && k < i; k++) {
        num = Math.min(num, dp[i-k] + Math.abs(h[i] - h[i-k]));
      }
      dp[i] = num;
    }
    System.out.println(dp[N]);
  }
}


Measured memory_bytes: 51192
#教室内の位置は右*中央
#問題は「Recursion / Divide and Conquer - The Number of Inversions」(http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_D&lang=jp)

#とりあえず入力部
n = int(input())
lis = list(map(int,input().split()))

#方針ですが、N=200000というところから、O(N)もしくはO(NlogN)であるという推測が立ちます。
#転倒数はバブルソートの時の入れ替えの回数というヒントが示されているので、ソートを使えばいいのではないかという予想が生えます
#というわけで計算量が一定であるところのマージソートが良さそうという気がします
#マージソートの機構を考えれば、マージの際に左側と右側を合わせていくわけですが、
#左側の数字が右の数字より大きい場合、その分だけ転倒数が生まれます(それぞれは部分的にソートされているので)
#したがって、マージする時に左が右より大きければある数だけ転倒数を増やします
#「ある数」とは、左側にあとn個数字が残っていればそのタイミングでのnになります
#以下は実装部分ですが、マージソートを描くのが面倒なのでQiitaから貼り付けました
#マージの部分が関数になっているので、ansを増やす時に関数の中で動かすためグローバル変数にします

def merge_sort(arr):
    if len(arr) <= 1:
        return arr

    mid = len(arr) // 2
    left = arr[:mid]
    right = arr[mid:]

    left = merge_sort(left)
    right = merge_sort(right)

    return merge(left, right)


def merge(left, right):
    global ans
    merged = []
    l_i, r_i = 0, 0

    while l_i < len(left) and r_i < len(right):
        if left[l_i] <= right[r_i]:
            merged.append(left[l_i])
            l_i += 1
        else:
            merged.append(right[r_i])
            r_i += 1
            ans += (len(left) - l_i)

    if l_i < len(left):
        merged.extend(left[l_i:])
    if r_i < len(right):
        merged.extend(right[r_i:])
    return merged

ans = 0
merge_sort(lis)
print(ans)



Measured memory_bytes: 27472
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl

using namespace std;
using ll = long long;

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}


int main() {
  ll MAX = 1000100;
  vector<bool> dp(MAX, true);
  vector<int> cnt(MAX, 0);

  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  sort(all(a));

  for (int i = 1; i <= MAX; ++i) {
    dp[i] = (cnt[i] == 1);
  }

  for (int i = 1; i <= MAX; ++i) {
    for (int j = i * 2; j <= MAX; j += i) {
      if (cnt[i]) dp[j] = false;
    }
  }

  int ans = 0;
  rep(i, n) if (dp[a[i]]) ans++;

  cout << ans << endl;
}


Measured memory_bytes: 8804
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()


void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

//ifstream &cin
void solve() {

}

int main() {
    fastik();
    ll n;
    cin >> n;
    vll a(n, 0);
    multiset<ll> s;
    set<ll> ss;
    forn(i, n) {
        cin >> a[i];
        s.insert(a[i]);
        ss.insert(a[i]);
    }
    vll ans(ll(2e+5) + 1, 0);
    forn(i, n) {
        if (ans[a[i]]) {
            cout << ans[a[i]] << '\n';
            continue;
        }
        for (auto it = ss.rbegin(); it != ss.rend(); ++it) {
            if (*it != a[i] || ((*it == a[i] && s.count(*it) > 1))) {
                cout << *it << '\n';
                ans[a[i]] = *it;
                break;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 19712
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    string s,t;
    cin>>s>>t;
    int exist=-1;
    rep(i,0,s.size()){
        if(i+t.size()>s.size())break;
        bool check=true;
        rep(j,0,t.size()){
            if(s[i+j]==t[j]||s[i+j]=='?')continue;
            else check=false;
        }
        if(check)chmax(exist,(int)i);
    }
        if(exist!=-1){
            rep(f,0,exist){
                if(s[f]=='?')cout<<'a';
                else cout<<s[f];
            }
            cout<<t;
            rep(f,exist+t.size(),s.size()){
                if(s[f]=='?')cout<<'a';
                else cout<<s[f];
            }
            cout<<endl;
            return 0;
        }
    cout<<"UNRESTORABLE"<<endl;
    return 0;
}




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


int main(){
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> p(A), q(B), r(C);
    for(auto &x: p) cin >> x;
    for(auto &x: q) cin >> x;
    for(auto &x: r) cin >> x;
    ll res=0;
    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());
    vector<int> s;
    for(int i=0; i<X; i++) s.push_back(p[i]);
    for(int i=0; i<Y; i++) s.push_back(q[i]);
    for(int i=0; i<r.size(); i++) s.push_back(r[i]);
    sort(s.begin(), s.end(), greater<int>());
    for(int i=0; i<X+Y; i++){
        res+=s[i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int a[201];
int main(){
    int m,mx,mn;
    while(cin>>m>>mn>>mx,m){
        rep(i,m) cin>>a[i];
        sort(a,a+m,greater<int>());
        int cnt=0,x=0;
        FOR(i,mn-1,mx){
            if(x<=a[i]-a[i+1]) cnt=i,x=a[i]-a[i+1];
        }
        cout<<cnt+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	string S; cin>>S;
	int l=0,r=S.size()-1;
	int ans = 0;
	while(l<r){
		if(S[l]!=S[r]){
			ans++;
		}
		l++;r--;
	}
	ote(ans);
}


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

int main(){
  int a,b;

  int an,bn;

  cin >> a;

  int ah[a+1];
  int am[a+1];

  for(int i=0;i<a;i++){
    cin >> ah[i] >> am[i];
  }
  ah[a] = 99;
  am[a] = 99;
  
  cin >> b;
  
  int bh[b+1];
  int bm[b+1];
  
  for(int j=0;j<b;j++){
    cin >> bh[j] >> bm[j];
}
  bh[b] = 99;
  bm[b] = 99;

  an =0;
  bn =0;
  while(an < a || bn < b){
    if(an + bn >0)cout <<" ";
    int ax =0;
    int bx =0;
    ax = ah[an] * 60 + am[an] ;
    bx = bh[bn] * 60 + bm[bn] ;
      if(ax == bx){
	printf("%d:%02d",bh[bn],bm[bn]);
	an++;
	bn++;
    }else if(ax < bx){
	printf("%d:%02d",ah[an],am[an]);
	an++;
    }else  if(bx < ax){
	printf("%d:%02d",bh[bn],bm[bn]);
	bn++;
    }
  }
  cout << endl;
}



Measured memory_bytes: 3224
a,b = list(map(int, input().strip().split()))
s= input().strip()
f="Yes"
if s[a]!='-':
    f="No"

for i in range(a):
    if  s[i]=="-":
        f="No"
        break

for i in range(a+1,a+b+1):
    if  s[i]=="-":
        f="No"
        break
print(f)

Measured memory_bytes: 9020
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();

		String[] sArray = s.split("");

		LinkedList<String> ansList = new LinkedList<>();

		for(int i = 0; i < s.length(); i++){
			if(sArray[i].equals("1")) {
				ansList.add("1");
			} else if(sArray[i].equals("0")) {
				ansList.add("0");
			} else if(sArray[i].equals("B") && ansList.size() != 0){
				ansList.removeLast();
			}
		}
		
		for(String ans: ansList){
			System.out.print(ans);
		}
	}
}

Measured memory_bytes: 23636
# Problem B -Qualification simulator

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

# initialization
rank_num = 0
rank_b_num = 0

# score roop
for s in S:
    if s=='a':
        if rank_num<A+B:
            print("Yes")
            rank_num += 1
        else:
            print("No")
    elif s=='c':
        print("No")
    elif s=='b':
        if rank_num<A+B and rank_b_num<B:
            print("Yes")
            rank_num += 1
            rank_b_num += 1
        else:
            print("No")


Measured memory_bytes: 56568
import itertools
import math
N=int(input())
lst=[None]*N
for i in range(N):
    lst[i]=tuple(map(int, input().split()))
total=0
for i in range(N-1):
    for j in range(i+1,N):
        total+=math.sqrt( (lst[i][0]-lst[j][0])**2 + (lst[i][1]-lst[j][1])**2 )

ave=total*2/N
print(ave)

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);
  string s;
  cin >> s;
  int b_w = 0;
  rep(i, s.size()) {
    if (i % 2 == 0 && s[i] != '0') b_w++;
    if (i % 2 == 1 && s[i] != '1') b_w++;
  }
  int w_b = 0;
  rep(i, s.size()) {
    if (i % 2 == 0 && s[i] != '1') w_b++;
    if (i % 2 == 1 && s[i] != '0') w_b++;
  }
  cout << min(b_w, w_b) << endl;
  return 0;
}


Measured memory_bytes: 512
using System;

namespace A___Move_and_Win
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var n = int.Parse (input[0]);
            var a = int.Parse (input[1]);
            var b = int.Parse (input[2]);
            if ((b - a) % 2 == 0)
                Console.WriteLine ("Alice");

            else
                Console.WriteLine ("Borys");
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <math.h>
 
typedef struct{
  double x;
  double y;
} Point;
 
void koch(int,Point,Point);
 
int main(int argc, char const *argv[]) {
 
  Point a,b; // a(0,0) b(100,0)??????
  int n;
 
  scanf("%d",&n);
 
  a.x = 0;
  a.y = 0;
  b.x =100;
  b.y = 0;
 
  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);
 
  return 0;
}
 
void koch(int n, Point a, Point b){
 
  if( n == 0 ){
    return;
  }
 
  Point s,t,u;
  double th = M_PI * 60.0 / 180.0;
 
  s.x = (2.0*a.x + 1.0*b.x) / 3.0;
  s.y = (2.0*a.y + 1.0*b.y) / 3.0;
  t.x = (1.0*a.x + 2.0*b.x) / 3.0;
  t.y = (1.0*a.y + 2.0*b.y) / 3.0;
  u.x = (t.x-s.x)*cos(th) - (t.y-s.y)*sin(th) + s.x;
  u.y = (t.x-s.x)*sin(th) + (t.y-s.y)*cos(th) + s.y;
 
  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
 
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
const ll INF = 100000000000000000;

int main(){
    int n,l;
    cin>>n>>l;
    vector<string> s(n);
    string hoge;
    rep(i,0,n-1) cin>>s[i];
    sort(s.begin(),s.end());
    rep(i,0,n-1) hoge += s[i];
    cout<<hoge<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	
	if (N == 1) cout << 0 << endl;
	else if (N & 1) cout << N / 2 << endl;
	else cout << N / 2 - 1 << endl;
	
	
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define deb(x) cout<<#x<<" = "<<x<<"\n";
#define mod 1000000007


int dp[10001][103][2];
int d;
vector<int> num;

int ans(int idx, int sum, int flag)
{
	if(idx == (int) num.size())
		return sum % d == 0;
	
	if( dp[idx][sum][flag] != -1)
		return dp[idx][sum][flag];
	
	int res = 0;
	int lim = 9;
	if(flag == 0) lim = num[idx];
	
	for(int i=0; i<=lim; i++)
	{
		int new_flag = flag;
		
		if(i < lim && flag == 0) new_flag = 1;
		
		int temp = ans(idx+1, (sum+i) % d, new_flag);
		res = (res + temp) % mod;
	}
	
	return dp[idx][sum][flag] = res;
	
}

int solve(string s)
{
	
	for(int i=0; i<s.length(); i++)
		num.push_back(s[i] - '0');
	
	memset(dp, -1, sizeof(dp));
	int res = ans(0, 0, 0);
	return res;
}

signed main()
{
	string k; cin>>k;
	cin>>d;
	
	int res = solve(k);
	cout << (res - 1 + mod) % mod <<"\n";
}



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

int main()
{
 ll a,b,c,k;
 cin>>a>>b>>c>>k;
 if (k<=a)
 {
      cout<<k;
      return 0;
 }
   k-=a;
 if (k<=b)
 {
     cout<<a;
     return 0;
 }
 k-=b;
 cout<<a-k;
    return 0;
}


Measured memory_bytes: 3592
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

def main():
  S = input()
  T = input()

  if S == T[0:len(S)] and len(T) == (len(S)+1):
    print('Yes')
  else:
    print('No')

if __name__ == '__main__':
  main()

Measured memory_bytes: 8972
import Control.Applicative ((<$>))
import Control.Monad (replicateM, unless)
import Data.List (sort, group, maximumBy)

main :: IO ()
main = do
  [n,q] <- map read <$> words <$> getLine
  unless (n == 0 && q == 0) $ do
    solve q <$> concat <$> (replicateM n (tail <$> map read <$> words <$> getLine)) >>= print
    main

solve :: Int -> [Int] -> Int
solve _ [] = 0
solve q xs = g . maximumBy f . group . sort $ xs
  where f xs ys | lx == ly = compare (head ys) (head xs)
                | otherwise = compare lx ly
          where lx = length xs
                ly = length ys
        g xs | length xs >= q = head xs
             | otherwise = 0



Measured memory_bytes: 5404
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,a,b) for(int i= (int)(a); i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define what_is(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
const int N = 1e6+7 ;
string s ;

int main(){fast ;
	int n,k ;
	cin >> n ;
	int m1 = n % 100 ;
	int m2 = n / 100 ;
	if(m1 > 0 && m1 <=12 && m2 > 0 && m2 <= 12)
		cout << "AMBIGUOUS" << endl ;
	else if((m1 == 0 || m1 > 12) && (m2 == 0 || m2 > 12))
		cout << "NA" << endl ;
	else if((m1 > 0 && m1 <=12) && !(m2 > 0 && m2 <= 12))	
		cout << "YYMM" << endl ;
	else 
		cout << "MMYY" << endl ;
	
}







Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

char s[10];

int main()
{
	scanf("%s", s);
	
	if ((s[0] == s[1]) || (s[1] == s[2]) || (s[2] == s[3]))
	{
		printf("Bad\n");
		return 0;
	}

	printf("Good\n");

	return 0;
}



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

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

    vector<int> s(200010);

    rep(i,S.size()) {
        s[i] = S.at(i) - '0';
    }


    vector<Int> n(2020,0);
    vector<Int> m(2020,0);
    int cnt;
    cnt = 0;

    rep(i,S.size()) {
        if (i % 2 == 0) {
            rep(j,2019) {
                n[((j*10)+s.at(i))%2019] = m[j];
            }
        n[s.at(i)]++;
        cnt += n[0];
        }
        else if (i % 2 == 1) {
            rep(j,2019) {
                m[((j*10)+s.at(i))%2019] = n[j];
            }
        m[s.at(i)]++;
        cnt += m[0];
        }

    }
    cout << cnt << endl;

}

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

int main() {
	int group[3][12] = {{2}, {4,6,9,11}, {1,3,5,7,8,10,12}};
	int x, y;
	cin >> x >> y;

	string ans = "No";
	for(int i = 0; i < 3; i++) {
		for (int j = 0; j < 12; j++) {
			if (group[i][j] == x) {
				for (int k = 0; k < 12; k++) {
					if (group[i][k] == y) {
						ans = "Yes";
						break;
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N,count = 1;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++)
    {
        cin >> d.at(i);
    }
    sort(d.begin(),d.end());
    reverse(d.begin(),d.end());
    for (int i = 1; i < N; i++)
    {
        int k = d.at(i-1) - d.at(i);
        if(k > 0){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)  (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define mod 1000000007
typedef long long LL;
#define int long long
typedef long double LD;
typedef vector<int> VI;
inline LL add(LL x, LL y) { x += y; if (x >= mod) x -= mod; return x; }
inline LL moduloMultiplication(LL x, LL y) {
	return (x%mod * 1LL * y%mod) %mod;
}
inline LL power(LL a, LL b) {
	LL x = 1 % mod;
	while (b) {
		if (b & 1) x = moduloMultiplication(x, a);
		a = moduloMultiplication(a, a);
		b >>= 1;
	}
	return x % mod;
}

inline LL inv(LL a) { return power(a, mod - 2) % mod; }
LL gcd(LL a, LL b)
{
	if (!a)
		return b % mod;
	return gcd(b%a, a) % mod;
}

signed main()
{
	fastio; 
	int l, r;
	cin >> l >> r;
	int ans = LLONG_MAX;
	for (int i = l; i <= r; i++) {
		for (int j = i + 1; j <= r; j++) {
			if (ans > ((i % 2019)*(j % 2019)) % 2019) {
				ans = ((i % 2019)*(j % 2019)) % 2019;
			}
			if (ans == 0)break;
		}
		if (ans == 0)break;
	}
	cout << ans%2019 << endl;
	
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import math

def main():
    na = list(map(int, input().split()))
    N, K = na[0], na[1]
    A = list(map(int, input().split()))

    i1 = A.index(1)
    r = math.ceil((N - 1) / (K - 1))

    print(r)


if __name__ == '__main__':
    main()



Measured memory_bytes: 13812
import sys
N = int(input())
if N == 1:
    print(1)
    sys.exit()
A = [int(i) for i in input().split()]
ls = [0 for i in range(10**6+1)]
s = set()
for a in A:
    if ls[a] == 0:
        cur = 1
        while a*cur <= 10**6:
            ls[a*cur] += 1
            cur += 1
        s.add(a)
    else:
        ls[a] += 1
ans = 0
for a in A:
    if ls[a] == 1:
        ans += 1
print(ans)

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




void solve(){
  int n;
  cin >> n;
  string s[n+10];
  rep(i,n){
    cin>> s[i];
  }
  ll count[5];
  rep(i,5){
    count[i]=0;
  }
  rep(i,n){
    char c=s[i][0];
    if(c=='M') count[0]++;
    if(c=='A') count[1]++;
    if(c=='R') count[2]++;
    if(c=='C') count[3]++;
    if(c=='H') count[4]++;
  }
  ll ans=0;
  for(int i=0; i<5; i++){
    for(int j=0; j<5; j++){
      for(int k=0; k<5; k++){
        if(i<j&&j<k) ans+=count[i]*count[j]*count[k];
      }
    }
  }
  cout<<ans<<endl;
  
}

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


Measured memory_bytes: 5760
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

N = 101

for i in range(N):
    a1 = i

    b1 = c11 - a1
    b2 = c12 - a1
    b3 = c13 - a1

    a2 = c21 - b1
    a3 = c31 - b1

if c22==a2+b2 and c23==a2+b3 and c32==a3+b2 and c33==a3+b3:
    print('Yes')
else:
    print('No')




Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    int count = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '1') {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b, c;
  cin >> a >> b >> c;
  if(a + b == c || b + c == a || c + a == b) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}
ll pow_l(ll a, ll b){
    ll rec = 1;
    rep(i,b){
        rec *= a;
    }
    return rec;
}
int main(){
    cout << fixed << setprecision(10);
    ll n,p;
    cin >> n >> p;
    ll ans = 1;
    for(auto u : prime_factorize(p)){
        //cout << u.first << " " << u.second << endl;
        if(u.second/n != 0)    ans *= pow_l(u.first , (u.second / n));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
	string s,t,u;
	int M=0,l=0;
	map<string,int>m;
	for(;cin>>u;){
		if(++m[u]>M)M=m[u],s=u;
		if(t.size()<u.size())t=u;
	}
	cout<<s<<' '<<t<<endl;
}

Measured memory_bytes: 1192
n = int(input())

number = list(map(int,input().split()))
count = 0
total = 0
K = True
while K:
  for i in number:
    if i%2==0:
      count+=1
    else:
      K = False
    if count ==n:
      count = 0
      total +=1
      number = [i / 2 for i in number] 

print(total)

Measured memory_bytes: 9120
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));

int main() {
	string o, e;
	cin >> o >> e;
	rep(i, o.length() + e.length()) {
		if ((i+1) % 2 == 0)cout << e[i/2];
		else cout << o[i/2];
	}
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    for (int i = 0; i < 100000; i++) {
        if ((int)floor(0.08 * i) == a && (int)floor(0.1 * i) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
} initializer;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

long long n, a, b, c;
vector<string> s = {}, ans = {};
bool good = false;

void rec(int idx, vector<string> &v, long long a, long long b, long long c) {
  if (good) return;
  if (idx == n) {
    if (a >= 0 and b >= 0 and c >= 0) {
      copy(v.begin(), v.end(), ans.begin());
      good = true;
    } else {
      return;
    }
  }
  if (a < 0 or b < 0 or c < 0) return;
  if (s[idx] == "AB") {
    v.emplace_back("A");
    rec(idx+1, v, a+1, b-1, c);
    if (good) return;
    v.pop_back();
    v.emplace_back("B");
    rec(idx+1, v, a-1, b+1, c);
    if (good) return;
    v.pop_back();
  } else if (s[idx] == "AC") {
    v.emplace_back("A");
    rec(idx+1, v, a+1, b, c-1);
    if (good) return;
    v.pop_back();
    v.emplace_back("C");
    rec(idx+1, v, a-1, b, c+1);
    if (good) return;
    v.pop_back();
  } else {
    v.emplace_back("B");
    rec(idx+1, v, a, b+1, c-1);
    if (good) return;
    v.pop_back();
    v.emplace_back("C");
    rec(idx+1, v, a, b-1, c+1);
    if (good) return;
    v.pop_back();
  }
}

int main() {
  cin>>n>>a>>b>>c;
  rep(i, n) {
    string st; cin>>st;
    s.emplace_back(st);
  }
  ans.resize(n);
  vector<string> v = {};
  rec(0, v, a, b, c);

  if (good) {
    print("Yes");
    for (auto x: ans) print(x);
  } else {
    print("No");
  }

  return 0;
}

Measured memory_bytes: 19452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define rep(i,x) for(int i=0;i<x;i++)
int n,m;
string f[205];
ll ans = 1;
bitset<205>mat[10005];
ll c[5][5];
int gauss(){
	int cur = 0;
	for(int i=0;i<205;i++){
		for(int j=cur;j<10005;j++){
			if(mat[j][i] == true){
				swap(mat[j],mat[cur]);
				goto nxt;
			}
		}
		continue;
		nxt:;
		for(int j=cur+1;j<10005;j++){
			if(mat[j][i] == true){
				mat[j]^= mat[cur];
			}
		}
		cur++;
	}
	return cur;
}
int main(){
	cin>>n>>m;
	rep(i,n)cin>>f[i];
	if(n%2 == 1){
		rep(i,m){
			if(i>m-1-i) break;
			if(f[n/2][i] != f[n/2][m-1-i]){
				ans = ans*2ll%mod;
				break;
			}
		}
	}
	if(m%2 == 1){
		rep(i,n){
			if(i>n-1-i) break;
			if(f[i][m/2] != f[n-1-i][m/2]){
				ans = ans*2ll%mod;
				break;
			}
		}
	}
	rep(i,5)rep(j,i+1){
		if(j==0||j==i)c[i][j]=1;
		else c[i][j]=c[i-1][j]+c[i-1][j-1];
	}
	int row = 0;
	rep(i,n/2)rep(j,m/2){
		map<char,int>S;
		S[f[i][j]]+=1;
		S[f[n-1-i][j]]+=1;
		S[f[i][m-1-j]]+=1;
		S[f[n-1-i][m-1-j]]+=1;
		int cur = 0; ll mul = 1;
		for(map<char,int>::iterator it=S.begin();it!=S.end();it++){
			mul = mul*c[cur+it->second][cur];
			cur += it->second;
		}
		if(mul == 24){
			ans = ans*12LL%mod;
			mat[row][i] = 1;
			mat[row][j+n/2+2] = 1;
			row++;
		}
		else{
			ans = ans*mul%mod;
		}
	}
	int free = gauss();
	rep(i,free) ans = ans*2LL%mod;
	cout << ans << endl;
}

Measured memory_bytes: 640
import java.lang.Math

fun main(args: Array<String>) {
    val (N, K) = readInputLine().split(" ").map { it.toInt() }
    val ps = readInputLine().split(" ").map { it.toInt() }

    val E = DoubleArray(1001) { it * (it + 1) / 2.0 / it.toDouble()}

    var ans = 0.0

    for (i in 0 until K) {
        ans += E[ps[i]]
    }

    var tmp = ans

    for (i in K until N) {
        tmp -= E[ps[i - K]]
        tmp += E[ps[i]]
        ans = Math.max(ans, tmp)
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 60192
#include <bits/stdc++.h>
#define INF 1000000000
#define MAX_N 100
using namespace std;
typedef pair<int, int> P;
struct edge {
	int to, cost;
	edge(int to_, int cost_) : to(to_), cost(cost_) {}
};

int n;
vector<edge> G[MAX_N];

int Prim() {
	int res = 0;
	vector<bool> used(n, false);
	priority_queue<P, vector<P>, greater<P>> que;
	que.push(P(0, 0));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (used[v]) continue;
		used[v] = true;
		res += p.first;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			que.push(P(e.cost, e.to));
		}
	}
	return res;
}

int main()
{
	cin >> n;
	for (int i = 0, c; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> c;
			if (c != -1)
				G[i].push_back(edge(j, c));
		}
	}
	cout << Prim() << endl;
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1LL<<60;

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  ll ans = INF;
  rep(i,100001){
    ll p = 2 * C * i;
    ll q = max(X - i,0) * A;
    ll r = max(Y - i,0) * B;
    ans = min(ans,p+q+r); 
  }
  cout << ans << endl;




  return 0;
}








Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(a,b,c) for(int i=a;i<b;i+=c)  
typedef pair<ll , pair<ll, ll> > pi;
int pow(int x,int y){
    int res=1;
    while(y){
        if(y&1) res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}   
struct Compare {
    constexpr bool operator()(pi const & a,
                              pi const & b) const noexcept
    { return a.first < b.first || (a.first == b.first && a.second.first > b.second.first); }
 
};
void prefix_function( string s,ll arr[] )
{
     long long border=0; arr[0]=0;
    for(long long i=1;i<s.size();i++)
    {
      while(border>0 && s[i]!=s[border])
        border=arr[border-1];
     
     if(s[i]==s[border])
         border++;
      else
       border=0;
      
      arr[i]=border;
    }
}
ll mod=998244353;
ll add( ll a , ll b)
{
    return (((a%mod)+(b%mod))%mod);
}
ll mul(ll a,ll b)
{
  return (((a%mod)*(b%mod))%mod);
}
//send mod-2 for a^-1 if mod is a prime number
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
ll dsu_arr[100000];
ll dsu_sz[100000];
void dsu(ll n)
{
    for(ll i=0;i<=n;i++)
    {
        dsu_arr[i]=i;
        dsu_sz[i]=1;
    }
}
ll find(ll x)
{
     ll root=x;
    while (root!=dsu_arr[root])
    {
        root=dsu_arr[root];
    }
    while(x!=dsu_arr[x])
    {
        dsu_arr[x]=root;
        x=dsu_arr[x];
    }
    return root;
}
ll merge(ll x,ll y)
{
    ll root1=find(x);
    ll root2=find(y);
    
    if(root1==root2)
    return 0ll;
 
    if(dsu_sz[x]>dsu_sz[y]){
    dsu_arr[root2]=root1;
    dsu_sz[x]+=dsu_sz[y];
    }
    else
    {
         dsu_sz[y]+=dsu_sz[x];
        dsu_arr[root1]=root2;
    }
    return 1ll;
}


int main()
{

string s;
cin>>s;
ll ans=0;
for(ll i=0;i<s.size();i++)
{
    ans+=(s[i]-'0');
}
if(ans%9==0)
cout<<"Yes"<<endl;
else
{
    cout<<"No"<<endl;
}

}



   
      
    
        



Measured memory_bytes: 3724
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	s := getString()
	if N%2 == 1 {
		out("No")
		return
	}
	s0 := s[:N/2]
	s1 := s[N/2:]
	if s0 == s1 {
		out("Yes")
		return
	}
	out("No")
}


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

int main(){
  int n; cin>>n;
  vector<int> x;
  for(int i=0;i<n;i++){
    int a; cin>>a;
    a=a-1-i;
    x.push_back(a);
  }
  long long ans=0;
  int med;
  sort(x.begin(),x.end());
  if(n%2!=0){
    med=x[n/2];
  }else{
    med=(x[n/2]+x[n/2-1])/2;
  }
  for(int i=0;i<n;i++){
    ans+=abs(-med+x[i]);
  }
  cout<<ans<<endl;
}

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

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

	for(int i=0;i<a.length();i++){
		for(int j=i+1;j<=a.length();j++){
			if(a[i]==a[j]){
				cout << "no" << endl;
				return 0;
			}	
		}
	}

	cout << "yes" << endl;
	return 0;
}

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

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

  std::sort(s.begin(), s.end());

  std::string judge = "Yes";
  if (s != std::string("abc")) judge = "No";

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


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

using namespace std;

int n,w,h;
int s,t;
int maxNum=0;

int cnts[501][501];
bool field[501][501];

int main(){

	while(cin>>n&&n!=0){
		maxNum=0;
		cin>>w>>h;
		memset(field,0,sizeof(field));
		memset(cnts,0,sizeof(cnts));
		for(int i = 0; i < n; i++){
			int x,y;
			cin>>x>>y;
			x--;y--;
			field[y][x]=true;
		}
		cin>>s>>t;
		for(int i = 0; i < w; i++){
			int init=0;
			for(int j = 0; j < t; j++){
				if(field[j][i])
					init++;
			}
			for(int j = 0; j < h-t+1; j++){
				cnts[j][i]=init;
				if(field[j][i])
					init--;
				if(field[j+t][i])
					init++;
			}
		}

		for(int k = 0; k+t-1 < h; k++){
			int in=0;
			for(int i = k; i < k+t; i++){
				for(int j = 0; j < s; j++){
					if(field[i][j])
						in++;
				}
			}
			for(int j = 0; j < w-s+1; j++){
				maxNum=max(in,maxNum);
				in-=cnts[k][j];
				in+=cnts[k][j+s];
			}
		}
		cout<<maxNum<<endl;
	}

	return 0;
}

Measured memory_bytes: 0