akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main(){
		new AOJ1186().doIt();
	}
	
	class AOJ1186{
		void doIt(){
			ArrayList<Data> list = new ArrayList<Data>();
			for(int h=1;h<=160;h++)for(int w=h+1;w<=160;w++)list.add(new Data(h, w));
			Collections.sort(list);
			while(in.hasNext()){
				int h = in.nextInt();
				int w = in.nextInt();
				if(h+w==0)break;
				for(int i=0;i<list.size();i++){
					if(list.get(i).h==h&&list.get(i).w==w){
						System.out.println(list.get(i-1).h+" "+list.get(i-1).w);break;
					}
				}
			}
		}
		
		class Data implements Comparable<Data>{
			int h,w;
			public Data(int h,int w){
				this.w = w;
				this.h = h;
			}
			public int compareTo(Data o) {
				if(w*w+h*h<o.w*o.w+o.h*o.h)return 1;
				else if(w*w+h*h>o.w*o.w+o.h*o.h)return -1;
				else if(this.h < o.h)return 1;
				else if(this.h > o.h)return -1;
				return 0;
			}
		}
		
	}
	
}

Measured memory_bytes: 35152
n = gets.to_i
S = gets.split(' ').map(&:to_i)
q = gets.to_i
T = gets.split(' ').map(&:to_i)

count = 0
T.each do |t|
  S.each do |s|
    if t == s
      count += 1
      break
    end
  end
end

puts count


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

struct Restaurant{
    int id;
    int p;
    string s;
};

int main(void){
    int n;
    cin >> n;
    vector<Restaurant> r(n);
    int id = 1;
    for(auto& i : r){
        cin >> i.s;
        cin >> i.p;
        i.id = id;
        id++;
    }
    sort(r.begin(), r.end(), [](const auto& i, const auto& j){
        if(i.s == j.s) return i.p > j.p;
        else return i.s < j.s;});
    for(auto i : r){
        cout << i.id << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,j,n,u,k,v;
  scanf("%d",&n);
  int HAKO[n][n];
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      HAKO[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      if(k==0) break;
      scanf("%d",&v);
      HAKO[u-1][v-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j==n-1) printf("%d",HAKO[i][j]);
      else printf("%d ",HAKO[i][j]); 
    }
    printf("\n");
  }
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
 
#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define debug(x) cerr << #x " = " << (x) << '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
 
lli MOD  = 1000000007;
lli inf = 1e15;
 
void scan(scantype &x);

lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

bool isprime(long long int n)
{
    if(n ==1 )
        return false;
    if(n == 2)
        return true;
    for(long long int i =2;i<=n/i;i++)
    {
        if(n%i == 0)
            return false;
    }
    return true;
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    int t;
    t = 1;
    while(t--)
    {

        int n;
        cin>>n;
        int a[n];
        for(int i = 0;i<n;i++)
            cin>>a[i];
        for(int i = n-1;i>=0;i-=2)
        {
            cout<<a[i]<<" ";
        }
        if(n%2)
        {
            for(int i = 1;i<n;i+=2)
                cout<<a[i]<<" ";
        }
        else
            for(int i = 0;i<n;i+=2)
                cout<<a[i]<<" ";
    }    


    
    return 0;    
}
 

void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}


Measured memory_bytes: 2944
def calc_bit(x):
    i = idx = 0
    if x < 0:
        x = -x
        i = 2
        idx = 1
    else:
        i = 1
        idx = 0
    p = i
    while True:
        if x <= p:
            return idx
        else:
            i *= 4
            p += i
            idx += 2


ans = ""
N = int(input())
pv = -1
f = False
if N == 0:
    ans = "0"
