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


int main(void){
    int answer[1000000];
    int num=0;
    int t=0;
    int i=2,k=0;
    double q=0;
    while(1){
        scanf("%d",&num);
        i=num+1;
        if(num==0){
            break;
        }
        while(1){
            k=i;
            if(i>=4){
                q=sqrt(i);
                k=(int)q;
            }
            for(int j=2;j<=k;j++){
                if(i%j==0&&i!=3&&i!=2){
                    break;
                }
                else if(k==j){
                    
                    answer[t]+=1;
                }
            }
            i++;
            if(i>num*2){
                t+=1;
                i=2;
                num=0;
                break;
            }
        }
      
    }
    for(int j=0;j<t;j++){
        printf("%d\n",answer[j]);
    }
    return 0;
}


Measured memory_bytes: 1976
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
const int INF=1001001001;
int main(){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  int score =0;
  rep(i,n-1){
    if (s[i]==s[i+1]) score++;
  }
  int ans =min(score+2*k, n-1);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
fun main(args: Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val bridge = (1..m).map { readLine()!!.split(" ").map { it.toInt()-1 } }
    val uft = UnionFindTree(n)
    var score = 0L
    val maxScore = 1L*n*(n-1)/2

    val ans = bridge.reversed().map {
        val (a,b) = it
        if(!uft.same(a,b)) score += uft.sizeOf(a).toLong() * uft.sizeOf(b).toLong()
        uft.unite(a,b)
        maxScore - score
    }.reversed().drop(1)+maxScore

    println( ans.joinToString("\n"))
}

class UnionFindTree(N:Int){
    private val parent = IntArray(N){ it }
    private val rank = IntArray(N){ 0 }
    private val size = IntArray(N){ 1 }
    private var numTree = N

    fun size() = numTree
    fun find(x:Int):Int = if(parent[x]==x)x else { parent[x] = find(parent[x]);parent[x] }
    fun same(x:Int,y:Int) = find(x)==find(y)
    fun sizeOf(x:Int) = size[find(x)]
    fun unite(x:Int,y:Int){
        val rx = find(x)
        val ry = find(y)
        if (rx==ry) return else numTree--

        if (rank[rx]<rank[ry]){
            parent[rx] = ry
            size[ry] += size[rx]
        } else {
            parent[ry] = rx
            size[rx] += size[ry]
            if( rank[rx]==rank[ry] ) rank[rx]++
        }
    }
}

Measured memory_bytes: 76092
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
using namespace std;
int n;
main()
{
    cin>>n;
    vector<int>a(n);
    iota(a.begin(),a.end(),1);
    do{
        for(int i=0;i<n;i++)cout<<(i?" ":"")<<a[i];
        cout<<endl;
    }while(next_permutation(a.begin(),a.end()));
}



Measured memory_bytes: 3088
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define SZ(c) int(c.size())
#define ff first
#define ss second
#define INF INT32_MAX
#define _INF INT32_MIN
#define PQ priority_queue
#define MM multimap
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
int main() {
	El3zba;
	string s;
	cin >> s;
	int n = (int)s.size();
	int ans = 0;
	stack<int>stck;
	for (int i = 0; i<n; i++)
	{
		if (stck.size()>0)
		{
			if (stck.top() != s[i]-'0')
			{
				ans++;
				stck.pop();
			}
			else stck.push(s[i] - '0');
		}
		else stck.push(s[i] - '0');
	}
	cout << ans * 2 << endl;
	return 0;
}


















Measured memory_bytes: 720
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int i;
  int k,x;
  int start=0,end=0;

  scanf("%d %d",&k,&x );

  start = x - k + 1;
  end = x + k - 1;
  for(i=start;i<=end;i++)printf("%d ",i );
  puts("");
  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

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

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

    int H, W, hh, ww;
    cin >> H >> W >> hh >> ww;

    cout << (H-hh)*(W-ww) << endl;

    return 0;
}

Measured memory_bytes: 256
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


S = instr()

n = len(S)

acgt = "ACGT"
max_len = 0
for i in range(n):
    for j in range(i, n+1):
        s = S[i:j]
        flag = 1
        for ch in s:
            if ch not in acgt:
                flag = 0
                break
        if flag == 1:

            max_len = max(max_len, len(s))
