akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int n; cin >>n;
  int a,b; cin >>a >>b;
  int res = b-a-1;
  cout <<(res % 2 == 1 ? "Alice" : "Borys") <<endl;
}


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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main()
{
    int n, d; 
    cin >> n >> d;
    vector<vector<int> > x(n, vector<int>(d));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> x[i][j];
        }
    }

    int ans = 0;
    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            int dist = 0;
            for(int k = 0; k < d; k++){
                dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }

            for(int l = 1; l <= 200; l++){
                if(dist == l * l){
                    ans++;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll t; cin>>t; while(t--)
typedef long long int ll;
int main() {
    FIO;
    //test
    {
       ll n;
       cin>>n;
       vector<double>a(n);
       for(int i=0;i<n;i++){
           cin>>a[i];
       }
       // Taken the input
       vector<vector<double>>dp(n+1,vector<double>(n+1,0));
       dp[0][0]=1;
       for(int i=0;i<n;i++){
           dp[i+1][0]=(dp[i][0]*(1-a[i]));
           for(int j=1;j<=n;j++){
               dp[i+1][j]+=(dp[i][j]*(1-a[i]));
               dp[i+1][j]+=(dp[i][j-1]*a[i]);
           }
       }
       n++;
       double ans=0;
       for(int i=n/2;i<n;i++){
           ans+=dp[n-1][i];
       }
       cout<<fixed<<setprecision(10)<<ans<<endl;
    }
	return 0;
}


Measured memory_bytes: 73756
#
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n, m = map(int, input().split())

    edges = defaultdict(list)

    for _ in range(m):
        u, v = map(int, input().split())
        edges[(u, 0)].append((v, 1))
        edges[(u, 1)].append((v, 2))
        edges[(u, 2)].append((v, 0))

    s, t = map(int, input().split())

    # print(new_edges)

    dones = set()
    que = deque()
    que.append(((s, 0), 0))
    while que:
        node, step = que.popleft()

        next_nodes = edges[node]
        # print(next_nodes)
        for n, l in next_nodes:
            if n == t and l == 0:
                print((step + 1) // 3)
                exit()

            if (n, l) not in dones:
                que.append(((n, l), step + 1))
                dones.add((n, l))
    print(-1)


if __name__ == '__main__':
    main()


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

using namespace std;

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

    string s;
    cin >> s;
    if (s[s.size()-1] != 's')
        s += "s";
    else
        s += "es";
    cout << s << "\n";
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;
const int MAX = 1100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

/*vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}*/


map< int, ll> prime_factor(int n) {
  map< int, ll > ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}



int main() {
    int n;
    cin>>n;
    ll A[n];
    map<int,ll> d;
    rep(i,n){
        cin>>A[i];
    }
    //最小公倍数を求める
    rep(i,n){
        //map<int,ll> d1;
        auto l=prime_factor(A[i]);
        /*for (int x:l){
            if (d1.count(x)){
                d1[x]+=1;
            }
            else{
                d1[x]=1;
            }
        }*/
        for (auto x:l){
            auto y=x.first;
            if (d.count(x.first)){
                d[x.first]=max(d[x.first],l[x.first]);
            }
            else{
                d[x.first]=l[x.first];
            }
        }

    }
    ll num=1;
    for (auto x:d){
        rep(i,d[x.first]){
            num*=x.first;
            num%=MOD;
        }
    }
    //cout<<num<<endl;
    COMinit();

    ll ans=0;

    rep(i,n){
        ans=(ans+num*inv[A[i]])%MOD;
        //ans%=MOD;
    }

    cout<<ans<<endl;





    return 0;
}

Measured memory_bytes: 26752
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 200000;
int n, w, p[N];
ll calc(int g) {
	vector<ll> sz(g, 0);
	ll res = 0;
	for (int j = 0; j < n; ++j) {
		int i = j%g;
		++sz[i];
		res += ((sz[i] + 1)*(sz[i] + 1) - (sz[i] > 1)*sz[i] * sz[i])*p[j];
		if (j < g)
			res += p[j];
	}
	res += (ll)g*w;
	res += (ll)n*w;
	return res;
}
int main()
{
	scanf("%d%d", &n, &w);
	for (int i = 0; i < n; ++i)
		scanf("%d", p + i);
	reverse(p, p + n);
	int l = 1, r = n, m, l1, l2;
	ll r1, r2, res = 1e18;
	while (l <= r) {
		l1 = (2 * l + r) / 3;
		l2 = (l + 2 * r) / 3;
		r1 = calc(l1);
		r2 = calc(l2);
		res = min(res, min(r1, r2));
		if (r2 > r1)
			r = l2 - 1;
		else
			l = l1 + 1;
	}
	printf("%lld\n", res);
	return 0;
}

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

int AdjM[101][101]={0};
int D[101];

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

void bfs(int s){
    //cerr<<"bfs root "<<s<<"\n";
    queue<int> Q;
    Q.push(s);
    D[s]=0;
    while(!Q.empty()){
        int cur=Q.front();
        Q.pop();
        //cerr<<"visiting "<<cur<<" "<<D[cur]<<"\n";
        for(int i=1;i<101;++i){
            if(AdjM[cur][i]!=0 && D[i]==-1){
                D[i]=D[cur]+1;
                Q.push(i);
            }
        }
    }
}

int main(){
    Fill(D,-1);
    int n;
    cin>>n;
    int id,num,ix;
    for(int i=0;i<n;++i){
        cin>>id>>num;
        for(int j=1;j<=num;++j){
            cin>>ix;
            AdjM[id][ix]=1;
        }
    }

    bfs(1);

    for(int i=1;i<=n;++i){
        cout<<i<<" "<<D[i]<<"\n";
    }
}

Measured memory_bytes: 3108
#include<iostream>
#include<cstdio>
#include<algorithm>
#define f first
#define s second
using namespace std;
typedef pair<pair<int,int>,pair<int,int> > P;
bool PC(P&f,P&s){return f.s.s<s.s.s;}
int main()
{
	int i,n,m,p,y;
	P a[100010];
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		cin>>p>>y;
		a[i].f.f=p;
		a[i].f.s=y;
		a[i].s.f=0;
		a[i].s.s=i;
	}
	sort(a,a+m);
	p=a[0].f.f;
	for(y=i=0;i<m;i++)
	{
		if(p!=a[i].f.f)p=a[i].f.f,y=0;
		a[i].s.f=++y;
	}
	sort(a,a+m,PC);
	for(i=0;i<m;i++)printf("%012ld\n",(long)(a[i].f.f*1e6+a[i].s.f));
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>

using namespace std;

int main()
{
	int a, b, c;
	cin >> a>> b>> c;
	if (a <= c && c <= b)
		cout << "Yes";
	else if (b <= c && c <= a)
		cout << "Yes";
	else
		cout << "No";

		return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
  cin >> s;
  char old = 'o';
  int count = 0;
  rep(i,(int)s.size()){
    if(old != s[i]){
      count++;
    }
    old = s[i];
  }
  cout << count-1 << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int m,n;
    cin>>m>>n;
    for(int i=0;i<=m;i++)
    for(int j=0;j<=m;j++)
    for(int k=0;k<=m,i+j+k<=m;k++){
    if(i+j+k==m&&i*1000+j*5000+k*10000==n){printf("%d %d %d",k,j,i);return 0;}}
    printf("-1 -1 -1");
    return 0;
}

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

int main()
{
  int n, m, a;
  int h, p, q;

  // left[a][h]==true iff ?£?a?????????h????????????????¨??£??????????
  bool left[101][1001], right[101][1001];

  while (1)
  {
    for (int i=0;i<101;i++)
      for (int j=0;j<1001;j++)
      { left[i][j]=false; right[i][j]=false; }

    cin >> n >> m >> a;
    if (n == 0) return 0;
    int maxh = 0;
    for (int i=0;i<m;i++)
    {
      cin >> h >> p >> q;
      maxh = max(h, maxh);
      right[p][h]=true;
      left[q][h]=true;
    }

    for (h=maxh;h>0;h--)
    {
      if (right[a][h]) a++;
      else if (left[a][h]) a--;
    }
    cout << a << endl;
  }
}

Measured memory_bytes: 1356
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String[] spl = s.split(" ");
		int A = Integer.parseInt(spl[0]);
		int B = Integer.parseInt(spl[1]);
		sc.close();

		if(A == B) {
			System.out.println(0);
		}else if((A + B) % 2 == 0){
			System.out.println((A + B) / 2);
		}else {
			System.out.println("IMPOSSIBLE");
		}
	}
}

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

using namespace std;


#define N 200005



int32_t main()
{
   // ios_base::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;

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

    int l=0,r=1e7;
    sort(a.begin(),a.end());
    
    vector < int > vis(m+1,0);

    set < pair < int , int > > mx;
    for(int i=1;i<m;i++)
    {
        mx.insert({a[i]-a[i-1],i});
    }

    int cur=n-1;
    vis[0]=1;
    while(cur && mx.size())
    {
        auto it = mx.end();
        it--;
        pair < int , int > me=*it;
        mx.erase(it);
        vis[me.second]=1;
        cur--;
    }

    int prev=a[0],ans=0;
    for(int i=1;i<m;i++)
    {
        if(vis[i]==1)
            prev=a[i];
        else
        {
            ans+=a[i]-a[i-1];
        }
    }
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

int main() {
	int n;	cin >> n;
	vector<LL> a(n);
	vector<bool> alive(n, true);
	for (auto &x : a) {
		cin >> x;
	}

	int dead = 0;
	int min = 0;
	while (dead < n - 1) {
		int index = distance(a.begin(), min_element(a.begin(), a.end()));
		min = a[index];
		for (int i = 0; i < n; i++) {
			if (!alive[i] || i == index) continue;
			if ((a[i] %= min) == 0) {
				a[i] = 1e10;
				alive[i] = false;
				dead++;
			}
		}
	}
	cout << min;

	return 0;
}


Measured memory_bytes: 1024
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

s = input()
t = input()

s = ''.join(sorted(s))
t = ''.join(sorted(t, reverse=True))

if s < t:
    print("Yes")
else:
    print("No")



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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long MOD = 1000000007;

void func(int n, long long m, vi oks) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    vll dp(n + 1);
    dp[0] = 1;                           //０段目は確実に１通り
    for (int now = 0; now < n; now++) {  //０段から見ていく
        for (int next = now + 1; next <= min(n, now + 2); next++) {
            // 次の段か次の次の段をみる、もしくは最大値まで
            if (oks[next]) {          //次に進めるのならば
                dp[next] += dp[now];  //今までの累積を次に渡す。
                dp[next] %= mod;  //巨大になりすぎる前にmodしておく。
            }
        }
    }
    cout << dp[n] << endl;
}

int main() {
    int N;
    scanf("%d", &N);
    long long M;
    scanf("%lld", &M);
    vi oks(N + 1, true);  // ok step ＝壊れていない段
    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        oks[a] = false;
    }
    func(N, M, std::move(oks));
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin>>n;
  double arr[n];
  double pro=1;
  for(int i=0;i<n;i++){
    cin>>arr[i];
    pro=pro*arr[i];
  }
  double sum=0;
  for(int i=0;i<n;i++){
	sum+=pro/arr[i];
  }
  double ans=pro/sum;
  printf("%.9f\n",ans);
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int i,j,ans;
	for(i=1;i<10;i++)
	{
		for(j=1;j<10;j++)
		{
			ans=0;
			ans=i*j;
			printf("%dx%d=%d\n",i,j,ans);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	
	while (1) {
		int M, N, r, t, n, m, s, q, ts, te, b[10001] = {}, ans;
		vector< vector<int> > a(10001);
		cin >> N >> M;
		if (N == 0 && M == 0) {
			break;
		}
		cin >> r;
		for (int i = 0; i < r; i++) {
			cin >> t >> n >> m >> s;
			if (s == 1) {
				if (b[m] == 0) {
					a[m].push_back(t);
					b[m]++;
				}
				else {
					b[m]++;
				}
			}
			else {
				if (b[m] == 1) {
					a[m].push_back(t);
					b[m]--;
				}
				else {
					b[m]--;
				}
			}
		}/*
		for (int i = 0; i < 5; i++) {
			for (int j = 0; j < a[i].size(); j+=2) {
				cout << a[i][j] << ' ' << a[i][j + 1] << endl;
			}
		}*/
		cin >> q;
		for (int i = 0; i < q; i++) {
			ans = 0;
			cin >> ts >> te >> m;
			for (int j = 0; j < a[m].size(); j += 2) {
				if ((ts <= a[m][j] && a[m][j] <= te) || (ts <= a[m][j + 1] && a[m][j + 1] <= te)) {
					int ss = max(ts, a[m][j]);
					int se = min(te, a[m][j + 1]);
					ans += se - ss;
				}
				else if (a[m][j] <= ts && te <= a[m][j+1]) {
					ans += te - ts;
				}
			}
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
using ull = uint_fast64_t;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i < n; ++i)
ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
template <typename T> void vecout(const T &v) {
  for (auto it = v.begin(); it != v.end();
       ++it, cout << (it != v.end() ? " " : "\n")) {
    cout << *it;
  }
}


void solve() {
  // main coding
  int n,m; cin>>n>>m;
  vector<vector<int>> E(n);
  vector<int> indeg(n);
  int x,y;
  rep(_,m) {
    cin>>x>>y;
    x--; y--;
    E[x].push_back(y);
    indeg[y]++;
  }
  queue<int> q;
  vector<int> t_sort;
  rep(i,n) if(indeg[i]==0) q.push(i);
  while(!q.empty()) {
    int u=q.front(); q.pop();
    t_sort.push_back(u);
    for(int v: E[u]) { // u to v:
      indeg[v]--;
      if(indeg[v]==0) q.push(v);
    }
  }
  vector<int> dp(n);
  for(int u: t_sort) {
    for(int v: E[u]) {
      dp[v]=max(dp[v],dp[u]+1);
    }
  }
  cout<<*max_element(dp.begin(),dp.end())<<endl;
}

int main() {
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 7032
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,t;cin>>n>>t;
	vector<pair<int,int>> dish(n);
	int mx = 0 ;
	for(int i=0;i<n;++i){
		int a,b;cin>>a>>b;
		dish[i] = {a,b};
		mx = max(mx,a);
	}
	sort(dish.begin(),dish.end());
	vector<int> dp(t+mx+1,0);
	int sz = dp.size();
	for(int i=0;i<n;++i){
		for(int j=sz-1;j>=0;--j){
			if(j>=dish[i].first && j-dish[i].first < t){
				dp[j] = max(dp[j],dp[j-dish[i].first] + dish[i].second);
			}
		}
	}
	int res = 0;
	for(int i=0;i<sz;++i)res = max(res,dp[i]);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
class Input {
    private lines: string[];
    constructor(lines: string[]) {
        this.lines = lines;
    }

    public readLine(): string { return this.lines.shift() as string; }
    public readLineInt(): number { return parseInt(this.readLine()); }
    public readLineIntArray(): number[] { return this.readLine().split(" ").map(n => parseInt(n)); }
    public readLineStringArray(): string[] { return this.readLine().split(" "); }

    public readAllLines(): string[] { return this.lines; }
    public readAllLinesInt(): number[] { return this.lines.map(s => parseInt(s)); }
    public readAllLinesIntArray(): number[][] { return this.lines.map(s => s.split(" ").map(n => parseInt(n))); }
    public readAllLinesStringArray(): string[][] { return this.lines.map(s => s.split(" ")); }
}

function calc(stdin: Input) {
    const first = stdin.readLineIntArray();
    const K = first[0];
    const S = first[1];

    let num = 0;
    for (let i = 0; i <= K; i++) {
        for (let j = 0; j <= K; j++) {
            let k = S - i - j;
            if (0 <= k && k <= K) {
                num++;
            }
        }
    }

    return num;
}
function main(stdin: string) {
    console.log(calc(new Input(stdin.split("\n"))));
}

if (require.main && require.main.filename.indexOf("Main") >= 0) {
    main(require('fs').readFileSync('/dev/stdin', 'utf8'));
} else {
    main(`
2 2
`.trim());
}

Measured memory_bytes: 7372
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	S := sc.nextRuneSlice()
	Q := sc.nextInt()
	head := true
	left := make([]byte, 0)
	right := make([]byte, 0)
	for i := 0; i < Q; i++ {
		T := sc.nextInt()
		if T == 1 {
			head = !head
		} else {
			f := sc.nextInt()
			c := sc.nextRuneSlice()[0]
			if (head && f == 1) || (!head && f == 2) {
				left = append(left, c)
			} else {
				right = append(right, c)
			}
		}
	}

	var ans []byte
	if head {
		for l, r := 0, len(left)-1; l < r; l, r = l+1, r-1 {
			left[l], left[r] = left[r], left[l]
		}
		ans = append(ans, left...)
		ans = append(ans, S...)
		ans = append(ans, right...)
		fmt.Printf("%s\n", string(ans))
	} else {
		for l, r := 0, len(right)-1; l < r; l, r = l+1, r-1 {
			right[l], right[r] = right[r], right[l]
		}
		for l, r := 0, len(S)-1; l < r; l, r = l+1, r-1 {
			S[l], S[r] = S[r], S[l]
		}
		ans = append(ans, right...)
		ans = append(ans, S...)
		ans = append(ans, left...)
		fmt.Printf("%s\n", string(ans))
	}
	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


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

int N;
double x[8];
double y[8];
bool used[8];

double dist(int n, int p) {
	if (n == N) {
		return 0;
	}

	double res = 0;
	for (int i = 0; i < N; ++i) {
		if (used[i]) {
			continue;
		}

		used[i] = true;
		double d = sqrt((x[i] - x[p]) * (x[i] - x[p]) + (y[i] - y[p]) * (y[i] - y[p]));
		res += d + dist(n + 1, i);
		used[i] = false;
	}

	return res;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> x[i] >> y[i];
	}

	double res = 0;
	for (int i = 0; i < N; ++i) {
		used[i] = true;
		res += dist(N - 1, i);
		used[i] = false;
	}

	cout << setprecision(16) << res / N;

	return 0;
}




Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);

	while ( stdin.hasNextInt() ) {

	    final int a = stdin.nextInt();
	    final int b = stdin.nextInt();
	    final int n = stdin.nextInt();

	    int mod = a % b;
	    int sum = 0;
	    for ( int i = 0; i < n; i++ ) {
		mod *= 10;
		sum += mod / b;
		mod %= b;
	    }
	    
	    System.out.println( sum );
	}
	
    }    
}

Measured memory_bytes: 19972
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

template <typename T>
class SegTree {
   private:
    int n;
    T ID_ELEM;
    vector<T> dat;
    T op(const T &a, const T &b) { return max(a, b); }

   public:
    SegTree(int n, T ID_ELEM) : ID_ELEM(ID_ELEM) {
        this->n = 1;
        while (this->n < n) {
            this->n *= 2;
        }
        dat.resize(2 * this->n - 1, ID_ELEM);
    }

    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r == -1) r = n;
        if (a >= r || b <= l) {
            return ID_ELEM;
        } else if (a <= l && r <= b) {
            return dat[k];
        }
        int mid = (l + r) / 2;
        return op(query(a, b, k * 2 + 1, l, mid), query(a, b, k * 2 + 2, mid, r));
    }

    void update(int k, T a) {
        k += n - 1;
        dat[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = op(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    void update(int k) {
        k += n - 1;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = op(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    T &at(int k) { return dat[k + n - 1]; }
};

#define MAX_N 100000
int n;
ll c, pvx, ans;
ll cal[2][MAX_N + 2], x[MAX_N + 2], v[MAX_N + 2];

int main() {
    scanf("%d%lld", &n, &c);
    reps(i, n) { scanf("%lld%lld", &x[i], &v[i]); }

    SegTree<ll> front(n + 2, -linf), back(n + 2, -linf);
    ll c1 = 0, c2 = 0;
    x[n + 1] = c;
    reps(i, n) {
        c1 += -(x[i] - x[i - 1]) + v[i];
        front.update(i, c1);
        c2 += -(x[n - i + 2] - x[n - i + 1]) + v[n - i + 1];
        back.update(i, c2);
    }
    ans = 0;
    reps(i, n) {
        ans = max({ans, front.at(i), back.at(i), front.at(i) - x[i] + back.query(0, n - i + 1),
                   back.at(i) - (c - x[n - i + 1]) + front.query(0, n - i + 1)});
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 5888
N,M,C=map(int,input().split())
b=[int(i) for i in input().split()]

a = []
for i in range(N):
    a.append(list(map(int, input().split())))

cnt=0
for i in range(N):
    plus=0
    for j in range(M):
        plus+=a[i][j]*b[j]
        #print(i,end=' ')
        #print(j)
        
    plus+=C
    if plus>0:
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())
from collections import Counter
count = Counter(S)

a = count['a']
b = count['b']
c = count['c']
N = len(S)

N = N//3
if N<=a<=N+1 and N<=b<=N+1 and N<=c<=N+1:
    print('YES')
else:
    print('NO')

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

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

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

    ll A,B;
    
    string b;
    cin >> A >> b;

    B = (b[0]-'0')*100 + (b[2]-'0')*10 + (b[3]-'0');

    cout << A*B/100 << endl;

    return 0;

}

Measured memory_bytes: 3652
import javax.xml.stream.events.EntityReference;
import java.util.*;

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

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

    private void run() {
        long n = sc.nextLong();
        Map<Long, Long> map = primeFactorization(n);

        int ans = 0;
        for (int i = 1; ; i++) {
            boolean isFound = false;
            for (Map.Entry<Long, Long> entry : map.entrySet()) {
                if (entry.getValue() >= i) {
                    ans++;
                    map.put(entry.getKey(), entry.getValue()-i);
                    isFound = true;
                }
            }
            if (!isFound) break;
        }
        System.out.println(ans);
    }

    static TreeMap<Long, Long> primeFactorization(long n) {

        TreeMap<Long, Long> map = new TreeMap<>();
        long sq = (long) Math.sqrt(n);

        //nが素数ならn^1の形で返す
        if (isPrime(n) == true) {
            map.put(n, 1L);
            return map;
        }

        for (int i = 2; i <= sq; i++) {
            //n<iなら明らかにnをiで除算できないので終了（ループを余計に回さない）
            if (n < i)
                break;

            //iが素数なら、nをiで何回除算できるか、その回数をmapに記録する
            if (isPrime(i) == true) {
                long count = 0;
                while (n % i == 0) {
                    n /= i;
                    count++;
                }
                if (count > 0) { //1回以上割れた場合のみ、mapに記録する
                    map.put((long)i, count);
                }
            }

        }

        //2～sqrt(n)で除算した結果、なお残った数をmapに追加する
        if (n != 1)
            map.put(n, 1L);

        return map;

    }

    //素数判定メソッド
    static boolean isPrime(long n) {
        if (n == 2)
            return true;
        if (n < 2 || n % 2 == 0)
            return false;
        int d = (int) Math.sqrt(n);
        for (int i = 3; i <= d; i += 2) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }
}



Measured memory_bytes: 35944
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int K;
  cin >> K;
  if(K%2==0) {
    cout << -1 << endl;
    return 0;
  }
  if(K%7==0) {
    K /= 7;
  }
  ll x = 1;
  int ans = 0;
  while(x%K!=0&&ans<10000000) {
    ans++;
    x = 10*x+1;
    x %= K;
  }
  if(ans==10000000) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans+1 << endl;
  return 0;
}

Measured memory_bytes: 3632
/*****************************************************
 *     created by: nayakashutosh9
 * "Winners Never Quit and Quitters Never Win".
*****************************************************/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 300005;
/**********************************************************************************************/
struct dt {
	int a, b, c, d;
};
int n, m, q, ans;
vector<dt> a;
vector<int> val;
void check(int i, int st) {
	if (i == n) {
		int cur = 0;
		for (int j = 0; j < q; j++) {
			if (val[a[j].b - 1] - val[a[j].a - 1] == a[j].c) cur += a[j].d;
		}
		ans = max(ans, cur);
		return;
	}
	for (int j = st; j <= m; j++)
		val[i] = j, check(i + 1, j);
}
void solve() {
	cin >> n >> m >> q;
	a.clear(); a.resize(q);
	for (int i = 0; i < q; i++)
		cin >> a[i].a >> a[i].b >> a[i].c >> a[i].d;
	ans = 0; val.clear(); val.resize(n, 0);
	check(0, 1);
	cout << ans << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1, z = 1;
	// cin >> t; cin.ignore();
	while (t--) {
		// cout << "Case #" << (z++) << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

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

int main(){
  int N,a;
  string S;
  cin>>N>>S;
  vector<int> sum(N);
  sum.at(0)=0;
  for(int i=1;i<N;i++){
    if(S.at(i)=='E')sum.at(0)++;
  }
  a=sum.at(0);
  for(int i=1;i<N;i++){
    if(S.at(i-1)!=S.at(i)){
      sum.at(i)=sum.at(i-1);
    }else if(S.at(i-1)=='E'){
      sum.at(i)=sum.at(i-1)-1;
      if(a>sum.at(i)){
        a=sum.at(i);
      }
    }else{
      sum.at(i)=sum.at(i-1)+1;
    }
  }
  cout<<a<<endl;
  
  
}

Measured memory_bytes: 1796
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    dp = [[0 for i in range(3)] for j in range(N)]
    
    ml = list(zip(a,b,c))

    for i,v in enumerate(ml[0]):
        dp[0][i] = v

    for i,m in enumerate(ml[1:]):
        i += 1
        for j in range(3):
            for k in range(3):
                if j != k:
                    dp[i][j] = max(dp[i][j],dp[i-1][k]+m[j])

    print(max(dp[-1]))
    



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]" 
    b = [int()] * (N)  # type: "List[int]" 
    c = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, a, b, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 44964
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N, K;
  cin >> N >> K;

  ll D[K];
  REP(i, K) { cin >> D[i]; }

  FOR(i, N, 100000) {
    ll tmp = i;
    set<ll> s;

    while (tmp > 0) {
      s.insert(tmp % 10);
      tmp /= 10;
    }

    bool f = true;

    REP(j, K) {
      if (s.count(D[j])) {
        f = false;
      }
    }
    if (f) {
      cout << i;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
ll mo=1000000007,ans=0;
ll dp[0][0];

int main()
{
ll n,q;

cin >> n>>q;
string s;
cin >> s;
s='z'+s+'z';
char t[q];
char d[q];
rep(i,q) {
    cin >> t[i]>>d[i];
}
char now;
int ichi,syo,sita=0,ue=0;

//二分探索でichiを指定
int x=0,z=n+1;
while(true){
syo=(x+z)/2;
ichi=syo;
//cout << syo<<' ';
now=s[ichi];
rep(i,q){
    if(now==t[i]){
        if(d[i]=='L'){now=s[ichi-1];ichi--;}
        else{now=s[ichi+1];ichi++;}
        //cout << now<<' ';
        
    }
}
if(ichi==0){
    x=syo;
    if(x==z-1){sita=syo;break;}
    }
else {
    z=syo;
    if(x==z-1){sita=syo-1;break;}
    }
}
//二分探索でichiを指定
x=0;
z=n+1;
while(true){
syo=(x+z)/2;
ichi=syo;
//cout << syo<<' ';
now=s[ichi];
rep(i,q){
    if(now==t[i]){
        if(d[i]=='L'){now=s[ichi-1];ichi--;}
        else{now=s[ichi+1];ichi++;}
        //cout << now<<' ';
        
    }
}
if(ichi!=n+1){
    x=syo;
    if(x==z-1){ue=syo+1;break;}
    }
else {
    z=syo;
    if(x==z-1){ue=syo;break;}
    }
}

ans=-sita+ue-1;
cout << ans << endl;
return 0;
}





Measured memory_bytes: 984
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_bacm
#define mp mame_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    string ans = "";
    for (int i = 0; i < n; i++){
        ans += s[i];
        ans += t[i];
    }
    cout << ans << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#define INF 1000000000

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

int main()
{
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	//-1,2 できる
	int ret=INF;
	//even
	int cnt=0;
	int a=A,b=B,c=C;
	if(a%2==1) a--,cnt++;
	if(b%2==1) b--,cnt++;
	if(c%2==1) c--,cnt++;
	int mx=max(a,max(b,c));
	cnt+=(mx-a)/2+(mx-b)/2+(mx-c)/2;
	ret=min(ret,cnt);
	//oddcnt=0;
	cnt=0;
	a=A,b=B,c=C;
	if(a%2==0) a--,cnt++;
	if(b%2==0) b--,cnt++;
	if(c%2==0) c--,cnt++;
	mx=max(a,max(b,c));
	cnt+=(mx-a)/2+(mx-b)/2+(mx-c)/2;
	ret=min(ret,cnt);
	printf("%d\n",ret);
	return 0;
}


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

int main() {
  int N, A;
  cin >> N;
  map<int, int> MA;
  while (cin >> A) MA[A]++;
  int cnt = 0;
  for (auto &ma : MA) {
    ma.second %= 2;
    if (!ma.second) ma.second += 2;
    if (ma.second == 2) cnt++;
  }
  cout << ((cnt % 2) ? MA.size() - 1 : MA.size()) << "\n";
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<string, string> sP;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second



int main() {
	int n, k, d;
	bool b[11] = { 0 };
	cin >> n >> k;
	for (int i = 0;i < k;i++) {
		cin >> d;
		b[d] = true;
	}
	for (int i = n;i < 1000000;i++) {
		string s = to_string(i);
		bool fl = 0;
		for (int j = 0;j < s.size();j++) {
			if (b[s[j] - '0'])fl = 1;
		}
		if (!fl) {
			cout << s << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}


int N;
vector<int> memo(100010,0);
int get(int n){
  if(n < 0){
    return INF;
  }
  else{
    return memo[n];
  }
}

signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N;
  memo[0] = 0;
  memo[1] = 1;
  int i = 2;
  while(true){
    memo[i] = min({get(i-1)+1,get(i-6)+1,get(i-36)+1,get(i-216)+1,get(i-1296)+1,
        get(i-7776)+1,get(i-46656)+1,get(i-9)+1,get(i-81)+1,get(i-729)+1,get(i-6561)+1,get(i-59049)+1});
    i++;
    if(i > 100000){
      break;
    }
  }
  cout << memo[N] << endl;
  return 0;
}


Measured memory_bytes: 640
/*input
5
0 0
0 1
1 0
2 2
3 1
*/
#include <bits/stdc++.h>
#define pr pair<int,int>
using namespace std;
const int N = 1e5 + 5;
int n;
#define val(u,t) (u + (t == 0 ? 0 : N))
bool ok[2*N];
pr point[N];
vector<int> Gx[N], Gy[N];
map< pr ,bool> check;
void dfs(int u, int& xPoint, int& yPoint,bool t){
	if (!t){
		for (auto y : Gx[u]){
			if (!ok[val(y, 1)]){
				ok[val(y,1)] = 1;
				dfs(y, xPoint, ++yPoint,1);
			}
		}
	}
	if (t){
		for (auto x : Gy[u]){

			if (!ok[val(x, 0)]){
				ok[val(x,0)] = 1;
				dfs(x, ++xPoint, yPoint,0);
			}
		}
	}
}
int main(){
	// freopen("solve.inp","r", stdin);
 //    freopen("solve.out","w", stdout);
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i=1;i<=n;++i){
		int x,y; cin >> x >> y;
		point[i] = {x, y};
		Gx[x].push_back(y);
		Gy[y].push_back(x);
	}
	long long ans = 0;
	for (int i=1;i<=n;++i){
		if (!ok[val(point[i].first,0)]) {
			#define x point[i].first
			#define y point[i].second
			int xPoint = 1, yPoint = 0;
			ok[val(x, 0)] = 1;
			dfs(x,xPoint, yPoint, 0);
			// cout << xPoint << ' ' << yPoint << ' ' << cnt << '\n';
			ans += 1LL * xPoint * yPoint;
		}
	}
	cout << ans - n;
}

Measured memory_bytes: 16920
package main

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

func main() {
	_, A, B := ReadInt(), ReadInt(), ReadInt()
	S := ReadString()
	var a, b int
	for _, si := range []byte(S) {
		switch si {
		case 'a':
			if a+b < A+B {
				fmt.Println("Yes")
				a++
			} else {
				fmt.Println("No")
			}
		case 'b':
			if a+b < A+B && b+1 <= B {
				fmt.Println("Yes")
				b++
			} else {
				fmt.Println("No")
			}
		case 'c':
			fmt.Println("No")
		}
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 2584
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}*/
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 
 














int main()
{
     string s;
     cin>>s;
     int n=s.length();
     int dp[n+1][2];memset(dp,0,sizeof(dp));
     for(int i=0;i<n;i++){
          if(s[i]=='1'){
               dp[i+1][1]=dp[i][0];
               dp[i+1][0]=1+dp[i][1];
          }
          else 
          {
               dp[i+1][0]=dp[i][1];
               dp[i+1][1]=1+dp[i][0];
          }
     }
     cout<<min(dp[n][0],dp[n][1]);
}




















 
 
 
 
 

















Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 200030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
int main()
{
ll n,k;
cin>>n>>k;
ll arr[n];
rep(i,0,n)
cin>>arr[i];
sort(arr,arr+n);
if(k>=n)
cout<<0;
else
{
	ll z=n-k;
	ll sum=0;
	for(int i=0;i<z;i++)
	sum+=arr[i];
	cout<<sum;
}


}

Measured memory_bytes: 1792
n = int(input())
data = input().split()
d = int(data[0])
x = int(data[1])
a = []
for i in range(n):
	a.append(int(input()))
sum = 0
for i in range(n):
	j = 1
	while j <= d:
		j += a[i]
		sum += 1	
print(sum+x)

Measured memory_bytes: 3064
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<set>
#include<vector>
#include<algorithm>
#include<array>
#include<cmath>

using namespace std;

int main(){/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

    long long int res = 0, n, a, b;
    cin>>n>>a>>b;
    res += (n / (a + b)) * a;
    res += (n % (a + b) > a) ? (a) : (n % (a + b));
    cout<<res<<endl;

}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    a = LI()

    ans = len([a[i] for i in range(N) if i % 2 == 0 and a[i] % 2 != 0])
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10108
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int k;
	cin >> k;
	for (int i = 0;i < k;++i) {
		int x, y;
		cin >> x >> y;
		int hoge = min(x - 1, n - x);
		hoge = min(hoge, y - 1);
		hoge = min(hoge, n - y);
		if (hoge % 3 == 0) {
			cout << 1 << endl;
		}
		else if (hoge % 3 == 1) {
			cout << 2 << endl;
		}
		else {
			cout << 3 << endl;
		}
	}
}


Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10,inf=1e9+10,mod=1e9+7;
int a[M],n;
pii cur[M];
main()
{
	int n,a,b,minn=inf,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a>>b;
		ans+=a;
		if(b<a)minn=min(minn,b);
	}
	if(minn==inf)return cout<<0,0;
	cout<<ans-minn;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
long long W,H,x,y;


int main(){
    cin >> W >> H >> x >> y;
    double s = W*H/2.0;
    cout << setprecision(20) << s << ' ';
    double gx = W/2.0, gy = H/2.0;
    if(x == gx && y == gy) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
flag = False
if (s[0] == 'A' and s[1] == 'B') or (s[0] == 'B' and s[1] == 'A'):
    flag = True

if (s[1] == 'A' and s[2] == 'B') or (s[1] == 'B' and s[2] == 'A'):
    flag = True

if flag:
    print("Yes")

else:
    print("No")

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

int main(){
    int n,m;
    cin >> n >> m;
    int a[n][m],b[m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i<m;i++)cin >> b[i];
    for(int i=0;i<n;i++){
        int k=0;
        for(int j=0;j<m;j++){
            k+=a[i][j]*b[j];
        }
        cout << k << endl;
    } 
}


Measured memory_bytes: 3152