akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>

using sll = signed long long;
using ui = unsigned int;

auto ui_cast(sll s) {
	return static_cast<ui>(s);
}

template<class T>
class rec {
private:
	const T t;
public:
	rec(const T& t_) :t{ t_ } {}
	rec(T&&t_) :t{ t_ } {}
	auto operator()(sll n, sll x)->sll {
		if (n == 0)
			return 1 <= x ? 1 : 0;

		auto idx = ui_cast(n) - 1;
		auto& e = t[idx];

		if (x <= e.first + 1)
			return this->operator()(n - 1, x - 1);
		else
			return
				e.second + 1
				+this->operator()(n - 1, x - 2 - e.first);
	}
};


int main() {
	sll n, x;
	std::cin >> n >> x;

	std::vector<std::pair<sll,sll>> apn;
	apn.resize(ui_cast(n));
	apn.front() = { 1,1 };
	
	for (ui i{ 1 }; i < ui_cast(n); ++i) {
		auto&e = apn[i];
		auto& pe = apn[i - 1];
		e.first = 2*pe.first+3;
		e.second = 2*pe.second+1;
	}
	rec<decltype(apn)> r{ std::move(apn) };

	std::cout<<r(n, x)<<"\n";
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int maxn = 1e5 + 10;
using namespace std;

int n, m, T, kase = 1;
vector<int> G[maxn];
char b[105][105];
char r[105][105];

int main() {
    while(scanf("%d", &n) != EOF) {
        for(int i = 0; i < n; i++) scanf("%s", b[i]);
        scanf("%d", &m);
        for(int i = 0; i < m; i++) scanf("%s", r[i]);
        int ans = 0;
        for(int i = 0; i < n; i++) {
            int tot = 0;
            for(int j = 0; j < n; j++) if(strcmp(b[i], b[j]) == 0) tot++;
            for(int j = 0; j < m; j++) if(strcmp(b[i], r[j]) == 0) tot--;
            ans = max(ans, tot);
        }
        cout <<ans <<endl;
    }
    return 0;
}


Measured memory_bytes: 2560
class Bit:
  def __init__(self,n):
    self.bl = n.bit_length()
    self.size = n
    self.tree = [0]*(n+1)
 
  def sum(self,i):
    s = 0
    while i > 0:
      s += self.tree[i]
      i -= i & -i
    return s

  def add(self,i,x):
    while i <= self.size:
      self.tree[i] += x
      i += i & -i

import sys
input = sys.stdin.readline
from collections import defaultdict
n,q = map(int,input().split())
a = list(map(int,input().split()))
lr = [tuple(map(int,input().split()))+(i,) for i in range(q)]
ans = [0]*q
lr.sort(key = lambda x:x[1])
bit = Bit(n+2)
dc = defaultdict(int)
cnt = 0
for L,R,p in lr:
  L -= 1
  for i in range(cnt,R):
    if dc[a[i]]:
      l = dc[a[i]]-1
      r = i
      bit.add(l+2,1)
      bit.add(r+2,-1)
    else:
      bit.add(1,1)
      bit.add(i+2,-1)
    dc[a[i]] = i+1
  ans[p] = bit.sum(L+1)
  cnt = R
print(*ans,sep="\n")

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


int main(){
	int n;
	scanf("%d", &n);
	int prev = 1;
	int prevprev = 1;
	int val;
	if (n == 0 || n == 1){
		val = 1;
	}
	else{
		for (int i = 1; i < n; i++){
			val = prev + prevprev;
			prevprev = prev;
			prev = val;
		}
	}
	printf("%d\n", val);

	return 0;
}


Measured memory_bytes: 3240
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys


def std_in():
    return sys.stdin.readline().strip()


def editor(s):
    d = ""
    for c in s:
        if c == "0":
            d += c
        elif c == "1":
            d += c
        elif c == "B":
            d = d[0:-1]
    return d


def _main():
    s = std_in()
    print(editor(s))


if __name__ == "__main__":
    _main()


Measured memory_bytes: 9096
n=int(input())
k= list(map(int, input().split()))
z=[0]*n
cnt=0
for  i in range(n):
   z[k[i]-1]+=1
for m in range(n):
    cnt+=z[m]*(z[m]-1)//2
for j in range(n):
    a=k[j]-1
    print(cnt-z[a]+1)

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = (int)1e9+7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll x,y;
	cin >>x >>y;
	
	rep(i,100){
		x *=2;
		if(x > y){
			cout << i+1 <<"\n";
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(){
	int a[1000001] = {0};
	for(int i = 0; i < 1000001; i++){
		a[i] = 1;
	}
	a[0] = 0;
	a[1] = 0;
	for(int i = 0; i < 1000; i++){
		if(a[i]){
			for(int j = i * 2; j < 1000001; j += i){
				a[j] = 0;
			}
		}
	}

	int n;
	while(cin >> n){
		int k = 0;
		for(int i = 0; i <= n; i++){
			if(a[i]) k++;
		}
		cout << k << endl;
	}

	return 0;
}

Measured memory_bytes: 5072
def main():
    S = input()

    s = set()
    s.add('A')
    s.add('C')
    s.add('G')
    s.add('T')

    max_count = 0

    count = 0
    for c in S:
        if c in s:
            count += 1
        else:
            max_count = max(max_count, count)
            count = 0

    max_count = max(max_count, count)
    print(max_count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){

	int a,b;
	int d,r;
	double f,area,circum;

	cin >> f;

	area = f * f * M_PI;
	circum = 2 * f* M_PI;

	cout << fixed << setprecision(8) << area << " " << fixed << setprecision(8) << circum << endl;


	return 0;
}


Measured memory_bytes: 3288
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
	string s;
	int ans=0, cou = 0;
	cin >> s;
	for(int i = 0; i < s.size(); ++i) {
		if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
			++cou;
		else {
			if(ans < cou) {
				ans = cou;
				cou = 0;
			}
		}
	}
	if(ans < cou)
		ans=cou;
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	//C問題

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n, m;
		String ans;
		n = scanner.nextInt();
		m = scanner.nextInt();

		//橋君の提出が AC となる場合は Yes, そうでない場合は No と出力せよ。

		if (n == m) {
			ans = "Yes";
		} else {
			ans = "No";
		}

		System.out.println(ans);
	}

}

Measured memory_bytes: 23764
import math
K = int(input())
A = list(map(int,input().split()))
lo = 2
hi = 2
for e in A[::-1]:
    if hi//e == lo//e and (hi%e)*(lo%e) != 0:
        print(-1)
        exit(0)
    else:
        lo = e*math.ceil(lo/e)
        hi = e*((hi//e)+1)-1
print(lo,hi)


Measured memory_bytes: 15020
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
#define ll long long
using namespace std;
const int N=50005;
int n,p[N],vis[N],cnt,now; ll a[505][505],v1[N],v2[N];
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
void init(int n){
	rep (i,2,n){
		if (!vis[i]) p[++cnt]=i;
		for (int j=1;j<=cnt&&i*p[j]<=n;j++){
			vis[i*p[j]]=1;
			if (i%p[j]==0) break;
		}
	}
}
int main(){
	scanf("%d",&n);
	if (n==2) return puts("4 7\n23 10"),0;
	init(10000);
	rep (i,1,n) a[i][0]=a[i][n+1]=a[0][i]=a[n+1][i]=1;
	now=1;
	for (int i=1+1;i<=n+n;i+=2) v1[i]=p[now++];
	for (int i=(n&1)?1-n:2-n;i<=n-1;i+=2) v2[i+n]=p[now++];
	rep (i,1,n) rep (j,1,n) if (!((i+j)&1)) a[i][j]=v1[i+j]*v2[i-j+n];
	rep (i,1,n) rep (j,1,n) if ((i+j)&1) a[i][j]=lcm(lcm(a[i][j-1],a[i][j+1]),lcm(a[i-1][j],a[i+1][j]))+1;
	rep (i,1,n){rep (j,1,n) printf("%lld ",a[i][j]); puts("");}
	return 0;
}

Measured memory_bytes: 5248
n, m, x = map(int, input().split())
y = []
for i in range(n):
    y.append(list(map(int, input().split())))

ans = 10 ** 7
for i in range(2**n):
    money = 0
    a = [0] * m
    for j in range(n):
        if i >> j & 1:
            money += y[j][0]
            a = [a[k] + y[j][k+1] for k in range(m)]
    flag = True
    for j in a:
        if j < x:
            flag = False
    if flag:
        ans = min(ans, money)

if ans < 10 ** 7:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 74112
#define _CRT_SECURE_NO_WARNINGS
/*                   وتزودوا فإن خير الزاد التقوى                    */
/*       وما تدري نفس ماذا تکسب غدا وما تدري نفس باي ارض تموت      */
#include <bits/stdc++.h>
#include<unordered_map>
#include<iomanip>
#include<fstream>
using namespace std;
#include<iostream>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define dll double
#define PI acos(-1)
#define watch(x) cout<<#x<<" = { "<<x<<" }\n"
#define sz(n) n.size()
#define M_Sayed fast() 
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define RT(v) return cout<<v,0
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
const double EPS = (1e-7);
ll Ceil(ll x, ll y) { return (x + y - 1) / y; }
void run() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
#endif
}
ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }
ll power(ll x, ll y, ll mod) {
	if (y == 0) return 1;
	if (y == 1) return x % mod;
	ll r = power(x, y >> 1, mod);
	return (((r * r) % mod) * power(x, y & 1, mod)) % mod;
}
void fast() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }
ll n, m, k,su,cnt;

