akhauriyash/Code-Regression huggingface dataset:
function Main(input) {
  input = input.split("\n");
  tmp = input[1].split(" ");

  var N = parseInt(input[0], 10);
  var A = tmp.map(x => parseInt(x, 10))

  // var b = parseInt(tmp[0], 10);
  // var c = parseInt(tmp[1], 10);
  // var s = input[2];

  // Convert String to Integer
  // var a = ~~input[0];
  // var b = ~~input[1];


  var Sunuke = function(N, A){
    this.A = A;
    this.N = N;
  };

  Sunuke.prototype = {
    splitNumber : function(){
      var count = 0;
      var flag = true;
      var arr = this.A;
      while(flag){
        for(var item of arr){
          if(item%2 != 0 || item == 0){
            flag = false;
            break;
          }
        }
        if(flag == false) return count;
        arr = arr.map(x => x/2);
        count++;
      }
    }
  }
  var sunuke = new Sunuke(N, A);
  console.log(sunuke.splitNumber());

  // console.log('%d %d',N,Q);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define ss second
#define ff first
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(s) (int)s.size()
#define all(a) a.begin(),a.end()
#define vii vector<pii>
typedef long double ld;

int main()
{
  IOS;
  ll a, b, c;
  cin >> a >> b >> c;
  if(a + b >= c)
  	cout << b + c << '\n';
  else
  	cout << a + b + b + 1 << '\n';
  return 0;
}

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

int main()
{
    int N, s;

    cin >> N;

    s = N / 1.08;

    if ((int)(s * 1.08) == N)
    {
        cout << s << endl;
    }

    else if ((int)((s + 1) * 1.08) == N)
    {
        cout << s + 1 << endl;
    }

    else
    {
        cout << ":(" << endl;
    }
}


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

using ll=long long;
int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;i++) cin>>a[i]>>b[i];
    vector<int> idx(n);
    iota(idx.begin(),idx.end(),0);
    sort(idx.begin(),idx.end(),[&](int lhs,int rhs){return a[lhs]<a[rhs];});
    ll res=0;
    for(int i=0;i<n;i++){
        int id=idx[i];
        ll c=min(m,b[id]);
        
        res+=c*a[id];
        m-=c;
    }
    cout<<res<<endl;
    return 0;
}

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

using namespace std;

