akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

vector<ll> fact_inv, fact;

ll pow(int a, int b) {
	if (!b) {
		return 1;
	}
	else if (b % 2 == 0) {
		ll d = pow(a, b/2);
		return (d * d) % MOD;
	}
	else {
		return (a*pow(a, b-1)) % MOD;
	}
}


ll inv(int a){
    return pow(a, int(MOD-2));
}

ll comb(int a, int b){
    if(a < b) return 0;
    if(a < 0 || b < 0) return 0;
    ll ret = fact[a];
    ret = ret * fact_inv[b] % MOD;
    ret = ret * fact_inv[a-b] % MOD;
    return ret;
}

void precom(int n){
    fact.resize(n);
    fact_inv.resize(n);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    for(int i = 2; i < n; ++i) fact[i] = fact[i-1] * i % MOD;
    for(int i = 2; i < n; ++i) fact_inv[i] = inv(fact[i]);
    return;
}

int main(){
    int n; cin >> n;
    precom(n+10);
    int dif;
    
    vector<int> idx(n, 0);
    REP(i, n+1){
        int a; cin >> a;
        if(idx[a-1] == 0) idx[a-1] = i+1;
        else dif = i+1 - idx[a-1];
    }
    REP(i, n+1){
        ll ans = comb(n+1, i+1) - comb(n-dif, i);
        cout << (ans<0 ? ans + MOD : ans) << "\n";
    }
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>

constexpr int N = 2000;

void solve() {
    std::vector<std::string> ss(3);
    for (auto& s : ss) std::cin >> s;

    int ans = 10000;

    for (int q = 0; q < 6; ++q) {
        std::vector<std::set<int>> ls(3);
        for (int i = 0; i < 3; ++i) {
            auto s = ss[i],
                 t = ss[(i + 1) % 3];
            if (i == 2) std::swap(s, t);

            int n = s.length(),
                m = t.length();

            for (int l = 0; l <= N; ++l) {
                bool ok = true;
                for (int j = 0; j < m; ++j) {
                    if (l + j >= n) break;
                    if (s[l + j] != '?' && t[j] != '?' &&
                        s[l + j] != t[j]) ok = false;
                }

                if (ok) ls[i].insert(l);
            }
        }

        for (auto l1 : ls[0]) {
            for (auto l2 : ls[1]) {
                int l = l1 + l2;
                if (l < (int)ss[0].length() && !ls[2].count(l)) continue;

                int len = std::max({(int)ss[0].length(),
                                    (int)ss[1].length() + l1,
                                    (int)ss[2].length() + l});
                ans = std::min(ans, len);
            }
        }

        std::next_permutation(ss.begin(), ss.end());
    }
    std::cout << ans << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
#include <math.h>
#include <string>
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
	int N, M;
	scanf("%d %d", &N, &M);
	N == M ? puts("Yes") : puts("No");
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
  using namespace std;
  #define ll long long
  
  int main()
  {
    ios::sync_with_stdio(0);
      cin.tie(0);
      cout.tie(0);

    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++) cin >>a[i];
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<k;i++) ans+=a[i];
    cout << ans;

    return 0;
  }

Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  double a, b, x;
  cin >> a >> b >> x;
  x /= a;
  if (x >= a*b/2) {
    double s = a*b-x;
    double l = s*2/a;
    double ans = atan(l/a)/M_PI*180;
    cout << fixed << setprecision(8) << ans << endl;
  } else {
    double l = x*2/b;
    double ans = 90-atan(l/b)/M_PI*180;
    cout << fixed << setprecision(8) << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a;
  int b;
  string c;
  string d;
  int i;
  cin >>a>>b;
  for (i=0;i<b+2;i++){
    d=d+"#";
  }
  cout <<d<<endl;
  for (i=0;i<a;i++){
    cin >>c;
    cout <<"#"<<c<<"#"<<endl;
  }
  cout <<d<<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>;

const int INF = 1001001001;

int main() {
  int h,n;
  cin >> h >> n;
  vector<vector<int>> ab(n,vector<int>(2,0));

  for(auto& v : ab) {
    cin >> v[0] >> v[1];
  }

  vector<vector<int>> dp(n+1,vector<int>(h+1,INF));
 rep(j,h+1) {
   dp[0][j] = ((j + ab[0][0] - 1) / ab[0][0])*ab[0][1];
 }

 rep(i,n) {
   rep(j,h+1){
       if (i == 0) continue;
       dp[i][j] = min(min(dp[min(i-1,n)][j],dp[i][max(j-ab[i][0],0)]+ab[i][1]),dp[i][j]);
     }
 }

  cout << dp[n - 1][h] << endl;
  return 0;
}


Measured memory_bytes: 39424
N, X, Y = list(map(int,input().split()))
 
Num = [0] * N
for j in range(1, N + 1):
  for i in range(1, j):
    D = min(j - i, abs(j - Y) + 1 + abs(i - X))
    Num[D] += 1
for k in range(1, N):
  print(Num[k])

Measured memory_bytes: 3444
array=gets.split.map { |e|e.to_i }
number=array[0]-2
min=array[1]+array[1]*number+array[2]
max=array[1]+array[2]*number+array[2]
answer=max-min+1

if array[0]==1 && array[1]!=array[2]
  puts(0)
elsif array[0]==1 && array[1]=array[2]
  puts(1)
elsif array[1]>array[2]
  puts(0)
else
puts(answer)
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
int n,m;
vector<P> in;
int main()
{
	int x;
	while(~scanf("%d %d",&n,&m))
	{
		in.clear();
		REP(i,1,n)
		{
			RI(x);
			in.PB(MP(x,0));
		}
		REP(i,1,m)
		{
			RI(x);
			in.PB(MP(x,1));
		}
		sort(in.begin(), in.end());

		LL ans=0;
		n++;
		m++;
		FOR(i,in)
		{
			if(i->S==0)
			{
				if(n>0)
				{
					ans += (LL)m*i->F;
					n--;
				}
			}
			if(i->S==1)
			{
				if(m>0)
				{
					ans += (LL)n*i->F;
					m--;
				}
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}



Measured memory_bytes: 2420
#include <iostream>

int main()
{
	std::string tenki,yoho;

	std::cin >> tenki;

	if (tenki == "Sunny")
	{
		yoho = "Cloudy";
	}
	else if (tenki == "Cloudy")
	{
		yoho = "Rainy";
	}
	else
	{
		yoho = "Sunny";
	}

	std::cout << yoho << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

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

const int mod = 998244353;
const int MX = (int)2e5;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int n;
	cin >> n;
	unordered_map<string, int> mp;
	while(n--){
		string s;
		cin >> s;
		mp[s]++;
	}

	const string llist[] = {"AC", "WA", "TLE", "RE"};

	for(auto &verdict : llist){
		cout << verdict << " x " << mp[verdict] << "\n";
	}

	return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

struct UnionFind {
  vector<int> data;
  void init(int n) { data.assign(n, -1); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  bool same(int x, int y) { return root(x) == root(y); }
  bool unite(int x, int y) {
    x = root(x), y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  int size(int x) { return -data[root(x)]; }
};

int main() {
  int n, q;
  cin >> n >> q;
  UnionFind uf;
  uf.init(n);
  while (q--) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c == 0) {
      uf.unite(x, y);
    } else {
      cout << uf.same(x, y) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3144
#include <cstdio>
#include <algorithm>

typedef long long int64;

int main() {
	int64 n, a, b, a0, b0;
	
	scanf("%lld %lld %lld", &n, &a, &b);
	if((b - a) & 1) 
		printf("%lld\n", std::min(a - 1, n - b) + 1 + ((b - a - 1) >> 1));
	else
		printf("%lld\n", (b - a) >> 1);
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,n) for (register int i=a;i<=n;i++)
#define per(i,a,n) for (register int i=n;i>=a;i--)
#define FOR(i,a,n,x) for (register int i=a;i<=n;i+=x)
#define ROF(i,a,n,x) for (register int i=n;i>=a;i-=x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define VI vector<int>
#define ll long long
#define ull unsigned long long
#define lowbit(x) ((x)&(-x))
#define mem(i, a) memset(i, a, sizeof(i))
#define sqr(x) ((x)*(x))
#define ls (p << 1)
#define rs (p << 1 | 1)
using namespace std;

template <typename T>

inline void read(T &X) {
  X = 0; char ch = 0; T op = 1;
  for(; ch > '9' || ch < '0'; ch = getchar())
    if(ch == '-') op = -1;
  for(; ch >= '0' && ch <= '9'; ch = getchar())
    X = (X << 3) + (X << 1) + ch - 48;
  X *= op;
}

const int INF = 0x3f3f3f3f;
const int MAXN =  + 5;

ll n;

int main() {
#ifdef WiLe
  freopen ("input.txt", "rt", stdin);
#endif

  read(n);
  ll tmp = n % 1000;
  if (tmp == 0) puts("0");
  else printf("%lld\n", 1000-tmp);

#ifdef WiLe
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}
/*
# author : WiLe
# date : 2020/07/18
*/

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

using namespace std;

typedef long long ll;

int n, k;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> k;
	if (k % 2 == 0)
	{
		ll m[] = {0, 0};
		for (int i = 1; i <= n; i++)
			if (i % k == 0)
				m[0]++;
			else if (i % k == k / 2)
				m[1]++;
		cout << m[0] * m[0] * m[0] + m[1] * m[1] * m[1] << endl;
	}
	else
		cout << (ll)(n / k) * (n / k) * (n / k) << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())

digit = len(str(N))

#print(digit)

is_even = digit % 2 == 1
#print("is_even", is_even)

count = 0

for i in range(digit//2):
    count += 9 * 10**(2*i)
    #print("for", count)

if is_even:
    count += N - 10**(digit-1) + 1
    #print("if", count)

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define ll      long long 
#define double      long double
#define pii     pair<int ,int>
#define pld     pair<ld ,ld>
#define all(v)  v.begin(),v.end()
#define F       first
#define S       second
#define mod     1000000007
#define pb      push_back
#define MP      make_pair
#define mset(x) memset(x, 0, sizeof(x));
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inf     10000000000000007
#define PI 3.14159265
const int N=300005;
// ll a[N],BIT[N];
// void upd(ll x,ll y)
// {
//     for(;x<N;x+=x&-x)
//         BIT[x]+=y;
// }
// ll get(ll x)
// {
//     ll res=0;
//     for(;x;x-=x&-x)
//         res+=BIT[x];
//     return res;
// }
// void f(ll i,ll l,ll r){
//     ll lo,hi,mid,st,en;
//     lo=0;
//     hi=n-1;
//     st=n;
//     while(lo<=hi){
//         mid=(lo+hi)/2;
//         if(v[mid].F>=l) st=mid,hi=mid-1;
//         else lo=mid+1;
//     }
//     en=-1;
//     while(lo<=hi){
//         mid=(lo+hi)/2;
//         if(v[mid].F<=r) en=mid,lo=mid+1;
//         else hi=mid-1;
//     }
//     for(;st<=en;st++)
//         seg[i].pb(v[st].S);
//     mid=(l+r)/2;
//     f(2*i,l,mid);
//     f(2*i+1,mid+1,r);
// }
// ll g(ll i,ll l,ll r,ll x,ll y){
    
// }
// void run(int t){
//     cin>>n>>q;
//     for(i=0;i<n;i++)cin>>a[i];
//     for(i=0;i<n;i++)
//         v.pb(MP(a[i],i));
    
//     sort(all(v));
//     f(1,1,100000);
//     while(q--){
//         cin>>x>>y;
//         cout<<g(1,1,100000,x,y)<<"\n";
//     }


   


// }
 
void run()
{
    ll x,y;
    cin>>x>>y;
    ll ans=x*y/__gcd(x,y);
    cout<<ans;

}
void setup(){
    ios;
    //cout << setprecision(20);
    // #ifndef ONLINE_JUDGE
    // freopen("input", "r", stdin);
    // freopen("output", "w", stdout);
    // #endif
}
 
signed main(){
    setup();
    int tests = 1;
    //cin >> tests;
    for(int i = 1; i <= tests; i++) run();
    return 0;
}


Measured memory_bytes: 256
import numpy as np

N, M, X = list(map(int,input().split()))
Q = []
C = []
A = []
for i in range(N):
  Q.append(list(map(int,input().split())))
  C.append(Q[i][0])
  A.append(Q[i][1:])
C = np.array(C) #価格行列
A = np.array(A) #スキル行列
           
#全パターンを表す行列Bの作成
B = []
beta = []
for n in range(2**N):
  b = bin(n)[2:].zfill(N)
  beta = []
  for i in range(N):
    beta.append(int(b[i]))
  B.append(beta)
B = np.array(B)

S = np.dot(B,A)
L = []
for n in range(2**N):
  if min(S[n]) >= X:
    L.append(n)
    
if len(L) == 0:
  print(-1)
else:
  kane = []
  for k in range(len(L)):
    kane.append(np.dot(B[L[k]],C))
  print(min(kane))
  

Measured memory_bytes: 27708
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int dp[1145140],sum[1145140];
signed main(){
	int n;
	cin>>n;
	if( n == 1 ){ cout<<1<<endl; return 0;}
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 1;
	sum[0] = 1;
	sum[1] = 2;
	sum[2] = 3;
	int ans = 0;
	for(int i=3;i<=n;i++){
		dp[i] = sum[i-3] + dp[i-1]; dp[i] %= inf;
		sum[i] = sum[i-1] + dp[i]; sum[i] %= inf;
	}
	ans %= inf;
	ans += (n-1) * (n-2) + 1;
	ans %= inf;
	ans += dp[n];
	ans %= inf;
	ans += sum[n-1] * (n-1);
	ans %= inf;
	for(int i=1;i<=n-2;i++){
		ans += dp[i] * ( ( (n-1) * (n-2) + i + 1)%inf);
		ans %= inf;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 17024
from collections import deque

n,m = [int(i) for i in input().split() ]
child = list(list([]) for i in range(n))
count = list( 0 for i in range(n))
ans = list( -1 for i in range(n))
for i in range(n-1+m):
    x = [int(i) for i in input().split() ]
    y = x[0] - 1
    z = x[1] - 1
    child[y].append(z)
    count[z] += 1

root =count.index(0)
que=deque()
que.append(root)

new_child = list([])
while len(que)>0 :
    m = que.popleft()
    new_child.clear()
    for i, node in enumerate(child[m]):
        if count[node] == 1:
            que.append(node)
            ans[node] = m
            new_child.append(node)
        else:
            count[node] -= 1
    child[m] = new_child[:]

for i in ans:
    print(i+1)

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

using namespace std;

typedef unsigned long long ull;

int main()
{
    ull X, Y;
    cin >> X >> Y;
    ull ans;
    for(ans=1;;++ans){
        X = 2*X;
        if(Y < X) break;
    }
    cout << ans << endl;
}


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

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n){
        for(int i=0; i<n; i++) par.at(i) = i;
    }

    int root(int x){
        if(par.at(x) == x){
            return x;
        } else {
            par.at(x) = root(par.at(x));
            return par.at(x);
        }
    }

    void unit(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par.at(rx) = ry;
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int N, K, L;
    cin >> N >> K >> L;

    UnionFind road(N);
    UnionFind train(N);

    for(int i=0; i<K; i++){
        int p, q;
        cin >> p >> q;
        p--; q--;
        road.unit(p, q);
    }

    for(int i=0; i<L; i++){
        int r, s;
        cin >> r >> s;
        r--; s--;
        train.unit(r, s);
    }    

    map <pair<int, int>, int> ma;
    for(int i=0; i<N; i++){
        pair<int, int> p = make_pair(road.root(i), train.root(i));
        ma[p]++;
    }    

    for(int i=0; i<N; i++){
        pair<int, int> p = make_pair(road.root(i), train.root(i));
        cout << ma[p];
        if (i != N-1) cout << ' '; else cout << endl;
    }

    return 0;
}


Measured memory_bytes: 13568
N, X = list(map(int, input().split()))

a = [2**(n+2)-3 for n in range(51)]
b = [2**(n+1)-1 for n in range(51)]

def func(n, x):
    if n == 0:
        return 1
    if x == 1:
        return 0
    if 2 <= x < 2+a[n-1]:
        return func(n-1, x-1)
    if x == 2+a[n-1]:
        return 1+b[n-1]
    if 3+a[n-1] <= x < 3+2*a[n-1]:
        return 1+b[n-1]+func(n-1, x-(2+a[n-1]))
    else:
        return 1+2*b[n-1]

print(func(N, X))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

const int maxN = 100005;

class TaskE {
private:
	Debugger debugger;

	vector<pair<int,int>> solve(int from, int to){
		vector<pair<int,int>> ans;
		while(from < to){
			ans.push_back({from, to});
			from++;
			to--;
		}
		return ans;
	}

public:
	void solveOne(int it){
		int n, m ;
		cin >> n >> m;
		int mid = (n+1)/2;
		vector<pair<int,int>> ans = solve(1, mid);
		vector<pair<int,int>> ans2;
		if(n & 1){
			ans2 = solve(mid+1,n);
		}else{
			ans2 = solve(mid+2,n);
		}
		for(auto elem : ans){
			if(m == 0){
				break;
			}
			cout << elem.first << " "<<elem.second << endl;
			m--;
		}
		for(auto elem : ans2){
			if(m == 0){
				break;
			}
			cout << elem.first << " "<<elem.second << endl;
			m--;
		}
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskE solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 4228
import java.util.*;
class Main{
  public static void main(String args[]){
    long h,w;
    Scanner s = new Scanner(System.in);
    h = s.nextInt();
    w = s.nextInt();
    if(h>1 && w>1){
      long total = ((w+1)/2)*((h+1)/2)+(w/2)*(h/2);
      System.out.println("" + total);
    }else{
      System.out.println("1");
    }
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100010];
map<string, int> mp;
int main()
{
    int i, j, k;
    int n, t, m;
    cin >> n;
    string s;
    for(i = 1; i <= n; i++) {
        cin >> s;
        mp[s]++;
    }
    int mx = -1;
    for(pair<string, int> p:mp) {
        mx = max(mx, p.second);
    }
    for(pair<string, int> p:mp) {
        if(p.second == mx) {
            cout << p.first << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 25216
#include<stdio.h>
#include <iostream>
#include <algorithm>

using namespace std; 

int main()
{
	int H , W;
	char s[60][60];
	int dx[] = { 1,-1,0,0 };
	int dy[] = { 0,0,1,-1 };
	cin >> H >> W;
	for (int i = 0; i < H; i++)
	{
		scanf("%s", s[i]);
	}
	bool ans = true;
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (s[i][j] == '#')
			{
				bool found = false;
				for (int k = 0; k < 4; k++)
				{
					int i2 = i + dx[k];
					int j2 = j + dy[k];
					if (/*i2 >= 0 && i2 < H&&
						j2 >= 0 && j2 < W&&*/s[i2][j2] == '#')
						found = true;
				}
				if (!found) ans = false;
			}
		}
	}
	cout << (ans ? "Yes" : "No") << endl;
}

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

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  
  int sum = 0;
  for (int i = 1; i <= n; i ++)
  {
    int sum_digits = 0;
    int tmp = i;
    while (tmp > 0)
    {
      sum_digits += tmp % 10;
      tmp /= 10;
    }
    if (sum_digits >= a && sum_digits <= b) sum += i;
  }
  
  cout << sum;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
//typedef pair<int,int>P;

int N,M,P,r1,r2;
vector<int>B,a1,a2;

int ch(vector<int> o,vector<int> s)
{
	int c=0,r=0;
	for(int i=0;i<o.size();i++)
		if(o[i]!=s[i])c++;
	if(c%2)return 1000000000;
	for(int i=0;i<o.size();i++)
	{
		if(o[i]!=s[i])
		{
			for(int j=i+1;j<o.size();j++)
			{
				if(o[j]!=s[j]&&o[i]!=o[j])
				{
					r+=j-i;
					swap(o[i],o[j]);
					break;
				}
			}
		}
		if(o[i]!=s[i])return 1000000000;
	}
	return r;
}

int main()
{
	scanf("%d%d",&N,&M);
	for(int i=0;i<N;i++)
	{
		int t;
		scanf("%d",&t);
		B.push_back(t);
	}
	for(int i=0;i<M;i++)
	{
		scanf("%d",&P);
		for(int j=0;j<P;j++)
		{
			a1.push_back(i%2);
			a2.push_back((i+1)%2);
		}
	}
	printf("%d\n",min(ch(B,a1),ch(B,a2)));
	
}

Measured memory_bytes: 1216
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			long A = scn.nextLong();
			BigDecimal B = scn.nextBigDecimal();

			System.out.println(BigDecimal.valueOf(A).multiply(B).setScale(0, BigDecimal.ROUND_DOWN));

		}
	}
}

Measured memory_bytes: 37368
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N, M;
  while(cin >> N >> M, N){
    int C[M];
    long long int INF = 10000000000LL;
    for(int i = 0; i < M; ++i)
      cin >> C[i];
    sort(C,C+M);
    int x[N];
    for(int i = 0; i < N; ++i)
      cin >> x[i];
    vector< vector<long long int> > dp(N, vector<long long int>(256,INF));
    for(int i = 0; i < M; ++i){
      int t = max(min(255,128+C[i]),0);
      dp[0][t] = (long long int)(x[0]-t)*(x[0]-t);
    }
    for(int i = 1; i < N; ++i){
      for(int j = 0; j < 256; ++j){
	if(dp[i-1][j] == INF) continue;
	for(int k = 0; k < M; ++k){
	  int t = max(min(255,j+C[k]),0);
	  dp[i][t] = min(dp[i][t], dp[i-1][j] + (long long int)(x[i]-t)*(x[i]-t));
	  if(j + C[k] > 255) break;
	}
      }
    }

    long long int ans = INF;
    for(int i = 0; i < 256; ++i){
      ans = min(ans, dp[N-1][i]);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 43808
import itertools
 
N, M = map(int, input().split())
lights = []
for m in range(M):
    tmp = list(map(int, input().split()))
    lights.append(tmp[1:])
    
    
 
 
P = list(map(int, input().split()))
 
ans = 0
for product in list(itertools.product([0, 1], repeat=N)):
    for light in range(len(lights)):
        cnt = 0
        for l in lights[light]:
            cnt += product[l-1]
        if cnt % 2 != P[light]:
            break
        if light == len(lights) - 1:
            ans += 1
print(ans)

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int arr[N] , sz[N];

int n , a , b , z , k;

void init(){
	for(int i = 0 ; i < N ; ++i){
		arr[i] = i;
		sz[i] = 1;
	}
}

int root(int i){
	while(i != arr[i])
		i = arr[i];

	return i;
}

int unin(int a , int b){
	int ra = root(a);
	int rb = root(b);
	if(ra != rb){
		if(sz[ra] > sz[rb]){
			arr[rb] = arr[ra];
			sz[ra] += sz[rb];
		}
		else{
			arr[ra] = arr[rb];
			sz[rb] += sz[ra];
		}
	}
}

int32_t main(){
    boost;
    
    //code
    cin >> n >> k;
    init();

    for(int i = 0 ; i < k ; ++i){
    	cin >> a >> b >> z;
    	unin(a,b);
    }

    set<int> st;

    for(int i = 1 ; i <= n ; ++i){
    	st.insert(root(i));
    }

    cout << st.size();
    return 0;
}

Measured memory_bytes: 6528
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	sc    = bufio.NewScanner(os.Stdin)
	edges map[int]map[int]int
	dists []int
)

func newLineInt() int {
	sc.Scan()
	data, _ := strconv.Atoi(sc.Text())
	return data
}

func pop(stack []int) (int, []int) {
	e := stack[len(stack)-1]
	updatedStack := stack[:len(stack)-1]
	return e, updatedStack
}

func dfs(v int) {
	var stack []int
	var current int
	var currentDist int
	stack = append(stack, v)
	current = v
	for {
		if len(stack) == 0 {
			break
		}

		current, stack = pop(stack)
		currentDist = dists[current]

		for neibor, w := range edges[current] {
			if dists[neibor] == -1 {
				stack = append(stack, neibor)
				dists[neibor] = (w + currentDist) % 2
			}
		}

	}
}

func main() {

	edges = make(map[int]map[int]int)

	sc.Split(bufio.ScanWords)
	n := newLineInt()
	for i := 0; i < n; i++ {
		edges[i] = make(map[int]int)
	}
	for i := 0; i < n-1; i++ {
		u, v, w := newLineInt(), newLineInt(), newLineInt()
		edges[u-1][v-1] = w % 2
		edges[v-1][u-1] = w % 2
	}
	dists = make([]int, n)
	for i := 0; i < n; i++ {
		dists[i] = -1
	}
	dists[0] = 0
	dfs(0)
	for i := 0; i < n; i++ {
		fmt.Println(dists[i])
	}
}

Measured memory_bytes: 34560
N=int(input())
A=list(map(int, input().split()))
A.insert(0,0)
A.append(0)

all_cost=0
for i in range(len(A)-1):
    all_cost+=abs(A[i+1]-A[i])

for i in range(1,len(A)-1):
    minus=abs(A[i-1]-A[i])+abs(A[i]-A[i+1])
    plus=abs(A[i-1]-A[i+1])
    ans=all_cost-minus+plus
    print(ans)

Measured memory_bytes: 85516
#include <iostream>
#include <stdlib.h>
#define llint long long

using namespace std;

llint n, s;
llint x[100005];

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

int main(void)
{
	cin >> n >> s;
	for(int i = 0; i < n; i++) cin >> x[i];
	
	for(int i = 0; i < n; i++){
		x[i] = abs(x[i]-s);
	}
	
	llint ans = 0;
	for(int i = 0; i < n; i++) ans = gcd(ans, x[i]);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    map<int,int> ma;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        ma[a]++;
    }
    for(int i = 0; i < m; i++){
        int a;
        cin >> a;
        ma[a]++;
    }
    vector<int> ans1,ans2;//and,or
    for(auto itr = ma.begin(); itr != ma.end(); itr++){
        int id = itr->first;
        int cnt = itr->second;
        if(cnt == 2)ans1.push_back(id);
        ans2.push_back(id);
    }
    cout << ans1.size() << " " << ans2.size() << endl;
    for(int i = 0; i < ans1.size(); i++){
        cout << ans1[i] << endl;
    }
    for(int i = 0; i < ans2.size(); i++){
        cout << ans2[i] << endl;
    }
}



Measured memory_bytes: 14088
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>kaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    //if(!kaijo[0])init_fact(2000010);
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,k,a[200010],f[200010],cycle,pos;
bool used[200010];
void dfs(int x){
    used[x]=true;
    int to=a[x];
    if(used[to]){
        cycle=f[x]+1-f[to];
        pos=to;
        return;
    }
    else{
        f[to]=f[x]+1;
        dfs(to);
    }
}
signed main(){
    cin>>n>>k;
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
    f[0]=0;
    dfs(0);
    if(k<=f[pos]){
        int x=0;
        rep(i,k){
            x=a[x];
        }
        cout<<x+1<<endl;
    }
    else{
        k-=f[pos];
        k%=cycle;
        int x=pos;
        rep(i,k)x=a[x];
        cout<<x+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 6964
// AOJ 0558
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<set>
#include<vector>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

typedef pair<int,int> P;

const int HMAX = 1008, WMAX = 1008;
char city[HMAX][WMAX];
int H, W, N;

P search(char c) {
  REP(y,H) REP(x,W) {
    if (city[x][y] == c) {
      return make_pair(x,y);
    }
  }
}


bool legal(int x, int y) {
  return 0 <= x and x < W and 0 <= y and y < H;
}

typedef pair<int,P> Dat;

int distance(char start, char goal) {
  P startp = search(start), goalp = search(goal);
  priority_queue<Dat,vector<Dat>,greater<Dat> > q;
  set<P> s;
  q.push(Dat(0,startp));
  s.insert(startp);
  while (!q.empty()) {
    Dat d = q.top(); q.pop();
    P p = d.second;
    if (p == goalp) return d.first;
    int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
    REP(i, 4) {
      int nx = p.first + dx[i], ny = p.second + dy[i];
      P np = P(nx,ny);
      if (legal(nx,ny) and city[nx][ny] != 'X' 
          and s.find(np) == s.end()) {
        q.push(Dat(d.first + 1, np));
        s.insert(np);
      }
    }
  }
  throw 1;
}

int solve() {
  char current = 'S';
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += distance(current, '0' + i);
    current = '0' + i;
  }
  return ans;
}

int main() {
  cin >> H >> W >> N;
  REP(y, H) {
    string row;
    cin >> row;
    REP(x, W) {
      city[x][y] = row[x];
    }
  }

  cout << solve() << endl;
}

Measured memory_bytes: 23116
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve() {
    LL N;
    cin >> N;

    LL ans = N - 1;
    FOR(A, 2, N + 1) {
        LL B = 1;
        while (A * B < N) {
            ans++;
            B++;
        }
    }
    cout << ans << endl;
}

int main(void) {
#ifndef ONLINE_JUDGE
    const auto in_stream = freopen("../in.txt", "r", stdin);
    if (in_stream == nullptr) {
        cerr << "ERROR!" << endl;
        return 1;
    }
#endif

    solve();

#ifndef ONLINE_JUDGE
    fclose(in_stream);
#endif
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string output = "consonant";
  char c;
  cin >> c;
  char vowel[5] = {'a','i','u','e','o'};
  for(v :vowel){
    if(c==v){
      output = "vowel";
      break;
    }
  }
  cout << output << endl;
}

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

int main(){
    int n;
    int b,f,r,v;
    int num = 0;
    int kousya[4][3][10] ={{{}}};
    scanf("%d",&n);
    num = n;
    for(int i= 0; i<num;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        kousya[b-1][f-1][r-1] += v;
    }
    for(int j = 0;j<4;j++){
        for(int k =0;k<3;k++){
            for(int l =0;l<10;l++){
                printf(" %d",kousya[j][k][l]);
               
            }
            putchar('\n');
        }
    if(j !=3) {
            
            printf("####################\n");
        }
    } 
     
return 0;
}




Measured memory_bytes: 3204
from collections import defaultdict, deque
import sys


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


a, b = LI()
if a <= 2 * b:
    print(0)
else:
    print(a - 2 * b)


Measured memory_bytes: 3316
s = input()[::-1]

cnts = [1] + [0] * (2019 - 1)
tmp = 0
d = 1

for i in s:
    tmp += int(i) * d
    cnts[tmp % 2019] += 1
    d = d * 10 % 2019 # 桁数が大きくなりすぎる → 10と2019が素だから可能

ans = 0
for cnt in cnts:
    ans += (cnt - 1) * cnt // 2

print(ans)

Measured memory_bytes: 9284
words = input()
if words.startswith('A') and words.find('C') >= 2 and not words.endswith("C") and words.count('C') == 1:
    w1 = words.strip("A")
    w2 = w1.replace("C","c")
    if w2.islower():
        print('AC')
    else:
        print("WA")
else:
    print("WA")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define __STDC_LIMIT_MACROS
#include <stdint.h>
using namespace std;
#define int             long long
#define endl '\n'	 
bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;
	
	}
	return true;
}
 
void c_p_c()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 
}
bool how(pair<int,int> a, pair<int, int>b)
{
	return a.second<b.second;
}
 
int32_t main()
 
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	c_p_c();
	int n,k;
	cin>>n>>k;
	int p[n];
	for(int i = 0; i<n; i++)
		cin>>p[i];
	sort(p,p+n);
	int ans = 0;
	for(int i = 0; i<k; i++)
		ans+=p[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 3664
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string s;
  cin >> s;

  int ans;
  if (s.size() == 1) {
    ans = stoi(s);
  } else {
    bool flag = false;
    for (int i = 1; i < s.size(); i++) {
      if (s[i] < '9') flag = true;
    }

    ans = (int)(s[0] - '0') + 9 * (s.size() - 1);
    if (flag) ans--;
  }

  // 解答
  cout << ans << endl;

  return 0;
}


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

int min(int a, int b){
	return a<b? a: b;
}


int main(){
	int n,a,b;
	cin >> n >> a >> b;
	int p[n];
	for (int i=0; i<n; i++)
		cin >> p[i];
	sort(p,p+n);
	int n1=0; int n2=0; int n3=0;
	for (int i=0; i<n; i++){
		if(p[i]<=a)
			n1++;
		else if (p[i]<=b)
			n2++;
		else n3++;
	}
	cout << min(min(n1,n2),n3);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;

const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    ll n, k;
  cin >> n >> k;

  if(k == 0) {
    cout << n*n << endl;
    return 0;
  }

  ll ans = 0;
  for(ll i = 1; i<=n ;i++) {
    if(i-1 >= k) {
      ans += n/i*(i-k);
      ans += max(0ll, (n%i) - k + 1);
    }
  }
  cout << ans << endl;
}

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


int main()
{
	string s, t; cin >> s >> t;
	int ans = t.size();
	for (int i = 0; i <= s.size() - t.size(); ++i)
	{
		int c = 0;
		for (int j = 0; j < t.size(); ++j)
		{
			c += s[i+j] != t[j];
		}
		ans = min(ans, c);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3588
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main() {
  int n,m;
  cin>>n>>m;
  
  vector<vector<int>> S(m);
  int k,s;
  rep(i,m){
    cin>>k;
    rep(j,k){
      cin>>s;
      S[i].push_back(s-1);
    }
  }
  
  vector<int> P(m);
  rep(i,m) cin>>P[i];
  
  int cnt,ans=0;
  for(int bit=0;bit<(1<<n);bit++){
    bool b=true;
    rep(i,m){
      cnt=0;
      rep(j,S[i].size()){
        if(bit&(1<<S[i][j])) cnt++;
      }
      if(cnt%2!=P[i]) b=false;
    }
    if(b) ans++;
  }
  
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3652
d={'7': ['p', 'q', 'r', 's'], '2': ['a', 'b', 'c'], '1': ['.', ',', '!', '?'," "], '3': ['d', 'e', 'f'], '9': ['w', 'x', 'y', 'z'], '5': ['j', 'k', 'l'], '8': ['t', 'u', 'v'], '4': ['g', 'h', 'i'], '6': ['m', 'n', 'o']}
time=int(input())
for i in range (time):
    answer=[]
    word=input().split("0")
    while "" in word: word.remove("")
    for i in word:
        answer.append(d[i[0]][len(i)%len(d[i[0]])-1])
    print("".join(answer))
    

Measured memory_bytes: 7600
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=190;
int n,m;
char a[N][N];
int pre[N][N];
short dp[N][N][N][18];
int main(){
	n=read(),m=read();
	For(i,1,n)
		cin>>(a[i]+1);
	For(i,1,n)
		For(j,1,m)
			pre[i][j]=pre[i-1][j]+pre[i][j-1]-pre[i-1][j-1]+(a[i][j]=='.');
	For(len,1,n)
		For(i,1,n-len+1){
			int j=i+len-1;
			For(k,0,16){
				for (int L=1,R=1;L<=m;L++){
					if (k==0){
						while (R<=m){
							int c=pre[j][R]-pre[i-1][R]-pre[j][L-1]+pre[i-1][L-1];
							if (!(c==0||c==len*(R-L+1)))
								break;
							R++;
						}
					}
					else {
						while (R<=m){
							if (dp[i][j][L][k-1]>=L)
								if (dp[i][j][L][k-1]>=m||dp[i][j][dp[i][j][L][k-1]+1][k-1]>=R){
									R++;
									continue;
								}
							if (i<j&&dp[i][i][L][k-1]>=R){
								int mid=i;
								Fod(zzy,7,0)
									if (mid+(1<<zzy)<=n&&dp[i][mid+(1<<zzy)][L][k-1]>=R)
										mid+=1<<zzy;
								if (mid>=j||dp[mid+1][j][L][k-1]>=R){
									R++;
									continue;
								}
							}
							break;
						}
					}
					dp[i][j][L][k]=R-1;
				}
			}
		}
	int ans=16;
	while (ans>0&&dp[1][n][1][ans-1]==m)
		ans--;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 236800
import java.util.Scanner;

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 k = sc.nextInt();
	        
	        int result = 0;
	        if(k<a) {
	        	result = k;
	        }else if(k>=a && a+b>=k) {
	        	result = a;
	        }else  {
	        	int d = k-a-b;
	        	result = a-d;
	        }
	        System.out.println(result); 
	        
            

          
	        
            //System.out.println(res); 
	        
	}
}

Measured memory_bytes: 35816
# import sys
# import bisect

# sys.setrecursionlimit(4100000)


# def inputs(num_of_input):
#     ins = [input() for i in range(num_of_input)]
#     return ins


def bis_insert(L, target, top=None, bottom=None):
    if top is None:
        top = len(L)
    if bottom is None:
        bottom = 0

    while bottom < top:
        half = (top + bottom) // 2
        if target > L[half]:
            bottom = half + 1
        else:
            top = half
    return bottom


def solve(inputs):
    L = string_to_int(inputs)
    L.sort()
    total_count = 0
    for i in range(len(L) - 2):
        for j in range(i + 1, len(L)-1):
            a = L[i]
            b = L[j]
            target = a + b
            r = bis_insert(L, target)
            # r = bisect.bisect_left(L, target)
            total_count += r - j - 1
    return total_count


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    input()
    ret = solve(input())
    print(ret)


Measured memory_bytes: 42460
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;

int main() {
  ll N;
  cin >> N;
  vector<ll> D(N);
  for (ll i=0; i<N; i++) cin >> D[i];
  if (D[0]!=0) cout << 0 << endl;
  else {
    map<ll, ll> dict; // 各数字の登場回数
    for (ll i=0; i<N; i++) {
      if (dict.count(D[i])) dict[D[i]]++;
      else dict[D[i]] = 1;
    }
    ll res = 1;
    for (ll i=1; i<N; i++) {
      res *= dict[D[i]-1];
      res %= Mod;
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 7296
n = int(input())
l = list(map(int,input().split()))
count = 0
for i in range(n):
    for ii in range(n):
        for iii in range(n):
            if l[i] + l[ii] > l[iii] and l[ii] + l[iii] > l[i] and l[iii] + l[i] > l[ii] and i<ii and ii < iii and l[i] != l[ii] and l[i] != l[iii] and l[ii] != l[iii]:
                count += 1
print(count)

Measured memory_bytes: 9160
N, L, T = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

y = [0] * N
cnt = 0
for i, (x, w) in enumerate(X):
    if w == 1:
        y[i] = (x + T) % L
        cnt += (x + T) // L
    else:
        y[i] = (x - T) % L
        cnt += (x - T) // L        

y.sort()
for i in range(N):
    print(y[(i + cnt) % N])

Measured memory_bytes: 65880
parseline(str=readline()) = parse.(Int, split(str))
function Knight()
    Mod = 10^9 + 7
    X, Y = parseline()
    (X+Y)%3≠0 && return println(0)
    N, M = minmax((2X-Y) ÷ 3, (2Y-X) ÷ 3)
    N<0 && return println(0)
    M<0 && return println(0)
    ans = 1
    for n in 1:N
        ans *= mod((M+n)*invmod(n, Mod), Mod)
        ans = mod(ans, Mod)
    end
    return println(ans)
end
Knight()

Measured memory_bytes: 177640
#include <stdio.h>

int main(){
  int l,r,i,j,mod=3000;
  scanf("%d%d",&l,&r);
  if(r-l>2020)printf("%d\n",0);
  else{
    int d = (l/2019)*2019;
    l -= d;
    r -= d;
    //printf("%d %d %d\n",l,r,d);
    for(i=l;i<=r;i++)for(j=i+1;j<=r;j++){
      if((i*j)%2019<mod)mod=(i*j)%2019;
    }
    printf("%d\n",mod);
  }
  return 0;
}


Measured memory_bytes: 128