akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<queue>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  vector<vector<int>> P(N, vector<int>(2));
  priority_queue<pair<string,vector<int>>> q;
  for(int i=0;i<N;i++){
    cin >> S.at(i)>> P.at(i).at(0);
    P.at(i).at(0) *= -1;    
    P.at(i).at(1) = i+1;
    q.push(make_pair(S.at(i), P.at(i)));
  }
  vector<int> a(N);
  for(int i=0;i<N;i++){
    auto j = q.top();
    a.at(i) = j.second.at(1);
    q.pop();
  }
  reverse(a.begin(), a.end());
  for(int i=0;i<N;i++){
    cout << a.at(i) <<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
 
int main() {
	int N;
	int total=0;
	int k = 0;
	int ten = 0;
	vector<int> points;
 
	cin >> N;
	points.resize(N);
	for (int i = 0; i < N; i++) {
		cin >> points[i];
		total += points[i];
	}
 
	sort(points.begin(),points.end());
 
	for (int i = 0; i < N; i++) {
		if (k == 0 && points[i] % 10 != 0) {
			k = points[i];
		}
		if (k == 0 && points[i] % 10 == 0) {
			ten += points[i];
		}
	}
 
	if (total % 10 == 0) {
		if (ten < k) {
			if (points[0] % 10 == 0) {
				k += points[0];
			}
			total -= k;
		}
		else {
			if (k == 0) {
				total = 0;
			}
			else {
				total -= k;
			}
		}
	}
 
	cout << total << endl;
 
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]

c0 = 0
c1 = 0
c2 = 0
c3 = 0

for i in range(len(s)):
    if s[i] == "AC":
        c0 += 1
    elif s[i] == "WA":
        c1 += 1
    elif s[i] == "TLE":
        c2 += 1
    else:
        c3 += 1

print("AC x ", str(c0))
print("WA x ", str(c1))
print("TLE x ", str(c2))
print("RE x ", str(c3))

Measured memory_bytes: 16156
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

//vector<int> t[n];
int visited[200005];

int main(){
    int n;
    ll k;
    cin >> n >> k;
    int a[n];
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    visited[0]=1;
    int i = 0;
    vector<int> v;
    int p;
    v.push_back(0);
    while(true){
        if(visited[a[i]]==0){
            visited[a[i]]=1;
            v.push_back(a[i]);
            i = a[i];
        }
        else{
            p = a[i];
            break;
        }
    }
    int j;
    rep(i,v.size()){
        if(v[i]==p)j=i;
    }
    ll d = v.size()-j;
    // cout << d << endl;
    // cout << j << endl;
    // cout << p << endl;
    // rep(i,v.size())cout << v[i];
    // cout << endl;
    ll size = v.size();
    if(k<size)cout << v[k]+1 << endl;
    else{
        k = k-size;
        k %= d;
        cout << v[j+k]+1 << endl;
    }
}

Measured memory_bytes: 5880
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3+5;
const int INF = 1e9;
const lli MOD = 1e9+7;


vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	vi m(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}
lli PROD(lli a, lli b, lli mod=MOD){
	a%=mod; b%=mod;
	return a*b % mod;
}
int dx[4]={-1,0,0,1}, dy[4]={0,1,-1,0};

// ---- コーディングはここから！ ('-')7



void solve(){
	int n; cin>>n;
	sieve();
	map<int,int>x;
	fore(i,0,n){
		int a; cin>>a;
		for(auto j:primes){
			if(j*j>a)break;
			if(a%j==0){
				x[j]++;
				while(a%j==0)a/=j;
			}
		}
		if(a>1)x[a]++;
	}
	int mx = 1;
	for(auto &[a,b]:x)mx= max(b,mx);
	if(mx==1){
		cout<<"pairwise coprime"<<ENDL;
		return;
	}
	if(mx!=n){
			cout<<"setwise coprime"<<ENDL;
			return;
	}
	cout<<"not coprime"<<ENDL;



}

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


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

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

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

int mypow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}

int main() {

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

	int N;
	cin >> N;

	int six, nine;
	vector<int> dp(N + 1, INF);
	dp[0] = 0;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= 6; j++) {
			six = mypow(6, j);
			nine = mypow(9, j);
			if (i >= six) dp[i] = min(dp[i], dp[i - six] + 1);
			if (i >= nine) dp[i] = min(dp[i], dp[i - nine] + 1);
		}
	}

	cout << dp[N] << "\n";

	return 0;
}

Measured memory_bytes: 640
a, b = map(int, input().split())
# a：電源タップ1個あたりの口数
# b：増やしたいタップ口数

