akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define    ll   long long 
 
int main()
{
   ll  n,a,b;
   cin>>n>>a>>b;
   
   ll full_times=n/(a+b);
   ll ans=full_times*a;
   ans=ans+min(a,n%(a+b));
   cout<< ans<<endl;
	
 
}

Measured memory_bytes: 3624
/*
#include<cstdio>

int main()
{
	long long a,b;
	scanf("%lld %lld",&a,&b);
	
	long long ans=1;
	while(a--) ans*=100;
	printf("%lld",ans*b);
	return 0;
}
*/
#include<cstdio>

int main()
{
	int n,a,cnt=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		while(!(a&1))
			cnt++,a>>=1;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long ans=0,i=0,o=0,m=0;
    string a;
    cin >> a;
    vector<int> s(a.size());
    for (int i=0;i<a.size();i++){
        if (a.at(i)=='A') s.at(i)=1;
        if (a.at(i)=='B') s.at(i)=2;
        if (a.at(i)=='C') s.at(i)=3;
    }
    for (int i=0;i<a.size();i++) {
        if (s.at(i)==1) {
            if (m!=1) o=0;
            o++;
            m=1;
        }
        if (s.at(i)==2) {
            if (m!=1) o=0;
            m=2;
        }
        if (s.at(i)==3){
            if (m!=2) {m=3;o=0;}
            else {ans=ans+o;m=1;}
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1412
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>

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

using namespace std;

int main(){
	int W, a, b;
	int work;
	int size;
	cin >> W >> a >> b;

	if(a < b){
		work = a;
		work += W;
		size = b - work;
	}else{
		work = b;
		work += W;
		size = a - work;
	}
	if(size <= 0) cout << 0 << endl;
	else cout << size << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int ans = 0;
  if ((A + B) > C * 2) {
    ans += (C * 2) * min(X, Y);
    int x = max(0, X - Y);
    int y = max(0, Y - X);
    X = x;
    Y = y;
  }
  if (X) {
    ans += min(A, C * 2) * X;
  }
  if (Y) {
    ans += min(B, C * 2) * Y;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int sod(int v){
  int r = 0;
  while(v) r += v % 10, v /= 10;
  return r;
}
int main(){
  int n, a, b; cin >> n >> a >> b;
  int ans = 0;
  for(int i = 1; i <= n; i++) if(a <= sod(i) && sod(i) <= b) ans += i;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import heapq

n,m = map(int,input().split())
Jobs = [list(map(int,input().split()))for i in range(n)]

Days = [[] for i in range(m)]
for i in range(n):
    if Jobs[i][0] <= m:
        Days[Jobs[i][0]-1] += [[-Jobs[i][1],Jobs[i][0]]]

Heap = []
heapq.heapify(Heap)
ans = 0
for i in range(m):
    for job in Days[i]:
        heapq.heappush(Heap,job)
    if Heap:
        ans -= heapq.heappop(Heap)[0]
        
print(ans)

Measured memory_bytes: 46212
#include <iostream>
#include <algorithm>
#include <vector>
#define int long long
signed main(){
  int N,temp,ans=0,sum,dif;
  std::cin>>N;
  std::vector<int> length_dic;
  for (int i=0;i<N;i++){
    std::cin>>temp;
    length_dic.push_back(temp);
  }
  sort(length_dic.begin(),length_dic.end());
  for (int i=0;i<N;i++){
    for (int j=i+1;j<N;j++){
      sum=length_dic[j]+length_dic[i];
      dif=length_dic[j]-length_dic[i];
      for (int k=j+1;k<N;k++){
        if(dif<length_dic[k]){
          ans+=1;
          if(length_dic[k]>=sum){
            ans-=1;
            break;
          }
        }
      }
    }
  }
  std::cout<<ans<<std::endl;
}


Measured memory_bytes: 256
use std::io;
use std::collections::VecDeque;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin
        .read_line(&mut buf)
        .expect("ERROR Can't read array size");
    let k:i64 = buf.trim().parse().unwrap();

    println!("50");
    let a:Vec<String> = (0..50).map(|i| {
        if i < k%50 {
            (k/50 + 50).to_string()
        } else {
            (k/50 + 49 - k%50).to_string()
        }
    }).collect();
    println!("{}", a.join(" "));
}


Measured memory_bytes: 4352
import copy
s = input()
ans=10000
for i in range(26):
    now = chr(97+i)
    a = copy.copy(s)
   # print(a)
    count=0
    while len(set(a))!=1:
        a_now=""
        for i in range(len(a)-1):
            if a[i] == now or a[i+1] == now:
                a_now += now
            else:
                a_now += a[i]
        #print(a_now)
        a = copy.copy(a_now)
        count+=1
    #print(count,chr(97+i))
    ans=min(ans,count)
print(ans)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define S second
#define F first
#define all(x) (x).begin(), (x).end()


using namespace std;

const bool dbg_flg = 1;
#define debug(x) if (dbg_flg) cerr << #x << ' ' << x << '\n'
#define debug_pair(x) if (dbg_flg) cerr << #x << ' ' << x.F << ' ' << x.S << '\n'
 
const int inf = 1e9 + 7;
const int MAXN = 1e6 + 5;
const ll INF = 1e18;

string s, t;
int dp[3005][3005];
pair<int, int> par[3005][3005];
vector<char> res;

int main() {
	
	//~ freopen(".in", "r", stdin);
	//~ freopen(".out", "w", stdout);
	
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);

	cin >> s >> t;
	int n = sz(s);
	int m = sz(t);
	
	s = "1" + s;
	t = "2" + t;
	
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (s[i] == t[j]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
				par[i][j] = mp(i - 1, j - 1);
			}
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
				if (dp[i - 1][j] >= dp[i][j - 1]) {
					par[i][j] = mp(i - 1, j);
				}
				else par[i][j] = mp(i, j - 1);
			}
		}
	}
	
	
	int i = n, j = m;
	
	while (i != 0 && j != 0) {
		if (par[i][j] == mp(i - 1, j - 1)) {
			res.pb(s[i]);
			i--;
			j--;
		}
		else {
			if (par[i][j] == mp(i - 1, j)) i--;
			else j--;
		}
	}	
	
	
	reverse(all(res));
	
	for (auto sym : res) {
		cout << sym;
	}
	
	return 0;
}


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

int main(int argc, char *argv[]){
  int n;
  while(cin >> n,n){
    int mat[n + 1][n + 1];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        cin >> mat[i][j];
      }
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
      int hor = 0;
      int var = 0;
      for (int j = 0; j < n; j++) {
        hor += mat[i][j];
        var += mat[j][i];
      }
      mat[i][n] = hor;
      mat[n][i] = var;
      sum += hor;
    }
    mat[n][n] = sum;
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= n; j++) {
        printf("%5d", mat[i][j]);
      }
      std::cout << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>
