akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& v) {
    return is >> v.first >> v.second;
}

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& v) {
    for (T& i: v) is >> i;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& v) {
    return os << v.first << " " << v.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
    int n = (int) v.size();
    for (int i = 0; i < n; ++i) os << v[i] << (i == n - 1 ? "" : " ");
    return os;
}

template <typename T>
void in(T& x) {
    std::cin >> x;
}

template <typename T1, typename... T2>
void in(const T1 H, const T2... T) {
    std::cin >> (H); in(T...);
}

template <typename T>
void out(const T H) {
    std::cout << (H);
}

template <typename T1, typename... T2>
void out(const T1 H, const T2... T) {
    std::cout << (H) << " "; out(T...);
}

template <typename T>
void eout(const char *s, const T H) {
    std::cerr << s << "=" << H << "\n";
}

template <typename T1, typename... T2>
void eout(const char *s, const T1 H, const T2... T) {
    while (*s != ',') std::cerr << *s++;
    std::cerr << "=" << H << " | "; eout(++s, T...);
}

#define nl                std::cout << "\n"
#define err(args...)      eout(#args, args)

#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define sz(v)             ((int) v.size())
#define all(v)            (v).begin(), (v).end()
#define lla(v)            (v).rbegin(), (v).rend()

#define no                std::cout << "NO\n"
#define yes               std::cout << "YES\n"

const int INF           = 2147483647;
const long long int LNF = 9223372036854775807LL;

using ll  = long long int;
using vi  = std::vector<int>;
using vb  = std::vector<bool>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N  = 505050;
const int MD = 1000*1000*1000 + 7;