print(max_len)


Measured memory_bytes: 3188
import java.util.*;
import java.math.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static double X, Y, r, angle,an;
    static String[] input;
    public static void main(String[] args) {
        while(read()){
            solve();
        }
        System.out.println((int)Y);
        System.out.println((int)X);
    }

    static boolean read(){
        input = sc.next().split(",");
        r = Integer.parseInt(input[0]);
        an = Integer.parseInt(input[1]);
        if(r == 0 && an == 0)return false;
        return true;
    }

    static void solve(){
        X = X + r*Math.cos(angle*Math.PI/180);
        Y = Y + r*Math.sin(angle*Math.PI/180);
        if(angle < 0)angle = angle + 360;
        angle = (angle + an)%360;
    }

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

void solve(int test_case) {
	int n;
	cin>>n;
	ll sum=0;
	int mi = INT_MAX;
	while(n--) {
		int val;
		cin>>val;
		sum+=val;
		if(val%10!=0) {
			mi=min(mi,val);
		}
	}
	if(sum%10==0&&mi!=INT_MAX)sum-=mi;
	if(sum%10==0)cout<<0;
	else cout<<sum;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3628
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int h[] = new int[N+1];
    int d[] = new int[N+1];
    h[0]=0;
    for(int i=1;i<N+1;i++){
      h[i]=sc.nextInt();
    }
    d[0]=0;
    d[1]=0;
    d[2]=Math.abs(h[2]-h[1]);
    
    for(int i=3;i<N+1;i++){
      d[i]=Math.min(d[i-1]+Math.abs(h[i]-h[i-1]),d[i-2]+Math.abs(h[i]-h[i-2]));
    }
    
    System.out.println(d[N]);
    
    
  }
  

  
}

Measured memory_bytes: 50480
#include "bits/stdc++.h"

using namespace std;
using int64 = long long int;

int C[50], V[50];

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

    for (int i = 0; i < n; i++)
    {
        cin >> V[i];
    }

    for (int i = 0; i < n; i++)
    {
        cin >> C[i];
    }

    int ans = 0;

    for (int i = 0; i < n; i++)
    {
        int c = C[i], v = V[i];
        if (v > c)
        {
            ans += v - c;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

const int64 mod = 998244353;

int64 mpow(int64 mm, int64 xx)
{
	if(xx == 0)
	{
		return 1;
	}
	int64 tmp = mpow(mm, xx / 2);
	tmp *= tmp;
	tmp %= mod;
	if(xx % 2 == 1)
	{
		tmp *= mm;
		tmp %= mod;
	}
	return tmp;
}

int main()
{
	int64 kk, xx;
	cin >> kk >> xx;
	for(int64 ii = xx - kk + 1;ii <= xx + kk - 2;ii++)
	{
		cout << ii << ' ';
	}
	cout << (xx + kk - 1) << endl;
	return 0;
}

Measured memory_bytes: 3604
from collections import defaultdict


def main():
    _ = int(input())
    a = list(map(int, input().split()))
    d = defaultdict(int)
    for x in a:
        d[x] += 1
    diff = {}
    sum_ = 0
    for key, value in d.items():
        num = value * (value - 1) // 2
        sum_ += num
        diff[key] = num - (value - 1) * (value - 2) // 2
    for x in a:
        print(sum_ - diff[x])


if __name__ == "__main__":
    main()

Measured memory_bytes: 32028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 300003;

struct Inversions{// hantensu
	vector<ll> L,R;
	void initsize(ll n){//input size of A
		L.resize(n/2+2);
		R.resize(n/2+2);	
	}
	ll merge(vector<ll> &A,ll n,ll left,ll mid,ll right){
		ll i,j,k;
		ll cnt = 0;
		ll n1 = mid - left;
		ll n2 = right - mid;
		for(i=0;i<n1;i++)L[i]=A[left+i];
		for(i=0;i<n2;i++)R[i]=A[mid+i];
		L[n1]=R[n2]=INT_MAX;//
		i=j=0;
		for(k=left;k<right;k++){
			if(L[i]<=R[j]){
				A[k]=L[i++];
			}else{
				A[k]=R[j++];
				cnt += n1-i;
			}
		}
		return cnt;
	}
	ll mergeSort(vector<ll> &A,ll n,ll left,ll right){
		ll mid;
		ll v1,v2,v3;
		if(left+1<right){
			mid = (left+right)/2;
			v1 = mergeSort(A,n,left,mid);
			v2 = mergeSort(A,n,mid,right);
			v3 = merge(A,n,left,mid,right);
			return v1+v2+v3;
		}else return 0;
	}
	ll num_inverstion(vector<ll> &A){
		return mergeSort(A,A.size(),0,A.size());
	}
};



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;cin>>n;
	Inversions in;
	in.initsize(n);
	vector<ll> a;
	a.resize(n);
	FOR(i,0,n){
		cin>>a[i];
	}
	cout<<in.num_inverstion(a)<<endl;
	return 0;
}



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

#define LL long long
const int mod = 1e9 + 7;
LL fac[500007], n, k, ans, x, y;

LL power(LL x, LL y){return y ? power(x * x % mod, y / 2) * (y % 2 ? x : 1) % mod : 1;}

LL modInverse(LL n) { return power(n, mod-2); } 
 
LL nCr(LL n, LL r) { 
    if (n < 0 || r < 0 || r > n) return 0;  
    return (fac[n]* modInverse(fac[r]) % mod * modInverse(fac[n-r]) % mod) % mod; 
} 


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
     
    fac[0] = 1LL; 
    for (LL i=1;i<=500006;++i) 
        fac[i] = fac[i-1]*i%mod;

    LL n, m, a, b;
    cin >> n >> m >> a >> b;

    LL ans = nCr(n + m - 2, m - 1);
    for(LL i = n-a+1; i <= n; i++) {
        LL x = nCr(i-1 + b-1, b-1), y = nCr(n-i + m-b-1, n-i);
        LL z = (x * y) % mod;
        ans -= z;
        if(ans < 0) ans += mod;
    }
    cout << ans;
}