#include <limits.h>

#ifndef KOTAISUU
#define KOTAISUU 12
#endif
#ifndef SEDAISUU
#define SEDAISUU 17000
#endif
#ifndef KAKURITU
#define KAKURITU 30 /* * 0.01 % */
#endif

#ifndef NO_ENABLE_REVERSE
#define ENABLE_REVERSE
#endif

static unsigned int x=123456789;
static unsigned int y=362436069;
static unsigned int z=521288629;
static unsigned int w=88675123;

void seed(unsigned int a,unsigned int b,unsigned int c,unsigned int d) {
	if((a|b|c|d)==0)return;
	x=a;y=b;z=c;w=d;
}

unsigned int randint(void) {
	unsigned int t;
	t=(x^(x<<11));
	x=y;y=z;z=w;
	w=(w^(w>>19))^(t^(t>>8));
	return w;
}

unsigned int randint2(unsigned int max) {
	unsigned int amari = ((UINT_MAX % max) + 1) % max;
	unsigned int ret;
	do {
		ret = randint();
	} while (ret < amari);
	return ret % max;
}

#define KIND 26
#define MAX 365

struct horieyui {
	int mamegu[MAX];
};

int D;
int c[KIND];
int s[MAX][KIND];

int mizuhasu(const struct horieyui* kitaeri, int n) {
	int sumipe = 0;
	int i, j;
	int last[KIND] = {0};
	for (i = 0; i < n; i++) {
		sumipe += s[i][kitaeri->mamegu[i]];
		last[kitaeri->mamegu[i]] = i + 1;
		for (j = 0; j < KIND; j++) {
			sumipe -= c[j] * ((i + 1) - last[j]);
		}
	}
	return sumipe;
}