int main()
{
	//run();
	M_Sayed;
	cin >> n ;
	vector<ll>v(n + 1),vis(n+5);
	for (int i = 1; i <= n; i++) {
		cin >> v[i];
	}
	v[0] = v[1];
	for (int i = 1; i <= n; i++) {
		if (i >= 2)vis[i] = min(abs(v[i - 1] - v[i]) + vis[i - 1], abs(v[i - 2] - v[i]) + vis[i - 2]);
		else vis[i] = abs(v[i - 1] - v[i]);
	}
	RT(vis[n]);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   if(abs(c-a)<=d||(abs(b-a)<=d&&abs(c-b)<=d)){
       cout<<"Yes"<<endl;
   }
   else{
       cout<<"No"<<endl;
   }

}

Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <math.h>
#include <set>
  
#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;
 
bool used[26];
 
string s;
 
vector <string> rec(string t,int i){
    vector<string> res,res1;
    if(i==t.size()){
        res.PB(t);
    }else{
        if(t[i]=='z'){
			if(!used['y'-'a'])return res;
            res=rec(t,i+1);
        }else if(t[i]=='a'){
            res=rec(t,i+1);
            if(!used[0]){
                used[0]=true;
                t[i]='b';
                res1=rec(t,i+1);
                res.insert(res.begin(),ALL(res1));
                used[0]=false;
            }
        }else{
            if(used[t[i]-'a'-1])res=rec(t,i+1);
            if(!used[t[i]-'a']){
                string tt=t;tt[i]=t[i]+1;
                used[t[i]-'a']=true;
                res1=rec(tt,i+1);
                used[t[i]-'a']=false;
                res.insert(res.begin(),ALL(res1));
            }
        }
    }
    return res;
}
 
