akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 2e6 + 5;
long long fac[N] = {};
long long inv(long long x) {
    if (x == 1) return 1;
    return (mod - mod / x) * inv(mod % x) % mod;
}
void init() {
    fac[0] = 1;
    for (long long i = 1; i < N; i++)
        fac[i] = fac[i - 1] * i % mod;
}
long long ksm(long long a, long long b) {
    if (b == 0) return 1;
    if (b & 1) return a * ksm(a * a % mod, b >> 1) % mod;
    return ksm(a * a % mod, b >> 1);
}
long long C(long long a, long long b) {
    return fac[a] * inv(fac[b] * fac[a - b] % mod) % mod;
}
int main() {
    string str;
    init();
    long long k, len;
    cin >> k >> str;
    len = str.size();
    long long ans = 0;
    for (long long i = len; i <= k + len; i++)
        ans = (ans + (C(i - 1, len - 1) * ksm(26, len + k - i) % mod) * ksm(25, i - len)) % mod;
    cout << ans << '\n';
    return 0;
}

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

int main(){
    int s;
    cin >> s;
    
    set<int> se;    
    se.insert(s);

    for(int i = 2;;i++){
        if(s % 2 == 0)  s = s/2;
        else            s = 3*s+1;
        if(se.count(s)){
            cout << i << endl;
            return 0;
        }else{
            se.insert(s);
        }
    }

}

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

#define mod 1000000007
#define maxn 100005

typedef pair<int, int> P;
string s;

int main()
{
    //freopen("monotonic.in", "r", stdin);
    //freopen("monotonic.out", "w", stdout);
    int k, n;
    cin >> k;
    cin >> s;
    n = s.length();
    for (int i = 0; i < n; i++)
    {
        int x = s[i] - 'A';
        x = (x + k) % 26;
        s[i] = 'A' + x;
    }
    cout << s;

    return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
A = list(map(int, input().split()))

for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 == 0:
            continue
        elif A[i] % 5 == 0:
            continue
        else:
            print("DENIED")
            sys.exit(0)
print("APPROVED")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
const int N=2e5+5;
int inf=0x3f3f3f3f;
int mod=1e9+7;
typedef pair<int,int> pa;
typedef long long ll;
long double PI=3.141592654;

ll ma[N];
ll mi[N];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    if(k>n) {
        cout<<1<<endl;
        return 0;
    }
    for(int i=1;i<=n;i++){
      mi[i]=(mi[i-1]+i-1)%mod;
    }
//    for(int i=1;i<=n;i++)
//        cout<<mi[i]<<" ";
//    cout<<endl;
    for(int i=n,j=1;i>=0;i--,j++){
      ma[j]=(ma[j-1]+i)%mod;
    }
//    for(int i=1;i<=n;i++)
//        cout<<ma[i]<<" ";
//    cout<<endl;
    ll ans=0;
    for(int i=k;i<=n;i++){
      ans=(ans+ma[i]-mi[i]+1+mod)%mod;
    }
    ans++;
    printf("%lld\n",ans%mod);
    return 0;
}


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

    int count = 0;
    int N = S.length();
    for (int i = 0; i < N; i++){
        if (S.substr(i, 2) == "AC"){
            count++;
        }        
    }

    if (count > 0){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b,c; cin >> a >> b >> c;
    int sum = a+b+c;
    if (sum >= 22) cout << "bust\n";
    else cout << "win\n";
    return 0;
}

Measured memory_bytes: 256
/*  Success may not come to me immediately,
 *  but it will come definitely....
 */
#include<bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li  	int64_t
#define ld  	double_t
#define ulli    uint64_t
//=====================================================================
#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define repi(i,v)   for(i=v.begin();i!=v.end();i++)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))
#define nl      	cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>   vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpl;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb  push_back
#define pob pop_back
#define pf  push_front
#define pof pop_front
#define all(v)  v.begin(),v.end()
#define itr iterator
#define sz  size()
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define mp  make_pair
#define F   first
#define S   second
//=====================================================================
#define mod (li)(1e9+7)
#define inf (li)(1e18)
#define MX1 (li)(1e5+5)
#define MX2 (li)(1e6+5)
#define pi  acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return (1LL<<n);}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

void solve(){
  string s,a;cin>>s;
  a=s;
  reverse(all(s));
  if(a==s) cout<<"Yes";
  else cout<<"No";
}

int main(){
  opt
  #ifndef ONLINE_JUDGE
//  freopen("input.txt","r",stdin);
 // freopen("output.txt","w",stdout);
  #endif
  li t=1;
  //cin>>t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
xxx = sorted(list(map(int, input().split())))
if n >= m:
    ans = 0
else:
    ddd = [0] * (m - 1)
    for i in range(m - 1):
        ddd[i] = xxx[i + 1] - xxx[i]
    ddd = sorted(ddd)
    ans = sum(ddd[:m - n])
print(ans)

Measured memory_bytes: 13960
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <sstream>

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#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)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define C(x) cout << x << endl //テスト出力

//関数
//nCkの計算の関数(呼び出しは[cbn])
ll cbn(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}
// a^n mod を計算する
ll powmod(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}
//２つの最大公約数
int gcb(int a, int b){
    if(a < b){
        int x = a;
        a = b;
        b = x;
    }
    int amari = a % b;
    if(amari == 0) return b;

    return gcb(b, amari);
}
//３つの最大公約数
int gcb_3(int a, int b, int c){
    return gcb(gcb(a, b), c);
}

/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;
vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))*/