int main(void) {
	int i, j;
	struct horieyui otehon;
	struct horieyui saikyou;
	int saikyou_score = 0;
	if (scanf("%d", &D) != 1) return 1;
	for (i = 0; i < KIND; i++) {
		if (scanf("%d", &c[i]) != 1) return 1;
	}
	for (i = 0; i < D; i++) {
		for (j = 0; j < KIND; j++) {
			if (scanf("%d", &s[i][j]) != 1) return 1;
		}
	}

	for (i = 0; i < D; i++) {
		int best = 0, bj = 0;
		for (j = 0; j < KIND; j++) {
			int score;
			saikyou.mamegu[i] = j;
			score = mizuhasu(&saikyou, i + 1);
			if (best < score || j == 0) { best = score; bj = j; }
		}
		saikyou.mamegu[i] = bj;
	}
	otehon = saikyou;

	for (i = 0; i < SEDAISUU; i++) {
		struct horieyui saituyo;
		int saituyo_score = 0;
		for (j = 0; j < KOTAISUU; j++) {
			struct horieyui kore = otehon;
			int k;
			int score;
			for(k = 0; k < D; k++) {
				if (randint2(10000) < KAKURITU) {
					kore.mamegu[k] = randint2(KIND - 1);
					if (kore.mamegu[k] >= otehon.mamegu[k]) kore.mamegu[k]++;
				}
			}
			score = mizuhasu(&kore, D);
			if (j == 0 || score > saituyo_score) {
				saituyo = kore;
				saituyo_score = score;
			}
		}
#ifdef NO_FORCE_UPDATE
		if (saituyo_score > saikyou_score)
#endif
		otehon = saituyo;
		if (saituyo_score > saikyou_score) {
#ifdef PRINT_UPDATE
			fprintf(stderr, "update at generation %d : %d -> %d\n", i + 1, saikyou_score, saituyo_score);
#endif
			saikyou = saituyo;
			saikyou_score = saituyo_score;
		}
	}
	for (i = 0; i < D; i++) {
		printf("%d\n", saikyou.mamegu[i] + 1);
	}
#ifdef PRINT_SCORE
	printf("score = %d\n", saikyou_score < -1000000 ? 0 : 1000000 + saikyou_score);
#endif
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

bool d[1000001];

int main(int argc, char **argv) {
	ll s;
	cin >> s;
	CLEAR(d);
	REP(i, 1000001) {
		d[s] = true;
		s = (s%2 == 0 ? s/2 : 3*s+1);
		if (d[s]) {
			cout << (i+2) << endl;
			return 0;
		}
	}
	return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main()
{
	int n, l;
	cin >> n >> l;
	
	vi a(n);

	int sum = 0;

	int min_ = inf;

	rep(i, n)
	{
		a[i] = l + i;
		sum += a[i];
		
		if (abs(min_) > abs(a[i])) min_ = a[i];
	}
	cout << sum - min_ << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <iomanip>
#include <vector>
using namespace std;
#define ll long long
#define fill(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(ll i=0;i<n;++i)
#define Sort(a) sort(a.begin(),a.end())
int main(){
    char n[8][8];
    rep(i,8){
        rep(j,8){
            cin>>n[i][j];
        }
    }
    cout<<90<<endl;
    rep(i,8){
        for(int j=7;j>=0;j--){
                cout<<n[j][i];
        }
        cout<<endl;
    }
    cout<<180<<endl;
    for(int i=7;i>=0;i--){
        for(int j=7;j>=0;j--)
        {cout<<n[i][j];}
        cout<<endl;
    }
    cout<<270<<endl;
    for(int i=7;i>=0;i--){
        rep(j,8){cout<<n[j][i];}
        cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 3100
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
	static final int MAX = 2_147_483_646; // intMax 
	static final int INF = 1_000_000_000; // 10^9  
	public static void main(String[] args) throws Exception{
		hayami saori = new hayami();
		int x = saori.saori_hayami();
		int n = saori.saori_hayami();
		if(n == 0){
			System.out.println(x);
			return;
		}
		HashSet<Integer> p = new HashSet<>();
		for(int i = 0;i < n;i++){
			p.add(saori.saori_hayami());
		}
		int ans = MAX;
		for(int i = 0;i <= 101;i++){
			if(p.contains(i)){
				continue;
			}
			if(Math.abs(i-x) < Math.abs(ans - x)){
				ans = i;
			}
		}
		System.out.println(ans);
		saori.close();
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}


Measured memory_bytes: 32440
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

main = do
  [n] <- readInt
  print $ length $ takeWhile (\x -> x < n) $ scanl (+) 0 [1 .. n]


Measured memory_bytes: 380
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>

using namespace std; 
int n, m;
const int maxn = 4e5 + 5;

int a[maxn];
typedef long long LL;
LL c[2][maxn];

void add(int id, int x, int d){
    for(int i = x;i < maxn;i += i & -i){
        c[id][i] += d;
    }
}

LL sum(int id, int x){
    LL res = 0;
    for(int i = x;i > 0;i -= i & -i){
        res += c[id][i];
    }
    return res;
}

void add1(int id, int l, int r, int v){
    add(id, l, v);
    add(id, r + 1, -v);
}

LL query(int x){
    return sum(0, x) * x + sum(1, x);
}

int main(){
    //freopen("in/mx1.txt", "r", stdin);
    cin >> n >> m;
    for(int i = 1;i <= n;i++){
        scanf("%d", &a[i]);
    }
    for(int i = 1;i < n;i++){
        if(a[i + 1] > a[i]){
            add1(1, 1, m, a[i + 1] - a[i]);
            add1(1, a[i] + 1, a[i + 1], a[i] + 1);
            add1(0, a[i] + 1, a[i + 1], -1);
        }else{
            add1(1, 1, m, a[i + 1] + m - a[i]);
            add1(1, a[i] + 1, m, a[i] + 1);
            add1(1, 1, a[i + 1], a[i] + 1 - m);
            add1(0, a[i] + 1, m, -1);
            add1(0, 1, a[i + 1], -1);
        }
    }
    for(int i = 1;i <= 2 * m;i++){
        //cout << i << " " << sum(0, i) << " " << sum(1, i) << endl;
    }
    LL ans = query(1);
    for(int i = 2;i <= m;i++){
        //cout << ans << endl;
        ans = min(ans, query(i));
    }
    cout << ans << endl;
    return 0;
}


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

ans = 0
for i in range(N):
    a, b = A[i], B[i]
    aa = A[i+1]
    if a <= b:
        ans += a
        if aa <= b-a:
            ans += aa
            A[i+1] = 0
        else:
            ans += b-a
            A[i+1] -= b-a

    else:
        ans += b
print(ans)

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	string s; cin >> s;
	VI c(26, 0);
	for (auto it : s) {
		c[it - 'a'] = 1;
	}
	FOR(i, 0, 26) {
		if (!c[i]) {
			cout << string(1,'a' + i) << endl;
			return 0;
		}
	}
	cout<<"None"<<endl;

	return 0;
}


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

int main() {
  string S;
  cin >> S;
  int N;
  string answer;
  if(S.size() % 2 == 1) {
    N = S.size() / 2 + 1;
  }
  else {
    N = S.size() / 2;
  }
  
  for(int i = 0;i < N;i++) {
    answer += S.at(2 * i);
  }
  cout << answer << endl;
}

Measured memory_bytes: 512
<?php

$N = trim(fgets(STDIN));
$d = trim(fgets(STDIN));

$array = explode(' ', $d);

$sum = [];
for ($i = 0; $i < $N; $i++) {
    for ($j = $i+1; $j < $N; $j++) {
       
        $sum[] = $array[$i] * $array[$j];
    }
}
echo array_sum($sum);


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

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

	int sz = S.size();
	stack<char> st;
	for( int i = 0; i < sz; i++ ) {
		if( S[i] == 'S' ) st.push( S[i] );
		else {
			if( st.empty() || st.top() == 'T' ) st.push( S[i] );
			else if( st.top() == 'S' ) st.pop();
		}
	}
	int ans = st.size();

	cout << ans << endl;
}


Measured memory_bytes: 644
#include <iostream>
#include<string>
#include<list>
#include<algorithm>
#include<cstdio>
using namespace std;


int main(){
    
    int n,t;
    scanf("%d",&n);
    list<int> V;
    char com[20];
    for(int i=0;i<n;i++){
        
        scanf("%s",com);
        
        if(com[0]=='i'){
            scanf("%d",&t);
            V.push_front(t);
            
        }else if(com[6]=='F'){
                V.pop_front();
                //deleteLast
        }else if(com[6]=='L'){
                V.pop_back();
        }else if(com[0]=='d'){
                scanf("%d",&t);
                for(list<int>::iterator it = V.begin();it!=V.end();it++){
                    if(*it==t){
                        V.erase(it);
                        break;
                    }
                }
            }
    }
    int i=0;

    for(list<int>::iterator it = V.begin();it != V.end();it++){
       if(i++) printf(" ");
        printf("%d",*it);
        }
        
    
    printf("\n");




return 0;
}



Measured memory_bytes: 34452
A = int(input())  # 500 yen
B = int(input())  # 100 yen
C = int(input())  # 50 yen
X = int(input())

# Aが最大で何枚使用できるかを考える
max_A = int(X/500)
max_A = min(A, max_A)

# カウント
count = 0

# ループ
for num_A in range(max_A + 1):
    # print("No. A: {}".format(num_A))
    left_BC = X
    left_BC -= num_A * 500

    max_B = int(left_BC / 100)
    max_B = min(B, max_B)

    for num_B in range(max_B + 1):
        # print("No. B: {}".format(num_B))
        left_C = left_BC
        left_C -= num_B * 100

        if left_C % 50 == 0:
            if C >= int(left_C/50):
                count += 1

        # print("=====")

print(count)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int euler_phi(int n) {
  int res = n;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      res = res / i * (i - 1);
      for (; n % i == 0; n /= i)
        ;
    }
  }
  if (n != 1) {
    res = res / n * (n - 1);
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  cout << euler_phi(n) << endl;
  return 0;
}



Measured memory_bytes: 3080
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10000000)

from bisect import bisect_left,bisect_right
n=int(input())
a=list(map(int,input().split()))
edge=[[]for i in range(n)]
for i in range(n-1):
  u,v=map(int,input().split())
  edge[u-1].append(v-1)
  edge[v-1].append(u-1)
ans=[-1]*n
dp=[10**18]*n

#オイラーツアー
#n=頂点数、s=始点、edge=隣接リスト
def EulerTour(n,s,e):
  EulerTour_list=[]
  def EulerTour_dfs(i,root):
    EulerTour_list.append(i)
    idx=bisect_left(dp,a[i])
    bef=dp[idx]
    dp[idx]=a[i]
    ans[i]=bisect_left(dp,10**18)
    for j in e[i]:
      if j!=root:
        EulerTour_dfs(j,i)
    if root!=-1:
      EulerTour_list.append(root)
      dp[idx]=bef
  EulerTour_dfs(s,-1)
  return EulerTour_list

EulerTour(n,0,edge)
print(*ans,sep="\n")


Measured memory_bytes: 276048
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
using namespace std;
int gcd(int x,int y){
    return y?gcd(y,x%y):x;
}

signed main(){
    int n,m;
    cin>>n>>m;
    vector<pi> v(m);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        v[i]=mp(a,b);
    }
    sort(all(v));
    set<pi> set;
    set.insert(v[0]);
    pi t=v[0];
    Rep(i,1,m){
        if(t.first<=v[i].first&&v[i].second<=t.second){
            t=v[i];
        }
        if(t.second<=v[i].first){
            t=v[i];
            set.insert(v[i]);
        }
    }
    cout<<set.size()<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	vector<string>ans;
	REP(i, N) {
		string S;
		cin >> S;
		SORT(S);
		//cout << S << endl;
		ans.push_back(S);
	}

	SORT(ans);
	REP(i, ans.size()) {
		//cout << ans[i] << endl;
	}
	int cnt = 0;
	int out = 0;
	REP(i, N - 1) {
		if (ans[i] == ans[i + 1])cnt++;
		if (ans[i] != ans[i + 1]) {
			//cnt++;
			out += cnt * (cnt + 1) / 2;
			//cout << cnt << endl;
			cnt = 0;
		}
	}

	out += cnt * (cnt + 1) / 2;
	//cout << cnt << endl;
	cout << out << endl;

	return 0;
}



