akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    ll k, a, b;
    cin >> k >> a >> b;

    if(b-a<=2) {
        cout << k+1 << endl;
        return 0;
    }

    ll remain = k - (a-1);
    ll res = a;

    if(remain%2) {
        --remain;
        ++res;
    }

    
    res += (b-a) * (remain/2);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Scanner;
public class Main {

	static final HashMap<Character, String> InMap = new HashMap<Character, String>() {
		{
			put(' ', "101");put('\'', "000000");put(',', "000011");
			put('-', "10010001"); put('.', "010001"); put('?', "000001");
			put('A', "100101"); put('B', "10011010");put('C', "0101");
			put('D', "0001");put('E', "110"); put('F', "01001");
			put('G', "10011011");put('H', "010000"); put('I', "0111");
			put('J', "10011000"); put('K', "0110");put('L', "00100");
			put('M', "10011001"); put('N', "10011110");put('O', "00101");
			put('P', "111"); put('Q', "10011111");put('R', "1000");
			put('S', "00110"); put('T', "00111"); put('U', "10011100");
			put('V', "10011101");put('W', "000010");put('X', "10010010");
			put('Y', "10010011"); put('Z', "10010000");
		}
	};

	static final HashMap<String, Character> OutMap = new HashMap<String, Character>() {
		{
			put("00000", 'A'); put("00001", 'B'); put("00010", 'C');
			put("00011", 'D'); put("00100", 'E'); put("00101", 'F');
			put("00110", 'G'); put("00111", 'H'); put("01000", 'I');
			put("01001", 'J'); put("01010", 'K'); put("01011", 'L');
			put("01100", 'M'); put("01101", 'N'); put("01110", 'O');
			put("01111", 'P'); put("10000", 'Q'); put("10001", 'R');
			put("10010", 'S'); put("10011", 'T'); put("10100", 'U');
			put("10101", 'V'); put("10110", 'W'); put("10111", 'X');
			put("11000", 'Y'); put("11001", 'Z'); put("11010", ' ');
			put("11011", '.'); put("11100", ','); put("11101", '-');
			put("11110", '\'');put("11111", '?');
		}
	};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String temp = sc.nextLine(),
					str = "",
					ans = "";
			char character[] = temp.toCharArray();
			for(int i = 0; i < character.length; i++){
				str += InMap.get(character[i]);
			}
			str += "00000";
			//System.out.println(str);
			for(int i = 0; i < str.length() - 5; i += 5 ){
				ans += OutMap.get(str.substring(i,i + 5));
			}
			System.out.println(ans);
		}

	}
}

Measured memory_bytes: 52920
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1000000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int p[500000];
int r[500000];

void init(int n){
  REP(i, n){
    p[i] = i;
    r[i] = 0;
  }
}

int find(int n) {return (p[n] == n ? n : p[n] = find(p[n]));}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y) return;
  if(r[x] < r[y]) p[x] = y;
  else{
    p[y] = x;
    if(r[x] == r[y]) r[x]++;
  }
}

bool same(int x, int y){
  return (find(x) == find(y));
}

int main(){
  int n, k, l;
  cin >> n >> k >> l;
  init(2*n);
  REP(i, k){
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    unite(x, y);
  }
  REP(i, l){
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    unite(x+n, y+n);
  }
  P d[n];
  map<P, int> m;
  REP(i, n){
    d[i] = {find(i), find(i+n)};
    m[d[i]]++;
  }
  REP(i, n){
    cout << m[d[i]];
    if(i == n-1) cout << endl;
    else cout << " ";
  }
  return 0;
}

Measured memory_bytes: 18048
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	s.emplace_back("AA");

	vector<char> ans;
	for (int i = 0; i < n; i++) {
		if (s[i] == "AB") {
			if (a == 0 && a == b) {
				cout << "No" << endl;
				return 0;
			}

			if (a == 1 && a == b) {
				if (s[i + 1] == "AC") {
					ans.emplace_back('A');
					b--;
					a++;
				} else {
					ans.emplace_back('B');
					b++;
					a--;
				}
			}else if (a > b) {
				ans.emplace_back('B');
				b++;
				a--;
			} else {
				ans.emplace_back('A');
				b--;
				a++;
			}
		} else if (s[i] == "AC") {
			if (a == 0 && a == c) {
				cout << "No" << endl;
				return 0;
			}

			if (a == 1 && a == c) {
				if (s[i + 1] == "AB") {
					ans.emplace_back('A');
					c--;
					a++;
				} else {
					ans.emplace_back('C');
					c++;
					a--;
				}
			} else if (a > c) {
				ans.emplace_back('C');
				c++;
				a--;
			} else {
				ans.emplace_back('A');
				c--;
				a++;
			}
		} else {
			if (b == 0 && b == c) {
				cout << "No" << endl;
				return 0;
			}

			if (b == 1 && b == c) {
				if (s[i + 1] == "AB") {
					ans.emplace_back('B');
					c--;
					b++;
				} else {
					ans.emplace_back('C');
					c++;
					b--;
				}
			} else if (b > c) {
				ans.emplace_back('C');
				c++;
				b--;
			} else {
				ans.emplace_back('B');
				c--;
				b++;
			}
		}
	}

	cout << "Yes" << endl;
	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 9596
