akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;


const int MAX = 1000000;
long long fac[MAX], finv[MAX], inv[MAX];


void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    COMinit();
    int n;
    cin >> n;
    vector<int> a(n+1);
    rep(i,n) cin >> a[i];
    vector<int> c(n+1,-1);
    int p = 0;
    rep(i,n){
        if(c[a[i]]>=0){
            p = c[a[i]] + n - i;
            break;
        }
        c[a[i]] = i;
    }
    for(int k=1;k<=n+1;k++){
        ll res = (COM(n+1,k) - COM(p,k-1) + MOD)%MOD;
        cout << res << endl;
    }
    return 0;
}

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

const int MAXN = 100 + 5;

int N, cnt(1), ans;
int col[MAXN];

int main()
{
    cin >> N ;
    for(int i = 1; i <= N; i++)
    {
        cin >> col[i] ;
        if(col[i] == col[i-1])
            cnt++;
        else
        {
            ans += cnt/2;
            cnt = 1;
        }
    }
    ans += cnt/2;
    cout << ans << endl ;


}


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

public class Solve
{
    public static void Main(string[] args)
    {
        new ABC_A();
    }
}
public class ABC_A
{
    public ABC_A()
    {
        var s = Ex.Read;
        if (s[2] == s[3] && s[4] == s[5])
        {
            Ex.Cw("Yes");
        }
        else Ex.Cw("No");
    }
}
public class ABC_B
{
    public ABC_B()
    {

    }
}
public class ABC_C
{
    public ABC_C()
    {

    }
}
public class ABC_D
{
    public ABC_D()
    {

    }
}
public class ABC_E
{
    public ABC_E()
    {

    }
}
public class ABC_F
{
    public ABC_F()
    {

    }
}
public static class Ex
{
    public static void Cw(string s)
    {
        Console.WriteLine(s);
    }

