akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;


struct SegmentTree{
    int n;
    vector<int> value; //0始まりのインデックス
    int SIJK;

    SegmentTree(int N){
        SIJK = INF; // compareの内容に応じて変える
        n = 1;
        while(n < N) n *= 2;
        value.assign(2 * n - 1, SIJK);
        rep(i, N) value[i + n - 1] = i;
        for(int i = n - 2; i >= 0; i--){
            value[i] = compare(value[2 * i + 1], value[2 * i + 2]);
        }
    }

    int compare(int a, int b){
        return min(a, b); //問題に応じて変える
    }

    void update(int i, int x){
        i += n - 1;
        value[i] = x;
        while(i > 0){
            i = (i - 1)/2; // 親のノード
            value[i] = min(value[2 * i + 1], value[2 * i + 2]);
        }
    }

    int find(int a, int b, int k = 0, int l = 0, int r = -1){
        // [a, b) の区間に対するクエリについて
        // ノード k （区間 [l, r) 担当）が答える
        if(r < 0) r = n;
        if(r <= a || b <= l) return SIJK;
        if(a <= l && r <= b) return value[k];
        else{
            int m = (l + r) / 2;
            int tmp1 = find(a, b, 2 * k + 1, l, m);
            int tmp2 = find(a, b, 2 * k + 2, m, r);
            return compare(tmp1, tmp2);
        }
    }


};


int main(){
    int N, M;
    cin >> N >> M;
    SegmentTree sg(M);
    priority_queue<P> que;
    rep(i, N){
        P tmp;
        cin >> tmp.second >> tmp.first;
        que.push(tmp);
    }

    int sum = 0;
    while(!que.empty()){
        P tmp = que.top();
        que.pop();
        int a = tmp.second - 1, b = tmp.first;
        int f = sg.find(a, M);

        if(f == INF) continue;
        else{
            sg.update(f, INF);
            sum += b;
        }
    }

    cout << sum << endl;

}

Measured memory_bytes: 2424
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n, i;
  scanf("%d", &n);
  for(i = 2; i*(i-1)/2 <= n; i++){
    if(i*(i-1)/2 == n) break;
  }
  if(i*(i-1)/2 == n){
    printf("Yes\n%d\n", i);
    for(int j = 0; j < i; j++){
      printf("%d", i-1);
      int t = j;
      for(int k = 0; k < j; k++){
        printf(" %d", t);
        t += i-2-k;
      }
      t = (2*i-1-j)*j/2 + 1;
      for(int k = 0; k < i-1-j; k++) printf(" %d", t+k);
      printf("\n");
    }
  }else printf("No\n");
}

Measured memory_bytes: 1408
# 正直者；いっていることは正しい, 不親切：いっていることは正しいか正しくない（情報量０）
# A->B->C->Dみたいに正直者同士をつなげることができる．Aを正直者だと仮定するとB,C,Dのすべての人達の言うことが正しくなり，これらの間で矛盾があってはならない
# 正直者が最大となるのは，不親切者が最小となるとき，つまり１５こについてループを回すとまずそう
# 15*14*13 # 分割統治法f(不親切としておくヒトのリスト,正直者だと確定したヒトのリスト,A(新たに正直者だと仮定するひと))=f([],[])+f([],[+A])
N=int(input())
A=[] #(N+1,an,2)
for i in range(N):
    xij=[]
    an = int(input())
    for j in range(an):
        xij.append(list(map(int,input().split())))
    A.append(xij)

#def can_connect(tsuika,unkind,honest): # tsuikaを正直者とした時に既存のリストと矛盾しないか
#    i = tsuika
#    flag = True # なんにもなければTrueでいい
#    for a = A[i-1]:
#        if a[1] == 1: 
#            if a[0] in honest:  # もうすでに正直者で確定していれば探索する必要はない
#                pass
#            elif a[0] in unkind: # 不親切のリストに入っていなければまた調べる必要がある
#                flag = False
#            else:  
#                honest.append(a[0])
#                flag = can_connect(a[0],unkind,honest)
#        else:
#            if a[0] in unkind: # もうすでに不親切でかくていして
#                pass
#            elif a[0] in honest: # 正直者になっていれば
#                flag = False
#            else: 
#                unkind.append(a[0])
#        can_connect(a[0],unkind,honest)
#        if flag == False: # a[i]がおかしな値になっていたら
#            return False
#    if flag == True:
#        return 
#

