akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int bm = 100002;
int BIT[bm];
void addp(int A) {
	while (A <= bm) {
		BIT[A]++;
		A += A & -A;
	}
}
void addn(int A) {
	while (A <= bm) {
		BIT[A]--;
		A += A & -A;
	}
}
int query(int A) {
	int ret = 0;
	while (A > 0) {
		ret += BIT[A];
		A -= A & -A;
	}
	return ret;
}

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], *di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) *di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint(), M = getint();
	int L[300001], ne[300001], he[100001] = {};
	rep1(i, N) {
		L[i] = getint();
		int lr = getint();
		lr += 1 - L[i];
		ne[i] = he[lr];
		he[lr] = i;
	}

	int k = N;
	putint(N);
	int cnt2 = 0;
	for (int j = he[1]; j; j = ne[j]) {
		addp(L[j]);
		addn(L[j] + 1);
		cnt2 += L[j] & 1;
		k--;
	}
	if (M >= 2) {
		putint(N - cnt2);
		for (int j = he[2]; j; j = ne[j]) {
			addp(L[j]);
			addn(L[j] + 2);
			k--;
		}
	}
	for (int i = 3; i <= M; i++) {
		int ans = k;
		for (int j = i; j <= M; j += i) {
			ans += query(j);
		}
		if (ans) putint(ans);
		else {
			*di++ = '0';
			*di++ = '\n';
		}
		for (int j = he[i]; j; j = ne[j]) {
			addp(L[j]);
			addn(L[j] + i);
			k--;
		}
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4736
#include<string.h>
#include<math.h>
#include<stdio.h>

void tennis(int score_a,int score_b)
{
	char game=0;
	int a_count=score_a;
	int b_count=score_b;
	if(score_b>=5)
	{
		game='B';
		b_count=4;
	}
	if(score_a>=5)
	{
		if(game)
		{
			game=1;/*分け*/
		}
		else
		{
			game='A';
		}
		a_count=4;
	}
	int bit_count=a_count+b_count;
	
	char result[bit_count+1];
	int limit=(int)pow(2,bit_count);
	
	unsigned int result_bin,cp_result_bin;
	int t_count;
	int echo_count;
	for(result_bin=0x00;result_bin<limit;++result_bin)
	{
		t_count=0;
		for(cp_result_bin=result_bin;cp_result_bin!=0;cp_result_bin&=cp_result_bin-1)
		{
			t_count++;
		}
		echo_count=bit_count-1;
		if(t_count==b_count)
		{
			for(cp_result_bin=result_bin;echo_count>=0;cp_result_bin=cp_result_bin>>1)
			{
				if(cp_result_bin & 0x01)
				{
					result[echo_count--]='B';
				}
				else
				{
					result[echo_count--]='A';
				}
			}
			result[bit_count]='\0';
			printf("%s",result);
			int i;
			if(game!=1)
			{
				for(i=0;score_a+score_b>bit_count+i;++i)
				{
					printf("%c",game);
				}
			}
			else/*分け*/
			{
				printf("AB\n");
				printf("%sBA",result);
			}
			printf("\n");
		}
	}
}

int main()
{
	int score_a,score_b;
	scanf("%d %d",&score_a,&score_b);
	
	tennis(score_a,score_b);
	
	return 0;
}
	

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF 5000000000000000000
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<ull>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  vector<ull>L(N,0),R(N,0);
  L[0]=A[0];
  R[N-1]=A[N-1];
  for(int i=1;i<N;i++)L[i]+=A[i]+L[i-1];
  for(int i=N-2;i>=0;i--)R[i]+=A[i]+R[i+1];
  ull ans=INF;
  for(int i=1;i<N;i++){
    if(L[i-1]>R[i])ans=min(ans,L[i-1]-R[i]);
    else ans=min(ans,R[i]-L[i-1]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

string dp[20000];

int main(){
    int n;
    cin >> n;
    VEC(ll, a, 3 * n);

    vector<ll>pre(n + 1, 0), suf(n + 1, 0);

    priority_queue<ll, vector<ll>, greater<ll>> pq_M;
    rep(i, n){
        pq_M.push(a[i]);
        pre[0] += a[i];
    }
    
    int now = 0;
    REP(i, n, 2 * n - 1){
        now++;
        ll MIN = pq_M.top();
        if(MIN < a[i]){
            pre[now] = pre[now - 1] - MIN + a[i];
            pq_M.pop();
            pq_M.push(a[i]);
        }
        else pre[now] = pre[now - 1];
    }




    priority_queue<ll> pq_m;
    reverse(ALL(a));
    rep(i, n){
        pq_m.push(a[i]);
        suf[0] += a[i];
    }

    now = 0;
    REP(i, n, 2 * n - 1){
        now++;
        ll MAX = pq_m.top();
        if(MAX > a[i]){
            suf[now] = suf[now - 1] - MAX + a[i];
            pq_m.pop();
            pq_m.push(a[i]);
        }
        else suf[now] = suf[now - 1];
    }

    reverse(ALL(suf));
    
    ll res = -INF * INF;
    const int len = pre.size();
    rep(i, len){
        res = max(res, pre[i] - suf[i]);
    }
    cout << res << endl;
}



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

int main(){
	int N,K;
  	cin >> N >> K;
  
  	int cnt=0;
  	for(int i=0;i<N;i++){
    int h;
    cin >> h;
    if(h >= K) cnt++;
    }
  	cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main(void)
{
    int N;
    cin >> N;

    int64_t a[100000];

    int64_t p = 1;
    for (int i = 0; i < N; ++i)
    {
        cin >> a[i];

        if (a[i] == 0)
        {
            cout << 0;
            return 0;
        }
    }

    for (int i = 0; i < N; ++i)
    {
        if (a[i] <= 1000000000000000000/p) 
        {
            p *= a[i];
        }
        else
        {
            cout << (-1);
            return 0;
        }
    }
    
    cout << p;

    return 0;
}


Measured memory_bytes: 3908
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<MOD>;

int N;
vector<vector<int>> G;
vector<bool> check;
pair<mint,mint> dfs(int v) {
    check[v] = true;
    mint W = 1;
    mint B = 1;
    for (auto nv : G[v]) {
        if (check[nv]) continue;
        mint w,b;
        tie(w,b) = dfs(nv);
        W *= (w+b);
        B *= w;
    }
    return make_pair(W,B);
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N;
    G.resize(N);
    rep(i,N-1) {
        int x,y; cin >> x >> y;
        x--; y--;
        G[x].emplace_back(y);
        G[y].emplace_back(x);
    }

    check.resize(N);
    mint answ,ansb;
    tie(answ,ansb) = dfs(0);

    cout << (answ+ansb).a << endl;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
const int MOD = 1000000007;
typedef long long ll;
const int MAX = 10;
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;
   }
}
// 二項係数計算
long long COM(int n, int k){
   if (n < k) return 0;
   if (n < 0 || k < 0) return 0;
   return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int num_of_amida(int n){//n本の間でのあみだの数
    int a=0;
    if(n<0)return 0;
    for(int i=0;n-i>=i;i++){
        a+=COM(n-i,i);
    }
    return a;
}
ll DP[101][9];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    COMinit();
    int H,W,K;
    cin>>H>>W>>K;
    DP[0][1]=1;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            if(j==1){
                DP[i][1]+=num_of_amida(W-1)*DP[i-1][1]%MOD;
                DP[i][1]+=num_of_amida(W-2)*DP[i-1][2]%MOD;
            }
            else if(j==W){
                DP[i][W]+=num_of_amida(W-1)*DP[i-1][W]%MOD;
                DP[i][W]+=num_of_amida(W-2)*DP[i-1][W-1]%MOD;
            }
            else{
                DP[i][j]+=(num_of_amida(j-1)*num_of_amida(W-j))*DP[i-1][j]%MOD;
                DP[i][j]+=(num_of_amida(j-2)*num_of_amida(W-j))*DP[i-1][j-1]%MOD;
                DP[i][j]+=(num_of_amida(j-1)*num_of_amida(W-j-1))*DP[i-1][j+1]%MOD;
            }
            DP[i][j]%=MOD;
        }
    }
    cout<<DP[H][K]<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,m,i,sum=2,ans=0,z=1,arr[1000];


    scanf("%d%d",&n,&m);

    for(i=1; i<=n; i++)
    {
        scanf("%d",&arr[i]);
    }

    for(i=1; i<=n; i++)
    {
        ans=((sum-1))+(arr[i]-1);
        sum=sum+arr[i];
        if(ans<=m)
        {
            z++;
            ans=0;
        }
        else
        {
            ans=0;
        }
    }

    printf("%d\n",z);

    return 0;
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

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

ll N, A;
ll dp[55][55][2505]{};

int main(int argc, char **argv)
{
	cin >> N >> A;
	vector<ll> X(N);
	REP(i, N) cin >> X[i];

	***dp = 1;
	
	REP(n, N)
	{
		REP(k, N+1)
		{
			REP(m, 2505)
			{
				dp[n+1][k][m] += dp[n][k][m];
				if (m-X[n] >= 0)dp[n+1][k+1][m] += dp[n][k][m-X[n]];
			}
		}
	}

	ll res{0};
	for (ll k = 1; k <= N; ++k)
		res += dp[N][k][A*k];

	std::cout << res << std::endl;
}


Measured memory_bytes: 54400
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args) throws IOException {
		try(BufferedReader kb= new BufferedReader(new InputStreamReader(System.in))){
			StringTokenizer st = new StringTokenizer(kb.readLine());
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			if(a<=0 && b>=0){
				System.out.println("Zero");
			}
			else if (a==b){
				System.out.println("Positive");
			}
			else if(a>0){
				System.out.println("Positive");
			}
			else if(((Math.abs(a)-Math.abs(b))%2)==0){
				System.out.println("Negative");
			}
			else{
				System.out.println("Positive");
			}
			
		}
	}
}