Measured memory_bytes: 7920
#include <stdio.h>

int main (void) {

    long long a;
    double b;

    scanf("%lld", &a);
    scanf("%lf", &b);

    int integerB = (int) ((b+0.005) * (double)100);

    long long result = a * integerB;

    printf("%lld\n", result / 100);

    return 0;
}

Measured memory_bytes: 1748
from sys import stdin
import itertools
from math import gcd
# def gcd(a,b):
#     x=max(a,b)
#     y=min(a,b)
#     if x%y==0:return y
#     else:
#         while(x%y!=0):
#             z=x%y
#             x=y
#             y=z
#         return z

# K = list(map(int, (stdin.readline().strip().split())))[0]
# i=[x for x in range(1,K+1)]
# j=[x for x in range(1,K+1)]
# k=[x for x in range(1,K+1)]
# num_list=set(map(tuple,(sorted(x) for x in (itertools.product(i,j,k)))))
#
# ans=0
# for i,j,k in num_list:
#     if i==j:
#         if j==k:
#             ans+=K
#         else:
#             ans+=gcd(i,gcd(j,k))*3
#     elif j==k:ans+=gcd(i,gcd(j,k))*3
#     else:ans+=gcd(i,gcd(j,k))*6
K = int(input())

ans = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        k = gcd(i, j)
        for l in range(1, K + 1):
            a = gcd(k, l)
            ans += a