int solve();
int main() {
    std::ios_base::sync_with_stdio(0); std::cin.tie(0);
    //std::cout.tie(0);

    //int t; in(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}

int solve() {
    std::string s; in(s); int n = sz(s);
    std::string t; in(t); int m = sz(t);

    vi index[26];
    rep(i, n) {
        index[s[i] - 'a'].push_back(i);
    }

    int c = 0, last = -1;
    rep(i, m) {
        int j = t[i] - 'a';
        if (sz(index[j]) == 0) return out(-1), 0;
        auto nxt = std::upper_bound(all(index[j]), last);
        if (nxt == index[j].end()) {
            ++c, last = index[j][0];
        } else {
            last = *nxt;
        }
    }

    out((ll) c*n + last + 1);

    return 0;
}


Measured memory_bytes: 1228
N = int(input())
A = [int(i) for i in input().split()]

def gcp(a,b):
    if b == 0:
        return a
    else:
        a,b = b,a%b
        return gcp(a,b)

a = A[0]
for i in range(1,N):
    a = gcp(a,A[i])
print(a)

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

int main() {
  int N, Nw;
  cin >> N;
  
  int sum = 0;
  Nw = N;
  while (Nw != 0) {
    sum += Nw % 10;
    Nw /= 10;    
  }
  
  if (N % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a=0;cin>>n;
  for(int i=0;i<n;i++){
    char s;cin>>s;
    if(s=='Y'){
      a++;
      break;
    }
  }
  if(a>0)cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
}

Measured memory_bytes: 256
while True:
  n = int(input())
  if n == 0:
    break
  c = 0
  l = []
  d = {}
  for i in range(n):
    num,x,y = map(int,input().split())
    if num in d:
      d[num] = d[num] + x*y
    else:
      d[num] = x*y
      l.append(num)
  for i in l:
    if d[i] >= 1000000:
      print(i)
      c += 1
  if c == 0:
    print('NA')

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

using namespace std;

int main(void) {
  char a, b;
  cin >> a >> b;

  if((a == 'H' && b == 'H') || (a == 'D' && b == 'D')) {
    cout << "H" << endl;
  }
  else {
    cout << "D" << endl;
  }
}

Measured memory_bytes: 256
void main(){
	int[] n = _scanln();
	(n[0]-n[1]+1).writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

int main() {
	int n;
	cin >> n;
	bool flag = false;
	for (int i = 0; i < 3; i++) {
		if (n % 10 == 7) {
			flag = true;
			break;
		}
		n /= 10;
	}
	if (flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i : c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
using namespace std;
const int dx[] = { 1, -1 , 0 , 0  };
const int dy [] = { 0 ,0 , 1 , -1  };
const int MOD = 1000 * 1000 * 1000 + 7 ;
const int N = 4  ;
const int MAXN = 1000*100 + 5 ;
const int INF = INT_MAX ;
int main ( ){
fast_io();

int t = 1  ;
// cin >> t ;
while (t--){
ll n , k ;
cin >> n >> k ; 
int cnt = 0 ; 
while ( n > 0   ) 
{
n = n / k  ; 
cnt++ ;


}
cout << cnt ;

}

return 0 ;
 
}


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

int n;
int x[5000], y[5000], maxn;
bool p[7000][7000];
int Ax, Ay, Bx, By, Cx, Cy, Dx, Dy;

int main() {
	while (true) {
		memset(p, false, sizeof(p));
		cin >> n;
		maxn = 0;
		if (n == 0) { break; }
		for (int i = 0; i < n; i++) {
			cin >> x[i] >> y[i];
			p[x[i]][y[i]] = true;
		}
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				Ax = x[i];
				Bx = x[j];
				Ay = y[i];
				By = y[j];
				Cx = Ax - (By - Ay);
				Cy = Ay + (Bx - Ax);
				Dx = Bx - (By - Ay);
				Dy = By + (Bx - Ax);
				if (Cx >= 0 && Cy >= 0 && Dx >= 0 && Dy >= 0 && Cx <= 5000 && Cy <= 5000 && Dx <= 5000 && Dy <= 5000) {
					if (p[Cx][Cy] == true && p[Dx][Dy] == true) {
						maxn = max(maxn, (Ax - Bx)*(Ax - Bx) + (Ay - By)*(Ay - By));
					}
				}
			}
		}
		cout << maxn << endl;
	}
	return 0;
}

Measured memory_bytes: 49052
# -*- coding: utf-8 -*-
from itertools import permutations

N,C = map(int, input().split())
D = []
for _ in range(C):
    line = list(map(int, input().split()))
    D.append(line)
c = []
t = [[0 for _ in range(C)] for _ in range(3)]
for i in range(N):
    line = list(map(int, input().split()))
    for j in range(N):
        r = (i+j)%3
        t[r][line[j]-1] += 1
    c.append(line)

def e(conv):
    ret = 0
    for r in range(3):
        for i in range(C):
            ret += t[r][i]*D[i][conv[r]-1]

    return ret

ret = 10**10
for conv in permutations(range(1,C+1), 3):
    ret = min(ret, e(conv))

print(ret)


Measured memory_bytes: 5620
#include<stdio.h>
int main()
{
	char a,b;
	scanf("%c %c",&a,&b);
	if(a=='H'){
		if(b=='H'){
			puts("H");
		}else if(b=='D'){
			puts("D");
		}
	}else if(a=='D'){
		if(b=='H'){
			puts("D");
		}else if(b=='D'){
			puts("H");
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
using namespace std;
int main() {
	long long N,t=0,P,sum=0;
	cin >> N;
	P = N;
	do {
		t++;
		P/=10;
	} while (P);
	for (int i = 1; i <= t; i += 2)
	{
		if (i == t)
		sum += N - pow(10, (t - 1))+1;
		else
		sum += pow(10, i) - pow(10, (i - 1));
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef struct BIT{
	vector<ll> b;
	int n;
	// 1 indexed ?
       void init(int size){
	       b = vector<ll> (size+1,0);
		n = size+1;
       }
	//[0,i)までの和       
	ll sum(int i){
		ll s = 0;
		while(i>0){
			s+= b[i];
			i-= i&-i;
		}
		return s;
	}
	//[s,t]までの和
	ll getSum(int s,int t){
		return sum(t)-sum(s-1);
	}
	void add(int i,int x){
		//while(i <= n){
		while(i < n){
			b[i] += x;
			i+= i&-i;
		}

	}

}BIT;
//Binary Indexed Tree

int main(){
	int n,q;
	cin>>n>>q;
	BIT bit;
	bit.init(n);
	for(int i=0;i<q;i++){
		int c,x,y;
		cin>>c>>x>>y;
		if(c==0){
			bit.add(x,y);
		}else{
			cout<<bit.getSum(x,y)<<endl;
		}
	
	}
	

	return 0;
}



Measured memory_bytes: 4460
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int n,d[SZ]; Edg
ld f[SZ],ca=0;
void dp1(int x,int fa=0)
{
	f[x]=0;
	for esb(x,e,b) if(b!=fa)
		dp1(b,x), f[x]+=(f[b]+1)/ld(d[x]-bool(fa));
}
ld anss[SZ];
void dp2(int x,int fa=0)
{
	ld cc=ca; anss[x]=cc;
	for esb(x,e,b) if(b!=fa)
	{
		ld ts=(f[b]+1)/ld(d[x]);
		ld ot=0;
		if(fabs(cc-ts)>1e-6)
			ot=(cc-ts)/(1-1.0/ld(d[x]));
		ot++;
		ca=f[b]*(1-1.0/ld(d[b]))+ot*1.0/ld(d[b]);
		dp2(b,x);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		adde(a,b);++d[a];++d[b];
	}
	dp1(1); ca=f[1]; dp2(1);
	for(int i=1;i<=n;i++)
		printf("%.10lf\n",anss[i]);
}


Measured memory_bytes: 22400
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/04/04.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC129
//
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__

void solve(void){
  
  int N, K;
  string S;
  
  cin >> S;
  
  string ans;
  string ans1="XX";
  string ans2="XX";
  
  N=stoi(S.substr(0,2));
  K=stoi(S.substr(2,2));

  if(N>12){ans1="YY";}else if(N>0){ans1="MM";}
  
  if(K>12){ans2="YY";}else if(K>0){ans2="MM";}
   
  if(ans1=="XX" && ans2=="XX"){
    ans="NA";
  }
  else if(ans1=="MM" && ans2=="XX"){
    ans="MMYY";
  }
  else if(ans1=="XX" && ans2=="MM"){
    ans="YYMM";
  }
  else if(ans1=="YY" && ans2=="XX"){
    ans="NA";
  }
  else if(ans1=="XX" && ans2=="YY"){
    ans="NA";
  }
  else if(ans1=="MM" && ans2=="MM"){
    ans="AMBIGUOUS";
  }
  else if(ans1=="YY" && ans2=="YY"){
    ans="NA";
  }
  else
  {
    ans=ans1+ans2;
  }

  cout << ans << endl;
  
  return;
   
}



#define TESTCASES 1

int main(int argc, const char * argv[]) {


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

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}



Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn main() {
    let in_vec: Vec<usize> = read_line();
    let n = in_vec[0];
    let _m = in_vec[1];
    let a: Vec<usize> = read_line();
    let sum = a.iter().fold(0, |sum, x| sum + x);

    if sum > n {
        println!("{}", -1);
    } else {
        println!("{}", n - sum);
    }
}


Measured memory_bytes: 2220
#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(){
	char a, b;
	while(cin >> a >> b){
		if(a == 'H' && b == 'H') cout << "H" << endl;
		else if(a == 'D' && b == 'H') cout << "D" << endl;
		else if(a == 'D' && b == 'D') cout << 'H' << endl;
		else cout << 'D' << endl;
	}

	return 0;
}


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

vector<int> v;

int main() {
    ll n;
    cin >> n;
    bool a=true;
    for (int i = 0; i < n; ++i) {
        ll t;cin >> t;if(t&1)a=!a;
    }
    cout << (a ? "YES" :"NO");
}

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

#define U1 unsigned char
#define S1 char
#define	S4 int
#define S8 long
#define DU double

#define TRUE					      (1)
#define FALSE					      (0)

#define MAX_VECTOR_ELM                (2)     /* ベクトルの最大要素数 */

/* qsort用比較関数 */
int comp(const void* vd_ap_var1, const void* vd_ap_var2)
{
	return *(S4*)vd_ap_var1 - *(S4*)vd_ap_var2;
}

DU du_d_calcEuclid(DU* du_ap_x, DU* du_ap_y, S4 s4_a_numElm)
{
	DU du_t_distance;
	DU du_t_delta;
	S4 s4_t_index;		/* 距離計算用ループのインデックス */
	
	du_t_distance = (DU)0;

	for (s4_t_index = (S4)0; s4_t_index < s4_a_numElm; s4_t_index++)
	{
		du_t_delta = fabs(du_ap_x[s4_t_index] - du_ap_y[s4_t_index]);
		du_t_distance += (du_t_delta * du_t_delta);
	}
	du_t_distance = sqrt(du_t_distance);

	return(du_t_distance);
}


S4 main()
{
	DU du_tp_x[MAX_VECTOR_ELM];
	DU du_tp_y[MAX_VECTOR_ELM];

	S4 s4_t_indexX;
	S4 s4_t_indexY;
	S4 s4_t_numElm;

	s4_t_numElm = (S4)MAX_VECTOR_ELM;

	/* xベクトルの入力 */
	for (s4_t_indexX = (S4)0; s4_t_indexX < s4_t_numElm; s4_t_indexX++)
	{
		scanf("%lf", &du_tp_x[s4_t_indexX]);
	}

	/* yベクトルの入力 */
	for (s4_t_indexY = (S4)0; s4_t_indexY < s4_t_numElm; s4_t_indexY++)
	{
		scanf("%lf", &du_tp_y[s4_t_indexY]);
	}
	printf("%f\n", du_d_calcEuclid(du_tp_x, du_tp_y, (S4)MAX_VECTOR_ELM));

	return((S4)0);
}




Measured memory_bytes: 2044
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
int dx[4]={0,0,-1,1},dy[4]={1,-1,0,0};

ll ketasum(ll a){
  ll s=0;
  while (a>0) {
    s+=(a%10);
    a/=10;
  }
  return s;
}


int main(int argc, char const *argv[]) {
  ll n,p=1,cnt=0;
  std::cin >> n;
  ll m=n;
  while(m>0){
    m/=10;
    cnt++;
  }
  for(int i=1; i<cnt; i++){
    p*=10;
  }
  std::cout << max(ketasum(n),ketasum(n-(n%p)-1)) << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	string s, c; cin >> s >> c;
	s += s;
	if (s.find(c) != string::npos) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 3248
#include<stdio.h>
int main()
{
    int a,i;
    scanf("%d",&a);
    int x[a];
    for(i=0;i<a;i++)
    {
        scanf("%d",&x[i]);
    }
    for(i=a-1;i>0;i--)
    {
        printf("%d ",x[i]);
    }
    for(i=0;i>=0;i--)
    {
        printf("%d\n",x[i]);
    }
    return 0;
}



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

int main(){
  int h,w,k;
  cin >> h >> w >> k;
  vector<vector<char>> c(h,vector<char>(w));
  vector<vector<char>> d(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> c.at(i).at(j);
    }
  }
  d=c;
  int ans=0;
  

   for (int bit = 0; bit < (1<<h+w); ++bit){
     for(int i=0;i<h;i++){
       if(bit & (1<<i)){
         for(int j=0;j<w;j++){
           d.at(i).at(j)='0';
         }
       }
     }
     for(int i=0;i<w;i++){
       if(bit & (1<<i+h)){
         for(int j=0;j<h;j++){
           d.at(j).at(i)='0';
         }
       }
     }
     
     int sum=0;
     for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(d.at(i).at(j)=='#') sum++;
      }
     }
     if(sum==k) ans++;
     d=c;
   }
  cout << ans << endl;
}

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

int main(){
  int n;
  ll ans,mi=100000000;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) {
    cin >>a[i];
  }
  for(int i =1;i<=100;i++){
    ans=0;
    rep(j,n){
      ans+=(a[j]-i)*(a[j]-i);
    }
    mi=min(mi,ans);
  }
  cout << mi << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // string c[2];
    // rep(i,2) cin>>c[i];
    char c[2][3];
    rep(i,2){
        rep(j,3){
            cin>>c[i][j];
        }
    }
    string ans = "YES";
    rep(i,2){
        rep(j, 3){
            if(c[i][j] != c[1-i][2-j]) {
                ans = "NO";
                break;
            }
        }
    }
    cout<<ans<<endl;
}

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

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

using namespace std;

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<int> v(n);
		rep(i,n) cin >> v[i];

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

		int sum = 0;
		REP(i,1,v.size()-1) {
			sum += v[i];
		}

		cout << sum / (n-2) << endl;
	}

	return 0;
}

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

int main() {
    int n,ans; string s; cin >> n >> s;
    
    for(int i=0;i<1000;i++){
        int c[3]={i/100,(i/10)%10,i%10};
        int cnt=0;
        for(int j=0;j<n;j++){
            if(s[j]-'0'==c[cnt]){
                cnt++;
                if(cnt==3){
                    break;
                }
            }
        }
        if(cnt ==3){
            ans++;
        }
    }
    cout <<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

//(ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9+7;
    int n;
    cin>>n;
    vector<P> a(n);
    rep(i,n){
        int in;
        cin>>in;
        a[i]={in,1};
    }
    sort(a.begin(),a.end());
    rep(i,1,n){
        if(a[i].first<=a[i-1].first*2){
            a[i].second+=a[i-1].second;
        }
        a[i].first+=a[i-1].first;
    }
    cout<<a[n-1].second<<endl;
}


Measured memory_bytes: 1792
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  ll N, K;
  cin >> N >> K;
  const int W = 4001;
  vector<vector<ll>> black(W, vector<ll>(W));
  for (int i = 0; i < N; i++) {
    ll x, y; char c;
    cin >> x >> y >> c;
    x %= 2 * K;
    if (c == 'W') {
      x = (x + K) % (2 * K);
    }
    y %= 2 * K;
    black[y][x]++;
    black[y][x + 2 * K]++;
    black[y + 2 * K][x]++;
    black[y + 2 * K][x + 2 * K]++;
  }

  vector<vector<ll>> acc(W + 1, vector<ll>(W + 1));
  for (int i = 0; i < W; i++) {
    for (int j = 0; j < W; j++) {
      acc[i + 1][j + 1] = acc[i + 1][j] + acc[i][j + 1] - acc[i][j] + black[i][j];
    }
  }

  ll ma = 0;
  for (int i = K; i < 3 * K; i++) {
    for (int j = K; j < 3 * K; j++) {
      ll b1 = acc[i][j] - acc[i - K][j] - acc[i][j - K] + acc[i - K][j - K];
      ll b2 = acc[i + K][j + K] - acc[i][j + K] - acc[i + K][j] + acc[i][j];
      ma = max(ma, b1 + b2);
    }
  }
  cout << ma << endl;
  return 0;
}

Measured memory_bytes: 250880
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,k,j;
    cin>>a>>b;
    k=a+b;
    j=b-a+1;
    for(int z=j;z<k;z++){
        if(z<1000000||z>-1000000){
            cout<<z<<" ";
        }
    }
    cout<<endl;
}


