akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <set>
#include <cassert>
using namespace std;
using lint = long long;
const long mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    string b;
    cin >> b;
    if(b == "A"){
        cout << "T" << endl;
    }
    if(b == "T"){
        cout << "A" << endl;
    }
    if(b == "C"){
        cout << "G" << endl;
    }
    if(b == "G"){
        cout << "C" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <vector>
#include <climits>
#include <queue>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<typename T1, typename T2>
inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2>
inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
const ll MOD = 1000000007;
const ll INF = 1LL << 60;


int main()
{
	int x, y;
	cin >> x >> y;

	int c, t;
	
	c = ((4 * x) - y) / 2;
	t = (y - (2 * x)) / 2;

	bool flag = true;

	if (c < 0 || t < 0)
		flag = false;

	if (c + t != x || (2 * c) + (4 * t) != y)
		flag = false;

	
	if (flag) cout << "Yes";
	else cout << "No";

	

}




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

int main() {
  string a,b;
  cin >> a >> b;
  int sum = 0;
  
  for(int i = 0; i < a.size(); i++){
    if(a.at(i)!=b.at(i)){
      sum++;
    }
  }
  cout << sum;


}

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

int main() {
  int64_t  a;
  cin >> a;
  if(a==111){
    cout << "3" << endl;
  } else {
  int64_t count=a/3;
  count=a-count*3;
  cout << count;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
struct point{
    int x,y,h;
};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    point p[N];
    for(int i = 0; i < N; ++i){
        cin >> p[i].x >> p[i].y >> p[i].h;
    }

    for(int x = 0; x < 101; ++x){
        for(int y = 0; y < 101; ++y){
            long long upper = 1L<<60;
            bool flag = true;
            long long h = -1;
            for(int i = 0; i < N; ++i){
                if(p[i].h == 0){
                    long long tmp = abs(x - p[i].x) + abs(y - p[i].y);
                    if(tmp < upper){
                        upper = tmp;
                    }
                    if(h != -1 && h - tmp > 0){
                        flag = false;
                        break;
                    }
                } else {
                    long long tmp = p[i].h + abs(x - p[i].x) + abs(y - p[i].y);
                    if(upper < tmp){
                        flag = false;
                        break;
                    } 
                    if(h != -1 && h != tmp){
                        flag = false;
                        break;
                    }
                    h = tmp;
                }
            }
            if(flag){
                cout << x << " " << y << " " << h << '\n';
                return 0;
            }
        }
    }
    return 0;
}

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

#define ll long long

using namespace std;

int main() {
  ll H;
  cin >> H;
  ll ans = 0;
  ll cnt = 1;

  while (H > 0) {
    ans += cnt;
    cnt *= 2;
    H /= 2;
  }
  cout << ans << endl;
}


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

int main(){
    int n,x,t;
    cin >> n >> x >> t;
    for(int i=1; ;i++){
        if(x*i>=n){
            cout << t*i << endl;
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main()
{
    ios_base::sync_with_stdio(0);
 
	int A, B;
  cin >> A >> B;
  ll ans = A;
  while (ans % B) ans += A;
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
int h,n,i,sum=0;
cin>>h>>n;
while(n>0){
    cin>>i;
    sum+=i;
    n--;
}
if(h<=sum){
    cout<<"Yes";
}
else{
    cout<<"No";
}
return 0;
}


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

typedef long long ll;


int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 700;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'o') {
            ans += 100;
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
s=input()

sr=s[::-1]

slen=len(s)

s1=(slen-1)//2 #3
s2=(slen+1)//2 #4

s1s=s[0:s1]
s1sr=s1s[::-1]
s2s=s[s2::]
s2sr=s2s[::-1]

if s==sr:
    if s1s==s1sr and s2s==s2sr:
        print("Yes")
    else:
        print("No")
else:
    print("No")
    

Measured memory_bytes: 9020
# -*- coding: utf-8 -*-
import sys
import math
#import fractions

n = int(input())
#tmp = input().split()
#n,m,k = list(map(lambda a: int(a), tmp))
s=input()

num_R=0
num_G=0
num_B=0

for i in range(n):
	if(s[i]=="R"):
		num_R+=1
	if(s[i]=="G"):
		num_G+=1
	if(s[i]=="B"):
		num_B+=1
total=num_R*num_G*num_B
#print(total)


tmp=n//2
#print(tmp)
for i in range(1,tmp+1):
	for j in range(n-i*2):
		if(s[j]!=s[j+i] and s[j]!=s[j+i*2] and s[j+i]!=s[j+i*2]):
			total-=1

#print(s)
print(total)

Measured memory_bytes: 9148
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;

	vector<vector<int>> open(N, vector<int>(10));
	vector<vector<int>> value(N, vector<int>(11));

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

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < 11; j++)
		{
			cin >> value[i][j];
		}
	}
	lint ans = -INF64;
	for (int bit = 1; bit < (1 << 10); bit++)
	{
		lint sale = 0;
		for (int i = 0; i < N; i++)
		{

			int count = 0;
			for (int j = 0; j < 10; j++)
			{
				if ((bit & (1 << j)) && open[i][j])
				{
					count++;
				}
			}
			sale += value[i][count];
		}
		ans = max(ans, sale);
	}
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

int main(){

    int N = 0;
    scanf("%d", &N);
    double x[N];
    double y[N];
    double sum = 0.0;
    double x_tmp = 0.0;
    double y_tmp = 0.0;
    int count = 1;

    for(int i = 0; i < N; i++){
        scanf("%lf %lf", &x[i], &y[i]);
        //count = count * (i + 1);
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i != j){
            x_tmp = pow(x[i] - x[j], 2.0);
            y_tmp = pow(y[i] - y[j], 2.0);
            sum = sum + sqrt(x_tmp + y_tmp);
            }
        }       
    }
    sum = sum * (N - 1);

    sum = sum / (N * (N - 1));
    printf("%.10lf", sum);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

	vector<int> p(n); 
	
	int ans = 0;
	int max_p = 0;
	int max_p_index;

	for (int i = 0; i < n; i++) {
		cin >> p[i]; 
		if (chmax(max_p, p[i])) max_p_index = i;
	}
	
	for (int i = 0; i < n; i++) {
		if (i == max_p_index) ans += p[i] / 2;		
		else ans += p[i];
	}
	
	cout << ans << endl;
		
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
  int key;
  Node *prev,*next;
};


Node *nil;
void init(){
  nil=(Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev=nil;
}

void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key=key;
  x->next = nil->next;
  nil->next->prev=x;
  nil->next =x;
  x->prev=nil;
}

Node* listSearch(int key){
  Node *cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void deleteNode(Node *t){
  if(t==nil)return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void deleteLast(){
  deleteNode(nil->prev);
}
void printList(){
  Node *cur = nil->next;
  int isf=0;
  while(1){
    if(cur==nil)break;
    if(isf++>0)printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
  }
  printf("\n");
}

int main(){
  int n,i=0,num;int size=0;int np=0,nd=0;
  char s[20];
  init();
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%s%d",s,&num);
    if(s[0]=='i'){insert(num);np++;size++;}
    else if(s[0]=='d'){
      if(strlen(s)>6){
      if(s[6]=='F')deleteFirst();
      else if(s[6]=='L')deleteLast();
    }else{
        deleteKey(num);nd++;
      }
      size--;
    }
    }
  printList();
  return 0;
}



Measured memory_bytes: 34016
# 法Pの下での組み合わせ数 nCk を求める
# MAX: nの最大値

P = (10**9)+7

fac=[]
inv=[]
finv=[]

# 拡張ユークリッドアルゴリズム
# (d, x, y): d=ax+by を満たすd, x, yを求める
# aとbが互いに素な整数であればgcd(a,b)=d=1, ax=1 (mod b)
# xは法bの元でaの乗法逆元a^-1になる
def exEuclid(a, b):
    if (b==0):
        return (a, 1, 0)
    else:
        (dd, xx, yy) = exEuclid(b, a % b)
        return (dd, yy, xx - (a//b)*yy)

def COMinit(MAX):
    global fac, inv, finv
    fac=[1 for _ in range(MAX)]
    inv=[1 for _ in range(MAX)]
    finv=[1 for _ in range(MAX)]
    #print('len(fac): {}'.format(len(fac)))
    #print(MAX)
    for i in range(2,MAX):
        #print(i)
        fac[i] = fac[i-1]*i % P
        (d, x, y) = exEuclid(i, P)
        inv[i] = x
        finv[i] = finv[i-1]*inv[i] % P

def COM(n, k):
    if(n<k):
        return 0
    elif ( (n<0)or(k<0)):
        return 0
    else:
        return fac[n]*(finv[n-k]*finv[k] % P) % P

####

#print('x, y:')
x, y = list(map(int,input().split()))
MAX = (x+y)//3 +1  # (X+Y)/3より大きい整数 1 <= X, Y <= 10**6
COMinit(MAX)

if ((x+y)%3 != 0):
    print(0)
    exit()
else:
    n1 = (-x+2*y)//3
    n2 = (2*x -y)//3
    if (n1<0):
        print(0)
        exit()
    elif(n2<0):
        print(0)
        exit()
    else:
        npath = COM(n1+n2, n1)
        print(npath)



Measured memory_bytes: 123020
# -*- coding: utf-8 -*-
S = list(input())
T = list(input())

flag = 0
for i in range(0, len(S)):
    tmp = T[0]
    T.pop(0)
    T.append(tmp)
    if S == T :
        flag = 1

if flag:
    print ("Yes")
else :
    print ("No")

Measured memory_bytes: 3060
X, N = map(int, input().split())
if N != 0:
  p = list(map(int, input().split()))
else:
  p = []

for i in range(100):
  if not(X-i in p):
    print(X-i)
    break
  else:
    if not(X+i in p):
      print(X+i)
      break
      

Measured memory_bytes: 9172
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    int a = 0, i=0;
    while(a<n){
        a += ++i;
    }

    // pr(a);
    for(int j=1; j<=i; j++){
        if(a-n > 0 && j == a - n) continue;
        pr(j);
    }

    return 0;}

Measured memory_bytes: 3624
#include<cstdio>
#include<vector>
#include<queue>
#include<cstring>
#include<algorithm>
#define MAXN 100006
#define INF 1000000000000000
using namespace std;
int n,m,s,t,u,v;
long long d[MAXN][2],ans[MAXN];
struct node
{
	long long v[2];
	int to;
};
vector<node> road[MAXN];
bool in[MAXN];
void SPFA(int x,int op)
{
	for(int i=0;i<MAXN;i++)
		d[i][op]=INF;
	d[x][op]=0;
	queue<int> q;
	q.push(x);
	memset(in,0,sizeof in);
	in[x]=1;
	while(!q.empty())
	{
		int now=q.front();
		q.pop();
		in[now]=0;
		for(int j=0;j<(int)road[now].size();j++)
		{
			int nex=road[now][j].to;
			if(d[nex][op]>d[now][op]+road[now][j].v[op])
			{
				d[nex][op]=d[now][op]+road[now][j].v[op];
				if(!in[nex])
				{
					in[nex]=1;
					q.push(nex);
				}
			}
		}
	}
}
int main()
{
	scanf("%d%d%d%d",&n,&m,&s,&t);
	node now;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%lld%lld",&u,&v,&now.v[0],&now.v[1]);
		now.to=v;
		road[u].push_back(now);
		now.to=u;
		road[v].push_back(now);
	}
	SPFA(s,0);
	SPFA(t,1);
	ans[n]=INF;
	for(int i=n-1;i>=0;i--)
		ans[i]=min(ans[i+1],d[i+1][0]+d[i+1][1]);
	for(int i=0;i<=n-1;i++)
		printf("%lld\n",INF-ans[i]);
}

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

string J(string str) {
  string a;
  a+= str[str.size()-1];
  for(int i=0;i<str.size()-1;i++) a += str[i];
  return a;
}

string C(string str){
  string a;
  for(int i=1;i<str.size();i++) a+=str[i];
  a += str[0];
  return a;
}

string E(string str) {
  string a = str;
  for(int i=0;i<str.size()/2;i++) 
    a[i] = str[str.size()-str.size()/2+i],a[str.size()-str.size()/2+i]=str[i];
  return a;
}

string P(string str){
  for(int i=0;i<str.size();i++) 
    if('0' <= str[i] && str[i] <= '9') str[i] = (str[i]-'0'-1+10)%10+'0';
  return str;
}

string M(string str){
  for(int i=0;i<str.size();i++) 
    if('0' <= str[i] && str[i] <= '9') str[i] = (str[i]-'0'+1)%10+'0';
  return str;
} 

int main() {
  int n;
  cin >>n;
  for(int q=0;q<n;q++) {
    string order;
    cin >> order;
    reverse(order.begin(),order.end());
    string str;
    cin >> str;
    for(int i=0;i<order.size();i++){
      if(order[i] == 'J') str = J(str);
      else if(order[i] == 'C') str=C(str);
      else if(order[i] == 'E') str = E(str);
      else if(order[i] == 'A') reverse(str.begin(),str.end());
      else if(order[i] == 'P') str = P(str);
      else if(order[i] == 'M') str = M(str);
    }
    cout << str << endl;
  }

  return 0;
}

Measured memory_bytes: 1208
def dfs(v)
	$used[v] = true
	G[v].each do |u|
		next if $used[u]
		next if $ex == [v, u]
		dfs(u)
	end
end


n, m = gets.split.map(&:to_i)
G = Array.new(n){[]}
es = []
m.times do
	a, b = gets.split.map(&:to_i)
	G[a-1] << b-1
	G[b-1] << a-1
	es << [a-1, b-1]
end

ans = 0
es.each do |e|
	$ex = e
	$used = Array.new(n, false)
	dfs(e[0])
	ans += 1 unless $used[e[1]]
end

puts ans

Measured memory_bytes: 1916
abc = input().split()
for n in abc:
	n = int(n)
	
w,h,x,y,r = int(abc[0]), int(abc[1]), int(abc[2]), int(abc[3]), int(abc[4]),

if (x+r) > w or (x-r) < 0 or (y+r)>h or (y-r)<0:
	print("No")
else:
	print("Yes")


Measured memory_bytes: 5600
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
//const ll MOD = 1e9 + 7;
const ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

//最大公約数
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}


int main(void){
  COMinit();
  ll K, N;
  cin >> K >> N;
  for(ll i = 2; i <= 2 * K; i++){
    ll ans = 0;
    if(i % 2){
      ll p = min(i/2, K-i/2);
      for(ll j = 0; j <= p; j++){
        ll a = N-j, b = K-2*p+j;
        ans += comb(a+b-1, a) * comb(p, j) % MOD * pow_mod(2, j) % MOD;
        ans %= MOD;
      }
    }else{
      ll p = min(i/2-1, K-i/2);
      //真ん中を1回使う
      for(ll j = 0; j <= p; j++){
        ll a = N-j-1, b = K-2*p+j-1;
        ans += comb(a+b-1, a) * comb(p, j) % MOD * pow_mod(2, j) % MOD;
        ans %= MOD;
      }
      //真ん中を使わない
      for(ll j = 0; j <= p; j++){
        ll a = N-j, b = K-2*p+j-1;
        ans += comb(a+b-1, a) * comb(p, j) % MOD * pow_mod(2, j) % MOD;
        ans %= MOD;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 4992
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n,k,c = inm()
s = ins()
l = [0]*n
r = [0]*n
for i in range(n):
    if s[i]=='x':
        l[i] = l[max(0,i-1)]
    else:
        l[i] = max(l[max(0,i-1)], (l[i-c-1]+1) if i>c else 1)
for i in range(n-1,-1,-1):
    if s[i]=='x':
        r[i] = r[min(n-1,i+1)]
    else:
        r[i] = max(r[min(n-1,i+1)], (r[i+c+1]+1) if i<n-c-1 else 1)
#ddprint(l)
#ddprint(r)
ans = []
for i in range(n):
    if s[i]=='o' and \
       (l[i-1] if i>0 else 0)+(r[i+1] if i<n-1 else 0)==k-1:
        ans.append(i+1)
for x in ans:
    print(x)


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  cout << (n < 1000 ? "ABC" : "ABD");
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> d(k);
    for(int i=0;i<k;i++)cin>>d[i];
    
    while(true){
        int m=n;
        bool sflag=true;
        while(m>0){
            bool flag=true;
            for(int i=0;i<k;i++){
                if(m%10==d[i]){
                    flag=false;
                    break;
                }
            }
            if(!flag){
                sflag=false;
                break;
            }
            m/=10;
        }
        if(sflag){
            cout<<n<<endl;
            break;
        }
        n++;
    }
}

   


Measured memory_bytes: 632
x, n = map(int, input().split())

if n==0:
  print(x)
else:
  p=list(map(int , input().split()))
  con=0
  anco=0
  
  for _ in range(0, 100):
    for i in range(n):
      if x-_==p[i]:
        con=1
      if x+_==p[i]:
        anco=1
    if con==0:
        print(x-_)
        break
    elif anco==0:
      print(x+_)
      break
    con=0
    anco=0
        

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

int main() {
  string s; cin >> s;
  int size = s.size();
  bool cont = true;
  while(cont) {
    --size;
    if(size%2) --size;
    for(int i=0; i<size/2; ++i) {
      if(s[i] == s[size/2+i]) {
        cont = false;
      } else {
        cont = true;
        break;
      }
    }
  }
  cout << size << endl;
  return 0;
}


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

int main()
{
    int n, x, cnt=1,sum;
    cin >> n >> x;
    int l[n];
    l[0]= 0;
    for(int i = 1; i<n+1; i++){
        cin >> l[i];
        sum = l[i-1] + l[i];
        l[i] = sum;
        if(sum <= x){
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Ord

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n, m] <- getIntList
    xs <- sort <$> getIntList
    let xl = (last xs) - (head xs)
        ds = sortOn Down $ zipWith (-) (tail xs) xs
    print $ xl - sum (take (n-1) ds)

Measured memory_bytes: 18812
import java.util.Scanner;

public class Main{
  public static void main (String[] args){
  double r,S,R;
    Scanner scan =new Scanner(System.in);
    r=scan.nextDouble();
    S=Math.PI*r*r;
    R=Math.PI*r*2;
    System.out.println(String.format("%f %f", S,R));

  }
}



Measured memory_bytes: 28232
use std::io::*;
use std::str::*;
use std::f64::consts::*;
use std::f64;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

struct Point {
    x: f64,
    y: f64,
}

impl Point {
    fn new() -> Point {
        Point {
            x: 0.0,
            y: 0.0,
        }
    }
}

fn koch(n: u32, a: &Point, b: &Point) {
    if (n == 0) { return; }
    let mut s = Point::new();
    let mut t = Point::new();
    let mut u = Point::new();
    let th = PI * 60.0 / 180.0;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * th.cos() - (t.y - s.y) * th.sin() + s.x;
    u.y = (t.x - s.x) * th.sin() + (t.y - s.y) * th.cos() + s.y;

    koch(&n - 1, &a, &s);
    println!("{:.8} {:.8}", s.x, s.y);
    koch(&n - 1, &s, &u);
    println!("{:.8} {:.8}", u.x, u.y);
    koch(&n - 1, &u, &t);
    println!("{:.8} {:.8}", t.x, t.y);
    koch(&n - 1, &t, &b);
}

fn main() {
    let a = Point::new();
    let mut b = Point::new();

    input!{
        n: u32,
    }

    b.x = 100.0;

    println!("{:.8} {:.8}", a.x, a.y);
    koch(n, &a, &b);
    println!("{:.8} {:.8}", b.x, b.y);

    return;
}


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

using namespace std;

const int N = 1024;

int ans[N][N];

int main() {
  for (int n = 1; n * 2 <= N; n *= 2) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        ans[i+n][j] = ans[i][j];
        ans[i][j+n] = ans[i][j];
        ans[i+n][j+n] = !ans[i][j];
      }
    }
  }
  for (int i = N-1; i > 0; --i) {
    for (int j = N-1; j > 0; --j) {
      ans[i][j] ^= ans[i-1][j-1] ^ ans[i-1][j] ^ ans[i][j-1];
    }
  }
  int n, m;
  scanf("%d %d", &n, &m);
  n = 1 << n;
  m = 1 << m;
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j < m; ++j) {
      printf("%d", ans[i][j]);
    }
    printf("\n");
  }
  return 0;
}


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

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

    int n = x / 100;
    if (5 * n >= x % 100)
        cout << 1 << endl;
    else
        cout << 0 << endl;
}