def calc(a, b):
    ans_list = [a]
    add_tap = a
    
    # タップを増やさなくてもよい場合を考慮
    if b == 1:
        print(0)
    else:      
        for i in range(19):
            add_tap += a-1
            ans_list.append(add_tap)

        for i, value in enumerate(ans_list):
            if value >= b:
                print(i+1)
                break
            
calc(a, b)

Measured memory_bytes: 9192
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using LD = long double;
using Comp = complex<LD>;

const int MOD = 200'003;

vector<Comp> fft(vector<Comp> v, bool rev = false) {
    int n = v.size();
    ll i, j, j1, j2, m;
    
    for(i = 0, j = 1; j < n-1; j++) {
        for(ll k = n>>1; k > (i^=k); k >>= 1);
        if(i > j) swap(v[i], v[j]);
        
    }
    for(m = 2; m <= n; m *= 2) {
        LD deg = (rev ? -1 : 1) * 2 * acos(-1) / m;
        Comp wr(cos(deg), sin(deg));
        for(i = 0; i < n; i += m) {
            Comp w(1, 0);
            for(j1 = i, j2 = i + m/2; j2 < i+m; j1++, j2++) {
                Comp t1 = v[j1], t2 = w * v[j2];
                v[j1] = t1 + t2, v[j2] = t1 - t2;
                w *= wr;
                
            }
        }
    }
    if(rev) rep(i,n) v[i] *= 1.0 / n;
    return v;
}

vector<Comp> MultPoly(vector<Comp> P, vector<Comp> Q, bool resize = false) {
    if(resize) {
        ll s = 2;
        while(s*2 < P.size() + Q.size()) s *= 2;
        P.resize(s*2); Q.resize(s*2);
        
    }
    P = fft(P), Q = fft(Q);
    for(ll i = 0; i < P.size(); i++) P[i] *= Q[i];
    return fft(P, true);
}

void printpoly(vector<Comp> p, int ps){
    rep(i, ps){
        ll ans = round(p[i].real());
        if(ans < 0) cout << " - ";
        else if(i != 0 && ans >= 0) cout << " + ";
        cout << abs(ans);
        if(i != ps-1) cout << " x^" << (ps-i-1);
    }
    cout << endl;
}

void Main(){
    vi logtable(MOD, -1);
    vi powtable(MOD, -1);
    // j = 2^i mod p <-> table[j] = i
    ll now = 1;
    rep(i, MOD-1){
        logtable[now] = i;
        powtable[i] = now;
        now = (now * 2) % MOD;
    }
    
    int n; cin >> n;
    vll a(n);
    vector<Comp> cnt(MOD, 0); 
    rep(i, n) {
        ll x; cin >> x;
        a[i] = x;
        if(x != 0) cnt[logtable[x]] += 1;
        // cout << x << " " << logtable[x] << endl;
    }

    auto prod = MultPoly(cnt, cnt, true);
    
    /*
    rep(i, MOD*2-1){
        ll tmp = round(prod[i].real());
        if(tmp) cout << i << " " << tmp << endl;
    }
    */
    
    ll ans = 0;
    rep(i, MOD-1){
        ll tmp = round(prod[i].real());
        ll tmp2 = round(prod[i + MOD - 1].real());
        ans += powtable[i] * (tmp + tmp2);
    }
    
    rep(i, n){
        ans -= (a[i] * a[i]) % MOD;
    }
    cout << ans/2 << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 62260
import queue

_in = input()
Nlen = len(_in)
N = int(_in)
glen = 1
ans = 0

findq = queue.Queue()
checkq = queue.Queue()

findq.put('3')
findq.put('5')
findq.put('7')

while glen <= Nlen and not findq.empty():
  head = findq.get()
  checkq.put(head)
  if len(head)+1 <= Nlen:
    glen = min(glen, len(head))
    findq.put(head+'3')
    findq.put(head+'5')
    findq.put(head+'7')

while not checkq.empty():
  head = checkq.get()
  if int(head) > N:
    continue
  checker = 0b000
  for ch in head:
    if ch == '3':
      checker |= 0b100
    elif ch == '5':
      checker |= 0b010
    elif ch == '7':
      checker |= 0b001
    else:
      checker = 0b000
      break
  if checker == 0b111:
    ans += 1

print(ans)

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

int main(){
  int n;
  cin>>n;
  vector<int>d(n);
  for(int i=0;i<n;i++){
    cin>>d[i];
  }
  int mn=100000000;
  for(int i=0;i<n;i++){
    int l=0,r=0;
    for(int j=0;j<i;j++) l+=d[j];
    for(int j=i;j<n;j++) r+=d[j]; 
    mn=min(abs(l-r),mn);
  }
  cout<<mn<<endl;
}
                        


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, q, a[100000], l[100000], r[100000];

signed main() {
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < q; i++) {
		cin >> l[i] >> r[i];
		cout << upper_bound(a, a + n, r[i]) - lower_bound(a, a + n, l[i]) << endl;
	}
}



