akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env pypy
from __future__ import division, print_function
 
import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase
 
import __pypy__
 
def pi(s):
    p = [0] * len(s)
    g = 0
    for i in range(1, len(s)):
        while g and (s[i] != s[g]):
            g = p[g - 1]
        g += s[i] == s[g]
        p[i] = g
 
    return p
 
def match(s, pat):
    if not pat: return list(range(len(s)))
    ret = []
    p = pi(pat)
    g = 0
    for i in range(len(s)):
        while g and s[i] != pat[g]:
            g = p[g - 1]
        g += s[i] == pat[g]
        if g == len(pat): 
            ret.append(i + 1 - g)
            g = p[g - 1]
    return ret
 
def main():
    s = input()
    t = input()
 
    if len(s) < len(t):
        s *= (len(t) + len(s) - 1) // len(s)
    n = len(s)
    s *= 3
 
    lo, hi = 0, (len(s) + len(t) - 1) // len(t)
    while lo < hi:
        mi = (lo + hi) // 2
        u = mi * t
        if not match(s, u):
            hi = mi
        else:
            lo = mi + 1
 
    if len(t * (lo - 1)) >= 2 * n:
        print(-1)
        return
 
    print(lo - 1)
 
 
# region fastio
 
BUFSIZE = 8192
 
 
class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()
 
 
class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)
 
    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()
 
 
def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
 
 
sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# endregion
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 133732
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<set>
#include<queue>
#include<vector>
#include<cstdio>
#include<map>
#include<iomanip>
using namespace std;
int a[222222],b[222222];
int main()
{
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  sort(b,b+n);
  int num1=b[n/2-1];
  int num2=b[n/2];
  for(int i=0;i<n;i++){
    if(a[i]<=num1)
      cout<<num2<<"\n";
    else
      cout<<num1<<"\n";
  }
  return 0;
}


Measured memory_bytes: 3712
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, 0, N) { cin >> A[i]; }
    int m = 0;
    int m2 = 0;
    int maxc = 0;
    rep(i, 0, N) {
        if(m < A[i]) {
            if(m > m2) {
                m2 = m;
            }
            m = A[i];

        } else if(m2 < A[i]) {
            m2 = A[i];
        }
    }
    rep(i, 0, N) {
        if(A[i] == m) {
            maxc++;
        }
    }

    if(maxc == 1) {
        rep(i, 0, N) {
            if(A[i] == m) {
                cout << m2 << endl;
            } else {
                cout << m << endl;
            }
        }
    } else {
        rep(i, 0, N) { cout << m << endl; }
    }
}


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

#define ll long long
#define endl "\n"
#define fi first
#define se second

template<typename T>
void selfmax(T &a, T b){
    if(b>a) a=b;
}

int n;