else:
    while True:
        v = calc_bit(N)
        if pv-v > 1 and f:
            ans += "0"*(pv-v-1)
        ans += "1"
        N -= (-2)**v
        if N == 0:
            if v > 0:
                ans += "0"*v
            break
        f = True
        pv = v
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

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

    int n; cin >> n;
    vector<int> hit(n);
    bool ok = true;
    rep(i,n) {
        cin >> hit[i];
        if (i == 0) continue;
        if (hit[i-1] <= hit[i]-1) hit[i]--;
        if (hit[i-1] > hit[i]) {
            ok = false;
            break;
        }
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
map<int, bool> undesirable_numbers;
bool Check(int n) {
  string s = to_string(n);
  REP(i,s.size()) {
    if(undesirable_numbers[(s[i]-'0')]) return false;
  }
  return true;
}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  int k = in();
  // REP(i,10) {
  //   undesirable_numbers[i] = false;
  // }
  REP(i,k) {
    int num = in();
    undesirable_numbers[num] = true;
  }
  while(!Check(n)) {
    ++n;
  }
  cout << n;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
'use strict';
function Main(stdin) {
  var line = stdin.split('\n');
  var result = (function(data) {
  	var tmp = [];
  	var index = 0;
		while (data[index] !== 0) {
			tmp.push('Case ' + (index + 1) + ': ' + data[index++]);
		}
    return tmp.join('\n');
  }(
    line.map(Number)
  ));
  console.log(result);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 10884
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
ll H, W, h, w;

int main()
{
	cin >> H >> W >> h >> w;
	cout << (H - h) * (W - w) << endl;
	int www;
	cin >> www;
}

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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int a[n][m], b[m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  int ans;
  for (int i = 0; i < n; i++) {
    ans = 0;
    for (int j = 0; j < m; j++) {
      ans += a[i][j] * b[j];
    }
    cout << ans << '\n';
  }
  return 0;
}


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

using namespace std;

int main() {
    int n, m; cin >> n >> m;
    vector<int> xs(m);
    for(int i = 0; i < m; i++) {
        cin >> xs[i];
    }
    sort(xs.begin(), xs.end());

    vector<int> ds;
    for (int i = 0;i < xs.size() - 1; i++) {
        ds.push_back(xs[i + 1] - xs[i]);
    }
    sort(ds.begin(), ds.end());
    reverse(ds.begin(), ds.end());

    if (n >= m) {
        cout << 0 << endl;
        return 0;
    }

    int ad = xs.back() - xs.front();
    for (int i = 0; i < n - 1; i++) {
        ad -= ds[i];
    }
    cout << ad << endl;

    return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 65
#define MAX 3000

struct Info{
	Info(int arg_value){

		value = arg_value;
	}

	bool operator<(const struct Info &arg) const{
		return value > arg.value;
	}
	int value;
};

int N,K;
vector<Info> vec_A,vec_RED,vec_BLACK;
int A[SIZE],RED[SIZE],BLACK[SIZE];
int ruiseki_A[SIZE],ruiseki_RED[SIZE],ruiseki_BLACK[SIZE];
int dp[SIZE][SIZE][3005];


int main(){

	scanf("%d %d",&N,&K);

	int tmp;

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

		scanf("%d",&tmp);
		vec_A.push_back(Info(tmp));
	}

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

	ruiseki_A[0] = 0;
	for(int i = 1; i <= N; i++){

		A[i] = vec_A[i-1].value;
		ruiseki_A[i] = A[i];
		ruiseki_A[i] += ruiseki_A[i-1];
	}

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

		scanf("%d",&tmp);
		vec_RED.push_back(Info(tmp));
	}

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

	ruiseki_RED[0] = 0;
	for(int i = 1; i <= K; i++){

		RED[i] = vec_RED[i-1].value;
		ruiseki_RED[i] = RED[i];
		ruiseki_RED[i] += ruiseki_RED[i-1];
	}

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

		scanf("%d",&tmp);
		vec_BLACK.push_back(Info(tmp));
	}

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

	ruiseki_BLACK[0] = 0;
	for(int i = 1; i <= K; i++){

		BLACK[i] = vec_BLACK[i-1].value;
		ruiseki_BLACK[i] = BLACK[i];
		ruiseki_BLACK[i] += ruiseki_BLACK[i-1];
	}

	for(int i = 0; i <= N; i++){
		for(int k = 0; k <= K; k++){
			for(int p = 0; p <= MAX; p++){
				dp[i][k][p] = BIG_NUM;
			}
		}
	}

	dp[0][0][0] = 0;

	for(int i = 1; i <= N; i++){
		for(int r = 0; r <= K; r++){
			for(int num = 0; num <= MAX; num++){

				if(dp[i-1][r][num] == BIG_NUM)continue;

				int add;

				if(r < K){

					add = max(0,A[i]-RED[r+1]);
					dp[i][r+1][num+A[i]] = min(dp[i][r+1][num+A[i]],dp[i-1][r][num]+add);
				}

				if(i-r >= 1 && i-r <= K){

					add = max(0,A[i]-BLACK[i-r]);
					dp[i][r][num] = min(dp[i][r][num],dp[i-1][r][num]+add);
				}
			}
		}
	}

	int ans = BIG_NUM;
	int total_A = ruiseki_A[N];
	int need_red;
	int need_black;

	for(int i = 0; i <= K; i++){
		for(int num = 0; num <= MAX; num++){

			if(dp[N][i][num] == BIG_NUM)continue;

			need_red = num;

			if(ruiseki_RED[K] < need_red){

				continue;
			}

			if(num == total_A){
				ans = min(ans,dp[N][i][num]);
				continue;
			}

			if(N-i < 0 || N-i > K)continue;

			need_black = total_A-num;

			if(ruiseki_BLACK[K] < need_black){

				continue;
			}

			ans = min(ans,dp[N][i][num]);
		}
	}


	if(ans == BIG_NUM){

		printf("-1\n");

	}else{

		printf("%d\n",ans);
	}

	return 0;
}