print(ans)

Measured memory_bytes: 9056
#include <bits/stdc++.h>
#define P pair<int, int>

using namespace std;

int main(){
  int n, m;
  cin >>n >> m;
  P p[100009];
  for(int i=0;i<m;i++){
    int a, b;
    cin >> a >> b;
    p[i] = P(a, b);
  }
  sort(p, p+m);
  int cnt=1, r=p[0].second;
  for(int i=1;i<m;i++){
    if(p[i].first>=r){
      cnt++;
      r=p[i].second;
    }
    r=min(r, p[i].second);
  }
  cout << cnt << endl;
}



Measured memory_bytes: 1024
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
# import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)
def IF(c, t, f): return t if c else f

class UnionFind:
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False

    def same(self, x, y):
        return self.find(x) == self.find(y)


def main():
    n,q = LI()
    tuv = [LI() for _ in range(q)]

    uf = UnionFind(n)
    r = []
    for t,u,v in tuv:
        if t == 1:
            r.append(IF(uf.same(u,v), 1, 0))
        else:
            uf.union(u,v)

    return JA(r, "\n")


print(main())




Measured memory_bytes: 54844
#include <iostream>
#include <vector>
#include <string>

int main()
{
	int H, W;
	std::cin >> H >> W;
	std::vector<std::string> ss(H);
	for (int i = 0; i < H; ++i) {
		std::cin >> ss[i];
	}

	std::vector<std::vector<int> > mat(H, std::vector<int>(W, 0));
	for (int iRow = 0; iRow < H; ++iRow) {
		for (int jCol = 0; jCol < W; ++jCol) {
			int cnt = 0;
			if (ss[iRow][jCol] == '#') ++cnt;
			if ((iRow > 0)     && (ss[iRow - 1][jCol] == '#')) ++cnt;
			if ((iRow < H - 1) && (ss[iRow + 1][jCol] == '#')) ++cnt;
			mat[iRow][jCol] = cnt;
		}
	}

	for (int iRow = 0; iRow < H; ++iRow) {
		for (int jCol = 0; jCol < W; ++jCol) {
			int cnt = 0;
			if (ss[iRow][jCol] != '.') continue;
			cnt += mat[iRow][jCol];
			if (jCol > 0    ) cnt += mat[iRow][jCol - 1];
			if (jCol < W - 1) cnt += mat[iRow][jCol + 1];
			ss[iRow][jCol] = '0' + cnt;
		}
	}

	for (int i = 0; i < H; ++i) {
		std::cout << ss[i] << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(void){
    int n, k;
    long long int s=0;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n-k;i++){
        s+=a[i];
    }
    cout<<( s );
}


Measured memory_bytes: 1024
#include <iostream>
#include <list>
#include <algorithm>
#include <climits>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n,m,a,b,c,mi,ret;
	int info[100][100];

	while(cin >> n >> m && n){
		ret = 0;
		rep(i,100)rep(j,100)info[i][j] = INT_MAX;

		rep(i,m){
			cin >> a >> b >> c;
			info[a][b] = info[b][a] = c;
		}

		list<int> X,Y;
		X.push_back(0);
		for(int i=1;i<n;i++){
			Y.push_back(i);
		}

		while(!Y.empty()){
			mi = INT_MAX;
			for(list<int>::iterator it = X.begin(); it != X.end(); ++it){
				rep(i,n){
					if( count(Y.begin(),Y.end(),i) ){
						if(info[*it][i]<mi){
							a = i;
							mi = info[*it][i];
						}
					}
				}
			}
			X.push_back(a);
			for(list<int>::iterator it = Y.begin(); it != Y.end(); ++it){
				if((*it)==a){
					Y.erase(it);
					break;
				}
			}
			ret+=mi;
		}
		cout << ret << endl;
	}
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long

const unsigned int BIT_FLAG_0 = (1 << 0);  // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1);  // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2);  // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3);  // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4);  // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5);  // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6);  // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7);  // 0000 0000 1000 0000

const double PI = 3.14159265358979323846;

const int dy[4] = {0, 1, 0, -1};
const int dx[4] = {1, 0, -1, 0};

#define H_MAX 500
#define W_MAX 500
#define INF 1e9 + 7
const ll mod = 1000000007;

int main() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <queue>
#include <map>
#include <stack>
using namespace std;
 
int dx[8]={1,-1,0,0,1,1,-1,-1};
int dy[8]={0,0,1,-1,-1,1,-1,1};
 
 
int main() {
int tate,yoko;
while(cin>>yoko>>tate && yoko){
int t[35][35]={0},y[35][35]={0};
for(int i=0;i<2*tate-1;i++){
if(i%2==0){
for(int j=0;j<yoko-1;j++) cin>>y[i/2][j];
}
else{
for(int j=0;j<yoko;j++) cin>>t[i/2][j];
}
}
int su[35][35]={0};
queue<pair<pair<int,int>,int > > qu;
qu.push(make_pair(make_pair(0,0),0));
su[0][0]=1;
int ans;
while(1){
if(qu.size()==0){
ans=-1;
break;
}
pair<pair<int,int>,int > dd=qu.front();
qu.pop();
int t1=dd.first.first,y1=dd.first.second;
if(dd.first.first==tate-1 && dd.first.second==yoko-1){
ans=dd.second;
break;
}
for(int i=0;i<4;i++){
if(0>t1+dx[i] || t1+dx[i]>=tate || 0>y1+dy[i] || y1+dy[i]>=yoko) continue;
if((i==0 && su[t1+dx[i]][y1+dy[i]]==0 && t[t1][y1]==0) ||(i==1 && su[t1+dx[i]][y1+dy[i]]==0 && t[t1+dx[i]][y1+dy[i]]==0)||(i==2 && su[t1+dx[i]][y1+dy[i]]==0 && y[t1][y1]==0) || (i==3 && su[t1+dx[i]][y1+dy[i]]==0 && y[t1+dx[i]][y1+dy[i]]==0) ){
qu.push(make_pair(make_pair(t1+dx[i],y1+dy[i]),dd.second+1));
su[t1+dx[i]][y1+dy[i]]=1;
//cout<<t1+dx[i]<<" "<<y1+dy[i]<<" "<<dd.second+2<<endl;
}

}



}

cout<<ans+1<<endl;
}


	return 0;
 
}

Measured memory_bytes: 3028
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		int n = Integer.parseInt(reader.readLine());
		String[] s = reader.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(s[i]);
		}
		int sum = 0;
		for (int i = 0; i < n - 1; i++) {
			for (int j = n - 1; j >= i + 1; j--) {
				if (a[j] < a[j - 1]) {
					sum++;
					int temp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = temp;
				}
			}
		}
		StringBuilder builder = new StringBuilder();
		for (int k = 0; k < n; k++) {
			if (k > 0)
				builder.append(" ");
			builder.append(a[k]);
		}
		builder.append("\n").append(sum);
		System.out.println(builder);

	}
}

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