Measured memory_bytes: 3648
import itertools
n, m, q = list(map(int, input().split()))
queries = [list(map(int, input().split())) for _ in range(q)]

nums = [i for i in range(1, m + 1)]
ans = 0
for nums in itertools.combinations_with_replacement(nums, r=n):
	tmp = 0
	for query in queries:
		if nums[query[1] - 1] - nums[query[0] - 1] == query[2]:
			tmp += query[3]
	ans = max(ans, tmp)
print(ans)

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

namespace AtCoder
{
    class Program
    {
        public static void Main()
        {
            new Program().Solve();
        }

        void Solve()
        {
            int n = int.Parse(Console.ReadLine());

            var blue = new Dictionary<string, int>();
            for (int i = 0; i < n; i++)
            {
                var s = Console.ReadLine();
                if (blue.ContainsKey(s))
                {
                    blue[s]++;
                }
                else
                {
                    blue.Add(s, 1);
                }
            }

            int m = int.Parse(Console.ReadLine());
            var red = new Dictionary<string, int>();
            for (int i = 0; i < m; i++)
            {
                var s = Console.ReadLine();
                if (red.ContainsKey(s))
                {
                    red[s]++;
                }
                else
                {
                    red.Add(s, 1);
                }
            }

            int maxPoint = 0;

            foreach (var item in blue)
            {
                var s = item.Key;
                var point = item.Value;

                if (red.ContainsKey(s))
                {
                    point -= red[s];
                }
                if (point > maxPoint)
                    maxPoint = point;
            }
            Console.WriteLine(maxPoint);
        }
    }
}