Measured memory_bytes: 23124
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)



def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

N,R=acinput()



if N>=10:
    K=R
else:

    K=R+(100*(10-N))

print(int(K))

Measured memory_bytes: 12508
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) emplace_back(x)
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef long long ll;
typedef vector<int> V;
typedef pair<int, int> pii;

const int N = 1e5;
int a[N];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    int ans = 1e9;
    for (int i = 1; i <= 100; i++) {
        int tmp = 0;
        for (int j = 1; j <= n; j++)
            tmp += (a[j] - i) * (a[j] - i);
        ans = min(ans, tmp);
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const double pi=3.14159265358979323846;
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n),b(n);
  rep(i,n){
    cin >> a[i] >> b[i];
  }
  int maxa=0,ans;
  rep(i,n){
    if(maxa<a[i]){
      maxa=a[i];
      ans=a[i]+b[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
int main(void){

    char str[3000];
    char *tok;
    int m,n;
    int i1,i2,i3,i4,i44;
    int gn,gm,sn,sm;
    int fin=0;
    int nn,nm;
    int a[3][2];
    int b[4];
    int con[4][3];
    
    for(i1=0;i1<=2;i1++){
        fgets(str, sizeof(str), stdin);
        tok=strtok(str," ");
        a[i1][0]=strtol(tok,NULL,10);
        tok=strtok(NULL," ");
        a[i1][1]=strtol(tok,NULL,10);
    }
    
    for(i1=0;i1<=4;i1++){
        b[i1]=0;
        for(i2=0;i2<=3;i2++){
            con[i1][i2]=0;
        }
    }
    
    for(i1=0;i1<=2;i1++){
        for(i2=0;i2<=1;i2++){
            b[a[i1][i2]-1]+=1;
        }
    }
    
    for(i1=0;i1<=2;i1++){
        if(a[i1][0]*a[i1][1] == a[(i1+1)%3][0]*a[(i1+1)%3][1]){
            fin=1;
        }
    }
    
    if(b[0]*b[1]*b[2]*b[3]==4 && fin!=1){
        printf("YES");
    }else{
        printf("NO");
    }

    
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>

using ll = long long;

using namespace std;

long long x = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= x;
	if (n % 2 == 1)t *= a;
	return t % x;
}

const int INF = 1001001001;

int main() {
	int n;
	cin >> n;
	set<ll>a;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		a.insert(x);
	}
	if (a.size() == n)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 9600
a,b,m=map(int,input().split())
price_A=list(map(int,input().split()))
price_B=list(map(int,input().split()))
coupon=[]
for _ in range(m):
  coupon.append(list(map(int,input().split())))
ans=min(price_A)+min(price_B)
for i in range(m):
  deprice=price_A[coupon[i][0]-1]+price_B[coupon[i][1]-1]-coupon[i][2]
  if deprice < ans:
    ans = deprice
print(ans)

Measured memory_bytes: 38564
n = int(input())
s = input()
M = 10**9 + 7

def mod(v):
    if v >= M:
        return v % M
    return v


dp = [[1] * n + [0] for _ in range(2)]
s = [v == "<" for v in s]
for i in reversed(range(n - 1)):
    for j in range(n - 1):
        dp[1][j + 1] = dp[1][j + 1] + dp[1][j]
        dp[0][j] = dp[1][j]
    dp[0][-2] = dp[1][-2]

    for zk in range(n - i):
        cnt = 0

        if s[i]:
            cnt = dp[0][zk - 1]
        else:
            zj = n - i - zk - 1
            cnt = dp[0][zk + zj - 1] - dp[0][zk - 1]
        dp[1][zk] = mod(cnt)

print(sum(dp[1]) % M)


Measured memory_bytes: 123868
import numpy as np

D = int(input())
c = np.array( list(map(int, input().split())) )
#
s = [[] for i in range(D)]
for i in range(D):
  s[i] = np.array( list(map(int, input().split())) )
#
v = 0
cc =  np.array( [0]*26 )
last = np.array( [-1]*26 )
for d in range(D):
  cc += c
  av = s[d] - sum( cc ) + cc
  av2 = av + cc*min((D-d-1),6)
  m = max(av2)
  for t in range(26):
    if av2[t] == m:
      cc[t] = 0
      v += av[t]
      print(t+1)
      break
#
#print( v )


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

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  bool water[f + 1], sugar[f + 1];
  fill(water, water + f + 1, false);
  fill(sugar, sugar + f + 1, false);
  for (int i = 0; i <= f; i++) {
    for (int j = 0; j <= f; j++) {
      if (c * i + d * j > f) continue;
      sugar[c * i + d * j] = true;
    }
  }
  for (int i = 0; i <= f; i++) {
    for (int j = 0; j <= f; j++) {
      if (100 * a * i + 100 * b * j > f) continue;
      water[100 * a * i + 100 * b * j] = true;
    }
  }
  double nodo = -1.0;
  int x = 0, y = 0;
  for (int i = 1; i <= f; i++) {
    for (int j = 0; j <= f; j++) {
      if (!water[i]) continue;
      if (!sugar[j]) continue;
      if (i + j > f) continue;
      if (100.0 * j / (i + j) > 100.0 * e / (100 + e)) continue;
      if (100.0 * j / (i + j) > nodo) {
        x = i;
        y = j;
        nodo = 100.0 * j / (i + j);
      }
    }
  }
  cout << x + y << " " << y << endl;
  return 0;
}


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

int n;
map<long long,int> mp;

main()
{
	long long ans=0;
	long long sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		long long a;
		scanf("%lld",&a);
		sum+=a;
		ans+=mp[sum];
		mp[sum]++;
		if(sum==0)
		{
			ans++;
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 12800
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int n, m;
  cin >> n >> m;
  int ans = (n * (n - 1) )/ 2 + (m * (m - 1) )/ 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n,m=map(int,input().split())
node=defaultdict(int)
ans='YES'
for i in range(m):
    a,b=map(int,input().split())
    node[a]+=1
    node[b]+=1
for i in node.items():
    if i[1]%2!=0:
        ans='NO'
print(ans)

Measured memory_bytes: 53080
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1001001001;

int N, W;
int dp[110][10100];

int main(){
  cin >> N >> W;
  vector<int> v(N+1), w(N+1);
  REP(i, 1, N) cin >> v[i] >> w[i];

  REP(i, 1, N){
    REP(j, 0, W){
      if(j >= w[i]) chmax(dp[i][j], dp[i-1][j-w[i]] + v[i]);
      chmax(dp[i][j], dp[i-1][j]);
    }
  }

  cout << dp[N][W] << endl;

  return 0;

}




Measured memory_bytes: 7040
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>

class Graph{
private:





 class Node{
 private:
  unsigned long node_id_;
  long depth_;

  std::vector<unsigned long> adjnodes_;
 public:

  Node(const unsigned long node_id,const std::vector<unsigned long> &adjnodes)
      : node_id_(node_id),
        depth_(-1),
        adjnodes_(adjnodes){
   if(node_id_ == 1) depth_ = 0;
  };

  bool isDepth(){
   if(depth_ == -1) return true;

   return false;
  };

  void CheckNode(std::queue<unsigned long>& queue_nextnode,const std::vector<Node*>& node){
   for(unsigned long adjnode_i = 0, adjnode_max = adjnodes_.size(); adjnode_i < adjnode_max; ++adjnode_i){
    unsigned long nextadjnode = adjnodes_[adjnode_i]-1;
    if(node[nextadjnode]->isDepth()){
     node[nextadjnode]->depth_ = depth_ + 1;
     queue_nextnode.push(nextadjnode);
    }
   }
  };

  void display(){
   std::cout << node_id_ << " ";
   std::cout << depth_ << std::endl;
  };
 protected:
 };





 std::vector<Node*> node_;

public:
 Graph(unsigned long node_max) : node_(std::vector<Node*>(node_max, 0)){};
 void CreateNode(const unsigned long node_i,const unsigned long node_id,const std::vector<unsigned long>& adjnodes){
  node_[node_i] = new Node(node_id, adjnodes);
 };

 void BreadthFirstSearch(){
  if(node_.empty()) return ;

  std::queue<unsigned long> queue_nextnode;
  queue_nextnode.push(0);
  while(!queue_nextnode.empty()){
   unsigned long nextnode = queue_nextnode.front();
   queue_nextnode.pop();
   node_[nextnode]->CheckNode(queue_nextnode, node_);

  }

 };

 void display(){
  for(unsigned long node_i = 0, node_max = node_.size(); node_i < node_max; ++node_i){
   node_[node_i]->display();
  }
 };
protected:

};


int main(){

 unsigned long node_max = 0; std::cin >> node_max;

 /*
  *  ノード数分の記憶領域を確保する。
  */
 Graph graph(node_max);

 /*
  *入力はテキスト。
  *入力は一行目に    [ノード数]
  *      二行目以降  [頂点id 接続ノード数 接続ノード1 接続ノード2 ...]
  */
 for(unsigned long node_i = 0; node_i < node_max; ++node_i){
  unsigned long node_id = 0; std::cin >> node_id;
  unsigned long adjnode_max = 0; std::cin >> adjnode_max;
  std::vector<unsigned long> adjnodes(std::vector<unsigned long>(adjnode_max, 0));
  for(unsigned long adjnode_i = 0; adjnode_i < adjnode_max; ++adjnode_i){
   std::cin >> adjnodes[adjnode_i];
  }

  graph.CreateNode(node_i, node_id, adjnodes);
 }

 graph.BreadthFirstSearch();
 graph.display();

 return 0;
};

Measured memory_bytes: 1220
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n; cin >> n;
  vector<ll> a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];
  sort(a); sort(c);

  ll ans = 0;
  rep(i, n) {
    ll ai = distance(a.begin(), lower_bound(all(a), b[i]));
    ll ci = distance(c.begin(), upper_bound(all(c), b[i]));
    ans += ai * (n-ci);
  }
  outl(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 2808
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		String s = sc.next();
		sc.close();
		sc = null;
		System.out.println(s.substring(0, k-1) + s.substring(k-1, k).toLowerCase() + s.substring(k));
	}
}


Measured memory_bytes: 22100
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912 2の29乗
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll N,P;
int cnt[1000001];
int main(){
    cin >> N >> P;
    if(N == 1){
        cout << P << endl;
        return 0;
    }
    if(P == 1){
        cout << 1 << endl;
        return 0;
    }
    ll x = sqrt(P);
    ll ans = 1;
    for(int i = 2; i <= x+1; i++){
        while(P%i == 0){
            cnt[i]++;
            P /= i;
        }
        ans *= pow(i,cnt[i]/N);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
from collections import Counter,deque
x,y=Counter(a),Counter(b)
for i in range(1,n+1):
    if x[i]+y[i]>n:
        print("No")
        exit()
ans=b[::-1]
change=deque()
num=-1
now=deque()
for i in range(n):
    if a[i]==ans[i]:
        change.append(i)
        num=ans[i]
    else:
        now.append(i)
if change==[]:
    print("Yes")
    print(" ".join(map(str,ans)))
    exit()
while len(change):
    q=now.popleft()
    p=change.popleft()
    if a[q]!=num and ans[q]!=num:
        ans[q],ans[p]=ans[p],ans[q]
    else:
        change.appendleft(p)

print("Yes")
print(" ".join(map(str,ans)))

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

typedef long long int   ll;
#define int             ll
#define PI              3.1415926535897932384626433832795

#define pb              push_back
#define rep0            for(int i=0;i<n;i++)
#define rep1            for(int i=1;i<=n;i++)
#define inputar0(ar)    for(int i=0;i<n;i++)cin>>ar[i]
#define inputar1(ar)    for(int i=1;i<=n;i++)cin>>ar[i]

#define hell            freopen("input.txt","r", stdin);freopen("output.txt", "w", stdout);freopen("error.txt", "w",stderr);
#define fastasF_boi()   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
//#define cerr            if(false)cerr

int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
int binpow(int a,int b){int res=1;while(b>0){if(b%2){res=(res*a);b--;}a=(a*a);b/=2;}return res;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}
int mulmod(int a,int b){return ((a%mod)*(b%mod))%mod;}
int addmod(int a,int b){return (((a%mod)+(b%mod))+mod)%mod;}

void solve(){
    string s,t;cin>>s>>t;
    int ans=t.size();
    for(int i=0;i<=(s.size()-t.size());i++){
        string x=s.substr(i,t.size());
//        cout<<x<<endl;
        int cnt=t.size();
        for(int j=0;j<t.size();j++){
            if(x[j]==t[j]){
                cnt--;
            }
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}

signed main(){
//    hell;

    fastasF_boi();
    int t=1;
//    cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
}



Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;

class Dice {
    int s1, s2, s3, s4, s5, s6;

public:
    Dice(int s1, int s2, int s3, int s4, int s5, int s6);

    void print();

    void relocate(int top, int front);

    void roll(char F);

    void make_top(int top);

    void make_front(int front);

    void print(int side);
};

void Dice::make_top(int top) {
    if (s1 == top) return;
    if (s2 == top) {
        roll('N');
        return;
    }
    if (s3 == top) {
        roll('W');
        return;
    }
    if (s4 == top) {
        roll('E');
        return;
    }
    if (s5 == top) {
        roll('S');
        return;
    } else {
        roll('N');
        make_top(top);
        return;
    }
}

void Dice::make_front(int front) {
    if (front == s2) return;
    else roll('R');
    make_front(front);
    return;
}

void Dice::relocate(int top, int front) {
    vector<int> S{s1, s2, s3, s4, s5, s6};
    int top_idx = distance(S.begin(), find(S.begin(), S.end(), top));
    int front_idx = distance(S.begin(), find(S.begin(), S.end(), front));

    int tmp_s1 = s1;

}

void Dice::roll(char F) {
    int tmp = s1;
    if (F == 'N') {
        s1 = s2;
        s2 = s6;
        s6 = s5;
        s5 = tmp;
    }
    if (F == 'W') {
        s1 = s3;
        s3 = s6;
        s6 = s4;
        s4 = tmp;
    }
    if (F == 'S') {
        s1 = s5;
        s5 = s6;
        s6 = s2;
        s2 = tmp;
    }
    if (F == 'E') {
        s1 = s4;
        s4 = s6;
        s6 = s3;
        s3 = tmp;
    }
    if (F == 'R') {
        tmp = s2;
        s2 = s3;
        s3 = s5;
        s5 = s4;
        s4 = tmp;
    }
}

void Dice::print() {
    cout << s1 << endl;
}

void Dice::print(int side) {
    vector<int> S{s1, s2, s3, s4, s5, s6};
    cout << S[side-1] << endl;
}


Dice::Dice(int _s1, int _s2, int _s3, int _s4, int _s5, int _s6) {
    s1 = _s1;
    s2 = _s2;
    s3 = _s3;
    s4 = _s4;
    s5 = _s5;
    s6 = _s6;
}

int main() {
    int s, S[6];
    for (int i = 0; i < 6; i++) {
        cin >> S[i];
    }
    Dice dice = Dice(S[0], S[1], S[2], S[3], S[4], S[5]);

//    string str;
//    cin >> str;
//    for (int i = 0; i < str.length(); i++) {
//        dice.roll(str[i]);
//    }
//    dice.print();

    int n, a, b;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        dice.make_top(a);
        dice.make_front(b);
        dice.print(3);
    }
}


Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int n,k,Mod;
int f[2][110][110][160];
int g[151][151];
void add(int& x,int y)
{
	x+=y;
	if(x>=Mod)x-=Mod;
	return ;
}
int main()
{
	scanf("%d %d %d",&n,&k,&Mod);
	if(k%2==0){
		k/=2;
		g[0][0]=1;
		for(int i=1;i<=n;i++)
		{
			for(int j=0;j<=k;j++)
			{
				add(g[i][j+1],g[i-1][j]);
				add(g[i][0],g[i-1][j]);
			}
		}
		int ans1=0,ans2=0;
		for(int i=0;i<=k;i++)
			add(ans1,g[n/2][i]);
		for(int i=0;i<=k;i++)
			add(ans2,g[(n+1)/2][i]);
		printf("%d\n",(long long)ans1*ans2%Mod);
		return 0;
	}
	f[0][0][0][0]=1;
	for(int i=1;i<=n;i++)
	{
		int now=i&1;
		for(int x=0;x*2<=i+1;x++)
			for(int y=0;y*2<=i;y++)
				for(int k=0;k<=n;k++)
					f[now][x][y][k]=0;
		for(int x=0;x*2<=i;x++)
			for(int y=0;y*2<i;y++)
			{
				for(int j=i+1;j<=n;j++)
				{
					if(now){
						add(f[now][0][y][(j&1)?0:j],f[now^1][x][y][j]);
						add(f[now][x+1][y][j],f[now^1][x][y][j]);
					}
					else{
						add(f[now][x][0][(j&1)?j:0],f[now^1][x][y][j]);
						add(f[now][x][y+1][j],f[now^1][x][y][j]);
					}
				}
				//0&i->0
				if(now){
					add(f[now][0][y][0],f[now^1][x][y][i]);
					add(f[now][0][y][0],f[now^1][x][y][0]);
				}
				else{
					add(f[now][x][0][0],f[now^1][x][y][i]);
					add(f[now][x][0][0],f[now^1][x][y][0]);
				}
				//0->?
				if(now){
					if(y*2-1>=k&&i-x*2+k<=n)
						add(f[now][x+1][y][i-x*2+k],f[now^1][x][y][0]);
					else add(f[now][x+1][y][0],f[now^1][x][y][0]);
				}
				else{
					if(x*2-1>=k&&i-y*2+k<=n)
						add(f[now][x][y+1][i-y*2+k],f[now^1][x][y][0]);
					else add(f[now][x][y+1][0],f[now^1][x][y][0]);
				}
			}
	}
	int ans=0;
	for(int x=0;x*2<=n+1;x++)
		for(int y=0;y*2<=n;y++)
			for(int j=0;j<=n;j++)
				add(ans,f[n&1][x][y][j]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 13952
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int t, x;
	cin >> t >> x;
	cout << (double)t/x << endl;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  SCIN(s);
  cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;

  return 0;
}



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

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

const ll MOD = 1e9+7;

typedef vector<vector<ll>> matrix;
matrix operator * (const matrix& M1, const matrix& M2)
{
    int a=M1.size(), b=M2.size(), c=M2[0].size();
    matrix M3=matrix(a, vector<ll>(c));
    int i, j, k;

    for(i=0; i<a; i++)
    {
        for(j=0; j<c; j++)
        {
            for(k=0; k<b; k++)
            {
                M3[i][j]+=M1[i][k]*M2[k][j];
                M3[i][j]%=MOD;
            }
        }
    }
    return M3;
}

ll n, k, cnt;
matrix adj, e, ans;

matrix mypow(const matrix& x, ll y)
{
    if(y==0) return e;
    if(y%2) return mypow(x, y-1)*x;
    matrix t=mypow(x, y/2);
    return t*t;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);
    int i, j;

    scanf("%lld %lld", &n, &k);
    adj=e=matrix(n, vector<ll>(n));
    for(i=0; i<n; i++) for(j=0; j<n; j++) scanf("%d", &adj[i][j]);
    for(i=0; i<n; i++) e[i][i]=1;

    ans=mypow(adj, k);

    for(i=0; i<n; i++) for(j=0; j<n; j++) cnt+=ans[i][j], cnt%=MOD;
    printf("%lld", cnt);
    return 0;
}


Measured memory_bytes: 384
program main
  implicit none
  integer(16) i, add
  character(200000) N, M
  read(*, *) N
  M = trim(N)
  add = 0
  do i = 1,len(M)
    if (M(i:i) == '1') then
      add = add + 1
    elseif (M(i:i) == '2') then
      add = add + 2
    elseif (M(i:i) == '3') then
      add = add + 3
    elseif (M(i:i) == '4') then
      add = add + 4
    elseif (M(i:i) == '5') then
      add = add + 5
    elseif (M(i:i) == '6') then
      add = add + 6
    elseif (M(i:i) == '7') then
      add = add + 7
    elseif (M(i:i) == '8') then
      add = add + 8
    elseif (M(i:i) == '9') then
      add = add + 9
    end if
  end do
  if (mod(add,9) == 0) then
    write(*, *) 'Yes'
  else
    write(*, *) 'No'
  end if
  !read(*, *) (L(i), i = 1,N)

  write(*, *)
end program main


Measured memory_bytes: 3284
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;


int main() {

    vector<int> x(5);
    REP(i, 5) {
        cin >> x[i];
    }
    REP(i, 5) {
        if (x[i] == 0) {
            cout << i + 1 << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3520
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val line1  = inputs.head.split(" ").map(_.toInt)
  val aBooks = inputs(1).split(" ").map(_.toInt)
  val bBooks = inputs(2).split(" ").map(_.toInt)

  println(solve(line1(0), line1(1), line1(2), aBooks, bBooks))

  def solve(n: Int, m: Int, k: Int, aBooks: Array[Int], bBooks: Array[Int]): Int = {
    val a = scala.collection.mutable.ArrayBuffer(0L)
    val b = scala.collection.mutable.ArrayBuffer(0L)

    (0 until n).foreach { i =>
      a.append(a(i) + aBooks(i))
    }
    (0 until m).foreach { i =>
      b.append(b(i) + bBooks(i))
    }

    var ans = 0
    var j   = m

    (0 until n + 1).foreach { i =>
      if(a(i) > k) {
        return ans
      }

      while(b(j) > k - a(i)) {
        j = j - 1
      }

      ans = Math.max(ans, i + j)
    }

    return ans
  }
}

Measured memory_bytes: 90796
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> v(m);
  vector<int> u(m);
  for (int i = 0; i < m; ++i)
  {
    cin >> v.at(i) >> u.at(i);
  }
  int count=0;
  for(int j=0;j<m;j++){
	if(n!=1){
    if(v.at(j)==1){
      if(u.at(j)==0){
        count++;
      }
    }
}
    for(int k=0;k<m;k++){
      if(v.at(j)==v.at(k)){
        if(u.at(j)!=u.at(k)){
          count++;
        }

      }
    }

  }
  
  vector<int> h(n);

  if(count!=0){
      cout << -1 << endl;
    }
    else{
      for(int j=1;j<n+1;j++){
      for(int i=0;i<m;i++){
       if(v.at(i)==j){
         h.at(j-1)=u.at(i);
      }
      }
    
   

  }
  if(n!=1){
  if(h.at(0)==0){
  	h.at(0)=1;
  }
  }
   for (int i = 0; i < n; ++i)
      {
      	cout << h.at(i);
      }
}
    }
    



Measured memory_bytes: 256
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 4e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}

signed main()
{
    Start();
    string s;
    cin >> s;
    if (s.size() != 6)
        return cout << "No", 0;
    if (s[2] != s[3] || s[4] != s[5])
        return cout << "No", 0;
    cout << "Yes";
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

ll dp[51][31];
vector<int> v[31];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n,n){
        for(int i=0;i<n;i++){
            for(int j=0;j<=30;j++){
                dp[i][j]=(1LL<<i);
            }
        }
        for(int i=0;i<=30;i++){
            v[i].clear();
        }
        for(int i=0;i<n;i++){
            int t; cin >> t;
            while(t--){
                int x; cin >> x;
                v[x].push_back(i);
            }
        }
        int res=35;
        ll ok=(1LL<<n)-1;
        for(int i=1;i<=30;i++){
            for(int j=0;j<v[i].size();j++){
                for(int k=0;k<v[i].size();k++){
                    dp[v[i][j]][i]|=dp[v[i][k]][i-1];
                }
            }
            for(int j=0;j<n;j++){
                dp[j][i]|=dp[j][i-1];
                if(dp[j][i]==ok){
                    res=min(res,i);
                }
            }
        }
        if(res==35)res=-1;
        printf("%d\n",res);
    }
}



Measured memory_bytes: 3180
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

int main(int argc, char *argv[]){
    int A,B;
    std::cin >> A >> B;
    if(A>9 || B>9){
        std::cout << -1 << std::endl;
        return 0;
    }
    std::cout << A*B << std::endl;
    return 0;
}


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


void solve(long long A, long long B){
    if(A == 1) A=14;
    if(B == 1) B=14;
    if(A > B) cout << "Alice" << endl;
    if(B > A) cout << "Bob" << endl;
    if(A==B) cout << "Draw" << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int k,n,ans;
int a[2000005];
signed main(){
	scanf("%lld",&k);
	scanf("%lld",&n);
	for (register int i=1; i<=n ; ++i) scanf("%lld",&a[i]);
	for (register int i=1; i<n; ++i) ans=max(ans,a[i+1]-a[i]);
	ans=max(ans,k-a[n]+a[1]);
	printf("%lld\n",k-ans);
return 0;	
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
const int maxn=1e5+7;
struct node{
	int index;
	int v;
}a[maxn];
bool cmp(const node &x,const node &y)
{
	if(x.v!=y.v)
	return x.v<y.v;
	return 0;
}
int main()
{
	int n,cnt=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i].v),a[i].index=i;
	std::sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
	  if((a[i].index&1)!=(i&1))
	    cnt++;
	printf("%d",cnt>>1);
	return 0;
}

Measured memory_bytes: 1024