from collections import Counter

n = int(input())
a = Counter(map(int, input().split()))

cnt = 0
for i in a:
    cnt ^= i

if n % 3 == 0 and all(a[i] % (n // 3) == 0 for i in a):
    print('Yes' if (cnt == 0 or a[0] == n // 3) else 'No')
else:
    print('Yes' if a[0] == n else 'No')


Measured memory_bytes: 85332
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

bool is_fizzbuzz(int n) {
	return n % 3 == 0 || n % 5 == 0;
}

int main() {
	int n;
	cin >> n;
	ll sum = 0;
	REP(i, n + 1) {
		if(!is_fizzbuzz(i)) {
			sum += i;
		}
	}
	cout << sum << endl;
	return 0;
}


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

int main() {
  int h,w,m;
  cin>>h>>w>>m;

  int height[h];
  int width[w];
  for(int i=0; i<h; i++) height[i]=0;
  for(int i=0; i<w; i++) width[i]=0;

  vector<pair<int, int>> bomb;
  for(int i=0; i<m; i++) {
    int a,b;
    cin>>a>>b;
    height[a-1]++;
    width[b-1]++;
    bomb.push_back(make_pair(a-1, b-1));
  }

  int hmax = *max_element(height, height+h);
  int wmax = *max_element(width, width+w);
  int ans = hmax+wmax;

  int64_t hcount = 0;
  int64_t wcount = 0;
  for(int i=0; i<h; i++) {
    if(height[i]==hmax) hcount++;
  }
  for(int i=0; i<w; i++) {
    if(width[i]==wmax) wcount++;
  }

  int64_t count = 0;
  for(int i=0; i<m; i++) {
    int a = bomb[i].first;
    int b = bomb[i].second;
    if(height[a]==hmax && width[b]==wmax) count++;
  }

  if(count==hcount*wcount) ans--;


  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 9800
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 1_000_000_007

@njit((i8, i8), cache=True)
def mpow(a, n):
    p = 1
    while n:
        if n & 1:
            p = p * a % MOD
        a = a * a % MOD
        n >>= 1
    return p


@njit((i8, ), cache=True)
def fact_table(N):
    """Compute 0!, 1!, ..., (N-1)! and their inverses modulo MOD. 

    Parameters
    ----------
    N : int
        length of the output array. 

    Returns
    -------
    fact : np.ndarray
        0!, 1!, ..., (N-1)!

    fact_inv : np.ndarray
        inverse of 0!, 1!, ..., (N-1)! modulo MOD. 
    """
    fact = np.empty(N, np.int64)
    fact[0] = 1
    for n in range(1, N):
        fact[n] = n * fact[n - 1] % MOD
    fact_inv = np.empty(N, np.int64)
    fact_inv[N - 1] = mpow(fact[N - 1], MOD - 2)
    for n in range(N - 1, 0, -1):
        fact_inv[n - 1] = fact_inv[n] * n % MOD
    return fact, fact_inv

@njit((i8, i8[:]), cache=True)
def main(H, P):
    fact, fact_inv = fact_table(1 << 20)
    inv = np.zeros(1 << 20, np.int64)
    inv[1:] = fact_inv[1:] * fact[:-1] % MOD
    # 根から v までの積。ただし v は含まない。半開区間で。
    f = np.ones_like(P)
    f_inv = np.ones_like(P)
    g = np.ones_like(P)
    g[0] = 0
    for v in range(2, 1 << H):
        parent = v >> 1
        f[v] = f[parent] * parent % MOD
        f_inv[v] = f_inv[parent] * inv[parent] % MOD
        g[v] = f_inv[v] * f_inv[v] % MOD * inv[v] % MOD
    # 要るところだけ使って巻き戻す
    dp1 = np.zeros(1 << H, np.int64)  # path product の和
    dp2 = np.zeros(1 << H, np.int64)  # path product の2乗和
    ws = np.zeros(1 << H, np.int64)
    ptr = 0
    ans = 0
    for x1 in range(1, 1 << H):
        l, r = x1, x1 + 1
        while 2 * l < 1 << H:
            l, r = 2 * l, 2 * r
        for v in range(l, r):
            pv = f[v] * v % MOD * f_inv[x1] % MOD  # パス[x1,v]の積
            w = P[v]
            pw = pv
            while w:
                pw = pw * w % MOD
                if dp1[w] == 0:
                    ws[ptr] = w
                    ptr += 1
                dp1[w] += pw
                dp2[w] += pw * pw % MOD
                w >>= 1
        for x2 in ws[:ptr]:
            dp1[x2] %= MOD
            dp2[x2] %= MOD
            x = (dp1[x2]**2 - dp2[x2]) % MOD
            x = x * inv[2] % MOD
            coef = (f[x1] * f[x2] % MOD)**2 % MOD
            x = x * coef % MOD
            p1, p2 = x1 >> 1, x2 >> 1
            coef = g[x1] * g[x2] % MOD
            coef -= g[p1] * g[x2] % MOD
            coef -= g[x1] * g[p2] % MOD
            coef += g[p1] * g[p2] % MOD
            coef %= MOD
            ans += coef * x % MOD
        for x2 in ws[:ptr]:
            dp1[x2] = 0
            dp2[x2] = 0
        ptr = 0
    return ans % MOD

H = int(readline())
P = np.zeros(1 << H, np.int64)
P[1 << H - 1:] = (np.array(read().split(), np.int64) - 1) | 1 << H - 1

print(main(H, P))

Measured memory_bytes: 143808
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	int N;
	cin >> N;
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		double a;
		cin >> a;
		sum += 1.0 / a;
	}
	cout << fixed << setprecision(6);
	cout << 1.0 / sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define inf 1000000000000000001
#define mod 1000000007
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
#define Set(N,p) N=((N)|((1LL)<<(p)))
#define Reset(N,p) N=((N)&(~((1LL)<<(p))))
#define Check(N,p) (!(((N)&((1LL)<<(p)))==(0)))
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define OUT(x) for(auto a:x) cout << a << " "; cout << endl;
#define OK cout << "@===================ok===================@" <<endl;
#define WTF cout <<"< "<<lo<<" | "<< hi <<" >" << endl;

using namespace std;

int main()
{
	fast_cin;
    int n;
    cin >> n;
    vll v(n+2),suf(n+2);
	for(int i=1;i<=n;i++) {
		cin >> v[i];
		v[i]%=mod;
	}
	ll s=0;
	for(int i=n;i>=1;i--){
		s+=v[i];
		s%=mod;
		suf[i]=s;
	}

	ll res=0;
	for(int i=1;i<=n-1;i++){
		res+=(v[i]*suf[i+1])%mod;
		res%=mod;
	}
	cout << res <<"\n";

}


Measured memory_bytes: 6304
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // cout << fixed << setprecision(20);
    int n,m;cin >> n >> m;
    int lb,ub;
    if(n == 1)lb = 0,ub = 9;
    if(n == 2)lb = 10,ub = 99;
    if(n == 3)lb = 100,ub = 999;

    vector<pair<int,char> > query(m);
    REP(i,m)cin >> query[i].first >> query[i].second;
    for(int i = lb;i <= ub;i++){
        string d = to_string(i);
        bool ok = true;
        REP(j,m){
            if(d[query[j].first - 1] != query[j].second){
                ok = false;
                break;
            }
        }
        if(ok){
            cout << d << '\n';
            return 0;
        }
    }
    cout << -1 << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
vector<int> arr(MAXX);
void trozen()
{
    int n;
    cin>>n;
    if(n>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


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

#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

struct St{
	int buff = 0;
	set<int> S;
	void add(int x){
		S.insert(x-buff);
	}
	int max(){
		return *S.rbegin()+buff;
	}
	int query(){
		while((*S.begin())+buff<0)S.erase(S.begin());
		S.insert(-buff);
		return S.size()-1;
	}
}SS;
ll ans = 0;
int n,a[200030];
int main() {
	read(n);
	SS.add(0);
	ll ans = 0;
	for(int i=0;i<n;i++)read(a[i]);
	if(a[0]!=0){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=n-1;i>=0;i--){
		if(SS.max()>a[i]){
			cout<<-1<<endl;
			return 0;
		}
		SS.add(a[i]);
		ans +=SS.query();
		SS.buff+=-1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <random>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int d;
vec c;
int s[365][26] = {};
int last[365][26] = {};
vec t;

lint update(int day, int type) {
    vec t2 = t;
    t2[day] = type;

    lint res = 0;

    rep(i, d) {
        res += s[i][t2[i]];
        for (int j = i; j < d; j++) last[j][t2[i]] = i+1;
        rep(j, 26) {
            res -= c[j] * (i+1 - last[i][j]);
        }
    }

    return res;
}

int main() {
    cin >> d;
    c.resize(26);
    rep(i, 26) cin >> c[i];
    rep(i, d) rep(j, 26) cin >> s[i][j];

    t.resize(d);
    lint now = 0;

    rep(i, d) {
        lint mx = 0;
        int selected = -1;
        rep(j, 26) {
            lint nw2 = now;

            nw2 += s[i][j];

            int tmp = last[i][j];
            last[i][j] = i+1;
            rep(k, 26) {
                nw2 -= c[k] * (i+1 - last[i][k]);
            }
            last[i][j] = tmp;

            if (nw2 > mx) {
                mx = nw2;
                selected = j;
                t[i] = j;
            }
        }
        for (int j = i; j < d; j++) last[j][selected] = i+1;
        now += mx;
    }

    int cnt = 1000;
    random_device rnd;
    mt19937 mt(rnd());
    while (cnt--) {
        int day = mt() % d;
        int type = mt() % 26;
        lint now2 = update(day, type);
        if (now < now2) {
            t[day] = type;
            now = now2;
        }
    }

    rep(i, d) cout << t[i]+1 << endl;
    return 0;
}

Measured memory_bytes: 3712
a,b = map(int,input().split())
s =  input()

if len(s) != a+b+1:
  print("No")
else:
  if s[a] == "-" and "-" not in s[0:a] and  "-" not in s[a+1:a+b+1]:
    print("Yes")
  else:
    print("No")



Measured memory_bytes: 2940
import java.util.*;

public class Main {
    final static int MOD = 1000000007;
    
    public static void main(String[] args) {
        MyScanner in = new MyScanner();
        long n = in.nextLong();
        long a = in.nextLong();
        long b = in.nextLong();
        

        long ans = n / (a + b) * a;
        long c =  n % (a + b);
        if (a < c) {
            System.out.println(ans + a);
        } else {
            System.out.println(ans + c);
        }
        
    }
    
    static class MyScanner {
        static Scanner sc = new Scanner(System.in);
        
        String next() {
            return sc.next();
        }
        
        String nextLine() {
            return sc.nextLine();
        }
        
        int nextInt() {
            return Integer.parseInt(sc.next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        int[] nextIntArray(int n) {
            int[] array = new int[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextInt();
            }
            return array;
        }
        
        double[] nextDoubleArray(int n) {
            double[] array = new double[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextDouble();
            }
            return array;
        }
        
        long[] nextLongArray(int n) {
            long[] array = new long[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextLong();
            }
            return array;
        }
        
        String[] nextLineArray(int n) {
            String[] array = new String[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextLine();
            }
            return array;
        }
        
        int[][] nextIntMatrix(int n, int m) {
            int[][] matrix = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextInt();
                }
            }
            return matrix;
        }
        
        double[][] nextDoubleMatrix(int n, int m) {
            double[][] matrix = new double[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextDouble();
                }
            }
            return matrix;
        }
        
        long[][] nextLongMatrix(int n, int m) {
            long[][] matrix = new long[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextLong();
                }
            }
            return matrix;
        }
    }
}

Measured memory_bytes: 23252
using namespace std;

#include <cstdio>

int a[10];

bool dfs(int i, int l, int r){
	if (i == 10){
		return true;
	}
	if (l < a[i]){
		return dfs(i + 1, a[i], r);
	}
	if (r < a[i]){
		return dfs(i + 1, l, a[i]);
	}
	return false;
}

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			scanf("%d", &a[j]);
		}
		printf("%s\n", dfs(0, 0, 0) ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 1008
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from math import gcd
    input = sys.stdin.buffer.readline

    N = int(input())
    cnt = {}
    zz = 0
    for _ in range(N):
        a, b = map(int, input().split())
        if a == b == 0:
            zz += 1
            continue
        if a < 0:
            a = -a
            b = -b
        elif a == 0:
            if b < 0:
                b = -b
        g = gcd(abs(a), abs(b))
        x = (a // g, b // g)
        if x in cnt:
            cnt[x] += 1
        else:
            cnt[x] = 1

    ans = 1
    num = 0
    for x in cnt:
        if cnt[x] == 0:
            continue
        a, b = x
        if b > 0:
            y = (b, -a)
        else:
            y = (-b, a)
        if y in cnt:
            nx = cnt[x]
            ny = cnt[y]
            cnt[y] = 0
            ans = (ans * ((pow(2, nx, mod) - 1) + (pow(2, ny, mod) - 1) + 1)%mod)%mod
        else:
            num += cnt[x]
    ans = (ans * pow(2, num, mod))%mod
    ans = (ans - 1)%mod
    print((ans + zz)%mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 105816
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int ans=0;
  for(int i=0;i<3;i++){
      if(s.at(i)==t.at(i)) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
# include <cstdio>
# include <iostream>

using namespace std;

bool f=false;
int a,b;

int main()
{
	scanf("%d%d",&a,&b);
	for (int i=1;i<=3;++i)
		if((a*b*i)%2==1) f=true;
	if(f) printf("Yes");
	else  printf("No");
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;

int main(){
  ll n,m;cin>>n;
  vll a(n);
  rep(i,0,n){
      cin>>a[i];
  }
  vb g(40001,false);
  rep(j,0,1<<n){
    ll tmp=0;
    rep(k,0,n){
        if(j>>k&1){
            tmp+=a[k];
        }
    }
    g[tmp]=true;
  }
  cin>>m;
  rep(i,0,m){
    ll q;cin>>q;
    if(g[q]){cout<<"yes"<<endl;}
    else{cout<<"no"<<endl;}
  }
}



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

int main()
{
    int n, m;
    cin >> n >> m;
    int ans=0;
    int nsum=1;
    int msum=1;
    if (n > 1) {
        for (int i = n; i > n - 2; i--) {
            nsum *= i;
        }
        for (int j = 1; j < 2+1; j++) {
            nsum /= j;
        }
    }
    else nsum = 0;
    if (m > 1){
        for (int i = m; i > m - 2; i--) {
            msum *= i;
        }
        for (int j = 1; j < 2+1; j++) {
            msum /= j;
        }
    }
    else msum = 0;
    cout << nsum + msum << endl;
    return 0;
}

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

double n, a, b, c;

int main() {
  cin >> n;
  vector<double> x(n);
  vector<double> y(n);
  rep (i, n) {
    cin >> x[i] >> y[i];
  }
  a = 0; b = 0; c = 0;
  rep (i, n) {
    for (int j = i+1; j < n; ++j) {
      a = (x[i] - x[j]) * (x[i] - x[j]);
      b = (y[i] - y[j]) * (y[i] - y[j]);
      c += pow(a + b, 0.5);
    }
  }
  cout << fixed << setprecision(10) << c * 2 / n << endl;
  return 0;
}


Measured memory_bytes: 4192
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int m=sc.nextInt();
        PriorityQueue<Integer> q=new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
			q.add(-sc.nextInt());
		}
        for (int i = 0; i < m; i++) {
			int p=q.poll()/2;
			q.add(p);
		}
        long a=0;
        for (int i = 0; i < n; i++) {
			a+=-q.poll();
		}
        
        out.println(a);
     	out.flush();
    }

    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x, y;
//	P(int  x, int y) {
//	  this.x=x;
//	  this.y=y;
//	}
//}

class P implements Comparable<P>{
    int a,b;
    P(int a, int b) {
    	this.b=b;
    	this.a=a;
    }

    public int compareTo(P p){
        return p.a-a;//des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() throws IOException{
        return this.nextString().toCharArray();
    }    
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 45740
#include<iostream>
#include<vector>
#include<cmath>
#include<complex>
#include<algorithm>

using namespace std;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}


namespace geom{
#define X real()
#define Y imag()
#define at(i) ((*this)[i])
#define SELF (*this)
	enum {TRUE = 1, FALSE = 0, BORDER = -1};
	typedef int BOOL;
	typedef double R;
	const R INF = 1e8;
	R EPS = 1e-9;
	inline int sig(const R &x) { return (abs(x) < EPS ? 0 : x > 0 ? 1 : -1); }
	inline BOOL less(const R &x, const R &y) {return sig(x-y) ? x < y : BORDER;}
	typedef complex<R> P;
#undef SELF
#undef at
}

using namespace geom;

int f = 0;
namespace std{
	bool operator<(const P &a, const P &b){return sig(a.X-b.X) ? a.X < b.X : a.Y+EPS < b.Y;}
	bool operator==(const P &a, const P &b){return abs(a-b) < EPS;}
	istream& operator>>(istream &is, P &p){R x,y;is>>x>>y;p=P(x, y);return is;}
}

int n;

int check(P p, const vector<P> &a, const vector<P> &b){
	const R PI = 2*atan2(1, 0);
	vector<pair<R, int>> args(1, make_pair(INF, 0));
	for(auto &q : a){
		R a = arg(q - p);
		args.eb(a, 0);
		args.eb(a+2*PI, 0);
	}
	for(auto &q : b){
		R a = arg(q - p);
		args.eb(a, 1);
		args.eb(a+2*PI, 1);
	}
	sort(ALL(args));
	int j=0;
	int ans = n-1;
	int c[2] = {0, 0};
	REP(i, n-1){
		while(args[j].first < args[i].first+PI- EPS) c[args[j++].second]++;
		if(c[0] == 0 && c[1] == b.size()) return 1;
		if(c[1] == 0 && c[0] == a.size()) return 1;
		c[args[i].second]--;
	}
	return 0;
}

int main(){
	cin >> n;
	vector<P> p, q;
	REP(i, n){
		double x, y;
		cin >> x >> y;
		p.eb(x, y);
	}
	REP(i, n){
		P t = p.back();
		p.pop_back();
		if(!check(t, p, q)){
			cout << "Impossible" << endl;
			return 0;
		}
		q.pb(t);
	}
	cout << "Possible" << endl;
	return 0;
}

Measured memory_bytes: 1420
import sys
 
f_i = sys.stdin
 
n, q = map(int, f_i.readline().split())

class DisjointSets:
    def __init__(self, size):
        self.size = size
        self.representatives = list(range(size))

    def _find(self, x):
        return self.representatives[x]

    def union(self, x, y):
        x1 = self._find(x)
        y1 = self._find(y)
        if x1 == y1:
            return None
        # unite Sx and Sy
        for i in range(self.size):
            if self.representatives[i] == y1:
                self.representatives[i] = x1

    def isSameSet(self, x, y):
        if self._find(x) == self._find(y):
            print(1)
        else:
            print(0)

S = DisjointSets(n)

for l in f_i:
    com, x, y = map(int, l.split())
    if com == 0:
        S.union(x, y)
    else:
        S.isSameSet(x, y)

Measured memory_bytes: 8780
export class Main {
  static main(input): string {
    const tmp: string[] = input.split("\n");
    const [n, k]: number[] = tmp[0].split(" ").map(Number);
    let result: string = "";
    if (k > 1) {
      result += tmp[1].slice(0, k - 1);
    }
    result += tmp[1][k - 1].toLowerCase();
    if (k < n) {
      result += tmp[1].slice(k);
    }
    return `${result}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
//let input = "100 22 5"; // x k d 初期座標　回数　一度に動ける

function main(input){
  input = input.trim();
  let list = input.split(" ");
  let x = Math.abs(parseInt(list[0]));
  let k = parseInt(list[1]);
  let d = parseInt(list[2]);
  let kaisuu = Math.floor(x/d); // ０を過ぎずに最も接近できる回数
  if(kaisuu>k){ // kを超えてしまったらkaisuuはk
    kaisuu=k;
  }
  let nokoriKaisuu = k - kaisuu;
  if(nokoriKaisuu%2===0){ // 残り回数が偶数のとき
    // 何もしない
  }else if(nokoriKaisuu%2===1){ // 残り回数が奇数のとき
    if(0 < x - d*kaisuu){ // kaisuu回移動したとき、xが正
      kaisuu+=1;
    }else{ // xが０か負
      kaisuu-=1;
    }
  }
  let answer = Math.abs(x - d*kaisuu);
  console.log(answer);
}
//main(input);
main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    int a[3000];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n, greater<int>());
    /*
    int f = -1;
    for (int i = 0; i <= a[0]; i++)
    {
        int tmp = 0;
        for (int j = 0; j < n; j++)
            tmp += i % a[j];
        f = max(f, tmp);
    }
    cout << f << endl;
    */
    int f = 0;
    for (int i = 0; i < n; i++)
        f += a[i] - 1;
    cout << f << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a, b, c ;
	scanf("%d %d %d", &a ,&b ,&c);
	if (a <= b && b <= c){
		printf("%d %d %d\n", a, b, c);
	}
	else if(a <= b && b > c){
		printf("%d %d %d\n", a, c, b);
	} 
	else if(b < a && a < c){
		printf("%d %d %d\n", b, a, c);
	}
	else if(c < a && a < b){
		printf("%d %d %d\n", c, a, b);
	}
	else if(c < b && b < a){
		printf("%d %d %d\n", c, b, a);
	}
	else if(b < c && c < a){
		printf("%d %d %d\n", b, c, a);
	}
	else if(a > b && b <= c){
		printf("%d %d %d\n", b, c, a);
	}
	return 0;
}

Measured memory_bytes: 1748
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    ll N,A,B;cin>>N>>A>>B;
    if((B-A)%2==0){
        cout<<(B-A)/2<<endl;
        return 0;
    }
    cout<<min((A+B-1)/2,N-(A+B-1)/2)<<endl;
    return 0;
}

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

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

  vector<lint> A(N);
  for(auto& elem : A) cin >> elem;

  K = min(K, 100LL);
  while(K--) {
    vector<lint> imos(N+1, 0);
    for(lint i=0; i<N; i++) {
      imos[max(0LL,i-A[i])]++;
      imos[min(N,i+A[i]+1)]--;
    }
    partial_sum(imos.begin(), imos.end(), imos.begin());
    for(lint i=0; i<N; i++) {
      A[i] = imos[i];
    }
  }

  for(auto& e : A) cout << e << " ";
  cout << endl;
}


Measured memory_bytes: 6364
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int h, w, n;
    scan(h, w);
    scan(n);
    auto a = readArr!(int)();
    auto ans = new int[](h * w);
    int num = 1;
    foreach (i ; 0 .. h * w) {
        if (a.front == 0) {
            a.popFront();
            num++;
        }
        ans[i] = num;
        a.front -= 1;
    }
    debug {
        writeln(ans);
    }
    foreach (i ; 0 .. h) {
        auto line = ans[w*i .. w*i + w];
        writefln("%(%s %)", i % 2 ? line.retro.array : line);
    }
}





void yes(bool b) {writeln(b ? "Yes" : "No");}
void YES(bool b) {writeln(b ? "YES" : "NO");}
T[] readArr(T)() {return readln.split.to!(T[]);}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 636
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = set()
for i in range(1,50):
    for j in range(2,10):
        if i**j > 1000:
            break
        s.add(i**j)
n = inp()
for i in range(n,0,-1):
    if i in s:
        print(i)
        break

Measured memory_bytes: 5076
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<numeric>
#include<limits>
#include <cstdint>
#include<stack>
#include<queue>
using namespace std;
#define ll long long int
#define rep(N) for(ll i=0;i<N;i++)
#define rep2(N1,N2) for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)for(ll k=0;k<N3;k++)
#define For(i,N) for(ll i=0;i<N;i++)

void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}

ll kai(ll x) {
	ll a = 1;
	if (x <= 0)
		return 1;
	else {
		for (ll i = 0; i < x; i++)
			a = a * (i + 1);
		return a;
	}
}

ll rui(ll x, ll y) {
	ll a = 1;
	for (ll i = 0; i < y; i++)
		a = a * x;
	return a;
}
const int nmax = 150;
int cccc[nmax][nmax];
ll comb(ll n, ll k) {
	if (n < k) {
		cout << "error n<k" << endl;
		return -1;
	}
	if (cccc[n][k] > 0)return cccc[n][k];
	if (k == 0 || n == k)return 1;
	return cccc[n][k] = comb(n - 1, k - 1) + comb(n - 1, k);
}

ll keta(ll a) {
	ll i = 1;
	while (1) {
		if (a < pow((ll)10, i))
			return i;
		i++;
	}
}
vector<ll> v;
ll n, m;
//m進数全探索
ll inc(ll a = n - 1) {
	if (a == 0 && v[0] == m) {
		v[0] = -1;
		return v[0];
	}
	if (v[a] == m) {
		v[a] = 0;
		inc(a - 1);
		return v[a];
	}
	else {
		++v[a];
		return v[a];
	}
}

ll powl(ll a, ll b) {
	ll c = 1;
	rep(b)
		c = c * a;
	return c;
}


int main() {
	cout.precision(20);
	string S;
	ll N, M, K;
	cin >> N;
	vector<ll>X(N);
	rep(N)
		cin >> X[i];
	ll cnt = 0;
	ll ans = 9999999999999;
	rep(101) {
		For(j, N) {
			cnt += pow(X[j] - i, 2);
		}
		ans = min(ans, cnt);
		cnt = 0;
	}
	cout << ans;
}




Measured memory_bytes: 256
N, M = gets.chomp.split(" ").map(&:to_i)

PYs = M.times.map do |_|
  gets.chomp.split(" ").map(&:to_i)
end

prefs = PYs.inject({}) do |m, v|
  m[v[0]] = [] unless m.key?(v[0])
  m[v[0]].push(v)
  m
end

prefs.each do |pref, v|
  v.sort_by { |v| v[1] }.each.with_index do |v2, i|
    v2.push("#{pref.to_s.rjust(6, "0")}#{(i + 1).to_s.rjust(6, "0")}")
  end
end

PYs.each do |v|
  puts v[2]
end


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

char s[200010];

int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	int flag=1;
	if(s[1]=='0'||s[n]=='1') flag=0;
	for(int i=1;i<n;i++) if(s[i]!=s[n-i]) flag=0;
	if(!flag)
	{
		puts("-1");
		return 0; 
	}
	int now=1;
	for(int i=2;i<=n;i++)
	{
		printf("%d %d\n",now,i);
		if(s[i-1]=='1') now=i;
	}
}

Measured memory_bytes: 3880
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NM[0]; var M = NM[1];
            var group = new UnionFind(N);

            for (int i = 0; i < M; i++)
            {
                var ab = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                group.unite(ab[0], ab[1]);
            }

            var result = 0;
            for (int i = 1; i <= N; i++)
            {
                if (group.RootCount(i) > result) result = group.RootCount(i);
            }
            Console.WriteLine(result);
        }
    }
    public class UnionFind
    {
        private int[] parents;
        // 同じ根に属する枝の数を格納する
        private int[] rootCount;

        public int RootCount(int branch)
        {
            return rootCount[root(branch)];
        }

        public UnionFind(int count)
        {
            parents = new int[count + 1];
            rootCount = new int[count + 1];
            for (int i = 0; i < count + 1; i++)
            {
                parents[i] = i;
                rootCount[i] = 1;
            }
        }

        private int root(int N)
        {
            if (parents[N] == N) return N;
            return parents[N] = root(parents[N]);
        }

        //木を併合する際に、枝の数も合算する
        public void unite(int X, int Y)
        {
            int rootX = root(X);
            int rootY = root(Y);
            if (rootX == rootY) return;
            rootCount[rootX] += rootCount[rootY];
            parents[rootY] = rootX;
        }

        public bool sameRoot(int X, int Y)
        {
            return root(X) == root(Y);
        }
    }
}


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

void prime_factor(vector<int> &res,int n){
    res[0]=-1;
    for(int i=2; i*i<=n; i++){
        while(n%i==0){
            ++res[i];
            n/=i;
        }
    }
    if(n!=1) res[n]+=1;
}

int main(){
    long long k,c=1;
    cin >> k;
    vector<int> res(k+1);
    for(int i=0;i<k+1;i++){
        res[i]=0;
    }
    for(int i=1;i<=k;i++){
        prime_factor(res,i);
    }
    for(int i=1;i<=k;i++){
        if(res[i]>=1){
            c*=(res[i]+1);
            c%=1000000007;
        }
    }
    cout<<c;
}

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

using namespace std;
using ll=long long;

void solve() {
    ll n,k;
    cin >> n >> k;
    n %= k;
    cout << min(n, k-n);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    ab = []
    for _ in range(N):
        ab.append([int(x) for x in input().split()])

    count = 0
    i = -1
    ab.sort()
    while count < K:
        i += 1
        count += ab[i][1]

    print(ab[i][0])






if __name__ == '__main__':
    main()



Measured memory_bytes: 21640
#include<bits/stdc++.h>
using namespace std;
bool vis[222222];
int ans[222222];
int m,n,x,y=1;
int main()
{
    scanf("%d%d",&n,&x);m=n*2-1;
    if(x==1||x==m) puts("No");
    else
    {
        ans[m>>1]=x-1;ans[(m>>1)+1]=x;ans[(m>>1)+2]=x+1;
        vis[x-1]=vis[x]=vis[x+1]=true;
        if((m>>1)-1>=1&&x+2<=m) ans[(m>>1)-1]=x+2,vis[x+2]=true;
        if((m>>1)+1<=m&&x-2>=1) ans[(m>>1)+3]=x-2,vis[x-2]=true;
        for(register int i=1;i<=m;++i)
        {
            if(ans[i]) continue ;
            else
            {
                while(vis[y]) ++y;
                ans[i]=y;vis[y]=true;
            }
        }
        puts("Yes");
        for(register int i=1;i<=m;++i) printf("%d\n",ans[i]);
    }
    return 0;
}

Measured memory_bytes: 2432
/* Your prologue will be the story. */
/* Copyright by HenryLi */
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<sstream>
#include<stack>
#include<ctime>
#include<cmath>
#include<cctype>
#include<climits>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<bitset>
#include<complex>
using namespace std;
template <class _T> inline void read(_T &_x) {
	int _t; bool _flag=false;
	while((_t=getchar())!='-'&&(_t<'0'||_t>'9')) ;
	if(_t=='-') _flag=true,_t=getchar(); _x=_t-'0';
	while((_t=getchar())>='0'&&_t<='9') _x=_x*10+_t-'0';
	if(_flag) _x=-_x;
}
typedef long long LL;
LL n;
int main() {
	//freopen("A.in","r",stdin);
	//freopen("A.out","w",stdout);
	read(n);
	LL ans = 0;
	bool flag = false;
	while (n >= 10) {
		if (n % 10 < 9) flag = true;
		n /= 10, ans += 9;
	}
	ans += n - flag;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int X,t,s;
	scanf("%d",&X);
	scanf("%d",&t);
	if(X>t){
	s=X-t;
	}
	if(X<=t){
	s=0;
	}
	printf("%d\n",s);
	return 0;
}


Measured memory_bytes: 128
//

fun main() {
    abc171b()
}

fun abc171b() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val p = readLine()!!.split(" ").map { it.toInt() }
    val sorted = p.sorted()
    var sum = 0
    for (i in 0 until k) {
        sum += sorted[i]
    }
    println(sum)
}


Measured memory_bytes: 40640
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: String = scan(tokens);
    for ch in n.chars() {
        if ch == '7' {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


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

int main() {
  const int MOD = 1000000007;
  string L; cin >> L;
  int N = L.size();
  vector<vector<long long>> dp(N+1, vector<long long>(2, 0));
  dp.at(0).at(0) = 1;
  for (int i = 0; i < N; i++) {
    // 未満フラグ立っていないとき
    int D = L.at(i) - '0';
    if (D == 1) {
      dp.at(i+1).at(0) += dp.at(i).at(0) * 2 % MOD;
      dp.at(i+1).at(1) += dp.at(i).at(0);
    }
    else {
      dp.at(i+1).at(0) += dp.at(i).at(0);
    }
    // 未満フラグ立っているとき
    dp.at(i+1).at(1) += dp.at(i).at(1) * 3 % MOD;
  }
  cout << (dp.at(N).at(0) + dp.at(N).at(1)) % MOD << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <math.h>
#include <deque>
#include <stack>
#include <queue>

#define PI 3.14159265358979323846

using namespace std;

typedef long long ll;
typedef long double ld;


int solve() {
    ll n;
    string s;
    cin >> n >> s;
    string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    ll num = 26;
    for(ll i = 0;i < s.length(); i++){
        ll slide = 0;
        for(ll j = 0;j < num; j++){
            if(s[i] == alpha[j]){
                slide = j;
            }
        }
        for(ll j = 0;j < n; j++){
            slide++;
        }
        s[i] = alpha[slide % num];
    }
    cout << s << endl;
    return 0;
}


int main(void){
  solve();
  return 0;
}


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

int main() {
  long X, Y, A, B, C, Sum=0;
  cin >> X >> Y >> A >> B >> C;
  vector<long> P(A), Q(B), S(A+B+C);
  
  rep(i, A) cin >> P.at(i);
  sort(P.begin(), P.end());
  reverse(P.begin(), P.end());
  rep(i, X) S.at(i)=P.at(i);

  rep(i, B) cin >> Q.at(i);
  sort(Q.begin(), Q.end());
  reverse(Q.begin(), Q.end());
  rep(i, Y) S.at(i+X)=Q.at(i);

  rep(i, C) cin >> S.at(i+X+Y);
  
  sort(S.begin(), S.end());
  reverse(S.begin(), S.end());
  rep(i, X+Y) Sum=Sum+S.at(i);

  cout << Sum << endl;
}

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

    int N, K, i, d, j, k, l, ans;
    cin >> N >> K;
    vector<int> kotae (N);
    ans = 0;

    for (i = 0; i < K; i++){
        cin >> d;
        vector<int> okashi (d);
    
        for (j = 0; j < d; j++){
            cin >> okashi.at(j);
            
            for (k = 0; k < N; k++){
                if(okashi.at(j) == k+1){
                    kotae.at(k) = 1;
                }
            }
        }
    }

    for (l = 0; l < N; l++){
        if (kotae.at(l) == 0){
            ans = ans + 1;
        }    
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 3556