akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>

using namespace std;

int main(void)
{
    char s[15];
    scanf("%s",s);
    int len = strlen(s);
    bool flag = true;
    if(len&1) flag = false;
    else{
        for(int i=0;i<len;i+=2){
            if(s[i]=='h' && s[i+1]=='i') continue;
            else flag = false;
        }
    }
    if(flag) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
in_r, in_g, in_b, n = map(int, input().split())

ans = 0

in_list= [in_r,in_g,in_b]
sorted_list = sorted(in_list)

r = sorted_list[-1]
g = sorted_list[-2]
b = sorted_list[-3]

max_r = n // r

for i in range(max_r+1):
    tmp = n - (r * i)
    max_g = tmp // g
    for j in range(max_g+1):
        if  (tmp - (g * j))%b == 0:
            ans = ans + 1

print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        int result = 0;
        result = X - A;
        while (B <= result) {
            result = result - B;
        }
        
        System.out.println(result);
        
    }
    
}

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

int n; //入力の個数
int o_min,tmp,o_max; //入力の数
int i;

int main() {
  cin >> n; //入力の個数を記憶
  cin >> tmp;
  o_min = tmp;
  cin >> tmp;
  o_max = tmp - o_min;
  if(tmp<o_min) {
    o_min = tmp;
  }
  for(i=2;i<n;i++) { //配列に入力データを記憶
    cin >> tmp;
    if(o_max<tmp-o_min) {
      o_max = tmp - o_min;
    }
    if(tmp<o_min) {
      o_min = tmp;
    }
  }
  cout << o_max << '\n'; //素数の個数を出力
  return(0);
}


Measured memory_bytes: 3100
N,K,Q = map(int,input().split())

lst = [0] * N

for i in range(Q):
    lst[int(input())-1] += 1

x = Q - K 

for i in range(len(lst)):
    if lst[i] - x > 0 :
        print('Yes')
    else:
        print('No')


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

using namespace std;

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

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back
#define pb push_back

int main(void){
  int x, d;
  cin >> x >> d;
  d = d * 2 + 1;
  cout << x / d + (x%d==0?0:1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007
#define endl "\n"
#define ff first
#define ss second

void solve()
{
	int x, n;
	cin >> x >> n;

	if (n == 0)
	{
		cout << x;
		return;
	}

	set<int> s1;
	for (int i = -1; i <= 101; i++)
		s1.insert(i);
	int ele;
	for (int i = 0; i < n; i++)
	{
		cin >> ele;
		s1.erase(ele);
	}
	int ans = x;
	int diff = inf;
	for (auto i : s1)
	{
		if (abs(x - i) < diff)
		{
			diff = abs(x - i);
			ans = i;
		}
	}
	cout << ans;
}


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


Measured memory_bytes: 3624
use std::io;

/// 一行を読み込んで、空白で区切ったベクタにして返す
#[allow(dead_code)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect()
}

/// n行を読み込んで、数字を空白で区切って二次元のベクタにして返す
#[allow(dead_code)]
fn read_table<T>(n: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut ret: Vec<Vec<T>> = Vec::new();
    for _ in 0..n {
        ret.push(read::<T>());
    }
    ret
}

/// n行を読み込んで、1文字ずつを二次元のベクタにして返す
#[allow(dead_code)]
fn read_char_table(n: usize) -> Vec<Vec<char>> {
    let mut ret: Vec<Vec<char>> = Vec::new();
    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let chr = buf.trim().chars().collect();
        ret.push(chr);
    }
    ret
}

/// n行を読み込んで、一次元のベクタにして返す
#[allow(dead_code)]
fn read_array<T>(n: usize) -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut array = Vec::new();

    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        array.push(buf.trim().parse().unwrap());
    }
    array
}

fn main() {
    // 数値
    let x = {
        let i = read::<i32>();
        i[0]
    };

    let mut max = 1;
    for m in 2..10 {
        for n in 1..64 {
            let tmp = (n as i32).pow(m as u32);
            if tmp > x {
                break;
            }
            use std::cmp;
            max = cmp::max(tmp, max);
        }
    }
    println!("{}", max);
}


Measured memory_bytes: 4352
import itertools

def solve(n, m, a, b):
    for i, j in itertools.product(range(n - m + 1), repeat=2):
        if all(a[i + x][j + y] == b[x][y] for x, y in itertools.product(range(m), repeat=2)): return "Yes"
    return "No"