    public static string Read { get { return Console.ReadLine().Trim(); } }
    public static int ReadInt { get { return int.Parse(Read); } }
    public static long ReadLong { get { return long.Parse(Read); } }
    public static double ReadDouble { get { return double.Parse(Read); } }
    public static string[] ReadArray() { return Read.Split(' '); }
    public static int[] ReadIntArray() { return Read.Split(' ').Select(s => int.Parse(s)).ToArray(); }
    public static long[] ReadLongArray() { return Read.Split(' ').Select(s => long.Parse(s)).ToArray(); }
    public static string[] ReadArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
    public static int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
    public static long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long i64;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int mod=1e9+7;

int main(void) {
    int N, X, Y, Z;
    cin >> N >> X >> Y >> Z;

    int target=(1<<(X+Y+Z)|1<<(X+Y)|1<<X)>>1;

    int M=X+Y+Z+1;
    vvi dp(N+1, vi(1<<M));
    dp[0][0] = 1;

    int i, j, k, cur;
    for (i=0; i<N; i++)
        for (j=0; j<(1<<M); j++)
            for (k=1; k<=10; k++) {
                cur = ((j<<k)^(1<<(k-1))) & ((1<<M)-1);
                if ((cur&target)^target) {
                    dp[i+1][cur] += dp[i][j];
                    dp[i+1][cur] %= mod;
                }
            }

    i64 total=1, invalid=0;
    for (i=0; i<N; i++) total = (total*10) % mod;
    for (i=0; i<(1<<M); i++) invalid = (invalid+dp[N][i]) % mod;

    cout << (total-invalid+mod)%mod << endl;
    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#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;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<int> x(n,0);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        if(h[a-1]>h[b-1]){
            x[b-1] += 1;
        }else if(h[a-1]<h[b-1]){
            x[a-1] += 1;
        }else{
            x[a-1] += 1;
            x[b-1] += 1;
        }
    }
    int ans = 0;
    rep(i,n){
        if(x[i]==0) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  
  vector<int> t(3);
  rep(i,3) cin >> t[i];
  
  sort(t.begin(), t.end());
   
  cout << t[2]-t[1] + t[1]-t[0] << endl;
  
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

def main():
    N,x = map(int,input().split())
    a = list(map(int,input().split()))
    b = a.copy()
    
    ans = 10**15
    for i in range(N):
        time = i*x+sum(b)
        ans = min(ans,time)
        for now in range(N):
            b[now] = min(b[now],a[(now-i-1+N)%N])

    print(ans)

if __name__ == "__main__":
    main()
    


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;
int K;
int A[3];

int main() {

	cin >> A[0] >> A[1] >> A[2] >> K;
	sort(A, A + 3);
	int ans = A[0] + A[1];
	ans += A[2] * pow(2, K);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
W = [int(x) for x in input().split()]

a = abs(sum(W[:1]) - sum(W[1:]))
for i in range(1, N):    
    S_1 = sum(W[:i])
    S_2 = sum(W[i:])
    if abs(S_1 - S_2) < a:
        a = abs(S_1 - S_2)

print(a)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b,ans = 0,dengen = 0,i = 0;
    cin >> a >> b;
    dengen = 1;
    while(dengen < b){
        i++;
        dengen = dengen - 1 + a;
    }
    cout << i <<endl;
}

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

using namespace std;

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

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

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, x; cin >> n >> x;
  
  vector<int> a(n+1);
  REP(i, n) {
    cin >> a[i];
  }
  a[n] = x;

  sort(a.begin(), a.end());
  vector<int> diff(n);
  REP(i, n) {
    diff[i] = a[i+1] - a[i];
  }

  int ans = diff[0];
  REP(i, n-1) {
    ans = gcd(ans, diff[i+1]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
#include "algorithm"
#include "iomanip"
#include "iostream"
#include "queue"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;

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

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

template <typename T>
void drop(const T& x) {
  cout << x << endl;
  exit(0);
}

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

  ll X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;

  V<ll> ps(A);
  rep(i, A) cin >> ps[i];
  sort(all(ps), [](ll a, ll b) { return a > b; });

  V<ll> qs(B);
  rep(i, B) cin >> qs[i];
  sort(all(qs), [](ll a, ll b) { return a > b; });

  V<ll> rs(C);
  rep(i, C) cin >> rs[i];
  sort(all(rs), [](ll a, ll b) { return a > b; });

  ll sum = 0;
  priority_queue<ll, V<ll>, greater<ll>> rg_pq;

  rep(i, X) {
    sum += ps[i];
    rg_pq.push(ps[i]);
  }

  rep(i, Y) {
    sum += qs[i];
    rg_pq.push(qs[i]);
  }

  ll next_i = 0;

  while (next_i < C && rs[next_i] > rg_pq.top()) {
    ll rm = rg_pq.top();
    sum -= rm;
    rg_pq.pop();
    sum += rs[next_i];

    next_i++;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 4852
import functools
import math
import fractions
n, x = map(int, input().split())
xx = list(map(int, input().split()))  # x1 x2 ... xn
xx.append(x)
xx.sort()
diff = []  # 隣接する都市の距離を保存
d = 0
if len(xx) > 2:
    for i in range(1, len(xx)):
        diff.append(abs(xx[i - 1] - xx[i]))
    d = functools.reduce(fractions.gcd, diff)
else:
    d = abs(xx[0] - xx[1])
print(d)


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

int digit(int n){
    while(n>=10){
         n /= 10;
       }
   return n;
}

int main(){
 int n;
 cin >> n;
 int ans = 0;
 int c[10][10] = {0};
 for(int i= 1;i<=n;i++){
     for(int a = 1; a<=9 ; a++){
        for(int b = 1; b<=9 ; b++){ 
        if(digit(i)==a && i%10 == b) c[a][b] ++;
         }
     }
 }  
 for(int a = 1; a<=9 ; a++){
     for(int b = 1; b<=9 ; b++){ 
         ans += c[a][b]*c[b][a];
     }
}
 cout <<  ans << endl;
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n,m;
    cin >> n;
    vector<string> s(n);
    for(auto &x:s)cin >> x;
    cin >> m;
    vector<string> t(m);
    for(auto &x:t)cin >> x;

    map<string, int> list;
    for(int i=0;i<n;i++){
        if(list.count(s[i])){
            list.at(s[i])++;
        }else{
            list.insert(make_pair(s[i],1));
        }
    }

    for(int i=0;i<m;i++){
        if(list.count(t[i])){
            list.at(t[i])--;
        }else{
            list.insert(make_pair(t[i],-1));
        }
    }

    int maxval=-inf;
    for(auto it=list.begin();it!=list.end();it++){
        maxval=max(maxval,it->second);
    }

    if(maxval<0)cout << 0 << endl;
    else cout << maxval << endl;

    return 0;
}


Measured memory_bytes: 3620
n = gets.chomp.to_i
t,a = gets.chomp.split.map(&:to_i)
h = gets.chomp.split.map(&:to_i)

heikins = []

for i in h do
    k = t - i*0.006
    ke = a - k
    heikins << ke.abs
end

puts heikins.index(heikins.min) + 1

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<stack>
#include<queue>

using namespace std;

#define inf              1e9   // this is double value
#define ms(a,b)          memset(a,b,sizeof a)
#define CLR(a)           memset(a,0,sizeof a)
#define input_file       freopen("in.txt","r",stdin)
#define output_file      freopen("out.txt","w",stdout)
#define N                100000008
#define LL               long long
#define nl               printf("\n")
#define spc              printf(" ")

int main()
{
	int l,flag,i,j;
	char str[1005];
	while(cin>>str)
	{
		l=strlen(str);
		flag=0;
		for(i=0,j=l-1; i<l; i++,j--)
		{
			if(str[i]!=str[j])
			{
				flag=1;
				break;
			}
		}
		if(flag==1)
			cout<<"No"<<endl;
		else 
			cout<<"Yes"<<endl;
	}
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int b = 2e6;
int base[b];
/**
7 111111111111111
*/
int main () {
    int k;
    cin >> k;
 
    if (k % 7 == 0) k /= 7;
 
    int cur = 1;
    int sum = 0;
 
    for (int i = 1 ; i < b ; ++ i) {
        sum += cur;
        sum %= k;
        cur = cur * 10 % k;
        if (sum == 0) return !printf("%d\n", i);
    }
    printf("-1");
}

Measured memory_bytes: 3756
import sys

n1, n2 = [int(i) for i in input().split()]

r1 = 2018

if n2 - n1 >= 2019:
    print(0)
    sys.exit()


for i3 in range(n2 - n1):
    n4 = i3 + n1

    t1 = n2 - n4
    if t1 >= 2019:
        t1 = 2019
    for i5 in range(t1):
        n5 = i5 + n4 + 1

        if ((n4 * n5) % 2019)  < r1:
            r1 = ((n4 * n5) % 2019)

print(r1)


Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <vector>
#define pb push_back
#define lld long long
#define pii pair<int,int>
#define mp make_pair
#define NMAX 100005

using namespace std;

vector<pii>v;
int n, w;
int weight, value;

lld dp[2][NMAX];

int main()
{
    scanf("%d %d",&n,&w);
    for (int i=1;i<=n;++i)
    {
        scanf("%d %d",&weight, &value);
        v.pb(mp(weight, value));
    }
    int now = 1, last = 0;
    for (int i=0;i<v.size();++i)
    {
        for (int j=0;j<=w;++j)
        {
            dp[now][j] = 0;
        }
        for (int j=0;j<=w;++j)
        {
            dp[now][j] = dp[last][j];
            if (j - v[i].first<0)
            {
                continue;
            }
            dp[now][j] = max(dp[now][j], dp[last][j - v[i].first] + v[i].second);
        }
        now ^= 1;
        last ^= 1;
    }
    printf("%lld", dp[last][w]);
    return 0;
}


Measured memory_bytes: 1792
a,b=map(int,input().split())
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  return arr
def gcd(a,b):
  if b==0:
    return a
  return gcd(b,a%b)

g=gcd(a,b)
l=factorization(g)
print(len(l)+1)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char *argv[])
{
	int N, M;
	int k[10], s[10][10], p[10];
	cin >> N >> M;
	
	for (int i = 0; i < M; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			cin >> s[i][j];
		}
	}
	for (int i = 0; i< M; i++) {
		cin >> p[i];
	}
	int m = pow(2, N) - 1;
	int ans = 0, ok = 0;
	bool flg = true;
	for (int i = 0; i <= m; i++) {
		ok = 0;
		for (int j = 0; j < M; j++) {
			int sum = 0;
			for (int l = 0; l < k[j]; l++) {
				int ss = s[j][l] - 1;
				sum = sum + ((i >> ss) & 1);
			}
			if (sum % 2 == p[j]) {
				ok++;
			} else {
				break;
			}
		}
		if (ok == M) {
			ans++;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

class UnionFindTree {
private:
    vector<int> parent;
    vector<int> count;
public:
    UnionFindTree(int n) : parent(n), count(n, 1) {
        // 最初は全てを根として初期化
        for(int i = 0; i < n; i++) parent[i] = i;
    }

    int get_root(const int x) {
        // データxが属する木の根を取得する
        if (parent[x] == x) return x;
        // 取得したものは直接木の根をつなぐ(経路圧縮)
        return parent[x] = get_root(parent[x]);
    }

    void unite(const int x, const int y) {
        // xとyの木を併合する
        int rx = get_root(x);
        int ry = get_root(y);
        // 元から同じ木に属している場合は何もしない
        if (rx == ry) return;
        // xの属する木をyの属する木につける
        parent[rx] = ry;
        count[ry] += count[rx];
        count[rx] = 0;
    }

    bool is_same_root(const int x, const int y) {
        return get_root(x) == get_root(y);
    }

    int get_size(const int x) {
        return count[get_root(x)];
    }

    void print() {
        for(auto elm : parent) cout << elm << " ";
        cout << endl;
        for(auto elm : count) cout << elm << " ";
        cout << endl;
    }
};

int main(){
    int64_t n, m;
    cin >> n >> m;

    int64_t base = n * (n - 1) / 2;
    UnionFindTree tree(n);
    vector<pair<int, int>> bridge(m);
    for (auto i = 0; i < m; i++) {
        int a, b; cin >> a >> b; a--; b--;
        bridge[i].first = a;
        bridge[i].second = b;
    }

    vector<int64_t> ans(m);
    ans[m - 1] = base;
    for (auto i = m - 1; i > 0; i--) {
//        tree.print();
        if(not tree.is_same_root(bridge[i].first, bridge[i].second)) {
            int64_t a = tree.get_size(bridge[i].first);
            int64_t b = tree.get_size(bridge[i].second);
//            cout << a << " " << b << endl;
            ans[i - 1] = ans[i] - a * b;
        } else ans[i - 1] = ans[i];
        tree.unite(bridge[i].first, bridge[i].second);
//        cout << ans[i - 1] << endl;
    }

    for (auto i = 0; i < m; i++) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;


    UnionFind(ll N): par(N), siz(N, 1LL) {
        for (ll i = 0; i < N; ++i) par[i] = i;
    }

    void init(ll N) {
        par.resize(N);
        siz.assign(N, 1LL);
        for (ll i = 0; i < N; ++i) par[i] = i;
    }


    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }


    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll N,M; cin >> N >> M;
    ll point = N*(N-1)/2;
    vector<ll> ans;
    UnionFind tree(N);
    int A[100100],B[100100];
    rep(i,0,M){
        int a,b; cin >> a >> b;
        a--; b--;
        A[i] = a;
        B[i] = b;
    } 

    
    rep(i,0,M){
        ans.pb(point);
        if(tree.same(A[M-1-i], B[M-1-i])) continue;

        ll a = tree.size(A[M-1-i]);
        ll b = tree.size(B[M-1-i]);
        point -= a*b;
        tree.unite(A[M-1-i], B[M-1-i]);
    }
    reverse(all(ans));
    rep(i,0,SZ(ans)) cout << ans[i] << "\n";
    return 0;
}


Measured memory_bytes: 6644
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,x[1000],i,j,sa,MAX,MIN;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&x[i]);
	}
	  MIN=2001;
	for(i=0;i<=2000;i++){
		MAX=-1;
		for(j=0;j<n;j++){
			sa=i-x[j];
			if(sa<0){
				sa=-sa;
			}
			MAX=max(MAX,sa);
		}
		MIN=min(MAX,MIN);
	}
	printf("%d\n",MIN);
	return 0;
}


Measured memory_bytes: 2760
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

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

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

using Weight = ll;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};
bool operator<(const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
			   e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using AdjMatrix = vector<vector<Weight>>;

// ワーシャルフロイド法による全点間の最小コスト算出
void warshallFloyd(AdjMatrix &m) {			   // nは頂点数
	for (int i = 0; i < m.size(); i++)		   // 経由する頂点
		for (int j = 0; j < m.size(); j++)	 // 開始頂点
			for (int k = 0; k < m.size(); k++) // 終端
				m[j][k] = min(m[j][k], m[j][i] + m[i][k]);
}

void foreach_permutation(int n, std::function<void(int *)> f) {
	int indexes[n];
	for (int i = 0; i < n; i++)
		indexes[i] = i;
	do {
		f(indexes);
	} while (std::next_permutation(indexes, indexes + n));
}

AdjMatrix m;
int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N, M, R;
	cin >> N >> M >> R;

	vector<int> r(R);
	for (int i = 0; i < R; i++) {
		cin >> r[i];
		r[i]--;
	}

	m.assign(N, vector<Weight>(N, INF));
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		m[a - 1][b - 1] = c;
		m[b - 1][a - 1] = c;
	}

	warshallFloyd(m);

	ll ans = 1e18;
	foreach_permutation(R, [&](int *indexes) {
		ll cost = 0;
		for (int i = 0; i < R - 1; i++) {
			cost += m[r[indexes[i]]][r[indexes[i + 1]]];
		}
		if (cost < ans) {
			ans = cost;
		}
	});
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main()
{
    string S, A;
    int count = 0, a;
    cin >> S;

    vector<char> v;

    for (int i = 0; i < S.length(); i++)
    {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')
        {
            v.push_back(S[i]);
        }

        else
        {
            v.push_back('#');
        }
    }

    for (int i = 0; i < v.size(); i++)
    {
        if (v[i] != '#')
        {
            count++;
            a = max(a, count);
        }

        if (v[i] == '#')
        {
            count = 0;
        }
    }

    cout << a;
}

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

int main() {
    double n,k;
    cin >> n >> k;
    vector<double> p(n);
    rep(i,n){
        double a;
        cin >> a;
        p[i] = a/2.0 + 0.5;
    }
    int cnt = k;
    double ans1 = 0;
    double ans = 0;
    rep(i,k){
        ans += p[i];
    }
    ans1 = ans;
    while(cnt<=n-1){
        ans = ans + p[cnt] - p[cnt-k];
        ans1 = max(ans1,ans);
        cnt++;
    }
    cout << setprecision(9) << ans1 << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  string S; cin >> S;
  int N = S.size();
  S += 'x';
  for (int i = 0; i < N; i += 2) {
    if (S[i] != 'h' || S[i+1] != 'i') {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int n, m, i, j, k, l, r;
int main(){
	scanf("%d%d%d", &l, &r, &k);
	for(i=l; i<=r; i++){
		if(i%k == 0) n++;
	}
	printf("%d\n", n);
	return 0;
}

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

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);cout.tie(NULL); 
    cout << fixed << setprecision(10);
    
    // write code here
    int t=1;
    // cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        int dp[n];
        dp[0]=0;
        dp[1]=abs(a[1]-a[0]);
        
        for(int i=2;i<n;i++)
            {
                dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
            }
      cout<<dp[n-1];

     }
 
        return 0;
 } 

Measured memory_bytes: 4248
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>

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

using namespace std;
typedef long long int ll;
const int INF = 100000000;

vector<int> left;
vector<int> right;
typedef pair <int, int> P;

int main()
{
    int n;
    cin >> n;
    vector<P> arm;
    rep(i, n) {
        int x, l;
        cin >> x >> l;
        P edge(x + l, x - l);
        arm.push_back(edge);
    }
    // 右端の座標位置でソート
    sort(arm.begin(), arm.end());
    int x = -INF;
    int ans = 0;
    rep(i, arm.size()) {
        // 重なったら選ばない
        if (arm[i].second < x) continue;
        // 重なっていなかったら右端を基準位置にして答え++
        else {
            x = arm[i].first;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include<iostream>
using namespace std;
int num[55];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>num[i];
	}
	long long sum=0;
	for(int i=0;i<n;i++){
		if(num[i]==0)
			continue;
		for(int j=i+1;j<n;j++){
			sum+=num[i]*num[j];
		}
	}
	cout<<sum;
	return 0;
} 

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

#ifdef LOCAL 
string to_string(char a) { return string(1,a); }
string to_string(bool a) { return a ? "1" : "0"; }
string to_string(const char* a) { return (string)a; }
string to_string(string a) { return a; }
string to_string(vector<bool> v) {
	string s = "["; for(unsigned i=0;i<v.size();i++){ s += ((i>0)?" ":"");
    s += char('0'+v[i]); } 	s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) {
	bool b = 1; string s = "["; for (const auto& x: v) {
		if (!b) {s += ", ";} b = 0; s += to_string(x); } s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void dbgf() { cerr << endl; }
template<class H, class... T> void dbgf(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	dbgf(t...); }
#define dbg(...) cerr << #__VA_ARGS__ << " = ", dbgf(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
#define boolout(x) cout<<(x?"YES":"NO")<<endl;
typedef long long ll;

const int mod = 1e9+7;

void add_self(int &a, int b){
    a+=b;
    if (a>=mod) {
        a-=mod;
    }
}

void solve()
{
    string s;
    cin >> s;
    int d;
    cin >> d;

    vector<vector<int>> dp(d, vector<int>(2, 0));

    dp[0][0] = 1;
    for (unsigned pos = 0; pos < s.size(); ++pos) {
        dbg(dp[0][0], dp[0][1]);
        vector<vector<int>> newdp(d, vector<int>(2, 0));
        for (int sum = 0; sum < d; ++sum) {
            for (int smaller = 0; smaller < 2; ++smaller) {
                for (int digit = 0; digit < 10; ++digit) {
                    if (digit > s[pos]-'0' && smaller==0) {
                       break; 
                    }
                    add_self(newdp[(sum+digit)%d][digit < (s[pos]-'0') || smaller], dp[sum][smaller]);
                        
                }
            }
        }
        dp = newdp;
    }

    dbg(dp[0][0], dp[0][1]);
    int ans = dp[0][0] + dp[0][1] - 1; 
    if (ans==-1) {
       ans += mod; 
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t; // read t. cin knows that t is an int, so it reads it as such.
    for (int i = 1; i <= t; ++i) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
n = int(input())
v = list(map(int,input().split()))
dict1 = {}
dict2 = {}

for i,key in enumerate(v):
    if i%2 == 0:
        if key not in dict1:
            dict1[key] = 1
        else:
            dict1[key] += 1
    else:
        if key not in dict2:
            dict2[key] = 1
        else:
            dict2[key] += 1

max1 = 0
max2 = 0
if len(dict1) == 1 and len(dict2) == 1:
    if v[0] == v[1]:
        ans = n//2
    else:
        ans = 0
elif len(dict1) == 1:
    dict2[v[0]] = 0
    for key in dict2:
        max2 = max(max2,dict2[key])
    else:
        ans = n//2 - max2
elif len(dict2) == 1:
        dict2[v[1]] = 0
        for key in dict1:
            max1 = max(max1,dict1[key])
        else:
            ans = n//2 - max1
else:
    second1 = 0
    second2 = 0
    maxkey1 = 0
    maxkey2 = 0
    secondkey1 = 0
    secondkey2 = 0
    for key in dict1:
        if dict1[key] > max1:
            max1,second1, = dict1[key],max1
            maxkey1,secondkey1 = key,maxkey1
        elif dict1[key] > second1:
            second1 = dict1[key]
            secondkey1 = key
    for key in dict2:
        if dict2[key] > max2:
            max2,second2, = dict2[key],max2
            maxkey2,secondkey2 = key,maxkey2
        elif dict2[key] > second2:
            second2 = dict2[key]
            secondkey2 = key
    if maxkey1 == maxkey2:
        if dict1[secondkey1] < dict2[secondkey2]:
            ans = n - dict1[maxkey1] - dict2[secondkey2]
        else:
            ans = n - dict2[maxkey2] - dict1[secondkey1]
    else:
        ans = n - dict1[maxkey1] - dict2[maxkey2]

print(ans)

Measured memory_bytes: 17760
n = int(input())
alist = list(reversed(sorted([int(input()) for _ in range(n)])))
blist = list(reversed(sorted([int(input()) for _ in range(n)])))
INF = pow(10, 9) + 7
a = alist.pop()
b = blist.pop()
aset, bset = 0, 0
ans = 1
while len(alist) > 0 or len(blist) > 0:
  if a < b:
    if bset > 0:
      ans = (ans * bset) % INF
      bset -= 1
    else:
      aset += 1
    a = INF
    if len(alist) > 0:
      a = alist.pop()
  else:
    if aset > 0:
      ans = (ans * aset) % INF
      aset -= 1
    else:
      bset += 1
    b = INF
    if len(blist) > 0:
      b = blist.pop()
print(ans % INF)


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

using namespace std;

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

  string o, e;
  cin >> o >> e;

  for (size_t i = 0; i < e.size(); ++i) {
    cout << o[i] << e[i];
  }
  if (o.size() - e.size() == 1) cout << o.back();
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
while True:
    N, M, P = map(int, input().split())
    if N == 0 and M == 0 and P == 0:
        break
    X = [0 for i in range(N)]
    for i in range(N):
        X[i] = int(input())
    
    if X[M - 1] != 0:
        print(sum(X) * (100 - P) // X[M - 1])
    else:
        print(0)


Measured memory_bytes: 5620
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

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

int main()
{
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	a--;
	ll g = c*d/gcd(c,d);

	ll sum1 = b-(b/c+b/d)+b/g;
	ll sum2 = a-(a/c+a/d)+a/g;

	cout << sum1-sum2 << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int x = sc.nextInt();
      int y = sc.nextInt();
      long total = 0;
      if(a + b <= c * 2) {
        total = a * x + b * y;
      } else {
        int ab = Math.min(x, y);
        total = ab * 2 * c;
        x -= ab;
        y -= ab;
        total += Math.min(a*x + b*y, (x + y) * 2 * c);
      }
      System.out.println(total);
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int m;
  cin >> m;
  vector<int> b(m);
  rep(i, m) cin >> b[i];

  vector<int> result;
  set_symmetric_difference(all(a), all(b), back_inserter(result));
  for (auto r : result)
    cout << r << endl;
  return 0;
}



Measured memory_bytes: 6484
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define e endl
#define debug cout<<"we are debuuging"<<endl;
#define MOD 998244353
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{

   ll n;
   cin>>n;
   ll ans=0;
   vector<ll> v;
   for(ll i=2;i*i<=n;i++)
   {
        if(n%i==0)
        {
             while(n%i==0)
             {
                  n/=i;
                  ans++;
             }
             v.pb(ans);
             ans=0;
        }
   }
   if(n>1)
     v.pb(1);
     ll res=0,fans=0;
   for(auto j: v)
   {
        for(int i=1;i<64;i++)
        {
             if(j>=(i*(i+1))/2)
               res=i;
        }
        fans+=res;
   }
   cout<<fans<<e;
}


Measured memory_bytes: 3628
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
    }
    // annotate for rust-analyzer
    let n: usize = n;

    println!("{}", (1000 - (n % 1000)) % 1000);
}


Measured memory_bytes: 2136
def get_area(ps):
    """頂点集合psから成る多角形の面積を求める。"""
    n = len(ps)
    ans = 0
    for i in range(n):
        p1 = ps[i]
        p2 = ps[i - 1]
        ans += (p1[0] * p2[1] - p2[0] * p1[1]) / 2
    return abs(ans)


n = int(input())
ps = [list(map(int, input().split())) for i in range(n)]

print(get_area(ps))


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

int main(){
    int n;
    cin >> n;
    int sum = 0;
    int ans = 1e8;
    vector<int> x(n);
    rep(i,0,n) cin >> x.at(i);
    sort(x.begin(),x.end());
    int a = x.at(0);
    int b = x.at(n-1); 
    
    rep(p,a,b+1){
        rep(i,0,n){
            sum += (int)pow((double)x.at(i)-(double)p,2.0);
        }
        ans = min(ans,sum);
        sum = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<int> dp(k+1,10);
    dp[0] = 0;
    for(int i = 1; i <= k; i++){
        bool is_exist = false;
        for(int j = 0; j < n; j++){
            if(i-a[j]>=0){
                if(dp[i-a[j]]==0){is_exist = true;}
            }
        }
        if(is_exist){
            dp[i] = 1;
        }else{
            dp[i] = 0;
        }
    }
    if(dp[k]==1){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
#include <fstream>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    int ans = 1;
    vector<int> M(n);
    M[0] = 200001;
    for (int i = 1; i < n; ++i) {
        M[i] = min(M[i - 1], p[i - 1]);
    }
    for (int i = 1; i < n; ++i) {
        if (p[i] <= M[i])ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <list>
#include <chrono>
#include <fstream>
#include <ctime>
#include <random>

using namespace std;
using namespace std::chrono;

const int mod = int(1e9) + 7;
//const int SZ = 10100;
//const int MX = 210500;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
#define ll long long
#define sqr(x) (x)*(x)
#define FREIN(file) freopen(file, "rt", stdin)

#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 6,5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,_6,N,...) N
#define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro, nargs) macro ## nargs
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)

const int magic = 3;

void solve();
//void init();

void dump(const vector<int>& a) {
    for (int i = 0; i < a.size(); i++) {
        cerr << a[i] << ' ';
    }
    cerr << endl;
}

int main(int argc, char** argv)
{
#ifdef LOCAL
    freopen("../in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
//    cin >> t;
//    init();
    while(t--){
        solve();
    }
    return 0;
}
// Solution ***********************************************************************************************

const int MX = 100500;


void solve() {
    int n, k;
    cin >> n >> k;
    long long ans = 0;
    for (int b = k + 1; b <= n; b++) {
        int cnt = b - k;
        long long s = cnt;
        s *= (n + 1) / b;
        if ((n + 1) % b) {
            int m = (n + 1) % b;
            m = b - m;
            m = cnt - m;
            if (m > 0) {
                s += m;
            }
        }
//        cerr << b << ' ' << s << endl;
        ans += s;
    }
    if (k == 0) {
        ans = n;
        ans *= n;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
typedef long long ll;

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i = 0; i < N; ++i) {
		cin >> A[i];
	}

	ll res = 0;
	int msk = 0, sum = 0;
	for(int l = 0, r = 0; l < N; l++){
		while(r < N && (msk ^ A[r]) == sum + A[r]) {
			msk ^= A[r];
			sum += A[r];
			res++;
			r++;
		}
		res += r - l - 1;
		msk ^= A[l];
		sum -= A[l];
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#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 it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    map<int,long long int>in;
    vector<int>in2;
    rep(i,n){
      int a;
      long long int b,c;
      cin>>a>>b>>c;
      if(in[a])in[a]+=b*c;
      else {in[a]+=b*c;in2.pb(a);}
    }
    bool han=false;
    rep(i,in2.size())if(in[in2[i]]>=1000000){han=true;cout<<in2[i]<<endl;}
    if(!han)cout<<"NA"<<endl;
  }
}

Measured memory_bytes: 1288
fun main(args: Array<String>) {
    val s = readLine()!!.split(" ")[0].map { it.toChar() }
    if (s[2] == s[3]){
        if (s[4] == s[5]){
            println("Yes")
        } else {
            println("No")
        }
    } else {
        println("No")
    }
}

    

Measured memory_bytes: 37904
S = input()
combination = 2 ** (len(S) - 1)

ans = 0
for i in range(combination):
    # 2進数に直す
    bin_str = bin(i)[2:]

    # 上の桁分を埋める
    bin_str = '0' * (len(S) - len(bin_str) - 1) + bin_str

    formula = ''
    for i, s_char in enumerate(S):
        # 0の場合はなし、1の場合は'+'を入れて計算させる
        plus = ''
        if len(S) - 1 != i and bin_str[i] == '1':
            plus = '+'

        formula += s_char + plus

    # 文字列から計算する
    ans += eval(formula)

print(ans)

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *

N, M = map(int, input().split())
S, T = input(), input()
gcd = lambda a, b: a if b == 0 else gcd(b, a%b)
g = gcd(N, M)
n, m = N//g, M//g
for i in range(min(N//n, M//m)):
    if S[n*i] != T[m*i]:
        print(-1)
        exit()
print(N*M//g)


Measured memory_bytes: 39536
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	ll n, k, s;
	scanf("%ld %ld %ld", &n, &k, &s);
	V ans(n, s);
	rep(i, k, n){
		if(s==1e9) ans[i] = 1;
		else ans[i] = s+1;
	}
	for(ll i: ans) printf("%ld ", i);
	return 0;
}


Measured memory_bytes: 2048
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int64_t n, k, q;
    cin >> n >> k >> q;

    vector<int64_t> cs(n, 0);
    for (int i = 0; i < q; i++)
    {
        int a;
        cin >> a;
        cs[a - 1]++;
    }
    for (int i = 0; i < n; i++)
    {
        if (k - q + cs[i] > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 1408
import sys
def func(x):
   fun = x*x
   return fun
def cal(d):
   s = 0
   for i in range(1,int(600/d)):
       s = s + d * func(i*d)
   return s
for line in sys.stdin.readlines():
   d = int(line)
   print(cal(d))

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

using namespace std;

int main()
{
    std::ios::sync_with_stdio(false);
   
    int n;
    cin>>n;
    int a[n];
    for(int i = 0; i < n;i++)
    {
        cin>>a[i];
    }
    int sum = 0;
    int sumfinal = 0;
    for(int i = 1; i < n;i++)
    {
        if(a[i] <= a[i-1])
        {
            sum++;
            sumfinal = max(sum,sumfinal);
        }
        else{
            sum = 0;
        }
    }
    cout<<sumfinal;
        return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        String str;
        while(!(str = scn.next()).equals("-")) {
            int lim = scn.nextInt();
            for(int i = 0; i < lim; i++) {
                int div = scn.nextInt();
                str = str.substring(div) + str.substring(0, div);
            }
            System.out.println(str);
        }
    }
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    sort(ALL(a));

    int cnt = 0;
    while (a[0] < a[2] - 1)
    {
        a[0] += 2;
        cnt++;
    }
    while (a[1] < a[2] - 1)
    {
        a[1] += 2;
        cnt++;
    }
    if (a[0] == a[1] && a[1] == a[2])
        OP(cnt);
    else if (a[0] == a[1])
        OP(cnt + 1);
    else
        OP(cnt + 2);

    return 0;
}

Measured memory_bytes: 256
N = int(input())
if N % 1000 == 0:
    print(0)
elif N < 1000:
    i = 1000
    print(i-N)
elif N < 2000:
    i = 2000
    print(i-N)
elif N < 3000:
    i = 3000
    print(i-N)
elif N < 4000:
    i = 4000
    print(i-N)
elif N < 5000:
    i = 5000
    print(i-N)
elif N < 6000:
    i = 6000
    print(i-N)
elif N < 7000:
    i = 7000
    print(i-N)
elif N < 8000:
    i = 8000
    print(i-N)
elif N < 9000:
    i = 9000
    print(i-N)
elif N < 10000:
    i = 10000
    print(i-N)

Measured memory_bytes: 9076