int main()
{
	int x,y;
	cin>>x>>y;
	if(y<2*x || y>4*x)
	{
		cout<<"No"<<endl;
	}
	else
	{
		if(y%2!=0)
		{
			cout<<"No"<<endl;
		}
		else
		{
			cout<<"Yes"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std; 
int main(){
    ios::sync_with_stdio(false);
    int iLeft1, iLeft2, iRight1, iRight2; 
    cin >> iLeft1 >> iLeft2 >> iRight1 >> iRight2; 
    if (iLeft1 + iLeft2 > iRight1 + iRight2)
        cout << "Left\n"; 
    else if (iLeft1 + iLeft2 == iRight1 + iRight2)
        cout << "Balanced\n";
    else 
        cout << "Right\n"; 
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < (n); i++)
using pint = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

// auto mod int
const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint (ll x = 0) : x ((x % mod + mod) % mod) {}
    mint operator-() const { return mint (-x); }
    mint &operator+= (const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator-= (const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator*= (const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+ (const mint a) const { return mint (*this) += a; }
    mint operator- (const mint a) const { return mint (*this) -= a; }
    mint operator* (const mint a) const { return mint (*this) *= a; }
    mint pow (ll t) const {
        if (!t) return 1;
        mint a = pow (t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const { return pow (mod - 2); }
    mint &operator/= (const mint a) { return *this *= a.inv(); }
    mint operator/ (const mint a) const { return mint (*this) /= a; }
};
istream &operator>> (istream &is, const mint &a) { return is >> a.x; }
ostream &operator<< (ostream &os, const mint &a) { return os << a.x; }

// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination (int n) : fact (n + 1), ifact (n + 1) {
        assert (n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    mint operator() (int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} c (200005);

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    mint ans = 0;
    rep (i, k + 1) {
        ll res = 1;
        ll now = n - i - 1;
        ll m_1 = m - 1;
        while (now) {
            if (now & 1) res = res * m_1 % mod;
            m_1 = m_1 * m_1 % mod;
            now >>= 1;
        }
        ans += c (n - 1, i) * m * res;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 6248
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);  
	int n;
  ll ans = 0;
  cin >> n;
  vector<ll> monster(n+1), hero(n);
  for(int i = 0; i <= n; i++){
		cin >> monster[i];  	
  }
  for(int i = 0; i < n; i++){
  	cin >> hero[i];
  	ans += min(hero[i], monster[i] + monster[i+1]);
  	monster[i+1] -= min(monster[i+1], max(hero[i] - monster[i], (ll)0)); 
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>

using namespace std;

vector<int> a;

int main() {

	int n = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int tmp = 0;
		cin >> tmp;
		a.push_back(tmp);
	}

	int ans = 0;

	for (int i = 0; i < n; ++i) {
		ans = ans + (a.at(i) - 1);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    auto I = iota(N).map!"a+1"().array;
    zip(A, I).sort();
    I.map!text().join(' ').writeln();
}


Measured memory_bytes: 6088
#include <iostream>
#include <cmath>
#include <iterator>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int f1, f2, f3, f4, f5, f6;
  cin >> f1 >> f2 >> f3 >> f4 >> f5 >> f6;
  cin.get();

  char move;
  while (cin.get(move), move != '\n') {
    if (move == 'N') {
      auto tmp = f5;
      f5 = f1;
      f1 = f2;
      f2 = f6;
      f6 = tmp;
    } else if (move == 'S') {
      auto tmp = f6;
      f6 = f2;
      f2 = f1;
      f1 = f5;
      f5 = tmp;
    } else if (move == 'E') {
      auto tmp = f3;
      f3 = f1;
      f1 = f4;
      f4 = f6;
      f6 = tmp;
    } else { // move == 'W'
      auto tmp = f4;
      f4 = f1;
      f1 = f3;
      f3 = f6;
      f6 = tmp;
    }
  }
  cout << f1 << endl;  // output top face
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a);i <= (b); i++)
#define ROF(i, a, b) for(int i = (a);i >= (b); i--)
double L, ans;
int main(){
    cin>>L;
    ans = L / 3;
    ans = ans * ans * ans;
    printf("%.6lf\n", ans);
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int A, B;
	cin >> A >> B;

	cout << (A + 49) / 50 * 2 + (B + 49) / 50 * 2 << " 100\n";

	string w(100, '.'), b(100, '#');
	for (int i = 0; i < 2 * (B - 1); i++) {
		
		if (i % 2) cout << '#';
		else cout << '.';
		if (i % 100 == 99) cout << "\n" << w << "\n";

	}
	for (int i = 0; i < 100 - 2 * (B - 1) % 100; i++) {
		cout << '.';
	}

	cout << "\n" << w << "\n" << b << "\n";

	for (int i = 0; i < 2 * (A - 1); i++) {

		if (i % 2) cout << '.';
		else cout << '#';
		if (i % 100 == 99) cout << "\n" << b << "\n";

	}
	for (int i = 0; i < 100 - 2 * (A - 1) % 100; i++) {
		cout << '#';
	}

	cout << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <cmath>
#include <algorithm>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){

int n;
cin >> n;

int d[1010] = {0};

for(int i = 2; i <= n; i++){
int num = i;
 for(int j = 2; num != 1; j++){
  while(num % j == 0){
   d[j]++;
   num /= j;
  }
 }
}

ll ans = 1;

for(int i = 0; i <= n; i++){
ans *= (d[i] + 1);
ans %= MOD;
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
import itertools
import sys

def main():
    n = []
    for i in range(5):
        n.append(int(input()))
    k = int(input())
    for c in itertools.combinations(n, 2):
        if abs(c[0] - c[1]) > k:
            print(':(')
            sys.exit()
    else:
        print('Yay!')

if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int n,ans,sum;  
int a[100005],cishu[100005];  
void f(){
    for(int i=1;i<=sum;i++){
    	if(cishu[i]>1){
    		ans+=cishu[i]-1; 
		}else{
			continue;
		}
	}
    if(ans%2==1){
    	ans+=1;
	}  
    cout<<n-ans<<endl;  
    return ;  
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cishu[a[i]]++;
        if(a[i]>=sum){
        	sum=a[i];
		}
    }
    f();
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n,sum=0;
    cin>>n;
    int a[n+5]={0};
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    cout<<sum-n<<endl;
    return 0;
}



Measured memory_bytes: 3600
from collections import deque


def bfs(q):
    ans = 0
    while q:
        i, j = q.popleft()
        for di, dj in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            ni, nj = i + di, j + dj
            if 0 <= ni < H and 0 <= nj < W and dist[ni][nj] < 0:
                q.append((ni, nj))
                dist[ni][nj] = dist[i][j] + 1
                ans = max(ans, dist[ni][nj])
    return ans


H, W = map(int, input().split())
field = [input() for _ in range(H)]
dist = [[-1] * W for _ in range(H)]
q = deque()
for i in range(H):
    for j in range(W):
        if field[i][j] == "#":
            dist[i][j] = 0
            q.append((i, j))
print(bfs(q))


Measured memory_bytes: 115872
import java.util.Scanner;

public class Main {
	public static int insertionSort(int[] A, int n, int g) {
		int v;
		int cnt = 0;
		for (int i = g; i < n; i++) {
			v = A[i];
			int j = i - g;
			while (j >= 0 && A[j] > v) {
				A[j + g] = A[j];
				j = j - g;
				cnt++;
			}
			A[j + g] = v;

		}
		return cnt;
	}

	public static int shellSort(int[] A, int n) {
		int cnt = 0;
		int[] G = new int[15];
        int m = 0;
        
        for(int i = 1; i <= n; i = i*3 + 1){
            G[m] = i; 
            m++;
        }
		System.out.println(m);
		for (int i = m-1; i >=0; i--) {
			if (i != 0) {
				System.out.print(G[i] + " ");
			} else {
				System.out.println(G[i]);
			}
		}
		for (int i = m-1; i >=0; i--) {
			cnt = cnt + insertionSort(A, n, G[i]);
		}
		return cnt;

	}

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] A = new int[n];
		for (int i = 0; i < n; i++) {
			A[i] = scanner.nextInt();
		}
		int cnt = shellSort(A, n);
		System.out.println(cnt);
		for (int i = 0; i < n; i++) {
			System.out.println(A[i]);
		}
		scanner.close();
	}
}


Measured memory_bytes: 300080
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    static int MAX = 1000001; 
    static int factor[]; 
  
    // function to generate all prime 
    // factors of numbers from 1 to 10^6 
    static void generatePrimeFactors() 
    { 
        factor[1] = 1; 
  
        // Initializes all the positions with 
        // their value. 
        for (int i = 2; i < MAX; i++) 
            factor[i] = i; 
  
        // Initializes all multiples of 2 with 2 
        for (int i = 4; i < MAX; i += 2) 
            factor[i] = 2; 
  
        // A modified version of Sieve of 
        // Eratosthenes to store the 
        // smallest prime factor that 
        // divides every number. 
        for (int i = 3; i * i < MAX; i++) { 
            // check if it has no prime factor. 
            if (factor[i] == i) { 
                // Initializes of j starting from i*i 
                for (int j = i * i; j < MAX; j += i) { 
                    // if it has no prime factor 
                    // before, then stores the 
                    // smallest prime divisor 
                    if (factor[j] == j) 
                        factor[j] = i; 
                } 
            } 
        } 
    } 
  
    // function to calculate number of factors 
    static int calculateNoOFactors(int n) 
    { 
        if (n == 1) 
            return 1; 
  
        int ans = 1; 
  
        // stores the smallest prime number 
        // that divides n 
        int dup = factor[n]; 
  
        // stores the count of number of times 
        // a prime number divides n. 
        int c = 1; 
  
        // reduces to the next number after prime 
        // factorization of n 
        int j = n / factor[n]; 
  
        // false when prime factorization is done 
        while (j != 1) { 
            // if the same prime number is dividing n, 
            // then we increase the count 
            if (factor[j] == dup) 
                c += 1; 
  
            /* if its a new prime factor that is  
               factorizing n, then we again set c=1  
               and change dup to the new prime factor, 
               and apply the formula explained  
               above. */
            else { 
                dup = factor[j]; 
                ans = ans * (c + 1); 
                c = 1; 
            } 
  
            // prime factorizes a number 
            j = j / factor[j]; 
        } 
  
        // for the last prime factor 
        ans = ans * (c + 1); 
  
        return ans; 
    } 
    
	public static void main (String[] args) throws java.lang.Exception
	{
	    factor = new int[MAX]; 
        factor[0] = 0; 
         generatePrimeFactors(); 
	    Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt();
	    long sum=0;
	    for(int i=1;i<n;i++)
	    sum+=(long)calculateNoOFactors(i);
	    System.out.println(sum);
	        
	}
}


Measured memory_bytes: 40124
def prepare(n, MOD):
 
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return factorials, invs


MOD = 10**9 + 7
f, inv = prepare(10**5+1, MOD)

n, k = map(int,input().split())
a = list(map(int,input().split()))

a.sort(reverse=True)

p = 0
m = 0
for i in range(n):
    if n - i >= k:
        cn = n - i - 1
        ck = k - 1
        combi = f[cn] * inv[ck] % MOD * inv[cn - ck] % MOD
        if a[i] >= 0:        
            p += (a[i] * combi) % MOD
        else:
            p += (a[i] * combi) % -MOD
        if p >= 0:
            p %= MOD
        else:
            p %= -MOD
    if i >= k - 1:
        cn = i
        ck = k - 1
        combi = f[cn] * inv[ck] % MOD * inv[cn - ck] % MOD
        if a[i] >= 0:        
            m += (a[i] * combi) % MOD
        else:
            m += (a[i] * combi) % -MOD
        if m >= 0:
            m %= MOD
        else:
            m %= -MOD
        
print((p - m) % MOD)


Measured memory_bytes: 28024
#include <algorithm>
#include <cstdio>

const int N=200005,M=1<<20,mo=924844033;
int a[M],b[M],rev[M],g[20][2],fst[N],fac[N],inv[N],n,tot=0,invn;
struct Edge{
	int to,nxt;
}e[N*2];

void addedge(int x,int y){
	e[++tot].to=y;e[tot].nxt=fst[x];fst[x]=tot;
}

int dfs(int x,int father){
	int sz=1;
	for (int i=fst[x];i;i=e[i].nxt)
		if (e[i].to!=father) sz+=dfs(e[i].to,x);
	if (x!=1) a[sz]++,a[n-sz]++;
	return sz;
}

void FFT(int *a,int n,int f){
	for (int i=0;i<n;i++)
		if (i<rev[i]) std::swap(a[i],a[rev[i]]);
	for (int i=1,t=0;i<n;i<<=1,t++){
		int wn=g[t][f];
		for (int j=0;j<n;j+=i<<1){
			int w=1;
			for (int k=0;k<i;k++,w=1ll*w*wn%mo){
				int x=a[j+k],y=1ll*w*a[j+k+i]%mo;
				a[j+k]=(x+y)%mo;
				a[j+k+i]=(x-y)%mo;
			}
		}
	}
	if (f)
		for (int i=0;i<n;i++) a[i]=1ll*a[i]*invn%mo;
}

int ksm(int x,int y){
	int i=1;
	for (;y;y>>=1,x=1ll*x*x%mo)
		if (y&1) i=1ll*i*x%mo;
	return i;
}

void mul(int m){
	int L=0,n=1;
	for (;n<m;n<<=1) L++;
	invn=ksm(n,mo-2);
	for (int i=1;i<n;i++)
		rev[i]=rev[i>>1]>>1^((i&1)<<(L-1));
	int val0=ksm(5,(mo-1)/n),val1=ksm(val0,mo-2);
	for (int i=L-1;i>=0;i--){
		g[i][0]=val0;val0=1ll*val0*val0%mo;
		g[i][1]=val1;val1=1ll*val1*val1%mo;
	}
	FFT(a,n,0);FFT(b,n,0);
	for (int i=0;i<n;i++) a[i]=1ll*a[i]*b[i]%mo;
	FFT(a,n,1);
}

int main(){
	scanf("%d\n",&n);
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d\n",&x,&y);
		addedge(x,y);
		addedge(y,x);
	}
	dfs(1,0);
	fac[0]=1;
	for (int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mo;
	inv[n]=ksm(fac[n],mo-2);
	for (int i=n;i;i--) inv[i-1]=1ll*inv[i]*i%mo;
	for (int i=0;i<=n;i++){
		a[i]=1ll*a[i]*fac[n-i]%mo;
		b[i]=inv[i];
	}
	mul(n*2);
	for (int i=1;i<=n;i++){
		int ans=(1ll*fac[n]*inv[n-i]%mo*n-a[n-i])%mo*inv[i]%mo;
		printf("%d\n",(ans+mo)%mo);
	}
}

Measured memory_bytes: 26368
from fractions import*
n,m,*a=map(int,open(0).read().split())
s=1
d=set()
for i in a:
  i//=2
  s*=i//gcd(s,i)
  t=0
  while i%2<1:
    t+=1
    i//=2
  d|={t}
print((0--(m//s)//2)*(len(d)<2))

Measured memory_bytes: 16084
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;


int main() {
	char a, b;
	cin >> a >> b;
	int a_ = a - '0', b_ = b - '0';
	string x, y;
	
	if (a_ < b_) {
		rep(i, b_) {
			x.push_back(a);
		}
	}

	else {
		rep(i, a_) {
			x.push_back(b);
		}
	}
	
	
	cout << x << endl;
	return 0;


}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cctype>
#include<string>

using namespace std;

int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  int i=1,sum=0;
  while (sum<c){
    sum+=a;
    if(i%7==0)sum+=b;
    //cout<<i<<sum<<endl;
    i++;
  }
  cout<<i-1<<endl;
  return 0;
}



Measured memory_bytes: 3116
#include<iostream>
template<class T>
class BST {
private:
    struct Node {
        T key;
        Node* left;
        Node* right;
        Node(T key) {
            this->key = key;
            this->left = nullptr;
            this->right = nullptr;
        }
        Node(T key, Node left, Node right) {
            this->key = key;
            this->left = left;
            this->right = right;
        }
    };
    Node* root = nullptr;
public:
    ~BST() {
        makeEmpty(root);
    }
    void insert(T key) {
        root = insertHelper(key, root);
    }
    bool find(T key) {
        return findHelper(key, root);
    }
    void inorder() {
        inorderHelper(root);
        std::cout << std::endl;
    }
    void preorder() {
        preorderHelper(root);
        std::cout << std::endl;
    }

private:
    Node* insertHelper(T key, Node* root) {
        if (root == nullptr) return new Node(key);
        if (key < root->key) root->left = insertHelper(key, root->left);
        else root->right = insertHelper(key, root->right);
        return root;
    }
    bool findHelper(T key, Node* root) {
        if(root == nullptr) return false;
        if(key == root->key) return true;
        if(key < root->key) return findHelper(key, root->left);
        else return findHelper(key, root->right);
    }
    void makeEmpty(Node* root) {
        if (root == nullptr) return;
        makeEmpty(root->left);
        makeEmpty(root->right);
        delete root;
    }
    void inorderHelper(Node* root) {
        if (root == nullptr) return;
        inorderHelper(root->left);
        std::cout << " " << root->key;
        inorderHelper(root->right);
    }
    void preorderHelper(Node* root) {
        if (root == nullptr) return;
        std::cout << " " << root->key;
        preorderHelper(root->left);
        preorderHelper(root->right);
    }
};
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m;
    cin >> m;
    BST<int> T;
    for (int i = 0; i < m; ++i) {
        int x;
        string s;
        cin >> s;
        if (s[0] == 'i') {
            cin >> x;
            T.insert(x);
        }else if (s[0] == 'f') {
            cin >> x;
            cout << (T.find(x)?"yes":"no") << endl;
        }
        else {
            T.inorder();
            T.preorder();
        }
    }
}

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

int main(void) {
	char c;
	int a, b, sum, ave, i;
	sum = ave = i = 0;
	while (cin >> a >> c >> b) {
		sum += a*b;
		ave += b;
		i++;
	}
	cout << sum << endl;
	cout << (int)(((double)ave / i) + 0.5) << endl;
}

Measured memory_bytes: 1160
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n)-1; i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1<<28;
const int MOD = 1000000007;

int main(){
  int p, q, r;  cin >> p >> q >> r;
  cout << min(p+q, min(q+r, r+p)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<stack>
#include<set>
#include<queue>
#include<vector>
#include<stdlib.h>
 
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cstdlib>
 
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn=1e6+6;
const int mod=1e9+7;
ll a[maxn],b[maxn];
 
int main()
{
    cin.tie(0);std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x,y;
        cin>>x>>y;
        a[i]=x+y;
        b[i]=x-y;
    }
    sort(a+1,a+1+n);
    sort(b+1,b+1+n);
    cout<<max(a[n]-a[1],b[n]-b[1])<<endl;
	system("pause");
    return 0;
}

Measured memory_bytes: 6828
#include<iostream>
#include<string>
using namespace std;
 int n,a[5000000],k; string s="",x,st;
int main()
{
    cin>>n;
    //cout<<n;
    for(int i=1;i<=n;i++)
    {
        //cout<<1;
        cin>>st>>a[s.length()];
        k+=a[s.length()];
        //cout<<a[s.length()]<<endl;
        s=s+st;
    }
    cin>>x;
    for (int i=0;i<=s.find(x)+x.length()-1;i++)
    {
        k-=a[i];
    }
    cout<<k;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int n, t;
    scanf("%d %d", &n, &t);
    int ans = 0;
    int prev = -1;
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        if (prev != -1) {
            ans += std::min(t, x - prev);
        }
        prev = x;
    }
    printf("%d\n", ans + t);
}

Measured memory_bytes: 256
n,m = map(int,input().split())
#v = list(map(int,input().split()))

#a = [0 for _ in range(n+1)]
ml = -1
mr = 10**6
for i in range(m):
  l,r = map(int,input().split())
  ml = max(ml,l)
  mr = min(mr,r)
if mr < ml :
  res = 0
else:
  res = mr-ml + 1

print(res)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int a[200005];
int h[200005];
int seg[800005];

void upd(int ver,int tl,int tr,int pos,int val)
{
   if(tl==tr)
      seg[ver]=val;
   else
   {
      int tm=(tl+tr)/2;
      if(tm>=pos)
         upd(2*ver,tl,tm,pos,val);
      else
         upd(2*ver+1,tm+1,tr,pos,val);
      seg[ver]=max(seg[2*ver],seg[2*ver+1]);
   }
}
int get_max(int ver,int tl,int tr,int l,int r)
{
   if(tl>tr||l>r||tr<l||r<tl)
      return 0;
   else if(tl==l&& tr==r)
      return seg[ver];
   else
   {
      int tm=(tl+tr)/2;
      return max(get_max(2*ver,tl,tm,l,min(tm,r)),get_max(2*ver+1,tm+1,tr,max(tm+1,l),r));
   }
}
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
     cout.tie(0);   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n;
   cin>>n;
   for(int i=1;i<=n;i++)
      cin>>h[i];
   for(int i=1;i<=n;i++)
      cin>>a[i];
   for(int i=1;i<=n;i++)
   {
      int mx=get_max(1,1,n,1,h[i]-1);
      // cout<<mx<<'\n';
      upd(1,1,n,h[i],mx+a[i]);
   }
   cout<<get_max(1,1,n,1,n);

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }
 

Measured memory_bytes: 9600
#include<string>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s.size()<4)
		puts("No");
	else
	{
		if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
			puts("Yes");
		else
			puts("No");
	}
	return 0;
}

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

using namespace std;
#define N 200200
#define Epsilon 0.000000000001L
#define inf 1000000000000.0L
#define MAXP 40

long long freq[MAXP][MAXP];
double x, y, z;
long long a, curr, ans;
int i, n, f2, f5, i2, i5;

long long R() {
    string s;
    cin >> s;
    long long res = 0LL;
    int it = 0, it2 = 0, c;
    while (it < s.size() && s[it] != '.'){
        res = res * 10LL + s[it] - '0';
        ++it;
    }
    if (it < s.size() && s[it] == '.')
        ++it;
    for (it2 = 0; it2 < 9; ++it2){
        if (it + it2 < s.size()){
            c = s[it + it2] - '0';
        }
        else {
            c = 0;
        }
        res = res * 10LL + c;
    }
    return res;
}

int main(){
    cin >> n;
    ans = 0;
    for (i = 0; i < n; ++i) {
        //cin >> x;
        //x *= inf;
        //a = (long long) x;
        a = R();
        f5 = f2 = 0;
        while (f2 < MAXP && a % 2 == 0){
            ++f2;
            a /= 2;
        }
        while (a % 5 == 0){
            ++f5;
            a /= 5;
        }
        curr = 0;
        for (i2 = 0; i2 < MAXP; ++i2)
        for (i5 = 0; i5 < MAXP; ++i5){
            if (i2 + f2 > 17 &&
                i5 + f5 > 17)
                    curr += freq[i2][i5];
        }
        ans += curr;
        ++freq[f2][f5];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3636
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    M, D = map(int, readline().split())
    ans = 0
    for m in range(1, M + 1):
        for d in range(10, D + 1):
            d_str = str(d)
            d_1 = int(d_str[1])
            d_10 = int(d_str[0])
            if d_1 >= 2 and d_10 >= 2:
                if d_1 * d_10 == m:
                    ans += 1

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 69468
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
const int maxm=1e5+5;
const int mod=1e9+7;
int d[105][70005];
pair<int,int>p[maxm];
map<int,int>mark;
int n,k;
signed main(){
    cin>>n>>k;
    int m=0;
    for(int i=1,j;i<=n;i=j+1){
        j=n/(n/i);
        p[++m]={j,j-i+1};
        mark[j]=m;
    }
    for(int i=1;i<=m;i++){
        d[1][i]=(d[1][i-1]+p[i].second)%mod;
    }
    for(int i=2;i<=k;i++){
        for(int j=1;j<=m;j++){
            d[i][j]=(d[i][j-1]+p[j].second*d[i-1][mark[n/p[j].first]]%mod)%mod;
        }
    }
    cout<<d[k][m]<<endl;
    return 0;
}
/*

*/


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

using namespace std;

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

const int MX = 100005;
const ll MOD = 1000000007;

template <typename T> void read(T &x)
{
	x = 0;
	char c = getchar();
	while(!isdigit(c)) c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
}

template <typename T> void add(T &x, const T &y)
{
	x += y;
	x %= MOD;
}

ll qpow(ll x, ll t)
{
	ll ans = 1;
	while(t)
	{
		if(t & 1) ans = ans * x % MOD;
		x = x * x % MOD;
		t >>= 1;
	}
	return ans;
}

ll inv(ll x)
{
	return qpow(x, MOD-2);
}

int n, h[MX], rak[MX];
int lmost[MX], rmost[MX];
ll f[MX][2][2][2];
int hmn[MX];

void input()
{
	read(n);
	for(int i=1; i<=n; i++) read(h[i]), rak[i] = i;
	sort(rak+1, rak+n+1, [=](int a, int b){return h[a] > h[b];});
}

void trans(ll a[2][2][2], ll b[2][2][2], ll tar[2][2][2])
{
	ll f[2][2][2];
	memset(f, 0, sizeof(f));
	for(int l=0; l<2; l++)
		for(int ma=0; ma<2; ma++)
			for(int mb=0; mb<2; mb++)
				for(int r=0; r<2; r++)
					for(int ca=0; ca<2; ca++)
						for(int cb=0; cb<2; cb++)
							add(f[l][r][ca|cb|(ma==mb)], a[l][ma][ca]*b[mb][r][cb]);
	memmove(tar, f, sizeof(f));
}

void moveh(ll a[2][2][2], ll tar[2][2][2], int dh)
{
	ll f[2][2][2];
	memset(f, 0, sizeof(f));
	for(int l=0; l<2; l++)
		for(int r=0; r<2; r++)
		{
			if(dh)
			{
				add(f[l][r][0], a[l][r][0]*qpow(2, dh-1));
				add(f[l^1][r^1][0], a[l][r][0]*qpow(2, dh-1));
			}
			else add(f[l][r][0], a[l][r][0]);
			add(f[l^(dh&1)][r^(dh&1)][1], a[l][r][1]);
		}
	memmove(tar, f, sizeof(f));
}

void work()
{
	for(int i=1; i<=n; i++)
	{
		int p = rak[i];
		if(!lmost[p-1] && !rmost[p+1])
		{
			f[p][0][0][0] = 1;
			f[p][1][1][0] = 1;
			lmost[p] = rmost[p] = p;
			hmn[p] = h[p];
		}
		else if(!lmost[p-1] && rmost[p+1])
		{
			moveh(f[p+1], f[p+1], hmn[p+1]-h[p]);
			lmost[rmost[p+1]] = p;
			rmost[p] = rmost[p+1];
			hmn[p] = hmn[rmost[p+1]] = h[p];
			f[p][0][0][0] = 1;
			f[p][1][1][0] = 1;
			trans(f[p], f[p+1], f[p]);
			memmove(f[rmost[p+1]], f[p], sizeof(f[p]));
		}
		else if(lmost[p-1] && !rmost[p+1])
		{
			moveh(f[p-1], f[p-1], hmn[p-1]-h[p]);
			rmost[lmost[p-1]] = p;
			lmost[p] = lmost[p-1];
			hmn[p] = hmn[lmost[p-1]] = h[p];
			f[p][0][0][0] = 1;
			f[p][1][1][0] = 1;
			trans(f[p-1], f[p], f[p]);
			memmove(f[lmost[p-1]], f[p], sizeof(f[p]));
		}
		else
		{
			moveh(f[p-1], f[p-1], hmn[p-1]-h[p]);
			moveh(f[p+1], f[p+1], hmn[p+1]-h[p]);
			rmost[lmost[p-1]] = rmost[p+1];
			lmost[rmost[p+1]] = lmost[p-1];
			hmn[p] = hmn[lmost[p-1]] = hmn[rmost[p+1]] = h[p];
			f[p][0][0][0] = 1;
			f[p][1][1][0] = 1;
			trans(f[p-1], f[p], f[p]);
			trans(f[p], f[p+1], f[p+1]);
			memmove(f[lmost[p-1]], f[p+1], sizeof(f[p+1]));
			memmove(f[rmost[p+1]], f[p+1], sizeof(f[p+1]));
		}
	}
	moveh(f[1], f[1], hmn[1]-1);
	ll ans = 0;
	for(int i=0; i<2; i++)
		for(int j=0; j<2; j++)
			for(int k=0; k<2; k++)
				add(ans, f[1][i][j][k]);
	printf("%lld\n", ans);
}

int main()
{
	input();
	work();
	return 0;
}

Measured memory_bytes: 2304
import bisect
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
GB = [0 for _ in range(N)]
for i in range(N):
    ind = bisect.bisect_right(C,B[i])
    GB[i] = N-ind
SB = [0 for _ in range(N)]
SB[N-1] = GB[N-1]
for i in range(N-2,-1,-1):
    SB[i] = SB[i+1]+GB[i]
cnt = 0
for i in range(N):
    a = A[i]
    ind = bisect.bisect_right(B,a)
    if ind<N:
        cnt += SB[ind]
print(cnt)

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

int main() {
    long long N, K, Q;
    cin >> N >> K >> Q;

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

    for (int i = 0; i <Q; i++){
        P[A[i]-1] ++;
    }

    for (int i = 0; i < N; i++){
        if (P[i] > Q - K){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 1408
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    string S; cin >> S;

    string ans = "";
    if (S == "Sunny") ans = "Cloudy";
    else if (S == "Cloudy") ans = "Rainy";
    else ans = "Sunny";

    cout << ans << endl;


    return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
	string s; cin >> s;
	string past; past.push_back(s[0]);
	int n = s.size(), cnt = 1;

	for(int i = 1; i < n; i++) {
		if(past.size() == 2ul) {
			past = s[i];
			cnt++;
			continue;
		}

		if(past.front() != s[i]) {
			past = s[i];
			cnt++;
			continue;
		}

		if(i >= n - 1)continue;
		past.push_back(s[i + 1]);
		cnt++;
		i++;

	}
	cout << cnt << endl;

}

Measured memory_bytes: 640
import sys

number = list(map(int,input().split()))
a = number[0]
b = number[1]

while True:
    if number[0] > number[1]:
        number[1] += b
    elif number[0] < number[1]:
        number[0] += a
    else:
        print(number[0])
        break
        
    
    


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long l,r;
int main()
{
	cin>>l>>r;
	long long dis=r-l+1;
	if(dis<2019)
	{
		long long mn=(1e9);
		for(long long i=l;i<=r;i++)
			for(long long j=i+1;j<=r;j++)
			{
				long long tmp=i%2019;
				tmp*=j;
				tmp%=2019;
				mn=min(mn,tmp);
			}
		cout<<mn<<endl;
		return 0;
	}
	cout<<0<<endl;
	return 0;
} 

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

const int _ = 1e5 + 7;
char stra[_] , strb[_]; int N , M;

int main(){
	scanf("%d %d %s %s" , &N , &M , stra + 1 , strb + 1);
	int t = __gcd(N , M);
	for(int i = 0 ; i < t ; ++i) if(stra[N / t * i + 1] != strb[M / t * i + 1]){puts("-1"); return 0;}
	cout << 1ll * N * M / t; return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;


int main() {
    ll N;
    cin >> N;
    vector<ll> a(N, 0);
    rep(i, N) cin >> a[i];
    ll sum = accumulate(all(a),0LL);
    ll ans = 1000000000000000000LL;
    ll tmp = 0;
    rep(i,N){
        tmp += a[i];
        if(i + 1 < N)   ans = min(ans, abs(sum - 2 * tmp));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4728
import java.util.Scanner;

public class Main{

  static int[] parent;
  static int[] size;
  static int N,M;
  static int[] A,B;
  static int count;
  static long[] ans;

  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    N = sc.nextInt();
    M = sc.nextInt();
    A = new int[M];
    B = new int[M];
    ans = new long[M];
    for(int i=0;i<M;i++){
      A[i]=sc.nextInt();
      B[i]=sc.nextInt();
    }
    UnionFindTree(N);
    ans[M - 1] = (long)N*(N-1)/2;
    for (int i = M - 1; i > 0; i--) {
      ans[i - 1] = ans[i];
      if (!same(A[i], B[i])) ans[i - 1] -= size[find(A[i])] * size[find(B[i])];
      union(A[i], B[i]);
    }
    for (int i = 0; i < M; i++) {
      System.out.println(ans[i]);
    }
  }

  static void UnionFindTree(int Size) {
    parent = new int[Size+1];
    size = new int[Size+1];

    for (int i = 1; i < Size+1; i++) {
      makeSet(i);
    }
  }

  public static void makeSet(int x) {
    parent[x] = x;
    size[x] = 1;
  }


  public static void union(int x, int y) {
    if(x==y){}
    else{
      final int xRoot = find(x);
      final int yRoot = find(y);


      if (xRoot != yRoot) {
        parent[yRoot] = xRoot;
        size[xRoot]+=size[yRoot];

      }
    }
  }


  public static int find(int x) {
    if (x != parent[x]) {
      parent[x] = find(parent[x]);
    }
    return parent[x];
  }


  public static boolean same(int x, int y) {
    return find(x) == find(y);
  }
}

Measured memory_bytes: 101832
#include <stdio.h>
#define MAX 50001

int main(int argc, const char * argv[]) {
    int t[MAX],n,i,j,count=0;
    for(i=0;i<MAX;i++){
        t[i]=1;
    }
    t[0]=t[1]=0;
    for(i=2;i*i<MAX;i++){
        if(t[i]==1){
            for(j=i*i;j<MAX;j+=i){
                t[j]=0;
            }
        }
    }
    while(1){
        scanf("%d",&n);
        if(n==0)
            break;
        i=2;
        if(t[n-i]==1){
            //printf("%d + %d\n",i,n-i);
            count++;
        }
        for(i=3;i<=n/2;i+=2){
            if(t[n-i]==1&&t[i]==1){
                //printf("%d + %d\n",i,n-i);
                count++;
            }
        }
        printf("%d\n",count);
        count=0;
    }
    return 0;
}

Measured memory_bytes: 1916
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String firstString = sc.next();
		StringBuilder secondStringBld = new StringBuilder(sc.next());
		sc.close();

		if(secondStringBld.indexOf(firstString) == 0 && (secondStringBld.length() - firstString.length()) == 1 ) {
			System.out.println("Yes");

		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 26964
# coding: utf-8

import sys

def _main():
    # args = sys.argv[1:]
    # args = [int(arg) for arg in args]
    text = input()
    datelist = text.split('/')
    year, month, day = [int(i) for i in datelist]

    if year< 2019:
        print('Heisei')
    elif year == 2019:
        if month<4:
            print('Heisei')
        elif month == 4:
            if day <= 30:
                print('Heisei')
            else:
                print('TBD')
        else:
            print('TBD')
    else:
        print('TBD')

if __name__ == '__main__':
    _main()

Measured memory_bytes: 3064
#include<iostream>
    #include<vector>
    using namespace std;
    int main()
    {

        int N;
        cin >> N;
        int maxStreak = 0;
        int prev = -1;
        int current = 0;
        int streak = 0;
        for(int i = 0; i < N; i++){
            cin >> current;
            if(prev >= current){
                streak++;
            }else{
                maxStreak = max(maxStreak, streak);
                streak = 0;
            }
            prev = current;
        }
        maxStreak = max(maxStreak, streak);
        cout << maxStreak << endl;
        
        return 0;
    }

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(x) begin(x), end(x)
using namespace std;
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }

constexpr int inf = 1e9+7;
int main() {
    // input
    int n; scanf("%d", &n);
    vector<vector<int> > children(n);
    repeat (i, n - 1) {
        int p; scanf("%d", &p); -- p;
        children[p].push_back(i + 1);
    }
    vector<int> x(n); repeat (i, n) scanf("%d", &x[i]);

    // solve
    vector<int> dp(n);
    function<void (int)> go = [&](int i) {
        vector<int> cur(x[i] + 1, inf);
        cur[0] = 0;
        for (int j : children[i]) {
            go(j);
            vector<int> prv = move(cur);
            cur.assign(x[i] + 1, inf);
            repeat (acc, prv.size()) if (prv[acc] < inf) {
                if (acc +  x[j] <= x[i]) setmin(cur[acc +  x[j]], prv[acc] + dp[j]);
                if (acc + dp[j] <= x[i]) setmin(cur[acc + dp[j]], prv[acc] +  x[j]);
            }
        }
        dp[i] = *min_element(whole(cur));
    };
    go(0);
    bool result = dp[0] < inf;

    // output
    printf("%s\n", result ? "POSSIBLE" : "IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 5752
#include<stdio.h>

int main(){
	long n, l, i, max = 0, nmax, sum;
	long a[100005];
	scanf("%ld%ld", &n, &l);
	for(i = 0; i < n; i++) scanf("%ld", &a[i]);
	
	for(i = 0; i < n - 1; i++){
		sum = a[i] + a[i+1];
		if(max < sum ){
			max = sum;
			nmax = i;
		}
	}
	if(max < l){
		printf("Impossible\n");
		return 0;
	}
	printf("Possible\n");
	
	for(i = 0; i < nmax; i++)    printf("%ld\n", i + 1);
	for(i = n-2; i >= nmax; i--) printf("%ld\n", i + 1);

	return 0;
}


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

ans = []
chk = [0]*(m+1)

tmp = x
tmp %= m
idx = 0

for i in range(n):
    ans.append(tmp)
    if tmp == 0:
        print(sum(ans))
        exit()
    if chk[tmp] == 1:
        idx = i
        break
    chk[tmp] = 1
    tmp *= tmp
    tmp %= m

if idx == 0:
    print(sum(ans))
    exit()

li = [0]*(m+1)

l_num = ans[-1]

for i in range(len(ans)):
    if l_num == ans[i]:
        f_idx = i
        break

li[0] = l_num

shuki = len(ans)-f_idx-1

for i in range(1,shuki):
    li[i] = li[i-1] + ans[f_idx+i]

t_ans = 0
t_ans += (n-idx-1) // shuki * li[shuki-1]
t_ans += li[(n-idx-1) % shuki]

print(sum(ans)-ans[-1]+t_ans)
#print(t_ans,n,sum(ans),li[shuki])

Measured memory_bytes: 71796
#include <bits/stdc++.h>
using namespace std;
int a[11][11];
int main()
{
	int i,j,n,m,k,s=0,cnt=0;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(i=1;i<n;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			s=0;
			for(k=1;k<=m;k++)
			{
				s+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
			if((int)sqrt(s)*(int)sqrt(s)==s)
				cnt++;
		}
	}
	printf("%d",cnt);
	return 0;
}

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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n, h; cin>>n>>h;
    vector<int> a(n), b(n);
    int amax=0;
    for(int i=0; i<n; i++){
        cin>>a[i]>>b[i];
        amax=max(amax, a[i]);
    }

    sort(b.begin(), b.end(), greater<int>());

    int cnt=0;
    for(int i=0; i<n; i++){
        if(b[i]>amax && h>0){
            h-=b[i];
            cnt++;
        }
    }

    if(h>0) cnt+=((h+amax-1)/amax);
    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_len=(n); i<i##_len; ++i)
#define FOR(i, a, b) for (int i=(a); i<(b); ++i)
using ll = long long;
using namespace std;

int main()
{
    int N = 'E' - 'A' + 1;
    int F[N];
    REP(i, N) cin >> F[i];

    int l = 0;
    REP(i, N) l = F[i]%10 < F[l]%10 && F[i]%10 != 0 ? i : l;

    int ret = 0;
    REP(i, N)
    {
        if (i == l) continue;
        ret += ret%10 !=  0 ? 10 - ret%10 : 0;
        ret += F[i];
    }
    ret += ret%10 !=  0 ? 10 - ret%10 : 0;
    ret += F[l];

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#define N (1<<17)
class BIT{
private:
    int dat[N];
public:
    void Init(){
	lol(i,N)dat[i]=0;
    }
    void Add(int i,int x){
	while(i<N){
	    dat[i]+=x;
	    i+=i&-i;
	}
    }
    int Sum(int i){
	int res=dat[i];
	while(i){
	    i-=i&-i;
	    res+=dat[i];
	}
	return res;
    }
};
int main(){
    int n,q;cin>>n>>q;
    BIT bit;bit.Init();
    while(q--){
	int c,a,b;cin>>c>>a>>b;
	if(c==0){
	    bit.Add(a,b);
	}
	if(c==1){
	    cout<<bit.Sum(b)-bit.Sum(a-1)<<endl;
	}
    }
    return 0;
}



Measured memory_bytes: 3624
ALPHA = "abcdefghijklmnopqrstuvwxyz"


def solve(s, K):
    for a in ALPHA:
        if a not in s:
            continue
        sss = [i for i, p in enumerate(s) if p == a]
        l = 1
        res = a
        if K == 1:
            return res
        while True:
            q = [(s[pos:pos + 1 + l], pos) for pos in sss]
            q = [(a, j) for a, j in q if len(a) == l + 1]
            if len(q) == 0:
                K -= 1
                break
            mins = sorted([a for a, j in q])[0]
            min_indexs = [i for a, i in q if a == mins]
            sss = min_indexs
            res = mins
            l += 1
            K -= 1

            if K == 1:
                return res


def main():
    s = input()
    K = int(input())
    res = solve(s, K)
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n;cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  long long sum = 0;
  for(int i=1;i<n;i++){
    if(a[i-1] > a[i]){
      sum += a[i-1]-a[i];
      a[i] = a[i-1];
    }
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 4336
n = int(input())
s = {}
for i in range(n):
    d = input()
    if d in s:
        s[d] += 1
    else:
        s.update({d:1}) 

m = int(input())
for j in range(m):
    t = input()
    if t in s:
        s[t] -= 1
    else:
        s.update({t:-1})

print(0 if max(s.values()) < 0 else max(s.values()))


Measured memory_bytes: 3060
N = int(input())
s = input()

b = [0 if si == 'o' else 1 for si in s]
sw = [0] * N

for i in range(4):
    sw[0] = i & 1
    sw[1] = (i >> 1) & 1

    for k in range(2, N):
        sw[k] = b[k - 1] ^ sw[k - 1] ^ sw[k - 2]

    if b[N - 1] != (sw[N - 2] ^ sw[N - 1] ^ sw[0]):
        continue
    if b[0] != (sw[N - 1] ^ sw[0] ^ sw[1]):
        continue

    ans = ['W' if si else 'S' for si in sw]
    print(''.join(ans))
    quit()

print(-1)

Measured memory_bytes: 5756