akhauriyash/Code-Regression huggingface dataset:
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

ll llmin(ll a,ll b){
    if(a>=b) return b;
    return a;
}
ll llmax(ll a,ll b){
    if(a<=b) return b;
    return a;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    cin >> A;
    cin >> B;


    cout << llmin(B,A*N) << endl;

    

}

Measured memory_bytes: 3616
#include<stdio.h>
int main(){
	int n,a,b,k,m,i;
	while(scanf("%d",&m),m){
		a=0,b=0;
		for(i=0;i<m;i++){
			scanf("%d%d",&n,&k);
			if(n<k)b+=n+k;
			else if(n>k)a+=n+k;
			else a+=n,b+=k;
		}
		printf("%d %d\n",a,b);
	}
	return 0;
}


Measured memory_bytes: 2044
NY = input().split(" ")
N = int(NY[0])
Y = int(NY[1])
KKK = 0
KK = 0
K = 0
check = 0
for i in range(0, N + 1):
    if check == 1:
        break
    for j in range(0, N + 1- i):
        k = N - i - j #kは千円
        if k * 10000 + j * 5000 + i * 1000 == Y:
            KKK = k
            KK = j
            K = i
            check = 1
            break
        
if check == 0:
    print(-1, -1, -1)
else:
    print(KKK, KK ,K)

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

#define MAXN (200010)
#define ll long long

int n;
ll a[MAXN];
std::map<ll, int> map;

