akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int a[100100], ind[100100];
void out(){
    cout<<"Impossible"<<endl;
    exit(0);
}
int main(){
    int i, N, max1=-1;
    cin>>N;
    for(i=0; i<N; i++){
        cin>>a[i];
        ind[a[i]]++;
        max1 = max(max1, a[i]);
    }
    if(ind[max1] <= 1) out();
    if(max1 % 2 == 0){
        if(ind[max1 / 2] != 1) out();
        for(i=max1/2+1; i<=max1-1; i++){
            if(ind[i] < 2) out();
        }
        for(i=max1/2-1; i>=0; i--){
            if(ind[i]) out();
        }
        cout<<"Possible"<<endl;
    }else{
        if(ind[max1/2+1] != 2) out();
        for(i=max1/2+2; i<=max1-1; i++){
            if(ind[i] < 2) out();
        }
        for(i=max1/2; i>=0; i--){
            if(ind[i]) out();
        }
        cout<<"Possible"<<endl;
    }
}


Measured memory_bytes: 256
def int_raw():
    return int(raw_input())
 
def words_raw():
    return raw_input().split()
 
def ints_raw():
    return map(int, words_raw())

N, A, B, C = ints_raw()
l = [int_raw() for _ in range(N)]

INF = 1e10
def cost(idx, a, b, c):
	if idx == N:
		if min(a,b,c)  == 0:
			return INF
		else:
			return abs(a - A) + abs(b - B) + abs(c - C) - 30
	val1 = cost(idx + 1, a, b, c)
	val2 = cost(idx + 1, a + l[idx], b, c) + 10
	val3 = cost(idx + 1, a, b + l[idx], c) + 10
	val4 = cost(idx + 1, a, b, c + l[idx]) + 10
	return min(val1, val2, val3, val4)

print cost(0, 0, 0, 0)