int main(){
    //
    //freopen("input.txt", "r", stdin);
    //
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin>>n;
    vector<pair<int,int>> a(n);
    for (int i=0; i<n; ++i){
        cin>>a[i].first;
        a[i].second=i;
    }
    vector<vector<ll>> dp(n+1, vector<ll>(n+1, -1));
    dp[0][0]=0;
    sort(a.begin(), a.end(), greater<>());
    for (int i=0; i<n; ++i){
        int val = a[i].fi;
        for (int j=0; j<=i; ++j){
            ll leftDist = abs(a[i].se-j);
            ll rightDist = abs(n-1-a[i].se-(i-j));
            selfmax(dp[i+1][j], dp[i][j] + 1LL * val * rightDist);
            selfmax(dp[i+1][j+1], dp[i][j] + 1LL * val * leftDist);
        }
    }
    ll ans = 0;
    for (int i=0; i<=n; ++i){
        selfmax(ans, dp[n][i]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 34608
#include<iostream>
#include<stdio.h>
#include<iomanip>
#include<algorithm>
#include<cstring>
using namespace std;

int gcd(int a, int b){
  if(b == 0){
    return a;
  }
  return gcd(b, a % b);
}

int main(){

  int N;
  cin >> N;
  int A[100005], L[100005] = {}, R[100005]={};
  for(int i = 1; i <= N; i++){
    cin >> A[i];
  }
  for(int i = 1; i <= N; i++){
    L[i] = gcd(A[i], L[i - 1]);
  }
  for(int i = N; 0 < i; i--){
    R[i] = gcd(A[i], R[i + 1]);
  }
  int ans = 0;
  for(int i = 1; i <= N; i++){
    ans = max(ans, gcd(L[i - 1], R[i + 1]));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408
#include <cstdio>

int main() {
	int n, m, sum, k;
	
	scanf("%d%d", &n, &m);
	
	int a[m];
	int s[n];
	
	s[0] = 0;
	for(int i=1;i<n;i++) {
		int b;
		scanf("%d", &b);
		s[i] = s[i-1]+b;
	}
	
	for(int i=0;i<m;i++) {
		scanf("%d", &a[i]);
	}
	
	sum = 0;
	k = 0;
	
	for(int i=0;i<m;i++) {
		sum += (a[i]<0?-1:1)*(s[k+a[i]]-s[k]);
		sum %= 100000;
		k += a[i];
	}
	
	
	printf("%d\n", sum);
	
	return 0;
}

Measured memory_bytes: 1808
x = int( input() )
if x < 600:
    print( 8 )
elif x < 800:
    print( 7 )
elif x < 1000:
    print( 6 )
elif x < 1200:
    print( 5 )
elif x < 1400:
    print( 4 )
elif x < 1600:
    print( 3 )
elif x < 1800:
    print( 2 )
else:
    print( 1 )
   

Measured memory_bytes: 9164
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n;
int d[100010];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>d[i];
	sort(d+1,d+n+1);
	int t1=d[n/2],t2=d[n/2+1];
	cout<<t2-t1<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int M=100000000;
  int n,m,i,u,s,c[510],f[20010],t[20010];
  while(scanf("%d %d",&n,&m),n||m){
    for(i=u=1;i<=n;i++)c[i]=M;
    for(i=s=c[1]=0;i<m*2;i+=2){
      scanf("%d %d",&f[i],&t[i]);
      f[i+1]=t[i];
      t[i+1]=f[i];
    }
    while(u){
      for(i=u=0;i<=m*2;i++){
	if(c[f[i]]==M||c[t[i]]<=c[f[i]]+1)continue;
	c[t[i]]=c[f[i]]+1;
	u=1;
      }
    }
    for(i=2;i<=n;i++){
      if(c[i]<3)s++;
    }
    printf("%d\n",s);
  }
  return 0;
}

Measured memory_bytes: 760
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

ll A[100010], sum[100010];

int main(void){
    int N;
    cin >> N;
    for(int i=0; i<=N; ++i) cin >> A[i];
    sum[N]=A[N], sum[N+1]=0;
    for(int i=N-1; i>=0; --i) sum[i]=sum[i+1]+A[i];
    ll now=1, ans=0;
    for(int i=0; i<=N; ++i){
        ans += now;
        now -= A[i];
        if(now<0){
            cout << -1 << endl;
            return 0;
        }
        now=min(now*2, sum[i+1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5196
from queue import deque
k = int(input())
Q = deque([ i for i in range(1, 10) ])
for _ in range(k):
    q = Q.popleft()
    if q%10 != 0: Q.append(10*q+q%10-1)
    Q.append(10*q+q%10)
    if q%10 != 9: Q.append(10*q+q%10+1)
print(q)

Measured memory_bytes: 41068
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int N, W;
vi v, w;

vvi dp(105, vi(10005, -1));

int dfs(int i, int r) {
    if (dp[i][r] != -1) return dp[i][r];

    int res;
    if (i == N) res = 0;
    else if (w[i] > r) res = dfs(i+1, r);
    else
    {
        res = max(dfs(i+1, r-w[i])+v[i], dfs(i+1, r));
        res = max(res, dfs(i, r-w[i])+v[i]);
    }

    dp[i][r] = res;
    return res;
}

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

    cin >> N >> W;
    v.resize(N);
    w.resize(N);
    REP(i, N) {
        cin >> v[i] >> w[i];
    }
    cout << dfs(0, W) << endl;
    return 0;
}



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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
set<char>st;
str s;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>s;
    for(int i=0;i<s.size();i++){
        st.insert(s[i]);
    }

    if(st.size()==s.size()) cout<<"yes\n";
    else cout<<"no\n";
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	while(1){
		int x, y;
		scanf("%d %d", &x, &y);
		if(x == 0 && y == 0){
			break;
		}else if(x <= y){
			printf("%d %d\n", x, y);
		}else if(x >= y){
			printf("%d %d\n", y, x);
		}
	}
	return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <unordered_map>
#include <vector>
#include <stack>
#include <algorithm>
#include <set>


int N;
std::vector<int> A;

int main() {
  std::cin >> N;
  for (int i = 0; i < N - 1; ++i) {
    int a; std::cin >> a;
    A.push_back(a - 1);
  }

  std::unordered_map<int, std::vector<int>> wins;
  for (int i = 0; i < N; ++i) wins[i] = {};
  for (int i = 1; i < N; ++i) {
    wins[A[i - 1]].push_back(i) ;
  }

  //for (const auto &k : wins) {
  //  std::cout << "KEY" << k.first << std::endl;
  //  for (const auto &j : k.second) {
  //    std::cout << j << " ";
  //  }
  //  std::cout << std::endl;
  //}

  std::stack<int> stack;
  std::set<int> expanded;
  std::vector<int> indices;
  stack.push(0);
  while (!stack.empty()) {
    const auto t = stack.top(); stack.pop();
    if (expanded.find(t) != expanded.end()) {
      indices.push_back(t);
      continue;
    }
    expanded.insert(t);
    stack.push(t);
    for (const auto target : wins[t]) {
      stack.push(target);
    }
  }

  std::vector<int> depth_table;
  for (int i = 0; i < N; ++i) {
    depth_table.push_back(0);
  }
  std::vector<int> tmp;
  for (int i = 0; i < N; ++i) {
    tmp.push_back(0);
  }
  for (const int i : indices) {
    if (wins[i].size() == 0) {
      depth_table[i] = 0;
      continue;
    }

    int c = 0;
    for (const int j : wins[i]) {
      tmp[c++] = -depth_table[j];
    }
    std::sort(tmp.begin(), tmp.begin() + c);
    depth_table[i] = -1;
    for (int j = 0; j < c; ++j) {
      if (-tmp[j] + j + 1 > depth_table[i]) {
        depth_table[i] = -tmp[j] + j + 1;
      }
    }
  }
  std::cout << depth_table[0] << std::endl;
//          def solve(i):
//            if len(wins[i]) == 0:
//            return 0
//            ans = max(n + 1 + d for n, d in enumerate(sorted((solve(j) for j in wins[i]), reverse=True)))
//            return ans
//
//            print(solve(0))
  return 0;
}


Measured memory_bytes: 17636
/*input
7
100 130 130 130 115 115 150

answer should be - 1685
answer coming - 1000
*/
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define v32 vector<int>
#define v64 vector<ll>

using namespace std;

void solve()
{
    ll n;
    cin >> n;
    ll *a = new ll[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll balance = 1000;
    ll stocks = 0;
    ll i;
    for (i = 0; i < n - 1; i++)
    { // if increasing
        if (a[i + 1] > a[i])
        {
            if ((balance / a[i]) > 0)
            {
                ll s = balance / a[i];
                stocks = stocks + s;
                balance = balance - (s * a[i]);
            }
        }
        // if constant
        else if (a[i + 1] == a[i])
        {
            if (i == 0)
            {

                if ((balance / a[i]) > 0)
                {
                    ll s = balance / a[i];
                    stocks = stocks + s;
                    balance = balance - (s * a[i]);
                }
            }

            continue;
        }
        // if decreasing
        else
        {
            if (stocks > 0)
            {
                balance = balance + (stocks * a[i]);
                stocks = 0;
            }
        }
    }
    balance = balance + (stocks)*a[n - 1];
    stocks = 0;
    cout << balance << endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3556
#include <iostream>
using namespace std;
 int main(){
int counter[26];

char ch;

for (int x = 0 ; x <= 25 ; x++){
	counter[x] = 0;
}

while (cin >> ch){
	if (isupper(ch)){
		ch = tolower(ch);
	} 
	int num = ch - 'a';

	if (num >= 0 && num <= 25){
		counter[num]++;
	}
}

for (int x = 0 ; x <= 25 ; x++){
	char y = x + 'a';
	cout << y << ' ' << ':' << ' ';
	cout << counter[x] << endl;
}


 	return 0;

}

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
  int A[101][101];
  int n, i, j, u, k, a;
  scanf("%d",&n);
  for(i=0 ; i<=n ; i++ )
    for(j=0 ; j<=n ; j++ )
      A[i][j] = 0;
  
  for(i=1 ; i<=n ; i++ ){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=1 ; j<=k ; j++ ){
      scanf("%d",&a);
      A[u][a] = 1;
    }
  }

  for(i=1 ; i<=n ; i++ ){
    for(j=1 ; j<n ; j++ ){
      printf("%d ",A[i][j]);
    }
    printf("%d\n",A[i][j]);
  }
  return 0;
}

Measured memory_bytes: 632
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int x = scanner.nextInt();

		int cnt = 0;
		for (int i = 0; i <= a; i++) {
			for (int j = 0; j <= b; j++) {
				for (int k = 0; k <= c; k++) {
					if (500 * i + 100 * j + 50 * k == x)
						cnt++;
				}
			}
		}

		System.out.println(cnt);
	}
}


Measured memory_bytes: 21588
#入力
N = input()
N = int(N)

#素因数分解
Num = []
n = N
for i in range(2, int(-(-N**0.5//1))+1):
    if n%i==0:
        j=0
        while n%i==0:
            j+=1
            n //= i
        Num.append(j)

if n!=1:
    Num.append(1)

if Num==[]:
    if N == 1:
        Num.append(0)
    else:
        NUm.append(1)

#階差数列
P = []
p = 0
l = max(Num)
for i in range(1,l+1):
    p += i
    P.append(p)

#計算
Answer = 0

l = len(Num)

if Num[0] != 0:
    for i in range(l):
        q = Num[i]
        while not(q in P):
            q -= 1
        Index = P.index(q)
        Index = int(Index)
        Index += 1
        Answer += Index

print(Answer)

Measured memory_bytes: 9384
n=int(input())
A=list(map(int,input().split()))
a=0
c=0
m=max(A)
while(m):
    o=sum(map(lambda x:x&1,A))
    a+=(n-o)*o*2**c
    A=list(map(lambda x:x>>1,A))
    c+=1
    a%=10**9+7
    m//=2
print(a)

Measured memory_bytes: 137536
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    string S;   cin>>S;

    for(int bit=0;bit<(1<<3);bit++){
        int num=S[0]-'0';
        for(int j=0;j<3;j++){
            if(bit & 1<<j){ //bitに1があるとき
                num+=S[j+1]-'0';
            }
            else{
                num-=S[j+1]-'0';
            }
        }
        if(num==7){
            for(int i=0;i<3;i++){
                cout<<S[i];
                if(bit&1<<i){
                    cout<<'+';
                }
                else{
                    cout<<'-';
                }
            }
            cout<<S[3]<<"=7\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>


int main(){
  int N;
  std::cin >> N;
  int count=0;
  for(int i=1;i<=N;i+=2){
    int yaku=0;
    for(int j=1;j<=i;j++){
      if(i%j==0) yaku++;
    }
    if(yaku==8) count++;
  }
  std::cout << count << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
map< int, int > xz;

int main()
{
	int N,cnt=0;
	cin >> N;
	for(int i = 0; i < N;++i)
	{
		int x;
		cin >> x;
		if(xz.find(x) == xz.end())
		{
			xz[x]=1;
			cnt++;
		}


	}
	cout << cnt << endl;
}

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

using namespace std;

template<typename T> class BIT {
private:
	int n;
	vector<T> bit;
public:
	// 0_indexed で i 番目の要素に x を加える
	void add(int i, T x){
		i++;
		while(i < n){
			bit[i] += x, i += i & -i;
		}
	}
	// 0_indexed で [0,i] の要素の和(両閉区間！！)
	T sum(int i){
		i++;
		T s = 0;
		while(i > 0){
			s += bit[i], i -= i & -i;
		}
		return s;
	}
	BIT(){}
	//初期値がすべて0の場合
	BIT(int sz) : n(sz+1), bit(n, 0){}
	BIT(vector<T>& v) : n((int)v.size()+1), bit(n, 0){
		for(int i = 0; i < n-1; i++){
			add(i,v[i]);
		}
	}
	void print(){
		for(int i = 0; i < n-1; i++){
			cout<<sum(i)-sum(i-1)<< " ";
		}
		cout<<endl;
	}
	//-1スタート
	void print_sum(){
		for(int i = 0; i < n; i++){
			cout<<sum(i-1)<<" ";
		}
		cout<<endl;
	}
};


int main()
{
    int n,q;
    scanf("%d%d",&n,&q);
    BIT<int> bt(n);
    for(int i = 0; i < q; i++){
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        if(x==0){
            bt.add(y-1, z);
        }else{
            printf("%d\n",bt.sum(z-1)-bt.sum(y-2));
        }
    }
    return 0;
}



Measured memory_bytes: 3412
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int maxn=1e5+10;
const ll mm=1e9+7;
int sp[maxn],vis[maxn];
int main()
{
    int n;
    cin>>n;
    int flag=0;
    memset(vis,0,sizeof(vis));
    for(int i=1;i<=n;++i){
        cin>>sp[i];
        vis[sp[i]]++;
    }
    if(n%2==1)
    {
        for(int i=0;i<n;i+=2)
        {
            if(i==0)
            {
                if(vis[i]!=1)
                {
                    flag=1;
                    break;
                }
            }
            else
            {
                if(vis[i]!=2)
                {
                    flag=1;
                    break;
                }
            }
        }
        if(flag==1)
            cout<<0<<endl;
        else
        {
            ll res=1;
            for(int i=1;i<=(n-1)/2;++i)
            {
                res=((res%mm)*2)%mm;
            }
          //  ll ans=res%mm;
            cout<<res<<endl;
        }
    }
    else if(n%2==0)
    {
        int flag=0;
        for(int i=1;i<n;i+=2)
        {
            if(vis[i]!=2)
            {
                flag=1;
                break;
            }
        }
        if(flag==0)
        {
            ll res=1;
            for(int i=1;i<=n/2;++i)
            {
                res=((res%mm)*2)%mm;
            }
          //  ll ans=res%mm;
            cout<<res<<endl;
        }

        else cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
MOD = 10 ** 9 + 7

def modPow(a, x, p):
	res = 1
	while x > 0:
		if x % 2 != 0:
			res = res * a % p
		a = a * a % p
		x = x // 2
	return res
 
def modInverse(a, p):
	return modPow(a, p - 2, p)
 
def modBinomial(n, k, p):
	numerator = 1
	for i in range(k):
		numerator = (numerator * (n - i)) % p
	denominator = 1
	for i in range(1, k + 1):
		denominator = (denominator * i) % p
	return (numerator * modInverse(denominator, p)) % p


if __name__ == "__main__":
	X, Y = map(int, input().split())
	if (X + Y) % 3 != 0 or Y > 2 * X or Y < X / 2.:
		print("0")
	else:
		n = (X + Y) // 3
		k = Y - n
		print(modBinomial(n, k, MOD))

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


int main(){

int a,b,c,d;
cin >> a >> b >> c >> d;
string ans;
while(true){

c -= b;
if (c <= 0)
{
    ans = "Yes";
    goto goal;
}

a -= d;
if (a <= 0)
{
    ans = "No";
    goto goal;
}

}
goal:
cout << ans << endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main() {
    long long X,K,D;
    long long count;
    cin >> X >> K >> D;
    
    if(X<0)
        X*=-1;
    count = X/D;
    if(count>K){
        X-=D*K;
        K=0;
    }
    else{
        X-=D*count;
        K-=count;
    }
    if(K%2==0){
        if(X<0)
            X*=-1;
        cout<<X<<endl;
    }
    else
    {
        X-=D;
        if(X<0)
             X*=-1;
        cout<<X<<endl;
    }
    

    
}

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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a)a, rreps(i,  0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;

const string NO_STR = "IMPOSSIBLE";

void solve(long long A, long long B) {
	int C = A + B;
	if (C % 2) {
		cout << "IMPOSSIBLE" << endl;
	} else {
		cout << C / 2 << endl;
	}
}

signed main() {
	long long A;
	scanf("%lld",&A);
	long long B;
	scanf("%lld",&B);
	solve(A, B);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

class Main {
    public static Scanner sc = new Scanner(in);
    public static Random rand=new Random();


    public void run() {
    	TCase:while(true){
    		String str=sc.nextLine();
    		if(str.equals("."))return;
    		char[] cs=str.toCharArray();
    		Stack<Character> st=new Stack<Character>();

    		for(char c:cs){
    			switch(c){
	    			case '[':case '(':
	    				st.push(c);
	    				break;
	    			case ']':case ')':
	    				if(st.isEmpty()){
	    					ln("no");continue TCase;
	    				}
	    				char now=st.pop();
	    				if(!((now=='[' && c==']') || (now=='(' && c==')'))){
	    					ln("no");continue TCase;
	    				}
	    			break;
    			}
    		}
    		if(st.isEmpty()){
        		ln("yes");
    		}else{
    			ln("no");
    		}
    	}
    }
    public static void main(String[] args) {
        new Main().run();
    }

    public int[] nextIntArray(int n){
        int[] res=new int[n];
        for(int i=0;i<n;i++){
            res[i]=sc.nextInt();
        }
        return res;
    }
    public static void pr(Object o) {
        out.print(o);
    }
    public static void ln(Object o) {
        out.println(o);
    }
    public static void ln() {
        out.println();
    }
}

Measured memory_bytes: 33580
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

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

using namespace std;


int main(void){
    
    int n,m;
    cin >> n >> m;
    vector<int64_t> xs(n);
    vector<int64_t> ys(m);
    vector<int64_t> xds(n-1);
    vector<int64_t> yds(m-1);
    
    REP(i,n){
        cin >> xs[i];
    }
    REP(i,m){
        cin >> ys[i];
    }
    
    sort(xs.begin(),xs.end());
    sort(ys.begin(),ys.end());
    
    REP(i,n-1){
        xds[i] = xs[i+1]-xs[i];
    }
    REP(i,m-1){
        yds[i] = ys[i+1]-ys[i];
    }
    int64_t a=0;
    int64_t b=0;
    
    REP(i,n-1){
        a+= xds[i]*(i+1)*(n-1-i);
        a %= 1000000007;
       // cout << a << endl;
    }
    REP(i,m-1){
        b+= yds[i]*(i+1)*(m-1-i);
        b %= 1000000007;
       // cout << b << endl;
    }
    
    //a %= 1000000007;
    //b %= 1000000007;
    int64_t sum = (a*b)%1000000007;
    
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

int k,n,a[200005],cnt,x,ans;

vector <int> f;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> k;
    for(int i=1;i<=n;i++){
        cin >> x;
        if(a[x]) a[x]++;
        else cnt++,a[x]++;
    }
    if(cnt>k){
        for(int i=1;i<=n;i++){
            if(a[i]) f.pb(a[i]);
        }
        sort(f.begin(),f.end());
        for(int i=1;i<=cnt-k;i++) ans+=f[i-1];
    }
    cout << ans;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
template<typename T> inline void add(T& a, T b) { a += b; if (a >= MOD) a -= MOD; }

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

  int K; cin >> K;
  queue<ll> Q;
  rep1(i, 9) Q.push(i);

  int curk = 0;
  while(!Q.empty()) {
    ++curk;
    ll cur = Q.front(); Q.pop();

    if(curk == K) {
      cout << cur << endl;
      return 0;
    }

    if(cur % 10 != 0) {
      Q.push(cur * 10 + (cur % 10) - 1);
    }
    Q.push(cur * 10 + (cur % 10));
    if(cur % 10 != 9) {
      Q.push(cur * 10 + (cur % 10) + 1);
    }
  }
}

// 10
// 11
// 12

// 21
// 22
// 23

// 32
// 33
// 34

// 43
// 42
// 41

// 98
// 99

// 100
// 101
// 110
// 111
// 112
// 121
// 122
// 123

// 210
// 211
// 212
// 221
// 222
// 223
// 232
// 233
// 234

// 987
// 988
// 989
// 998
// 999


Measured memory_bytes: 1792
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int num[] = {1,2,3,4,5,6,7,8,9};
int cnt[] = {2,5,5,4,5,6,3,7,6};
bool use[9] = {};

const int MAX_N = 1e4+10;
string dp[MAX_N];

void strMax(string& a, const string& b) {
    if(a.size() < b.size()) a = b;
    else if(a.size() == b.size()) {
        rep(i, a.size()) {
            if(a[i] > b[i]) return;
            if(a[i] < b[i]) {
                a = b;
                return ;
            }
        }
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a;
        cin >> a;
        use[a-1] = true;
    }
    dp[0] = "0";
    rep(i, n) if(dp[i].size()){
        rep(j, 9) if(use[j]) {
            string nxt = dp[i] + char('1' + j);
            strMax(dp[i+cnt[j]], nxt);
        }
    }
    auto ans = dp[n].substr(1);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 43776
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;


int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, ans = 0;
	cin >> n;
	map<int, int> data;

	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		ans += data[i - x];
		data[i + x]++;
	}
	cout << ans;
}

Measured memory_bytes: 26392
#include <iostream>

using namespace std;

int  selectionSort(int a[],int n) 
{
    int count = 0;
    
    for (int i = 0; i < n; i++) {
        int minj = i;
        for (int j = i; j < n; j++) {
            if (a[j] < a[minj]) {
                minj = j;
            }
        }
        swap(a[i], a[minj]);
        if (i != minj) {
            count++;
        }
        
    }
    return count;
}

int main()
{
    int n, a[100];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int sw = selectionSort(a, n);
    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << a[i];
    }
    cout << endl;
    cout << sw << endl;

    return 0;
}

Measured memory_bytes: 1160
const main = stdin => {
  const N = stdin.trim()
  switch (N[N.length - 1]) {
    case '2':
    case '4':
    case '5':
    case '7':
    case '9':
      console.log('hon')
      break;
    case '0':
    case '1':
    case '6':
    case '8':
      console.log('pon')
      break;
    default:
      console.log('bon')
      break;
  }
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 30272
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    N, D = LI()
    ans = 0
    D2 = D **2
    for _ in range(N):
        X, Y = LI()
        if X **2 + Y **2 <= D2:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 84292
#include "bits/stdc++.h"
using    namespace std;
typedef  long double ld;
#define  int long long
typedef  pair<int,int> pii;
#define  RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  rep(i,n) for(i=0; i <n; i++)
#define  repv(i,k,n) for(int i=k; i<=n; i++)
#define  pb push_back
#define  mp make_pair
#define  F  first
#define  S  second
#define  sz(x)  (int)x.size()
#define  all(v) v.begin(),v.end()
#define  endl '\n'
#define  deb(x) c out<<#x<<" = "<<x<<endl
#define  gcd   __gcd
#define  inf   LLONG_MAX
#define  minf  LLONG_MIN 
#define  sp(n) fixed<<setprecision(n)
const int mod = 1e9+7;
int power(int x,int n)
{   
    if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;return (y*y)%mod;}
    if(n&1)     {   int y = power(x,n-1);return (x%mod * y%mod)%mod;}
    return 0;
}
int pct(int x)
{   return __builtin_popcountll(x);}
int  lcm(int a,int b){return a*b/gcd(a,b);}
bool is_power_2(int n){ return log2(n)==floor(log2(n));}
bool is_prime(int n){for(int i=2; i*i<=n; i++)if(n%i==0)return 0; return 1;}
void db()
{   
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
void timeit()
{  
    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}
int     dx []    =  {-1 , 0 , 1 , 0 ,-1,-1, 1,  1};
int     dy []    =  { 0 , 1 , 0 ,-1 ,-1, 1, 1, -1};
char    dir[]    =  {'U','R','D','L'};
/* ------------------------------------------------------- */
const int maxn = 1e6+5;
void solve(int tc)
{
    int n,i,j,k,m,q;
    int r,g,b;
    cin>>r>>g>>b>>k;
    while(g<=r && k)
        g*=2 , k--;
    while(b<=g && k)
        b*=2 , k--;
    if(g>r && b>g)
        cout<<"Yes";
    else
        cout<<"No";
}
signed main()
{
    RAGE;
  //  db();       
    int t=1;
    //  cin>>t;
    for(int i=1; i<=t; i++)
    {
        solve(i);
    }
 //   timeit();
    return 0;
}

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

#define int long long
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1

using namespace std;

inline int mod(int n){ return (n%1000000007); }

int gcd(int a, int b){
  if(a == 0 || b == 0) return 0;
  if(b == 1) return b;
  else return gcd(b, a%b);
}

int32_t main(){
	DESYNC;
	int n,m;
	cin >> n >> m;
	int ans = 0;
	vector< ii > v(m);
	for(int i=0; i<m; i++){
	  cin >> v[i].ff >> v[i].ss;
	}
	sort(v.begin(), v.end());
	int l = 0, r = n+1;
	int last_l = 0, last_r = n+1;
	for(int i=0; i<m; i++){
	  l = max(l, v[i].ff);
	  r = min(r, v[i].ss);
	  if(r - l + 1 >= 2){
	    last_l = l;
	    last_r = r;
	  }
	  else {
	    ans++;
	    l = v[i].ff;
	    r = v[i].ss;
	  }
	}
	if(r - l + 1 >= 2) ans++;
	cout << ans << endl;
	  
}



Measured memory_bytes: 1792
import java.util.Scanner;

/**
 * PrintChess
 */
public class Main{

    public static void main(String[] args) {
        int h, w;
        Scanner sc = new Scanner(System.in);

        while (true) {
            h = sc.nextInt();
            w = sc.nextInt();

            if (h == 0 && w == 0) {
                break;
            }

            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if ((i + j) % 2 == 0) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.println();
            }

            System.out.println();
        }

        sc.close();
    }
}


Measured memory_bytes: 35572
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int ans = 1000000001;
    for(int i=0;i+k-1<n;i++)
        {
            ans=min(ans,abs(a[i]-a[i+k-1]));
        }
    cout<<ans;
}


Measured memory_bytes: 3876
/*
СТРОИМ СТЕНУ РАБОТЯГИ!
█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
*/

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
    
     
     
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }
/** Interface */
     
inline int readChar();
template <class T = int> inline T readInt(); 
template <class T> inline void writeInt( T x, char end = 0 );
inline void writeChar( int x ); 
inline void writeWord( const char *s );
     
/** Read */
     
static const int buf_size = 4096;
     
inline int getChar() {
    static char buf[buf_size];
    static int len = 0, pos = 0;
    if (pos == len) {
        pos = 0, len = fread(buf, 1, buf_size, stdin);
    }
    if (pos == len) {
        return -1;
    }
    return buf[pos++];
}
     
inline int readChar() {
    int c = getChar();
    while (c <= 32) {
        c = getChar();
    }
    return c;
}
     
template <class T>
inline T readInt() {
    int s = 1, c = readChar();
    T x = 0;
    if (c == '-')
        s = -1, c = getChar();
    while ('0' <= c && c <= '9')
        x = x * 10 + c - '0', c = getChar();
    return s == 1 ? x : -x;
}
     
/** Write */
     
static int write_pos = 0;
static char write_buf[buf_size];
     
inline void writeChar( int x ) {
    if (write_pos == buf_size)
        fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
    write_buf[write_pos++] = x;
}
     
template <class T> 
inline void writeInt( T x, char end ) {
    if (x < 0)
        writeChar('-'), x = -x;
     
    char s[24];
    int n = 0;
    while (x || !n)
        s[n++] = '0' + x % 10, x /= 10;
    while (n--)
        writeChar(s[n]);
    if (end)
        writeChar(end);
}
     
inline void writeWord( const char *s ) {     while (*s)
writeChar(*s++); }
     
struct Flusher {
    ~Flusher() {
        if (write_pos)
            fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
    }
} flusher;   
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left228
#define right right228
#define rank rank228
#define prev prev228
#define y1 y1228  





int main() {
    int n, k;
    cin >> n >> k;
    int cur = 1;
    for (int i = 0; i < n; i++) {
        if (cur <= k) {
            cur *= 2;
        } else {
            cur += k;
        }
    }
    cout << cur << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=2020,P=924844033;
int i,j,k,k1,k2,n,m,nm,ch,Ans;
int ans[N],f[N][N][2][2],Jc[N];
void pre(int n) {
	int i;
	Jc[0]=1;
	for (i=1;i<=n;i++) Jc[i]=(ll) Jc[i-1]*i%P;
}
void Up(int &x,int y) {
	x=(x+y)%P;
}
int main() {
	scanf("%d%d",&n,&m);
	pre(n);
	nm=n/m+1;
	f[0][0][1][0]=1;
	for (i=0;i<=nm;i++)
		for (j=0;j<=i;j++)
			for (k1=0;k1<2;k1++)
				for (k2=0;k2<2;k2++) if (f[i][j][k1][k2]) {
					Up(f[i+1][j][k2][0],f[i][j][k1][k2]);
					if (!k1) Up(f[i+1][j+1][k2][0],f[i][j][k1][k2]);
					Up(f[i+1][j+1][k2][1],f[i][j][k1][k2]);
				}
	ans[0]=1;
	for (i=1;i<=m;i++) {
		int t;
		if (i<=n%m) t=nm;
		else t=nm-1;
		for (j=n;j>=0;j--) if (ans[j]) {
			for (k=1;k<=t;k++) Up(ans[j+k],(ll) ans[j]*(f[t][k][0][0]+f[t][k][1][0])%P);
		}
	}
	for (i=0;i<=n;i++) {
		int t=(ll) Jc[n-i]*ans[i]%P;
		if (i&1) t=(P-t)%P;
		Ans=(Ans+t)%P;
	}
	printf("%d\n",Ans);
}

Measured memory_bytes: 61952
n, a, b, c, d = map(int, input().split())
s = input()

a -= 1; b -= 1; c -= 1; d -= 1

#ABCD
if c < d:
    for i in range(a, d-1):
        if s[i] == "#" and s[i+1] == "#":
            print("No")
            exit()
    print("Yes")

#ABDC
elif d < c:
    flag_a = False
    for i in range(b, d+1):
        if s[i-1] == "." and s[i] == "." and s[i+1] == ".":
            flag_a = True

    flag_b = True
    for i in range(a, d-1):
            if s[i] == "#" and s[i+1] == "#":
                flag_b = False

    if flag_a and flag_b:
        print("Yes")
    else:
        print("No")                


Measured memory_bytes: 3572
import math

while(1):
    try:
        n = int(input())
    except:
        break

    m = int(math.sqrt(n))
    keys = [n // i for i in range(1, m+1)]
    keys += range(keys[-1]-1, 0, -1)
    h = {i: i-1 for i in keys}

    for i in range(2, m+1):
        if h[i] > h[i-1]:
            hp = h[i-1]
            i2 = i*i
            for j in keys:
                if j < i2:
                    break
                h[j] -= h[j // i] - hp
    print(h[n])



Measured memory_bytes: 6080
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

typedef long long ll ;
typedef double db;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define sf(a)		 scanf("%d",&a)
#define sfl(a)		scanf("%lld",&a)
#define sff(a,b)	 scanf("%d %d",&a,&b)
#define sffl(a,b)	scanf("%lld %lld",&a,&b)
#define pb(a)         push_back(a)
#define loop0(i,n)          for(int i=0;i<n;i++)
#define loop1(i,n)          for(int i=1;i<=n;i++)
#define loopab(a,b)       for(int i=a;i<=b;i++)
//#define mod			1e+9 + 7
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)     cout<<"Case "<<z<<": "<<x<<"\n"
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
ll mod = 1000000007;
ll pow_mod(ll x,ll y,ll p) 
{ 
    ll res = 1;    
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
  
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 
  
ll modInverse(ll n) 
{ 
    return pow_mod(n, mod-2, mod); 
} 

ll ncr_mod(ll x,ll y)
{
    ll ans=1;
    for(ll i=0;i<y;i++) ans=ans*(x-i)%mod;
    ll sub=1;
    for(ll i=1;i<=y;i++) sub=sub*i%mod;

    return ans*modInverse(sub)%mod;
}

int main()
{
	 ll n,a,b;
    cin>>n>>a>>b;
    ll ans =pow_mod(2,n,mod);
    ll x=ans-1;
    x=(x - ncr_mod(n,a)-ncr_mod(n,b))%mod;
    cout<<(x+mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main() {
    int N;
    string S;

    cin >> N;
    cin >> S;

    int ans = 1;

    for (int i = 1; i < N; i++) {
        if(S[i - 1] != S[i]) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512