Measured memory_bytes: 47164
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;

typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

long long int MOD = 1000000007;
int N;
int main(){
	cin>>N;
	vi p;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;a--;
		p.pb(a);
	}
	p.pb(0);
	int ans=0;
	for(int i=0;i<N;i++){
		if(i==p[i]){
			int temp=p[i+1];
			p[i+1]=p[i];
			p[i]=temp;
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 892
S = list(input())
S = set(S)
alpha = [chr(ord('a') + i) for i in range(26)]
alpha = set(alpha)
anset = alpha - S
anset = sorted(list(anset))

if len(anset) != 0:
    ans = anset[0]
    print(ans)
else:
    print("None")

Measured memory_bytes: 3956
#include <stdio.h>

int main(void) {
	int count[26] = {0};
	char w[128];
	int i;
	if (scanf("%127s", w) != 1) return 1;
	for (i = 0; w[i] != '\0'; i++) {
		count[w[i] - 'a']++;
	}
	for (i = 0; i < 26; i++) {
		if (count[i] % 2 != 0) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 128
from string import ascii_lowercase
n=int(input())
s=[]
for i in range(n):
  s.append(input())
ans={}
for i in ascii_lowercase:
  ans[i]=s[0].count(i)
for i in range(1,n):
  for j in ascii_lowercase:
    ans[j]=min(ans[j],s[i].count(j))
a=""
for i in ascii_lowercase:
  a+=i*ans[i]
print(a)

Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P2;
vector<P> kn[1005];
bool used[1005];
ll mincost[1005]={0};
bool dfs(ll pos,ll goal){
  if(pos==goal) return true;
  for(int i=0;i<kn[pos].size();i++){
    ll to=kn[pos][i].first;
    if(!used[to]){
      used[to]=true;
      if(dfs(to,goal)) return true;
    }
  }
  return false;
}
int main(){
  ll n,m;
  cin>>n>>m;
  for(int i=1;i<=m;i++){
    ll s,t,cos;
    cin>>s>>t>>cos;
    kn[s].push_back(P(t,-cos));
  }
  ll gs=0;
  vector<P2> node;
  for(int i=1;i<=n;i++){
    for(int j=0;j<1005;j++) used[j]=false;
    used[i]=true;
    if(dfs(i,n)){
      for(int j=0;j<kn[i].size();j++) node.push_back(P2(i,kn[i][j]));
      gs++;
    }
  }
  for(int i=2;i<=1005;i++) mincost[i]=17441744174417;
  int cnt=0;
  while(1){
    bool upd=false;
    for(int i=0;i<node.size();i++){
      ll s=node[i].first,t=node[i].second.first,cos=node[i].second.second;
      if(mincost[s]+cos<mincost[t]){
        upd=true;
        mincost[t]=mincost[s]+cos;
      }
    }
    cnt++;
    if(!upd) break;
    if(upd&&cnt>=gs){
      cout<<"inf"<<endl;
      return 0;
    }
  }
  cout<<mincost[n]*-1<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define rall(v)     (v).rbegin(),(v).rend()
#define gcd(a,b)    __gcd((a),(b))
#define fill(a,value) memset(a,value,sizeof(a));
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
#define sum(v)+x    accumulate(v.begin(), v.end(),x);
typedef pair<int,int> pii;  
typedef vector<int> vi;
signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int n;
    cin>>n;
    if(n%2==1)print(n/2)
    else print(n/2-1)
 
    
    return 0;
}

Measured memory_bytes: 3624
h,w=map(int,input().split())
a=[list(map(int,input().split()))for i in range(10)]
b=[list(map(int,input().split()))for i in range(h)]
for h in range(10):
    for i in range(10):
        for j in range(10):
            if a[i][j]>a[i][h]+a[h][j]:
                a[i][j]=a[i][h]+a[h][j]
print(sum([sum([a[d][1] if d>=0 else 0 for d in i])for i in b]))

Measured memory_bytes: 3316
from itertools import accumulate


N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

# 累積和
B = [0] + A
B = list(accumulate(B))

ans = []
for i in range(N-K+1):
    ans.append(B[i+K]-B[i])

print((max(ans)+K)/2)


Measured memory_bytes: 27076
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
map<lli,lli>mp;
map<string,lli>mps;
map<char,lli>mpc;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> S;
  A=B=C=0;
  rep(i,0,N){
    if(S[i]=='R')A++;
    else if(S[i]=='G')B++;
    else C++;
  }
  DV(P,lli,3,N,0);
  rep(i,0,N){
    if(i>0)rep(j,0,3)P[j][i]+=P[j][i-1];
    if(S[i]=='R')P[0][i]++;
    else if(S[i]=='G')P[1][i]++;
    else P[2][i]++;
  }
  rep(i,0,N-2)rep(j,i+1,N-1){
    if(S[i]!=S[j]&&S[i]!='B'&&S[j]!='B'){
      if(j+j-i<N&&S[j+j-i]=='B')sum--;
      sum+=C-P[2][j];
    }
    else if(S[i]!=S[j]&&S[i]!='G'&&S[j]!='G'){
      if(j+j-i<N&&S[j+j-i]=='G')sum--;
      sum+=B-P[1][j];
    }
    else if(S[i]!=S[j]&&S[i]!='R'&&S[j]!='R'){
      if(j+j-i<N&&S[j+j-i]=='R')sum--;
      sum+=A-P[0][j];
    }
  }
  Out(sum);
}

Measured memory_bytes: 3784
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

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

// 少し多めに確保すること
// ぴったりだと正しく動かないので注意
const long long MAX_V = 1010101;

struct edge {
  long long to, cost;
};

using Pll = pair<long long, long long>;

long long V;
vector<edge> Graph[MAX_V];
long long dist[MAX_V];

void dijkstra(long long s) {
  priority_queue<Pll, vector<Pll>, greater<Pll>> que;

  // 0-indexedと1-indexedの両方に対応
  fill(dist, dist + MAX_V, INF);

  dist[s] = 0;
  que.push(Pll(0, s));

  while (!que.empty()) {
    auto elem = que.top();
    que.pop();

    auto cv = elem.second;

    if (elem.first > dist[cv]) {
      continue;
    }

    for (auto e : Graph[cv]) {
      if (dist[e.to] > dist[cv] + e.cost) {
        dist[e.to] = dist[cv] + e.cost;
        que.push(Pll(dist[e.to], e.to));
      }
    }
  }
}

ll N;
ll dist1[MAX_V], distN[MAX_V];

int main() {
  cin >> N;
  V = N;
  rep(i, 1, N) {
    ll a, b;
    cin >> a >> b;
    Graph[a].push_back(edge{b, 1});
    Graph[b].push_back(edge{a, 1});
  }

  dijkstra(1);
  repe(i, 1, N) { dist1[i] = dist[i]; }

  dijkstra(N);
  repe(i, 1, N) { distN[i] = dist[i]; }

  ll fenec = 0;
  repe(i, 1, N) {
    if (dist1[i] <= distN[i]) {
      ++fenec;
    }
  }

  ll snuke = N - fenec;

  if (fenec > snuke) {
    cout << "Fennec";
  } else {
    cout << "Snuke";
  }
}


Measured memory_bytes: 41736
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int mod = 1e9+7;

ll mpow(ll a, ll n){
    return n ? (n%2 ? mpow(a,n-1)*a%mod : mpow(a*a%mod,n/2)) : 1;
}

int main(){
    //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
    
    int m, n;
    cin>>m>>n;
    ll ans = 0;
    vector<ll> d(n+1);
    for(int i=n;i>=1;--i){
        ll x = mpow(n/i, m);
        for(int j=i*2;j<=n;j+=i) x-=d[j];
        x = (x%mod + mod) %mod; 
        d[i] = x;
        ans+=x*i;
        ans%=mod;
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3960
#include<bits/stdc++.h>
#define ll long long 
#define fast cin.sync_with_stdio(false);
using namespace std;


int main()
{
 

	int n,k;cin>>n>>k;
	int arr[n];
	for (int i=0;i<n;i++)cin>>arr[i];

	int dp[n];
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for (int i=2;i<n;i++)
	{
		int ans=INT_MAX;
		for (int j=i-1;j>=i-k;j--)
		{
			if (j>=0)
			{
				ans=min(ans,abs(arr[i]-arr[j])+dp[j]);
			}
			else
				break;
		}
		dp[i]=ans;
	}


	cout<<dp[n-1];


}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(m), c(m, 0);
    REP(i, 0, m) {
        int b;
        cin >> a[i] >> b;
        REP(j, 0, b) {
            int t;
            cin >> t;
            c[i] |= (1 << (t - 1));
        }
    }

    const ll inf = 1LL << 60;
    auto dp = make_v(m + 1, 1 << n, inf);
    dp[0][0] = 0;
    REP(i, 0, m) {
        REP(j, 0, 1 << n) {
            chmin(dp[i + 1][j], dp[i][j]);
            if ((j & c[i]) != c[i]) continue;
            for (int k = c[i];; k = (k - 1) & c[i]) {
                int t = j - k;
                chmin(dp[i + 1][j], dp[i][t] + a[i]);
                if (k == 0) break;
            }
        }
    }
    ll ans = dp[m][(1 << n) - 1];

    if (ans == inf) {
        ans = -1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 32384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}

char s[N],t[N];
int dp[10000][10000];

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	scanf("%s %s",s+1,t+1);
	int len1=strlen(s+1);
	int len2=strlen(t+1);

	for(int i=1;i<=len1;++i){
		for(int j=1;j<=len2;++j){
			if(s[i]==t[j]) dp[i][j]=dp[i-1][j-1]+1;
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}

	int i=len1,j=len2;
	char ans[N];
	int cnt=0;
	while(dp[i][j]){
		if(s[i]==t[j]){
			ans[++cnt]=s[i];
			i--;
			j--;
		}
		else if(dp[i][j]==dp[i-1][j]) i--;
		else if(dp[i][j]==dp[i][j-1]) j--;
	}

	for(int i=cnt;i>=1;--i) printf("%c",ans[i]);

    return 0;
}

Measured memory_bytes: 50740
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (A, B) = Slice2<long>();
            if (B % A == 0)
                WriteLine(A + B);
            else
                WriteLine(B - A);
        }


        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 27536
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
int a, b, c;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a>>b>>c;
    if(a<c&&c<b){
        cout << "Yes" << "\n";
        return 0;
    }
    if(b<c&&c<a){
        cout << "Yes" << "\n";
        return 0;
    }

    cout << "No" << "\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){

    int a,b;

    cin >> a >> b;

    if(a > 0)cout << "Positive";
    else if(a <= 0 && b >= 0)cout << "Zero";
    else if((b - a) % 2 == 0)cout << "Negative";
    else cout << "Positive";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
int n, m;
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> m;
 	priority_queue <int> q;
	for(int i=1; i<=n; i++)
	{
		int x;
		cin >> x;
		q.push(x);
	}
	while(m-- && sz(q))
	{
		int x = q.top(); q.pop();
		x /= 2;
		if(x) q.push(x);
	}
	ll sum = 0;
	while(sz(q))
	{
		sum += q.top();
		q.pop();
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)

struct el {
	ll to,cost,w;
};

ll n,m,s;
vector<el> adj[55];
ll dst[55][3001];
ll c[55], d[55];


int main() {
	IO;
	cin>>n>>m>>s;
	for(int i=0;i<m;++i) {
		int u,v,a,b;
		cin>>u>>v>>a>>b;
		adj[u].pb({v,a,b});
		adj[v].pb({u,a,b});
	}
	
	for(int i=1;i<=n;++i) {
		cin>>c[i]>>d[i];
		fill(dst[i],dst[i]+3001, 1LL<<60);
	}
	
	priority_queue<array<ll,3>, vector<array<ll,3>>, greater<array<ll,3>>> pq;
	s=min(s,3000LL);
	dst[1][s]=0;
	pq.push({0,1,s});
	while(!pq.empty()) {
		auto tp=pq.top();
		pq.pop();
		if(dst[tp[1]][tp[2]]<tp[0]) {
			continue ;
		}
		
		for(auto i:adj[tp[1]]) {
			array<ll,3> st={i.w+tp[0], i.to, tp[2]-i.cost};
			if(st[2]>=0 && dst[st[1]][st[2]]>st[0]) {
				dst[st[1]][st[2]]=st[0];
				pq.push(st);
			}
		}
		
		array<ll,3> st={tp[0]+d[tp[1]], tp[1], tp[2]+c[tp[1]]};
		st[2]=min(st[2], 3000LL);
		if(dst[st[1]][st[2]]>st[0]) {
			dst[st[1]][st[2]]=st[0];
			pq.push(st);
		}
	}
	
	
	for(int i=2;i<=n;++i) {
		cout<<*min_element(dst[i],dst[i]+3001)<<"\n";
	}
	
	return 0;
}


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

signed main(void){
    long long N;
    cin >> N;
    
    long long Ans = 0;
    for(int i=1;i<=N;i++){
        long long num = ((N/i)*(N/i + 1) / 2);
        num *= i;
        Ans += num;
    }
    
    cout << Ans << endl;
    
    return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll n=s.size();
  ll a=0,b=0;
  ll ans=0;
  rep(i,n){
    if(s[i]=='1') a++;
    else b++;
    if(a>0&&b>0){
      ans+=2;
      a--,b--;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b,a||b){
    vector<vector<double> >in(a,vector<double>(a));
    rep(i,a)rep(j,a)cin>>in[i][j];
    vector<vector<double> >out(b,vector<double>(a));
    rep(i,a)out[0][i]=1.0;
    rep(i,b-1){
      rep(j,a){
	double max1=0;
	rep(k,a)if(max1<out[i][k]*in[k][j])max1=out[i][k]*in[k][j];
	out[i+1][j]=max1;
      }
    }
    double max1=0;
    rep(i,a)if(max1<out[b-1][i])max1=out[b-1][i];
    //double tmp=max1*100-(int)(max1*100);
    //printf("%.3f\n",tmp);
    //if(tmp-0.50>=-ESP)max1+=0.01;
    printf("%.2f\n",max1);
  }
}

Measured memory_bytes: 1356
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <deque> 

using namespace std;


char s[550];

bool isYear(int num)
{
	if (0 <= num)
		return true;
	else
		return false;
}

bool isMonth(int num)
{
	if ((1 <= num) && (num <= 12))
		return true;
	else
		return false;
}

int main()
{
	scanf("%s", s);
	int a, b;
	a = (s[0] - '0') * 10 + (s[1] - '0');
	b = (s[2] - '0') * 10 + (s[3] - '0');
	
	bool isYYMM = false;
	if (isYear(a) && isMonth(b))
		isYYMM = true;
		
	bool isMMYY = false;
	if (isMonth(a) && isYear(b))
		isMMYY = true;
		
	if (isYYMM && isMMYY)
	{
		printf("AMBIGUOUS\n");
		return 0;
	}
	
	if (isYYMM)
	{
		printf("YYMM\n");
		return 0;
	}
	
	if (isMMYY)
	{
		printf("MMYY\n");
		return 0;
	}
	
	printf("NA\n");
	
	return 0;
}



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

int main(){
	int n; cin>>n;
	n++;
	vector<int> v(n); int sum=0;
	for(int i=1; i<n; i++) {cin>>v[i]; sum+=v[i];}
	int m; cin>>m;
	rep(i,m){
		int p,x; cin>>p>>x;
		cout<<sum-(v[p]-x)<<endl;
	}
}

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

#define MAXN 3005
#define int long long
#define LL long long
#define pii pair<int, int>
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

using namespace std;

string s, t;
int dp[MAXN][MAXN];
pii pre[MAXN][MAXN];

signed main() {
    cin >> s >> t;
    int ns = s.size(), nt = t.size();
    for (int i = 0; i < ns; i++) {
        for (int j = 0; j < nt; j++) {
            if (s[i] == t[j]) {
                dp[i+1][j+1] = dp[i][j] + 1;
                pre[i+1][j+1] = {i, j};
            } else {
                dp[i+1][j+1] = dp[i+1][j];
                pre[i+1][j+1] = {i+1, j};
                if (dp[i][j+1] > dp[i+1][j+1]) {
                    dp[i+1][j+1] = dp[i][j+1];
                    pre[i+1][j+1] = {i, j+1};
                }
            }
        }
    }
    pii p = {ns, nt};
    string res;
    while (p.fi + p.se) {
        pii np = pre[p.fi][p.se];
        if (np.fi == p.fi - 1 && np.se == p.se - 1) res.push_back(s[p.fi-1]);
        p = np;
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 211840
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#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 REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    cin >> n >> m >> k >> s;
    REP(i,s.size()){
        if(cnt<m+k){
            if(s[i]=='a'){
                cout << "Yes" << endl;
                cnt++;
            }else if(s[i]=='b'){
                if(sum<k){
                    cout << "Yes" << endl;
                    cnt++;
                    sum++;
                }else{
                    cout << "No" << endl;
                }
                
            }else{
                cout << "No" << endl;
            }
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

void solve(int a, int b, int c) {
	int sum = a + b;
	float prob = 0.0f;
	for (int n = 1; n <= 10; n++) {
		if (n == a || n == b || n == c) continue;
		if (sum + n <= 20) prob += 1.0f / 7.0f;
	}
	if (prob >= 0.5f)
		cout << "YES" << endl;
	else 
		cout << "NO" << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	while (cin >> a >> b >> c)
		solve(a, b, c);

}

Measured memory_bytes: 1184
#include <iostream>
using namespace std;
int main(){
    int a,b,c,tmp;
    cin >> a >> b >> c;
    if (a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    if(b>c){
        tmp=c;
        c=b;
        b=tmp;
    }
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    cout << a <<" "<< b <<" "<< c <<endl;
    return 0;
}


Measured memory_bytes: 3104
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    n = ii()
    s = input()
    cnt = 0
    for i in range(n-2):
        if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
            cnt+=1

    print(cnt)


    
main()


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

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

int main(){
	//freopen("b.in","r",stdin);
	int w,a,b;
	cin >> w >> a >> b;
	if((a<=b && b<=a+w) || (a<=b+w && b<=a)) cout << "0" <<endl;
	else if(a+w<b) cout<<b-a-w<<endl;
	else cout<< a-b-w <<endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
p=list(map(int, input().split()))
cnt=0
for i in range (n):
    if i == 0:
        continue
    if i == n - 1:
        break
    if p[i-1] <= p[i] and p[i] <= p[i+1] or p[i+1] <= p[i] and p[i] <= p[i-1]:
        cnt+=1

print(cnt)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
int a[N];
int nxt[N],head[N];
int d[N];
int n;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		nxt[i]=head[a[i]],head[a[i]]=i;
	d[0]=1;
	for(int i=1;i<=n;i++){
		d[i]=d[i-1];
        if(nxt[i]&&nxt[i]!=i-1)
			d[i]=(d[i]+d[nxt[i]])%mod;
	}
	printf("%d\n",d[n]);
}


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

class UnionFind {
  int N;
  vector<int> PS;
public:
  UnionFind() : N(0) {}
  UnionFind(int n) : N(n), PS(n, -1) {}
  // a, b が連結だった場合はその代表元、非連結だった場合は新たな代表元を返す
  int merge(int a, int b) {
    assert(0 <= a && a < N);
    assert(0 <= b && b < N);
    int x = leader(a), y = leader(b);
    if (x == y) return x;
    if (-PS.at(x) < -PS.at(y)) swap(x, y);
    PS.at(x) += PS.at(y);
    PS.at(y) = x;
    return x;
  }
  // 頂点 a, b が連結かどうか
  bool same(int a, int b) {
    assert(0 <= a && a < N);
    assert(0 <= b && b < N);
    return leader(a) == leader(b);
  }
  // 頂点 a の属する連結成分の代表元
  int leader(int a) {
    assert(0 <= a && a < N);
    if (PS.at(a) < 0) return a;
    return PS.at(a) = leader(PS.at(a));
  }
  // 頂点 a の属する連結成分のサイズ
  int size(int a) {
    assert(0 <= a && a < N);
    return -PS.at(leader(a));
  }
  // グラフを連結成分に分け、「一つの連結成分の頂点番号のリスト」のリストを返す
  vector<vector<int>> groups() {
    vector<int> leader_buf(N), group_size(N);
    for (int i = 0; i < N; i++) {
      leader_buf.at(i) = leader(i);
      group_size.at(leader_buf.at(i))++;
    }
    vector<vector<int>> result(N);
    for (int i = 0; i < N; i++) {
      result.at(i).reserve(group_size.at(i));
    }
    for (int i = 0; i < N; i++) {
      result.at(leader_buf.at(i)).push_back(i);
    }
    result.erase(
      remove_if(result.begin(), result.end(),
        [&](const vector<int>& v) { return v.empty(); }),
      result.end());
    return result;
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  UnionFind UF(N);
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    UF.merge(--A, --B);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = max(ans, UF.size(i));
  }
  cout << ans << "\n";
}

Measured memory_bytes: 4056
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    ll n, k;
    cin >> n >> k;

    vll d(n);
    ll dmax = 0;
    for (ll i = 0; i < n; i++)
    {
        double ki = (double)k / (i + 1);
        d[i] = ceil(log2(ki));
        if (d[i] < 0)
        {
            d[i] = 0;
        }
        dmax = max(dmax, d[i]);
    }

    ll numerator = 0;
    ll denominator = pow(2LL, dmax);
    for (ll i = 0; i < n; i++)
    {
        numerator += pow(2LL, dmax - d[i]);
    }

    cout << setprecision(12) << ((double)numerator / denominator / n) << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

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

int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(ALL(a));
  cout << unique(ALL(a)) - a.begin() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

int main (){
    int N;
    vector<tuple<string, int, int>> S;

    cin >> N;

    rep(i,0,N) {
        string s_tmp;
        int tmp;

        cin >> s_tmp >> tmp;
        S.emplace_back(s_tmp,-tmp,i+1);
    }

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


    rep(i,0,N) {
        cout << get<2> (S[i]) << endl;
    }
}



Measured memory_bytes: 256
main=do
 [a,b,c,d,e,f]<-map read.words<$>getLine
 (putStrLn.unwords.map show.k.map h)[(100*(w*a+x*b),y*c+z*d)|w<-[0..(quot f (100*a))],x<-[0..(quot (f-100*w*a) (100*b))],y<-[0..(quot(f-100*(w*a+x*b))c)],z<-[0..(quot(f-100*(w*a+x*b)-y*c)d)],w+x>0,y*c+z*d<=e*(w*a+x*b)]
  where k tri = j ((length tri)-1) (tail tri) (head tri)
        j 0 _ (x,y,z) = [y+z,z]
        j n ((a,b,c):t) (x,y,z) = j(n-1)t(max(a,b,c)(x,y,z))
        h (w,s) =(quot(s*10000)(w+s),w,s)

Measured memory_bytes: 180604
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl

//毎回変える場所
#define N_MAX 100
int N;
LL T,ans;

//問題文のとおり
LL Gcd(LL a, LL b) {
	if(a<b)return Gcd(b,a);
	while (b != 0) {
		LL remain=a%b;
		a=b;
		b=remain;
	}
	return a;
}

LL Lcm(LL a, LL b) {
	return (b/Gcd(a,b))*a;
}



int main() {
	cin>>N;
	ans=1;
	REP(i,N){
		cin >> T;
		ans=Lcm(ans,T);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
using namespace std;

int main() {
	string s[3];
	int cnt[3];
	for (int i = 0; i < 3; i++) {
	cin >> s[i];
	cnt[i] = 0;
}
	int ptr = 0;
	while (true) {		
		cnt[ptr]++;
		ptr = (s[ptr][cnt[ptr] - 1] - 'a');
		if (cnt[ptr] == s[ptr].length()) {
			cout << char('A' + ptr) << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    
    if (N == 1) {
        println("Hello World")
    } else {
        val A = readInputLine().toInt()
        val B = readInputLine().toInt()
        println(A + B)
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 29732