int main(){
    string s;
    while(1){
        cin>>s;
        if(s=="#")break;
        vector<string> ans;
        memset(used,false,sizeof(used));
        ans=rec(s,0);
        sort(ALL(ans));
        cout<<ans.size()<<endl;
		if(ans.size()<10){
			REP(i,ans.size())cout<<ans[i]<<endl;
        }else{
			REP(i,5)cout<<ans[i]<<endl;
			REP(i,5)cout<<ans[ans.size()-5+i]<<endl;
		}
    }
}


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

const int N = 100000;
const int MOD = 1e9 + 7;

int n, k;
vector<int> G[N];

bool visited[N], painted[N];

void dfs(int v, int *p) {
  visited[v] = true;
  int c = 0;
  int kk = k;
  if (painted[v]) {
    kk--;
  } else {
    c++;
    painted[v] = true;
  }
  rep(i, G[v].size()) {
    int to = G[v][i];
    if (painted[to]) {
      kk--;
    } else {
      c++;
      painted[to] = true;
    }
  }
  rep(i, c) *p = (ll)*p * (kk--) % MOD;

  rep(i, G[v].size()) {
    int to = G[v][i];
    if (visited[to]) continue;
    dfs(to, p);
  }
  // printf("v = %d, *p = %d\n", v, *p);
}

int main() {
  cin >> n >> k;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b; a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  rep(i, n) visited[i] = false;
  rep(i, n) painted[i] = false;
  int ans = 1;
  dfs(0, &ans);
  cout << ans << endl;
  return 0;
}

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