Measured memory_bytes: 11220
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int p[100010];

struct edge{int to, cost;};

int n, d[100010];
vector<edge> g[100010];

void dijkstra(int s) {
  priority_queue<PII, vector<PII>, greater<PII>> que;
  fill(d, d+n, INF);
  d[s] = 0;
  que.push(PII{0, s});

  while(que.size()) {
    PII p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(edge e: g[v]) {
      if(d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(PII{d[e.to], e.to});
      }
    }
  }
}

signed main(void)
{
  // int n;
  cin >> n;
  REP(i, n) cin >> p[i];

  REP(i, n) {
    if(p[i] == 0) {
      FOR(j, 1, 7) {
        g[i].PB({min(n-1, (int)(i+j)), 1});
      }
    } else {
      g[i].PB({(int)i+p[i], 0});
    }
  }

  dijkstra(0);
  cout << d[n-1] << endl;

  return 0;
}

Measured memory_bytes: 10964
n=int(input())
d=[list(map(int,input().split())) for _ in range(n)]

ans=cnt=0
for i in range(n-1):
  for j in range(i+1,n):
    ans+=((d[i][0]-d[j][0])**2+(d[i][1]-d[j][1])**2)**0.5
print(2*ans/n)


Measured memory_bytes: 9340
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i <= n; ++i)
using namespace std;
int main()
{
    int N, Y;
    cin >> N >> Y;
    REP(x, N)
    {
        REP(y, N - x)
        {
            int z = N - x - y;
            if ((x * 10000 + y * 5000 + z * 1000) == Y)
            {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}


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

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

using namespace std;

int N,M,A[100];

int main() {
  cin >> N >> M;
  rep(i,N) cin >> A[i];
  REP(k,2,M+1) rep(i,N-1) if( A[i] % k > A[i+1] % k ) swap(A[i],A[i+1]);
  rep(i,N) cout << A[i] << endl;;
  return 0;
}

Measured memory_bytes: 1160
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int dp[2][2002];
int a[2002];
int main() {
	int N,Z,W;
	cin >> N >> Z >> W;
	a[0]=W;
	for(int i=1;i<=N;i++){
		cin >> a[i];
	}
	for(int i=N;i>0;i--){
		dp[0][i]=dp[1][i]=abs(a[i-1]-a[N]);
		for(int j=i+1;j<=N;j++){
			dp[0][i]=max(dp[0][i],dp[1][j]);
			dp[1][i]=min(dp[1][i],dp[0][j]);
		}
		//cerr << i << ", " << dp[0][i] << ", " << dp[1][i] << endl;
	}
	cout << dp[0][1] << endl;



	return 0;
}



Measured memory_bytes: 256
n,k = map(int, input().split())
A = list(map(int,input().split()))

def gcd(a,b):
    r = 1
    while r!=0:
        r = a%b
        a = b
        b = r
    return a

if max(A)<k:
    print('IMPOSSIBLE')
    exit()

if max(A)==n or min(A)==1:
    print('POSSIBLE')
    exit()

ans = A[0]
for i in A:
    ans = gcd(ans,i)

if ans > 1:
    if gcd(ans,k)>1:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

else:
    print('POSSIBLE')


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

int main() {
  std::string s;
  std::cin >> s;
  if (std::count(s.begin(), s.end(), 'A') == 3 || std::count(s.begin(), s.end(), 'B') == 3)
    std::cout << "No" << std::endl;
  else
    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 3516
n, m = map(int, input().split())
cardid_2_num_map = [0] * (10**5 + 2)

for i in range(m):
    l, r = map(int, input().split())
    cardid_2_num_map[l] += 1
    cardid_2_num_map[r + 1] -= 1

for i in range(1, n + 1):
    cardid_2_num_map[i] += cardid_2_num_map[i - 1]

max_sum_num = max(cardid_2_num_map)
count_max_card = cardid_2_num_map.count(max_sum_num)

if max_sum_num == m:
    print(count_max_card)
else:
    print(0)

Measured memory_bytes: 12776
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    let mut a = read_vec::<usize>();
    let mut x = Vec::with_capacity(m);
    let mut y = Vec::with_capacity(m);

    for i in 0..m {
        let v = read_vec::<usize>();
        x.push(v[0] - 1);
        y.push(v[1]);
    }

    let mut count = vec![0; n + 1];
    for &num in a.iter() {
        count[num] += 1;
    }
    let mut span = vec![0; n];
    for i in 1..n + 1 {
        for j in 0..count[i] {
            if i >= j + 1 {
                span[i - j - 1] += 1;
            }
        }
    }
    // println!("count {:?}", count);
    // println!("span {:?}", span);

    let mut blank_count = 0;
    for i in 0..n {
        if span[i] == 0 {
            blank_count += 1;
        }
    }

    for i in 0..m {
        let x = x[i];
        let y = y[i];

        if a[x] >= count[a[x]] {
            span[a[x] - count[a[x]]] -= 1;
            if span[a[x] - count[a[x]]] == 0 {
                blank_count += 1;
            }
        }
        count[a[x]] -= 1;

        a[x] = y;
        count[y] += 1;
        if y >= count[y] {
            span[y - count[y]] += 1;
            if span[y - count[y]] == 1 {
                blank_count -= 1;
            }
        }

        // println!("count {:?}", count);
        // println!("span {:?}", span);
        println!("{:?}", blank_count);
    }
}


Measured memory_bytes: 16500
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
using namespace std;

int n,m,t;
int ki,kj;
int col[105][105];
int f[10005];

void mke(int x){
	while(f[x]){
		f[x]--;
		col[ki][kj]=x;
		if(kj%2==0){
			ki++;
			if(ki==n){
				ki=n-1;
				kj++;
			}
		}else{
			ki--;
			if(ki==-1){
				ki=0;
				kj++;
			}
		}
	}
}

int main(){
	cin>>n>>m>>t;
	ki=0;
	kj=0;
	for(int i=1;i<=t;i++){
		cin>>f[i];
		mke(i);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++)
			cout<<col[i][j]<<" ";
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,M;
  cin >> N >> M;
  combination c(N+M);
  mint ans = 0;
  for(int i=0; i<=N; i++){
    mint now = c(N,i);
    if(i%2) now *= -1;
    now *= c(M,i) * c.fact[i];
    now *= c(M-i,N-i) * c.fact[N-i];
    now *= c(M-i,N-i) * c.fact[N-i];
    ans += now;
  }
  cout << ans.x << "\n";
  return 0;
}

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

int main(){
  string S;
  cin>>S;
  int s[3]={};
  for(int i=0;i<S.size();i++){
    s[S[i]-'a']++;
  }
  int mx=0;
  mx=min(s[0],s[1]);
  mx=min(mx,s[2]);

  for(int i=0;i<3;i++){
    s[i]=s[i]-mx;
  }
  if(s[0]>=2||s[1]>=2||s[2]>=2){
    cout<<"NO"<<endl;
  }else{
    cout<<"YES"<<endl;
  }
  return 0;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
)

func main() {
	n := 0
	var a, b, c string
	fmt.Scan(&n, &a, &b, &c)
	ans := 0
	for i := range a {
		cnt := 0
		if a[i] == b[i] {
			cnt++
		}
		if b[i] == c[i] {
			cnt++
		}
		if c[i] == a[i] {
			cnt++
		}
		if cnt == 1 || cnt == 2 {
			ans++
		} else if cnt == 0 {
			ans += 2
		}
	}
	fmt.Println(ans)
}


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

int main()
{
    ll X;
    cin >> X;
    ll money=100;
    int count=0;
    while(money<X){
        money*=1.01;
        count++;
    }
    cout << count << endl;
}


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

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[][][] info = new int[4][3][10];

		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 3; j++){
				for(int k = 0; k < 10; k++){
					info[i][j][k] = 0;
				}
			}
		}
		
		for(int i = 0; i < n; i++){
			int tower = scanner.nextInt();
			int f = scanner.nextInt();
			int room = scanner.nextInt();
			int member = scanner.nextInt();

			info[tower-1][f-1][room-1] += member;
		}

		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 3; j++){
				for(int k = 0; k <= 9; k++){
					System.out.print(" " + info[i][j][k]);
				}
				System.out.print("\n");
			}
			if(i < 3){
			System.out.println("####################");
			}
		}
	}

}

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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define mod 1e9 + 7
#define INF 999999999
#define fk first
#define sv second

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

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

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

  string num;
  cin >> num;

  cout << "ABC" << num << endl;

}



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