Measured memory_bytes: 7548
N, C = map(int, input().split())

X = [0]
V = [0]
sV = [0]
Amax1 = [0]
Amax2 = [0]
for _ in range(N):
    x, v = map(int, input().split())
    X.append(x)
    V.append(v)
    sV.append(sV[-1]+v)
    Amax1.append(max(Amax1[-1], sV[-1]-x))
    Amax2.append(max(Amax2[-1], sV[-1]-2*x))
X.append(C)

ans = 0
for b in range(1, N+2):
    # O -> A -> B
    a1 = Amax2[b-1]+sV[-1]-sV[b-1]-(C-X[b])

    # O -> B -> A
    a2 = Amax1[b-1]+sV[-1]-sV[b-1]-2*(C-X[b])

    ans = max(ans, a1, a2)

print(ans)


Measured memory_bytes: 84568
import itertools
N, M = map(int,input().split())
AB = [0] * M
for i in range(M):
  AB[i] = list(map(int, input().split()))
  
lis = [x for x in range(1, N + 1)] # 1からnまでのリスト
 
permutations_lis = itertools.permutations(lis)# 全ての場合のリストを生成
# 以下出力

ans = 0
for one_case in permutations_lis: 
  #print(one_case) #(1,2,3)など
  if one_case[0] == 1:
    m = 0
  else:
    m = N
  for i in range(N - 1):
    #print(one_case[i])
    path = [one_case[i], one_case[i + 1]]
    path2 = [one_case[i + 1], one_case[i]]
    if path in AB:
      m += 1
    elif path2 in AB:
      m += 1
  if m == N - 1:
    ans += 1
    
print(ans)
  


Measured memory_bytes: 42588
#include<bits/stdc++.h>
using namespace  std;
int main ()
{
	string s1,s2;
	cin>>s1>>s2; 
	int n=0;
	for(int i=0;i<s1.size();i++)
	{
		if(s1[i]!=s2[i])n++;
	}
	cout<<n;
	return 0;
} 

Measured memory_bytes: 3900
'''
参考
https://qiita.com/srtk86/items/874639e361917e5016d4

整数Nが素数である=√N以下のすべての数で割り切れない
'''
import math

def is_prime(n):
    if n == 1:
        return False
    
    for m in range(2, int(math.sqrt(n)+1)):
        if n % m == 0:
            return False
    
    return True