/*-----------------------------ここから-----------------------------*/

int main() {
cin.tie(0);
ios::sync_with_stdio(false);
  ll n,a, cnt=0,ans = 1;
  
  cin >> n;
FOR(k,1,n-1){
  a=n-k;
  ans=1;
  for (int i = 2; i <= sqrt(a); i++) {
    int cnt = 0;
    while (a % i == 0) {
      cnt++;
      a /= i;
    }
    ans *= (cnt + 1);
    if (a == 1) break;
  }
  if (a != 1) ans *= 2;
  cnt+=ans;
}
  
  
  
 cout << cnt;
}

Measured memory_bytes: 3692
#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() {
    int n, m;
    cin >> n >> m;
    priority_queue<ll> a;
    rep(i, n){
        ll tmp;
        cin >> tmp;
        a.push(tmp);
    }
    rep(i, m){
        ll mx = a.top(); a.pop();
        a.push(mx / 2); 
    }
    ll ans = 0;
    rep(i, n){
        ans += a.top(); a.pop();
    }
    cout << ans << endl;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
typedef long long ll;

vector<vector<ll>> tizu(50,vector<ll>(50));
vector<vector<bool>> visit(50,vector<bool>(50, false));
ll h,w;

void dfs(pair<ll,ll> v)
{
    ll a = v.first;
    ll b = v.second;
    if(!tizu.at(a).at(b)){
        return;
    }
    visit.at(a).at(b) = true;
    ll tate[9] = {-1,0,1,-1,0,1,-1,0,1};
    ll yoko[9] = {-1,-1,-1,0,0,0,1,1,1};
    ll i,j;
    for(i = 0;i < 9;++i){
        ll p = a + tate[i];
        ll q = b + yoko[i];
        if(p < 0 || p >= h){
            continue;
        }else if (q < 0 || q >= w){
            continue;
        }else if(!visit.at(p).at(q) && tizu.at(p).at(q)){
            dfs(make_pair(p,q));
        }
    }
    return;
}