const int MOD = 1000000000 + 7;
string s;
int dp[100000 + 1][4];

int main() {
    cin >> s;
    int n = s.length();
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= 3; j++) {
            dp[i][j] = ((long long)(dp[i - 1][j]) * (s[i - 1] == '?' ? 3 : 1)) % MOD;
            if (j > 0 && (s[i - 1] == '?' || (int)(s[i - 1] - 'A') + 1 == j)) {
                dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % MOD;
            }
        }
    }
    // for (int i = 1; i <= n; i++) {
    //     for (int j = 0; j <= 3; j++) {
    //         cout << "dp[" << i << "][" << j << "] = " << dp[i][j] << "; ";
    //     }
    //     cout << "\n";
    // }
    cout << dp[n][3] << "\n";

    return 0;
}


Measured memory_bytes: 2048
///////////////////////////////////////////////////////////
#include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
///////////////////////////////////////////////////////////
#define ll long long
#define ull unsigned long long
///////////////////////////////////////////////////////////
template <class T>
T absolute(const T& n);
template <class T>
void input(vector<T>& vec);
template <class T>
void output(const vector<T>& vec);
template <class T>
T sum(const vector<T>& vec);
template <class T>
void upsort(vector<T>& vec);
template <class T>
void downsort(vector<T>& vec);
template <class T>
T max(const vector<T>& vec);
template <class T>
T min(const vector<T>& vec);
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<10&&b<10){
        cout<<a*b<<endl;
    }else{
        cout<<-1<<endl;
    }
    return 0;
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
template <class T>
T absolute(const T& n)
{
    if (n < 0) {
        return (-n);
    }
    return n;
}

template <class T>
void input(vector<T>& vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cin >> vec.at(i);
    }
}

template <class T>
void output(const vector<T>& vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

template <class T>
T sum(const vector<T>& vec)
{
    T initial = 0.0;
    T s = accumulate(vec.begin(), vec.end(), initial);
    return s;
}

template <class T>
void upsort(vector<T>& vec)
{
    sort(vec.begin(), vec.end());
}

template <class T>
void downsort(vector<T>& vec)
{
    sort(vec.begin(), vec.end(), greater<T>());
}

template <class T>
T max(const vector<T>& vec)
{
    T m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = max(m, vec.at(i));
    }
    return m;
}

template <class T>
T min(const vector<T>& vec)
{
    T m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = min(m, vec.at(i));
    }
    return m;
}
///////////////////////////////////////////////////////////

Measured memory_bytes: 256