Measured memory_bytes: 2696
n ,a,b= map(int,input().split())
cur = (b-a-1)
if cur %2==0:
    left = a-1
    right = n-b
    if b-a == 1:
        print(min(n-a,b-1))
    else:
        cur =0
        if left<right:
            cur = left
            a = 1
            b -= left
        else:
            cur = right
            a+=right
            b=n
        if b-a ==1:
            print(cur+1)
        else:
            need = b-a
            if need %2 ==0:
                need+=2
            else:
                need+=1
            print(cur+(need)//2)
else:
    cur +=1
    print(cur//2)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

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

    vector<pair<int, int>> A;

    for (int i = 0; i < N; ++i)
    {
        int a;
        cin >> a;
        A.push_back(make_pair(a, i + 1));
    }

    sort(A.begin(), A.end(), [](pair<int, int> x, pair<int, int> y) { return x.first < y.first; });

    for (int i = 0; i < N; ++i)
    {
        cout << A[i].second;

        if (i < N - 1) cout << " ";
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 1780
// https://beta.atcoder.jp/contests/abc073
// status:

#define SUBMIT
//#define DEBUG

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

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(2
6 8
3 3
)");
#endif
    int N;
    int ans = 0;
    stream >> N;
    for (int i = 0; i < N; ++i) {
        int left, right;
        stream >> left >> right;
        ans += 1 + (right - left);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Jun 28 20:59:50 JST 2020
 **/

std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());

template <class T, class S> T make_vec(S x) { return x; }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return std::vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

Int D;
std::vector<Int> c;
std::vector<std::vector<Int>> s;
constexpr Int K = 26;

Int calc_score(const std::vector<Int>& a) {
    assert(a.size() == D);
    Int ret = 0;
    Int sum = std::accumulate(c.begin(), c.end(), 0LL);
    Int cur_minus = 0;
    std::vector<Int> last(K, -1);
    REP(d, D) {
        cur_minus += sum - c[a[d]] * (d - last[a[d]]);
        ret += s[d][a[d]] - cur_minus;
        last[a[d]] = d;
    }
    return ret;
}

std::chrono::system_clock::time_point start_time;
std::vector<Int> ans(D);
Int best_score;
std::vector<Int> local_search(Int t) {
    std::vector<Int> nxt = ans;
    if (t % 10 == 0) {
        Int idx = rnd() % (D - 1);
        std::swap(nxt[idx], nxt[idx + 1]);
    } else {
        Int idx = rnd() % D;
        nxt[idx] = rnd() % K;
        return nxt;
    }
    return nxt;
}
void hill_climb() {
    std::vector<Int> cnt(2);
    REP(t, 1e9) {
        std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
        if (std::chrono::duration_cast<std::chrono::milliseconds>(now - start_time).count() > 1700) break;
        // change
        auto nxt = local_search(t);
        Int nxt_score = calc_score(nxt);
        if (nxt_score >= best_score) {
            dump(t, best_score, nxt_score);
            best_score = nxt_score;
            ans = std::move(nxt);
            cnt[t % 2]++;
        }
    }
    dump(cnt);
}

signed main() {
    start_time = std::chrono::system_clock::now();
    // input
    std::cin >> D;
    c.resize(K);
    s = make_vec<Int>(D, K, 0);
    REP(i, K) std::cin >> c[i];
    REP(i, D) REP(j, K) std::cin >> s[i][j];

    // hoge
    ans.resize(D);
    REP(i, D) ans[i] = i % K;
    best_score = calc_score(ans);
    hill_climb();
    // dump(calc_score(ans));
    // REP(i, D) { ans[i] = std::max_element(s[i].begin(), s[i].end()) - s[i].begin(); }
    // dump(calc_score(ans));

    // output
    for (Int x : ans) std::cout << x + 1 << "\n";
    std::cout << std::endl;
}


Measured memory_bytes: 3712
import java.util.*;
import java.lang.*;

/**
 * SumOfInteger
 */
public class Main {

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

        out_of_loop: while (true) {
            int n = Integer.parseInt(sc.next());
            int s = Integer.parseInt(sc.next());

            if (n == 0 && s == 0) {
                break out_of_loop;
            }

            System.out.println(dfs(n, s, 0, 0, -1));
        }

        sc.close();
    }

    private static int dfs(int maxdepth, int target, int sum, int depth, int lastNum) {

        // System.out.println("depth:" + depth + " sum:" + sum);
        if (depth == maxdepth) {
            if (sum == target) {
                return 1;
            } else {
                return 0;
            }
        }

        int ans = 0;

        for (int i = 0; i < 10; i++) {
            if (lastNum < i) {
                ans += dfs(maxdepth, target, sum + i, depth + 1, i);
            }
        }

        return ans;
    }
}


Measured memory_bytes: 26252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin>>n>>m;
  
  int ans=0;
  if(n>1) ans+=n*(n-1)/2;
  if(m>1) ans+=m*(m-1)/2;
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
# # input = sys.stdin.buffer.readline
# def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

from string import ascii_lowercase
# print(ascii_lowercase)
d = dict(zip(ascii_lowercase, range(26)))
# print(d['a'])
N = int(input())

def nexts(s, n, maxnum):
    if n == N:
        print(s)
        return
    for i in range(maxnum+1):
        nexts(s + ascii_lowercase[i], n+1, max(maxnum,i+1))

nexts('a', 1, 1)


Measured memory_bytes: 5024
#include <iostream>

using namespace std;

int main()
{
	int a, b, c;
	int x;
	int ans = 0;

	cin >> a >> b >> c >> x;
	
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (x == (i * 500 + j * 100 + k * 50)) {
					ans++;
				}
			}
		}
	}
	
	cout << ans << endl;
	
	return (0);
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> broken(n+1);
    for (int i = 0; i < m; ++i) {
        int a;
        cin >> a;
        broken[a] = 1; 
    }
    vector<int> dp(n+2);
    const int MOD = 1000000007;
    dp[n] = 1;
    for (int i = n-1; i >= 0; --i) {
        if (broken[i]){
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i+1] + dp[i+2]) % MOD;   
    }
    cout << dp[0] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1.0)
#define pb push_back
#define vi vector<int>
#define mapii map<int , int>
#define mapci map<char, int>
#define mapsi map<string,int>
#define FOR(i,n) for(int i = 0;i<n;i++)
#define CP(n) cout<<"Case "<<n<<": "
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
#define MAX 1000007
#define all(x)(x.begin(),x.end())
#define debug(x,c) cout<<x<<": "<<c<<" ";
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	FOR(i,n)cin>>a[i];
	sort(a,a+n);
	int sum = 0;
	FOR(i,k)sum+=a[i];
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);
//ios::sync_with_stdio(false);