int main()
{
    ll i,j;
    while(true){
        cin >> w >> h;
        if(w == 0 && h == 0){
            return 0;
        }
        for(i = 0;i < h;++i){
            rep(j,w){
                cin >> tizu.at(i).at(j);
            }
        }
        for(i = 0;i < h;++i){
            rep(j,w){
                visit.at(i).at(j) = false;
            }
        }
        ll ans = 0;
        for(i = 0;i < h;++i){
            rep(j,w){
                if(visit.at(i).at(j) || !tizu.at(i).at(j)){
                    continue;
                }else{
                    dfs(make_pair(i,j));
                    ++ans;
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3648
#!/usr/bin/env python3
#ABC132 E
#有向グラフ上の路長が3の倍数であるようなものの内、最短の長さを3で割ったものを出力

import sys
sys.setrecursionlimit(1000000)
from collections import deque

N,M = map(int,input().split())
UV = [list(map(int,input().split())) for _ in range(M)]
S,T = map(int,input().split())

G = [[] for _ in range(N)]

for i in UV:
    G[i[0]-1].append(i[1]-1)

reach = [[-1 for _ in range(N)] for _ in range(3)]#元のグラフのGの状態数3倍化
reach[0][S-1] = 0#スタート位置を0にする

que = deque()
que.append(S-1)#スタート位置を追加

time = 1
for _ in range(4*N):
    new_que = deque()
    for q in que:
        for v in G[q]:#qから移動できる辺を見る
            if reach[time%3][v] == -1:#まだたどり着いていない辺なら
                reach[time%3][v] = time#たどり着けた時刻をたどり着いた時刻を3で割った余りのリストに入れる
                new_que.append(v)#たどり着いた頂点をqueueにいれて次のターンでそこから移動できる辺を見る
    que = new_que
    time += 1
if reach[0][T-1] == -1:
    print(-1)
else:
    print(reach[0][T-1]//3)


Measured memory_bytes: 91736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
#define db double long
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a;
	cin >> a;
	cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(11);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int a, b;
  cin >> a >> b;
  if (b == 1) { cout << 0 << endl; return; } // debuged
  int c = a;
  if (c >= b) { cout << 1 << endl; return; }
  rep(i, 20) {
    c += a - 1;
    if (c >= b) { cout << i + 2 << endl; return; }
  }
}


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

vector<int> adj[100001];
vector<int> topo;

void topo_sort(int n)
{
    int in_degree[n+1];
    for(int i=0;i<=n;i++)
        in_degree[i] = 0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<adj[i].size();j++)
        {
            in_degree[adj[i][j]]++;
        }
    }

    queue<int> q;
    for(int i=1;i<=n;i++)
    {
        if(in_degree[i] == 0)
            q.push(i);
    }
    while(!q.empty())
    {
        int cur = q.front();
        q.pop();
        topo.push_back(cur);
        for(int i=0;i<adj[cur].size();i++)
        {
            in_degree[adj[cur][i]]--;
            if(in_degree[adj[cur][i]] == 0)
                q.push(adj[cur][i]);
        }
    }
}

int main()
{
    int n,m;
    cin>>n>>m;
    int x,y;
    vector<int> ins[n+1];
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        ins[y].push_back(x);

    }

    topo_sort(n);
    int dis[n+1];
    for(int i=1;i<=n;i++)
        dis[i] = 0;

    for(int i=0;i<topo.size();i++)
    {
        int v = topo[i];
        for(int j=0;j<ins[v].size();j++)
        {
            int u = ins[v][j];
            dis[v] = max(dis[v],dis[u]+1);
        }
    }
    int ans = 0;
    for(int i=1;i<=n;i++)
    {
        ans = max(ans,dis[i]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 12160
import heapq


class Edge():

    def __init__(self, _to, _cost):
        self.to = _to
        self.cost = _cost


class Dijkstra():
    def __init__(self, V):

        self.G = [[] for i in range(V+1)]
        self._E = 0
        self._V = V

    @property
    def E(self):
        """ 辺数 """
        return self._E

    @property
    def V(self):
        """ 頂点数 """
        return self._V

    def add(self, _from, _to, _cost):
        self.G[_from].append(Edge(_to, _cost))
        self._E += 1

    def shortest_path(self, s):

        que = []
        heapq.heapify(que)
        d = [10**10] * (self._V+1)
        par = [-1] * (self._V + 1)
        d[s] = 0
        heapq.heappush(que, (0, s))

        while que:
            cost, v = heapq.heappop(que)
            if d[v] < cost:
                continue

            for e in self.G[v]:
                if d[e.to] > d[v] + e.cost:
                    d[e.to] = d[v] + e.cost
                    par[e.to] = v
                    heapq.heappush(que, (d[e.to], e.to))
        return d, par


N, M = map(int, input().split())
G = []
ans = []
now_dis = 10**6
for i in range(M):
    a, b = map(int, input().split())
    G.append((a, b))
for i in range(M):
    graph = Dijkstra(N)
    for j in range(M):
        if j != i:
            graph.add(G[j][0], G[j][1], 1)
    S, T = G[i][0], G[i][1]
    d, par = graph.shortest_path(T)
    if d[S]+1 < now_dis:
        now_dis = d[S]+1
        sub = []
        node = S
        while node != T:
            sub.append(node)
            node = par[node]
        sub.append(T)
        ans = sub

K=len(ans)
if K==0:
    print(-1)
    exit()
print(K)
for x in ans:
    print(x)

Measured memory_bytes: 141536
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<vector>

using namespace std;

#define LL long long

struct BIT{//1-indexed
	vector<int> bit;
	BIT(int n, int i):bit(n,i){}
	void add(int now, int val){
		for(int i=now; now<bit.size(); now+=(now&-now))
			bit[now]+=val;
		return;
	}
	int sum(int now){
		int ret=0;
		for(int i=now; now>0; now-=(now&-now))
			ret+=bit[now];
		return ret;
	}
};

LL n,a[200002],st[200002],ans=0;
map<int,int>key;

int main() {
	cin>>n;
	BIT bt(n+1,0);
	for(int i=0;i<n;i++){
		cin>>a[i];
		st[i]=a[i];
	}
	sort(st,st+n);
	for(int i=0;i<n;i++)key[st[i]]=i+1;
	for(int i=0;i<n;i++){
		ans+=i-bt.sum(key[a[i]]);
		bt.add(key[a[i]],1);	
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 16012
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
} 
int ans[2145];
signed main(){
	ic(n) ic(x) ic(y)
	x-=1;
	y-=1;
	rep(0,i,n){
		int dis[2145];
		if(i<x){
			rep(0,j,x)dis[j]=abs(j-i);
			dis[x]=x-i;
			rep(x+1,j,y)dis[j]=min(j-x,y-j+1)+x-i;
			rep(y,j,n)dis[j]=j-y+1+x-i;
		}
		else if(x<=i&&i<y){
			dis[x]=min(y-i+1,i-x);
			rep(0,j,x)dis[j]=x-j+dis[x];
			rep(x+1,j,y){
				if(j<i)dis[j]=min(abs(j-i),y-i+1+j-x);
				else dis[j]=min(abs(j-i),i-x+1+y-j);
			}	
			rep(y,j,n)dis[j]=min(y-i,i-x+1)+j-y;
		}
		else{
			rep(0,j,x+1)dis[j]=i-y+1+x-j;
			rep(x+1,j,y)dis[j]=i-y+min(1+j-x,y-j);
			rep(y,j,n)dis[j]=abs(i-j);
		}
		rep(0,j,n){
			if(dis[j]>0)ans[dis[j]-1]++;
		}
		cout<<endl;
	}
	rep(0,i,n-1)c(ans[i]/2)
}	

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var A = input[0];
        var B = input[1];
        var C = input[2];
        var K = input[3];

        if (A >= K)
        {
            Console.WriteLine(K);
        }
        else if (A + B >= K)
        {
            Console.WriteLine(A);
        }
        else
        {
            Console.WriteLine(A - (K - A - B));
        }
    }
}


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


int main() {
    int n;
    cin >> n;
    
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    
    vector<int> all(1000010);
    for(int x : a) {
        if(all[x] != 0) {
            all[x] = 2;
        }
        else {
            for(int i = x; i <= 1000000; i+=x) {
                all[i]++;
            }
        }
    }
    
    int cnt = 0;
    for(int x : a) {
        if(all[x] == 1)
            cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
}




Measured memory_bytes: 8008
# input
n = int(input())
a = [0] * n
b = [0] * n
c = [0] * n
for i in range(n):
  a[i], b[i], c[i] = map(int, input().split())

# DP
dp_a = [0] * n
dp_b = [0] * n
dp_c = [0] * n

dp_a[0] = a[0]
dp_b[0] = b[0]
dp_c[0] = c[0]

for i in range(1, n):
  dp_a[i] = max(dp_b[i - 1], dp_c[i - 1]) + a[i]
  dp_b[i] = max(dp_a[i - 1], dp_c[i - 1]) + b[i]
  dp_c[i] = max(dp_a[i - 1], dp_b[i - 1]) + c[i]

print(max(dp_a[n - 1], dp_b[n - 1], dp_c[n - 1]))

Measured memory_bytes: 52764
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	char str1[16], str2[16], str3[16];

	cin >> str1 >> str2 >> str3;
	if (str1[strlen(str1) - 1] == str2[0] &&
		str2[strlen(str2) - 1] == str3[0])
		cout << "YES";
	else
		cout << "NO";

	cout << endl;
	
	return 0;
}


Measured memory_bytes: 256
def main
  n = gets.chomp.to_i

  total_price = 0
  items = []
  n.times do
    price = gets.chomp.to_i
    items << price
    total_price += price
  end

  items.sort!

  discount = items[-1] / 2

  puts total_price - discount
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int k, n, a[10000], maxn;
int main() {
	cin >> k >> n;
	for (int i = 0; i < n; i++) { cin >> a[i]; maxn = max(maxn, a[i]); }
	if (maxn <= k / 2) { cout << "0" << endl; }
	else { cout << maxn * 2 - k - 1 << endl; }
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int mene(int num){
	int toori=0;
	for(int i=1;i<=sqrt(num);i++){
		if((num/i)*i==num){
			toori+=2;
		}
		if(num==i*i)toori--;
	}
	return(toori);
}
int main()
{
   int ans=0;
   int n;
   scanf("%d",&n);
    for(int i=1;i<n;i++){
		ans+=mene(i);
   }
   printf("%d",ans);
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll a,b; cin >> a >> b;
    ll res = abs(a-b);
    if(res % 2 == 0){
        ll c = max(a,b);
        cout << c - res/2<< endl;
    }
    else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const double inf=1e8;
int main(){
	int n;
	int cnt=0;
	while(cin>>n,n){
		if(cnt++)cout<<endl;
		cout<<"Case "<<cnt<<":"<<endl;
		char in[110][7][7][7]={0};
		rep(i,5)rep(j,5)rep(k,5){
			cin>>in[0][i+1][j+1][k+1];
			in[0][i+1][j+1][k+1]-='0';
		}
		vvi w(2,vi(30));
		rep(i,2){
			int a;cin>>a;
			while(a--){
				int b;cin>>b;
				w[i][b]=true;
			}
		}
		rep(q,n)rep(i,5)rep(j,5)rep(k,5){
			int co=0;
			rep(x,3)rep(y,3)rep(z,3)if(x*y*z!=1&&in[q][i+x][j+y][k+z])co++;
			if(w[in[q][i+1][j+1][k+1]][co])in[q+1][i+1][j+1][k+1]=true;
		}
		rep(i,5){
			if(i)cout<<endl;
			rep(j,5){
				rep(k,5)cout<<(char)(in[n][i+1][j+1][k+1]+'0');
				cout<<endl;
			}
		}
	}
}

Measured memory_bytes: 3124
use std::io;

fn left(i: usize) -> usize {
    2 * i
}

fn right(i: usize) -> usize {
    2 * i + 1
}

fn max_heapify(a: &mut Vec<i32>, i: usize, h: usize) {
    let l = left(i);
    let r = right(i);

    let mut largest: usize;

    if l <= h && a[l] > a[i] {
        largest = l;
    } else {
        largest = i;
    }

    if r <= h && a[r] > a[largest] {
        largest = r;
    }

    if largest != i {
        a.swap(i, largest);
        max_heapify(a, largest, h);
    }
}

fn build_max_heap(a: &mut Vec<i32>, h: usize) {
    for i in (1..(h / 2) + 1).rev() {
        max_heapify(a, i, h)
    }
}

fn main() {
    let h: usize = read_line().parse().unwrap();

    let input: Vec<i32> = read_line()
        .split_whitespace()
        .map(|n| n.parse::<i32>().unwrap())
        .collect();

    let mut a = [vec![0], input].concat();

    build_max_heap(&mut a, h);

    for i in 1..(h + 1) {
        print!(" {}", a[i]);
    }
    println!();
}

// Utilities
fn read_line() -> String {
    let mut input = String::new();
    io::stdin().read_line(&mut input).ok();
    input.trim().to_string()
}



Measured memory_bytes: 14212
#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() {
    string S;
    cin >> S;
    cout << S.substr(0, 3) << endl;
    
  return 0;
}


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

//B:1, W:2
int n, k;
int a[1002][1002], b[1002][1002];
bool ok(int y, int x){
	if(y < 0 || k <= y)return 1;
	if(x < 0 || k <= x)return 1;
	return 0;
}

int solve1(int y, int x){
	int ans = a[y][x]*2;
	ans += a[k-1][k-1]-(a[y][k-1]+a[k-1][x]);
	ans += b[y][k-1]+b[k-1][x]-2*b[y][x];
	return ans;
}

int solve2(int y, int x){
	int ans = b[y][x]*2;
	ans += b[k-1][k-1]-(b[y][k-1]+b[k-1][x]);
	ans += a[y][k-1]+a[k-1][x]-2*a[y][x];
	return ans;
}

int main(){
	int nx, ny;
	char c;
	scanf("%d%d", &n, &k);
	for(int i = 0;i < n;i++){
		scanf("%d%d %c", &nx, &ny, &c);
		int f = (c == 'B' ? 1 : 0);
		if((nx/k+ny/k+f)%2 == 1)a[ny%k][nx%k]++;
		else b[ny%k][nx%k]++;
		//printf("%d\n", (nx/k+ny/k+f)%2);
	}
	
	rep(i,k)rrep(j,k-1){
		a[i][j] += a[i][j-1];
		b[i][j] += b[i][j-1];
	}
	rep(j,k)rrep(i,k-1){
		a[i][j] += a[i-1][j];
		b[i][j] += b[i-1][j];
	}
	
	int ans = 0;
	for(int i = 0;i < k;i++){
		for(int j = 0;j < k;j++){
			ans = max(ans, solve1(i, j));
			ans = max(ans, solve2(i, j));
		}
	}
	
	/*for(int i = k-1;i >= 0;i--){
		for(int j = 0;j < k;j++)printf("%d ", a[i][j]);
		printf("\n");
	}*/
	printf("%d\n", ans);
	return 0;
}

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


    int n;int ans;
    cin>>n;
    if (n<1000)
    {
        ans=1000-n;
    }
    else if (n%1000==0)
    {
        ans=0;
    }
    else
    {
        ans=1000-(n%1000);
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> a(H,vector<char>(W));
  vector<int> h(H);
  vector<int> w(W);
  rep(i,H){
    rep(j,W){
      cin >> a.at(i).at(j);
      if(a.at(i).at(j) == '#'){
        h.at(i) = 1;
        w.at(j) = 1;
      }
    }
  }
  rep(i,H){
    if(h.at(i) == 1){
      rep(j,W){
        if(w.at(j) == 1){
          cout << a.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int dp[4000][4000]={0};
  string s,t;
  cin >> s >> t;
  for(int i=0; i<s.size(); i++){
    for(int j=0; j<t.size(); j++){
      if(s[i]==t[j]){
        dp[i+1][j+1]=dp[i][j]+1;
      }else{
        dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
      }
    }
  }
  string ans = "";
  int i=s.size(),j=t.size();
  while(i>0&&j>0){
    if(dp[i][j]==dp[i-1][j]){
      i--;
    }
    else if(dp[i][j]==dp[i][j-1]){
      j--;
    }
    else if(dp[i][j]==dp[i-1][j-1]+1){
      ans = s[i-1]+ans;
      i--;
      j--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 62720
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iterator>
using namespace std;

//http://abc054.contest.atcoder.jp/tasks/abc054_d

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

#define MAX_ab 401

int dp[40][401][401];

int a[40];
int b[40];
int c[40];

//vector<int> v[10001];
//vector<int> v_old[10001];

/*
int ans(int k,int w){
  int i,ind,s=0;
  vector<int>::iterator m;
  if(v[w].size() <= k){
    return accumulate(v[w].begin(),v[w].end(),0);
  }
  REP(i,k){
    m = max_element(v[w].begin(),v[w].end());
    s += *m;
    ind = distance(v[w].begin(),m);
    v[w].erase(v[w].begin()+ind);
  }
  return s;
}
*/

int main(){
  int n,ma,mb;
  cin >> n >> ma >> mb;
  int  i,j,k,ax,bx,cx;
  REP(i,n){
    cin >> ax >> bx >> cx;
    a[i] = ax;
    b[i] = bx;
    c[i] = cx;
  }
  REP(i,n){
    REP(j,MAX_ab){
      REP(k,MAX_ab){
	if(!j && !k)
	  dp[i][j][k] = 0;
	else
	  dp[i][j][k] = 50000;
      }
    }
  }
  REP(i,n){
    ax = a[n-i-1];
    bx = b[n-i-1];
    cx = c[n-i-1];
    if(!i){
      dp[n-i-1][ax][bx] = dp[n-i-1][ax][bx] > cx ? cx:dp[n-i-1][ax][bx];
      continue;
    }
    REP(j,MAX_ab){
      REP(k,MAX_ab){
	if(j >= ax && k >= bx)
	  dp[n-i-1][j][k] = (dp[n-i][j-ax][k-bx] + cx < dp[n-i][j][k]) ? dp[n-i][j-ax][k-bx] + cx:dp[n-i][j][k];
	else
	  dp[n-i-1][j][k] = dp[n-i][j][k];
      /*
      ostream_iterator<int> out_it (std::cout,", ");
      cout << n-i-1 << " " << j;
      copy(v[j].begin(), v[j].end(), out_it );
      cout << endl;
      */
	//if(max(j,k)<10)
	//cout << n-i-1 << " " << j << " " <<k << " "<< dp[n-i-1][j][k]<< endl;
      }
    }
    /*
    REP(j,w+1)
      v_old[j]=v[j];
    */
  }
  i=1;
  int cost = 50000;
  while(max(ma*i,mb*i) < MAX_ab){
    cost = cost > dp[0][ma*i][mb*i]? dp[0][ma*i][mb*i]:cost;
    i++;   
  }
  cout << ((cost >= 10000)? -1:cost) << endl;
  return 0;
}


Measured memory_bytes: 25344
module Main where

import           Control.Monad
import           Debug.Trace
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
import           Data.List
import qualified Data.ByteString               as BS
import qualified Data.ByteString.Char8         as BSC8
import           Data.Char
import           Data.Maybe
import           Data.Ord
--import           Data.Vector.Algorithms.Search
import qualified Data.Array                    as A
import qualified Data.Array.Unboxed            as AU
import qualified Data.Array.IO                 as AIO
import qualified Data.Set                      as S


getVUIL :: IO (VU.Vector Int)
getVUIL = VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
readI :: BSC8.ByteString -> Int
readI = fst . fromJust . BSC8.readInt
readIL :: BSC8.ByteString -> [Int]
readIL = map readI . BSC8.words
getI :: IO Int
getI = readI <$> BSC8.getLine
getIL :: IO [Int]
getIL = readIL <$> BSC8.getLine

getNIS :: Int -> IO [(Int, BSC8.ByteString)]
getNIS 0 = return []
getNIS n = do
    [aFst, aSnd] <- BSC8.words <$> BSC8.getLine
    next         <- (getNIS (n - 1))
    return ((readI aFst, aSnd) : next)

il2ss :: [Int] -> String
il2ss = unwords . map show

il2sn :: [Int] -> String
il2sn = unlines . map show

modNum = 10 ^ 9 + 7
newtype Mint = M Int
instance Num Mint where
    (M a) + (M b) = M $ mod (a + b) modNum
    (M a) - (M b) = M (a - b)
    (M a) * (M b) = M $ mod (a * b) modNum
    fromInteger a = M $ mod (fromInteger a) modNum
    abs (M a) = M $ abs a
    signum (M a) = M $ signum a
instance Show Mint where
    show (M a) = show (mod a modNum)

int2MInt :: Int -> Mint
int2MInt a = M (mod a modNum)

main :: IO ()
main = do
    [aN, aM] <- getIL
    aA       <- getIL
    let set = S.fromList $ zip aA [1 .. length aA]
    let pSet = foldl
            (\acc x ->
                let maxSet@(maxNum, maxInd) = S.findMax acc
                in  S.insert ((div maxNum 2), maxInd) $ S.deleteMax acc
            )
            set
            [1 .. aM]
    --print pSet
    print $ S.foldl (\acc x -> fst x + acc) 0 pSet


Measured memory_bytes: 33020
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Integer> k = new ArrayList<>();
        List<List<Integer>> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            k.add(sc.nextInt());
            List<Integer> list = new ArrayList<>();
            for (int j = 0; j < k.get(i); j++) {
                list.add(sc.nextInt());
            }
            a.add(list);
        }

        List<Integer> correct = new ArrayList<>(a.get(0));
        for (int i = 1; i < n; i++) {
            correct.retainAll(a.get(i));
        }
        System.out.println(correct.size());
    }

}


Measured memory_bytes: 23724
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a,b,c,d,e,f,g,h,P,Q;
    scanf("%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&g,&h);
    P=a+b+c+d;
    Q=e+f+g+h;
    if(P<Q)printf("%d\n",Q);
    if(Q<P)printf("%d\n",P);
    if(Q==P)printf("%d\n",P);
    
    

    return 0;
}

Measured memory_bytes: 592
from itertools import accumulate

MOD = 10**9 + 7

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

def N2sqrtN(N):
    M = int(N**0.5)
    As = list(range(1, M+1))
    Bs = [N//A for A in reversed(As)]
    if As[-1] == Bs[0]:
        return As + Bs[1:]
    else:
        return As + Bs

Bs = N2sqrtN(N)
lenB = len(Bs)

nums = [1]
for i in range(lenB-1):
    nums.append(Bs[i+1]-Bs[i])

dp = [0] * lenB
dp[0] = 1
for i in range(1, K+1):
    dp = list(accumulate(dp))
    dp = [dpi*num%MOD for dpi, num in zip(reversed(dp), nums)]

print(sum(dp) % MOD)


Measured memory_bytes: 11792
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
#include <functional>
using namespace std;


int main() {
	int ans;
	long long int n, m, c = 0, x = 1;
	bool flag = true,f = true;
	cin >> n;
	m = n;
	while (m != 0) {
		if (!f) {
			flag = false;
		}
		else if (m%10 != 9) {
			f = false;
		}
		m /= 10;
		c++;
		x *= 10;
	}
	x /= 10;
	ans = (c - 1) * 9;
	if (flag) {
		ans += n / x;
	}
	else {
		ans += (n / x) - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<int, int> P;

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

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

    vector<int> h(n);
    rep(i, 0, n) cin >> h[i];

    int ans = 1;
    int tallest = h[0];
    rep(i, 1, n) {
        if (h[i] >= tallest) ans++;
        tallest = max(tallest, h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N,D=gets.chomp.split.map(&:to_i)
x=[]
N.times { x << gets.chomp.split.map(&:to_i)}
ans=0
0.upto(N-1) do |i|
  (i+1).upto(N-1) do |j|
    t = 0
    0.upto(D-1) do |k|
      t += (x[i][k] - x[j][k])**2
    end

    0.upto(Math.sqrt(t)) do |l|
      ans += 1 if t == l**2
    end
  end
end
puts ans
    

Measured memory_bytes: 3836
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main() {
    int n;
    cin >> n;
    ll sum=0;
    for(int i=1; i<n; ++i) {
        sum+=(n-1)/i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
#define M 2005
#define mod 1000000007
long long n,k,C[M][M];
int main(){
	cin>>n>>k;
	int m=n-k;
	if(m==0){
		for(int i=1;i<=k;i++)
			if(i==1)puts("1");
			else puts("0");
		return 0;
	}
	for(int i=1;i<M;i++){
		C[i][i]=C[i][0]=1;
		for(int j=1;j<i;j++)C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	}
	printf("%lld\n",(C[m-1][1]+2*C[m-1][0])%mod*C[k-1][0]%mod);
	for(int i=2;i<=k;i++)printf("%lld\n",(C[m-1][i]+2*C[m-1][i-1]+C[m-1][i-2])%mod*C[k-1][i-1]%mod);
	return 0;
}

Measured memory_bytes: 30208
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define pb push_back
#define fr first
#define sc second



int main() {
	ll n, a[200010], ans = 0, b[200010] = {0};
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		b[a[i]] = b[a[i]-1] + 1;
	}
	for (int i = 1;i <= n;i++)ans = max(ans, b[i]);
	cout << n-ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  int n,m;
  cin >> n >> m;
  vector<pair<int,int> > tre(n);
  REP(i,n) cin >> tre[i].first >> tre[i].second;
  set<int> sx,sy;
  REP(i,n){
    sx.insert(tre[i].first);
    sy.insert(tre[i].second);
  }
  sx.insert(-1023456789);
  sy.insert(-1023456789);
  sx.insert(1023456789);
  sy.insert(1023456789);
  vector<int> vx(sx.begin(),sx.end()),vy(sy.begin(),sy.end());
  vector<vector<int> > fi(vx.size(),vector<int>(vy.size(),0));
  REP(i,n){
    int x=lower_bound(vx.begin(),vx.end(),tre[i].first)-vx.begin();
    int y=lower_bound(vy.begin(),vy.end(),tre[i].second)-vy.begin();
    ++fi[x][y];
  }
  REP(i,vx.size()) REP(j,vy.size()-1) fi[i][j+1]+=fi[i][j];
  REP(i,vx.size()-1) REP(j,vy.size()) fi[i+1][j]+=fi[i][j];
  REP(i,m){
    int tmp;
    cin >> tmp;
    int x0=upper_bound(vx.begin(),vx.end(),tmp-1)-vx.begin()-1;
    cin >> tmp;
    int y0=upper_bound(vy.begin(),vy.end(),tmp-1)-vy.begin()-1;
    cin >> tmp;
    int x1=upper_bound(vx.begin(),vx.end(),tmp)-vx.begin()-1;
    cin >> tmp;
    int y1=upper_bound(vy.begin(),vy.end(),tmp)-vy.begin()-1;
    cout << fi[x1][y1]-fi[x0][y1]-fi[x1][y0]+fi[x0][y0] << endl;
  }
  return 0;
}

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

bool is_prime(int n){
    for(int i=2; i<=sqrt(n); i++){
        if(n%i==0) return false;
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    vector<int> ans;
    for(int i=6; i<=55555; i+=5){
        if(ans.size() == n) break;
        if(is_prime(i)) ans.push_back(i);
    }
    for(auto p=ans.begin(); p!=ans.end(); p++){
        cout << *p << ' ';
    }
    cout << endl;
    return 0;
}


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

using namespace std;

const int maxn = 100 + 20;
int n, a[maxn], g;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		if (a[i] == a[i+1])
		{
			if (a[i+1] == a[i+2])
			{
				i += 1;
				g++;
			}
			else
			{
				g++;
			}
		}
	}
	cout << g;
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
vlist = []
n.times do
  u, k, *v = gets.split.map {|i| i.to_i}
  vlist[u-1] = v
end

q = []
q.push 0
d = Array.new(n, nil)
d[0] = 0

while !q.empty?
  u = q.shift
  vlist[u].each do |i|
    unless d[i-1]
      d[i-1] = d[u] + 1
      q.push i-1
    end
  end
end

d = d.map{ |i| i ? i:-1 }
d.each_with_index do |i, idx|
  puts "#{idx+1} #{i}"
end


Measured memory_bytes: 6872
// author:  Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define all(x) x.begin(),x.end()
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;

//ll modexp(ll x, ll y, ll p)
//{
//	ll res = 1;
//	x = x % p;
//	while (y > 0)
//	{
//		if (y & 1)
//			res = (res * x) % p;
//		y = y >> 1;
//		x = (x * x) % p;
//	}
//	return res;
//}

//ll mulmod(ll a, ll b,ll m)
//{
//	return ((a % m) * (b % m)) % m;
// }

// ll sub_mod(ll a, ll b, ll m){
//    if (a >= b)
//        return a - b;
//    else
//        return m - b + a;
// }

// ll add_mod(ll a, ll b){
//    if (0 == b)
//        return a;

//    b = mod - b;
//    if (a >= b)
//        return a - b;
//    else
//        return mod - b + a;
// }

// ll gcd(ll a, ll b)
// {
// 	if (a == 0)
// 		return b;
// 	else
// 		return gcd(b % a, a);
// }

// ll modInv(ll a)
// {
//     ll g = gcd(a, mod);
//     if (g != 1)
//         return -1;
//     else
//         return modexp(a, mod-2, mod);
// }

int main()
{
	fastio;
	double a=0;
	cin>>a;
	double ans=a*a*a/27;
	printf("%.10lf",ans);
   	return 0;
}


Measured memory_bytes: 256
flag = False
a,b=(int(x) for x in input().split())
for i in range(1,1010):
    mul_1 = int(i*0.08)
    mul_2 = int(i*0.1)
    #print(mul_1)
    if a==mul_1 and b == mul_2:
        flag = True
        print(i)
        if flag == True:
            break
        

else:
    print(-1)
      

Measured memory_bytes: 3060
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.abs;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] a = new int[n];
		int sum = 0;
		for(i=0;i<n;i++) {
			a[i] = parseInt(sc.next());
			sum += a[i] -1; 
		}
		sc.close();
		out.println(sum);
	}
}

Measured memory_bytes: 24404
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
string S;
int dp[505][505];
bool is_cat(int l,int r)//[l,r)
{
	if(l==r)return true;
	if(S[l]!='m'||S[r-1]!='w')return false;
	if(dp[l][r]!=-1)return dp[l][r];
	for(int i=l+1;i<r-1;i++)
	{
		if(S[i]=='e')
		{
			if(is_cat(l+1,i)&&is_cat(i+1,r-1))return dp[l][r]=true;
		}
	}
	return dp[l][r]=false;
}
int main()
{
	memset(dp,-1,sizeof(dp));
	cin >> S;
	if(is_cat(0,(int)S.size()))cout << "Cat" << endl;
	else cout << "Rabbit" << endl;
	return 0;
}

Measured memory_bytes: 2196
#include<stdio.h>
int h,n,a,i,s=0;
int main(){
    scanf("%d%d",&h,&n);
    for(i=n;i--;){
        scanf("%d",&a);
        s+=a;
        if(s>=h){puts("Yes");return 0;}
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 128
N = int(input())
minA = 100001
maxA = -1
maxB = 0
for i in range(N):
	A, B = map(int, input().split())
	minA = min(minA, A)
	if maxA < A:
		maxA = A
		maxB = B


print((minA) + (maxA - minA) + maxB)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <regex>
#include <locale>
using namespace std;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

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

using ll = long long;

int main () {
  int a, b;
  cin >> a >> b;
  set s1 = {1,3,5,7,8,10,12};
  set s2 = {4,6,9,11};
  
  if (a == 2) {
    if (s1.count(b) > 0 || s2.count(b) > 0) {
      cout << "No" << endl;
    }
  } else if (b == 2) {
    if (a == 1) cout << "No" << endl;
  } else if ((s1.count(a) > 0 && s2.count(b) > 0) ||
             (s1.count(b) > 0 && s2.count(a) > 0)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

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

using namespace std;

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

#define rep(pos, len) for(int pos=0;pos<len;pos++)
#define repp(pos, len) for(int pos=1;pos<=len;pos++)

#define INF 987654321
#define IINF 2987654321987654321
#define MOD 998244353

const int MAXN = 1e5 + 50;
int a[MAXN], cnt[MAXN][2];
int main() {
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		cnt[a[i]][i&1]++;
	}

	vector<pii> v[2];
	for(int x = 0; x < 2; x++) {
		for(int i = 0; i < MAXN; i++)
			v[x].emplace_back(cnt[i][x], i);
		sort(v[x].begin(), v[x].end(), greater<pii>());
	}

	if(v[0][0].second != v[1][0].second)
		printf("%d\n", n - v[0][0].first - v[1][0].first);
	else
		printf("%d\n", n - max(v[0][0].first + v[1][1].first, v[0][1].first + v[1][0].first));
}

Measured memory_bytes: 3700