akhauriyash/Code-Regression huggingface dataset:
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 998244353, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

ll f[ohara], fr[ohara];

ll mod_pow(ll xx, ll nn, ll mod) {
  ll ret = 1;
  while (nn > 0) {
    if (nn & 1) ret = ret * xx % mod;
    xx = xx * xx % mod;
    nn >>= 1;
  }
  return ret;
}

ll ncr(ll nn, ll r) {
  if (nn < r) return 0;
  return f[nn] * fr[r] % MOD * fr[nn - r] % MOD;
}

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> a >> b >> k;

  f[0] = 1;
  rrep(i, 1, n + 3) { f[i] = f[i - 1] * i % MOD; }
  fr[n + 2] = mod_pow(f[n + 2], MOD - 2, MOD);
  rrrep(i, n + 1, 0) { fr[i] = fr[i + 1] * (i + 1) % MOD; }

  rep(i, n + 1) {
    ll re, bl;
    re = i;
    if ((k - re * a) % b != 0) continue;
    bl = (k - re * a) / b;
    if (bl < 0) continue;
    ll add;
    add = ncr(n, re);
    add *= ncr(n, bl);
    add %= MOD;
    ans += add;
    ans %= MOD;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
#define FIO "sample"
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

const int maxn=30;
int n;char s[maxn],st[maxn];

bool vis[300];

int main()
{
#ifdef dxymaster
	freopen(FIO".in","r",stdin);
	freopen(FIO".out","w",stdout);
#endif
	for(int i=1;i<=26;i++)
		st[i]='z'-i+1;
	cin>>(s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)
		vis[s[i]] = 1;
	if(n>26) return puts("-1"),0;
	if(n<26)
	{
		char ch;
		for(ch='a';ch<='z';++ch)
			if(!vis[ch]) break;
		printf("%s",s+1);
		putchar(ch);putchar(10);
		return 0;
	}
	else
	{
		bool flag=1;
		for(int i=1;i<=n;i++)
			if(st[i]!=s[i])
			{
				flag=0;
				break;
			}
		if(flag) return puts("-1"),0;
		for(int i=n;i>=1;i--)
		{
			for(int j=s[i]+1;j<='z';j++)
			{
				if(!vis[j])
				{
					s[i]=j;
					for(int k=1;k<=i;k++)
						putchar(s[k]);
					putchar(10);
					return 0;
				}
			}
			vis[s[i]]=0;
		}
		return 0;
	}

	return 0;
}



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

using namespace std;

int main() {
	char S[5];
	cin >> S;
	int A = S[0] - '0', B = S[1] - '0', C = S[2] - '0', D = S[3] - '0';

	if (A + B + C + D == 7) {
		cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
	}
	else if (A + B + C - D == 7) {
		cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
	}
	else if (A + B - C - D == 7) {
		cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
	}
	else if (A + B - C - D == 7) {
		cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
	}
	else if (A - B - C - D == 7) {
		cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
	}
	else if (A - B + C + D == 7) {
		cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
	}
	else if (A - B - C + D == 7) {
		cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
	}
	else if (A + B - C + D == 7) {
		cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
	}
	else if (A - B + C - D == 7) {
		cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
	}


	return 0;
}

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

int n, A, B, C, l[8], ans = 1e9;
void dfs(int cur, int a, int b, int c, int sum)
{
    if (cur == n)
    {
        if (a*b*c)
        {
            ans = min(ans, abs(a - A) + abs(b - B) + abs(c - C) + sum - 30);
        }
        return;
    }
    dfs(cur + 1, a, b, c, sum);
    dfs(cur + 1, a + l[cur], b, c, sum + 10);
    dfs(cur + 1, a, b + l[cur], c, sum + 10);
    dfs(cur + 1, a, b, c + l[cur], sum + 10);
}
int main()
{
    cin >> n >> A >> B >> C;
    for (int i = 0; i < n; i++)
    {
        cin >> l[i];
    }
    dfs(0, 0, 0, 0, 0);
    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
original_list = list(map(int, input().split()))


num = 1
_index = None
num_index_list = []

for i in range(N):
    if original_list[i] == num:
        num_index_list.append([num, i])
        num += 1
    else:
        pass

time = N - len(num_index_list)

if time == N:
    print(-1)
else:
    print(time)

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

int main() { 
  int N, A, X, sum;
  cin >> N;
  A = N;
  sum = 0;
  for (int i = 0;i < 9; i++){
    sum += N % 10;
    N /= 10;
      if (N == 0)
        break;
  }
  if(A % sum ==0)
    cout << "Yes"<< endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
/*
AIZU ONLINE 0002

Digit Number
*/

#include <stdio.h>
#include <string.h>

main()
{
  int a,b;
  char buf[10];

  while(EOF != scanf("%d %d",&a,&b))
    {
      sprintf(buf,"%d\0",a+b);
      printf("%d\n",strlen(buf));
    }

  return(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int N,G;
  cin >> N >> G;
  vector<int> a(N);
  vector<int> b(N);
  int mini=99999999;
  rep(i,N)
    cin >> a.at(i) >> b.at(i);
  rep(i,N){
    for(int tmp=0;tmp < (1 << N);tmp++){
      bitset<13> s(tmp);
      int sum=0;
      int ques=0;
      rep(j,N){
        if(j != i){
          if(s.test(j)){
          sum += (a.at(j)*(j+1)*100+b.at(j));
          ques += a.at(j);
          }
        }
      }
      if(sum < G){
        if(sum+(i+1)*100*a.at(i)+b.at(i)>=G){
          if(sum+(i+1)*100*a.at(i)>=G){
          if((G-sum)%((i+1)*100)==0)
            ques += (G-sum)/((i+1)*100);
          else
            ques += ((G-sum)/((i+1)*100)+1);
          }
          else
            ques += a.at(i);
        }
        else
          ques=999999999;
      }
      mini=min(mini,ques);
    }
  }
  cout << mini << endl;
}
      
          
        
      
      
      
  
    
    
  

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;

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

  ll a, b; cin >> a >> b;
  if(a*b <= 0) {
    cout << "Zero" << '\n';
    return 0;
  }

  bool flag = false;
  if(b < 0 && !((b-a)&1)) flag = true;
  cout << (flag ? "Negative" : "Positive") << '\n';
  return 0;
}


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

l = 0
r = 0
sum_A = 0
res = 0

for l in range(N):
    while(r < N):
        if ((sum_A & A[r]) == 0):
            sum_A += A[r]
            r += 1
        else:
            break
    res += (r - l)
    sum_A -= A[l]

print(res)


Measured memory_bytes: 24712
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    int l, r, d; cin >> l >> r >> d;
    int cnt = 0;
    Rep(i, l, r+1) {
        if(i % d == 0) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

vector<P> es;
vector<ll> ls;
vector<ll> xs;
ll L,N,n;

ll L2(ll x){ //ビットの個数
  ll res = 0;
  while(x>0){
    x = (x>>1);
    res++;
  }
  return res;
}

ll pow2(ll x){
  return (1LL<<x);
}
//
// ll tori(ll x){
//   return 1LL<<L2(x);
// }

ll nbit(ll x){
  ll res = 0;
  while(x%2){
    x = (x>>1);
    res++;
  }
  return res;
}

int main()
{
  cin>>L;
  L--;
  N = L2(L);
  // cout<<N<<endl;
  n = N;
  rep(i,N-1){
    es.pb(P(i+1,i));
    es.pb(P(i+1,i));
    ls.pb(0LL);
    ls.pb(pow2(i));
    // cout<<pow2(i)<<endl;
  }

    ll H = nbit(L);
  if(L2(L)!=L2(L+1)){
    N++;
    es.pb(P(N-1,N-2));
    es.pb(P(N-1,N-2));
    ls.pb(0LL);
    ls.pb(pow2(N-2));
    goto en;
  }

  es.pb(P(N-1,H));
  ls.pb(L- ((1<<H) -1 ) );

  for(ll i=H;i<N-1;i++){
    if( (L>>i) & 1LL ){
      es.pb(P(N-1,i));
      ls.pb( (L>>(i+1))<<(i+1) );
    }
  }

  en: ;
  cout<<N<<" "<<int(es.size())<<endl;
  rep(i,es.size()){
    cout<<N-es[i].fr<<" "<<N-es[i].sc<<" "<<ls[i]<<endl;
  }
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)turn idx;
#define deg_to_rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad_to_deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)

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;
};

pair<int, char> to_score(char ch, int R, int S, int P) {
  int ret = 0;
  char retch;
  if (ch == 'r') {
    ret = P;
    retch = 'p';
  } else if (ch == 's') {
    ret = R;
    retch = 'r';
  } else {
    ret = S;
    retch = 's';
  }
  return make_pair(ret, retch);
};

pair<int, char> to_s(char ch, char ch2, char ch3, int R, int S, int P) {
  int ret = 0;
  char retch = 'q';
  if (ch == 'r') {
    if (ch2 == 'p' || ch3 == 'p'  || ch2 == 'q') {
      ret = P;
      retch = 'p';
    }
  } else if (ch == 's') {
    if (ch2 == 'r' || ch3 == 'r'  || ch2 == 'q') {
      ret = R;
      retch = 'r';
    }
  } else if (ch == 'p') {
    if (ch2 == 's' || ch3 == 's' || ch2 == 'q') {
      ret = S;
      retch = 's';
    }
  }
  return make_pair(ret, retch);
};

int main() {
  int N, K, R, S, P;
  cin >> N >> K >> R >> S >> P;
  string T;
  cin >> T;

  int ans = 0;
  vector<char> memo(N);

  rep(i, 0, K) {
    char ch = T[i];
    auto tmp = to_score(ch, R, S, P);
    ans += tmp.first;
    memo[i] = tmp.second;
  }

  rep(i, K, T.size()) {
    char ch = T[i];
    char ch2, ch3;
    char ch4 = memo[i - K];
    if (ch4 == 'r') {
      ch2 = 's';
      ch3 = 'p';
    } else if (ch4 == 's') {
      ch2 = 'p';
      ch3 = 'r';
    } else if (ch4 == 'p') {
      ch2 = 'r';
      ch3 = 's';
    } else if (ch4 == 'q') {
      ch2 = ch3 = 'q';
    }

    auto tmp = to_s(ch, ch2, ch3, R, S, P);
    ans += tmp.first;
    memo[i] = tmp.second;
  }

  cout << ans << endl;
};


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    string s;
    cin >> s;

    string ans;
    rep(i, s.length())
    {
        ans += 'x';
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import math
n=int(input())
for i in range(1,n+1):
    nn=int(math.sqrt(i))
    min=int((nn+1)/math.sqrt(3))
    min1=int((nn+1)/math.sqrt(2))
    count=0
    for x in range(1,min+1):
        for y in range(x,min1+1):
            for z in range(y,nn+1):
                #print(x*x+y*y+z*z+x*y+y*z+z*x)
                if (x*x+y*y+z*z+x*y+y*z+z*x)==i:
                    if x==y and y==z and z==x:
                        count=count+1
                    elif x!=y and y!=z and z!=x:
                        count=count+6
                    else:
                        count=count+3
    print(count)


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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

int n,m;

int main(){
  cin >> n >> m;
  cout << (n*(n-1))/2+(m)*(m-1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
using ll=long long;
#include<algorithm>
#include<set>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using P=pair<int,int>;
const int mod=1000000007;


int main(){
ll n,a,b;
cin>>n>>a>>b;
ll c=a+b;
ll ans=(n/c)*a;
ans+=min(n%c,a);
cout<<ans<<endl;
return 0;
}

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

int main() {
  int a,b,m,mi;
  cin >> a >> b >> m;
  vector<int>A(a);
  vector<int>B(b);
  vector<int>AA;
  vector<int>BB;
  rep(i,a) cin >> A[i];
  rep(i,b) cin >> B[i];
  AA = A;
  BB = B;
  sort(AA.begin(),AA.end());
  sort(BB.begin(),BB.end());
  mi = AA[0]+BB[0];
  rep(i,m){
    int x,y,c;
    cin >> x >> y >> c;
    x--;y--;
    mi = min(mi,A[x]+B[y]-c);
  }
  cout << mi << endl;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
{
    int k,x;
    cin>>k>>x;
    if(k==1){
        cout<<x<<endl;
    }
    else{
        int min,max;
        min=x-k+1;
        max=x+k-1;

        for(int i=min;i<=max;i++){
        cout<<i<<" ";
        if(i==max){
            cout<<"\n";
        }
        }

    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a, b, ap, bp, n;
		
		n = scanner.nextInt();
		while(n != 0) {
			ap = bp = 0;
			for(int i = 0; i < n; i++) {
				a = scanner.nextInt();
				b = scanner.nextInt();
				if (a == b) {
					ap += a;
					bp += a;
				} else if (a > b) {
					ap += a + b;
				} else {
					bp += a + b;
				}
			}
			System.out.println(String.format("%d %d", ap, bp));
			n = scanner.nextInt();
		}
	}
}

Measured memory_bytes: 57976
import numpy as np

N = input()
l = [i for i in range(int(N))]
M = 0
A = 0
R = 0
C = 0
H = 0
for j in range(int(N)):
  l[j] = input()
  if l[j][0] =="M":
    M = M+1
  elif l[j][0] =="A":
    A = A+1
  elif l[j][0] =="R":
    R = R+1
  elif l[j][0] =="C":
    C = C+1
  elif l[j][0] =="H":
    H = H+1
  else: pass

a = np.array([M,A,R,C,H])
ch = np.nonzero(a)
ch = ch[0]
re = 0
if len(ch)<3:
  re = 0
else:
  re = M*A*R+M*A*C+M*A*H
  re = re + M*R*C+M*R*H
  re = re + M*C*H
  re = re + A*R*C+A*R*H+A*C*H
  re = re + R*C*H

print(re)

Measured memory_bytes: 19064
#include<bits/stdc++.h>
using namespace std;
#define N 200005
char s[N];
int a[N],f[N],g[(1<<26)+5];
int len;
int main()
{
	scanf("%s",s+1);
	len=strlen(s+1);
	for(int i=1;i<=len;i++)
	  a[i]=a[i-1]^(1<<(s[i]-'a'));
	memset(g,0x3f,sizeof(g));
	memset(f,0x3f,sizeof(f));
	g[0]=f[0]=0;
	for(int i=1;i<=len;i++)
	{
		f[i]=min(f[i],g[a[i]]);
		for(int j=1;j<(1<<26);j<<=1)
		  f[i]=min(f[i],g[a[i]^j]);
		f[i]++;
		g[a[i]]=min(g[a[i]],f[i]);
	}
	printf("%d",f[len]);
	return 0;
}

Measured memory_bytes: 264320
function main(input) {
	const pqr = input.trim().split(" ").map(n => Number(n));
  	const cmb = [[0, 1], [0, 2], [1, 2]];
  	const result = [];
  	cmb.forEach(c => {
      	const time = pqr[c[0]] + pqr[c[1]];
      	result.push(time);
    });
  	console.log(Math.min(...result));
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  // i∊Nから各桁の値を抽出する
  int a1, a2, a3, a4;
  int sum = 0;
  for (int i=1; i<=N; ++i) {
    a1 = i % 10;  // 1桁目
    a2 = i / 10 % 10;  // 2桁目
    a3 = i / 100 % 10;  // 3桁目
    a4 = i / 1000 % 10;  // 4桁目
    
    // 各桁の値の総和を求める
    int sum_ = a1 + a2 + a3 + a4;
    //cout << i << " " << sum_ << endl;
    // N == 10000の場合のみ例外
    if (sum_ == 0) {
      sum_ = 1;
    }
    // 総和がA以上B以下ならsumに加える
    if (A <= sum_ && sum_ <= B) {
      sum += i;
      //cout << i << " " << sum << endl;
    }
  }
  
  cout << sum << endl;
}
  
  

Measured memory_bytes: 256
input_str = list(input())
ans = ''
for i in input_str:
    if i == '0':
        ans = ans +'0'
    elif i == '1':
        ans = ans + '1'
    elif i == 'B':
        if ans == None:
            continue
        else:
            ans = ans[:-1]
print(ans)

Measured memory_bytes: 9048
N, X, Y = map(int, input().split())

ans = [0]*(N-1)
for i in range(1, N):
    for j in range(i+1, N+1):
        a = min(j-i, abs(X-i)+1+abs(Y-j))
        ans[a-1] += 1

print(*ans, sep='\n')


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

int main(){
    int n;
    cin >> n;
    double t, a, x;
    double delta = 10000000.0;
    cin >> t >> a;
    int ans;
    for(int i = 1; i <= n; ++i){
        cin >> x;
        if(fabs(t - 0.006 * x - a) < delta)
            delta = abs(t - 0.006 * x - a), ans = i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
MAX_P = 100000 * 10000

n, k = map(int, input().split())
w = list()
for _ in range(n):
    w.append(int(input()))


# k台のトラックに、積載量Pでいくつ荷物が載せられるか
# 0 <= r <= n
def check(p):
    k_no = 1
    tmp = 0
    for i, wi in enumerate(w):
        if wi > p:
            return i
        if tmp + wi > p:
            if k_no == k:
                return i
            else:
                k_no += 1
                tmp = wi
        else:
            tmp += wi
    return len(w)


def solve():
    left = 1
    right = MAX_P

    while right - left > 1:
        mid = (left + right) // 2
        v = check(mid)  # v個載せられる
        if v < n:
            left = mid
        else:
            right = mid

    # print("left", left)
    # print("right", right)
    if check(left) >= n:
        return left
    else:
        return right

# for i in range(10):
#     print(i, check(i))

print(solve())


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

int main() {
    string s;
    cin >> s;
    int n = s.length();

    string ans;
    if (n < 26) {
        bool include[26];
        for (int i = 0; i < 26; i++) {
            include[i] = false;
        }
        for (int i = 0; i < n; i++) {
            include[(int)(s[i] - 'a')] = true;
        }
        ans = s;
        for (int i = 0; i < 26; i++) {
            if (!include[i]) {
                ans += (char)('a' + i);
                break;
            }
        }
    } else {
        bool flag = false;
        for (int i = n - 1; i > 0; i--) {
            if (s[i - 1] < s[i]) {
                flag = true;
                ans = s.substr(0, i - 1);
                for (int j = n - 1; j >= i; j--) {
                    if (s[j] > s[i - 1]) {
                        ans += s[j];
                        break;
                    }
                }
                break;
            }
        }
        if (!flag) ans = "-1";
    }

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

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int m;
    cin>>m;
    int a[m],b[m];
    int p=1;
    for(int i=1;i<n;i++)
    {
        p=p*10;
    }
    if(m==0)
    {
        if(n==1)
        {
            cout<<0<<endl;
        }else
        {
            cout<<p<<endl;
        }
        return 0;
    }
    vector< pair <int,int> >par;
    for(int i=0;i<m;i++)
    {
        cin>>a[i]>>b[i];
        par.push_back(make_pair(a[i],b[i]));
    }
    sort(par.begin(),par.end());
    if(par[0].first==1 && par[0].second==0 && n!=1)
    {
        cout<<-1<<endl;
        return 0 ;
    }
    for(int i=0;i<(m-1);i++)
    {
        if(par[i].first==par[i+1].first)
        {
            if(par[i].second!=par[i+1].second)
            {
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    int t=0;
    int br=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(i==par[j].first)
            {
                t=1;
                br=br+p*par[j].second;
                break;
            }
        }
        if(t==0)
        {
            if(i==1)
            {
                br=br+p*1;
            }else
            {
                br=br+0;
            }
        }
        p=p/10;
        t=0;
    }
    cout<<br<<endl;
}


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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

int k;

int main()
{
    cin >> k;
    cout << (k / 2) * (k / 2 + k % 2) << endl;
}

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

int main()
{
    int d,g,p[11],c[11];
    cin>>d>>g;
    REP(i,d)cin>>p[i]>>c[i];

    int ans=1e9;
    REP(bit,(1<<d))
    {
        int s=0,num=0,rest=-1;
        REP(i,d)
        {
            if(bit>>i&1)
            {
                s+=100*(i+1)*p[i]+c[i];
                num+=p[i];
            }else
            {
                rest=i;
            }
        }
        if(s<g)
        {
            int s1=100*(rest+1);
            int need=(g-s+s1-1)/s1;
            if(need>=p[rest])continue;
            num+=need;
        }
        ans=min(ans,num);
    }
    cout<<ans<<endl;
}


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

const int N = 200005;
const int inf = 1e9;

int n, f[N][2];
char str[N];

void pri(int x, int y)
{
	if (!x) return;
	if (str[x] == '?') str[x] = y ? 'D' : 'P';
	if (!y)
	{
		if (f[x][0] == f[x - 1][0]) pri(x - 1, 0);
		else pri(x - 1, 1);
	}
	else
	{
		if (f[x][1] == f[x - 1][0] + 2) pri(x - 1, 0);
		else pri(x - 1, 1);
	}
}

int main()
{
	scanf("%s", str + 1);
	n = strlen(str + 1);
	if (str[1] == 'D') f[1][0] = -inf, f[1][1] = 1;
	else if (str[1] == 'P') f[1][1] = -inf;
	else f[1][1] = 1;
	for (int i = 2; i <= n; i++)
		if (str[i] == 'P') f[i][1] = -inf, f[i][0] = max(f[i - 1][0], f[i - 1][1]);
		else if (str[i] == 'D') f[i][0] = -inf, f[i][1] = max(f[i - 1][0] + 2, f[i - 1][1] + 1);
		else f[i][0] = max(f[i - 1][0], f[i - 1][1]), f[i][1] = max(f[i - 1][0] + 2, f[i - 1][1] + 1);
	if (f[n][0] > f[n][1]) pri(n, 0);
	else pri(n, 1);
	for (int i = 1; i <= n; i++) putchar(str[i]);
	return 0;
}

Measured memory_bytes: 5448
def resolve():
    k,x = map(int,input().split())
    if k == 1:
        print(x+k-1)
    else:
        for i in reversed(range(k)):
            print('{} '.format(x-i),end='')
        for i in range(1,k-1):
            print('{} '.format(x+i),end='')
        print(x+k-1)
resolve()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;

int main(){
    int n;  cin >> n;
    vector<string> s(n);
    for(int i=0; i<n; i++)  cin >> s.at(i);
   

    ll ac=0, bc=0, either=0, cnt=0;
    for(int i=0; i<n; i++){
        if(s[i][0]=='B' && s[i].back()=='A') either += 1;
        else if(s[i].back()=='A') ac += 1;
        else if(s[i][0]=='B') bc += 1;

        for(int j=0; j<s[i].size()-1; j++)
            if(s[i][j]=='A' && s[i][j+1]=='B') cnt += 1;   
    }
    
    if(ac==0 && bc==0) cnt += max(0LL, either-1);
    else cnt += min(ac, bc) + either;
    
    cout << cnt << endl;
    
}

Measured memory_bytes: 768
def main():
    n = int(input())
    L = []
    L.append(2)
    L.append(1)
    for i in range(2, n + 1):
        L.append(L[i - 1] + L[i - 2])
    print(L[n])
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include<iomanip>

using namespace std;
typedef long long ll;

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include<iomanip>

using namespace std;
typedef long long ll;


int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> AB(N);
	for (int i = 0; i < N; i++) {
		int a, b; cin >> a >> b;
		AB[i] = make_pair(b, a);
	}
	sort(AB.begin(), AB.end());
	//bool deadline = true;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		sum += AB.at(i).second;
		if (sum > AB.at(i).first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 4816
#include<cstdio>
#define neko 100010
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))
#define travel(i,u,v) for(register int i=head[u],v=e[i].v;i;i=e[i].nex,v=e[i].v)
typedef long long ll;
int n,m,t,flag;
typedef int arr[neko];
arr head,col,book;
struct edge
{
	int v,tp,nex;
}e[neko<<1];
ll ans,tot,cnt[5];
void dfs(int u)
{
	book[u]=1,++cnt[0],++cnt[col[u]];
	travel(i,u,v)
	{
		if(e[i].tp==1)++tot;
		if(!book[v])
		{
			col[v]=(col[u]+e[i].tp+2)%3+1;//反正这样就是对的我不管啦
			dfs(v);
		}
		else if(col[v]^((col[u]+e[i].tp+2)%3+1))flag=1;
	}
}
void add(int x,int y)
{
	e[++t].v=y,e[t].tp=1,e[t].nex=head[x],head[x]=t;
	e[++t].v=x,e[t].tp=-1,e[t].nex=head[y],head[y]=t;
}
int main()
{
	int x,y;
	scanf("%d%d",&n,&m);
	f(i,1,m)scanf("%d%d",&x,&y),add(x,y);
	f(i,1,n)col[i]=1;
	f(i,1,n)
	{
		if(book[i])continue;
		cnt[0]=tot=cnt[1]=cnt[2]=cnt[3]=0;
		dfs(i);
		if(flag)ans+=cnt[0]*cnt[0],flag=0;
		else if(!(cnt[1]&&cnt[2]&&cnt[3]))ans+=tot;
		else ans+=cnt[1]*cnt[2]+cnt[2]*cnt[3]+cnt[3]*cnt[1];
	}return printf("%lld\n",ans),0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
const int mod = 1e9 + 7;

void fail() {
  cout << 0 << endl;
  exit(0);
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n, m;
  cin >> n >> m;
  vi a(n), b(m);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < m; ++i) cin >> b[i];
  sort(a.rbegin(), a.rend());
  sort(b.rbegin(), b.rend());
  ll res = 1, rem = 0;
  int ia = 0, ib = 0;
  for (int t = n * m; t >= 1; --t) {
    bool hasa = false, hasb = false;
    if (ia < a.size() && a[ia] == t) {
      hasa = true;
      ++ia;
      if (ia < a.size() && a[ia] == t) fail();
    }
    if (ib < b.size() && b[ib] == t) {
      hasb = true;
      ++ib;
      if (ib < b.size() && b[ib] == t) fail();
    }
    if (hasa && hasb) {
      rem += ia + ib - 2;
    } else if (hasa && !hasb) {
      res = res * ib % mod;
      rem += ib - 1;
    } else if (!hasa && hasb) {
      res = res * ia % mod;
      rem += ia - 1;
    } else {
      res = res * max(0LL, rem) % mod;
      --rem;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define forall(it, v) for(auto it = v.begin(); it != v.end(); ++it)
#define dforn(i, n) for(int i = ((int) n) - 1; i >= 0; i--)
#define db(v) cerr << #v << " = " << v << endl
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define ff first
#define ss second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
const int MAXN = -1;

int n;

void create(string &X, map<string, int> (&M)[20]){
    string A, Aux;
    forn(bm, 1<<n){
        A.clear(); Aux.clear();
        int p = __builtin_popcount(bm);
        forn(i, n){
            if(bm & (1<<i)) A.pb(X[i]);
            else Aux.pb(X[i]);
        }
//        cout << "bm: " << (bitset<3>) bm << endl;
//        cout << A << endl << Aux << endl;
        while(sz(Aux)){A.pb(Aux.back()); Aux.pop_back();}

        M[p][A]++;
    }
}

string S, T;
map<string, int> MS[20], MT[20];

int main(){
//	freopen("input.txt", "r", stdin);
	while(scanf("%d", &n) >= 1){
        cin >> S; T = S.substr(n, n); S = S.substr(0, n);
        reverse(T.begin(), T.end());
//        db(S); db(T);
        forn(i, 20){ MS[i].clear(); MT[i].clear();}
        create(S, MS); create(T, MT);

        ll ans = 0;
        forn(i, n+1){
            forall(it, MS[i]){
                string K = it -> ff;
                ans += (ll)MS[i][K]*MT[i][K];
            }
        }
        printf("%lld\n", ans);
    }
	return 0;
}


Measured memory_bytes: 92416
n = int(input())
p = [int(input()) for i in range(n)]
q = [0] * n
now = 1
for k,v in enumerate(p):
  q[v-1] = k
now = -1
ans = 1
mini_ans = 0
for i in q:
  if i > now:
    mini_ans += 1
  else:
    ans = max(ans,mini_ans)
    mini_ans = 1
  now = i
ans = max(ans,mini_ans)
ans = n-ans
print(ans)

Measured memory_bytes: 19016
import numpy as np
 
N,X = [int(v) for v in input().rstrip('\n').split()]
distance = np.array([int(v) for v in input().rstrip('\n').split()])

count = 1
pos = 0
 
for n in range(N):
  pos += distance[n]
  if pos <= X :
    count += 1 
 
print(count)

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    int a,b,k;
    cin>>a>>b>>k;

    Vi cd;
    REP(i,min(a,b)){
        if(a%(i+1)==0 && b%(i+1)==0){
            cd.pb(i+1);
        }
    }

    cout<<cd[cd.size()-k]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    if(abs(M1 - M2) % 10 == 1) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	buf.Split(bufio.ScanWords)

	size := 3

	a := make([][]int, size)
	for i := range a {
		a[i] = scanInts(size)
	}
	n := scanInt()
	b := scanInts(n)

	marked := make([][]bool, size)
	for i := range marked {
		marked[i] = make([]bool, size)
	}

	for _, number := range b {
		for i := 0; i < size; i++ {
			for j := 0; j < size; j++ {
				if number == a[i][j] {
					marked[i][j] = true
				}
			}
		}
	}

	for i := 0; i < size; i++ {
		if marked[i][0] && marked[i][1] && marked[i][2] {
			fmt.Println("Yes")
			return
		}
	}

	for j := 0; j < size; j++ {
		if marked[0][j] && marked[1][j] && marked[2][j] {
			fmt.Println("Yes")
			return
		}
	}

	if marked[0][0] && marked[1][1] && marked[2][2] {
		fmt.Println("Yes")
		return
	}
	if marked[2][0] && marked[1][1] && marked[0][2] {
		fmt.Println("Yes")
		return
	}

	fmt.Println("No")
}

var buf = bufio.NewScanner(os.Stdin)

func scanInt() int {
	buf.Scan()
	i, _ := strconv.Atoi(buf.Text())
	return i
}

func scanInts(n int) []int {
	a := make([]int, n)
	for k, _ := range a {
		a[k] = scanInt()
	}
	return a
}

func scanString() string {
	buf.Scan()
	return buf.Text()
}

func scanStrings(n int) []string {
	a := make([]string, n)
	for k, _ := range a {
		a[k] = scanString()
	}
	return a
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys
import random

N,M = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(M)]

# while True:
#     N = int(random.randint(1,3))
#     M = int()
    
ms = -1
upt = [False]*N
ans = [0]*N
for s,c in sc:
    ms = max(N-s,ms)
    if upt[s-1]:
        if ans[s-1] != c:
            print(-1)
            sys.exit()
        else:
            continue        
    else:
        upt[s-1] = True
        ans[s-1] = c

if upt[0]:
    if ans[0] == 0:
        if N>1:
            print(-1)
            sys.exit()
        else:
            print(0)
            sys.exit()


if M==0 and N==1:
    print(0)
    sys.exit()

A = 0
base = 1
for i,a in enumerate(reversed(ans)):
    if i==N-1 and a == 0:
        A += 1*base
        base *= 10
    else:
        A += a * base
        base *= 10
print(A)
    


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

using namespace std;

#define int long long

#define N 305

char a[N][N];
int ans[N][N];

int check(int k, int l, int r)
{
    for(int i=l;i<=r;i++)
    {
        if(a[k][i]=='#' || ans[k][i]!=0)
            return 0;
    }
    return 1;
}


int32_t main()
{
    int n, m, k;
    cin>>n>>m>>k;

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

    int cur = 1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(a[i][j]=='#')
            {
                int l = j, r =j;
                int l1 = j-1;
                while(l1>=0)
                {
                    if(a[i][l1]=='#' || ans[i][l1]!=0)
                        break;
                    l = l1;
                    l1--;
                }

                int r1= j+1;
                while(r1<m)
                {
                    if(a[i][r1]=='#' ||ans[i][r1]!=0)
                        break;
                    r = r1;
                    r1++;
                }

                for(int k=l;k<=r;k++)
                {
                    ans[i][k] = cur;
                }

                for(int k=i+1;k<n;k++)
                {
                    if(check(k, l, r))
                    {
                        for(int x=l;x<=r;x++)
                        {
                            ans[k][x] = cur;
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                for(int k=i-1;k>=0;k--)
                {
                    if(check(k, l, r))
                    {
                        for(int x=l;x<=r;x++)
                        {
                            ans[k][x] = cur;
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                cur++;
            }
        }
    }




    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			var inputArray = retreiveStringArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var S = inputArray[0];
			var inputList = new List<int>();
			var N = S.Length;

			for (int i = 0; i < N; i++) {
				inputList.Add(int.Parse(S[i].ToString()));
			}

			if (N < 4) {//4文字未満の場合は0を返す
				Console.WriteLine(0);
				return;
			}

			var mod10List = new List<int>();

			var mod10 = 1;
			for (int i = 0; i < N; i++) {
				mod10List.Add(mod10);
				mod10 = (mod10 * 10) % 2019;
			}

			var modDic = new Dictionary<int, int>();

			// k+1文字目以降を足した数をTkと表現する。
			//TkのMod2019のリストを作る
			var Tk = 0;

			modDic.Add(0, 1);
			for (int i = 1; i <= N; i++) {

				var n10 = mod10List[i - 1];
				Tk = (Tk + inputList[N - i]*n10)%2019;
				if (modDic.ContainsKey(Tk)) {
					modDic[Tk]++;
				}
				else {
					modDic.Add(Tk, 1);
				}
			}

			long sum = 0;

			foreach (var item in modDic) {

				var num = item.Value;
				sum +=  num * (num - 1) / 2;

			}

			//答えの出力
			var ans = sum;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}

	}
}


Measured memory_bytes: 36672
n=int(input())
h=list(map(int,input().split()))
count=0
while h!=[0]*n:
	find=0 #左端を見つけたかどうか
	count+=1
	for i in range(n):
		if h[i]==0 and find==1:
			break
		if h[i]!=0:
			h[i]-=1
			find=1	
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
typedef complex<double> cd;
static const double pi = 3.141592653589793;

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

  int h,w; cin >> h >> w;
  vector<int> cnt(26, 0);
  rep(i, h) {
    string s; cin >> s;
    for(auto&c:s) {
      ++cnt[c-'a'];
    }
  }

  priority_queue<int> pq;
  rep(i, 26) {
    pq.push(cnt[i]);
  }

  int need4 = (h&1 ? h - 1 : h) * (w&1 ? w - 1 : w);
  need4 /= 4;
  while(need4 > 0) {
    if(pq.empty() || pq.top() < 4) {
      cout << "No" << endl;
      return 0;
    }
    int topCnt = pq.top(); pq.pop();

    --need4;
    topCnt -= 4;
    if(topCnt) {
      pq.push(topCnt);
    }
  }

  int need2 = 0;
  if(h&1 && w&1) {
    need2 = (h + w - 2) / 2;
  } else if(h&1) {
    need2 = w / 2;
  } else if(w&1) {
    need2 = h / 2;
  }

  while(need2 > 0) {
    if(pq.empty() || pq.top() < 2) {
      cout << "No" << endl;
      return 0;
    }
    int topCnt = pq.top(); pq.pop();

    --need2;
    topCnt -= 2;
    if(topCnt) {
      pq.push(topCnt);
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 256
from math import log2
a, b = map(int, input().split())
p, q = a, b
a -= 1
if a > 0:
    n = int(log2(a))
else:
    n = -1
if b > 0:
    m = int(log2(b))
else:
    print(0)
    exit()
a_cnt = [0]*(m+1)
b_cnt = [0]*(m+1)
for i in range(m, 0, -1):
    if i <= n:
        if a >= 2**i:
            a_cnt[i] = a-2**i+1
            a -= 2**i
    if b >= 2**i:
        b_cnt[i] = b-2**i+1
        b -= 2**i

ans = [0]*(m+1)
for i in range(m+1):
    ans[i] = (b_cnt[i]-a_cnt[i])%2

tmp = 0
for i in range(1, m+1):
    if ans[i]:
        tmp += 2**i

tmp += ((q+1)//2-p//2)%2
print(tmp)


Measured memory_bytes: 3064
# https://atcoder.jp/contests/abc134/tasks/abc134_c

N = int(input())
A = []
max1 = 0
max2 = 0

for _ in range(N):
    a = int(input())
    # if max1 <= a:
    #     max2 = max1
    #     max1 = a
    # elif max2 <= a:
    #     max2 = a
    A.append(a)

# for a in A:
#     print(max1 if a != max1 else max2)


# でも制約からこんなバグりやすいプログラム書かなくても
A_sorted = sorted(A)
max1 = A_sorted[-1]
max2 = A_sorted[-2]
for a in A:
    print(max1 if a != max1 else max2)


Measured memory_bytes: 14112
#include <bits/stdc++.h>
 
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define hello777 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#include <string>
#define pie 3.14159265358979323846
constexpr int MOD = 1e9+7;
const int MAX= 1e5+5;
using namespace std;


//ll gcd(int a, int b)
//{ 
//    if (a == 0) 
//        return b;  
//    return gcd(b % a, a);  
// } 
// 
//ll lcm(int a, int b)  
// {  
//    return a/gcd(a, b) *b;  
// }
//  
//int prime(int n)
//{
//	rep(i,2,n+1)
//	{
//		if(n%i==0)return i;
//	}
//	
//vector<unordered_set<int> > prime_factors(MAX,unordered_set<int>());
//int primes[MAX];
//int prefix[MAX][6];
//void sieve(){
//    //primes i stores the largest prime factor of a number....
//    for(int i=2;i<MAX;++i){
//        if(primes[i]!=0){
//            continue;
//        }
//        primes[i] = i;
//        for(int j=2*i;j<MAX;j+=i){
//            primes[j] = i;
//        }
//    }
//    
//    for(int i=2;i<MAX;++i){
//        int current = i;
//        
//        while(current!=1){
//            prime_factors[i].insert(primes[current]);
//            current = current/primes[current];
//        }
//    }
//    
//    for(int i=1;i<MAX;++i){
//        for(int k=1;k<=5;++k){
//            prefix[i][k] = prefix[i-1][k] + (prime_factors[i].size()==k);
//        }
//    }
//    
//}
void solve() 
{
  string s,t;
  cin>>s>>t;
  int ans=0;
  rep(i,0,s.length())
  {
  	if(s[i]!=t[i])ans++;
  }
  cout<<ans<<endl;
}

int main()
{
	hello777;
	int q=1;
	
//    cin>>q;
    while(q--)
    {   
      solve();

    }
}



Measured memory_bytes: 3804
/*Lucky_Glass*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;

int main(){
	ll n;scanf("%lld",&n);
	ll X1,Y1,X2,Y2;
	X1=min(n,(ll)1e9);
	Y2=n/X1+(n%X1? 1:0);
	ll X2Y1=X1*Y2-n;
	if(X2Y1==0) X2=1,Y1=0;
	else{
		X2=Y1=-1;
		for(ll x=1;x*x<=X2Y1;x++)
			if(X2Y1%x==0){
				X2=X2Y1/x;
				Y1=x;
				break;
			}
		if(X2==-1) X2=X2Y1,Y1=1;
	}
	printf("0 0 %lld %lld %lld %lld\n",X1,Y1,X2,Y2);
	return 0;
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int Q,P,R;
  cin >> Q >> P >> R;
  int h = 1e9;
  h = min(h,Q + P);
  h = min(h,Q + R);
  h = min(h,P + R);
  cout << h << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

template< int mod >
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
};
using mint = ModInt< 1000000007 >;

signed main(){

  int S; cin >> S;
  if(S < 3){
    cout << 0 << endl;
    return 0;
  }

  vector<mint> dp(S+1, 0);
  //dp[3] = dp[4] = dp[5] = 1;
  // for(int i = 3; i <= S; i++){
  //   dp[i] = 1;
  // }
  auto dfs = [&](auto&& dfs, int s)->mint{
    if(dp[s] != 0) return dp[s];
    mint res = 1;
    for(int i = 3; i <= S; i++){
      if(s - i < 3) break;
      res += dfs(dfs, s - i);
    }
    return dp[s] = res;
  };

  mint ans = dfs(dfs, S);
  cout << ans << endl;
  // for(int i = 3; i <= S; i++){
  //   cout << dp[i] <<  " ";
  // }
  // cout << endl;

  return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
struct UnionFind{
  int n;
  vector<int> r,p,cnt;
  UnionFind(){}
  UnionFind(int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
  int sum(int x){
    return r[find(x)];
  }
};
main(){
  map<P,int>m;
  int n,m1,m2,a,b,l[200009],r[200009];
  cin>>n>>m1>>m2;
  UnionFind u1(n),u2(n);
  while(m1--){
    cin>>a>>b;a--;b--;
    u1.unite(a,b);
  }
  while(m2--){
    cin>>a>>b;a--;b--;
    u2.unite(a,b);
  }
  rep(i,n)l[i]=u1.find(i);
  rep(i,n)r[i]=u2.find(i);
  rep(i,n)m[P(l[i],r[i])]++;
  rep(i,n)cout<<m[P(l[i],r[i])]<<endl;
}

Measured memory_bytes: 16640