int main()
{
    int N;
    cin >> N;
    vector<vector<pair<int, int>>> graph(N);

    for (int i = 0; i < N-1; i++)
    {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        graph[u].push_back(make_pair(v, w));
        graph[v].push_back(make_pair(u, w));
    }
    vector<int> colors(N);
    for (int i = 0; i < N; i++)
        colors[i] = -1;

    queue<int> nqueue;
    colors[0] = 0;
    nqueue.push(0);
    while (!nqueue.empty())
    {
        int node = nqueue.front();
        int color = colors[node];
        // cout << "node " << node << endl;
        nqueue.pop();
        for (auto p: graph[node])
        {
            // cout << "hey" << node << ' ' << p.first << ' ' << p.second <<  endl;
            if (colors[p.first] != -1)
                continue;
            if (p.second % 2 == 0)
                colors[p.first] = color;
            else
                colors[p.first] = (color + 1) % 2;
            // cout << colors[p.first] << endl;
            nqueue.push(p.first);
            // cout << nqueue.size() << 'a' << endl;
        }
    }

    for (int i = 0; i < N; i++)
        cout << colors[i] << endl;
   	return 0;
}

Measured memory_bytes: 6784
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
 
using namespace std;
 

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 
ll binomialCoeff(ll n, ll k) 
{ 
	ll C[n + 1][k + 1]; 
	ll i, j; 


	for (i = 0; i <= n; i++) 
	{ 
		for (j = 0; j <= min(i, k); j++) 
		{ 
			
			if (j == 0 || j == i) 
				C[i][j] = 1; 

			else
				C[i][j] = (C[i - 1][j - 1] + 
										C[i - 1][j])%MOD; 
		} 
	} 

	return C[n][k]; 
}
bool compare(const string &a , const string&b){
	
}
 