Measured memory_bytes: 5436
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,k,a[MAXN];
string str;
vector<int> bits;
int sum;
void decompose()
{
    for(int i=0;i<(int)str.size();i++) bits.push_back(str[i]-'0');
    reverse(bits.begin(),bits.end());
}
void mult9()
{
    int carry=0;
    for(int i=0;i<(int)bits.size();i++)
    {
        int result=bits[i]*9+carry;
        bits[i]=result%10; carry=result/10;
    }
    if(carry) bits.push_back(carry);
}
void find_sum()
{
    sum=0;
    for(int i=0;i<(int)bits.size();i++) sum+=bits[i];
}
void add9()
{
    int pos=0;
    bits[pos]+=9;
    sum+=9;
    while(bits[pos]>9)
    {
        bits[pos]-=10; sum-=9;
        if(pos==(int)bits.size()-1) bits.push_back(1); else bits[pos+1]++;
        pos++;
    }
}
int main()
{
    cin>>str;
    decompose();mult9();find_sum();
    for(int i=1;;i++)
    {
        add9();
        if(sum<=9*i)
        {
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 3068
#include <iostream>
#include <algorithm>

using namespace std;

int N, X;
int M[1000];

int main (){
    int sum = 0;
    cin >> N;
    cin >> X;
    for (int i = 0; i < N ; i++){
        cin >> M[i];
        X -= M[i];
        sum++;
    }
    sort(M, M+N);
    for (int i = 0; X >= M[0] ;X -= M[0], sum++){}
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int right_side_table[ 6 ][ 6 ] =
{
	//front=
	// 1    2    3    4    5    6
	{ -1 ,  3 ,  5 ,  2 ,  4 , -1 },	//upper=1
	{  4 , -1 ,  1 ,  6 , -1 ,  3 },	//2
	{  2 ,  6 , -1 , -1 ,  1 ,  5 },	//3
	{  5 ,  1 , -1 , -1 ,  6 ,  2 },	//4
	{  3 , -1 ,  6 ,  1 , -1 ,  4 },	//5
	{ -1 ,  4 ,  2 ,  5 ,  3 , -1 },	//6
};

int search_index( const int* number_table , int number )
{
	for( int i = 0 ; i < 6 ; i++ )
	{
		if( number_table[ i ] == number )
		{
			return i;
		}
	}
	return 0;
}

int main( int argc , char** argv )
{

    int number_table[ 6 ];
    scanf( "%d %d %d %d %d %d" ,
        &number_table[ 0 ] ,
        &number_table[ 1 ] ,
        &number_table[ 2 ] ,
        &number_table[ 3 ] ,
        &number_table[ 4 ] ,
        &number_table[ 5 ] );
 
	int question_count;
	scanf( "%d" , &question_count );
	for( int i = 0 ; i < question_count ; i++ )
	{
		int upper;
		int front;
		scanf( "%d %d" , &upper , &front );

		int index_upper = search_index( number_table , upper );
		int index_front = search_index( number_table , front );
		int index_right = right_side_table[ index_upper ][ index_front ] - 1;

		printf( "%d\n" , number_table[ index_right ] );
	}
	return 0;
}

Measured memory_bytes: 1024
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val n = readInteger()
    val tList = readIntegerList()
    val vList = readDoubleList()

    val times = tList.sum() * 2 + 1
    val maxVs = DoubleArray(times) { Double.MAX_VALUE }
    maxVs[0] = 0.0
    maxVs[times - 1] = 0.0
    var curT = 0
    for ((i, t) in tList.withIndex()) {
        for (j in 0..(2 * t)) {
            if (curT + j in 0 until times) {
                maxVs[curT + j] = Math.min(maxVs[curT + j], vList[i]) // 境界値難しい...
            }
        }
        curT += 2 * t
    }

    for (i in 0 until (times - 1)) {
        maxVs[i + 1] = Math.min(maxVs[i + 1], maxVs[i] + 0.5)
    }

    for (i in (times - 1) downTo 1) {
        maxVs[i - 1] = Math.min(maxVs[i - 1], maxVs[i] + 0.5)
    }

    var ans = 0.0
    var preV = maxVs.first()
    for (v in maxVs.drop(1)) {
        ans += preV + v
        preV = v
    }
    println(ans / 4)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 40916
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) throws IOException {
		// System.out.println("Hello world");
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		while(true){
		
		int n = 2;
		String c = br.readLine();
		
		if(c == null)
			break;
		
		long[] arr = new long[n];
		for(int i = 0; i < n; i++){
		if(c.indexOf(" ") !=  -1){
		String str = c.substring(0, c.indexOf(" "));
		arr[i] = Long.parseLong(str);
		c = c.substring(c.indexOf(" ") + 1);
		}
		else{
		arr[i] = Long.parseLong(c);
		}
		}

		if(arr[1] < arr[0]){
			long re = arr[1];
			arr[1] = arr[0];
			arr[0] = re;
		}
		
		long[] arr2 = arr.clone();
		long amari = 1;
		while(arr2[0] !=0){
			amari = arr2[1] % arr2[0];
			if(amari == 0) break;
			arr2[1] = arr2[0];
			arr2[0] = amari;
		}
		


		long i = 1;
		while((arr[0]*i) % arr[1] != 0){
			i++;
		}
		
		System.out.println(arr2[0] + " " + arr[0]*i);
		
		}
	}

}

Measured memory_bytes: 9348
#include<iostream>
#include<string>
#include<queue>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;
#define fr first
#define sc second
typedef pair<string,int> P;
struct edge{
  int to;
  string cost;
  edge(){}
  edge(int to,string cost):to(to),cost(cost){};
};
vector< vector<edge> > info;
int n,a,s,g;
string d[40][400];
string Dijkstra(){
  priority_queue< P,vector<P>,greater<P> > que;
  for(int i=0;i<n;i++) for(int j=0;j<400;j++) d[i][j] = "";
  que.push(P("",s));
  d[s][0] = "";
  while(!que.empty()){
    P p = que.top();
    int now = p.sc;
    string nowstr = p.fr;
    que.pop();
    if( now == g ) return (nowstr.size() >= 300 ? "NO" : p.fr);
    if( d[now][nowstr.size()] != "" && d[now][nowstr.size()] < nowstr ) continue;
    for(int i = 0 ; i < info[now].size() ; i++ ){
      edge e = info[now][i];
      string next_str = nowstr + e.cost;
      if( next_str.size() >= 400 ) continue;
      if( d[e.to][next_str.size()] == "" || next_str < d[e.to][next_str.size()] ){
        d[e.to][next_str.size()] = next_str;
        que.push(P(next_str , e.to ));
      }
    }
  }
  return "NO";
}
int main(){
  while(cin >> n >> a >> s >> g , n){
    info.resize(n);
    for(int i = 0 , x , y ; i < a ; i++ ){
      string s;
      cin >> x >> y >> s;
      info[x].push_back(edge(y,s));
    }
    cout << Dijkstra() << endl;
    info.clear();
  }
}

Measured memory_bytes: 15516
#include<iostream>
using namespace std;
int G[51];
main()
{
	int n,m;cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;cin>>a>>b;
		G[a]++,G[b]++;
	}
	for(int i=0;i++<n;)cout<<G[i]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  string s;cin>>s;
  vi pl(222222),mi(222222);
  ll one = 0;
  for(auto a:s)one += (a == '1');
  if(one == 0){
    for(int i=0;i<n;i++)
      cout<<1<<endl;
    return 0;
  }

  pl[0] = mi[0] = 1;
  for(int i=0;i<n;i++){
    pl[i+1] = (pl[i]*2)%(one+1);
    if(one > 1)
      mi[i+1] = (mi[i]*2)%(one-1);
  }
  ll sum = 0,sum2 = 0;
  for(int i=0;i<n;i++){
    if(s[i] == '1'){
      sum += pl[n-i-1];
      sum2 += mi[n-i-1];
    }
  }
  for(int i=0;i<n;i++){
    if(s[i] == '1'){
      if(one == 1){
	cout<<0<<endl;
	continue;
      }
      ll ans = 0;
      ll ho = sum2 - mi[n-i-1];
      ho %= one-1;
      while(ho){
	ll cnt = __builtin_popcountll(ho);
	ho %= cnt;
	ans++;
      }
      cout<<ans+1<<endl;
    }else{
      ll ans = 0;
      ll ho = sum + pl[n-i-1];
      ho %= one+1;
      while(ho){
	ll cnt = __builtin_popcountll(ho);
	ho %= cnt;
	ans++;
      }
      cout<<ans+1<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 7036
#include<bits/stdc++.h>
using namespace std;
const int N=1<<20;
long long a[N];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",a+i);
	}
	if(a[n-1]!=2)
	{
		puts("-1");
		return 0;
	}
	long long mi=2,ma=3;
	for(int i=n-2;~i;i--)
	{
		if((mi+a[i]-1ll)/a[i]*a[i]>ma || ma/a[i]*a[i]+a[i]-1ll<mi)
		{
			puts("-1");
			return 0;
		}
		mi=(mi+a[i]-1ll)/a[i]*a[i];
		ma=ma/a[i]*a[i]+a[i]-1ll;
	}
	printf("%lld %lld\n",mi,ma);
	return 0;
}


Measured memory_bytes: 1024
def mat_dot(A, B, mod):
    assert len(A[0]) == len(B), 'invalid_size'
    
    L = len(A)
    M = len(A[0])
    N = len(B[0])
    
    res = [[0]*N for _ in range(L)]
    
    for i in range(L):
        for j in range(N):
            a = 0
            for k in range(M):
                a = (a+A[i][k]*B[k][j]) % mod
            res[i][j] = a
            
    return res

def mat_pow(A, x, mod):
    N = len(A)
    res = [[0]*N for _ in range(N)]
    for i in range(N):
        res[i][i] = 1
    for i in range(x.bit_length()):
        if 2**i & x:
            res = mat_dot(res, A, mod)
        A = mat_dot(A, A, mod)
    return res

N, K = map(int, input().split())

A = [list(map(int, input().split())) for _ in range(N)]
A = list(map(list, zip(*A)))
mod = 10**9+7
B = mat_pow(A, K, mod)
ans = 0
for i in range(N):
    for j in range(N):
        ans = (ans + B[i][j]) % mod
print(ans)


Measured memory_bytes: 41324
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (p,q,r) = get!(usize, usize, usize);
    println!("{}", min!(p+q, q+r, r+p));
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    ll n;
    string s;
    cin>>n;
    cin>>s;
    vector< pll > pre(n+5), pos(n+5);
    int i;
    FOR0(i, n)
    {
        pre[i] = pll(0, 0);
        if(s[i]=='.') pre[i].ff++;
        else pre[i].ss++;
        if(i!=0)
        {
            pre[i].ff += pre[i-1].ff;
            pre[i].ss += pre[i-1].ss;
        }
    }
    FORD(i, n-1, 0)
    {
        pos[i] = pll(0, 0);
        if(s[i]=='.') pos[i].ff++;
        else pos[i].ss++;
        if(i!=n-1)
        {
            pos[i].ff += pos[i+1].ff;
            pos[i].ss += pos[i+1].ss;
        }
    }
    ll ans = inf;
    ll cur = 0;
    FOR0(i, n)
    {
        ll pr = 0, po = 0;
        if(i!=0) pr = pre[i-1].ss;
        po = pos[i].ff;
        cur = pr + po;
        ans = MIN2(ans, cur);
    }
    cur = pre[n-1].ss;
    ans = MIN2(ans, cur);
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}


Measured memory_bytes: 6804
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}