# 総当りで解ける, bit全探索という N=15として,2^15*(N*N)10^8くらい？
max_num = 0
for i in range(2**N): #  前から順にi番目の要素ビットの値がヒトiが真か偽か
    res=True
    i = str(bin(i))[2:]
    i=i.zfill(N)
    for l,a in enumerate(A):
        flag=bool(int(i[l]))
        if flag: # 本当のことをいっている人なら判定をする
            for k,ai in enumerate(a):
                if not str(ai[1]) == i[ai[0]-1]:
                    res = False
                    break
        if not res: # もうだめなことがわかっていたら
            break
    if res:
        res_list = list(map(int,i))
        max_num = max(max_num, sum(res_list))

print(max_num)



Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int N = stdIn.nextInt();
			if(N == 0) break;
			String kka = stdIn.next();
			
			String[] c = new String[100];
			
			for(int i = 0; i < 100; i++) {
				c[i] = Character.toString(kka.charAt(i));
			}
			String[][] m = new String[N][100];
			String[] ba = new String[100];
			
			int bapp = 0; //場のポインタ
			
			int[] pp = new int[N];
			
			int pc = 0;
			
			for(int i = 0; i < 100; i++) {
				if(c[i].equals("M")) {
					m[pc][pp[pc]] = "M";
					pp[pc]++;
				}
				if(c[i].equals("S")) {
					ba[bapp++] = "S";
					for(int j = 0; j < pp[pc]; j++) {
						ba[bapp++] = m[pc][pp[pc]];
					}
					pp[pc] = 0;
				}
				if(c[i].equals("L")) {
					m[pc][pp[pc]++] = "L";
					for(int j = 0; j < bapp; j++) {
						m[pc][pp[pc]++] = ba[j]; 
					}
					bapp = 0;
				}
				pc++;
				if(pc == N) {
					pc = 0;
				}
				
			}
			
			Arrays.sort(pp);
			for(int i = 0; i < N; i++) {
				System.out.print(pp[i]+" ");
			}
			System.out.println(bapp);
		}
	}
		
}

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

