akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int N, M;
    cin >> N >> M;
    map<int,int> H;
    for(int i = 1; i <= N; i++){
        int h;
        cin >> h;
        H[i] = h;
    }
    vector<bool> good(N, true);
    for(int i = 0; i < M; i++){
        int A, B;
        cin >> A >> B;
        if(H[A] > H[B]) good[B-1] = false;
        else if(H[A] < H[B]) good[A-1] = false;
        else{
            good[A - 1] = false;
            good[B - 1] = false;
        }
    }
    int count = 0;
    for(bool a : good){
        if(a) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 8316
#include <stdio.h>

int main(void) {
	int  n,i;
	long  min,max,sum,a;
	sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%ld",&a);
		sum += a;
		if(i==0){
			max=a;
			min=a;
		}else if(a > max){
			max=a;
		}else if(a < min){
			min =a;
			
		}
	}
		printf("%ld %ld %ld\n", min, max, sum);
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  long long M;
  cin>>N>>M; 
  vector<long long> A(N,0), B(2e5+1,0), C(2e5+1,0);
  for(int i=0; i<N; i++){
    int a;
    cin>>a;
    A[i]=a;//入力
    B[a]++;//方法の累積和
    C[a]+=a;//幸福度の累積和
  }
  sort(A.begin(), A.end(), greater<long long>());  
  //B[i]は1度の握手で得られる幸福度がi以上になる方法の数。
  for(int i=1e5-1; i>=0; i--){
    B[i]+=B[i+1];
    C[i]+=C[i+1];
  }
  long long h=2e5+1, l=0;//1度の握手で上昇する幸福度の定数
  while(h-l>1){
    long long mid=(h+l)/2, p=0;//pは定数midのときの方法の数
    for(int i=0; i<N; i++){
      p+=B[max(mid-A[i], 0LL)];//a[i]はたとえば左手の幸福度。l-a[i]は右手で必要な幸福度。B[]でその場合の方法の数。
    }
    if(p>=M) l=mid;//p=Mだった場合は下限を上げる。
    else h=mid;
  }
  long long p=0;//lかmどちらが正しいか最終確認。いるかな？
  for(int i=0; i<N; i++){
    p+=B[max(h-A[i],0LL)];
  }
  if(p!=M) h--;

  //1回の握手がh点以上の組み合わせをすべて足せば答えになる。
  //WAパターン。たとえばA{100,99,5,5,3,3}で、103を1個とるまで加算する場合、左手を最大のものから全てとるようにすると103を2個とってしまう。(99,5)が1個しかとれない。
  long long ans=0;
  for(int i=0; i<N; i++){
    p=B[max(h-A[i], 0LL)];
    M-=p;
    ans+=C[max(h-A[i], 0LL)]+A[i]*p;
  }
  ans+=h*M;//オーバーする場合は境界幸福度hを足しすぎてる。
  cout << ans << endl;
}

Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll res=pow(x,y/2);
  res*=res;
  res%=mod;
  if(y%2==1) res*=x;
  return res%mod;
}
ll gyaku(ll x){
  return pow(x,mod-2);
}
vector<ll> frac,gfrac;
void set_frac(ll n){
  frac.push_back(1);
  gfrac.push_back(1);
  for(ll i=1;i<=n;i++){
    frac.push_back(frac[i-1]*i%mod);
    gfrac.push_back(gyaku(frac[i]));
  }
}
ll nCr(ll n,ll r){
  ll res=frac[n]*gfrac[r]%mod;
  res*=gfrac[n-r];
  return res%mod;
}

int main(){
  ll n;
  cin>>n;
  vector<ll> vec;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    vec.push_back(a);
  }
  n--;
  //if(n>2000) return 0;
  ll nfrac=1;
  ll ans=0;
  for(ll i=1;i<=n;i++){
    nfrac*=i;
    nfrac%=mod;
  }
  set_frac(n+5);
  ll nf=nfrac;
  ll an=0;
  for(ll i=1;i<=n;i++){
    ll kans=an;
    kans*=nf;
    kans%=mod;
    nf*=gyaku(i+1);
    nf%=mod;
    kans+=nfrac;
    ans+=kans*(vec[i]-vec[i-1])%mod;
    ans%=mod;
    an*=(i+1);
    an+=frac[i];
    an%=mod;
  }
  cout<<ans<<endl;
}


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

using namespace std;