X = int(input())

while True:
    if is_prime(X) == True:
        break
    X += 1

print(X)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;
const double PI = acos(-1);

// 入力numが素数かどうか判定する関数
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

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

    while (true) {
        if (IsPrime(x)) {
            cout << x << endl;
            return 0;
        }
        x++;
    }
    return 0;
}

Measured memory_bytes: 256
def cin
  gets.split.map(&:to_i)
end

n, k = cin
p = cin.map { |pi| (pi + 1).to_f / 2 }

max = sum = p[0...k].inject(:+)

(k...n).each do |i|
  sum += p[i] - p[i - k]
  max = sum > max ? sum : max
end

puts max

Measured memory_bytes: 18436
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d,e,f,g,h,i,r[10000];
    vector<int>v;
    string s,t;
    while(cin>>a)
    {

      set<int>s;
      b=1;

      while(1)
      {
          if(b==1)
          {
              c=a;
              s.insert(c);
          }
          else
          {

              if(c%2==0)
              {
                  d=c/2;
                  c=d;
                  e=s.size();
                  s.insert(c);
                  f=s.size();
                  if(f==e)
                  {
                      g=b;
                      break;
                  }

              }
              else
              {

                  d=(3*c+1);
                  c=d;
                  e=s.size();
                  s.insert(c);
                  f=s.size();
                  if(f==e)
                  {
                      g=b;
                      break;
                  }
              }
          }
          b++;
      }
      cout<<g<<endl;
      s.clear();

    }






    return 0;
}


Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

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

#define int long long

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, MAXN); \
                 auto rnd = bind(__dis, __gen);

const int MAXN = 1E6;

int32_t main() {
    fastIO();
    
    int n, tmp;
    bool arr[3][3];
    map<int, int> tab;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            arr[i][j] = 0;
            cin >> tmp;
            tab[tmp] = 3*i + j + 1;
        }
    }
    
    cin >> n;
    while (n--) {
        cin >> tmp;
        if (tab[tmp]) arr[(tab[tmp]-1) / 3][(tab[tmp]-1) % 3] = 1;
    }
    
    for (int i = 0; i < 3; ++i) {
        int cnt = 0;
        for (int j = 0; j < 3; ++j) cnt += arr[i][j] == 1;
        if (cnt == 3) return cout << "Yes\n", 0;
    }
    
    for (int i = 0; i < 3; ++i) {
        int cnt = 0;
        for (int j = 0; j < 3; ++j) cnt += arr[j][i] == 1;
        if (cnt == 3) return cout << "Yes\n", 0;
    }
    
    if (arr[0][0] and arr[1][1] and arr[2][2]) return cout << "Yes\n", 0;
    if (arr[0][2] and arr[1][1] and arr[2][0]) return cout << "Yes\n", 0;
    
    return cout << "No\n", 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    vector<long long> a(N);
    for(long long i=0; i<N; i++) cin >> a[i];
    vector<long long> ans(N, 0);

    vector<pair<long long, long long>> b;
    long long h = 0;
    for(long long i=0; i<N; i++){
        if(h < a[i]){
            h = a[i];
            b.push_back(pair<long long, long long>(h, i));
        }
    }

    sort(a.begin(), a.end());
    long long j = 0;
    long long id = 0;
    h = 0;
    for(long long i=0; i<N; i++){
        ans[id] += (a[i] - h) * (N - i);
        h = a[i];
        if(b[j].first == h){
            j++;
            if(b.size() == j) break;
            id = b[j].second;
        }
    }

    for(long long i=0; i<N; i++)
        cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 4336
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int h = scanner.nextInt();
			int[] a = new int[n], b = new int[n];
			IntStream.range(0, n).forEach(i -> {
				a[i] = scanner.nextInt();
				b[i] = scanner.nextInt();
			});
			int maxA = Arrays.stream(a).max().getAsInt();
			int[] filteredB = Arrays.stream(b).filter(i -> i > maxA).toArray();
			long filterdBSum = Arrays.stream(filteredB).mapToLong(i -> (long) i).sum();
			if (h > filterdBSum) {
				System.out.println(((h - filterdBSum) + maxA - 1) / maxA + filteredB.length);
			} else {
				Arrays.sort(filteredB);
				int i = filteredB.length;
				while (h > 0) {
					h -= filteredB[--i];
				}
				System.out.println(filteredB.length - i);
			}
		}
	}
}