int main() {
  
  int a, b;
  cin >> a >> b;
  
  if (a % 2 == 1 && b % 2 == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)

int main() {

	int n, k;
	cin >> n >> k;

	vector<int> d(k), cnt(n);

	rep(i, 0, k) {
		cin >> d[i];
		vector<int> a(d[i]);
		rep(j, 0, d[i]) {
			cin >> a[j];
			cnt[a[j] - 1]++;
		}
	}

	int count = 0;

	rep(i, 0, n) {
		if (cnt[i] == 0) {
			count++;
		}
	}
	cout << count << endl;

			return 0;
}

Measured memory_bytes: 3632
//
// Created by ZEN on 2019/10/20.
//

#include <bits/stdc++.h>

using namespace std;

vector<int> getList(int i) {
    int a;
    vector<int> vec(i);
    for (int j = 0; j < i; ++j) {
        cin >> a;
        vec.at(j) = a;
    }
    return vec;
}

int main() {
    int n;
    cin >> n;
    vector<int> A = getList(n);
    vector<int> B = getList(n);
    vector<int> C = getList(n - 1);
    int amount = 0;
    amount += B.at(A.at(0) - 1);
    for (int i = 1; i < n; ++i) {
        amount += B.at(A.at(i) - 1);
        if (A.at(i - 1) == A.at(i) - 1) {
            amount += C.at(A.at(i - 1) - 1);
        }
    }
    cout << amount << endl;
}



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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    ll ans = 0;
    int num;
    cin >> num;
    if(num > x) {
        ans = num-x;
        num = x;
    }
    rep(i, n-1) {
        int u;
        cin >> u;
        if(u+num > x) {
            ans += u+num-x;
            u = x-num;
        }
        num = u;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val s = sc.next + "**"

  val res = s.tail.tail.foldLeft((0, s.head, s.tail.head)){ case ((cnt, pre2, pre), now) =>
    if(pre2 == '*' || pre == '*' || now == '*') (cnt, '*', '*')
    else {
      val newCnt = cnt + ( if ( pre2 == 'A' && pre == 'B' && now == 'C') 1 else 0)
      (newCnt, pre, now)
    }
  }._1

  println(res)
}


Measured memory_bytes: 27448
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
Int printX(Int r, Int D, Int X, int count){
    if(count == 10){
        return 0;
    }
    Int nextX = r*X - D;
    cout<< nextX <<endl;
    printX(r,D,nextX,count+1);

}
int main() {
    int N;
    vector<Int> W;
    cin >> N;
    W = vi(N);
    rep(i,N){
        cin >> W[i];
    }

    Int W_all = 0;
    rep(i,N){
        W_all += W[i];
    }

    Int ans = inf;
    Int now =0;
    rep(i,N){
        now += W[i];
        Int tmp = abs(now-(W_all-now));
        ans = min(ans, tmp);
    }

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


Measured memory_bytes: 256
const fs = require('fs')
const stdin = fs.readFileSync('/dev/stdin', 'utf8')

const input = stdin.split('\n')

const N = input[0]
const H = input[1].split(' ').map(Number)

let v = H[0]

const res = H.filter(h => {
  if(v <= h){
    v = h
    return true
  }
  return false
}).length

console.log(res)

Measured memory_bytes: 7500
/*
|| Suyash Yadav | B.Tech (3rd Year CSE) | Tier-3 (NCR,India)
|| suyashky@gmail.com | "suyashky" @linkedIn
||
||		   /\_/\
||		  ( o.o )
|| 	 	   > ^ <
|| From infinity to beyond!
*/

# include <bits/stdc++.h>
using namespace std;
# define INF (long long int)1e28
# define MOD 1000000007
# define all(con) con.begin() , con.end()
# define MAX numeric_limits<int64>::max()
# define MIN numeric_limits<int64>::min()
# define watch1(x) cout<<#x<<": "<<x<<endl
# define watch2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
# define watch3(x,y,z) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
# define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int int64;
typedef unsigned long long int uint64;

struct node {
	int64 w, v;
};

int64 dp[102][100002];

int64 knapsack(vector<node> &list, int64 maxw, int64 n)
{
	if (n == -1 || maxw == 0)
		return 0;
	if (dp[n][maxw] != -1)
		return dp[n][maxw];
	if (list[n].w > maxw)
		return (dp[n][maxw] = knapsack(list, maxw, n - 1));
	int64 a = 0, b = 0;
	a = list[n].v + knapsack(list, maxw - list[n].w, n - 1);
	b = knapsack(list, maxw, n - 1);
	return (dp[n][maxw] = max(a, b));
}

int main()
{
	/*
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	*/

	memset(dp, -1, sizeof(dp));
	int64 n, maxw;
	cin >> n >> maxw;

	vector<node> list;
	int64 a, b;
	for (int64 i = 0 ; i < n ; i++)
	{
		cin >> a >> b;
		list.push_back({a, b});
	}

	// recursive
	int64 ans1 = knapsack(list, maxw, n - 1);
	cout << ans1 << endl;


}

Measured memory_bytes: 80000
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<P> v(n);
    vector<ll> p(n);
    FOR(i,0,n) p[i] = i;
    FOR(i,0,n)cin>>v[i].first>>v[i].second;
    ld ans = 0;
    ll x = 0;
    do {
        FOR(i,1,n){
            ans += sqrt((v[p[i]].first - v[p[i-1]].first)*(v[p[i]].first - v[p[i-1]].first) + (v[p[i]].second - v[p[i-1]].second)*(v[p[i]].second - v[p[i-1]].second));
        }
        x++;
    } while (std::next_permutation(p.begin(), p.end()));
    cout(10)<<ans/x<<endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> num(n+1,0),cnt(n+1,0);
  for(int i=1;i<=n;i++){
    cin >> num[i]; cnt[num[i]]++;
  }
  ll mother=0;
  for(int i=1;i<=n;i++){
    mother += cnt[i]*(cnt[i]-1)/2;
  }
  for(int i=1;i<=n;i++){
    cout << mother - cnt[num[i]] + 1 << endl;
  }
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(), (a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(), (a).end())

int main(){
    int64_t x;
    cin>>x;
    int i=1;
    int ans = 0;
    while(1){
        ans += i;
        if(ans>=x){
            break;
        }
        i++;
    }
    cout<<i<<endl;
}

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

int main() {
  int n;
  int a[4][13] = {0};
  char x;
  int y;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    switch (x) {
      case 'S':
        a[0][y - 1] = 1;
        break;
      case 'H':
        a[1][y - 1] = 1;
        break;
      case 'C':
        a[2][y - 1] = 1;
        break;
      case 'D':
        a[3][y - 1] = 1;
        break;
    }
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      if (a[i][j] == 0) {
        switch (i) {
          case 0:
            cout << 'S';
            break;
          case 1:
            cout << 'H';
            break;
          case 2:
            cout << 'C';
            break;
          case 3:
            cout << 'D';
            break;
        }
        cout << ' ' << j + 1 << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int main() {
	int n; cin >> n;
	map<int, int> md;
	for(int i=0;i<n;i++){
		int d; cin >> d;
		md[d]++;
	}
	int m; cin >> m;
	for(int i=0;i<m;i++){
		int t; cin >>t;
		md[t]--;
		if(md[t]<0){
			cout << "NO" <<endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 11111111111111111
#define MOD 1000000007
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//-------------------------------------------------------------------------------

#define MAX 10000

int main(void) {
  ll a, b, c;
  ll x[3];
  cin >> a >> b >> c;

  while (1) {
	if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
	  cout << cnt << endl;
	  return 0;
	}

	if (a == b && b == c && c == a) {
	  cout << "-1" << endl;
	  return 0;
	}

	x[0] = (b + c) >> 1;
	x[1] = (c + a) >> 1;
	x[2] = (a + b) >> 1;
	a = x[0];
	b = x[1];
	c = x[2];
	cnt++;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
bool f(pair<pair<string, int>, int> l, pair<pair<string, int>, int> r){
    if(l.first.first > r.first.first) return false;
    else if(l.first.first < r.first.first) return true;
    else return l.first.second > r.first.second;
}
int main(){
    int n;
    cin >> n;
    vector<pair<pair<string, int>, int> > v;
    for(int i = 0; i < n; i++){
        string s;
        int x;
        cin >> s >> x;
        v.pb(make_pair(make_pair(s,x), i+1));
    }
    sort(v.begin(), v.end(), f);
    for(int i = 0; i < n; i++){
        cout << v[i].second << endl;
    }
}

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

template<typename T>
T MatMaximum(vector<vector<T>> &mat){
    vector<T> max_array;
    for(auto itr = mat.begin(); itr != mat.end(); ++itr) {
        T maximum = *max_element((*itr).begin(), (*itr).end());
        max_array.push_back(maximum);
    }
    return *max_element(max_array.begin(),max_array.end());
}



void process_vec(vector<int> &array, string hoge){
    int size_array = array.size();
    int count = 0;
    hoge.push_back('#');
    for (int i= 0;i<size_array+1;i++){
        if (hoge[i] == '.'){
            count+=1;
        }else{
            for (int k=0;k<count;k++){
                array[i-k-1] = count;
            }
            count=0;
        }
    }
}

string get_vec_col(vector<string> &S,int col_idx){
    int row_len = S.size();
    string ret;
    for (int i= 0;i<row_len;i++){
        ret.push_back(S[i][col_idx]);
    }
    return ret ;
}

//末尾に注意しないといけない
void solve(long long H, long long W, std::vector<std::string> S){
    vector<vector <int>> horizontal_count(H,vector<int>(W,0));
    vector<vector <int>> vertical_count(W,vector<int>(H,0));
    for (int i=0;i<H;i++){
        process_vec(horizontal_count[i],S[i]);
    }
    for (int i=0;i<W;i++){
        process_vec(vertical_count[i],get_vec_col(S,i));
    }

    vector<vector <int> > count(H,vector<int>(W,0));
    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            count[i][j] = horizontal_count[i][j] + vertical_count[j][i];
        }
    }
    printf("%d\n",MatMaximum(count)-1);

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    std::vector<std::string> S(H);
    for(int i = 0 ; i < H ; i++){
        std::cin >> S[i];
    }
    solve(H, W, std::move(S));
    return 0;
}


Measured memory_bytes: 51456
using System;
using System.Collections.Generic;

public class CSharp
{
    public static void Main()
    {
        Kyopuro chokudai = new Kyopuro();
        chokudai.AtCoder();
    }
}

public class Kyopuro
{

    int n, m, k;

    public void AtCoder()
    {
        string[] input;
        input = Console.ReadLine().Split(' ');
        n = int.Parse(input[0]);
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i=0; i<n; i++)
        {
            a[i] = int.Parse(Console.ReadLine());
            b[i] = a[i];
        }
        Array.Sort(a);
        if(a[n-1] == a[n - 2])
        {
            for (int i = 0; i < n; i++) Console.WriteLine(a[n - 1]);
        } else
        {
            for(int i=0; i<n; i++)
            {
                if (b[i] == a[n - 1])
                {
                    Console.WriteLine(a[n - 2]);
                }
                else Console.WriteLine(a[n - 1]);
            }
        }
    }
    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
}


Measured memory_bytes: 17876
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;


int main(){
    int n;
    cin>>n;
    int ans=n;
    vector<int> num(MAX_N,0);
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        num[a]++;
    }
    int m=0;
    bool f=false;
    for(int i=1;i<=MAX_N;i++){
        if(num[i]>0) m+=num[i]-1;
        if(num[i]>0 && num[i]%2==0) f=!f;
    }
    ans-=m;
    if(f) ans--;
    cout<<ans<<endl;
    

}

Measured memory_bytes: 5112
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val map = mutableMapOf<Int, Map<Int, Int>>()
    repeat(n) {
        val a = readInteger()
        val tmp = mutableMapOf<Int, Int>()
        repeat(a) {
            val (x, y) = readIntegerList()
            tmp[x - 1] = y
        }
        map[it] = tmp
    }

    var ans = 0
    for (state in 0 until (1 shl n)) {
        if (check(state, n, map)) {
            ans = max(ans, Integer.bitCount(state))
        }
    }
    out.println(ans)
}

fun check(state: Int, n: Int, map: MutableMap<Int, Map<Int, Int>>): Boolean {
    val tmp = IntArray(n) { -1 }
    for (i in 0 until n) {
        if (((state shr i) and 1) == 1) {
            for (j in map[i]!!) {
                if (((state shr j.key) and 1) != j.value) {
                    return false
                }
                if (tmp[j.key] == -1) {
                    tmp[j.key] = j.value
                } else if (tmp[j.key] != j.value) {
                    return false
                }
            }
        }
    }
    return true
}



fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 42348
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):

    plug_num = 1
    plugable_num = A

    while plugable_num < B:
        plugable_num += A - 1
        plug_num += 1

    if B == 1:
        print(0)
    else:
        print(plug_num)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string s;
	scan(s);
	queue<char> mae;
	rep(i,s.size()){
		if(i>=1){
			if(mae.back()==s[i]){
				printf("%d %d\n",i,i+1);
				return 0;
			}
		}
		if(i>=2){
			if(mae.front()==s[i]){
				printf("%d %d\n",i-1,i+1);
				return 0;
			}
			mae.pop();
		}
		mae.push(s[i]);
	}
	printf("-1 -1\n");
	return 0;
}


Measured memory_bytes: 512
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
 
n = I()
ans = 0
lst = [[] for _ in range(n)]
for i in range(n):
    a = I()
    for j in range(a):
        x,y = LI()
        lst[i].append((x-1,y))
for i in range(2**n):
    b = [0]*n
    for j in range(n):
        if (i >> j) & 1:
            b[j] = 1
    flg = True
    for j in range(n):
        if b[j] == 0:
            continue
        for k,l in lst[j]:
            if l == 0:
                if b[k] == 1:
                    flg = False
                    break
            else:
                if b[k] == 0:
                    flg = False
                    break
        if not flg:
            break
    else:
        ans = max(ans,sum(b))
print(ans)

Measured memory_bytes: 3444
import math
n = int(input())
input_nums = [int(input()) for _ in range(n)]

primes = []
for i in range(2, 10000):
    is_prime = True
    # 今まででた素数で割っていくと、自身が素数かどうかわかる
    for p in primes:
        if i % p == 0:
            is_prime = False
    if is_prime:
        primes.append(i)


def check(n):
    for p in primes:
        if n <= p:
            return True
        if n % p == 0:
            return False
    return True


count = 0
for num in input_nums:
    if check(num):
        count += 1
print(count)



Measured memory_bytes: 6012
#include <stdio.h>
 
int cnt;
 
void insertionSort(int A[], int n, int g);
void shellSort(int A[], int n);
 
int n;
int A[1000000];
 
int main() {
  int i;
  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", A+i);
  shellSort(A, n);
  printf("%d\n", cnt);
  for(i = 0; i < n; ++i) printf("%d\n", A[i]);
  return 0;
}
 
void insertionSort(int A[], int n, int g) {
  int tmp;
  int i, j;
  for(i = g; i < n; ++i) {
    tmp = A[i];
    j = i-g;
    while(j >= 0 && A[j] > tmp) {
      A[j+g] = A[j];
      j -= g;
      ++cnt;
    }
    A[j+g] = tmp;
  }
}
 
void shellSort(int A[], int n) {
  int m = 0;
  int G[100];
  int i;
  G[0] = 1;
  for(m = 1; 3*G[m-1]+1 <= n; ++m) G[m] = 3*G[m-1]+1;
  printf("%d\n", m);
  cnt = 0;
  for(i = m-1; i >= 0; --i) {
    printf("%d%c", G[i], " \n"[i==0]);
    insertionSort(A, n, G[i]);
  }
}


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define sz(v) (v).size()
#define debug(x) cerr << #x << "_=_" << x << "\n";
#define sum(n) ((n)*((n)+1)>>1)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;

const int MAXN = 3e3+5;
ll dp[MAXN][MAXN], a[MAXN];
int n;

ll f(int i, int j){
    if(i==j) return a[i];
    if(~dp[i][j]) return dp[i][j];
    return dp[i][j] = max(a[i] - f(i+1, j), a[j] - f(i, j-1));
}

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


    cin >> n;
    for (int i=0; i<n; i++)
        cin >> a[i];

    memset(dp, -1, sizeof dp);

    cout << f(0, n-1) << "\n";




    return 0;
}