int main() {
    int N,A,B,sum=0;
    scanf("%d %d %d",&N,&A,&B);
    int n,a,b;
    for (int i=0; i <= B && i <= N/10000; i++) {
        n = N - 10000*i; a = A-i; b = B-i;
        for (int j=0; j <= b && j <= n/1000 && j <= 9; j++) {
            n -= 1000*j; a -= j; b -= j;
            for (int k=0; k <= b && k <= n/100 && k <= 9; k++) {
                n -= 100*k; a -= k; b -= k;
                for (int l=0; l <= b && l <= n/10 && l <= 9; l++){
                    n -= 10*l; a -= l; b -= l;
                    for (int m=max(a,0); m <= n && m <= 9 && m <= b; m++) {
                        sum += N - (n - m);
                    }
                    n += 10*l; a += l; b += l;
                }
                n += 100*k; a += k; b += k;
            }
            n += 1000*j; a += j; b += j;
        }
    }
    printf("%d\n",sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define endl '\n'
#define int long long
int32_t main()
{
    int h,a;
    cin>>h>>a;
    cout<<h/a+(h%a!=0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6,inf=1e9;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int a,b;cin>>a>>b;
  cout<<(a+b-1)/b<<endl;
  
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 0

[n,k] = inpl()
s = input()
change = 0
nochange = 0
for i in range(1,len(s)):
    if s[i]!= s[i-1]: change += 1
    else: nochange += 1

if change//2 < k: ans = nochange + change
else: ans = nochange + 2*k

print(ans)

Measured memory_bytes: 12684
def max(a, b)
  a > b ? a : b
end

gets
arr = gets.split.map(&:to_i)

counter = 0
max_counter = 0
now = -1
arr.each do |i|
  if i <= now
    counter += 1
  else
    max_counter = max(counter, max_counter)
    counter = 0
  end
  now = i
end

puts max(counter, max_counter)

Measured memory_bytes: 8580
#include<stdio.h>
int main(void){
  int a = 0,b = 0;
  char op = 0;

  do {

    scanf("%d %c %d", &a, &op, &b);

  if (op == '+'){
    printf("%d\n",a + b);
  } else if (op == '-'){
    printf("%d\n",a - b);
  } else if (op == '*'){
    printf("%d\n",a * b);
  } else if (op == '/'){
    printf("%d\n",a / b);
  } else {
    return 0;
  }
  }while(1);

}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#include <climits>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k, x;
  cin >> k >> x;
  if (500*k >= x)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

using namespace std;

const int O = 1e6 + 5;

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string s; cin >> s;
    bool flag = false;
    for (int i = 1; i < s.size(); ++ i){
        if (s[i] != s[i - 1]) flag = true;
    }
    if (flag) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	ll x = 7, i, n;
	cin >> n;
	rep(i, n) {
		if (x % n == 0)
			break;
		x %= n;
		x = 10 * x + 7;
	}
	if (i >= n)
		printf("-1\n");
	else
		cout << i + 1 << "\n";
	return 0;
}

Measured memory_bytes: 3552
#include<stdio.h>

int ans[10000];

int main() {

	int m, min, max;
	int P[10000];
	int c = 0;
	int INPUTMAX;
	int INPUTNUM;

	while (1) {
		scanf("%d %d %d", &m, &min, &max);
		if (m == 0 && min == 0 && max == 0)break;

		for (int i = 0; i < m; i++) {
			scanf("%d", &P[i]);
		}
		for (int i = 0; i < max - min + 1; i++) {
			if (i == 0) {
				INPUTMAX = P[min - 1 + i] - P[min + i];
				INPUTNUM = min + i;
			}
			else {
				if (INPUTMAX <= P[min - 1 + i] - P[min + i]) {
					INPUTMAX = P[min - 1 + i] - P[min + i];
					INPUTNUM = min + i;
				}
			}
		}

		ans[c] = INPUTNUM;

		c++;
	}

	for (int i = 0; i < 10000; i++) {
		if (ans[i] == 0) break;
		printf("%d\n", ans[i]);
	}

	return 0;
}


Measured memory_bytes: 2052
import math
from collections import Counter
from collections import defaultdict
mod = 10**9+7 

def prime(n):
  for i in range(2, math.ceil(math.sqrt(n))+1):
    while n % i == 0:
      n /= i
      prime_count[i] += 1
  if n > 1:
    prime_count[int(n)] += 1

n = int(input())
a = 1
prime_count = defaultdict(int)
for i in range(1, n+1):
  prime(i)

ans = 1
for v in prime_count.values():
  ans *= (v+1)
  ans %= mod 
print(ans)





Measured memory_bytes: 3316
//Bismillahir Rahmanir Rahim
//In the name of Allah the Most Merciful
//Astagfirullahil laji Rabbi Minkulli Jamio
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define int   long long  int
#define double  long double

#include<fstream>
#define ck while(1)
int i,j,k;

main()
{
   string s,t;cin>>s>>t;
   int c=0;
   for(i=0;i<s.length();i++)
   {
       if(s[i]!=t[i]) c++;
   }
   cout<<c<<endl;
}


Measured memory_bytes: 3916
#include <iostream>
#include <string>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int n = 0;
  for (char c : S) {
    n += (c == 'x');
  }
  if (n > 7)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}

Measured memory_bytes: 256
import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str

isdelim(x::UInt8, xs::Set{UInt8}) = x in xs

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        if !isdelim(c, delims)
            break
        end
    end
    push!(out, c)
    if eof(s)
        return out
    end
    while !eof(s)
        c = read(s, UInt8)
        if isdelim(c, delims)
            break
        end
        push!(out, c)
    end
    return out
end

delimset = Set([0x0a, 0x20])

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

readvec(tys::Tuple , len::Signed)::Vector{Tuple{tys...}} = @inbounds Tuple{tys...}[reads(tys...) for i in 1:len]

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i = 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

function main()
    N,M = reads(Int,Int)
    tp = 0
    arr = Set(Int[])
    i = 0
    if isodd(M)
        while i < M
            i += 1
            if (i-1+N-(N+1-i-tp)) in arr
                tp += 1
                i -= 1
                continue
            end
            println("$i $(N+1-i-tp)")
            push!(arr, N+1-i-tp-i-1)
        end
    else
        if iseven(N)
            for i in 1:M÷2
                println("$i $(N+1-i)")
            end
            for i in M÷2+1:M
                println("$i $(N+1-i-1)")
            end
        else
            for i in 1:M
                println("$i $(N+1-i)")
            end
        end
    end
end

main()


Measured memory_bytes: 213920
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N = int(input())
A = np.array(list(map(int, input().split())))
B = np.zeros(N+1, dtype = np.int64)

for a in A:
	B[a] += 1

for b in B[1:]:
	print(b)


Measured memory_bytes: 51012
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> W(M);
  for (int i = 0; i < N; i++){
    int A, B;
    cin >> A >> B;
    if (M - A >= 0){
      W[M - A].push_back(B);
    }
  }
  int ans = 0;
  priority_queue<int> pq;
  for (int i = M - 1; i >= 0; i--){
    for (int j : W[i]){
      pq.push(j);
    }
    if (!pq.empty()){
      ans += pq.top();
      pq.pop();
    }
  }
  cout << ans << endl;
}

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

int main() {
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		if(i == 4){
			cout << " ";
		}
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

// ビット演算
namespace Bits {
    // 整数 x を左に i ビットシフトした値を返す
    static Int LeftBitShift(Int x, Int i);
    // 整数 x を右に i ビットシフトした値を返す
    static Int RightBitShift(Int x, Int i);
    // 整数x の 下から i 桁目が1かどうかを返す
    static bool IsFlagUp(Int x, Int i);
    // 整数x の 下から i 桁目が0かどうかを返す
    static bool IsFlagDown(Int x, Int i);

    // 整数 x を左に i ビットシフトした値を返す
    Int LeftBitShift(Int x, Int i) {
        return (x << i);
    }
    // 整数 x を右に i ビットシフトした値を返す
    Int RightBitShift(Int x, Int i) {
        return (x >> i);
    }
    // 整数x の 下から i 桁目が1かどうかを返す
    bool IsFlagUp(Int x, Int i) {
        return ((x & (1 << i)) != 0);
    }
    // 整数x の 下から i 桁目が0かどうかを返す
    bool IsFlagDown(Int x, Int i) {
        return ((x & (1 << i)) == 0);
    }
}
using namespace Bits;

// 二つの値の最大値を求める関数
Int Max(const Int a, const Int b) {
    if (a >= b) {
        return a;
    } else {
        return b;
    }
}

int main(void) {
    Int n;
    cin >> n;
    VI a(n);
    VVI table(n, VI(n, -1)); // -1 不明, 0 不親切, 1 正直者
    Int x, y;
    for (Int i = 0; i < n; ++i) {
        cin >> a[i];
        for (Int j = 0; j < a[i]; ++j) {
            cin >> x >> y;
            --x;
            table[i][x] = y;
        }
    }
    Int result = 0;
    for (Int i = 0; i < pow(2, n); ++i) {
        // cout << "I = " << i << endl;
        bool correct = true;
        Int rank = 0;
        // ビット列が1の人のみの証言に矛盾がないかを調べる
        for (Int j = 0; j < n; ++j) {
            if (IsFlagUp(i, j)) {
                rank++;
                for (Int k = 0; k < n; ++k) {
                    if (table[j][k] == 0 && IsFlagUp(i, k)) {
                        correct = false;
                    } else if (table[j][k] == 1 && IsFlagDown(i, k)) {
                        correct = false;
                    }
                }
            }
        }
        if (correct) {
            // cout << "CORRECT" << endl;
            result = Max(result, rank);
        } else {
            // cout << "INCORRECT" << endl;
        }
    }
    cout << result << endl;

    /*
    for (Int i = 0; i < n; ++i) {
        for (Int j = 0; j < n; ++j) {
            cout << table[i][j] << " ";
        }
        cout << endl;
    }
    */
    return 0;
}


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

#define ll long long

int main() {
	int n;
	ll k;
	cin >> n >> k;
	k *= k;
	vector<pair<ll,ll>> v(n);
	for(int i = 0;i<n;i++)
		cin >> v[i].first >> v[i].second;
	int count = 0;
	for(int i = 0;i<n;i++)
		if( pow(v[i].first,2) + pow(v[i].second,2) <= k)
			count++;
	cout << count << endl;
	return 0; 
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i];
    }
    sort(X.begin(), X.end());
    int ans = 1e9;
    for (int i = X[0]; i <= X[N - 1]; i++) {
        int val = 0;
        for (int& x: X) {
            val += pow(x - i, 2);
        }
        ans = min(ans, val);
    }
    cout << ans << endl;
    return 0;
}


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