int main()
{
	scanf("%d", &n);
	++ map[0];
	for (int i = 1; i <= n; ++ i) {
		scanf("%lld", a + i);
		a[i] += a[i - 1];
		++ map[a[i]];
	}
	ll ans = 0;
	for (auto &v : map) {
		ans += 1ll * v.second * (v.second - 1) / 2;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 14336
#include <iostream>

using namespace std;

int main()
{
    string color1, color2, chosen;
    int num1, num2;
    cin >> color1 >> color2 >> num1 >> num2 >> chosen;
    if (chosen == color1)
        num1 --;
    else
        num2--;
    cout << num1 << " " << num2;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = 0
numb = 0
numa = 0
numba = 0
for _ in range(N):
    s = input()
    ans += s.count("AB")
    if s[0] == "B" and s[-1] == "A":
        numba += 1
    elif s[0] == "B":
        numb += 1
    elif s[-1] == "A":
        numa += 1

if numa == 0:
    if numb == 0:
        ans += max(0, numba - 1)
    else:
        ans += numba
else:
    if numba == 0:
        ans += min(numa, numb)
    elif numb == 0:
        ans += numba
    else:
        numa -= 1
        ans += numba + 1
        numb -= 1
        ans += min(numa, numb)
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main() {
	long long N;
	cin >> N;
	long long power = 1;
	for (int i = 1; i <= N; i++) {
		power = power * i;
		power = power % (1000000000 + 7);
	}

	cout << power << endl;

	
	return 0;
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    ll N, K;
    cin >> N >> K;

    vector<ll> A(N), acc(N + 1);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        acc[i + 1] = acc[i] + A[i];
    }

    vector<ll> B;
    for (int i = 0; i < N; i++) {
        for (int j = i; j < N; j++) {
            B.push_back(acc[j + 1] - acc[i]);
        }
    }
    
    vector<ll> flag(B.size(), 1);
    ll ans = 0;
    for (int b = 62; b >= 0; b--) {
        ll cnt = 0;
        for (int i = 0; i < B.size(); i++) {
            if (flag[i] && (B[i] >> b & 1)) cnt++;
        }
        if (cnt >= K) {
            for (int i = 0; i < B.size(); i++) {
                if (flag[i] && !(B[i] >> b & 1)) flag[i] = 0;
            }
            ans |= 1LL << b;
        }
    }
    cout << ans << endl;

}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

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

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

  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }

  int num;
  for (int i = 1; i < N; i++) {
    for (int j = 0; j < i; j++) {
      if (p[i] > p[j]) {
        num = p[i];
        p[i] = p[j];
        p[j] = num;
      }
    }
  }

  int ans = p[0]/2;
  for (int i = 1; i < N; i++) {
    ans += p[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main _ =
    let [|N;Y|] = reada int
    let mutable x, y, z = -1, -1, -1
    for i in 0..N do
        for j in 0..N-i do
            let k = N - i - j
            if 10000 * i + 5000 * j + 1000 * k = Y then
                x <- i
                y <- j
                z <- k

    printfn "%d %d %d" x y z
    0


Measured memory_bytes: 14044
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
int INF=1000000007;
using ll=long long;

int main(){
	ll n,m,ans;
	cin>>n>>m;
	ll tmp=m-n,ans2;
	if(tmp>0){
		ans=(m/2-n)/2;
		ans2=n/2+m/4;
		ans=max(ans,ans2);
	}else ans=min(n,m/2);
	if(ans==1)cout<<"2"<<endl;
	else cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;

int n;
const int N = 1000002;
char s[N];
bool test(int mx, int mi){
    //printf("test mx = %d, mi = %d\n",mx,mi);
    int U = 0, L = 0;
    int i, j;
    for(i = 1; i <= n; ++i){
        if(s[i] == '?'){
            for(j = i; j <= n && s[j]=='?'; ++j);
            U += j-i; L -= j-i;
            int m = U&1;
            U = min(U, mx); L = max(L, mi);
            if((U&1)^m) --U;
            if((L&1)^m) ++L;
            if(U < L) return false;
        }else{
            int sum = 0, deep = 0, peak = 0;
            for(j = i; j <= n && s[j]!='?'; ++j){
                if(s[j]=='0') --sum;
                else ++sum;
                deep = min(deep, sum);
                peak = max(peak, sum);
            }
            // mx - peak, mi - deep
            int m = U&1;
            U = min(U, mx-peak); L = max(L, mi-deep);
            if((U&1)^m) --U;
            if((L&1)^m) ++L;
            U += sum; L += sum;
            if(U < L) return false;
        }
        //printf("%d --- %d %d\n",i,U,L);
        i = j-1;
    }
    return true;
}
int main(){
    scanf("%s",s+1);
    n = strlen(s+1);
    int l, r, m;
    l = 1; r = n;
    while(l < r){
        m = (l+r)>>1;
        if(test(m, -m)) r = m;
        else l = m+1;
    }
    //printf("==%d\n",l);
    int mx = l;
    l = 0; r = n;
    while(l < r){
        m = (l+r)>>1;
        if(test(mx, -m)) r = m;
        else l = m+1;
    }
    int ans = mx + l;
    FOR(i, 1, n){
        if(s[i] != '?') s[i] = '0'+'1'-s[i];
    }
    l = 0; r = n;
    while(l<r){
        m = (l+r)>>1;
        if(test(mx, -m)) r = m;
        else l = m+1;
    }
    ans = min(ans, mx+l);
    printf("%d",ans);
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */


Measured memory_bytes: 4820
#include <bits/stdc++.h>
     
    // Preparing for IOI 2018
     
    using namespace std;
     
    const int inf = (int) 1e9 + 7;
    const int N = (int) 1e5 + 7;
    const double PI = 3.141592653589793238462643;
    const double eps = 0.000000001;
     
    #define ok puts("OK");
    #define ll long long
    #define fr first
    #define sc second
    #define eb emplace_back
    #define sz(s) ((int)s.size())
    #define all(s) s.begin(), s.end()
     
    inline void solve () {
    	int n; cin >> n;
    	ll a[n];
    	for (int i = 0; i < n; i++) {
    		cin >> a[i];
    	}
    	sort(a, a + n, greater < ll > ());
    	ll ans = 0;
    	bool p = 0;
    	for (int i = 1; i < n; i++) {
    		if (p) {
    			if (a[i] == a[i - 1]) {
    				ans *= a[i];
    				cout << ans;
    				return ;
    			}
    		}
    		if (a[i] == a[i - 1] && p == 0) {
    			ans = a[i];
    			p = 1;
    			i++;
    		}
    	}         
    	cout << 0;
    }
     
    int test = 1;
     
    main () {
            // freopen("example.in", "r", stdin); freopen("example.out", "w', stdout);
            // scanf ("%d", &test);
            while (test--) {
                    solve();
            }
    }

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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
  int n, m;
  cin >> n >> m;
  int a[n] = { };
  REP(i, 2*m){
    int b;
    cin >> b;
    b--;
    a[b]++;
  }
  int c = 0;
  REP(i, n){
    if(a[i]%2 == 1){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
int mod=int(1e9)+7;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n;
    cin>>n;
    int w;
    cin>>w;
    int d[n+1],v[n+1];
    for(int i=0;i<n;i++){
        cin>>d[i+1];
        cin>>v[i+1];
    }
    ll dp[n+1][w+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++){
            dp[i][j]=0;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=w;j++){
            if(d[i]<=j){
                dp[i][j]=max(dp[i-1][j],dp[i][j]);
                dp[i][j]=max(dp[i-1][j-d[i]]+v[i],dp[i][j]);
            }
            else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 82516
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 5;
int n, x, m, stp, now, a, b, len, pos;
int vis[N];
int res[N];
signed main () {
    cin >> n >> x >> m;
    now = x;
    while (1) {
        if (vis[now]) {
            // cout << now << " " << vis[now] <<endl;
            // for (int i = 1; i <= stp; i++) cout << res[i] <<endl;
            for (int i = vis[now]; i <= stp; i++) b += res[i];
            for (int i = 1; i <= vis[now] - 1; i++) a += res[i];
            len = stp - vis[now] + 1;
            n -= vis[now] - 1; pos = vis[now];
            break;
        }
        res[++stp] = now;
        vis[now] = stp;
        now = now * now % m;
    }
    // cout << a << " " << b << " " << n << " " <<len << endl;
    int ans = a + b * (n / len);
    for (int i = 0; i <= (n % len) - 1; i++) ans += res[i + pos];
    printf ("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4864
#include<iostream>
using namespace std;
int main(){
int n;
int h,w;
cin >> h>>w;
cin >>n;
int a[h][w];
int s=0;
int t=0;
int count =1;
int line=1;
for(int i=0;i<n;i++){
int j;
cin >>j;
for(int x=j;x>0;x--){
if(line==1){
a[s][t]=count;
t++;
if(t==w){
line=2;
s++;
t--;
}
}
else{
a[s][t]=count;
t--;
if(t<0){
line=1;
s++;
t++;
}
}
}
count++;
}
for(int i=0;i<h;i++){
for(int y=0;y<w;y++){
cout << a[i][y]<<" ";
}
cout<<endl;
}
return 0;
}

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

    int r,c;
    int mt[101][101];
int main(){

    cin >> r >> c;
    for(int i = 0;i<=c;i++){
        for(int j = 0;j<=r;j++){
            mt[i][j]=0;
        }
    }
    for(int i = 0;i<r;i++){
        for(int j = 0;j<c;j++){
            cin >> mt[i][j];
        }
    }
    
    for(int i =0;i<r;i++){
        for(int j=0;j<c;j++){
            mt[i][c] += mt[i][j];
            mt[r][j] += mt[i][j];
            cout << mt[i][j] << " ";
            if(j==c-1)cout << mt[i][c];
        }
        cout << endl;
    }
    for(int i=0;i<c;i++){
        mt[r][c] += mt[r][i];
        cout << mt[r][i] << " ";
    } 
    cout << mt[r][c] << endl;
}

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

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if((A==B)&&(B==C)){
    cout<<"No"<<endl;
    return 0;
  }

  if( (!(A==B))&&(!(B==C))&&(!(A==C)) ){
    cout<<"No"<<endl;
    return 0;
  }

  cout<<"Yes"<<endl;

     return 0;
}


Measured memory_bytes: 256
# include<iostream>
# include<algorithm>
# include<cmath>
using namespace std;
int main ()
{
	int N,M;
	cin>>N>>M;
	int A[N];
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
	}
	int sum = 0;
	for(int i=0;i<N;i++)
	{
		sum+=A[i];
	}
	int v = ceil(sum*1.0/(4*M));
	
	sort(A,A+N);
	int time =0;
	for(int i=N-1;i>=0;i--)
	{
		if(A[i]>=v)
		{
			time++;
		}
	}
	if(time>=M)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define C(n,m) (jc[(n)] * inv[(m)] % Mod * inv[(n)-(m)] % Mod)
using namespace std;

typedef long long LL;

const LL N = 200010;
const LL inf = 1e9;
const LL Mod = 1e9 + 7;
inline LL read()
{
  LL p=0; LL f=1; char ch=getchar();
  while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
  while(ch>='0' && ch<='9'){p=p*10+(ch-'0'); ch=getchar();}
  return p*f;
}

LL jc[N],inv[N];

void upd(LL &x,LL y){x=(x-y+Mod)%Mod;}

int main()
{
  
  jc[0] = 1; for(LL i=1;i<=200000;i++) jc[i] = jc[i-1] * i % Mod;
  inv[0] = inv[1] = 1; for(LL i=2;i<=200000;i++) inv[i] = (Mod - Mod/i) * inv[Mod%i] % Mod;
  for(LL i=1;i<=200000;i++) inv[i] = inv[i-1] * inv[i] % Mod;
  LL n=read(); LL m=read(); LL r=read(); LL w=read();
  LL ans = C(n+m-2,m-1);

  for(LL i=n;i>=n-r+1;i--) upd(ans,C(i+w-2,w-1) * C(n-i+m-w-1,m-w-1) % Mod);

  return printf("%lld\n",ans),0;
}

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

const int MOD = 1000000007;

void add(int &a, int b) { a += b; if(MOD <= a) a -= MOD; }
void sub(int &a, int b) { a -= b; if(a < 0) a += MOD; }

int dp[2][100055];

int N, K;

int main() {
	cin >> N >> K; dp[0][0] = 1;
	for(int ni = 0, a; ni < N; ni++) {
		cin >> a;
		for(int i = 0, j = -a, s = 0; i <= K; i++, j++) {
			add(s, dp[0][i]);
			dp[1][i] = s;
			if(0 <= j) sub(s, dp[0][j]);
		}
		memcpy(dp[0], dp[1], (K+1) * sizeof(int));
	}
	cout << dp[0][K] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int a, b, c;

int main() {
	while(scanf("%d %d %d", &a, &b, &c) != EOF) {
		if(c - b <= 0) puts("delicious");
		else {
			if(c - b <= a) puts("safe");
			else puts("dangerous");
		}
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int h, w, n;
    cin >> h >> w >> n;
    int tmp = max(h, w);
    int ans = n / tmp;
    if(n % tmp > 0) ans++;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int N,M,C,i,j,k,x,y=0;
    int A[30][30];
    int B[30];
    cin>>N>>M>>C;
    for(i=0;i<M;i++)
    {
        cin>>B[i];
    }
    for(j=0;j<N;j++)
    {
        for(k=0;k<M;k++)
        {
            cin>>A[j][k];
        }
    }
    for(j=0;j<N;j++)
    {
        x=0;
        for(k=0;k<M;k++)
        {
            x=x+(A[j][k]*B[k]);
        }
        x=x+C;
        if(x>0)
        {
            y=y+1;
        }
    }
    cout<<y<<endl;
    return 0;
}


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n, m, l;
		cin >> n >> m >> l;
		if(n+m+l > 21)cout << "bust\n";
		else cout << "win\n";
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int[] list = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int res= 0;
		for(int i = 1;i<=n;i=i+2){
			if(list[i-1]%2==1) res++;
		}
		System.out.println(res);	
	}
}


Measured memory_bytes: 34340
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

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

  cout << max(max(a*10+b+c,a+c+b*10),a+b+c*10) << endl;
  return 0;
}


Measured memory_bytes: 256
/*
 * atcoder/dp_2nd/s.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long
#define MOD 1000000007

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX_K = 10100;
const int MAX_D = 120;
int D, N;
string K;

ll dp[2][MAX_K][MAX_D];

void input() {
  cin >> K >> D;
  N = K.size();
}

/*
 * n: 今何桁目
 * d: 今までの合計 (MOD D)
 * l: 次の桁の数字を制限するか
 */
ll rec(int n = 0, int d = 0, bool l = true) {
  ll &cache = dp[l][n][d];
  if (~cache) return cache;
  if (n == N) return cache = d == 0;
  int u = l ? K[n] - '0' : 9;
  ll ways = 0;
  for (int i=0; i<=u; i++) {
    ways += rec(n + 1, (d + i) % D, l && i == u);  // 一度でも制限解除されると最後の桁まで制限なし.
    ways %= MOD;
  }
  return cache = ways;
}

void solve() {
  memset(dp, -1, sizeof(dp));
  ll ways = (rec() - 1 + MOD) % MOD; // 1<= なので0の分を引く
  cout << ways << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


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

#define ll long long int
#define llu unsigned long long int
#define MOD 1000000007
#define N 100001
using namespace std;

int main(){
int n,k;
cin>>n>>k;
vector<ll> v(n);
vector<vector<ll>> dp(1001,vector<ll>(N,1));
for(int i=0;i<n;i++)
cin>>v[i];
dp[0][0]=1;

for(int i=0;i<n;i++){
	vector<ll> s(k+1);
	s[0]=1;
	for(int j=1;j<=k;j++){
		if(i==0){
			if(v[i]>=j)
				dp[i][j]=1;
			else dp[i][j]=0;
		} else {
			dp[i][j]=dp[i-1][j];
			if(v[i]>=j)
				dp[i][j]+=s[j-1];
			else dp[i][j]+=s[j-1]-s[j-v[i]-1];
			s[j]=dp[i-1][j]+s[j-1];
		}
		dp[i][j]=dp[i][j]%MOD;
	}
}
cout<<dp[n-1][k];

return 0;
}

Measured memory_bytes: 785792
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))

using namespace std;
using LL=long long;

class DisjointSet{
public:
    vector<int> rank,p;
    DisjointSet(){}
    DisjointSet(int size){
        rank.resize(size,0);
        p.resize(size,0);
        for(int i=0;i<size;i++) makeSet(i);
    }
    void makeSet(int x){
        p[x]=x;
        rank[x]=0;
    }
    bool same(int x,int y){
        return findSet(x)==findSet(y);
    }
    void unite(int x, int y){
        link(findSet(x),findSet(y));
    }
    void link(int x,int y){
        if(rank[x]>rank[y]){
            p[y]=x;
        }
        else{
            p[x]=y;
            if(rank[x]==rank[y]){
                rank[y]++;
            }
        }
    }
    int findSet(int x){
        if(x!=p[x]){
            p[x]=findSet(p[x]);
        }
        return p[x];
    }
};

int main(){
    int n,a,b,q;
    int t;
    cin>>n>>q;
    DisjointSet ds=DisjointSet(n);
    for(int i=0;i<q;i++){
        cin>>t>>a>>b;
        if(t==0) ds.unite(a,b);
        else if(t==1){
            if(ds.same(a,b)) cout<<1<<endl;
            else cout<<0<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3180
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		int n = sc.nextInt();
		int[] R = new int[n];
		for (int i = 0; i < n; i++) {
			R[i] = sc.nextInt();
		}
		int min = R[0];
		int ans = -Integer.MAX_VALUE;
		for (int i = 1; i < n; i++) {
			ans = Math.max(ans, R[i] - min);
			min = Math.min(min, R[i]);
		}
		System.out.println(ans);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 96476
#include<iostream>

using namespace std;

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

	int k,x;
	cin >> k >> x;
	for(int i=x-k+1; i<=x+k-1; i++){
		cout << i << " ";
	}
	return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

int a,b;
int main()
{
	cin>>a>>b;
	cout<<b*2-a<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

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

	int A = 0;

	if (str[5] == '0') {
		if (str[6] == '1' || str[6] == '2' || str[6] == '3' || str[6] == '4') {
			A = 1;
		}
	}

	if (A == 1) {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
 
		int X = sc.nextInt();
		String result = "NO";
 
      	if(X == 7 || X == 5 || X == 3){
        	result = "YES";
        }
 
		System.out.println(result);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

using namespace std;

const ll N = 1e3 + 5, MOD = 1e9 + 7;

int n, m;
char ch[N][N];

ll dp[N][N];

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin>>ch[i][j];
    dp[1][0] = 1;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            if (ch[i][j] == '.')
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
    cout<<dp[n][m]<<endl;
    return 0;
}


Measured memory_bytes: 9088
#include<stdio.h>

int main(void)
{
	double w;
	
	while(scanf("%lf",&w)!=EOF)
	{
		if(w<=48)
			printf("light fly\n");
		else if(w<=51)
			printf("fly\n");
		else if(w<=54)
			printf("bantam\n");
		else if(w<=57)
			printf("feather\n");
		else if(w<=60)
			printf("light\n");
		else if(w<=64)
			printf("light welter\n");
		else if(w<=69)
			printf("welter\n");
		else if(w<=75)
			printf("light middle\n");
		else if(w<=81)
			printf("middle\n");
		else if(w<=91)
			printf("light heavy\n");
		else
			printf("heavy\n");
	}
	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;

int main() {

    int N;

    cin >> N;
    int A[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    //for(int i=0; i<N; i++){cin>>A[i];}
    //vector<vector<int>> A(N,vector<int>(M));
    //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
    //sort(A.begin(),A.end());
    //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
    //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
    cout << A[N - 1] << endl;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[55];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    REP(i, N) {
        cin >> A[i];
    }

    ll ans = 0;
    REP(left, K + 1) {
        REP(right, K + 1) {
            if (left + right > K || left + right > N)
                break;
            priority_queue<ll, vector<ll>, greater<ll>> q;
            ll s = 0;
            REP(i, left) {
                s += A[i];
                q.push(A[i]);
            }
            REP(i, right) {
                s += A[N - 1 - i];
                q.push(A[N - 1 - i]);
            }

            ans = std::max(ans, s);
            ll k = K - (left + right);
            while (!q.empty() && k > 0) {
                ll t = q.top();
                q.pop();
                s -= t;
                ans = std::max(ans, s);
                k--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

void solve(){
  ll n; cin>>n;
  vector<ld> p(n);
  rep(i,n) cin>>p[i];
  vector<ld> dp(n+1); // dp[k]=表がk枚でる確率
  dp[0]=1.0;
  rep(i,n){
    vector<ld> newdp(n+1,0);
    rep(k,n){
      newdp[k]+=dp[k]*(1-p[i]);
      if(k+1<=n) newdp[k+1]+=dp[k]*p[i];
    }
    dp=newdp;
  }
  ld ans=0;
  rep(k,n/2+1,n+1) ans+=dp[k];
  cout<<ans<<"\n";
}

Measured memory_bytes: 384
#include<stdio.h>
 
int main(void) {
  long long int a, b, k;
  
  scanf("%lld %lld %lld",&a,&b,&k);
  
  if (a > k){
    a -= k;
  }else if (a+b <= k){ 
    a = b = 0;
  }else {
    b -= k - a;
  	a = 0;
  } 
  
  printf("%lld %lld",a,b);
 
  return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum = sum(b)
a_new = [0] * (n-1)
for i in range(1, n):
    a_new[i-1] = a[i]- a[i-1]
for i, val in enumerate(a_new):
    if val == 1:
        sum += c[a[i]-1]
print(sum)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
    int w,h;
    char c;
    scanf("%d %d %c",&w,&h,&c); 
   for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
           
            if(i==0||i==h-1){
                if(j==0||j==w-1) printf("+");
                else printf("-");
            }
            else {
                if(j==0||j==w-1) printf("|");
                else if(i==h/2 && j==w/2){
                    printf("%c",c);
                }
                else printf(".");
            }
           
        }
        printf("\n");
    }
   return 0;
}




Measured memory_bytes: 2048
n,c,k = map(int,input().split())
T =[int(input()) for t in range(n)]
T.sort()
s,p,ans = -k ,0,0
for t in T:
    if s+k < t or p == c:
        ans += 1
        p = 1
        s = t
    else:
        p += 1
print(ans)

Measured memory_bytes: 50520
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <vector>

int main(){
  int N;
  scanf("%d", &N);
  std::vector<long long > A(N), B(N), C(N);
  for (int i=0; i<N; i++){
    scanf("%lld", &A[i]);
    B[i]=i+1-A[i];
    C[i]=-(i+1+A[i]);
  }
  long long ans = 0;
  std::sort(B.begin(), B.end());
  std::sort(C.begin(), C.end());
  int diff;
  for (int i=0; i<N; i++){
    auto itrL = std::lower_bound(B.begin(), B.end(), i+1+A[i]);
    auto itrU = std::upper_bound(B.begin(), B.end(), i+1+A[i]);
    diff = itrU-itrL;
    ans += diff;

    itrL = std::lower_bound(C.begin(), C.end(), A[i]-(i+1));
    itrU = std::upper_bound(C.begin(), C.end(), A[i]-(i+1));
    diff = itrU-itrL;
    ans += diff;
  }
  std::cout << ans/2 << std::endl;
  return 0;
}


Measured memory_bytes: 7632
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int const nmax = 200000;
vector<int> g[1 + nmax];
int a[1 + nmax], b[1 + nmax];
int active[1 + nmax];

int main()
{
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  s = "#" + s;
  for(int i = 1; i <= m; i++){
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
    if(s[y] == 'A')
      a[x]++;
    else
      b[x]++;

    if(s[x] == 'A')
      a[y]++;
    else
      b[y]++;
  }
  queue<int> q;
  for(int i = 1;i <= n; i++)
    if(a[i] == 0 || b[i] == 0) {
      q.push(i);
      active[i] = 0;
    } else
      active[i] = 1;

  while(0 < q.size()){
    int node = q.front();
    q.pop();
    for(int h = 0; h < g[node].size(); h++){
      int to = g[node][h];
      if(s[node] == 'A')
        a[to]--;
      else
        b[to]--;
      if(active[to] == 1 && (a[to] == 0 || b[to] == 0)){
        q.push(to);
        active[to] = 0;
      }
    }
  }

  for(int i = 1;i <= n; i++)
    if(0 < active[i]) {
      cout << "Yes";
      return 0;
    }
  cout << "No";
  return 0;
}


Measured memory_bytes: 13128
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>


using ll = long long;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);

}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
int d[210];
bool flag = true;
bool fl = true;
struct edge { int to, cost; };
std::vector<edge>v[100];
bool used[210];

int main() {
	int a, b;
	std::cin >> a >> b;
	if (a > 0 && b > 0) {
		std::cout << "Positive" << std::endl;
	}
	else if (a <= 0 && b >= 0) {
		std::cout << "Zero" << std::endl;
	}
	else if (a < 0 && b < 0) {
		int c = b - a + 1;
		if (c % 2 == 1) {
			std::cout << "Negative" << std::endl;
		}
		else {
			std::cout << "Positive" << std::endl;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,f,t) for(int i=f;i<t;i++)
#define P(ary) do { for(auto i:ary){ cout << i << " "; } cout << endl; } while (0)
int main()
{
    int N; cin >> N;
    vector<int> A(N), B;
    REP(i, N) cin >> A[i];
    sort(A.rbegin(), A.rend());
    int i, last = 0;
    for (i = 0; i < A.size(); i++) {
        if (A[i] == last) {
            B.push_back(A[i]);
            last = 0;
        } else {
            last = A[i];
        }
    }
    cout << (B.size() >= 2 ? (Int)B[0] * B[1] : 0) << endl;
    return 0;
}

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

int main()
{
    int a,b;
    
    cin >> a >> b;
    
    if(a>b){
        cout << "a > b" <<"\n";
    }
    else if(a<b){
        cout << "a < b" <<"\n";
    }
    else{
        cout << "a == b" <<"\n";
    }
    return 0;
}


Measured memory_bytes: 3028
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n, q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<int> ends;
    f(i, s.length() - 1){
        if(s[i] == 'A' && s[i + 1] == 'C'){
            ends.pb(i + 1);
        }
    }
    while(q--){
        int l, r;
        cin>>l>>r;
        l--, r--;
        auto it = lower_bound(all(ends), r);
        if(it != ends.end()){
            if(*it > r) --it;
        }
        else --it;
        auto it2 = upper_bound(all(ends), l);
        bool none = false;
        if(it2 != ends.end()){
            if(*it2 > r){
                none = true;
            }
        }
        if(none) cout<<"0\n";
        else cout<<it - it2 + 1<<"\n";
    }
    return 0;
}

Measured memory_bytes: 1228
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on
void main()
{
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long Q;
    Q = input.front.to!long;
    input.popFront;

    long[] c = new long[](cast(size_t)(N));
    foreach (i; 0 .. cast(size_t)(N))
    {
        c[i] = input.front.to!long;
        input.popFront;
    }

    long[] l = new long[](cast(size_t)(Q));
    long[] r = new long[](cast(size_t)(Q));
    foreach (i; 0 .. cast(size_t)(Q))
    {
        l[i] = input.front.to!long;
        input.popFront;
        r[i] = input.front.to!long;
        input.popFront;
    }

    solve(N, Q, c, l, r);
}

void solve(long N, long Q, long[] c, long[] l, long[] r)
{
    auto bit = BinaryIndexedTree(N);
    auto last = new long[](5 * 100_000 + 1);
    auto I = iota(Q).array();
    zip(r, l, I).sort();
    auto ans = new long[](Q);
    long ptr = 0;
    foreach (i; 0 .. Q)
    {
        while (ptr < r[i])
        {
            // writefln("%s %s %s", ptr, c[ptr], last[0 .. 10]);
            bit.add(ptr + 1, 1);
            if (last[c[ptr]] != 0)
            {
                bit.add(last[c[ptr]], -1);
            }
            last[c[ptr]] = ptr + 1;
            ptr++;
        }
        // writefln("%s %s %s %s", I[i], l[i], r[i], last[0 .. 10]);
        ans[I[i]] = bit.sum(r[i]) - bit.sum(l[i] - 1);
    }
    foreach (a; ans)
    {
        writeln(a);
    }
}

/// BIT (1-indexed)
alias BinaryIndexedTree = BinaryIndexedTreeImpl!long;
struct BinaryIndexedTreeImpl(T)
{
    T[] _data;
    this(long n)
    {
        _data = new T[](n + 1);
    }

    T sum(long i)
    {
        T ans;
        for (; 0 < i; i -= (i & -i))
            ans += _data[i];
        return ans;
    }

    void add(long i, T x)
    {
        for (; i < _data.length; i += (i & -i))
            _data[i] += x;
    }
}


Measured memory_bytes: 45112
Sa = list(input())
Sb = list(input())
Sc = list(input())
lena = len(Sa)-1
lenb = len(Sb)
lenc = len(Sc)

T = Sa[0]
Sa = Sa[1:]
for i in range(lena+lenb+lenc):
    if T == 'a':
        if len(Sa)==0:
            print('A')
            break
        else: 
            T = Sa[0]
            Sa = Sa[1:]
    elif T == 'b':
        if len(Sb)==0:
            print('B')
            break
        else: 
            T = Sb[0]
            Sb = Sb[1:]
    elif T == 'c':
        if len(Sc)==0:
            print('C')
            break
        else: 
            T = Sc[0]
            Sc = Sc[1:]

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main () {
  int D , N;
  cin >> D >> N;
  if(D == 0 && N !=100){
    cout << N << endl;
  }
  if(D == 0 && N == 100){
    cout << 101 << endl;
  }
  if(D == 1 && N !=100){
    cout << N * 100 << endl;
  }
  if(D == 1 && N == 100){
    cout << 101 * 100 << endl;
  }
  if(D == 2 && N !=100){
    cout << N * 10000 << endl;
  }
  if(D == 2 && N == 100){
    cout << 101 * 10000 << endl;
  }
}


Measured memory_bytes: 256
#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++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp)   for (auto &i : mp)

const int INF = 1001001001;

int main()
{
  int n;
  cin >> n;
  vector <int> d1(n);
  vector <int> d2(n);
  rep(i, n) {
    cin >> d1[i];
    cin >> d2[i];
  }
  int    counter = 0;
  string ans     = "No";
  for (int i = 0; i < n; i++) {
    if (d1[i] == d2[i]) {
      counter++;
    }
    else {
      counter = 0;
    }
    if (counter >= 3) {
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,i,j,ans;
  cin>>N;
  ans=10000000;
  vector<int>X(N);
  for(i=0;i<N;i++)
    cin>>X[i];
  sort(X.begin(),X.end());
  for(j=X[0];j<=X[N-1];j++){
    int sum=0;
    for(i=0;i<N;i++){
      sum+=(X[i]-j)*(X[i]-j);
    }
    if(sum<=ans)
    ans=sum;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a=0,b;
  int s,l;
  while(a<1 || 100<b){
    scanf("%d%d",&a,&b);
  }
  s = a*b;
  l = (a+b)*2;
  printf("%d %d\n",s,l);
  return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
int main(void)
{
        double a[10000];
        double min,max,sum;
        int i,n;
        sum = 0;
        max = -1000000;
        min = 1000000;
        scanf("%d",&n);
        for(i = 0;i < n;i++){
                scanf("%lf",&a[i]);
                sum = sum + a[i];
                if(max < a[i]){
                        max = a[i];
                }
                if(min > a[i]){
                        min = a[i];
                }
        }
        printf("%.0f %.0f %.0f\n",min,max,sum);
        return 0;
}

Measured memory_bytes: 740
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 5005;

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);

    int n;
    cin >> n;
    cout << n*n*n << '\n';
}
	
	

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

// C
int main(void){
    Cin(int, n);
    vc<int> ans(n);
    Rep(n-1){
        Cin(int, i);
        ans[i-1] ++;
    }
    For(i, n) Cout(ans[i]);
}


Measured memory_bytes: 4052
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <bits/stdc++.h>
using namespace std;

// utility of stdin,stdout
#define _CRT_SECURE_NO_WARNINGS
#define OUT cout << 
#define BR << endl
#define RET return 0
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,x;
	int ans;
	cin >> n >> x;
	std::vector<int> m(n);

	for (int i = 0; i < n; ++i)	cin >> m.at(i);
	std::vector<int>::iterator iter = std::min_element(m.begin(), m.end());
	size_t index = std::distance(m.begin(), iter);

	x -= std::accumulate(m.begin(), m.end(), 0);
	ans = n + x / m.at(index);
	OUT(ans) BR;
	RET;
}


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

using namespace std;

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

    vector<bool> problems(n, false);
    vector<int> WA(n);
    int ACcount = 0;
    int WAcount = 0;

    for (int i = 0; i < m; i++) {
        int p; string s;
        cin >> p >> s;
        p--;

        if (s == "AC") {
            if (!problems[p]) {
                problems[p] = true;
                ACcount++;
            }
        }
        if (s == "WA") {
            if (!problems[p]) {
                WA[p]++;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        if (problems[i]) {
            WAcount += WA[i];
        }
    }

    cout << ACcount << " " <<  WAcount << endl;

    return 0;
}

Measured memory_bytes: 640