/*
1
9 3
111100000
 */

Measured memory_bytes: 71040
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  vint count(3);
  rep(i,(int)s.size()){
    if(s[i]=='a'){
      count[0]++;
    }
    else if(s[i]=='b'){
      count[1]++;
    }
    else{
      count[2]++;
    }
  }
  sort(all(count));
  
  if((count[2]-count[0])+(count[1]-count[0])+(count[2]-count[1])>2){
    cout<<"NO"<<'\n';
  }
  else{
    cout<<"YES"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 512
n,m = [int(i) for i in input().split()]
ab = []
for i in range(m):
  ab.append([int(i)-1 for i in input().split()])

def find_index(c,eld):
  if c in eld[c]:
    return(c,len(eld[c]))
  else:
    return(eld[c][0],len(eld[eld[c][0]]))
           
eld = []
for i in range(n):
  eld.append([i])
stat = eld
ans = [int(len(eld)*(len(eld)-1)/2)]

for a,b in ab[1:][::-1]:
#  print(eld)
  a_index,a_size = find_index(a,eld)
  b_index,b_size = find_index(b,eld)
#  print(a_index,b_index)
  if a_index == b_index:
    ans.append(ans[-1])
    continue
  else:
    next = a_size * b_size
    ans.append(ans[-1] - next)

  if a_size >= b_size:
    eld[a_index].extend(eld[b_index])
    for i in eld[b_index]:
      eld[i] = [a_index]
  else:
    eld[b_index].extend(eld[a_index])
    for i in eld[a_index]:
      eld[i] = [b_index]

for i in ans[::-1]:
  print(i)

Measured memory_bytes: 43844
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

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

int main()
{
    int A,B;
    cin >> A >> B;
    if(A%3 == 0 || B%3 == 0 || (A+B)%3 == 0)
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;

    return 0;
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

using ll = long long;

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

vector<int> path[100010];
bool visited[100010];

int dfs(int v) {
    visited[v] = true;
    int ret = 0;
    for (int sv : path[v]) {
        if (visited[sv]) continue;
        ret ^= (dfs(sv) + 1);
    }
    return ret;
}

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

    for (int i = 0; i < N - 1; ++i) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        path[x].push_back(y);
        path[y].push_back(x);
    }

    fill(visited, visited + N, false);

    cout << (dfs(0) > 0 ? "Alice" : "Bob") << endl;

    return 0;
}