int main(){
  int n, m, x, max_=0, ans=0;
  cin >> n >> m;
  vector<int> data(n,0), sum(n,0);
  for(int i=0; i<n; ++i) cin >> data[i];
  for(int i=0; i<m; ++i){
    cin >> x;
    for(int j=0; j<n; ++j){
      if(data[j]<=x){ ++sum[j]; break; }
    }
  }
  for(int i=0; i<n; ++i){
    if(sum[i]>max_) max_=sum[i], ans=i+1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1200
int main(){
  int length[6],i,j;
  for(i=0;i<6;i++){
     scanf("%d",&length[i]);
  }
  for(i=0;i<5;i++){
    for(j=0;j<5;j++){
      if(length[i]-length[j] > length[5]){
        printf(":(");
        return 0;
      }
    }
  }
  printf("Yay!");
  return 0;

}

Measured memory_bytes: 128
package main

import . "fmt"

func main() {
  var a,b,c,d int
  Scan(&a,&b,&c,&d)
  if abs(a-c) <= d || abs(a-b) <= d && abs(b-c) <= d {
    Println("Yes")
  } else {
    Println("No")
  }
}

func abs(n int) int {
  if n > 0 {
    return n
  } else {
    return -n
  }
}

Measured memory_bytes: 512
def main():
    *A, = map(int, input().split())

    ps = tuple(set() for _ in range(2))
    for i, x in enumerate(A):
        ps[x % 2].add(i)

    ret = 0
    for j in range(2):
        if len(ps[j]) == 2:
            for i in ps[j]:
                A[i] += 1
            ret += 1

    ma = max(A)
    ret += (ma * 3 - sum(A)) // 2

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
require "prime"
class Main
  def initialize
    fh = STDIN
    n = fh.gets.chomp.to_i
    count=0
    (1..n).each {|i|
      p = fh.gets.chomp.to_i
      if Prime.prime?(p) then
        count += 1
      end
    }
    puts count
  end
end

if $0==__FILE__ then
  Main.new()
end

Measured memory_bytes: 8864
(set! *unchecked-math* true)
(defn input []
  (vector
    (->> (clojure.string/split (read-line) #"\s")
      (map #(Integer/parseInt %)))
    (apply vector (read-line))
    (apply vector (read-line))))

(defn gcd [A B]
  (.gcd (BigInteger. (str A)) (BigInteger. (str B))))

(defn lcm [a b]
  (quot (* (bigint a) (bigint b)) (gcd a b)))

(defn first-inner [N S L]
  (zipmap (range 0 L (quot L N)) S))

(defn second-inner [M T L X]
  (let [Number (quot L M)]
    (loop [t T i 0]
      (if (empty? t)
        true
        (if-let [v (find X i)]
          (if (not= (v 1) (first t))
            false
            (recur (rest t) (unchecked-add-int i Number)))
          (recur (rest t) (unchecked-add-int i Number)))))))


(defn TwoAbbreviation [[[N M] S T]]
  (let [L (lcm N M)]
    (if (->> (first-inner N S L) (second-inner M T L))
      (str L)
      -1)))

(->> (input)
  TwoAbbreviation
  println)


Measured memory_bytes: 96580
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;scanf("%d",&n);
    vector<int> v;
    for(int i=0;i<n;i++)
    {
        int a;scanf("%d",&a);
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    for(int i=1;i<n;i++)
    {
        if(v[i]==v[i-1]){cout<<"NO"<<endl;return 0;}

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


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> vec(3);
  for(int i=0;i<3;i++){
    cin >> vec.at(i);
  }
  std::sort(vec.begin(), vec.end(), std::greater<int>() );
  cout << vec.at(0) * 10 + vec.at(1) + vec.at(2) << endl;
}

Measured memory_bytes: 256
A, B, C, D, E, F = map(int, input().split())
A = A * 100
B = B * 100
ans = [0, 0]
den = 0

def dence(a,b,c,d):
  return a*A+b*B+c*C+d*D


for a in range(F//A+1):
  for b in range(F-a*100//B+1):
    for c in range((F-a*A-b*B)//C+1):
      for d in range((F-a*A-b*B-c*C)//D+1):
        if (a*A+b*B)*E/100 >= c*C+d*D and any(i for i in [a,b,c,d]):
          
          if 100*(c*C+d*D)/(a*A+b*B+c*C+d*D) > den:
            #print(a,b,c,d)
            den = 100*(c*C+d*D)/(a*A+b*B+c*C+d*D)
            #print(den)
            ans = [a*A+b*B+c*C+d*D, c*C+d*D]
if ans[1]:
  print(ans[0], ans[1])
else:
  print(A, 0)

Measured memory_bytes: 45400
#include <iostream>
using namespace std;
int main(){
  int a[100000], i, j;
  cin >> a[0];
  for(i=0;;i++){
    if(a[i]%2==0) a[i+1]=a[i]/2;
    else a[i+1]=3*a[i]+1;
      for(j=0;j<i+1;j++){
	if(a[i+1]==a[j]){ cout << i+2;
	  return 0;
	}
      }
    }
 return 0; 
}


Measured memory_bytes: 256
#include<iostream>

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

using namespace std;
 
int main()
{
    int x;
    cin >> x;

    int ans=0;

    while(x>=500){
        ans+=1000;
        x-=500;
    }

    while(x>=5)
    {
        x-=5;
        ans+=5;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import itertools

def b():
    n = map(int, input())
    ds = list(map(int, input().split()))
    cs = list(itertools.combinations(ds, 2))

    sum_ = 0

    for c in cs:
        sum_ += c[0] * c[1]

    print(sum_)

if __name__ == '__main__':
    b()


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


using ull = unsigned long long;

struct xi {
	int v, i;
};

int main() {

	int n;
	std::cin >> n;

	std::vector<xi> tab;
	tab.resize(n);

	for (int i{}; i < n; ++i) {
		std::cin >> tab[i].v;
		tab[i].i = i;
	}

	std::sort(std::begin(tab), std::end(tab)
		, [](auto a,auto b) {
			return a.v < b.v;
		}
	);

	std::vector<int> v;
	v.resize(n);

	int m1 = tab[n / 2 - 1].v;
	int m2 = tab[n / 2].v;

	for (int i{}; i < n; ++i) {
		v[ tab[i].i ] = i;
	}
	
	auto half = n / 2;

	for (const auto&e : v) {
		std::cout << (e < half ? m2 : m1) << "\n";
	}

	return 0;
}

Measured memory_bytes: 4608
#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;
}
int main()
{
    int N;
    string X;
    cin >> N;
    vector<pair<int, string>> P(N);
    rep(i, N)
    {
        string s;
        int t;
        cin >> s;
        cin >> t;
        P[i].first = t;
        P[i].second = s;
    }
    cin >> X;
    int ans = 0;
    bool flag = false;
    rep(i, N)
    {
        if (flag)
        {
            ans += P[i].first;
        }
        if (P[i].second == X)
        {
            flag = true;
        }
        }
    cout << ans;
    return 0;
}

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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n, p;
	read(n, p);

	string s;
	read(s);

	ll ans = 0;

	if (p == 2) {
		for (int i = 0; i < n; i++) if ((s[i] - '0') % 2 == 0)
			ans += i + 1;
		die(ans);
	}

	if (p == 5) {
		for (int i = 0; i < n; i++) if ((s[i] - '0') % 5 == 0)
			ans += i + 1;
		die(ans);
	}

	reverse(all(s));

	vector<ll> freq(p);

	int acc = 0;
	int mul = 1;
	for (char c : s) {
		freq[acc]++;
		acc = (acc + (c - '0') * mul % p) % p;
		mul = mul * 10 % p;
		ans += freq[acc];
	}

	write(ans);
}


Measured memory_bytes: 3908
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	char s[11];
	scanf("%s", s);
	int len = strlen(s);
	int flag = 1;
	if (s[0] != 'A')flag = 0;
	int cnt = 0;
	FOR(i, 2, len - 1) {
		if (s[i] == 'C')cnt++;
	}
	if (cnt != 1)flag = 0;
	REPS(i, len-1) {
		if (s[i] != 'C') {
			if (!('a' <= s[i] && s[i] <= 'z')) {
				flag = 0;
				break;
			}
		}
	}
	if (flag) {
		puts("AC");
	}
	else {
		puts("WA");
	}
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <numeric>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll MOD = 1000000007;
const ll INF = 1LL << 60;
#define PI (acos(-1))

ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}
vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

const ll MAX = 510000;
// const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

string s[101];
ll solve()
{
    ll n, k;
    cin >> n >> k;
    for(int i=0; i < n; i++){
        cin >> s[i];
    }
    sort(s, s + n);
    for(int i=0; i < n; i++){
        cout << s[i];
    }
    cout << endl;

    return 0;
}

int main()
{
    //cout.precision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();
}


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

#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

typedef long long int ll;

int read_int()
{
    int a;
    scanf("%d", &a);
    return a;
}

int read_lint()
{
    ll a;
    scanf("%lld", &a);
    return a;
}

int read_float()
{
    float a;
    scanf("%f", &a);
    return a;
}

int read_double()
{
    double a;
    scanf("%lf", &a);
    return a;
}

int main()
{
    int a = read_int();
    printf("%d\n", a + a * a + a * a * a);
    return 0;
}

Measured memory_bytes: 1680
n,m,qu=map(int,input().split())
ans=[[0]*(n+1) for __ in range(n+1)]
for _ in range(m):
  l,r=map(int,input().split())
  ans[l][r]+=1
for i in range(n+1):
  for j in range(n):
    ans[i][j+1]+=ans[i][j]
for i in range(n):
  for j in range(n+1):
    ans[i+1][j]+=ans[i][j]
for qq in range(qu):
  p,q=map(int,input().split())
  print(ans[q][q]-ans[p-1][q]-ans[q][p-1]+ans[p-1][p-1])


Measured memory_bytes: 13264
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
    static long mod=998244353;
    static long power[]= new long[100005];

   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       int d=sc.nextInt();
       int t=sc.nextInt();
       int s=sc.nextInt();
       if (s*t>=d){
           System.out.println("Yes");
       }
       else System.out.println("No");
   }





        static void sort(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }
    static void sortReverse(long[] a) {
        ArrayList<Long> l=new ArrayList<>();
        for (long i:a) l.add(i);
//        Collections.sort.(l);
        Collections.sort(l,Collections.reverseOrder());
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }

    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }


}

Measured memory_bytes: 36412
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
int n,a,b,c;
string s[100100];
string ans;
int main()
{
  cin>>n>>a>>b>>c;
  ans="";
  rep(i,n)cin>>s[i];
  rep(i,n)
  {
  	if(s[i]=="AB")
  	{
  		if(a==0&&b==0)
  		{
  			cout<<"No\n";
  			return 0;
		  }
		else if(a>b||(a==b&&b==1&&s[i+1]=="BC")){
		a--,b++;
		ans+='B';}
		else {
		ans+='A';
		a++,b--;}
	  }
	  if(s[i]=="AC")
	  {
	  	if(a==0&&c==0)
  		{
  			cout<<"No\n";
  			return 0;
		  }
		else if(a>c||(a==c&&c==1&&s[i+1]=="BC")){
		a--,c++;
		ans+='C';}
		else {
		ans+='A';
		a++,c--;}
	  }
	  if(s[i]=="BC")
	  {
	  	if(b==0&&c==0)
  		{
  			cout<<"No\n";
  			return 0;
		  }
		else if(b>c||(c==b&&b==1&&s[i+1]=="AC")){
		b--,c++;
		ans+='C';}
		else {
		ans+='B';
		b++,c--;}
	  }
  }
  cout<<"Yes\n";
  rep(i,ans.size())
		cout<<ans[i]<<endl;
  return 0;
}



Measured memory_bytes: 6904
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int a,b,c,d; cin>>a>>b>>c>>d;
	//[a,b], [c,d]
	if(b<c)
	{
		cout<<0<<'\n';
	}
	else if(d<a)
	{
		cout<<0<<'\n';
	}	
	else
	{
		if(a>c)
		{
			swap(a,c);swap(b,d);
		}
		cout<<min(d,b)-c<<'\n';
	}
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        var a = Reader.NextLong;
        var b = Reader.NextLong;
        var c = Reader.NextLong;
        var k = Reader.NextLong;
        Console.WriteLine(-(a - b) * (k % 2 * 2 - 1));
    }
}


static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = 0;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }


    public static long NextLong
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            long res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

bool is753(string str){
    return str.find("7") != string::npos 
    && str.find("5") != string::npos
    && str.find("3") != string::npos;   
}

int main(){
    long long n;
    cin >> n;
    vector<long> v;
    vector<long> x;
    vector<long> w;
    v.push_back(3);
    v.push_back(5);
    v.push_back(7);
    x.push_back(3);
    x.push_back(5);
    x.push_back(7);
    while(true){
        w.clear();
        for(int i = 0; i < x.size(); i++){
            w.push_back(stol("3" + to_string(x[i])));
            w.push_back(stol("5" + to_string(x[i])));
            w.push_back(stol("7" + to_string(x[i])));
            w.push_back(stol(to_string(x[i]) + "3"));
            w.push_back(stol(to_string(x[i]) + "5"));
            w.push_back(stol(to_string(x[i]) + "7"));
        }
        sort(w.begin(), w.end());
        w.erase(unique(w.begin(), w.end()), w.end());
        bool flag = false;
        for(int i = 0; i < w.size(); i ++){
            if(w[i] <= n){
                v.push_back(w[i]);
            } else {
                flag = true;
                break;
            }
        }
        if(flag){
            break;
        }
        x.clear();
        for(int i = 0; i < w.size(); i++){
            x.push_back(w[i]);
        }
    }
    int ans = 0;
    for(int i = 0; i < v.size(); i++){
        if(is753(to_string(v[i]))){
            ans++;
        }        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;
//stoi(s) : string→int stoll(s) :string→longlong  int→string to_string(i)
const double PI = acos(-1.0);
//小数点の表し方 cout << fixed << setprecision(5);

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> p(n);
    UnionFind tree(n);
    for(int i=0;i<n;i++){
        cin >> p[i];
        p[i]--;
    }
    int ans = 0;
    for(int i = 0;i<m;i++){
        int x,y;
        cin >> x >> y;
        x--;
        y--;
        tree.unite(x,y);
    }
    for(int i=0;i<n;i++){
        if(tree.same(i,p[i])){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b,x,y,c,r,z,cnt=0;
    cin>>a>>b;
  a--;b--;
    c=b/a;
    if(b%a>0)
    {
        cout<<c+1<<endl;
    }
    else cout<<c<<endl;



	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

long long gcd(long long a, long long b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

int main()
{
    long long n, x;
    std::cin >> n >> x;

    std::vector<long long> xs(n);
    for (int i = 0; i < n; i++) {
        std::cin >> xs[i];
    }

    long long ans = abs(xs[0] - x);
    for (int i = 1; i < n; i++) {
        ans = gcd(ans, std::abs(xs[i] - x));
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 1024
S = input()

f = int(S[:2])
b = int(S[2:])

def mm(n):
    return 1 <= n <= 12

def yy(n):
    return 0 <= n <= 99

if mm(f) and mm(b) or mm(b) and mm(f):
    print("AMBIGUOUS")
elif mm(f) and yy(b):
    print("MMYY")
elif mm(b) and yy(f):
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
    int main(){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if(s.at(0) == s.at(1) && s.at(1) != s.at(2) && s.at(2) == s.at(3))
    cout << "Yes" << endl;
    else 
    cout << "No" << endl;
    return 0;
}


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int A, B;
	cin >> A >> B;

	FOR(C,1,4){
		if((A*B*C)%2 == 1){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100005
#define NIL -1

typedef struct node{
  int p; 
  int l;
  int r;
}Node;

void print(int);
void setDepth(int, int);
int setHeight(int);
int getSibling(int);

Node T[MAX];
int n = 0, D[MAX], H[MAX];

int main(){

  int i = 0;
  int v = 0, l = 0, r = 0, root = 0;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    T[i].p = NIL;
  }

  for(i = 0; i < n; i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)T[l].p = v;
    if(r != NIL)T[r].p = v;
  }

  for(i = 0; i < n; i++){
    if(T[i].p == NIL){
      root = i;
    }
  }

  setDepth(root, 0);
  setHeight(root);

  for(i = 0; i < n; i++){
    print(i);
  }
  
  return 0;
  
}

void print(int u){

  int deg = 0;
  
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("sibling = %d, ",getSibling(u));
  if(T[u].l != NIL)deg++;
  if(T[u].r != NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].p == NIL)printf("root\n");
  else if(T[u].l == NIL && T[u].r == NIL)printf("leaf\n");
  else printf("internal node\n");
  
}

void setDepth(int u, int d){

  if(u == NIL)return;
  D[u] = d;
  setDepth(T[u].l, d+1);
  setDepth(T[u].r, d+1);
  
}
int setHeight(int u){
  
  int h1 = 0, h2 = 0;

  if(T[u].l != NIL)h1 = setHeight(T[u].l) + 1;
  if(T[u].r != NIL)h2 = setHeight(T[u].r) + 1;

  return H[u] = (h1 > h2 ? h1 : h2);
  
}

int getSibling(int u){

  if(T[u].p == NIL)return NIL;
  if(T[T[u].p].l != u && T[T[u].p].l != NIL)return T[T[u].p].l;
  if(T[T[u].p].r != u && T[T[u].p].r != NIL)return T[T[u].p].r;

  return NIL;
  
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
struct SegTree{
    int n;
    vector <int> node;
    SegTree(vector <int> v){
        int sz = v.size();
        n = 1;
        while(n<sz) n*=2;
        node.resize(2*n-1, INF);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i]; //一番下側
        for(int i=n-2;i>=0;i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }
    void update(int number, int val){
        number += n-1;
        node[number]= val;
        while(number>0){
            number=(number-1)/2;
            node[number] = min(node[number*2+1], node[number*2+2]);
        }
    }
    int getmin(int a, int b, int k=0, int l = 0, int r = -1){
        if(r<0) r=n;
        if(r<=a||l>=b) return INF;
        if(a <= l&& r<=b) return node[k];
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};
//参考:http://tsutaj.hatenablog.com/entry/2017/03/29/204841
signed main(void){
    int n,x; cin>>n>>x;
    vector <int> a(n);
    int ans = 0;
    rep(i,n) {cin>>a[i]; ans += a[i];}
    SegTree seg = SegTree(a);
    for(int i=0;i<=n;i++){
        //i魔法を唱える回数
        int addmagic = x*i;
        int cnt = 0;
        rep(j,n){
            int rem = j-i;
            if(rem<0){
                int mi = seg.getmin(0, j+1);
                mi = min(mi, seg.getmin(n+rem, n));
                cnt += mi;
            }else{
                int mi = seg.getmin(j-i, j+1);
                cnt += mi;
            }
        }
        chmin(ans, addmagic + cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll a, b;
  cin >> a >> b;

  cout << (a * b / (__gcd(a, b))) << en;
  return 0;
}

Measured memory_bytes: 256
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define v vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define _fast_ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
ll n,m;
vector<ll>mm[100005];
bool visited[100005];
ll dp[100005];
void dfs(ll ind)
{
    visited[ind] = true;
  //  cout<<ind<<"\n";
    f(mm[ind].size())
    {
        if(visited[mm[ind][i]] == false)
        {
            dfs(mm[ind][i]);
            dp[ind] = max(dp[ind],1+dp[mm[ind][i]]);
        }
        else
        {
            dp[ind] = max(dp[ind],1+dp[mm[ind][i]]);
        }
        
    }
   // cout<<"dis\n";
   // cout<<dp[ind]<<"\n\n";
}
int main()
{
    _fast_
    ll t = 1;
   // cin>>t;
    while(t--){
    cin>>n>>m;
    f(n)
    {
        dp[i] = 0;
        mm[i].clear();
        visited[i] = false;
    }
    ll no1,no2;
    f(m)
    {
        cin>>no1>>no2;
        mm[no1-1].pb(no2-1);
    }
    f(n)
    {
        if(visited[i] == false)
        {
            dfs(i);
        }
    }
    ll ans = INT_MIN;
    f(n){
        ans = max(ans,dp[i]);
    }
    cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;
    vector<ll> water(0);
    REPS(i,F){
        REP(l,i+1){
            if(100*A*l + 100*B*(i-l) <= F){
                water.pb(A*l+B*(i-l));
            }
        }
    }
    sort(ALL(water));
    UNIQUE(water);
    vector<ll> sugar(0);
    REPS(i,F){
        REP(l,i+1){
            if(C*l + D*(i-l) <= F){
                sugar.pb(C*l+D*(i-l));
            }
        }
    }
    sort(ALL(sugar));
    UNIQUE(sugar);
    ll satou = -1;
    ll mizu = -1;
    ll mitsudoa = -1;
    ll mitsudob = 100;
    REP(i,water.size()){
        ll up = min(E * water[i],F - 100 * water[i]);
        ll num = upper_bound(ALL(sugar),up) - sugar.begin();
        num--;
        if(num >= 0){
            if(mitsudoa*(water[i] + sugar[num]) < 100*sugar[num]*mitsudob){
                mitsudoa = 100*sugar[num];
                mitsudob = (water[i] + sugar[num]);
                satou = sugar[num];
                mizu = sugar[num] + water[i]*100;
            }
        }else{
            if(mitsudoa*water[i] < 0){
                mitsudoa = 0;
                mitsudob = water[i];
                satou = 0;
                mizu = water[i]*100;
            }
        }
    }
    cout << mizu << " " << satou << "\n";
}

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

int main() {
  
  int count=0;
  
  char S1,S2,S3;
  char T1,T2,T3;
  
  cin >>  S1  >>  S2  >>  S3  ;
  
  cin >>  T1  >>  T2  >>  T3  ;
  
  if(S1=='S'){
    if(T1=='S'){
      count = count + 1;
    }
  }
  if(S1=='R'){
    if(T1=='R'){
      count = count + 1;
    }
  }
  if(S1=='C'){
    if(T1=='C'){
      count = count + 1;
    }
  }
  if(S2=='S'){
    if(T2=='S'){
      count = count + 1;
    }
  }
  if(S2=='R'){
    if(T2=='R'){
      count = count + 1;
    }
  }
  if(S2=='C'){
    if(T2=='C'){
      count = count + 1;
    }
  }
  if(S3=='S'){
    if(T3=='S'){
      count = count + 1;
    }
  }
  if(S3=='R'){
    if(T3=='R'){
      count = count + 1;
    }
  }
  if(S3=='C'){
    if(T3=='C'){
      count = count + 1;
    }
  }
  
  cout << count ;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>

#define MAXN 500

using namespace std;

typedef long long ll;

ll S[MAXN+1];
ll F[MAXN+1];
ll A[MAXN+1];
ll C[MAXN+1];
ll D[MAXN+1];
int N;

ll uppermultiple ( ll x, ll div )
{
  if ( x % div == 0 ) return x;
  else return div*(x/div+1);
}

ll find ( int s )
{
  A[s] = 0;
  for ( int i = s; i < N; ++i  ) {
    if ( A[i] <=  S[i] ) A[i+1] = S[i]+C[i];
    else {
      A[i+1] = uppermultiple(A[i], F[i])+C[i];
    }
  }

  return A[N];
}

int main()
{
  cin >> N;
  for ( int i = 1; i < N; ++i ){
    ll c,f,s;

    scanf("%ld%ld%ld", &C[i], &S[i], &F[i]);
  }

  for ( int i = 1; i <= N; ++i ) D[i] = find(i);
  for ( int i = 1; i <= N; ++i ) cout << D[i] << "\n";
}


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

int main(){
    string S;
    long N,min,white=0,black=0,left_black,right_white;
    cin >> N;
    cin >> S;
    min = N;
   
    for(int i=0;i<N;i++){
        if(S[i]=='.')white++;
    }

    black = N - white;

    left_black=0;
    right_white=white;

    for(int i=0;i<=N;i++){
        if(i!=0){
            if(S[i-1]=='.'){
                right_white--;
            }else{
                left_black++;
            }
        }

        if(min > right_white + left_black){
            min = right_white + left_black;
        }
    }
   
    cout << min << endl;

    return 0;
}

Measured memory_bytes: 640
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e1 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	cin >> str;
	if (str.front() == str.back()) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
import sys
S=list(raw_input())
#print S
#print len(S)

A=list('abcdefghijklmnopqrstuvwxyz')

#print A


for i in range(len(A)):
	#print "A[i]:::"+str(A[i])
	for cnt,v in enumerate(S):
		#print A[i]
		#print cnt,v
		if A[i]==v:
			if A[i]=='z':
				print 'None'
				break
			else:
				break
		if cnt==len(S)-1:
			print A[i]
			sys.exit()
			


Measured memory_bytes: 3460
#include<iostream>
 using namespace std;
 int main() {
     int a,b,c,d;
     cin>>a>>b>>c>>d;
     while(c>0 && a>0)
     {
         c=c-b;
         if(c>0)
         {
             a=a-d;
         }
     }
    if(c>0)
    {
        cout<<"No";
    }
    else
    {
        cout<<"Yes";
    }
 }


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define pb push_back
#define in(x) int x; cin>>x;
#define inn(x, y) int x, y; cin>>x>>y;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int lowerIndex(vi arr, int n, int x) 
{ 
    int l = 0, h = n - 1; 
    while (l <= h) { 
        int mid = (l + h) / 2; 
        if (arr[mid] >= x) 
            h = mid - 1; 
        else
            l = mid + 1; 
    } 
    return l; 
} 
int upperIndex(vi arr, int n, int y) 
{ 
    int l = 0, h = n - 1; 
    while (l <= h) { 
        int mid = (l + h) / 2; 
        if (arr[mid] <= y) 
            l = mid + 1; 
        else
            h = mid - 1; 
    } 
    return h; 
} 

int helper(vi v1, vi v2, vi v3){
	int s1 = v1.size();
	int s2 = v2.size();
	int s3 = v3.size();
	mi m;
	
	rep(i, 0, s2) m[v2[i]] += 1;
	
	int total;
	int req;
	int index;
	int ans = 0;
	int upper, lower;
	rep(i, 0, s1)
	{
		rep(j, 0, s3)
		{
			total = v1[i] + v3[j];
			if(total%2 == 0) req = total/2;
			else req = -1;
			if(v3[j] > v1[i])
			{
				lower = lowerIndex(v2, s2, v1[i]);
				upper = upperIndex(v2, s2, v3[j]);
			}
			else
			{
				lower = lowerIndex(v2, s2, v3[j]);
				upper = upperIndex(v2, s2, v1[i]);
			}
			ans += (upper - lower + 1);
			if(m[req] != 0) ans-=1;
		}
	}
	return ans;
}

int32_t main(void){
	IOS;
	string s;
	in(n);
	cin>>s;
	vi R, G, B;
	rep(i, 0, n)
	{
		if(s[i] == 'R') R.pb(i);
		else if(s[i] == 'G') G.pb(i);
		else B.pb(i); 
	}
	
	int s1 = R.size(), s2 = G.size(), s3 = B.size();
	if(!s1 || !s2 || !s3)
	{
		cout<<0<<endl;
		return 0;
	}
	
	int ans = helper(R, G, B) + helper(R, B, G) + helper(G, R, B);
	cout<<ans<<endl;
}

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

# 2進数で何桁まで考えればよいか求める
def digit2(n):
    s = 0
    while n > 0:
        n = n // 2
        s += 1
    return s
dK = digit2(max(K, max(A)))

K2 = list(map(int, list(bin(K))[2:]))
K2 = [0] * (dK - len(K2)) + K2

# Aの各桁の1の数
# すなわち A xor 0 のときの各桁の和 (一番下の桁がi=0)
Axor0 = [0] * dK
for a in A:
    for i in range(dK):
        a, x = divmod(a, 2)
        Axor0[i] += x
# 一番上の桁をi=0に
Axor0 = Axor0[::-1]
Axor1 = [N-x for x in Axor0]

# (自由なら)0,1どちらを選ぶのが良いか
Abest = [None] * dK
for i in range(dK):
    Abest[i] = 0 if Axor0[i] >= Axor1[i] else 1


# 上からk桁目までをX=[x0, ..., xk]にしたときのfの最大値を求める
def f(X, free):
    n = len(X)

    if free or n == len(K2):
        a = X + Abest[len(X):]
        s = 0
        for i in range(len(a)):
            s = s * 2 +(Axor0[i] if a[i] == 0 else Axor1[i])
        return s
    
    if K2[n] == 1:
        a = f(X + [0], True)
        b = f(X + [1], False)
        return max(a, b)
    else:
        a = f(X + [0], False)
        return a

ans = f([], False)
print(ans)

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

using namespace std;


typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;

#define rep(i,b) for(i=0;i<b;++i)
#define repp(i,a,b) for(i=a;i<b;++i)

int main() {
    ll n, r, ir;
    cin >>  n >> r;
    if(n < 10){
        ir = 100 * (10 - n);
    }
    else ir = 0;
    cout << (ir + r) << endl;

    return 0;
}
/*
         ,--"""",--.__,---[],-------._
       ,"   __,'            \         \--""""""==;-
     ," _,-"  "/---.___     \       ___\   ,-'',"
    /,-'      / ;. ,.--'-.__\  _,-"" ,| `,'   /
   /``""""-._/,-|:\       []\,' ```-/:;-. `. /
             `  ;:::      ||       /:,;  `-.\
                =.,'__,---||-.____',.=
                =(:\_     ||__    ):)=
               ,"::::`----||::`--':::"._
             ,':::::::::::||::::::::::::'.
    .__     ;:::.-.:::::__||___:::::.-.:::\     __,
       """-;:::( O )::::>_|| _<::::( O )::::-"""
   =======;:::::`-`:::::::||':::::::`-`:::::\=======
    ,--"";:::_____________||______________::::""----.          , ,
         ; ::`._(    |    |||     |   )_,'::::\_,,,,,,,,,,____/,'_,
       ,;    :::`--._|____[]|_____|_.-'::::::::::::::::::::::::);_
      ;/ /      :::::::::,||,:::::::::::::::::::::::::::::::::::/
     /; ``''''----------/,'/,__,,,,,____:::::::::::::::::::::,"
     ;/                :);/|_;| ,--.. . ```-.:::::::::::::_,"
    /;                :::):__,'//""\\. ,--.. \:::,:::::_,"
   ;/              :::::/ . . . . . . //""\\. \::":__,"
   ;/          :::::::,' . . . . . . . . . . .:`::\
   ';      :::::::__,'. ,--.. . .,--. . . . . .:`::`
   ';   __,..--'''-. . //""\\. .//""\\ . ,--.. :`:::`
   ;    /  \\ .//""\\ . . . . . . . . . //""\\. :`::`
   ;   /       . . . . . . . . . . . . . . . . .:`::`
   ;   (          . . . . . . . . . . . . . . . ;:::`
   ,:  ;,            . . . . . . . . . . . . . ;':::`
   ,:  ;,             . . . . . . . . . . . . .;`:::
   ,:   ;,             . . . . . . . . . . . . ;`::;`
    ,:  ;             . . . . . . . . . . . . ;':::;`
     :   ;             . . . . . . . . . . . ,':::;
      :   '.          . . . . . . . .. . . .,':::;`
       :    `.       . . . . . . . . . . . ;::::;`
        '.    `-.   . . . . . . . . . . ,-'::::;
          `:_    ``--..___________..--'':::::;'`
             `._::,.:,.:,:_ctr_:,:,.::,.:_;'`
________________`"\/"\/\/'""""`\/"\/""\/"____________________________

*/


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;



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

  ll N, K;
  cin >> N >> K;
  vector<ll> H(N);
  REP(i,N) { cin >> H[i]; }

  sort(H.begin(), H.end());

  ll ans = 0;
  if (N > K){
    REP(i,N-K){
      ans += H[i];
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

struct S {
	int t, n, m, s;
};
vector<S> rec;

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

	int N, M, r, q;
	while(cin >> N >> M, N | M) {
		cin >> r;
		rec.clear();

		for(int i = 0; i < r; i++) {
			int t, n, m, s;
			cin >> t >> n >> m >> s;
			rec.push_back(S{ t, n, m, s });
		}

		cin >> q;
		while(q--) {
			int ts, te, m;
			cin >> ts >> te >> m;
			int s = ts, c = 0;
			int sum = 0;
			for(int i = 0; i < r; i++) {
				if(rec[i].m != m) continue;
				if(rec[i].t > te) break;
				if(rec[i].s == 0) {
					c--;
					if(c == 0 && ts <= rec[i].t) {
						sum += rec[i].t - s;
					}
				}
				else {
					if(c == 0 && ts <= rec[i].t) {
						s = rec[i].t;
					}
					c++;
				}
			}
			if(c) {
				sum += te - s;
			}
			cout << sum << endl;
		}
	}
}

Measured memory_bytes: 3256