ll add(ll k)
{
    return (k * (k + 1) / 2) % mod;
}

signed main()
{
    ll n, k, ans = 0;
    cin >> n >> k;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];

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

            if (v[i] > v[j])
            {
                if (i < j)
                {
                    ans += add(k);
                    ans %= mod;
                }else{
                    ans+=add(k-1);
                    ans%=mod;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>

using namespace std;

int a,b,c,x,y;
int ans[5];

int main(){

    cin>>a>>b>>c>>x>>y;

    ans[0]=a*x+b*y;
    if(x>y){
        ans[1]=c*2*y+a*(x-y);
        ans[2]=c*2*x;
    }else{
        ans[1]=c*2*x+b*(y-x);
        ans[2]=c*2*y;
    }

    sort(ans,ans+3);


    
    cout<<ans[0]<<endl;
 
    return 0;
}

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

string u="##..";
string v="#.#.";

signed main(){
    int N;
    cin>>N;

    string S,T;
    string ret;
    while(true){
       bool update=false;
       rep(i,4){
            string SS=S+u[i];
            string TT=T+v[i];
            cout<<SS<<endl<<TT<<endl;
            cin>>ret;
            if(ret=="end")return 0;
            if(ret=="T"){
                S=SS;T=TT;
                update=true;
                break;
            }
       }
       if(!update)break;
    }

    while(true){
       bool update=false;
       rep(i,4){
            string SS=u[i]+S;
            string TT=v[i]+T;
            cout<<SS<<endl<<TT<<endl;
            cin>>ret;
            if(ret=="end")return 0;
            if(ret=="T"){
                S=SS;T=TT;
                update=true;
                break;
            }
       }
       if(!update)break;
    }
    return 0;
}


Measured memory_bytes: 724
use std::io::*;
use std::cmp;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn read_vec_char() -> Vec<char> {
    read::<String>().chars().collect()
}

fn read_mat<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_mat_char(n: usize) -> Vec<Vec<char>> {
    (0..n).map(|_| read_vec_char()).collect()
}

fn main() {
    let v = read_vec::<usize>();
    let (n,k,q) = (v[0],v[1],v[2]);
    let a = read_vec::<usize>();
    let mut xs: Vec<usize> = Vec::new();
    for i in 0..n-k+1 {
        let mut m = a[i];
        for j in i+1..i+k {
            m = cmp::min(m,a[j]);
        }
        if !xs.contains(&m) {
            xs.push(m);
        }
    }
    let mut ans = usize::max_value();
    for x in xs {
        let mut ups: Vec<usize> = Vec::new();
        for sub in a.split(|&y| y < x) {
            let l = sub.len();
            if l < k {
                continue;
            }
            let mut ssub = sub.to_vec();
            ssub.sort();
            let mut ssub2 = ssub[0..l-k+1].to_vec();
            ups.append(&mut ssub2);
        }
        if ups.len() >= q {
            ups.sort();
            ans = cmp::min(ans,ups[q-1]-x);
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long int ll;
using namespace std;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string S;
cin>>S;
int n=S.length();
int len=0;
string check="ACGT";
for(int i=0;i<n;i++){
    for(int j=1;j<=n-i;j++){
        string tmp_S=S.substr(i,j);
        int res=0;
        for(auto _q:tmp_S){
            res=check.find(_q);
            if(res<0)break;
        }
        if(res>=0)len=max(len,j);    
    }    
}
cout<<len<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <cfloat>

using namespace std;

int main() {
	double height = 0, maxNum=0.0, minNum=DBL_MAX;
	while(cin>>height){
		if(cin.eof()) break;
		maxNum = max(maxNum, height);
		minNum = min(minNum, height);
	}
	printf("%.1f\n", maxNum-minNum);
	return 0;

}

Measured memory_bytes: 1236
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;

ll l;
int n;
ll tab[nax];
ll sum[nax];

ll wyn;

ll odp(int v)
{
	return sum[v];
}

ll dok(int v)
{
	//~ if (v>n)
		//~ return 0;
	ll ret=sum[n]-sum[v-1];
	return (n+1-v)*l-ret;
}

int main()
{
	scanf("%lld%d", &l, &n);
	for (int i=1; i<=n; i++)
		scanf("%lld", &tab[i]);
	tab[n+1]=l;
	for (int h=0; h<2; h++)
	{
		for (int i=1; i<=n; i++)
			sum[i]=sum[i-1]+tab[i];
		for (int i=1; i<=n; i++)
		{
			if (2*i<n)
				continue;
			if (i==n)
			{
				wyn=max(wyn, tab[n]);
				continue;
			}
			int j=n-i;
			int r=i-j;
			assert(r>=0);
			ll lew=odp(i)-odp(r);
			ll pra=dok(i+1);
			lew-=tab[r]*(i-r);
			pra+=tab[r]*j;
			ll ter=(tab[r]+lew*2+pra*2-min(l-tab[i+1]+tab[r], tab[i]-tab[r]));
			//~ debug() << h << " " << i << "  " << lew << " " << pra << "   " << ter;
			wyn=max(wyn, ter);
		}
		
		
		
		for (int i=1; i<=n; i++)
			tab[i]=l-tab[i];
		reverse(tab+1, tab+1+n);
	}
	
	printf("%lld\n", wyn);
	return 0;
}


Measured memory_bytes: 5888
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    n = I()
    h = LI()
    dp = [float("inf") for i in range(n)]
    dp[0] = 0
    for i in range(n-2):
        dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))
        dp[i+2] = min(dp[i+2],dp[i]+abs(h[i+2]-h[i]))
    dp[n-1] = min(dp[n-1],dp[n-2]+abs(h[n-1]-h[n-2]))
    print(dp[n-1])
#B
def B():
    n,k = LI()
    h = LI()
    dp = [float("inf") for i in range(n)]
    dp[0] = 0
    for i in range(n):
        for j in range(1,min(n-i,k+1)):
            dp[i+j] = min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
    print(dp[n-1])

#C
def C():
    n = I()
    v = LIR(n)
    dp = [[0,0,0] for i in range(n+1)]
    for i in range(n):
        dp[i+1][0] = max(dp[i+1][0],dp[i][1]+v[i][0],dp[i][2]+v[i][0])
        dp[i+1][1] = max(dp[i+1][1],dp[i][2]+v[i][1],dp[i][0]+v[i][1])
        dp[i+1][2] = max(dp[i+1][2],dp[i][0]+v[i][2],dp[i][1]+v[i][2])
    print(max(dp[n]))

#D
def D():
    n,W = LI()
    g = LIR(n)
    dp = [[0 for i in range(W+1)] for j in range(n+1)]
    for i in range(n):
        for j in range(W+1)[::-1]:
            w,v = g[i]
            if j >= w:
                dp[i+1][j] = max(dp[i][j],dp[i][j-w]+v)
            else:
                dp[i+1][j] = max(dp[i+1][j],dp[i][j])
    print(max(dp[n]))
#E
def E():
    n,W = LI()
    g = LIR(n)
    V = 100000
    dp = [[float("inf") for i in range(V+1)] for j in range(n+1)]
    dp[0][0] = 0
    for i in range(n):
        for j in range(V+1)[::-1]:
            w,v = g[i]
            if j >= v:
                dp[i+1][j] = min(dp[i][j],dp[i][j-v]+w)
            else:
                dp[i+1][j] = min(dp[i+1][j],dp[i][j])

    for i in range(V+1)[::-1]:
        if dp[n][i] <= W:
            print(i)
            quit()

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    E()


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

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

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

    string S;
    int n;

    string ins, r;
    int f, t;

    cin>>S;
    cin>>n;
    rep(i, n) {
        cin>>ins;
        if (ins == "replace") {
            cin>>f>>t>>r;
            S.replace(f, t - f + 1, r);
        }
        else if (ins == "reverse") {
            cin>>f>>t;
            string st = S.substr(f, t - f + 1);
            reverse(st.begin(), st.end());
            S.replace(f, t - f + 1, st);
        }
        else if (ins == "print") {
            cin>>f>>t;
            cout<<S.substr(f, t - f + 1)<<endl;
        }
    }
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loop2(num) for (lli j = 0 ; j < num ; j ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back ()
#define pof pop_front ()

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main ()
{
    fastio
    st s ; cin >> s ;
    (s == "AAA"|| s == "BBB" ? No : Yes);
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.List
import qualified Data.IntMap as IM
import Control.Monad

main :: IO ()
main = do
    [n,k,q] <- map read . words <$> getLine :: IO [Int]
    a <- map (fst . fromJust . BS.readInt) . BS.lines <$> BS.getContents
    let a' = group $ sort a
        m  = IM.fromList $ map (\v -> (head v, length v)) a'
        ret = map (\i -> k - q + (maybe 0 id (IM.lookup i m))) [1..n]
    forM_ ret $ \n -> do
        putStrLn $ if n > 0 then "Yes" else "No" 

Measured memory_bytes: 27388
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int A, B, M; cin >> A >> B >> M;
	vector<int>A_vec(A);
	rep(i, A)cin >> A_vec[i];
	vector<int>B_vec(B);
	rep(i, B)cin >> B_vec[i];
	vector<vector<int>>xyc(M, vector<int>(3));
	rep(i, M)rep(j, 3)cin >> xyc[i][j];
	int ans = INF;
	rep(i, M) {
		int cnt = A_vec[xyc[i][0] - 1] + B_vec[xyc[i][1] - 1] - xyc[i][2];
		ans = min(ans, cnt);
	}
	sort(all(A_vec));
	sort(all(B_vec));
	ans = min(ans, A_vec[0] + B_vec[0]);
	cout << ans << "\n";


	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int ac = 0, qc1 = 0, qc2 = 0, cc = 0, k = 1;
int ans = 0, ans0 = 0, ans1 = 0, ans2 = 0, ans3 = 0;
string s;
signed main() {
	cin >> s;
	for (char ch : s) {
		if (ch == '?')qc2++;
		if (ch == 'C')cc++;
	}
	for (char ch : s) {
		if (ch == '?')qc2--;
		if (ch == 'C')cc--;
		if (ch == '?') {
			ans1 += ac * cc;
			ans2 += qc1 * cc + ac * qc2;
			ans3 += qc1 * qc2;
			ans1 %= mod; ans2 %= mod; ans3 %= mod;
		}
		if (ch == 'B') {
			ans0 += ac * cc;
			ans1 += qc1 * cc + ac * qc2;
			ans2 += qc1 * qc2;
			ans1 %= mod; ans2 %= mod; ans0 %= mod;
		}
		if (ch == '?')qc1++;
		if (ch == 'A')ac++;
	}
	for1(i, qc1 - 3) { k *= 3; k %= mod; }
	if (qc1 >= 3) {
		ans += k * ans3; ans %= mod;
		k *= 3; k %= mod;
	}
	if (qc1 >= 2) {
		ans += k * ans2; ans %= mod;
		k *= 3; k %= mod;
	}
	if (qc1 >= 1) {
		ans += k * ans1; ans %= mod;
		k *= 3; k %= mod;
	}
	if (qc1 >= 0) {
		ans += k * ans0; ans %= mod;
		k *= 3; k %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
int main() {
	while (true) {
		int x, y, s;
		cin >> x >> y >> s;
		if (x == 0) return 0;
		int ans = 0;
		for (int i = 1; i <= s - 1; ++i) {
			for (int q = 1; q <= s - 1; ++q) {
				int geko = i * (100 + x);
				geko /= 100;
				geko += q * (100 + x) / 100;
				if (geko == s) {
					ans = max(ans, i * (100 + y) / 100 + q * (100 + y) / 100);
				}
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3000
#include <algorithm>
#include <cmath>
#include <limits>
#include <iostream>
#include <vector>


int main() {
    int n;
    std::cin >> n;
    std::vector<int> heights(n);
    for(int& h : heights) std::cin >> h;

    if(heights.size() <= 1) {
        std::cout << "0\n";
        return 0;
    }
    int prevPrev = 0;
    int prev = std::abs(heights[0] - heights[1]);
    int ans = prev;
    for(std::size_t i = 2; i < heights.size(); i++) {
        int op1 = prev + std::abs(heights[i - 1] - heights[i]);
        int op2 = prevPrev + std::abs(heights[i - 2] - heights[i]);
        ans = std::min(op1, op2);
        prevPrev = prev;
        prev = ans;
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 640
import java.util.*;

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

		int r = 0;
		char t = '/';
		for (char c: sc.next().toCharArray())
			if (c != t) {
				r++;
				t = c;
			}
		System.out.println(r);
	}
}


Measured memory_bytes: 27092
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
const int A = 0, G = 1, C = 2, T = 3;

//直近の4文字を0~1度swapしてAGCが揃わなければtrue, 揃ったらfalseを返す
bool judge(int a, int b, int c, int x){
    int s[4] = {c, b, a, x};
    
    bool ret = true;
        rep(j, 2)
            if(s[j]==A && s[j+1]==G && s[j+2]==C)ret = false;
    for(int i=0; i<3; i++){
        swap(s[i], s[i+1]);
        rep(j, 2)
        if(s[j]==A && s[j+1]==G && s[j+2]==C)ret = false;
        swap(s[i], s[i+1]);
    }
    return ret;
}

int main(){
	cin >> n;
	ll dp[n+1][4][4][4]; //直前の文字、2文字前、3文字前 最大計算量25600
	rep(i, n+1)rep(j, 4)rep(k, 4)rep(l, 4)dp[i][j][k][l] = 0;
	//初期化 
	rep(a, 4)rep(b, 4)rep(c, 4) if(judge(a,b,c,T))dp[3][a][b][c] = 1;
	
	rept(i, 3, n){
	    rep(a, 4){
	        rep(b, 4){
	            rep(c, 4){
	                rep(x, 4){
	                    //直近4文字が条件を満たす場合のみ遷移する
	                    if(judge(a, b, c, x)){
	                        dp[i+1][x][a][b] = (dp[i+1][x][a][b] + dp[i][a][b][c]) % MOD;
	                    }
	                }
	            }
	        }
	    }
	}
	
	ll res = 0;
	rep(a, 4)rep(b, 4)rep(c, 4) res = (res + dp[n][a][b][c]) % MOD;
    cout << res << ln;
	
}

Measured memory_bytes: 3528
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[inline]
#[allow(dead_code)]
fn gcd(mut m: u64, mut n: u64) -> u64 {
    if m < n {
        std::mem::swap(&mut m, &mut n);
    }

    loop {
        let k = m % n;
        if k == 0 {
            return n;
        }

        m = n;
        n = k;
    }
}

#[inline]
#[allow(dead_code)]
fn lcm(m: u64, n: u64) -> u64 {
    m / gcd(m, n) * n
}

macro_rules! eprint(
    ($($arg:tt)*) => { {
        use std::io::Write;
        let r = write!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! eprintln(
    ($($arg:tt)*) => { {
        use std::io::Write;
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! dbg {
    ($val:expr) => {
        // Use of `match` here is intentional because it affects the lifetimes
        // of temporaries - https://stackoverflow.com/a/48732525/1063961
        match $val {
            tmp => {
                eprintln!(
                    "[{}:{}] {} = {:#?}",
                    file!(),
                    line!(),
                    stringify!($val),
                    &tmp
                );
                tmp
            }
        }
    };
}

fn main() {
    input! {
        n: usize,
        ab_v: [[u64; 2]; n],
    }

    let mut answer = 0u64;
    for ab in ab_v.iter().rev() {
        let a = ab[0] + answer;
        let b = ab[1];

        answer += if a % b == 0 { 0 } else { b - (a % b) };
    }

    println!("{}", answer);
}


Measured memory_bytes: 8444
def main():
    import sys
    input = sys.stdin.readline

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

    if K == 0:
        print(N**2)
        exit()

    ans = 0
    for b in range(K+1, N+1):
        ans += N // b * (b-K) + max(N%b - (K-1), 0)
    print(ans)


if __name__ == '__main__':
    main()


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	vector<bool>M_S(300100, false);
	int x = 6;
	while (x < M_S.size()) {
		M_S[x] = true;
		if (x % 7 == 1)x += 5;
		else if (x % 7 == 6)x += 2;
	}

	for (int i = 0; i*i < M_S.size(); i++) {
		if (M_S[i]) {
			for (int j = i + i; j < M_S.size(); j += i) M_S[j] = false;
		}
	}

	int n;
	while (cin >> n, n != 1) {
		cout << n << ":";
		for (int i = 6; i <= n; i++) {
			if (M_S[i] && n%i == 0)cout << " " << i;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3012
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n=ii()
a=li()

cnt=0
for i in range(n):
    if(i%2==0 and a[i]%2==1):
        cnt+=1
print(cnt)

Measured memory_bytes: 9048
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<a+b+c-max(max(a,b),c);
}

Measured memory_bytes: 256
import numpy as np
N,K=map(int, input().split())
A=list(map(int, input().split()))

#最大桁数調べる
MAX=max(len(bin(K)[2:]), len(bin(max(A))[2:]))


L=[[0]*MAX for _ in range(N)]
for i,a in enumerate(A):
    b=bin(a)[2:]
    b=b.zfill(MAX)
    for j,s in enumerate(b):
        if s=="1":
            L[i][j]+=1
L=np.array(L)
count=0
ones=L.sum(axis=0)
#print(ones)
for i in range(MAX):
    if ones[i]*2==N:
        continue
    elif ones[i]*2<N:
        add=2**(MAX-1-i)
        if count+add<=K:
            count+=add
    else:
        continue

ans=0
for a in A:
    ans+=(count^a)
print(ans)


Measured memory_bytes: 87148
//B - Picture Frame
//https://atcoder.jp/contests/abc062/tasks/abc062_b

#include <cstdio>

int main()
{
  int N, M, a, b;

  scanf("%d%d", &N, &M);
  int num[N] = {};

  for (int i = 0; i < M; i++)
  {
    scanf("%d%d", &a, &b);
    for (int j = 0; j < N; j++)
    {
      if (a - 1 == j)
      {
        num[j]++;
      }
      if (b -1 == j)
      {
        num[j]++;
      }
    }
  }

  for (int i = 0; i < N; i++)
  {
    printf("%d\n", num[i]);
  }
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{

    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            long[] m = new long[N + 1];
            long[] b = new long[N];

            string[] s = Console.ReadLine().Split(' ');
            for (int i = 0; i < N + 1; i++)
            {
                m[i] = long.Parse(s[i]);
            }

            s = Console.ReadLine().Split(' ');
            for (int i = 0; i < N; i++)
            {
                b[i] = long.Parse(s[i]);
            }

            long ans = 0;
            long remain = 0;
            for (int i = 0; i < N; i++)
            {
                if (m[i] < remain)
                {
                    ans += m[i];
                    remain = b[i];
                }
                else
                {
                    ans += remain;
                    m[i] -= remain;

                    if (b[i] > m[i])
                    {
                        ans += m[i];
                        remain = b[i] - m[i];
                    }
                    else
                    {
                        ans += b[i];
                        remain = 0;
                    }
                }
            }

            if (m[N] > remain)
            {
                ans += remain;
            }
            else
            {
                ans += m[N];
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 33748
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main(){
  string s,t;
  cin>>s>>t;

  int l=s.size();
  for(char cs='a';cs<='z';cs++){
    bool f=0;
    char ct;
    REP(i,l){
      if(f==0 && s[i]==cs){
        ct=t[i];
        f=1;
      }
      if(f==1 && s[i]==cs){
        if(t[i]!=ct){
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
  }
  for(char ct='a';ct<='z';ct++){
    bool f=0;
    char cs;
    REP(i,l){
      if(f==0 && t[i]==ct){
        cs=s[i];
        f=1;
      }
      if(f==1 && t[i]==ct){
        if(s[i]!=cs){
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <string>
using namespace std;
int result[200] = { 0 };
int main(){
	int num;
	while (cin>>num)
	{
		string before[1000], after[1000];
		string answer = "";
		if (num == 0)break;

		for (int i = 0; i < num; i++)
		{
			cin >> before[i] >> after[i];

		}

		int a;
		cin >> a;

		for (int i = 0; i < a; i++)
		{
			string ch;
			cin >> ch;
			for (int j = 0; j < num; j++)
			{
				if (ch == before[j])
				{				
					ch = after[j];
					break;
				}
			}
			answer += ch;
		}



			cout << answer << endl;

	}
}

Measured memory_bytes: 1360
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_cxx;
#define dprint(v) cout << #v"=" << v << endl //;)
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define INF (ll)1e16
#define endl '\n'
#define isin(x,y) ((y).find(x)!=(y).end())

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
        ll n;
        cin>>n;
        cout<<(n-2)*180<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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()
{
  ll N;
  cin >> N;
  ll ans=0;
  REP2(i,1,N){
    ans+=N/i;
    if(N%i==0){
      ans--;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		int N;
		cin >> N;
		int num[8];
		for(int j=0;j<8;j++){
			num[j] = N/pow(10,7-j);
			N%=int(pow(10,7-j));
		}
		sort(num, num+8);
		int min = num[0]*10000000+num[1]*1000000+num[2]*100000+num[3]*10000+num[4]*1000+num[5]*100+num[6]*10+num[7];
		int max = num[7]*10000000+num[6]*1000000+num[5]*100000+num[4]*10000+num[3]*1000+num[2]*100+num[1]*10+num[0];
		cout<<max-min<<endl;
	}
	return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  int M = max(A,max(B,C));
  int total = A + B + C;
  int X;
  if (M % 2 == total % 2) {
    X = 3 * M;
  } else {
    X = 3 * (M + 1);
  }

  cout << (X - total) / 2 << endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<string> a;
    int count=0;
    int n;
    cin>>n;
    string p;
    for(int i=0;i<n;i++) 
    {
        cin>>p;
        a.push_back(p);
    }  
    sort(a.begin(), a.end()); 
    a.erase(std::unique(a.begin(), a.end()), a.end());
    cout<<a.size()<<endl;
}

Measured memory_bytes: 11664
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL)

int main() {
   int a,b;cin>>a>>b;
    if(a>=13)cout<<b;
    else if(a>=6&&a<=12)cout<<b/2;
    else if(a<=5)cout<<0;
 
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string s;
    cin>>s;
    map<char,char>mp;
    mp['A']='T';
    mp['T']='A';
    mp['C']='G';
    mp['G']='C';
    cout<<mp[s[0]]<<endl;

    return 0;
}


Measured memory_bytes: 3620
//Volume2-0206
import java.util.Scanner;

public class Main {

	public static void main(String[] args){

		//declare
		int     L,ret;
		boolean flg;

		//input
        Scanner sc = new Scanner(System.in);
        while(true){
            L = sc.nextInt();
            if(L==0){break;}

            //calculate
            ret = 0;
            flg = false;
            for(int i=0;i<12;i++){
            	if((L -= (sc.nextInt() - sc.nextInt())) <= 0 && !flg){
            		ret = i+1;
            		flg = true;
            	}
            }

            //output
            if   (ret > 0){System.out.println(ret) ;}
            else          {System.out.println("NA");}
        }
	}
}

Measured memory_bytes: 34788
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, M, K, Q;
string S;

int main() {
    vector<int> v = {1,
                     1,
                     1,
                     2,
                     1,
                     2,
                     1,
                     5,
                     2,
                     2,
                     1,
                     5,
                     1,
                     2,
                     1,
                     14,
                     1,
                     5,
                     1,
                     5,
                     2,
                     2,
                     1,
                     15,
                     2,
                     2,
                     5,
                     4,
                     1,
                     4,
                     1,
                     51};
    int k;
    cin >> k;
    cout << v[k - 1] << endl;

    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, t;
  cin >> n >> t;

  vll a(n + 1), b(n + 1);
  REP(i, n + 1) {
    cin >> a[i] >> b[i];
  }

  vvll ldp(n + 2, vll(t + 1)), rdp(n + 2, vll(t + 1));
  REP(i, n + 1) {
    rep(j, t) {
      chmax(ldp[i][j], ldp[i - 1][j]);
      if (j > 0) {
        chmax(ldp[i][j], ldp[i][j - 1]);
      }
      if (j + a[i] < t) {
        chmax(ldp[i][j + a[i]], ldp[i - 1][j] + b[i]);
      }
    }
  }

  for (int i = n; i > 0; i--) {
    rep(j, t) {
      chmax(rdp[i][j], rdp[i + 1][j]);
      if (j > 0) {
        chmax(rdp[i][j], rdp[i][j - 1]);
      }
      if (j + a[i] < t) {
        chmax(rdp[i][j + a[i]], rdp[i + 1][j] + b[i]);
      }
    }
  }

  ll ans = 0;
  REP(i, n + 1) {
    rep(j, t) {
      ll v = ldp[i - 1][j] + rdp[i + 1][t - 1 - j];
      chmax(ans, v + b[i]);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 141312