Measured memory_bytes: 8960
import java.util.*;
import java.io.*;

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);


        int S  =  in.nextInt();
        int W =   in.nextInt();

        if(S<=W)
        {
            System.out.println("unsafe");
        }

        else
            {
                System.out.println("safe");
            }
 }

    }










Measured memory_bytes: 35528
#include <stdio.h>
int main(void){
    int N,sum=1;
    scanf("%d",&N);
    
    char S[N];
    scanf("%s",S);
    
    for(int i=0;i+1<N;i++){
        if(S[i]!=S[i+1]){
            sum+=1;
        }
    }
    printf("%d\n",sum);
    return 0; 
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())
d=[list(map(int, input().split())) for i in range(a)]
ans=10**9+7
t2=0
for i in range(2**a):
  e=[0 for j in range(b)]
  f=[0 for j in range(a)]
  ex=0
  for j in range(a):
    if (i//(2**j))%2==1:
      ex+=d[j][0]
      for k in range(b):
        e[k]+=d[j][k+1]
  t1=1
  for j in range(b):
    if c>e[j]:
      t1=0
      break
  if t1 and ans>ex:
    ans=ex
    t2=1
if t2:
  print(ans)
else:
  print(-1)
    
      


Measured memory_bytes: 68840
n = int(input())
x, y = map(int, input().split())
h_list = list(map(int, input().split()))

min_diff = 9999999999
min_index = 0
for i, h in enumerate(h_list):
    diff = abs(y - (x - h * 0.006))
    if min_diff > diff:
        min_diff = diff
        min_index = i

print(min_index + 1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int f(int x){
  if(x%2 == 0) return x / 2;
  return 3 * x + 1;
}
int main(){
  int s; cin >> s;
  set<int> vis;
  vis.insert(s);
  for(int i = 2; ; i++){
    s = f(s);
    if(vis.count(s)){
      cout << i << endl;
      return 0;
    }
    vis.insert(s);
  }
}

Measured memory_bytes: 256
R, G, B, N = map(int, input().split())

cnt = 0
for r in range(N//R+1):
    Rr = R*r
    for g in range((N-Rr)//G+1):
        if (N-(Rr + G*g)) % B == 0:
            cnt += 1
print(cnt)

Measured memory_bytes: 2940
N,A,B = map(int,input().split(" "))
list = []
for i in range(1,N+1):
    i = str(i)
    if len(str(i)) == 1:
        d = int(i)
    elif len(str(i)) == 2:
        d = int(i[0]) + int(i[1])
    elif len(str(i)) == 3:
        d = int(i[0]) + int(i[1]) + int(i[2])
    elif len(str(i)) == 4:
        d = int(i[0]) + int(i[1]) + int(i[2]) + int(i[3])
    elif len(str(i)) == 5:
        d = int(i[0]) + int(i[1]) + int(i[2]) + int(i[3]) +int(i[4])
    list.append(d)
ans = 0
for j in range(len(list)):
    if list[j] >= A and list[j] <= B:
        ans += j+1
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, m;
    cin >> n >> m;
  
    int score=0, pena=0;
    VI sco(n);
    VI sco1(n);
  
    rep(i,m){
        int x;
        string y;
        cin >> x >> y;
        x--;
        if(y =="WA" && sco[x] <= 0) sco[x]--;
        else if(sco[x]<=0 && sco1[x] == 0){
        score++;
        sco1[x] = 1;
        sco[x] *= (-1);
        }
    }
 
    rep(i,n) if(sco[i]>0) pena+=sco[i];
    
    cout << score << " " << pena << endl;

    return 0;
}

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

int main(){
    int k;
    string s;
    cin>>k>>s;
    if(s.size()<=k)
        cout<<s;
    else{
        string::iterator it;
        int m=1;
        for(it=s.begin();m<=k;it++){
            cout<<*it;
            m++;
        }
        cout<<"...";
    }
    return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<int>> cnt(n, vector<int>(26, 0));
    REP(i, n) {
        string S;
        cin >> S;
        for (auto c : S) {
            cnt[i][c - 'a']++;
        }
    }
    REP(i, 26) {
        int mi = 50;
        REP(j, n) {
            amin(mi, cnt[j][i]);
        }
        if (mi > 0) {
            cout << string(mi, 'a' + i);
        }
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
const int N=605;
int n,d1,d2,c,a[N][N];
void color(int d){
  int w=0;
  while (d%4==0) d/=4,w++;
  if (d&1){
  	for (int i=0;i<2*n;i++)
  	  for (int j=0;j<2*n;j++)
  	    if (((i>>w)&1)^((j>>w)&1))
  	      a[i][j]=1;
  }
  else {
  	for (int i=0;i<2*n;i++)
  	  for (int j=0;j<2*n;j++)
  	    if ((j>>w)&1)
  	      a[i][j]=1;
  }
}
int main(){
  scanf("%d%d%d",&n,&d1,&d2);
  color(d1);color(d2);
  for (int i=0;i<2*n;i++)
    for (int j=0;j<2*n;j++)
      if (c<n*n&&!a[i][j]) 
        printf("%d %d\n",i,j),c++;
  return 0;
}

Measured memory_bytes: 2304
//
//  abc_swap.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>

int main(int argc, const char* argv[]) {
  int x, y, z;
  std::cin >> x >> y >> z;
  std::cout << z << " " << x << " " << y << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int n;
    string s;
    cin>>n>>s;
    rep(i,s.size()) {
        s.at(i)=(s.at(i)-'A'+n)%26+'A';
    }
    cout<<s<<endl;
}

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

int main(){
  int n,a,b;
  string s;
  cin >> n >> a >> b >> s;
  int home = 0;
  int visit =0;
  for (char c:s){
    if (c=='a'){
      if(home+visit<a+b){
        cout << "Yes" << endl;
        home ++;
      }
      else cout << "No" << endl;
    }
    else if (c=='b'){
      if(home+visit<a+b && visit < b){
        cout << "Yes" << endl;
        visit ++;
      }
      else cout << "No" << endl;
    }
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){ 
    string n;
    cin >> n;
    int key = n.find('9');
    if(key != n.npos) puts("Yes");
    else puts("No");
   
}   

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
E=[]
for i in range(m):
    a,b,c=map(int,input().split())
    E.append((a-1,b-1,c))
INF=-10**20
score=[INF]*n
score[0]=0
for i in range(n-1):
    for j in range(m):
        e=E[j]
        if score[e[0]]!=INF:
            if score[e[1]]<score[e[0]]+e[2]:
                score[e[1]]=score[e[0]]+e[2]
negative=[False]*n
for i in range(n):
    for j in range(m):
        e=E[j]
        if score[e[0]]!=INF:
            if score[e[1]]<score[e[0]]+e[2]:
                score[e[1]]=score[e[0]]+e[2]
                negative[e[1]]=True
if negative[n-1]:
    print('inf')
else:
    print(score[n-1])
        








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

int main() {
	ll N, M; cin >> N >> M;
	ll ans = 0;
	if (2*N >= M) {
		ans += M / 2;
	}
	else {
		M -= 2 * N;
		ans += N;
		ans += M / 4;
	}
	cout << ans << endl;
}


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

int main()
{
    string s;
    cin >> s;
    if( (s[2] == s[3]) && (s[4] == s[5]))
    {
        cout << "Yes" <<endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  ll n;
  cin>>n;
  ll cnt[111]={};
  for(ll i=2;i<=n;i++){
    ll t=i;
    for(ll j=2;t!=1;j++){
	 while(t%j==0){
	   t/=j;
	   cnt[j]++;
	 }
    }
  }
  ll sum=0;
  for(ll i=0;i<111;i++){
    if(cnt[i]>=74)sum++;
    for(ll j=0;j<111;j++){
	 for(ll k=j+1;k<111;k++){
	   if(i==j||i==k)continue;
	   if(cnt[i]>=2&&cnt[j]>=4&&cnt[k]>=4)sum++;
	 }
    }
  }
  for(ll i=0;i<111;i++){
    for(ll j=0;j<111;j++){
	 if(i==j)continue;
	 if(cnt[i]>=14&&cnt[j]>=4)sum++;
	 if(cnt[i]>=24&&cnt[j]>=2)sum++;
    }
  }
  cout<<sum<<endl;
  return 0;
}


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

using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	vector<long long> a(n + 1);
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		a[i] += a[i - 1];
	}
	map<long long, int> mp;
	for(int i = 0; i <= n - 1; i++){
		for(int j = i + 1; j <= n; j++){
			mp[a[j] - a[i]]++;
		}
	}
	long long ans = 0;
	for(int i = 40; i >= 0; i--){
		int cnt = 0;
		for(auto&& j : mp){
			if((j.first & (ans + (1LL << i))) == ans + (1LL << i)){
				cnt += j.second;
			}
		}
		if(cnt >= k) ans += (1LL << i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 31488
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int getcnt(int n)
{
	int cnt = 0;
	while (n)
	{
		cnt++;
		n /= 10;
	}
	return cnt;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		ans += getcnt(i) & 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
k, n = map(int, input().split())
arr = list(map(int, input().split()))
max_inter = 0
max_inter = max(max_inter, arr[0]+k - arr[-1])
for i in range(n-1):
    max_inter = max(max_inter, arr[i+1] - arr[i])
print(k - max_inter)

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

int main()
{
    int n,m;
    std::cin >> n >> m;
    std::vector<std::vector<int>> hen(n);
    for(int i = 0; i < m; i++){
        int a,b;
        std::cin >> a >> b;
        a--; b--;
        hen[a].push_back(b);
        hen[b].push_back(a);
    }
    bool res = false;
    for(auto i : hen[0]){
        for(auto j : hen[i]){
            if(j == n - 1)res = true;
        }
    }
    std::cout << (res ? "POSSIBLE" : "IMPOSSIBLE") << std::endl;
}


Measured memory_bytes: 12016
#include <vector>
#include <set>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <ctime>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie();
    
    string s;
    cin >> s;
    if(s[0] != 'A') {
        cout << "WA";
        return 0;
    }

    int count = 0;
    int pos = 0;
    for(int i = 2;i < (int)s.size() - 1;i++)
        if(s[i] == 'C')
            count++, pos = i;
    if(count != 1) {
        cout << "WA";
        return 0;
    }

    for(int i = 1;i < s.size();i++){
        if(i != pos) {
            if(!(s[i] >= 'a' && s[i] <= 'z')) {
                cout << "WA";
                return 0;
            }
        }
    }
    cout << "AC";
}

Measured memory_bytes: 384