bool isPrime(int n)
{
    if(n==1)
        return false;
    for(int i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}
const int MX=3e5+100;
int n,arr[MX],cm[MX];
int Left,Right,add;
bool can(int x){
 for(int i=1,j=x;j<=n;++i,++j){
  if(cm[j]-cm[i-1]+add>=x){
  Left=i,Right=j;
   return true;}
 }
 return false;
}
bool checkP(int n){
 vector<int>vr;
 while(n!=0){
 int a=n%10;
  n/=10;
 vr.push_back(a);}
 if(vr[0]==vr[4]&&vr[1]==vr[3])
 return true;
 return false;
}
int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);

int n=RD();

cout<<n/3;

 }


Measured memory_bytes: 256
# -*- coding:utf-8 -*-

import sys
input = sys.stdin.readline

M,D = map(int, input().split())
ans = 0
for i in range(1, M+1):
    for j in range(22, D+1):
        a = int(str(j)[0])
        b = int(str(j)[1])
        if a >= 2 and b >= 2:
            if a * b == i:
                ans += 1

print(ans)


Measured memory_bytes: 39024
#include <iostream>

using namespace std;

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

		for (int posY = 0; posY <= 100; posY++) {
				for (int posX = 0; posX <= 100; posX++) {
						int H = -1; 
						for (int i = 0; i < N; i++) {
								if (h[i]) {
										int t = h[i] + abs(x[i] - posX) + abs(y[i] - posY);
										if (H == -1) {
												H = t;
										} else if (H != t) {
												H = -2;
												break;
										}
								}
						}

						if (H == -2) continue;

						for (int i = 0; i < N; i++) {
								if (!h[i]) {
										int dist = abs(x[i] - posX) + abs(y[i] - posY);
										if (H > dist) {
												H = -2;
												break;
										}
								}
											
						}

						if (H == -2) continue;
						cout << posX << " " << posY << " " << H << endl;
				}
		}
		return 0;
}


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