Measured memory_bytes: 80320
// g++ -std=c++11 test.cpp && ./a.out
// g++ -std=c++11 bfs.cpp && cat bfs.txt | ./a.out

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>

using namespace std;

#define INF (1<<29)
#define PRINT(A) {for (auto it=A.begin(); it != A.end(); ++it) {cout << *it << ' ';} cout << endl;}
#define SUM(A) accumulate(A.begin(), A.end(), 0)
#define MAX(A) *max_element(A.begin(), A.end())
#define BIT_LENGTH(N) floor(log2(N)) + 1
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define RREP(I, N) for (int I = N-1; I >= 0 ; --I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RREPP(I, A, B) for (int I = A; I > (B); --I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I

typedef vector<int> VI;
typedef map<int, int> MII;
typedef set<int> SI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;

int main() {
    int N;
    cin >> N;
    VS S;
    unordered_map<string, int> M;
    M["AC"] = 0;
    M["WA"] = 0;
    M["TLE"] = 0;
    M["RE"] = 0;
    REP(i, N) {
        string s;
        cin >> s;
        M[s] += 1;
    }

    cout << "AC x " << M["AC"] << endl;
    cout << "WA x " << M["WA"] << endl;
    cout << "TLE x " << M["TLE"] << endl;
    cout << "RE x " << M["RE"] << endl;

    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
typedef long long ll;
// index が条件を満たすかどうか
bool isOK(ll index, ll key, vector<ll>&a) {
    return (a[index] >= key);
}
ll binary_search(ll key, vector<ll>&a) {
    ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll right = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        ll mid = left + (right - left) / 2;

        if (isOK(mid, key,a)) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B,Q;
    cin>>A>>B>>Q;
    vector<ll>s(A),t(B),x(Q);
    for(ll i=0;i<A;i++){
        cin>>s[i];
    }
    for(ll i=0;i<B;i++){
        cin>>t[i];
    }
    for(ll i=0;i<Q;i++){
        cin>>x[i];
    }
    ll sr,sl,tl,tr;
    for(ll i=0;i<Q;i++){
        sr=binary_search(x[i],s);
        if(sr==A){sl=A-1;}
        else if(sr==-1){sl=-1;sr=0;}
        else{sl=sr-1;}
        tr=binary_search(x[i],t);
        if(tr==B){tl=B-1;}
        else if(tr==-1){tl=-1;tr=0;}
        else{tl=tr-1;}
        vector<ll>v;
        if(sl!=-1&&tl!=-1){v.push_back(x[i]-min(s[sl],t[tl]));}
        if(sr!=A&&tr!=B){v.push_back(max(s[sr],t[tr])-x[i]);}
        if(sl!=-1&&tr!=B){v.push_back(t[tr]-s[sl]+min(t[tr]-x[i],x[i]-s[sl]));}
        if(sr!=A&&tl!=-1){v.push_back(s[sr]-t[tl]+min(s[sr]-x[i],x[i]-t[tl]));}

        sort(ALL(v));
        cout<<v[0]<<endl;
        v.clear();
    }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(){
  int W,H,N;
  cin >> W >> H >> N;
  int x,y,a;
  int a1=0,a2=W,a3=0,a4=H;
  for (int i = 0; i < N; i++){
    cin >> x >> y >> a;
    if (a==1 && x>a1) a1=x;
    if (a==2 && x<a2) a2=x;
    if (a==3 && y>a3) a3=y;
    if (a==4 && y<a4) a4=y;
  }
  cout << max(0,a2-a1)*max(0,a4-a3);
}   

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int i,l,p=0,w=0,g=0,y=0,sum=0;
  scanf("%d",&l);
  char hina[l][1];
  for(i=0;i<l;i++){
    scanf("%s",&hina[i]);
  }
  for(i=0;i<l;i++){
    if(hina[0][i]=='P'){
      p=1;
    }else if(hina[0][i]=='W'){
      w=1;
    }else if(hina[0][i]=='G'){
      g=1;
    }else if(hina[0][i]=='Y'){
      y=1;
    }
  }
  sum=p+w+g+y;
  if(sum==3){
    printf("Three");
  }else if(sum==4){
    printf("Four");
  }
  return 0;
}


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

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

ll a, b;

int main()
{
    cin >> a >> b;
    map<ll, int> mp = prime_factor(__gcd(a, b));
    cout << mp.size() + 1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int N,K;
int h[100000];
int ans=1000000000;
 
int main()
{
	cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>h[i];
	}
	sort(h,h+N);
	for(int i=0;i<=N-K;i++){
		ans=min(ans,h[i+K-1]-h[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<pair<string,int> > v(N);
  rep(i,N)cin >> v[i].first >> v[i].second;
  string s;cin >> s;
  int ans = 0;
  bool sleep = false;
  rep(i,N){
    if(sleep){
      ans += v[i].second;
    }
    if(s == v[i].first)sleep = true;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    ll a, b, c;
    cin >> a >> b >> c;
    if (c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b))
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head,tail,n;

void enqueue(P x){
  if(head==(tail+1)%(LEN+1)){
    printf("Error!Full!\n");
    exit(1);
  }
  Q[tail]=x;
  if(tail+1==(LEN+1))tail=0;
  else tail++;
}

P dequeue(){
  P x;
  if(head==tail){
    printf("Error!Empty!\n");
    exit(2);
  }
  x=Q[head];
  if((head+1)==(LEN+1))head=0;
  else head++;
  return x;
}

int main(){
  int elaps=0,c,total=0,count=0;
  int i, q;
  P u;
  scanf("%d%d",&n,&q);

  head=tail=0;
  for (i=1;i<=n; i++){
    scanf("%s",u.name);
    scanf("%d",&u.t);
    enqueue(u);
    total+=u.t;
  }
  
  while(count!=total){
    u = dequeue();
    if(u.t>q){
      u.t-=q;
      count+=q;
      enqueue(u);
    }
    else if(u.t<=q){
      count+=u.t;
      printf("%s %d\n",u.name,count);
    }
  }

  return 0;
}
  



Measured memory_bytes: 11864
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
int main() {
    ios_base::sync_with_stdio(false);
    LL n;
    cin >> n;
    LL arr[n],dp[n]={0};
    for(int i=0; i<n; i++) {
        cin >> arr[i];
        if(i==1)    dp[i] = abs(arr[i]-arr[0]);
        if(i>1)
            dp[i] = min(dp[i-2]+abs(arr[i-2]-arr[i]),dp[i-1]+abs(arr[i-1]-arr[i]));
    }
    cout << dp[n-1] << "\n";
}


Measured memory_bytes: 1792
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

int main(void) {

  int n;
  ll t[1010], a[1010];
  cin >> n;
  rep(i, n) cin >> t[i] >> a[i];

  ll x = t[0], y = a[0];
  rep(i, n) {
    ll c = (x - 1LL) / t[i] + 1;
    ll d = (y - 1LL) / a[i] + 1;
    x = t[i] * max(c, d);
    y = a[i] * max(c, d);
  }
  cout << x + y << endl;

  return 0;

}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)
#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(V.begin(),V.end(),c))

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N,x;
    cin >>N;
    double nd;
    nd=N;
    nd/=1.08;
    x=nd;
    if(x+x*8/100 == N) cout<< x<<endl;
    else if(x+1 + (x+1)*8/100 == N) cout<<x+1<<endl;
    else cout<<":("<<endl;
    
    return (0);
}

Measured memory_bytes: 256
#include <iostream> 
using namespace std;
  
int main(){
long long x;
long long y;
cin >> x >>y;
long long z;
for(int i=1;i<=100;i++)
{
if(x!=0 && y!=0)
{
if(x>y)
{z=x%y;}
else if(y>x)
{z=y%x;}
else
{cout << x << endl;
x=0;
y=0;}
if(z==0)
{
if(x<y)
{cout << x << endl;
x=0;
y=0;}
else if(y<x)
{cout << y << endl;
x=0;
y=0;}
}
else
{if(x>y)
x=z;
else if(y>x)
y=z;
}
}
}
}


Measured memory_bytes: 3092
<?php
  fscanf(STDIN,"%d %d %d", $n,$a,$b);
  $s = trim(fgets(STDIN));
  $tag = "tag";
  $foreign = 0;
  $tuka = 0;
  for($i=0; $i<$n; $i++){
    if($tuka < $a+$b){
      if($s[$i] == "a" ){
        $tag = "Yes";
        $tuka++;
      }else if($s[$i] == "b"){
        if($foreign < $b){
          $tag = "Yes";
          $foreign++;
          $tuka++;
        }else{
          $tag = "No";
        }
      }else{
        $tag = "No";
      }
    }else{
      $tag = "No";
    }
    echo $tag."\n";
  }

Measured memory_bytes: 4984
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
bc = [list(map(int, input().split())) for i in range(m)]
sort_bc = sorted(bc, key = lambda x:x[1], reverse = True)
cnt_a = 0
cnt_m = 0
for i in sort_bc:
    if cnt_a <= n - 1:
        for j in range(i[0]):
            if cnt_a <= n - 1:
                if i[1] > a[cnt_a]:
                    a[cnt_a] = i[1]
                    cnt_a += 1
                else:
                    break
    else:
        break
print(sum(a))

Measured memory_bytes: 33656
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/*-------------ここまで---------------------------------------------*/
int main(){
    int y, m, d;
    char c1, c2;
    cin >> y >> c1 >> m >> c2 >> d;
    cout << (m <= 4 ? "Heisei" : "TBD") << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct Mon {
  ll X, H;

  bool operator<(const Mon& that) const { return X < that.X; }
};

int main() {
  int N;
  ll D, A;
  cin >> N >> D >> A;

  vector<Mon> M(N);
  for (int i = 0; i < (int)N; ++i) cin >> M[i].X >> M[i].H;

  sort((M).begin(), (M).end());

  ll ans = 0, cum = 0;
  queue<pair<ll, ll>> q;
  for (int i = 0; i < (int)N; ++i) {
    while (!q.empty() && q.front().first < M[i].X) {
      cum -= q.front().second;
      q.pop();
    }

    ll h = M[i].H - cum;
    if (h <= 0) continue;
    ll k = (h + A - 1) / A;

    ans += k;
    q.emplace(M[i].X + 2 * D, A * k);
    cum += A * k;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9+7;

// 各桁の和
template<typename T>
T digit(T num){
  T sum = 0;
  while(num){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}


template<typename T>T gcd(T a,T b){
  if(b == 0)
    return a;
  return gcd(b,a%b);
}
template<typename T>T lcm(T a, T b){
  T g = gcd(a,b);
  return a/g*b; 
}

int main(){
  int N;cin>>N;
  vector<ll> T(N);rep(i,N)cin>>T[i];
  ll ans = 1;
  rep(i,N){
    ans = lcm(max(ans,T[i]),min(ans,T[i]));
  }
  print(ans)
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int A, B, C;

void solve() {
	cin >> A >> B >> C;
	cout << max(C - (A - B), 0) << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

int d[1<<25];
int f(char*s){
	int ret=1;
	for(int i=0;s[i];i++){
		switch(s[i]){
			case 'A':ret=ret*4+0;break;
			case 'G':ret=ret*4+1;break;
			case 'C':ret=ret*4+2;break;
			case 'T':ret=ret*4+3;break;
		}
	}
	return ret;
}
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		char p[10],q[20];
		scanf("%s%s",p,q);
		if(p[0]=='i')d[f(q)]=1;
		else puts(d[f(q)]?"yes":"no");
	}
}


Measured memory_bytes: 7120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int N;
int flg[9];
int d[10];

ll calc(){

	ll ret = 0;
	int i = N-1;
	ll m = 1;
	while(i >= 0){
		ret += d[i] * m;
		if(i > 0 && flg[i-1] == 0){
			m *= 10;
		}
		else{
			m = 1;
		}
		i--;
	}

    if (N <= 3){
        rep(j, N-1){
            fprintf(stderr, "%d", flg[j]);
        }
        fprintf(stderr, " - %lld \n", ret);

    }
    return ret;
}

ll dfs(int i){
	ll ret = 0;

	if (i == N-1) return calc();

	flg[i] = 0;
	ret += dfs(i+1);
	flg[i] = 1;
	ret += dfs(i+1);
	return ret;
}

ll dfs_run(){
	return dfs(0);
}

int main() {
	string s;
	cin >> s;
	N = s.length();
	rep(i, N) d[i] = s[i] - '0';

	ll ret = dfs_run();
	cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int A, B, X;
  cin >> A >> B >> X;
  bool canContain = (A <= X && X <= (A + B));
  if (canContain) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(c)     for(bool p=1;p;p=next_permutation(ALL(c)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<typename T>string join(const vector<T>& v, string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(d.length());}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v)
{if(SZ(v))s<<join(v,", ");return s;}

const ll inf = 1e15;
const ll mod = 1e9+7;
const double eps = 1e-10;

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

struct edge { ll from, to, cost; };

int main() {
    ll N; cin >> N;
    
    map<ll, vector<edge>> mp;
    REP(i, N-1) {
        ll a, b, c; cin >> a >> b >> c;
        mp[b].push_back((edge){b, a, c});
        mp[a].push_back((edge){a, b, c});
    }
    
    ll Q, K; cin >> Q >> K;
    vector<ll> x(Q), y(Q); REP(i, Q) cin >> x[i] >> y[i];
    
    vector<ll> dist(N+1, 0);
    queue<edge> que;
    for (edge e : mp[K]) que.push(e);
    
    while (!que.empty()) {
        edge e1 = que.front(); que.pop();
        if (dist[e1.to] != 0) continue;
        
        dist[e1.to] = e1.cost + dist[e1.from];
        for (edge e2 : mp[e1.to]) que.push(e2);
    }
    
    REP(i, Q) cout << dist[x[i]] + dist[y[i]] << endl;
    
    return 0;
}


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

int main(){
  string s, t;
  cin >> s >> t;
  int cnt = 0;
  for(int i = 0; i < 3; i++){
    if(s.at(i) == t.at(i)) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
typedef long long ll;
using namespace std;

int main() {
	ll a,b,x; cin >> a >> b >> x;
	
	ll ans =(b / x + 1) - ((a - 1) / x + 1);
	if (a == 0) ans = (b / x + 1);
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(),k = sc.nextInt();
    if(n % k == 0){
      System.out.println(0);
    }else{
      System.out.println(1);
    }
  }
}


Measured memory_bytes: 21972
# -*- coding: utf-8 -*-
"""
Created on Mon May 13 13:29:57 2019

@author: avina
"""

n= int(input())
l = []
for i in range(5):
    l.append(int(input()))
k = min(l)
o = l.index(k)
sums = 4
if n%k != 0:
    sums+= n//k + 1
else:
    sums+= n//k

print(sums )

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define int          long long
#define pb          push_back
#define pii         pair<int,int> 
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007 
#define mem(x)      memset(x,0,sizeof(x));
#define what_is(x)  cout << #x << " is " << x << flush << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
 
using namespace std;
const int maxn = 100010;
int n,k;
int a[maxn];
int dp[maxn];
void solve(){
 	cin>>n>>k;
 	rep(i,0,n)cin>>a[i];
 	dp[1] = abs(a[1]-a[0]);
 	rep(i,2,n)
 	{
 		dp[i] = INT_MAX;
 		for(int j = i-1; j>=0 && i-j<=k; j--)
 		dp[i] = min(dp[i], dp[j]+abs(a[i]-a[j]));
 	}
 	cout<<dp[n-1]<<endl;



}
 
signed main(){
   
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t=1;
     //cin>>t;
 
    while(t--)
        solve();
    
    return 0;
}

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

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

	int d = 0, j = 0;
	while (j < c)
	{
		d++;
		j += a;
		if (d % 7 == 0)
			j += b;
	}
	cout << d << endl;

	return 0;
}


Measured memory_bytes: 3120
#include <stdio.h>

int main (void){
	int n;
	int a[10000];
	int min =  1000000;
	int max = -1000000;
	long long sum = 0;
	
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	for(i=0;i<n;i++){
	if(min>a[i]){
			min=a[i];
		}
		if(max<a[i]){
			max=a[i];
		}
		sum+=a[i];
	}
	
	printf("%d %d %lld\n",min ,max ,sum);
	return 0;
}

Measured memory_bytes: 636