void solve()
{
	string  s ; 
	cin>>s ;
	int num1 = (s[0]-'0')*10 + (s[1]-'0') ;
	int num2 = (s[2] - '0') *10 + (s[3] - '0') ;
	if((num1>=1 && num1<=12) && (num2<=12 && num2>=1)){
		cout<<"AMBIGUOUS";
	}
	else if(num1<=12 && num1>=1){
		cout<<"MMYY";
	}
	else if(num2<=12 && num2>=1){
		cout<<"YYMM";
	}
	else{
		cout<<"NA";
	}
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3768
N,A,B=map(int,input().split())
S=input()
cnt_a=0
cnt_b=0
for i in range(N):
    if cnt_a<A+B:
        if S[i]=='a':
            cnt_a+=1
            print('Yes')
        elif S[i]== 'b' and cnt_b<B:
            cnt_b+=1
            cnt_a+=1
            print('Yes')
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 9268
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		a: usize,
		b: usize,
		c: usize,
		d: usize,
		e: usize,
		f: usize,
	}

	// x = 100ai+100bj、かつ x < f であるような整数xをすべて求める
	// iの最大値はf/100a、jの最大値はf/100b
	let mut x = vec![];
	for i in 0..=f/(100*a) {
		for j in 0..=f/(100*b) {
			let tmp = 100*a*i + 100*b*j;
			if tmp <= f {
				x.push(tmp);
			}
		}
	}
	x.sort();
	x.dedup();
	//println!("{:?}", x);

	// y = ci+dj、かつ y < f であるような整数yをすべて求める
	// iの最大値はf/c、jの最大値はf/d
	let mut y = vec![];
	for i in 0..=f/c {
		for j in 0..=f/d {
			let tmp = c*i + d*j;
			if tmp <= f {
				y.push(tmp);
			}
		}
	}
	y.sort();
	y.dedup();
	//println!("{:?}", y);

	let z:f64 = 100.0*e as f64 / (100+e) as f64;
	let mut max:f64 = 0.0;
	//let mut ans = (0, 0);
	let mut ans = (100*a, 0);
	for i in 0..x.len() {
		for j in 0..y.len() {
			if x[i] + y[j] > f  {
				continue;
			}
			let tz:f64 = 100.0 * y[j] as f64 / (x[i]+y[j]) as f64;
			if z < tz {
				continue;
			}
			if tz > max {
				max = tz;
				ans = (x[i]+y[j], y[j]);
				//println!("x={}, y={}", x[i], y[j]);
			}
		}
	}
	println!("{} {}", ans.0, ans.1);

}



Measured memory_bytes: 4728
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,R;
    cin >> N >> R;
    while(N){
        vector<int> V(N);
        iota(V.rbegin(), V.rend(), 1);
        //for(auto i:V)cout << i << endl;
        rep(i,0,R){
            int p,c;
            cin >> p >> c;
            p--;
            vector<int> tmp(p + c);
            rep(j,0,c){
                tmp[j] = V[j + p];
            }
            rep(j,c,p+c){
                tmp[j] = V[j-c];
            }
            rep(j,0,p+c){
                V[j] = tmp[j];
            }
        }
        cout << V[0] << endl;
        cin >> N >> R;
    }
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
using namespace std;
int num[105];