if __name__ == '__main__':
    n, m = map(int, input().split())
    a = [[token for token in input()] for _ in range(n)]
    b = [[token for token in input()] for _ in range(m)]

    ans = solve(n, m, a, b)
    print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    long K,N,M,X,max=0,cnt=0;
    string S;
    cin >> K >> S;
    M=S.size();
    if(M<=K){
        cout << S;
    }else{
        for(int i=0;i<K;i++){
            cout << S[i];
        }
        cout << "...";
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

//////////

signed main()
{
    fastio;
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
    }
    int ans[n];
    ans[0]=0;
    ans[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;++i)
    {
        ans[i]=min(ans[i-1]+abs(a[i-1]-a[i]),ans[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<ans[n-1];
}

Measured memory_bytes: 1792
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto ab = readln.split.to!(int[]);
    auto A = ab[0];
    auto B = ab[1];
    auto PS = readln.split.to!(int[]);

    int a, b, c;
    foreach (p; PS) {
        if (p <= A) {
            ++a;
        } else if (p <= B) {
            ++b;
        } else {
            ++c;
        }
    }
    writeln(min(a, b, c));
}

Measured memory_bytes: 256
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())

print(s[k-1])


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

using namespace std;

char s[50];
int cnt,n;

int main()
{
    cin>>n;
    for (int i=0;i<=n-1;i++) cin>>s[i];
    for (int i=0;i<=n-3;i++)
    {
        if ((s[i]=='A')&&(s[i+1]=='B')&&(s[i+2]=='C'))
        cnt++; //i+=2;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
// Author: Harshdeep Sharma , IIT  Indore
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
#define ll long long
const double PI = atan(1.0) * 4;
// const ll INF = (int)1e9 ;
const int di[4] = { -1, 0, 1, 0} ;
const int dj[4] = {0, -1, 0, 1} ;
const ll INF = (ll)2e18 + 50;
const int maximum  = numeric_limits<int>::max();
const int minimum  = numeric_limits<int>::min();
// const int N = 1e5 + 5 ;
const int mod = 1e9 + 7 ;
// const int N = 3e5 + 5 ;

ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a;
		a =  a * a  ;
		e /= 2 ;
	}
	return res ;
}






int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t ;
	// cin >> t ;
	t = 1 ;
	while (t--) {
		// int n;
		string s;
		cin >> s ;
		ll sum = 0 ;
		for (int i = 0 ; i < s.length() ; i++) {
			sum += (s[i] - '0') ;
		}
		if (sum % 9 == 0) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}



	}



	return 0 ;
}





Measured memory_bytes: 3740
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>

using ll = long long;
ll n, m, k, e;
std::vector<ll> av;
std::vector<ll> bv;
std::vector<ll> ans;

int main() {
    std::cin >> n >> m >> k;
    av.assign(n+1, 0);
    bv.assign(m+1, 0);
    av[0] = 0;
    bv[0] = 0;
    for (ll i = 1; i <= n; i++) {
        std::cin >> e;
        av[i] = av[i-1] + e;
    }
    for (ll i = 1; i <= m; i++) {
        std::cin >> e;
       bv[i] = bv[i-1] + e;
    }
    ll p = std::upper_bound(av.begin()+1, av.end(), k) - (av.begin()+1);
    ans.push_back(p);
    p = std::upper_bound(bv.begin()+1, bv.end(), k) - std::next(bv.begin());
    ans.push_back(p);
    for (ll i = 1; i <= n; i++) {
        ll u = av[i];
        if (u > k) {
            break;
        }
        ll x = std::upper_bound(bv.begin()+1, bv.end(), k - u) - std::next(bv.begin());
        ans.push_back(i + x);
    }
    std::cout << *std::max_element(ans.begin(), ans.end()) << std::endl;
}


Measured memory_bytes: 8416
#include<iostream>
#include<cstdio>
#include<iomanip>
#include <math.h>
using namespace std;

int main() {
    int n;
    int x[8], y[8];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }

    double result = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            result += sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
        }
    }
    cout << setprecision(20) << result / n << endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;

  int a[N];
  int b[N];
  int c[N-1];
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  for(int i=0; i<N; i++){
    cin >> b[i];
  }
  for(int i=0; i<N-1; i++){
    cin >> c[i];
  }
  int manzoku = 0;
  for(int i=0; i<N; i++){
    manzoku += b[i];
  }
  for(int i=0; i<N; i++){
    if(a[i]+1 == a[i+1]){
      manzoku += c[a[i]-1];
    }
  }
  cout << manzoku << endl;
  return 0;

}


Measured memory_bytes: 256
public class Main {

  private static void solve() {
    char[] s = ns();

    if (s[2] == s[3] && s[4] == s[5]) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	bool cond1 = (s[2] == s[3]);
	bool cond2 = (s[4] == s[5]);


	if (cond1 && cond2){
		cout <<  "Yes" << endl;
	} else {
		cout <<  "No" << endl;		
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int a, b, c; cin >> a>> b>> c;
        if (a + b + c >= 22) cout << "bust";
        else cout << "win";
return 0;
}


Measured memory_bytes: 256
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__);
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__);


#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair


int main(){

    CIN(a,b,c);
    if(a==b)COUT(c);
    else COUT(a==c?b:a);


   return 0;


}


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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
    int num=max(x,y);
    ll res=1e9;
    for(int i=0;i<=2*num;i+=2){
        ll tmp=c*i;
        if(x-i/2>0) tmp += a*(x-i/2);
        if(y-i/2>0) tmp += b*(y-i/2);
        res=min(res,tmp);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;


int main () {

    string S;
    ll K;

    cin >> S >> K;

    REP(i,S.size()) {
        if (S[i] >= '2') {
            cout << S[i] << endl;
            return 0;
        } else {
            K--;
            if (K == 0) {
                cout << S[i] << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<set>
using namespace std;

int main() {
  int n,t;
  while(scanf("%d", &n), n) {
    map<int,int> m;
    int ans = -1;
    bool end = false;
    for(int i=0; i<n; ++i) {
      scanf("%d", &t);
      if(end) continue;
      m[t]++;
      if(m[t] > (n/2)) {
          ans = t;
          end = true;
      }
    }

    if(ans == -1) puts("NO COLOR");
    else printf("%d\n", ans);
  }
}

Measured memory_bytes: 1852
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){
    set<int> st;
    rep(i, 3){
        int a; cin >> a;
        st.insert(a);
    }
    cout << st.size() << ln;
}

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

using namespace std;
using ll = long long;

bool dfs(vector<vector<pair<int, int>>> &graph, vector<int> &vpos,
         vector<bool> &seen, int idx, int dist) {
  if (seen[idx]) {
    return vpos[idx] == dist;
  }

  seen[idx] = true;
  vpos[idx] = dist;
  return all_of(graph[idx].begin(), graph[idx].end(), [&](auto &node) {
    return dfs(graph, vpos, seen, node.first, dist + node.second);
  });
};

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;

  vector<array<ll, 3>> lrd;
  vector<vector<pair<int, int>>> graph(n);
  for (int i = 0; i < m; ++i) {
    ll l, r, d;
    cin >> l >> r >> d;
    l--, r--;
    graph[l].push_back({r, d});
    graph[r].push_back({l, -d});
  }

  vector<bool> seen(n, false);
  vector<int> vpos(n, -1);
  bool ans = true;
  for (int i = 0; i < n && ans; ++i) {
    if (!seen[i]) {
      vpos[i] = 0;
      ans = dfs(graph, vpos, seen, i, 0);
    }
  }

  cout << (ans ? "Yes" : "No") << '\n';

  return 0;
}

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

int gcd(int a, int b)
{
	int r;
	if (a < b)
		r = a, a = b, b = r;

	while (r = a % b)
		a = b, b = r;

	return b;
}

int main()
{
	int n, x, xi, d, i;
	scanf("%d %d", &n, &x);

	scanf("%d", &xi);
	d = abs(xi - x);
	for (i = 1; i < n; i++) {
		scanf("%d", &xi);
		d = gcd(d, abs(xi - x));
	}

	printf("%d", d);
	return 0;
}

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

/**
 * コンソールテスト用Main クラス
 *
 */
public class Main {

	/* コンストラクタ */
	Main() {
	//何もしない
	}

	/**
	 * 提出
	 *
	 */

	public static void main(String args[]) {

		Scanner scanner= new Scanner(System.in);
		String a = " ";
		String b = "0";
		ArrayList<String> list = new ArrayList<String>();
		String caseNo = "Case";

		for (int i = 0; i < 10000; i++) {

			a = scanner.next();
			/* 0を入力したら、ループを抜ける */
			if (b.equals(a)) {
				break;
			} else {
				list.add(a);
			}
		}

		for (int j = 0; j < list.size(); j++) {
			System.out.println ("Case " + (j + 1) + ": "  + list.get(j));
		}


	}
}



Measured memory_bytes: 42484
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int m=max(max(a,b),c);
    if((a+b+c+m)%2==0){
        printf("%d\n",(3*m-a-b-c)/2);
    }else{
        printf("%d\n",(3*(m+1)-a-b-c)/2);
    }
    return 0;
}

Measured memory_bytes: 128
# 128 B

n = int(input())
s = []

for i in range(n):
    tp = list(input().split())
    s.append(tp)

for i in range(n):
    s[i][1] = int(s[i][1]) * (-1)
    s[i].append(i+1)
s.sort()

for i in range(n):
    print(s[i][2])



Measured memory_bytes: 9120
#include <vector>
#include <string>
#include <iostream>
using namespace std;
main(){int N,Q,i,x,y;string s;for(;cin>>N>>Q,N;){
	vector<pair<int,pair<int,string> > >v;
	for(i=0;i<N;i++)cin>>s>>x>>y,v.push_back(make_pair(y-x,make_pair(y,s)));
	for(i=0;i<Q;y<N?cout<<v[y].second.second<<' '<<x-v[y].first<<endl:cout<<"Unknown"<<endl,i++)for(cin>>x,y=0;y<N;y++)if(v[y].first<x&&x<=v[y].second.first)break;
}}

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

typedef long long ll;

int main () {
    ll N,T;
    cin >> N >> T;
    vector<ll> t(N+1,INT_MAX);

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

    ll sum = 0;
    for(int i=0; i<N; i++) {
	sum += min(T,t[i+1]-t[i]);
    }

    cout << sum << endl;
    
    return 0;
}


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

//AC
using namespace std;
#define rep(i, s, n) for(int i = s;i<n;i++)

int main(void) {
    string s;
    cin >> s;
    int min_val = stoi(s.substr(0, 3)) - 753;
    rep(i, 0, s.size() - 2) {
        int x = stoi(s.substr(i, 3));
        min_val = min(abs(x - 753), abs(min_val));
    }
    cout << min_val << endl;
}

Measured memory_bytes: 256
local a, b = io.read("*n", "*n")
local c, d = io.read("*n", "*n")

local function getgcd(x, y)
  while 0 < x do
    x, y = y % x, x
  end
  return y
end
local function getlcm(x, y)
  local gcd = getgcd(x, y)
  return (x // gcd) * y
end

local cd = getlcm(c, d)

local cnt = b - a + 1
cnt = cnt - (b // c - (a - 1) // c)
cnt = cnt - (b // d - (a - 1) // d)
cnt = cnt + (b // cd - (a - 1) // cd)
print(cnt)


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

int main(){

  int m;

  cin >> m;

  while(m--){
    int M, n, y;
    cin >> M >> y >> n;

    long long ans = -1;
    int judge = 0;
    double a, b, c, d;

    for(int i = 0; i < n; i++){
      long long cp = M;
      long long bb = 0;
      cin >> a >> b >> c;
      for(int j = 0; j < y; j++){
        if(a == 1){
          cp = b*cp + cp - c;
          // cout << ans << endl;
        }else {
          bb += cp*b;
          cp -=  c;
          judge = 1;
        }
      }
      // cout << cp << " "  << bb << endl;
      if(judge == 1) cp = cp + bb;
      judge = 0;
      ans = max(ans,cp);
    }
    cout << ans << endl;
  }


}

Measured memory_bytes: 1228
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

void countingsort(int [],int);

int main(){
  int A[MAX];
  int n, i, j;

  scanf("%d", &n);


  /* your code */
  for(i=0 ; i<n ; i++)
  {
    scanf("%d",&A[i]);
  }

  countingsort(A,n);

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

  return 0;
}

void countingsort(int A[],int n)
{
  int i,j,k=0;

  int C[VMAX];
  for(i=0;i<VMAX;i++){
    C[i]=0;
  }
  for(i=0;i<n;i++){
    C[A[i]]++;
  }
  for(i=0;i<VMAX;i++){
    for(j=C[i];j>0;j--){
A[k++]=i;
    }
}
}


Measured memory_bytes: 9548
from operator import itemgetter

N, M = map(int, input().split())

iPY = []
for i in range(M):
    iPY.append([i] + list(map(int, input().split())))

iPY.sort(key=itemgetter(2))

count = [0] * (N + 1)
ans = [''] * M
for ipy in iPY:
    count[ipy[1]] += 1
    ans[ipy[0]] = '{:06}{:06}'.format(ipy[1], count[ipy[1]])

print(*ans, sep='\n')

Measured memory_bytes: 34108
h, w = map(int, input().split())
field = []
hstack, wstack = set(), set()

for i in range(h):
    a = input()
    field.append(a)
    for j in range(w):
        if a[j] == '#':
            hstack.add(i)
            wstack.add(j)

hstack = sorted(list(hstack))
wstack = sorted(list(wstack))

for i in hstack:
    out = ""
    for j in wstack:
        out += field[i][j]
    print(out)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		boolean flag = false;
		if (x>=r && x<=W-r) {
			if (y>=r && y<=H-r) {
				flag = true;
			}
		}
		System.out.println(flag==true?"Yes":"No");
	}
}



Measured memory_bytes: 26288
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
struct Work{
  int reward;
  int days;
};

bool cmp(const Work &a, const Work &b) {
  if (a.days <= b.days) {
    return a.reward >= b.reward;
  }
  return a.days <= b.days;
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int> > works(m);

  int a, b;
  for (int i = 0; i < n; i++) {
    //受け取るまでの日数, 報酬
    cin >> a >> b;
    if (a > m) {
      continue;
    }
    //残り日数m-a日でできる仕事として格納していく
    works[m-a].push_back(b);
  }
  priority_queue<int> q;

  ll ans = 0;
  for (int i = m-1; i >= 0; i--) {
    for (int b : works[i] ){
      q.push(b);
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }

  cout << ans << endl;
  return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 A, B;
    cin >> A >> B;

    i64 res = (A - 1) * (B - 1);
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
    ll x;
    cin >> x;
    ll ret = 0;
    ret += (x/500)*1000;
    x = x%500;
    ret += (x/5)*5;
    cout << ret;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <cstdio>
#include <utility>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

int n,m,l,a[100][100],b[100][100];

long c;

int main() {
  
   cin>>n>>m>>l;
   
   for(int i=0; i<n; i++){
     
     for(int j=0; j<m; j++){
     
     cin>>a[i][j];
     
     }
     
    }
    
    
    for(int i=0; i<m; i++){
     
     for(int j=0; j<l; j++){
     
     cin>>b[i][j];
     
     }
     
    }
    
    for(int i=0; i<n; i++){
     
     for(int j=0; j<l; j++){
       
       c=0;
       
     for(int k=0; k<m; k++){
         
         c+=a[i][k]*b[k][j];
          
      }
      
       if(j==l-1){
         
         cout<<c<<endl;
         
       }else{
         
         cout<<c<<' ';
         
         }
     
     }
     
    }
     
    
}

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

int main(){

  int n, k;
  cin >> n >> k;
  int ans = 0;
  for (int i = 0; i < n; i++){
    int u;
    cin >> u;
    ans += min(u, k - u) * 2;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#D - Road to Millionaire
N= int(input())
A= list(map(int,input().split()))
A_s = [0]
B = 1000
C = 0
B_1 = 0
C_1 = 0
for j in range(N-1):
    A_s.append(A[j+1]-A[j])
#print(A_s)

for i in range(N-1):
    if A_s[i+1] > 0:
        B_1 = B - (B // A[i])*A[i]
        C_1 = C + B // A[i]
        B = B_1
        C = C_1
    elif A_s[i+1] <= 0:
        if C > 0:
            B_1 = B + C * A[i ]
            C = 0
            B = B_1
        else:
            pass
    else:
        pass

if C > 0:
    B = B +C*A[N-1]

print(B)

Measured memory_bytes: 9224
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)

int main() {
	int d[1001][3] = {};
	int a;
	char c;
	while ((c = getchar())!='\n') ungetc(c, stdin),fscanf(stdin, "%d,%*d%*c", &a),d[a][0] = 1, d[a][2]++;
	while (~fscanf(stdin, "%d,%*d", &a)) d[a][1] = 1,d[a][2]++;
	for (a = 1; a <= 1000; a++) if (d[a][0] && d[a][1]) fprintf(stdout, "%d %d\n", a, d[a][2]);
	return 0;
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();ite++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
typedef long long ll;
typedef pair<int,int> pii;
//---------------------
#define MAXN
//---------------------
ll n,p;
string s;

typedef pair<string,int> psi;
vector<psi> vec;

bool mysort(psi a,psi b){
	bool ret=false;
	if(a.first==b.first){
		ret=(a.second%1000)>(b.second%1000);
	
	}
	else{
		int id=0;
	
		while(a.first[id]==b.first[id]){
			id++;
			if(id>=a.first.length()){
				ret=true;
				break;
			}
			if(id>=b.first.length()){
				ret=false;
				break;
			}
		}
		ret=a.first[id]<b.first[id];
	}
	return ret;
}

int main(){
	cin>>n;
	REP(i,n) {
		cin>>s>>p;
		vec.push_back(psi(s,p+(i+1)*1000));
	}
	sort(ALL(vec),mysort);
	REP(i,n) cout<<vec[i].second/1000<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
A = sorted(map(int, input().split()))

c = Counter(A)

yes_or_no = [True for i in range(A[n-1]+1)]

for a in A:
  t = a*2
  while t <= A[n-1]:
    yes_or_no[t] = False
    t += a
ans = 0
for a in A:
  if c[a] == 1 and yes_or_no[a] == True:
    ans += 1
print(ans)

Measured memory_bytes: 42928
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while(cin >> n >> m, n | m) {
    vector<int> sum = {0};
    for(int i = 0; i < n; ++i) {
      int K;
      cin >> K;
      sum.push_back((sum.back() + (K % m)) % m);
    }
    int answer = 0;
    set<int> used = {m};
    for(auto j: sum) {
      answer = max(answer, (j - *used.upper_bound(j) + m) % m);
      used.insert(j);
      used.insert(j + m);
    }
    cout << answer << endl;
  }
}

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

int main(){
  
long long a;
  cin >> a;
  long long b;
  long long x = a; 
    long long  y = sqrt(x);
  for(int i = y;i > 0 ; i--) {//ルートa以下でみて一番大きい約数で終了
    if(a % i == 0) {
      b = i;
      break;
      
    }
  }
    long long  d = b;
    long long  e = a/d;

    cout << d + e -2 << endl;
  }
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
int cnt(0);
int N;

void dfs(int a, string s){
  int num=stoi(s);
  bool flag3(false);
  bool flag5(false);
  bool flag7(false);
  for (int i(0);i<s.size();i++){
    if (s[i]=='3') flag3=true;
    if (s[i]=='5') flag5=true;
    if (s[i]=='7') flag7=true;
  }
  if (flag3==true&&flag5==true&&flag7==true&&num<=N) {
    cnt+=1;
  }
  if (a < 9){
    dfs(a+1,s+'3');
    dfs(a+1,s+'5');
    dfs(a+1,s+'7');
  }
}


int main(){
  cin>>N;
  dfs(1,"3");
  dfs(1,"5");
  dfs(1,"7");
  cout << cnt << endl;
}


Measured memory_bytes: 256
def tmp_ans(total_cost, six_cost):
    res = 0
    tmp = n
    t = six_cost
    while t > 0:
        res += t % 6
        t //= 6
    t = total_cost - six_cost
    while t > 0:
        res += t % 9
        t //= 9
    return res

n = int(input())
ans = n
for x in range(n+1):
    ans = min(ans, tmp_ans(n, x))
print(ans)

Measured memory_bytes: 41452
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int a,b;

int main(){
	cin>>a>>b;
	if(a>=13){
		cout<<b<<endl;
	}else if(a>=6){
		cout<<b/2<<endl;
	}else{
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

int main () {
	ll n, m;
	ll i, j;
	ll ret;
	
    cin >> n >> m;
    
    if ( n <= m ) {
        cout << "unsafe" << endl;

    }
    else {
        cout << "safe" << endl;
    }
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    string s1, s2;
    cin >> s1  >> s2;
    int sol = 0;
    FOR(i, s1.length()) sol += s1[i] != s2[i];
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

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

int main() {
	int n,k;
	cin>>n>>k;
	vector<int>A(n);
	for(int i=0;i<n;i++){cin>>A[i];}
	vector<int>dp(n);
	dp[0]=0;
	for(int i=1;i<n;i++)
	{   int t=INT_MAX; 
	    for(int j=1;j<=min(i,k);j++)
	    {
	        t=min(t,dp[i-j]+abs(A[i]-A[i-j]));
	    }
	    dp[i]=t;
	}
	cout<<dp[n-1];
	return 0;
}

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

string maze[1001];
int jcnt[1010][1010];
int ocnt[1010][1010];
int icnt[1010][1010];

int main() {
	int m, n, k;
	cin >> m >> n;
	cin >> k;
	for(int i = 0; i < m; ++i){
		cin >> maze[i];
	}
	for(int i = 0; i < m; ++i){
		for(int j = 0; j < n; ++j){
			jcnt[i + 1][j + 1] = jcnt[i + 1][j] + jcnt[i][j + 1] 
								- jcnt[i][j] + (maze[i][j] == 'J' ? 1 : 0);
			ocnt[i + 1][j + 1] = ocnt[i + 1][j] + ocnt[i][j + 1] 
								- ocnt[i][j] + (maze[i][j] == 'O' ? 1 : 0);
			icnt[i + 1][j + 1] = icnt[i + 1][j] + icnt[i][j + 1] 
								- icnt[i][j] + (maze[i][j] == 'I' ? 1 : 0);
		}
	}
	int a, b, c, d;
	for(int i = 0; i < k; ++i){
		scanf("%d %d %d %d", &a, &b, &c, &d);

		printf("%d", jcnt[c][d] - jcnt[c][b - 1] - jcnt[a - 1][d] + jcnt[a - 1][b - 1]);
		printf(" %d", ocnt[c][d] - ocnt[c][b - 1] - ocnt[a - 1][d] + ocnt[a - 1][b - 1]);
		printf(" %d\n", icnt[c][d] - icnt[c][b - 1] - icnt[a - 1][d] + icnt[a - 1][b - 1]);
	}
	return 0;
}

Measured memory_bytes: 14168
/* 実行時間1s制限の場合
  10^6 1,000,000   : 余裕をもって間に合う
  10^7 10,000,000  : おそらく間に合う
  10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}          // Least Commont Multiple オーバーフローしないように先に割る

const ll INF = LONG_MAX;
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; }

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("c.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n;
    cin >> n;

    vector<int > b(n);
    rep(i, n-1) {
        cin >> b[i];
    }

    vector<int > a(n);

    a[0] = b[0];
    a[n-1] = b[n-2];

    for (int i = 1; i < n-1; i++)
    {
        a[i] = min(b[i-1], b[i]);
    }

    cout << accumulate(a.begin(), a.end(), 0);

    return 0;
}

/*
  - 1e9 : 10^9
  - vector
    vector<int> A(N);
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 256
#include<stdio.h>

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

 int main(){
          int i,n,T,q,S[10001],cnt=0,j;

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

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


Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
using u64 = uint64_t;

int main() {
	u64 N;
	u64 A, B, C;
	cin >> N >> A >> B >> C;

	vector<string> S(N);
	for(u64 i=0; i<N; i++) cin >> S[i];

	vector<char> co(N);
	vector<vector<u64>> ABC(3, vector<u64>(N));	

	for(u64 i=0; i<N; i++) {
		if(S[i] == "AC") {
			if(A == 0 && C == 0) {
				cout << "No" << endl;
				return 0;
			} else if(A > C) {
				A--; C++; co[i] = 'C';
			} else if(C > A) {
				A++; C--; co[i] = 'A';
			} else if(i < N - 1 && S[i+1] == "BC") {
				A--; C++; co[i] = 'C';
			} else {
				A++; C--; co[i] = 'A';
			}
		} else if(S[i] == "AB") {
			if(A == 0 && B == 0) {
				cout << "No" << endl;
				return 0;
			} else if(A > B) {
				A--; B++; co[i] = 'B';
			} else if(B > A) {
				A++; B--; co[i] = 'A';
			} else if(i < N - 1 && S[i+1] == "AC") {
				A++; B--; co[i] = 'A';
			} else {
				A--; B++; co[i] = 'B';
			}
		} else {
			if(B == 0 && C == 0) {
				cout << "No" << endl;
				return 0;
			} else if(B > C) {
				B--; C++; co[i] = 'C';
			} else if(C > B) {
				B++; C--; co[i] = 'B';
			} else if(i < N - 1 && S[i+1] == "AB") {
				B++; C--; co[i] = 'B';
			} else {
				B--; C++; co[i] = 'C';
			}
		}
		
		ABC[0][i] = A;
		ABC[1][i] = B;
		ABC[2][i] = C;
	}
	

	cout << "Yes" << endl;
	for(u64 i=0; i<N; i++) {
		//cout << co[i] << ":" << ABC[0][i] << " " << ABC[1][i] << " " << ABC[2][i] << endl;
		cout << co[i] << endl;
	}
	return 0;
	
}


Measured memory_bytes: 9592
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

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

int main() {
    int S, W; cin >> S >> W;
    if (S <= W) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}


Measured memory_bytes: 3624
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

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

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	s := input()
	t := input()
	sLen := len(s)
	tLen := len(t)
	dp := make([][]int, sLen+1)
	for i := 0; i <= sLen; i++ {
		dp[i] = make([]int, tLen+1)
	}

	for i := 0; i < sLen; i++ {
		for j := 0; j < tLen; j++ {
			if s[i] == t[j] {
				dp[i+1][j+1] = dp[i][j] + 1
			} else {
				dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])
			}
		}
	}

	ans := ""
	for i, j := sLen, tLen; i > 0 && j > 0; {
		if dp[i][j] == dp[i-1][j] {
			i--
		} else if dp[i][j] == dp[i][j-1] {
			j--
		} else {
			ans = string(s[i-1]) + ans
			i--
			j--
		}
	}
	fmt.Println(ans)
}


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

unordered_map<int,list<int>> l;
int dp[100001];

int lp(int src)
{
    if(dp[src]!=-1)
        return dp[src];
    bool leaf=1;
    int ans=INT_MIN;
    for(auto it:l[src])
    {
        leaf=0;
        ans=max(ans,lp(it));
    }
    if(leaf==true)
        return dp[src]=0;
    return dp[src]=ans+1;
}


int main()
{
    int n,m;
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    for(int i=0; i<m; i++)
    {
        int x,y;
        cin>>x>>y;
        l[x].push_back(y);
    }
    int ans=0;
    for(int i=1; i<=n; i++)
        ans=max(ans,lp(i));
    cout<<ans;
}

Measured memory_bytes: 14996
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
L = na()

A = sorted(L, reverse=True)[1::2]

print(sum(A))



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

int main(){
	int x;
	int change[6] = {500, 100, 50, 10, 5, 1};
	while( cin >> x, x ){
		x = 1000 - x;
		int ans = 0;
		/*while( x > 0 ){
			ans++;
			if( x >= 500 ){
				x -= 500;
			}else if( x >= 100 ){
				x -= 100;
			}else if( x >= 50 ){
				x -= 50;
			}else if( x >= 10 ){
				x -= 10;
			}else if( x >= 5 ){
				x -= 5;
			}else{
				x--;
			}
		}*/
		while( x > 0 ){
			ans++;
			for(int i=0 ; i < 6 ; i++ ){
				if( x >= change[i] ){
					x -= change[i];
					break;
				}
			}
		}
		cout << ans << endl;
	}
}

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

using namespace std;

typedef long long lint;

int n;

string s;
/*
int stkLen1;
int stkLen2;
int stk1[1000009];
int stk2[1000009];
*/

int q;

int dist;
/*
int cautBin(int val, int poz)
{
    int i = 0;
    int pas = (1 << 20);

    while(pas != 0)
    {
        if(i + pas <= stkLen1 && stk1[i + pas] - poz >= val)
            i += pas;

        pas >>= 1;
    }

   // cout << i << " " << stk1[1] - poz << " "  << val<< "\n";

    return (stkLen1 - i);
}
*/
int apm[1000009];

int stkLen;
int stk[1000009];

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


    for(int i = 0; i < n; i ++)
    {
        if(i > 0)
            apm[i] += apm[i - 1];

        apm[i] += (s[i] == 'M');
    }

    cin >> q;
    for(int j = 1; j <= q; j ++)
    {
        cin >> dist;

        lint rez = 0;
        lint cr = 0;
        int st = 1, dr = 0;
        for(int i = n - 1; i >= 0; i --)
        {
            if(s[i] == 'C')
                stk[++ dr] = i;

            if(s[i] == 'M')
            {
                cr += (dr - st + 1);
            }

            if(s[i] == 'D')
            {
                while(st <= dr && stk[st] - i >= dist)
                {
              //      cout << "SCADEM " << apm[stk[st]] - apm[i] << "\n";
                    cr -= (apm[stk[st]] - apm[i]);
                    st ++;
                }

            //    cout << "PENTRU D CURENT " << i << " AVEM " << cr << "\n";

                rez += cr;
            }
        }

        cout << rez << "\n";
    }

    return 0;
}


Measured memory_bytes: 9220
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

template<class T> inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int main() {
	int X, Y, Z;

	cin >> X >> Y >> Z;

	cout << Z << " " <<  X << " "<< Y << endl;
}


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

void writing(int ans)
{
    char c;
    if (ans < 10)
    {
        c = ans + '0';
        write(1, &c, 1);
    }
    else
    {
        writing(ans / 10);
        writing(ans % 10);
    }
}

int get_num(char *s)
{
    int num;
    int i;
    
    i = -1;
    while (s[++i] != 10)
    {
        if (s[i] != 32)
        {
            num = 0;
            while ('0' <= s[i] && s[i] <= '9')
            {
                num = num * 10 + s[i++] - '0';
                    
            }
            return (num);
        }
    }  
}

void get_nums(int *array, char *s, int count)
{
    int num;
    int i;
    
    i = -1;
    while (s[++i])
    {
        if (s[i] != 10 && s[i] != 32)
        {
            num = 0;
            while ('0' <= s[i] && s[i] <= '9')
            {
                num = num * 10 + s[i++] - '0';
                if (!s[i])
                {
                    array[count] = num;
                    return ;                    
                }
            }
            array[count++] = num;
            i--;
        }
    }  
}

void get_num_plus(int *tab, char *tmp, int pass_flag, int count)
{
    int i;
    
    i = -1;
    while (count < pass_flag)
    {
        while (tmp[++i] != 10)
            ;
        count++;
    }
    get_nums(tab, &tmp[++i], 0);
}

void get_ans(int n, char *tmp)
{
    int i;
    int j;
    int tab[n];
    int count;
    
    get_num_plus(tab, tmp, 1, 0);
    count = 0;
    j = 0;
    i = -1;
    while (++i < n)
    {
        count++;
        if (tab[j] == 2)
        {
            writing(count);
            return ;
        }
        j = tab[j] - 1;
    }
    write(1, "-1", 2);
}

char *create_array(char *s, char *new_arr, char *t, int size)
{
    int i;
    int j;
    
    i = -1;
    while (s[++i])
        new_arr[i] = s[i];
    free(s);
    j = 0;
    while (j < size)
        new_arr[i++] = t[j++];   
    new_arr[i] = 0;
    return (new_arr);
}

char *get_data(char *s)
{
    int size;
    int sum_size;
    char t[30000];
    char *new_arr;
    
    sum_size = 0;
    while ((size = read(0, t, 30000)))
    {
        if (size == -1)
            return (NULL);
        sum_size += size;
        if (!(new_arr = (char*)malloc(sum_size + 1)))
            return (NULL);
        s = create_array(s, new_arr, t, size);
    }
    return (s);
}

int main(void){
    int num;
    char *s;
    
    s = malloc(1);
    s = get_data(s);
    num = get_num(s);
    get_ans(num, s);
    free(s);
    return (0);
}


Measured memory_bytes: 1404
import java.util.*;
	
	
	
	public class Main {
	
		public static void main(String[] args) {
		
			Scanner sc = new Scanner(System.in);
			
			String S = sc.next();
			String T = sc.next();
			int  A = sc.nextInt();
			int  B = sc.nextInt();
			String U = sc.next(); 
			
			if (U.equals(S) ) {
				System.out.println((A-1)+" "+B);
				return;
			}else  {
				System.out.println(A+" "+(B-1));
				return;
			}
			
			
			
		}
		
		
	}

Measured memory_bytes: 21716