int main(){
  int N;
  cin>>N;
  
  bool can=false;
  
  rep(i,25)rep(j,15)
    if(4*i+7*j==N)can=true;
  
  if(can)cout<<"Yes"<<endl;
  else   cout<<"No"<<endl;
  return 0;
}

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

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

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


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W, N;
    cin >> H >> W >> N;
    map<pii, ll> st;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        for (ll dx = -1; dx <= 1; dx++) {
            const ll x = b + dx;
            if (x < 1 or x >= W - 1) {
                continue;
            }
            for (ll dy = -1; dy <= 1; dy++) {
                const ll y = a + dy;
                if (y < 1 or y >= H - 1) {
                    continue;
                }
                st[make_pair(x, y)]++;
            }
        }
    }
    const ll total = (H - 2) * (W - 2);
    vector<ll> num(10, 0);
    num[0] = total - st.size();
    for (const auto& p : st) {
        num[p.second]++;
    }
    for (int i = 0; i < 10; i++) {
        cout << num[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 56576
/*   --------------------
    |       LOSER        |
    |     ~NOOBOSS~      |
     --------------------
*/
#include <bits/stdc++.h>
using namespace std;

#define      inl(x)              scanf("%lld",&x)
#define      in(x)               scanf("%d",&x)
#define      mxx                 10000000000000
#define      mnn                 -10000000000000
#define      Y()                 cout<< "YES" <<endl
#define      N()                 cout << "NO"<<endl
#define      endl                "\n"
#define      max_3(a,b,c)        max(a, max(b,c))
#define      max_4(a,b,c,d)      max(a,max(b,max(c,d)))
#define      min_3(a,b,c)        min(a, min(b,c))
#define      min_4(a,b,c,d)      min(a,min(b,min(c,d)))
#define      gcd(a,b)            __gcd(a,b)
#define      lcm(a,b)           (a*b)/gcd(a,b)
#define      loser               return 0
#define      ll                  long long
#define      PI                  acos(-1)
#define      mem(a,v)            memset(a,v,sizeof(a))
#define      SORT(v)             sort(v.begin(),v.end())
#define      REV(v)              reverse(v.begin(),v.end())
#define      O(x)                cout<<x<<endl
#define      B                   begin()
#define      E                   end()
#define      V                   vector
#define      F                   first
#define      S                   second
#define      PSB                 push_back
#define      EMB                 emplace_back
#define      MP                  make_pair
#define      PII                 pair<int,int>
#define      MII                 map<int,int>
#define      InTheNameOfGod      ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
const ll MOD = 998244353;
//auto it=std:: unique(v.B,v.E);
//v.resize(std::distance(v.B,it));
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
/*-----*/
#define bug1(a)  cout<<a<<endl;
#define bug2(a,b)  cout<<a<<" "<<b<<endl;
#define bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
/*----*/
ll power(ll n,ll p){if(p==0) return 1;if(p==1)return n;if(p%2)return power(n,p-1)*n;else{ll x=power(n,p/2);return x*x;}}
ll binpow(ll a, ll b){ll res = 1;while (b > 0) {if (b & 1)res*=a;a*=a;b>>=1;}return res;}
ll fact(ll num){ll fac=1;while(num!=1){fac=fac*num;num--;}return fac;}
string to_binary(int x) {string s;while(x > 0) {s += (x % 2 ? '1' : '0');x /= 2;}reverse(s.begin(), s.end());return s;}
ll nsum(ll num){return (num*(num+1))/2;}
/*-----*/
const int N=2e5+5;

/*-----*/
//vector<int> v[202];

/*-----*/
int main(){
   InTheNameOfGod

       ll test=1;
       //cin>>test;
       while(test--){
           ll n,i,ans=0;
           string s;
           cin>>n;
           for(i=1;i<=3;++i){
            ans+=power(n,i);
           }
           cout<<ans<<endl;
        }
	loser;
}
///////LeArN MoRe AnD Wait FoR ThE Result///////


Measured memory_bytes: 3608
long a,v,c;f(char*x,char*y){c=*y-*x;}main(){for(;read(c=0,&c,1)|v;v&66&&printf(a==0x414144494e4e5559?v=0,"AIZUNYAN":"%c",v))v=a=v>>8|c<<56,qsort(&a,8,1,f);}

Measured memory_bytes: 524
#include<stdio.h>
int main(void)
{
	int r,g,b;
	scanf("%d%d%d",&r,&g,&b);
	if((r*100+g*10+b)%4==0){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
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: 9104
import itertools
def has_duplicates(seq):
    return len(seq) != len(set(seq))

N = int(input())
L = list(map(int,input().split()))
L.sort()

C = list(itertools.combinations(L,3))

ans = 0
for i in range(len(C)):
    if has_duplicates(list(C[i])):
        continue
    elif list(C[i])[2] >= list(C[i])[0] + list(C[i])[1]:
        continue
    else:
        ans += 1

print(ans)

Measured memory_bytes: 20608
#include<stdio.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)

int n, A[50];

// 入力値のMから選んだ要素を引いていく再帰関数
int solve(int i, int m){
  if (m==0) return 1;
  if (i >= n) return 0;
  int res = solve(i+1, m) || solve(i+1, m - A[i]);  // A[i] を使わない || A[i]を使う  // m-A[i] で A[i] を使うことを意味している
  return res;
}

int main(int argc, char const *argv[]){
  int q, M, i;

  scanf("%d", &n);
  rep(i, n) scanf("%d", &A[i]);
  scanf("%d", &q);
  
  rep(i, q){
    scanf("%d", &M);
    if (solve(0, M)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}



Measured memory_bytes: 2624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  int s;
  cin >> s;
  int a = s / 100;
  int b = s - (a*100);
  if(a >= 1 && a <= 12) {
    if(b >= 1 && b <= 12) {
      cout << "AMBIGUOUS" << endl;
      return 0;
    }
  }
  if(a > 12 || a == 0) {
    if(b <= 12) {
      if(b == 0) {
        cout << "NA" << endl; 
        return 0;
      }
      cout << "YYMM" << endl;
      return 0;
    }
  } else if(b > 12 || b == 0) {
    if(a <= 12) {
      if(a == 0) {
        cout << "NA" << endl; 
        return 0;
      }
      cout << "MMYY" << endl;
      return 0;
    }
  }
  cout << "NA" << endl;
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;


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

	int n;
	cin >> n;
	
	vi a(n);
	for(auto& el : a) cin >> el;
	
	vector<bool> balls(n);
	
	vi ans;
	for(int i = n ; i > 0 ; --i)
	{
		int cnt = 0;
		for(int j = i + i ; j <= n ; j += i)
		{
			cnt += balls[j - 1];
		}
		
		if(cnt % 2 != a[i - 1])
		{
			ans.pb(i);
			balls[i - 1] = true;
		}
	}
	
	cout << sz(ans) << nl;
	for(int e : ans) cout << e << " ";

	return 0;
}

Measured memory_bytes: 2424
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
std::vector<ll> cache;

#if 0
//
ll findAB(ll re)
{
    if (cache[re] != -1)
    {
        return cache[re];
    }
    //
    ll ans = 0;

    //
    ll A;
    for (A = 1; (A * A) < re; ++A)
    {
        if (re % A == 0)
        {
            ans += 2;
        }
    }
    if (A * A == re)
    {
        ans += 1;
    }
    cache[re] = ans;
    return ans;
}

//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    cache.resize(N, -1);
    ll ans = 0;
    for(ll C=1;C<N;++C)
    {
        ll re = N - C;
        ans += findAB(re);
    }
    cout << ans;
    return 0;
}
#endif

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    //
    ll cnt = 0;
    ll A;
    for(A=1;A<N;++A)
    {
        for (ll B = 1; A * B < N; ++B)
        {
            cnt += 1;
        }
    }
    if (A * A == N)
    {
        ++cnt;
    }
    cout << cnt;
}

Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
ll mod = 1e9 + 7;

int A,B;
int x[111];
ll coudp[111][111][5555];
string divide[4] = { "dream","dreamer","erase","eraser" };
int main()
{
	ll n, s;
	cin >> n;
	s = n % 11;
	if (s == 0) cout << 2 * (n / 11) << endl;
	else if (s < 7) cout << 2 * (n / 11) + 1 << endl;
	else cout << 2 * (n / 11) + 2 << endl;
		
}
	

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


int main() {
    
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    cout<<60*(h2 -h1) + m2-m1-k<<endl;


 return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int n,a[100010],l[10];
vector<int> v;
int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a[i];
		v.push_back(a[i]);
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	if (v[0]==0){
		if (v.size()>2){
			cout<<"No"<<endl;
			return 0;
		}
		if (v.size()==1){
			cout<<"Yes"<<endl;
			return 0;
		}
		else if (v.size()==2){
			for (int i=0;i<n;i++){
				if (a[i]==v[0]) l[0]++;
				if (a[i]==v[1]) l[1]++;
			}
			if (l[0]*2==l[1])
				cout<<"Yes"<<endl;
			else
				cout<<"No"<<endl;
		}
		return 0;
	}
	if (v.size()!=3){
		cout<<"No"<<endl;
		return 0;
	}
	for (int i=0;i<n;i++){
		if (a[i]==v[0]) l[0]++;
		if (a[i]==v[1]) l[1]++;
		if (a[i]==v[2]) l[2]++;
	}
	if (l[0]==l[1]&&l[1]==l[2]&&((v[0]^v[1])==v[2]||(v[1]^v[2])==v[0]||(v[0]^v[2])==v[1]))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1148
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/
#include <stdbool.h>/*bool型*/
#include <limits.h> /*限界*/

#define rep(i, n) for(int  i = 0; i < (n); i++)
#define max(a,b) ((a>b)?a:b)
#define ABS(a) (((a)>(0))?a:-(a))
#define LL long long
#define MOD 1000000007//10^9+7(素数)

int main(void)
{
  int a, b, c;

scanf("%d %d %d", &a, &b, &c);

printf("%d %d %d", c, a, b);
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;

ll ind(ll y, ll x, ll w) { return y * w + x; }
void Main()
{
    ll H, W;
    cin >> H >> W;

    vector<string> S(H);
    rep(i, H) cin >> S[i];
    
    
    // Warshall–Floyd 
    ll INF = 1e18;
    vector<vector<ll> > d(H * W, vector<ll>(W * H, INF));
    rep(y, H) {
        rep(x, W) {
            if (S[y][x] == '#') continue;
            if (0 <= y - 1 && S[y-1][x] == '.') {
                d[ind(y-1, x, W)][ind(y, x, W)] = 1;
                d[ind(y, x, W)][ind(y-1, x, W)] = 1;
            }
            if (0 <= x - 1 && S[y][x-1] == '.') {
                d[ind(y, x-1, W)][ind(y, x, W)] = 1;
                d[ind(y, x, W)][ind(y, x-1, W)] = 1;
            }
            if (y + 1 < H && S[y+1][x] == '.') {
                d[ind(y+1, x, W)][ind(y, x, W)] = 1;
                d[ind(y, x, W)][ind(y+1, x, W)] = 1;
            }
            if (x + 1 < W && S[y][x+1] == '.') {
                d[ind(y, x+1, W)][ind(y, x, W)] = 1;
                d[ind(y, x, W)][ind(y, x+1, W)] = 1;
            }
        }
    }
    ll n = H * W;
    rep(k, n) {
        rep (i, n) {
            rep (j, n) {
                if (d[i][k] < INF && d[k][j] < INF) {
                    d[i][j] = min(
                        d[i][j], d[i][k] + d[k][j]);
                }
            }
        }        
    }

    
    ll res = 0;
    rep(i, n) {
        rep(j, n) {
            if (i == j) continue;
            if (d[i][j] < INF) {
                res = max(res, d[i][j]);
            }
        }
    }

    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 4872
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n;cin>>n;
    vector<ll> v(n);
    ll sum=0;
    REP(i,n){
        ll a; cin>>a;
        sum+=a;
        v[i]=sum;
    }
    ll m=1e15;
    REP(i,n-1){
        m=min(m, abs(v[i]*2-sum));
    }
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 4816
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define flash ios_base::sync_with_stdio(false);     cin.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(v) v.begin(),v.end()
#define f first
#define s second



using namespace std;

int main()
{
  flash
  ll n,w;
  cin>>n>>w;

  std::vector<int> wt(n);
  std::vector<int> v(n);
  for(int i=0; i <n;i++){

    cin>>wt[i]>>v[i];

  }

  ll dp[n+1][w+1];

  for(int i=0;i<=n;i++){

    for(int j=0;j<=w;j++){

      if(i==0 || j==0)
        dp[i][j]=0;
      else if( wt[i-1]<=j )
        dp[i][j] = max ( v[i-1] + dp[i-1][j-wt[i-1]] , dp[i-1][j] );
      else
        dp[i][j] = dp[i-1][j];
    }

  }
  cout<<dp[n][w]<<"\n";


}


Measured memory_bytes: 82540
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}




int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> A(n),B(m);
    cin>>A>>B;
    vector<vector<ll>> dp(n+1,vector<ll>(m+1,0));
    for(int i=0;i<=m;i++){dp[0][i]=1;}
    for(int i=0;i<=n;i++){dp[i][0]=1;}
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(A[i-1]==B[j-1]){dp[i][j]=dp[i-1][j-1];}
        }
        for(int j=2;j<=m;j++){dp[i][j]+=dp[i][j-1]; dp[i][j]%=MOD;}
        for(int j=1;j<=m;j++){dp[i][j]+=dp[i-1][j]; dp[i][j]%=MOD;}
    }
    cout<<dp[n][m]<<endl;
    
    
    return 0;
}


Measured memory_bytes: 31616