akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}	
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}

void solve()
{

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	int n;
	cin>>n;
	vll a(n);
	ll sum = 0;
	map<ll, ll> ct;
	for(int i = 0; i < n; i++)
	{ 
		cin>>a[i];
		ct[a[i]]++;
		sum+=a[i];
	}
	int q;
	cin>>q;
	ll b, c;
	for(int i = 0; i <q; i++)
	{
		cin>>b>>c;
		// cin>>
		ct[c]+=ct[b];
		sum=sum-(b-c)*ct[b];
		ct[b]=0;
		// for(auto i:ct)
		// {
		// 	cout<<i.fi<<"  "<<i.se<<endl;
		// }
		// cout<<endl;
		p(sum);
	}


	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int A,B,C,D;
  A=N/1000;
  B=(N-1000*A)/100;
  C=(N-1000*A-100*B)/10;
  D=N-1000*A-100*B-10*C;
  if(A+B+C+D==7){
    cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
    return 0;
  }
  if(A+B+C-D==7){
    cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
    return 0;
  }
  if(A+B-C+D==7){
    cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
    return 0;
  }
  if(A+B-C-D==7){
    cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
    return 0;
  }
  if(A-B+C+D==7){
    cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
    return 0;
  }
  if(A-B+C-D==7){
    cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
    return 0;
  }
  if(A-B-C+D==7){
    cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
    return 0;
  }
  if(A-B-C-D==7){
    cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
    return 0;
  }
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


 
signed main() {
    string S;
    cin >> S;

    cout << S.substr(0, S.size()-8) << endl;
    
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	int64_t x = 2, y = 1, z = x + y;
	for (int i = 0;i < N;++i) {
		x = y;
		y = z;
		z = x + y;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
COLOR = {
    "000000": "black",
    "0000ff": "blue",
    "00ff00": "lime",
    "00ffff": "aqua",
    "ff0000": "red",
    "ff00ff": "fuchsia",
    "ffff00": "yellow",
    "ffffff": "white"
}

while True:

    input_data = input()

    if len(input_data) == 1:
        break

    color_code = ""

    for first, second in zip(input_data[1::2], input_data[2::2]):
        if int(first + second, 16) <= 127:
            color_code += "00"
        else:
            color_code += "ff"

    print(COLOR[color_code])



Measured memory_bytes: 5568
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int A;
  int B;
  int C;
  cin >>A>>B>>C;
  if((A==5) && (B==7) &&(C==5)
    || (A==7) && (B==5) &&(C==5)
    ||  (A==5) && (B==5) &&(C==7))  {
cout <<"YES" << endl;
  }
  else {
cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pi 3.14159265358979323846
#define mod 1000000007
using namespace std;
int main()
{
    ll n, s,sum=0;
    cin >> n;
    ll a[n + 1], b[n];
    for (int i = 0; i < n + 1; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];
    for(int i=0;i<n;i++)
    {
        s=a[i]+a[i+1];
        if(b[i]>=s)
        {
            sum+=s;
            a[i+1]=0;
        }
        else if(b[i]<s)
        {
            if(b[i]<=a[i])
            {
                sum+=b[i];
            }
            else
            {
                a[i+1]=s-b[i];
                sum+=b[i];
            }
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1792
use proconio::input;


fn main() {
    input! {
        a: usize,
        b: usize,
        m: usize,
        va: [i32; a],
        vb: [i32; b],
        x: [[i32; 3]; m]
    }

    let mina = va.iter().min().unwrap();
    let minb = vb.iter().min().unwrap();

    let mut ans = mina + minb;
    for xi in x {
        let ai = xi[0] as usize;
        let bi = xi[1] as usize;
        let c  = xi[2];
        ans = std::cmp::min(ans, va[ai-1] + vb[bi-1] - c);
    }

    println!("{}", ans);
}


Measured memory_bytes: 11112
import numpy as np
from collections import Counter
#from statistics import mode
num=raw_input()
tmp=map(int, raw_input().split(" "))
#tmp_count=[]
#for i in set(tmp):
#    tmp_count.append(tmp.count(i))

#print set(tmp),tmp_count
#out=tmp[:]
#for i,j in zip(set(tmp),tmp_count):

#out=tmp[:]
#for i in tmp:
#    out.append(i-1)
#    out.append(i+1)

arr1=np.array(tmp)
arr2=np.array(tmp)+1
arr3=np.array(tmp)-1
arr=np.r_[arr1, arr2,arr3]
#print arr
data = Counter(list(arr))
print data.most_common(1)[0][1]
#print mode(list(arr))
#print np.median(arr)
"""
sub=[]
for i in set(arr):
    sub.append(list(arr).count(i))
#print sub
print max(sub)
"""


Measured memory_bytes: 40464
# -*- coding: utf-8 -*-
import heapq
import math
import sys

N = int(input())
ws = [int(w) for w in input().split()]

left_s = 0
all_s = sum(ws)
now_min = all_s
w_i = 0
for w_i, w in enumerate(ws):
    left_s += w
    right_s = all_s - left_s
    score = abs(left_s - right_s)
    if now_min > score:
        now_min = score
    
print(int(now_min))


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vii;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip> vip;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 :1e9;
#define MAX 50010
int dp[110][MAX];
int mo[110][MAX];
void f(int a,int b,int c,int d){
	if(dp[a][b]<c){
		dp[a][b]=c;
		mo[a][b]=d;
	}else if(dp[a][b]==c)
		mo[a][b]=min(mo[a][b],d);
}
int main(){
	int n;
	while(cin>>n,n){
		vi in(n);
		rep(i,n)cin>>in[i];
		rep(j,110)rep(k,MAX)dp[j][k]=-inf;
		dp[0][0]=mo[0][0]=0;
		rep(i,n)rep(j,MAX)if(dp[i][j]!=-inf){
			f(i+1,j,dp[i][j],mo[i][j]);
			int a=in[i]%1000;
			int t=1000-a;
			if(a)f(i+1,j+t%500,dp[i][j]+(t>=500),mo[i][j]+in[i]);
			else if(j>=500)f(i+1,j-500,dp[i][j]+1,mo[i][j]+in[i]);
			t=500+j-a;
			if(t>=0&&a>=500)f(i+1,t,dp[i][j]+1,mo[i][j]+in[i]);
		}

		int outc=0,out=inf;
		rep(i,MAX)if(dp[n][i]!=-inf){
			if(outc<dp[n][i]){
				outc=dp[n][i];
				out=mo[n][i];
			}else if(outc==dp[n][i])
				out=min(out,mo[n][i]);
		}
		cout<<outc<<" "<<out<<endl;
	}
}


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

int     main()
{
    int N; cin >> N;
    int hoge = 1;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {   
        int a; cin >> a;
        if (a == hoge)
        {   
            ans++;
            hoge++;
        }   
    }   
    if (hoge == 1)
    {   
        cout << -1 << endl;
        return 0;
    }   
    cout << N - ans << endl;
}

Measured memory_bytes: 768
/*
author:Rahul Chocha
school of eng. and applied science
*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define MAXI INT_MAX
#define MINI INT_MIN
#define din(t) long long t; cin >> t;
#define fi(i, l, r, d) for (i = l; i < r; i += d)
#define fd(i, l, r, d) for (i = l - 1; i >= r; i -= d)
#define pb push_back
#define mp make_pair


void speed_up()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
}
void Inp_Out(){
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("A.01.inp", "r", stdin);
    // for writing output to output.txt
    //freopen("A.01.out", "w", stdout);
    #endif
}

int main()
{   

   	speed_up();
   	//Inp_Out();
	din(n) din(k)
	ll arr[n]={0};
	ll dp[n+1]={0};
	ll i;
	dp[0]=0;
	fi(i,0,n,1)cin>>arr[i];
	fi(i,k,n,1){
		if(arr[i-k]<arr[i])cout<<"Yes\n";
		else cout<<"No\n";
	}


} 


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

const int INF = 1 << 29;

int main() {
    int n;
    cin >> n;
    vector<int> vi(2 * n);
    rep (i, 2 * n) {
        cin >> vi[i];
    }
    sort(all(vi));
    int ans = 0;
    for (int i = 0; i < 2 * n; i += 2) {
        ans += min(vi[i], vi[i + 1]);
    }
    cout << ans << endl;
}


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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<32>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<llint>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

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

int main()
{
    int n;
    int p[30];

    ci >> n;
    rep(i, 0, n) ci >> p[i];

    int cnt = 0;
    
    rep(i, 1, n - 1) {
	if(p[i] > p[i - 1] && p[i] < p[i + 1] ||
	   p[i] < p[i - 1] && p[i] > p[i + 1]) cnt++;
    }

    co << cnt << en;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  ll a,b;
  cin>>a>>b;
  if(a > 9 || b > 9){
    cout<<-1<<endl;
  }else{
    cout<<a*b<<endl;
  }
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    int n, m;
    cin >> n >> m;
    vector<i64> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];

    using P = pair<i64, i64>;
    vector<P> l(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        l[i] = { a[i], a[i + 1] };
        if (l[i].first > l[i].second) l[i].second += m;
    }
    sort(begin(l), end(l));
    i64 scr = 0;
    for (int i = 0; i < n - 1; ++i) {
        scr += l[i].second - l[i].first;
    }
    for (int i = 0; i < n - 1; ++i) {
        l.emplace_back(l[i].first + m, l[i].second + m);
    }

    i64 ans = scr, sum_seg = 0, sum_end = 0;
    auto cmp = [](P a, P b) { return a.second > b.second; };
    priority_queue<P, vector<P>, decltype(cmp)> pq(cmp);
    for (int x = 0, i = 0; x < 2 * m; ++x) {
        while (!pq.empty() && pq.top().second < x) {
            auto a = pq.top();
            sum_seg -= a.second - a.first;
            sum_end -= a.second;
            pq.pop();
        }
        while (i < l.size() && l[i].first < x) {
            auto a = l[i];
            sum_seg += a.second - a.first;
            sum_end += a.second;
            pq.push(a);
            ++i;
        }
        // cerr << sum_seg << ' ' << sum_end << ' ' << pq.size() << endl;
        i64 res = scr - sum_seg + (sum_end - x * pq.size()) + pq.size();
        ans = min(ans, res);
    }

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

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

using namespace std;

const long mod = 1e9 + 7;

signed main()
{
    string s;
    cin >> s;
    reverse(s.begin(), s.end());

    int n = s.size();
    vector<vector<long>> dp(n + 1, vector<long>(13, 0));
    dp[0][0] = 1;
    long p_mod = 1;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < 13; ++j){
            for(int k = 0; k < 10; ++k){
                if(s[i] != '?' && s[i] != '0' + k)
                    continue;
                int add_mod = p_mod * k;
                dp[i + 1][(j + add_mod) % 13] += dp[i][j];
                dp[i + 1][(j + add_mod) % 13] %= mod;
            }
        }
        p_mod = (p_mod * 10) % 13;
    }
    cout << dp[n][5] << endl;
    return 0;
}


Measured memory_bytes: 13696
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<ll> res(n);
	ll sol = 0;
	rep(i, n) {
		int a, b; cin >> a >> b;
		sol += b;
		res[i] = a + b;
	}
	sort(rall(res));
	ll ans = 0;
	rep(i, n) {
		if (i % 2 == 0) {
			ans += res[i];
		}
	}
	ans -= sol;
	dunk(ans);
	return 0;
}


Measured memory_bytes: 1024
N = int(input())
A = [[int(i) for i in input().split()] for j in range(2)]
count = 0
Max = 0

for i in range(N):
    for j in range(i+1):
        count += A[0][j]
    for j in range(N-i):
        count += A[1][i+j]
    Max = max(Max, count)
    count = 0

print(Max)


Measured memory_bytes: 3060
#ifdef DBG1
  #define LOCAL
#endif

#ifdef LOCAL
  #define _GLIBCXX_DEBUG
#endif

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifdef DBG1
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dbg(...)
#endif

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;

bool solve() {
  int n, m;
  if (scanf("%d%d", &n, &m) != 2) { return false; }

  static char s[110000], t[110000];
  scanf("%s%s", s, t);
  int k = __gcd(n, m);
  for (int i = 0, j = 0, x = 0; x < k; ++x, i += n / k, j += m / k) {
    if (s[i] != t[j]) {
      printf("-1\n");
      return true;
    }
  }
  printf("%lld\n", ll(m) / k * n);
  return true;
}

int main() {
  while (solve());
  return 0;
}

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

A = list(sorted(A))
flag = 0
for i in range(N//2-1):
    if N % 2 == 1:
        if A[2*i+1]==A[2*i+2] and A[2*i+1] == 2*i+2:
            pass;
        else:
            flag = -1
            break;
    if N % 2 == 0:
        if A[2*i]==A[2*i] and A[2*i+1] == 2*i+1:
            pass;
        else:
            flag = -1
            break;
if flag == 0:
    ans = 2**(N//2)%(10**9+7)
    print (ans)
else:
    print(0)


Measured memory_bytes: 14008
/*input
10 9 3
10 1
6 7
8 2
2 5
8 4
7 3
10 9
6 4
5 8
2 6
7 5
3 1
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=1e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
vector<int> v[maxn],v2[maxn];
int par[maxn],rank1[maxn],ans[maxn];
int find(int u){
    return u==par[u]?u:par[u]=find(par[u]);
}
void merge(int a,int b){
    a=find(a),b=find(b);
    if(a==b) return;
    rank1[b]+=rank1[a];
    par[a]=b;
}
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    REP(i,n) par[i]=i,rank1[i]=1;
    REP(i,m){
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        merge(a,b);
        v[a].pb(b);
        v[b].pb(a);
    }
    REP(i,k){
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        v2[a].pb(b);
        v2[b].pb(a);        
    }
    REP(i,n){
        ans[i]=rank1[find(i)]-sz(v[i])-1;
    }
    REP(i,n){
        for(auto x:v2[i]){
            if(find(x)==find(i)){
                ans[i]--;
            }
        }
    }
    REP(i,n) cout<<ans[i]<<' ';
}

Measured memory_bytes: 13560
#include <iostream>

using ll_t = long long;
const int MAXN = (int)1e5;
const int P = 998244353;

int dis[MAXN];  // The dis between vertex 1 and vertex i is dis[i].
int num[MAXN];


// Calc x^y % P.
ll_t pow(ll_t x, int y) {
  ll_t res = 1;
  while (y > 0) {
    if (y & 1) res = res * x % P;
    x = x * x % P;
    y >>= 1;
  }
  return res;
}

int solve(int n) {
  if (dis[0] != 0) return 0;
  
  int max_dis = 0;
  for (int i = 0; i < n; ++i) {
    ++num[dis[i]];
    if (dis[i] > max_dis) max_dis = dis[i];
  }

  if (num[0] != 1) return 0;

  ll_t tree_num = 1;
  for (int i = 1; i <= max_dis; ++i) {
    tree_num = tree_num * pow(num[i - 1], num[i]) % P;
  }

  return static_cast<int>(tree_num);
}

int main() {
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    std::cin >> dis[i];
  }
  std::cout << solve(n) << std::endl;
  return 0;
}


Measured memory_bytes: 1024
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
//~ #pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(),x.end()
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define erase_duplicates(x) sort(all(x)); (x).resize(distance((x).begin(), unique(all(x))));


using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<
T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<" = "<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#define cerr if(0)cout
#endif

const int maxn = (1e6)+7;
const int maxk = 20;
const int inf = (1e9)+7;
const LL LLinf = ((LL)1e18)+7LL;
const LD eps = 1e-9;
const LL mod = 1e9+7;

// ***************************** CODE ***************************** //

LL licz(string s)
{
  LL res = 0LL;
  LL cnt = 0LL;
  for(int i = 0;i < SZ(s);i++)
    if(s[i] == 'A')
      cnt++;
    else
      res += cnt;
  return res;
}

int main()
{
	_upgrade
  string s;
  cin>>s;
  LL res = 0;
  string cur;
  for(int i = 0;i < SZ(s);i++)
  {
    if(s[i] == 'A')
      cur.pb('A');
    else
    {
      if(s[i] == 'B' && i + 1 < SZ(s) && s[i + 1] == 'C')
      {
        cur.pb('X');
        i++;
      }
      else
      {
        res += licz(cur);
        cur = "";
      }
    }
  }
  res += licz(cur);
  cout<<res;

	return 0;
}


Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      if (S - i - j <=K && S - i - j >= 0) {
          ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
using namespace std;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}

int main(){
    int a,b;
    while(cin>>a>>b){
        if(a<=b)swap(a,b);
        int g=gcd(a,b);
        cout<<g<<" "<<a/g*b<<endl;
    }
}

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

char s[150];

bool is (int l,int r) {
	for (int i=0;i<=(r-l);i++)
	{
		if (s[l+i] != s[r-i]) return 0;
	}
	return 1;
}

int main ()
{
	scanf ("%s",s+1);
	int n=strlen (s+1);
	
	if (is (1,n) && is (1,(n-1)/2) && is ((n+3)/2,n)) puts ("Yes");
	else puts ("No");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

const int dh[] = {-1, 0, 1, 0};
const int dw[] = {0, -1, 0, 1};

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    vector<string> mat(h);
    rep(i, h) cin >> mat[i];

    set<P> done;
    ll ans = 0;
    vector<vector<bool>> seen(h, vector<bool>(w, 0));
    rep(i, h) rep(j, w) {
        if (mat[i][j]=='#') {
            if (done.count({i, j})) continue;
            seen[i][j] = 1;
            queue<P> que;
            que.push({i, j});
            ll par = 1ll;
            ll cnt = 0;
            while (!que.empty()) {
                P p = que.front(); que.pop();
                char c = mat[p.fi][p.se];
                rep(i, 4) {
                    int nh = p.fi+dh[i], nw = p.se+dw[i];
                    if (nh<0||nh>h-1||nw<0||nw>w-1) continue;
                    if (seen[nh][nw]!=0) continue;
                    if (mat[nh][nw]==c) continue;
                    seen[nh][nw] = 1;
                    if (mat[nh][nw]=='#') {
                        par++;
                        done.insert({nh, nw});
                    } else {
                        cnt++;
                    }
                    que.push({nh, nw});
                }
            }
            ans += cnt*par;
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++) // no semicoron
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>0;i--)
#define FORD(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
//#define PI 3.14159265359

using namespace std;

int main(){
    ll N, M;
    cin >> N >> M;

    vector<ll> A(N);

    ll sum = 0;

    FOR(i, 0, M){
        cin >> A[i];
        sum += A[i];
    }

    if(sum <= N) cout << N - sum << endl;
    else cout << "-1" << endl;

}

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

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if(a < k){
        ans += a;
        if(b < k-a){
            ans -= k-a-b;
        }
    }else{
        ans += k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<iomanip>
#include<cstdio>
#define eps 1e-9
using namespace std;

int main(){
    double a,b,c,d,e,f;
    double x,y;

    while(cin>>a>>b>>c>>d>>e>>f){
        x = ((e*c)-(b*f))/((a*e) - (b*d)) ;
        y = ((a*f) - (c*d))/((a*e) - (b*d)) ;

        printf("%.3lf %.3lf\n",x+eps,y+eps);
    }
    return 0;
}

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

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

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

const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, a, b;

  cin >> x >> a >> b;
  if (abs(x - a) < abs(x - b)) {
    cout << "A";
  } else {
    cout << "B";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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


ll a[2100];

int main()
{
	int n;
	int z, w;
	cin >> n >> z >> w;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (n == 1) {
		ll cur = abs(z - w);
		ll ne = abs(a[0] - w);
		cout << ne << endl;
		return 0;
	}
	if (n >= 2) {
		ll s = abs(z - w);
		ll k = a[n - 2];
		ll l = a[n - 1];
		cout << max(abs(k - l), abs(l - w)) << endl;
		return 0;
	}


	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <cmath>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;

signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<int> a(3*n);

    rep(i,3*n){
        cin >> a[i];
    }

    vector<bool> use(3*n);
    vector<pii> vec;
    min_heap<int> left;
    set<pii> stock;
    int lsum = 0, rsum = 0;

    rep(i,n){
        left.emplace(a[i]);
        lsum += a[i];
    }

    for(int i = n; i < 3*n; ++i){
        stock.insert({a[i], i});
        vec.emplace_back(a[i], i);
    }

    sort(all(vec));

    rep(i,n){
        rsum += vec[i].first;
        use[vec[i].second] = true;
        stock.erase({vec[i].first, vec[i].second});
    }

    int res = lsum - rsum;

    for(int i = n; i < 2 * n; ++i){
        if(use[i]){
            rsum -= a[i];
            int v, p;
            tie(v, p) = *stock.begin();
            stock.erase(stock.begin());
            rsum += v;
            use[i] = false;
            use[p] = true;
        }else{
            stock.erase({a[i], i});
        }
        if(left.top() < a[i]){
            lsum -= left.top();
            left.pop();
            left.emplace(a[i]);
            lsum += a[i];
        }
        chmax(res, lsum - rsum);
    }

    cout << res << '\n';

    return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    map<string, int> dic;
    int mx = 1;
    rep(i, n)
    {
        string s;
        cin >> s;
        if (!dic.count(s)) {
            dic[s] = 1;
        } else {
            dic.at(s)++;
            if (mx < dic.at(s)) {
                mx = dic.at(s);
            }
        }
    }

    for (auto s : dic) {
        if (s.second == mx) {
            cout << s.first << endl;
        }
    }
}

Measured memory_bytes: 25216
package main

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

// INF means infinity as constant
var INF int = 1001001001

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

var to [][]int = make([][]int, 100005)

// var to [][]int = make([][]int, 5)
var q []int
var dist []int
var pre []int

/* https://atcoder.jp/contests/abc168/tasks/abc168_d */
func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	n, m := nextInt(), nextInt()
	for i := 0; i < m; i++ {
		a, b := nextInt()-1, nextInt()-1
		to[a] = append(to[a], b)
		to[b] = append(to[b], a)
	}

	dist = make([]int, n)
	pre = make([]int, n)
	for i := 0; i < n; i++ {
		dist[i] = INF
		pre[i] = -1
	}
	dist[0] = 0
	q = append(q, 0)

	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		for i := 0; i < len(to[v]); i++ {
			u := to[v][i]
			if dist[u] != INF {
				continue
			}
			dist[u] = dist[v] + 1
			pre[u] = v
			q = append(q, u)
		}
	}

	fmt.Println("Yes")
	for i := 1; i < n; i++ {
		ans := pre[i]
		ans++
		fmt.Println(ans)
	}
	// fmt.Println(to)
	// fmt.Println(dist)
	// fmt.Println(pre)

}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

func max(a, b int) int {
	return int(max64(int64(a), int64(b)))
}

func max64(a int64, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	return int(min64(int64(a), int64(b)))
}

func min64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


Measured memory_bytes: 18672
def main():
  N, K = map(int, input().split())
  d = []
  A = []

  for i in range(K):
    d.append(input())
    A.append(list(map(int, input().split())))

  S = []
  for i in range(N):
    S.append(0)

  for i in range(len(A)):
    for j in A[i]:
      S[j-1] += 1
  
  ans = 0
  for i in S:
    if i == 0:
      ans += 1
  
  print(ans)
    

if __name__ == "__main__":
  main()

Measured memory_bytes: 9208
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i,n) for(int i=n-1;i>=0;i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef pair<int,int> P;
//typedef long long int ll;


int ans,ans2;

signed main(){

    int n,A,B;
    string s;
    cin>>n>>A>>B>>s;
    int a=0,b=0;
    rep(i,s.size()){
        if(A+B>a+b){
            if(s[i]=='a'){
                a++;
                cout<<"Yes"<<endl;
            }
            if(s[i]=='b'){
                if(B>=b+1){
                    b++;
                    cout<<"Yes"<<endl;
                }
                else cout<<"No"<<endl;
            }
            if(s[i]=='c')cout<<"No"<<endl;
        }
        else cout<<"No"<<endl;

    }

}


Measured memory_bytes: 896
n, m = map(int, input().split())

lis = sorted(list(map(int, input().split())))

query = []
for i in range(m):
    b, c = map(int, input().split())
    query.append([c, b])

query.sort(reverse = 1)

i = 0
for j in query:
    for k in range(j[-1]):
        if i < n:
            if lis[i] < j[0]:
                lis[i] = j[0]
                i += 1 
            else:
                break
        else:
            break
        
print(sum(lis))

Measured memory_bytes: 77208
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e18

#define MAX 100005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	char ch;
	db aa,bb,cc;
	string s1,s2,s3;
    lli i,j,k,a,b,c,n,m,sum=0,ans=0,temp,t;
    cin >> n >> k;
    a=n/k;
    b=n-(a*k);
    cout << min(abs(b-k),b);
    
    
    return 0;
}





















/* UJJWAL KESHRI */

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
  int n,c,m,sw;
  char w;
  while(1){
    sw=0;
    m=0;
    c=0;
    while(1){
      scanf("%d%c",&n,&w);
      if(n==0){
	sw=1;
	break;
      }
	if(n==1){
	  m+=1;
	  c+=11;
	}
	else if(n>10)c+=10;
	else c+=n;
      if(w=='\n')break;
    }
    if(sw==1)break;
    while(m!=0){
      if(c>21){
	m--;
	c-=10;
      }
      else break;
    }
    if(c<22)cout << c << endl;
    else cout<< "0"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
using System;
using System.Linq;
using System.Collections.Generic;

namespace AGC002_C___Knot_Puzzle
{
    class Program
    {
        static List<int> process;
        static void Main(string[] args)
        {
            if (solver())
            {
                Console.WriteLine("Possible");
                foreach (int i in process) Console.WriteLine(i);
            }
            else Console.WriteLine("Impossible");

        }
        static bool solver()
        {
            var NL = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            var N = NL[0];
            var L = NL[1];
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);

            int lastKnot;
            for (lastKnot = 1; lastKnot < N + 1; lastKnot++)
            {
                if (lastKnot == N) return false;
                if (A[lastKnot] + A[lastKnot - 1] >= L) break;
            }

            process = new List<int>();
            for (int i = 1; i < lastKnot; i++) process.Add(i);
            for (int i = (int)(N - 1); i > lastKnot; i--) process.Add(i);
            process.Add(lastKnot);
            return true;
        }
    }
}


Measured memory_bytes: 33116
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    int ans = 0;
    while(n>0){
        ans++;
        n/=k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
int main()
{
  ll L,K;
  cin>>L>>K;
  vector<ll> A(K);
  rep(i,K)cin>>A.at(i);
  ll ans=0;
  ll Z=0;
  rep(i,K)ans+=max(Z,(A.at(i)*2-L-1));
  cout<<ans<<endl;
}

Measured memory_bytes: 256
h = int(input())
list_1 = []
ans = 0
cnt = 0
if h == 1 :
  ans = 0
else :
  cnt += 1
  list_1.append(cnt)
  while h // 2 != 1: 
    cnt += 1
    list_1.append(cnt)
    h = h // 2

for i in list_1 :
  if i == 1:
    ans += 2
  else :
    ans += 2**i

print(ans+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {

  int64_t N,A,B;
  cin>>N>>A>>B;
  
  int64_t cy=A+B;
  int64_t x=N/cy;
  int64_t y=N%cy;
  
  if(A==0){
    cout<<0<<endl;
  }
  
  else if(B==0){
    cout<<N<<endl;
  }
  
  else if(A!=0 && B!=0 && y<A){
    cout<<x*A+y<<endl;
  }
  else if(A!=0 && B!=0 && A<y){
    cout<<x*A+A<<endl;
  }
}

Measured memory_bytes: 256