void SieveOfEratosthenes(int n) 
{ 
    int x=n-100000;
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for (int p=2; p<=n; p++) 
       if (prime[p]&&p>=x) {
          cout << p << " ";
          break;
       }
}

int main()
{
    int n;scanf("%d",&n);
    SieveOfEratosthenes(n+100000);
    return 0;
}

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

using namespace std;

int main()
{
    vector<int> sassi;
    vector<int> dp;
    int numSassi, maxSalti;

    cin >> numSassi;
    cin >> maxSalti;

    sassi.resize(numSassi);
    dp.resize(numSassi);

    for(int i = 0; i < sassi.size(); i++)
    {
        cin >> sassi[i];
    }

    dp[0] = 0;
    for(int i = 1; i < dp.size(); i++)
    {
        dp[i] = dp[i - 1] + abs(sassi[i] - sassi[i - 1]);
        for(int j = 2; j <= maxSalti; j++)
        {
            if((i - j) >= 0)
            {
                dp[i] = min(dp[i], dp[i - j] + abs(sassi[i] - sassi[i - j]));
            }
        }
    }

    cout << dp[dp.size() - 1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

struct Point{
  double x;
  double y;
};

struct Point2{
  Point p1;
  Point p2;
};

struct Ret{
  Point s;
  Point u;
  Point t;
};

void PrintPoint(Point p){

  printf("x: %lf y:%lf\n",p.x,p.y);
}

Ret cohho(Point p1,Point p2){

  Ret r;
  double x1,y1,xx,yy;

  const double alpha = M_PI*(1/3.0d);

  x1 = p2.x - p1.x;
  y1 = p2.y - p1.y;

  r.s.x = x1 * (1/3.0d) + p1.x;
  r.s.y = y1 * (1/3.0d) + p1.y;

  r.t.x = x1 * (2/3.0d) + p1.x;
  r.t.y = y1 * (2/3.0d) + p1.y;

  xx = r.t.x - r.s.x ;
  yy = r.t.y - r.s.y ;
  
  r.u.x = xx * cos(alpha) - yy * sin(alpha) + r.s.x;
  r.u.y = xx * sin(alpha) + yy * cos(alpha) + r.s.y;
  
  return r;
}

int main(){
  long ii,jj,kk;
  vector<int> a;
  int n;
  cin >> n;
  Ret r;
  Point p1,p2,s,u,t;
  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;
  Point2 start;
  start.p1 = p1;
  start.p2 = p2;
  vector<Point2> p;
  vector<Point2> nextp;
  p.push_back(start);

  nextp.push_back(start);
  for(ii=0;ii<n;ii++){

    nextp.clear();
    auto it = p.begin();

    while(it != p.end()){

      r = cohho((*it).p1,(*it).p2);

      p1 = (*it).p1;
      s  = r.s;
      u  = r.u;
      t  = r.t;
      p2 = (*it).p2;
//      cout << "==================START============" << endl;
//      PrintPoint(p1);
//      PrintPoint(s);
//      PrintPoint(u);
//      PrintPoint(t);
//      PrintPoint(p2);
//      cout << "==================END=============" << endl;
      
      start.p1 = p1;
      start.p2 = s;
      nextp.push_back(start);

      start.p1 = s;
      start.p2 = u;
      nextp.push_back(start);

      start.p1 = u;
      start.p2 = t;
      nextp.push_back(start);

      start.p1 = t;
      start.p2 = p2;
      nextp.push_back(start);

      it++;
    }
    
    p = nextp;
    
  }

  auto it2 = nextp.begin();

  while(it2 != nextp.end()){
    //cout << (*it2).p1.x << " " << (*it2).p1.y << endl;
    printf("%.14lf %.14lf\n",(*it2).p1.x,(*it2).p1.y);
    if((it2+1 ) == nextp.end()){
      printf("%.14lf %.14lf\n",(*it2).p2.x,(*it2).p2.y);
    }
    it2++;
  }
  
  return 0;
}



Measured memory_bytes: 3384
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll long long
#define P pair<ll,ll>
#define cat(p) cout<<p<<endl
#define catA(p,n) for(int i=0;i<n;i++)cout<<p[i]<<((i==n-1)?"\n":" ")

int n;
vector<P>t;

int main(){
  cin>>n;
  rep(i,n){
    ll a,b;
    cin>>a>>b;
    t.pb(mp(b,a));
  }
  sort(t.begin(),t.end());

  ll time=0;

  rep(i,n){
    ll a=t[i].second,b=t[i].first;

    time+=a;
    if(time>b){
      cout<<"No"<<endl;
      return 0;
    }
  }

  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 6544
#include<iostream>
#include<cstdlib>
#include<stack>
#include<queue>
using namespace std;

int max(int x, int y);
int min(int x, int y);
int gcd(int x, int y);	/*最大公約数*/
int lcm(int x, int y);	/*最小公倍数*/
void swap(int* x, int* y);	/*値の交換*/
void downsort(int* a, int n);	/*降順ソート*/
void upsort(int* a, int n);	/*昇順ソート*/

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*/


/*ここからmain関数*/

int main()
{
	int N, M, C;
	int B[20];
	int A[20][20];

	cin >> N >> M >> C;
	for (int i = 0;i < M;i++)
		cin >> B[i];
	for (int i = 0;i < N;i++)
		for (int j = 0;j < M;j++)
			cin >> A[i][j];

	int ans = 0;

	for (int i = 0;i < N;i++)
	{
		int sum = C;
		for (int j = 0;j < M;j++)
			sum += A[i][j] * B[j];
		if (sum > 0)
			ans++;
	}
	
	cout << ans;

	return 0;
}

/*2数の大きい方を返す*/
int max(int x, int y)
{
	int max;

	if (x < y)
		max = y;
	else
		max = x;

	return max;
}

/*2数の小さい方を返す*/
int min(int x, int y)
{
	int min;

	if (x < y)
		min = x;
	else
		min = y;

	return min;
}

/*2数の最大公約数を返す*/
int gcd(int x, int y)
{
	int m;
	int gcd = 1;

	m = min(x, y);

	for (int i = 1;i <= m; i++)
	{
		if (x%i == 0 && y%i == 0)
			gcd = i;
	}

	return gcd;
}

/*2数の最小公倍数を返す*/
int lcm(int x, int y)
{
	int m;

	for (int i = 1;i <= y;i++)
	{
		if ((x*i) % y == 0) {
			m = x * i;
			break;
		}
	}

	return m;
}

/*2数の値を交換する*/
void swap(int* px, int* py)
{
	int temp;

	temp = *px;
	*px = *py;
	*py = temp;
}

/*クイックソートによる降順並べ替え*/
void downsort(int* a, int n)
{
	//初期設定
	int l = 0, r = n - 1;

	// ピボットの決定
	int piv = *a;

	//ピボットより大を左に、ピボット以下を右に
	while (l < r)
	{
		if (*(a + l) > piv)
			l++;
		else if (*(a + r) <= piv)
			r--;
		else
			swap(a + l, a + r);
	}

	//再帰処理
	if (n == 2)
		return;
	else if (l == 1 || l == 0)
		downsort(a + 1, n - 1);
	else if (r == n - 1)
		downsort(a, n - 1);
	else
	{
		downsort(a, l);
		downsort(a + l, n - l);
	}
}

/*クイックソートによる昇順ソート*/
void upsort(int* a, int n)
{
	downsort(a, n);

	for (int i = 0;i < n / 2;i++)
		swap(a[i], a[n - 1 - i]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
int main()
{
    fast();
    char a;
    cin>>a;
    if(a>='a'&&a<='z')
    cout<<"a\n";
    else
    cout<<"A\n";
    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int maskNum,commandNum,command,k;
    unsigned long num = 0,one = 1,index,bit;
    cin >> maskNum;
    unsigned long masks[maskNum];

    for(int i = 0;i < maskNum;++i){
        masks[i] = 0;
        cin >> k;
        for(int j = 0;j < k;++j){
            cin >> bit;
            bit = one << bit;
            masks[i] = masks[i] | bit;
        }
    }

    cin >> commandNum;
    for(int i = 0;i < commandNum;++i){
        cin >> command >> index;
        switch (command) {
                // test(i): i番目のフラグの状態がONの場合1、OFFの場合0を出力する
            case 0:{
                index = one << index;
                bool on = (num & index) > 0 ? true : false;
                cout << on << endl;
                break;
            }
            // set(i): i番目のフラグをONにする
            case 1:
                num = masks[index] | num;
                break;
                // clear(i): i番目のフラグをOFFにする
            case 2:
                num =  ~masks[index] & num;
                break;
                // flip(i): i番目のフラグを反転する
            case 3:
                num = masks[index] ^ num;
                break;
                // all(m): 指定されたマスクが表す部分の全てのフラグがONになっている場合1、なっていない場合0を出力する
            case 4:{
                bool isAll = (masks[index] & num) == masks[index] ? true : false;
                cout << isAll << endl;
                break;
            }
            // any: 指定されたマスクが表す部分のいずれかのフラグがONになっている場合1、なっていない場合0を出力する
            case 5:{
                bool isAny = (masks[index] & num) > 0 ? true : false;
                cout << isAny << endl;
                break;
            }
            // none(m): 指定されたマスクが表す部分の全てのフラグがOFFになっている場合1、なっていない場合0を出力する
            case 6:{
                bool isNone = (masks[index] & num) > 0 ? false : true;
                cout << isNone << endl;
                break;
            }
            // count(m): 指定されたマスクが表す部分のONになっているフラグの数を出力する
            case 7:{
                int bitNum = 0;
                unsigned long bit = one;
                for(int i = 0;i < 64;++i){
                    bit = one << i;
                    if(masks[index] & bit){
                        if((num & bit) > 0){
                            bitNum++;
                        }
                    }
                }
                cout << bitNum << endl;
                break;
            }
            // val: 状態の整数値を出力する
            default:{
                cout << (masks[index] & num) << endl;
                break;
            }
        }
    }
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define int long long
#define all(c) (c).begin(),(c).end()
#define pii pair<long long,long long>
#define endl '\n'

using namespace std;

signed main(){
    std::ios::sync_with_stdio(false);
    int n,a,b;
    cin >> n >> a >> b;
    int ans=(n/(a+b))*a;
    int rem=n%(a+b);
    ans+=min(rem,a);
    cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
void q(long int a[],int s,int t){
  if(s<t){
    int i=s,j=t,p=a[s];
    while(1){
      while(a[i]<p)i++;
      while(p<a[j])j--;
      if(i>=j)break;
      a[i]^=a[j]^=a[i]^=a[j];
      i++;j--;
    }
    q(a,s,i-1);q(a,j+1,t);
  }
}
int main(){
  long int a[200000],b[200000];
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%ld%ld",&a[i],&b[i]);
  q(a,0,n-1);q(b,0,n-1);
  if(n%2)printf("%ld",b[n/2]-a[n/2]+1);
  else printf("%ld",b[n/2-1]+b[n/2]-a[n/2-1]-a[n/2]+1);
}


Measured memory_bytes: 4856
[N,M] = list(map(int,input().split()))
K = []
A = []
for i in range(N):
    X = list(map(int,input().split()))
    K.append(X[0])
    A.append(X[1:])

P = [0]*M

for i in range(N):
    for j in A[i]:
        P[j-1] += 1

cnt = 0
for i in P:
    if i==N:
        cnt += 1
print(cnt)


Measured memory_bytes: 38256
x=int(input())
if x%7==2 :
  print('sat')
  
elif x%7==3 :
  print('sun')
  
elif x%7==4 :
  print('mon')
  
elif x%7==5 :
  print('tue')
  
elif x%7==6 :
  print('wed')
  
elif x%7==0 :
  print('thu')
  
elif x%7==1 :
  print('fri')



Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
long long n,a[101010],s[101010],ans,nw;
int main()
{
	cin>>n;
	for(int i=0;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=n;i>=0;i--)
	{
		s[i]=s[i+1]+a[i];
	}
	for(int i=0;i<=n;i++)
	{
		if(i!=0)
		{
			nw=min(nw*2,s[i]);
		}
		else
		{
			nw=1;
		}
		ans+=nw;
		if(nw<a[i])
		{
			cout<<-1<<endl;
			return 0;
		}
		nw-=a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5160
#include<stdio.h>
int main(void)
{
	int a[4],b[4],c,d[4];
	for(c=0;c<4;c++){
		scanf("%d %d",&a[c],&b[c]);
		if(a[c]==1){
			d[c]=6000*b[c];
		}
		if(a[c]==2){
			d[c]=4000*b[c];
		}
		if(a[c]==3){
			d[c]=3000*b[c];
		}
		if(a[c]==4){
			d[c]=2000*b[c];
		}
		printf("%d\n",d[c]);
	}
	return 0;
}

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

int main() {
  	int n;
    string a;
 	cin >> n ;
    if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
    {
    a = "hon";
    }
        if(n%10 == 0||n%10 == 1||n%10 == 6||n%10 == 8)
    {
    a = "pon";
    }
          if(n%10 == 3)
    {
    a = "bon";
    }
    
	cout << a;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(){
    int n, m, i;
    char dat[128];
    while(1){
        scanf(" %d", &n);
        if (!n)
            return 0;
        for (i=0; i<128; i++)
            dat[i] = 0;
        for (i=0; i<n; i++){
            char ca, cb;
            scanf(" %c %c", &ca, &cb);
            dat[ca] = cb;
        }
        scanf(" %d", &m);
        for (i=0; i<m; i++){
            char c;
            scanf(" %c", &c);
            if (dat[c])
                printf("%c", dat[c]);
            else
                printf("%c", c);
        }
        printf("\n");
    }
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

vector<vector<int> > query(30);
vector<P> Query;
int N, Q;
string s;

int dfs(int time, int i, int last){
  if(i == -1 || i == N) return i == last;
  time = *lower_bound(query[s[i] - 'A'].begin(), query[s[i] - 'A'].end(), time);
  if(time == Q) return 0;
  
  char t = Query[time].first, d = Query[time].second;
  assert(t == s[i]);
  int res = 0;
  if(d == 'L') res = dfs(time+1, i - 1, last);
  else res = dfs(time + 1, i + 1, last);
  return res;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin>>N>>Q;
  cin>>s;
  for(int i=0;i<Q;i++){
    char t, d;
    cin>>t>>d;
    query[t - 'A'].push_back(i);
    Query.push_back(P(t, d));
  }

  for(int i=0;i<30;i++) query[i].push_back(Q);

  int a, b;
  {
    int L = 0, R = N;
    while(L + 1 < R){
      int M = (L + R) / 2;
      int r = dfs(0, M, -1);
      r == 1? (L = M):(R = M);
    }
    a = R;
  }
  
  {
    int L = 0, R = N;
    while(L + 1 < R){
      int M = (L + R) / 2;
      int r = dfs(0, M, N);
      r == 1? (R = M):(L = M);
    }
    b = N - R;
  }

  int ans = max(0, N - (a + b));
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 8072
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  string s, t;
  int n;
  cin >> s >> n;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '1') {
      t += '1';
    } else {
      t += s[i];
      break;
    }
  }
  --n;
  if (n < t.size()) {
    cout << t[n] << endl;
  } else {
    cout << t.back() << endl;
  }
  return 0;
}


Measured memory_bytes: 256
a=int(input())
in_list=[]
in_list.append(a)

n=0
while True:
    if in_list[n]%2==1:
        in_list.append(int(3*in_list[n]+1))
    if in_list[n]%2==0:
        in_list.append(int(in_list[n]/2))
    if in_list[n+1] in in_list[0:n]:
        print(n+2)
        break
    n+=1

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes\n";
            rr;
        }
        a -= d;
        if (a <= 0) {
            cout << "No\n";
            rr;
        }
    }
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define REP(a,b) for(long long a = 0;a < b;++a)
int main(){
    int n;
    cin >> n;
    vector<int> hoge;
    REP(i,n){
        int a;
        cin >> a;
        hoge.push_back(a);
    }
    REP(tere,2){
        int now = 1;
        for(int i = 0;i < n;++i){
            if(i >= now){
                cout << "no" << endl;
                return 0;
            }
            now = max(now,1 + i + hoge[i]/10);
        }
        reverse(hoge.begin(),hoge.end());
    }
    cout << "yes" << endl;
    return 0;
}


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

ll mod = 1000000007;
ll modpow(ll a, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll com(ll a, ll b){
	ll res = 1;
	b = min(b, a-b);
	ll n = b;
	for(int i=0; i<n; i++){
    	res *= a;
    	if(res >= mod) res %= mod;
    	res *= modpow(b, mod-2);
    	if(res >= mod) res %= mod;
    	a--;
    	b--;
    }
	return res;
}

int main(){
	int n, k;
	cin >> n >> k;
	int rim = min(k, n-k+1); 
	for(int i=1; i<=k; i++){
      if(i <= rim){
      	cout << com(k-1, i-1)*com(n-k+1, i)%mod << endl;
      }else{
 	    cout << 0 << endl;
      }
    }
}

Measured memory_bytes: 256
A, B, C = [int(x) for x in input().split()]
K = int(input())

for _ in range(K):
    if max(A, B, C) == A:
        A *= 2
    elif max(A, B, C) == B:
        B *= 2
    else:
        C *= 2
ans = A + B + C

print(ans)


Measured memory_bytes: 2940
using System;
public class C
{
    public static void Main()
    {
        var list = Console.ReadLine().Split(' ');
        var a = long.Parse(list[0]);
        var b = long.Parse(list[1]);
        var c = long.Parse(list[2]);
        if (c - a - b <= 0)
        {
            Console.WriteLine("No");
        } else {
            Console.WriteLine((a * a + b * b + c * c > 2 * (a * b + b * c + c * a)) ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 11092
from collections import Counter
import itertools
import math

n, p = map(int, input().split())
alist = map(int, input().split())

d = Counter()
for a in alist:
    d[a % 2] += 1

# print(d)

zeros = 2 ** d[0]


ones = 0
if p == 0:
    for i in range(d[1]+1):
        if i % 2 == 0:
            ones += math.factorial(d[1]) // (math.factorial(d[1] - i) * math.factorial(i))
        # print(i)
        # print(ones)
else:
    for i in range(d[1]+1):
        if i % 2 == 1:
            ones += math.factorial(d[1]) // (math.factorial(d[1] - i) * math.factorial(i))
        # print(i)
        # print(ones)

# print(zeros)
# print(ones)

print(zeros * ones)


Measured memory_bytes: 3316