int main()
{
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n; i ++) {
        scanf("%d",&num[i]);
        sum += num[i];
    }
    int a1 = sum / n,a2 = a1 + 1;
    int r1 = 0,r2 = 0;
    for (int i = 0; i < n; i ++) {
        r1 += (num[i] - a1) * (num[i] - a1);
        r2 += (num[i] - a2) * (num[i] - a2);
    }
    cout << min(r1,r2) << endl;
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
import heapq
from collections import defaultdict
dic = defaultdict(list)
l = []
heapq.heapify(l)
for i in range(n):
    a,b=map(int,input().split())
    b = -b
    dic[a].append(b)
s = 0
t = [0]
for i in range(m):
    for i in dic[i+1]:
        heapq.heappush(l,i)
    if len(l) ==0 : M = 0
    else:
        # print(l)
        M = heapq.heappop(l)
        s += -M
print(s)

Measured memory_bytes: 79448
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;

typedef pair<int, pint> P;

int dp[101][11];

int main()
{
	int c, n, m, s, d;
	while (scanf("%d%d%d%d%d", &c, &n, &m, &s, &d), c|n|m|s|d)
	{
		vector<pint> edge[101];
		for (int i = 0; i < m; ++i)
		{
			int a, b, f;
			scanf("%d%d%d", &a, &b, &f);
			edge[a].push_back(pint(b, f));
			edge[b].push_back(pint(a, f));
		}

		const int INF = 2 << 25;
		for (int i = 1; i <= n; ++i)
			for (int j = 0; j <= c; ++j)
				dp[i][j] = INF;

		priority_queue<P, vector<P>, greater<P> > q;
		q.push(P(0, pint(s, c)));
		while (!q.empty())
		{
			P e = q.top();
			q.pop();
			int cost = e.first;
			int from = e.second.first;
			int ticket = e.second.second;

			if (cost >= dp[from][ticket])
				continue;
			dp[from][ticket] = cost;

			foreach (it, edge[from])
			{
				int to = it->first;
				int f = it->second;
				q.push(P(cost + f, pint(to, ticket)));
				if (ticket)
					q.push(P(cost + f/2, pint(to, ticket-1)));
			}
		}

		printf("%d\n", *min_element(dp[d], dp[d]+c+1));
	}

	return 0;
}

Measured memory_bytes: 1112
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

static MOD: u64 = 1_000_000_007;

fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0];
    let x = line[1];
    let y = line[2];
    let z = line[3];

    let mut memo = vec![vec![0u64; 1 << 16]; n+1];
    memo[0][0] = 1;
    
    let mut memo2 = vec![true; 1 << 17];
    for i in 0..1 << 17 {
        let mut state = 0;
        let mut sum = 0;
        let mut pos = 0;
        let mut prev = 0;
        while pos < 17 {
            if (i & (1 << pos)) > 0 {
                sum += pos-prev+1;
                prev = pos+1;
                if state == 0 && sum == z {
                    state = 1;
                    sum = 0;
                } else if state == 1 && sum == y {
                    state = 2;
                    sum = 0;
                } else if state == 2 && sum == x {
                    state = 3;
                    break;
                }
            }
            pos += 1;
        }
        
        if state == 3 {
            memo2[i] = false;
        }
    }
    
    for i in 0..n {
        for j in 0..1 << 16 {
            // println!("len: {}, state: {:b}, sum: {}", i, j, memo[i][j]);
            if !memo2[j] {
                continue;
            }
            for k in 1..11 {
                let next = ((j << k) + (1 << (k-1))) % (1 << 17);
                if memo2[next] {
                    memo[i+1][next % (1 << 16)] += memo[i][j];
                    memo[i+1][next % (1 << 16)] %= MOD;
                }
            }
        }
    }
    let mut ans = 1u64;
    for i in 0..n {
        ans *= 10;
        ans %= MOD;
    }

    for i in 0..1 << 16 {
        ans += MOD - memo[n][i];
        ans %= MOD;
    }

    println!("{}", ans);
}


Measured memory_bytes: 30972
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String O = sc.nextLine();
    String E = sc.nextLine();
    int o = O.length();
    int e = E.length();
    if(o==e){
      for(int a=0;a<o;a++){
        System.out.print(O.charAt(a)+""+E.charAt(a));
      }
    }else{
      for(int b=0;b<o-1;b++){
        System.out.print(O.charAt(b)+""+E.charAt(b));
      }
      System.out.print(O.charAt(o-1));
    }
  }
}

Measured memory_bytes: 25684
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    int minv = 101;
    rep(i,n) {
        int a;
        cin >> a;
        ans += a;
        if(a%10 != 0) {
            minv = min(minv,a);
        }
    }
    
    if(ans%10==0) {
        if(minv != 101) ans -= minv;
        else ans = 0;
    } 
    cout << ans << endl;
}

Measured memory_bytes: 3624