Measured memory_bytes: 3168
#include <cstdio>
#include <algorithm>
int a[200001];
int cmp(int a, int b){
	return a >b;
}
using namespace std;
int main(){
	
	long long n, m;
	scanf("%lld", &n);
	long long ans = 0;
	long long b = 1;
	while(n!=1){
		n /= 2;
		ans+= b;
		b = b*2;
	}
	ans+= b;
	printf("%lld", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

int main(){
    int *pos;
    int i,j,n;
    int temp;
    int position;
    string str;
    vector<int> R_stop;
    vector<int> L_stop;
    int r_pos,l_pos;

    cin >> str;
    n = str.length();
    pos = new int[n];
    for(i=0;i<n-1;i++){
        if( str[i] == 'R' && str[i+1] == 'L'){
            R_stop.push_back(i);
        }
        if( str[n-i-1] == 'L' && str[n - i - 2] == 'R'){
            L_stop.push_back(n-i-1);
        }
        pos[i] = 0;
    }
    pos[n-1] = 0;
    /*
    cout << endl;
    cout << "R" << endl;
    for(i=0;i<R_stop.size();i++){
        cout << R_stop[i] + 1 << " ";
    }
    cout << endl;
    cout << "L" << endl;
    for(i=0;i<L_stop.size();i++){
        cout << L_stop[i] + 1 << " ";
    }
    cout << endl;
    */
    for(i=0;i<n;i++){
        if( str[i] == 'R'){
            for(j=0;j<R_stop.size();j++){
                if( i <= R_stop[j] ){
                    break;
                }
            }
            temp = R_stop[j] - i;
            if( temp % 2 == 0){
                position = R_stop[j];
            }else{
                position = R_stop[j]+1;
            }
        }else{
            for(j=0;j<L_stop.size();j++){
                if( i >= L_stop[j] ){
                    break;
                }
            }
            temp = i - L_stop[j];
            if( temp % 2 == 0){
                position = L_stop[j];
            }else{
                position = L_stop[j]-1;
            }
        }
        //cout << i + 1 << " " << position + 1 << endl;
        pos[position]++;
    }
    for(i=0;i<n;i++){
        cout << pos[i] << " ";
    }
    cout << endl;
    return 0;
}


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

/*
 * bubble sort
 *  未ソートの列の後ろから、隣接する要素の順序が逆だった場合は要素の入れ替えを実施する
 *  先頭はソート済みとなる
 *  入れ替えが行われなくなったら終了
 */
int bubbleSort(vector<int>& a, int n) {
    int cnt = 0;
    int flag = 1;
    while (flag) {
        flag = 0;
        for (int j=n-1; j>0; j--) {
            if (a[j] < a[j-1]) {
                int t = a[j];
                a[j] = a[j-1];
                a[j-1] = t;
                flag = 1;
                cnt++;
            }
        }

        // for (int i=0; i<a.size()-1; i++) cout << a[i] << " ";
        // cout << a[n-1] << endl;
    }

    for (int i=0; i<a.size()-1; i++) cout << a[i] << " ";
    cout << a[n-1] << endl;

    return cnt;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++) cin >> A[i];
    // cout << "----- start -----" << endl;

    int cnt = bubbleSort(A, N);
    cout << cnt << endl;

    return 0;
}



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

using namespace std;

int a[202000];

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> cnt(n + 10, 0);
    for(int i = 1; i <= k; i++){
        int d;
        cin >> d;
        for(int j = 1; j <= d; j++){
            int c;
            cin >> c;
            cnt[c]++;
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(!cnt[i]){
            ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>  // ver1.9.5
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(8);
  int n,ans=0,qw,er;
  cin >> n;
  vector<Pii> a(n),b(n);
  rep(i,0,n) {
    cin >> qw >> er;
    a[i]=mp(qw,er);
  }
  rep(i,0,n) {
    cin >> qw >> er;
    b[i]=mp(qw,er);
  }
  sort(ALL(b));
  
  
  int maxy=-1,memo;
  
  rep(i,0,n){
    maxy = -1;
    if(b[i].first==0) continue;
    
    rep(j,0,a.size()){
      if(b[i].first > a[j].first && b[i].second > a[j].second){
        if(a[j].second>maxy) {
          memo = j;
          maxy = a[j].second;
        }
      }
    }
    
    //if(maxy!=-1)cout << a[memo].first <<' '<<b[i].first<<endl;
    
    if(maxy != -1){
      ans++;
      a.erase(a.begin()+memo);
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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

#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define sc(a) scahf("%c",&a);
#define ss(a) scanf("%s",a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pc(a) putchar(a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i, a, b) for(register int i=a;i<=b;++i)
#define repd(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int,int>
#define pll pair<long,long>
#define pil pair<int,long>
#define pli pair<long,int>
#define mii unordered_map<int,int>
#define msi unordered_map<string,int>
#define lowbit(x) ((x)&(-(x)))
#define ce(i, r) i==r?'\n':' '
#define pb push_back
#define fi first
#define se second
#define INF 0x3f3f3f3f
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;

inline int qr() {
    int f = 0, fu = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')fu = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        f = (f << 3) + (f << 1) + c - 48;
        c = getchar();
    }
    return f * fu;
}
const int N=2e5+10;
int n;
int cnt[N];
int main(){
    n=qr();
    repi(i,1,n-1){
        int x=qr();
        cnt[x]++;
    }
    repi(i,1,n)pi(cnt[i]);
    return 0;
}

Measured memory_bytes: 4472
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll> 
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N;cin>>N;
  string s;
  map<string,ll> mp;rep(i,N) {cin>>s;mp[s]++;}
  ll mx=0;
  for(auto i:mp) mx=max(mx,i.second);
  for(auto i:mp) if(mx==i.second) print(i.first);
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  if(s == "Sunny"){
    cout << "Cloudy\n";
  }
  if(s == "Cloudy"){
    cout << "Rainy\n";
  }
  if(s == "Rainy"){
    cout << "Sunny\n";
  }
  return 0;
}



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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const ll mod = 1e9 + 7;
const int inf = 1e9;

int main() {
	cin.sync_with_stdio(false);
	ll A, B, C;
	cin >> A >> B >> C;
	if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
		cout << 0 << endl;
		return 0;
	}
	cout << min(min(A*B,B*C),A*C) << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <utility>
#include <algorithm>
#include <ctime>
#include <cstdarg>
#include <sstream>
#include <functional>
using namespace std;

int const MAX_N = 512 * 1024;
long long const LL_INF = 5000000000000000000LL;

int k[50], p[50], s[50][50];

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	for (int i = 0; i < m; i++) cin >> p[i];
	int ans = 0;
	for (int code = 0; code < (1 << n); code++) {
		int cnt = 0;
		for (int i = 0; i < m; i++) {
			int sum = 0;
			for (int j = 0; j < k[i]; j++)
				if ((code >> s[i][j]) & 1) sum++;
			if (sum % 2 == p[i]) cnt++;
		}
		if (cnt >= m) ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;

long long int gcd(long long int a, long long int b){
  if( a == 0 || b == 0 ) return 0;
  long long int c;
  while( a != 0 ){
    c = a; a = b%a; b = c;
  }
  return b;
}

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  int ans = a[0];
  for(int i=1; i<n; i++){
    ans = gcd(ans, a[i]);
  }
  cout << ans << endl;

  return 0;
}


//


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if ( d >= abs(b-a) && d >=abs(c-b) || d >= abs(c-a)){
    cout << "Yes" << endl;
  }
 
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 764
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#define INF 1000000000
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll n,v,cnt=0;
  cin >> n;
  ll a[n];
  bool used[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    a[i]--;
    used[i]=false;
  }
  v=0;
  while(true){
    if(v==1){
      cout << cnt << endl;
      break;
    }else if(used[v]){
      cout <<"-1\n";
      break;
    }
    cnt++;
    used[v] = true;
    v = a[v];
  }
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  ll N,K;cin>>N>>K;
  string S;cin>>S;

  // ひっくり返す範囲はどこかの連続した0
  // 単純にひっくり返せる数が多ければいいわけではなく、結果としての長さ
  // 連続した1の数の島をカウントしていって、Kの数だけ繋げられるとする
  deque<int> row;
  char prevch;
  int cur_idx = -1;
  REP(i,N) {
    if (S[i]==prevch) {
      row[cur_idx]++;
    } else {
      prevch = S[i];
      cur_idx++;
      row.push_back(1);
    }
  }

  // 条件を統一するために、1から始まって1で終わると設定する
  if (S[0]=='0') row.push_front(0);
  if (S.back()=='0') row.push_back(0);
  int row_size = row.size();

  // もしK回で十分繋げられるなら全部
  if ((row_size-1)/2<=K) {
    OUT(N);
    return 0;
  }

  int tmp = 0;
  REP(i,K*2+1) tmp += row[i];
  int ans = tmp;
  for (int i=2;i<row_size-K*2;i+=2) {
    tmp -= row[i-2];
    tmp -= row[i-1];
    tmp += row[i+K*2];
    tmp += row[i+K*2-1];
    ans = max(ans,tmp);
  }
  OUT(ans);

  return 0;
}


Measured memory_bytes: 768
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M,K=MI()
    #2この組み合わせを全部足して，平均ぽく考える
    
    def sum2(x):
        return ((x*(x+1))//2)%mod
    
    #i,jますにいるときの相手．（i,j）よりも奥にあるやつの全組み合わせの総和
    def calc(i,j):
        temp=0
        temp=sum2(M-j-1)#該当する行
        temp=(temp+((sum2(M-j-1)+sum2(j))*(N-i-1)))%mod#下の行の階差部分，左右方向にあるから
        temp=(temp+sum2(N-i-1)*M)%mod
        return temp
        
    S=0
    for i in range(N):
        for j in range(M):
            S=(S+calc(i,j))%mod
            
    rem=(N*M)-2
    
    def cmb(n, r, mod):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return (fact[n] * factinv[r] * factinv[n-r])%mod

    fact=[1,1]
    factinv=[1,1]
    inv=[0,1]
    
    for i in range(2, rem + 1):
        fact.append((fact[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod // i)) % mod)
        factinv.append((factinv[-1] * inv[-1]) % mod)  
        
    #print(rem,K-2)
    S=(S*cmb(rem,K-2,mod))%mod
            
    print(S)

main()


Measured memory_bytes: 81904
#include <bits/stdc++.h>
using namespace std;
int main(){
    char s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    int ans = 0;
    if (s1 == '1') ans = ans + 1;
    if (s2 == '1') ans = ans + 1;
    if (s3 == '1') ans = ans + 1;
    cout << ans ;
}

Measured memory_bytes: 256
#include <stdio.h>
long long x, k, d;
int main() {
	scanf("%lld%lld%lld", &x, &k, &d);
	if (x < 0)x = -x;
	if (x / d >= k) {
		printf("%lld\n", x - d * k);
		return 0;
	}
	if ((x / d + k) % 2) {
		printf("%lld\n", (x / d + 1) * d - x);
	}
	else {
		printf("%lld\n", x - x / d * d);
	}
}

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

int cmp(const void* p, const void* q) {
	return *(int*)q - *(int*)p;
}
int main(void) {
	int n;
	int a[200000] = { 0 };
	int temp[200000] = { 0 };

	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]),temp[i]=a[i];
	qsort(temp, n, sizeof(int), cmp);
	for (int i = 0; i < n; i++) {
		if (a[i] == temp[0]) printf("%d\n", temp[1]);
		else printf("%d\n", temp[0]);
	}
	return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main() {
 
  
  vector<vector<int>> A(3, vector<int>(3));
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> A.at(i).at(j);
    }
  }
  
  int N; cin >> N;
  bool bingo = 0;
  for(int i=0; i<N; i++){
    int b = 0;
    cin >> b;
    for(int j=0; j<3; j++){
      for(int k=0; k<3; k++){
        if(b == A.at(j).at(k)){
          A.at(j).at(k) = 0;
          break;
        }
      }
    }
    if(A.at(0).at(0) == 0 && A.at(0).at(1) == 0 && A.at(0).at(2) == 0 || 
       A.at(1).at(0) == 0 && A.at(1).at(1) == 0 && A.at(1).at(2) == 0 ||
       A.at(2).at(0) == 0 && A.at(2).at(1) == 0 && A.at(2).at(2) == 0 ||
       A.at(0).at(0) == 0 && A.at(1).at(0) == 0 && A.at(2).at(0) == 0 ||
       A.at(0).at(1) == 0 && A.at(1).at(1) == 0 && A.at(2).at(1) == 0 ||
       A.at(0).at(2) == 0 && A.at(1).at(2) == 0 && A.at(2).at(2) == 0 ||
       A.at(0).at(0) == 0 && A.at(1).at(1) == 0 && A.at(2).at(2) == 0 ||
       A.at(0).at(2) == 0 && A.at(1).at(1) == 0 && A.at(2).at(0) == 0 ){
      bingo = 1;
      break;
    }
  }
    
  if(bingo) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  int N;
  int sum=0;
  cin>>N;
  for(int i=0;i<N;i++){
	int l,r;
    cin>>l>>r;
    sum+=r-l+1;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    String s = sc.next();
    int ok = a + b;
    int ok_b = b;
    for (int i = 0; i < n; i++) {
      if (s.charAt(i) == 'a' && ok != 0) {
        System.out.println("Yes");
        --ok;
      } else if (s.charAt(i) == 'b' && ok != 0 && ok_b != 0) {
        System.out.println("Yes");
        --ok_b;
        --ok;
      } else {
        System.out.println("No");
      }
    }
    sc.close();
  }
}


Measured memory_bytes: 50228
#include "bits/stdc++.h"

using namespace std;

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

	for(int i = 1;i <= n;i++){
		int h = 0;
		int o = 0;
		int sc = 0;
		string a;
	while(1){
		cin >> a;
		if(a == "HIT"){
			h++;
		}
		if(a == "OUT"){
			o++;
		}
		if(a == "HOMERUN"){
			sc = sc + h + 1;
			h = 0;
		}
		if(o == 3) break;
		if(h == 4){
			sc++;
			h--;
		}
	}
		cout << sc <<endl;
	}



	return 0;
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define pie 3.1415926
int ara[200020],ara2[200020];
int main()
{
  int n,i;
  cin>>n;
  for(i=2;i<=n;i++)
  {
    cin>>ara[i];
    ara2[ara[i]]++;
  }
  for(i=1;i<=n;i++)
    cout<<ara2[i]<<endl;


    return 0;
}


Measured memory_bytes: 5140
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;

const int MAX_N=1 << 19;

int nn,dat[2*MAX_N-1];

void init(int n_){
    nn=1;
    while (nn<n_) nn*=2;
    for (int i=0;i<2*nn-1;i++) dat[i]=inf;
 }

 void update(int k,int a){
     k+=nn-1;
     dat[k]=a;
     while(k>0){
         k=(k-1)/2;
         dat[k]=min(dat[k*2+1],dat[k*2+2]);
     }
 }

 int query(int a,int b,int k,int l,int r){
     if (r<=a || b<=l) return inf;
     if (a<=l && r<=b) dat[k];
     else {
         int vl=query(a,b,k*2+1,l,(l+r)/2);
         int vr=query(a,b,k*2+2,(l+r)/2,r);
         return max(vl,vr);
     }
 }

int main() {
    int n,m;
    cin >> n >> m;
    priority_queue<ll> q;
    rep(i,n){
        ll f;
        cin >> f;
        q.push(f);
    }
    rep(i,m){
        ll f=q.top();
        q.pop();
        q.push(f/2);
    }
    ll ans=0;
    rep(i,n){
        ll f=q.top();
        q.pop();
        ans+=f;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int N,K,X,Y;
int main(){
    cin>>N>>K>>X>>Y;

    if(N<=K){
        cout<<X*N<<endl;
    }
    else if(N>K){
        cout<<X*K+Y*(N-K)<<endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  string S;
  cin >> N >> S;

  int count1=0;
  int count2=0;

  int tmp=0;
  REP(i, S.size()){
    if(S[i]=='(') tmp--;
    else tmp++;
    count1 = max(count1, tmp);
  }
  tmp=0;
  REP(i, S.size()){
    if(S[S.size()-1-i]==')') tmp--;
    else tmp++;
    count2 = max(count2, tmp);
  }

  REP(i, count1){
    S = '(' + S;
  }
  REP(i, count2){
    S = S + ')';
  }

  cout << S << "\n";

  return 0;
}

Measured memory_bytes: 256
import numpy as np
import math
def num2alpha(num):
    if num<=26:
        return chr(96+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(122)
    else:
        return num2alpha(num//26)+chr(96+num%26)
N = int(input())
print(num2alpha(N))

Measured memory_bytes: 27168
#include <bits/stdc++.h>
#define int long long
#define double long double
const int INF = (int)1e18 + 18;
const int maxn = (int) 1e6 + 6; 
using namespace std;

int n, m, sum = 0;
vector<int> vec[maxn];
priority_queue<int> pq;

signed main() {

	cin >> n >> m;

	for(int i = 0; i < n; i++){
		int day, points;
		cin >> day >> points;
		vec[day].push_back(points);
	}

	for(int i = 1; i <= m; i++){
		for(int j = 0; j < (int) vec[i].size(); j++){
			pq.push(vec[i][j]);
		}
 
		if(!pq.empty()){
			sum += pq.top();
			pq.pop();
		}
	}


	cout << sum << endl;



	return 0;

}


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


int main()
{
	ll n,k;cin>>n>>k;ll a[200009];
	for(ll i=1;i<=n;i++) cin>>a[i];
	
	vector <ll> f(200009,-1);
	
	ll cnt=0;ll pos=1;ll cy;f[1]=0;
	while(cnt<k)
	{
		++cnt;pos=a[pos];
		if(f[pos]!=-1) {cy=cnt-f[pos];break;}
		f[pos]=cnt;
		
	}
	ll rem=k-cnt;//cout<<cy<<" ";
	
	if(rem>0)
	{
		for(ll i=1;i<=rem%cy;i++)pos=a[pos];
	}
	cout<<pos;
		
}


Measured memory_bytes: 6424
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
 
using namespace std;
 
#define rep(n,m) for(int i = n; i < m; i++)
 
int main(void) {
 
	string str = "";
	cin >> str;
	int begin = 0;
	int end = str.length() - 1;
	bool ok = true;
	int count = 0;
	
		while ( begin < end) {
			if (str[begin] == str[end]) {
				begin++;
				end--;
			}
			else if (str[begin] == 'x') {
				if (end == str.length() - 1) {
					str += "x";
					count++;
				}
				else
				{
					str.insert(end + 1, "x");
					count++;
				}
				begin++;
			}
			else if (str[end] == 'x') {
				str.insert(begin, "x");
				count++;
				begin++;
			}
			else {
				ok = false;
				break;
			}
		}
		if (!ok) cout << -1 << endl;
		else cout << count << endl;
		//oaxox
	
}

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

void Main() {
    int n, Q;
    cin >> n >> Q;
    vector<long long> a(n);
    rep(i, n) cin >> a[i];
    rep(j, Q) {
        long long x;
        cin >> x;
        long long ans = 0;
        int right = 0;
        long long total = 0;
        rep(left, n) {
            while (right < n && total + a[right] <= x) {
                total += a[right];
                ++right;
            }
            ans += right - left;
            if (left == right) {
                right++;
            } else {
                total -= a[left];
            }
        }
        cout << ans << endl;
    }
}
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 3540
from collections import Counter

N=int(input())
D=Counter((list(map(int,input().split()))))
M=int(input())
T=Counter((list(map(int,input().split()))))

for difficult,count in T.items():
    if difficult in D and D[difficult]>=count:
        pass
    else:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 55588
#include <stdio.h>

int main(void);

int main(void)
{
    int a ,b;

/* 標準入力から1つの整数を変数xに読み込む ⇒ scanf("%d", &x); */
    scanf("%d", &a);
    scanf("%d", &b);
    printf("%d ", a * b);
    printf("%d\n", 2 *(a + b));

    return(0);
}


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

int main(){
    int a,b,c;
    char op;
    cin>>a>>op>>b;
    while(op!='?'){
        if(op=='+')
            c=a+b;
        if(op=='-')
            c=a-b;
        if(op=='*')
            c=a*b;
        if(op=='/')
            c=a/b;
        cout<<c<<endl;
        cin>>a>>op>>b;
    }
}


Measured memory_bytes: 3104