akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main (){

  long long int n,m,sum;

  scanf("%lld%lld",&n,&m);

  if(2*n >= m) printf("%lld\n",m/2);
  else if((m-2*n)<3) printf("%lld\n",n);
  else printf("%lld\n",n+(m-2*n)/4);

  return 0;
}


Measured memory_bytes: 128
#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>;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)

ll n, W;
ll w[110], v[110];
ll dp[110][110000];

int main(){
    cin >> n >> W;
    for(int i=1; i<=n; i++) cin >> w[i] >> v[i];

    for(int j=1; j<110000; j++){
        dp[0][j] = LINF;
    }
    for(int i=1; i<=n; i++){
        for(int j=0;j<110000;j++){
            dp[i][j] = dp[i-1][j];
            if(j-v[i]>=0){
                dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]]+w[i]);
            }
        }
    }
    ll ans = 0;
    for(ll v=0; v<110000; v++){
        if(dp[n][v]<=W){
            ans = max(ans, v);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 90440
fun main(args: Array<String>){
    val input: List<Int> = readLine()!!.split(" ").map { it.toInt() }
    val a = input[0]
    val b = input[1]

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

Measured memory_bytes: 38000
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<queue>
#define null NULL
using namespace std;
/** 区间表示：[p->dl,p->dr]
 *  从0开始计数，[0,n-1]
 *  线段树RSQ
 *
 */

struct Node
{
    long long dl,dr,s,delta;
    Node *pl,*pr;
};
int n,q;

void build(Node *&p,int l,int r)
{
    p=(Node *)malloc(sizeof(Node));
    p->dl=l,p->dr=r,p->s=0,p->delta=0;
    p->pl=null,p->pr=null;
    int mid=(l+r)/2;
    if(r>l)
    {
        build(p->pl,l,mid);
        build(p->pr,mid+1,r);
    }
}

void pushdown(Node *&p,int delta)
{
    p->pl->s += p->delta*(p->pl->dr - p->pl->dl+1);
    p->pr->s += p->delta*(p->pr->dr - p->pr->dl+1);
    p->pl->delta += p->delta;
    p->pr->delta += p->delta;
    p->delta=0;
}

void update(Node *&p,int l,int r,int data)
{
    ///[l,r]必然位于[p->dl,p->dr]子区间
    if(p->delta>0 && p->dr>p->dl)
        pushdown(p,p->delta);

    p->s+=data*(r-l+1);
    if(p->dl==l &&p->dr==r)
    {
        p->delta=data;
        return ;
    }
    int mid=(p->dl+p->dr)/2;
    if(r<=mid)
        update(p->pl,l,r,data);
    else if(l>mid)
        update(p->pr,l,r,data);
    else
        update(p->pl,l,mid,data),update(p->pr,mid+1,r,data);
}
long long query(Node *&p,int l,int r)
{
    ///一个查询区间最终必然被分成若干个小的区间和，最后一个定会完全和区间贴合
    if(p->delta>0 && p->dr>p->dl)
        pushdown(p,p->delta);

    if(p->dl==l &&p->dr==r)
        return p->s;
    int mid=(p->dl+p->dr)/2;
    ///判断查询区间与当前区间的位置关系
    //全部位于左侧
    if(r<=mid)
        return query(p->pl,l,r);
    //全部位于右侧
    else if(l>mid)
        return query(p->pr,l,r);
    //两个都有
    else
        return query(p->pl,l,mid)+query(p->pr,mid+1,r);
}

int main()
{
    int i,type,tx,ty,x;
    Node *tree=null;
    scanf("%d%d",&n,&q);
    build(tree,0,n-1);
    for(i=0;i<q;i++)
    {
        scanf("%d",&type);
        if(type==0)
        {
            scanf("%d%d%d",&tx,&ty,&x);
            tx--,ty--;
            update(tree,tx,ty,x);
        }else
        {
            scanf("%d%d",&tx,&ty);
            tx--,ty--;
            long long ans=query(tree,tx,ty);
            printf("%lld\n",ans);
        }
    }
    return 0;
}



Measured memory_bytes: 15708
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int main(){
    int H,W;
    cin >> H >> W;
    string C[100];
    REP(i,H) cin >> C[i];
    REP(i,H){
        cout << C[i] << endl;
        cout << C[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
l = list(map(int, input().split()))


ans = 0

def solve(l):
    global ans
    if len(l) == 1:
        ans += l[0]
    elif len(l) == 0:
        pass
    else:
        minv = min(l)
        ans += minv

        l = [x - minv for x in l]

        zero = l.index(0)

        solve(l[:zero])
        solve(l[zero+1:])

solve(l)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using pr = pair<int, int>;

int N, A[100005], B[100005];
ll ans;

int main() {
    scanf("%d", &N);
    for(int i=1; i<=N+1; i++) scanf("%d", B+i);
    for(int i=1; i<=N; i++) scanf("%d", A+i);
    for(int i=1; i<=N; i++) {
        if(B[i] > A[i]) ans += A[i], B[i] -= A[i], A[i] = 0;
        else ans += B[i], A[i] -= B[i], B[i] = 0;
        if(B[i+1] > A[i]) ans += A[i], B[i+1] -= A[i], A[i] = 0;
        else ans += B[i+1], A[i] -= B[i+1], B[i+1] = 0;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 1024
import sys
def input(): return sys.stdin.readline().strip()

def main():
    a,b,k=map(int,input().split())
    for i in range(min(a,b),0,-1):
        if a % i == 0 and b % i == 0:
            k-=1
            if k==0:
                print(i)
                return

main()

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
  int N, X, Y;
  cin >> N >> X >> Y;
  int ans[N];
  for (int i = 0; i < N; i++){
    ans[i] = 0;
  }
  X--;
  Y--;

  for (int i = 0; i < N - 1; i++){
    for (int j = i + 1; j < N; j++){
      if (i <= X && X <= j && i <= Y && Y <= j){
        ans[j - i - (Y - X) + 1]++;
      }else if(X <= i && i <= Y && Y <= j){
        int tmp;
        if (Y-i > i-X) {
          tmp = i - X;
        }else{
          tmp = Y - i;
        }
        
        tmp = (j - Y) + tmp + 1;
        if (tmp <= j-i) {
          ans[tmp]++;
        }else{
          ans[j-i]++;
        }
      }else if(i <= X && X <= j && j <= Y){
        int tmp;
        if (Y-j > j-X) {
          tmp = j - X;
        }else{
          tmp = Y - j;
        }

        tmp = (X - i) + tmp + 1;
        if (tmp <= j-i){
          ans[tmp]++;
        }else{
          ans[j-i]++;
        }
      }else if(X < i && j < Y){
        int tmp = (i - X) + (Y - j) + 1;
        
        if (tmp <= j-i){
          ans[tmp]++;
        }else{
          ans[j-i]++;
        }

      }else{
        ans[j-i]++;
      }
    }
    
  }
  
  for (int i = 1; i < N; i++){
    printf("%d\n", ans[i]);
  }
  
}


Measured memory_bytes: 3764
#include <stdio.h>
int main ()
{
	int j,i,n,a[100010],b[100010];
	scanf("%i",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%i",&a[i]);
	}
	for(i=1;i<=n;i++)
	{
		b[a[i]]=i;
	}
	for(i=1;i<=n;i++)
	{
		printf("%i ",b[i]);
	}
	return 0;
}


Measured memory_bytes: 1536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
 
    public static void main(String[] args)
    {
        FastReader s=new FastReader();
        int d = s.nextInt();
        int t = s.nextInt();
        int sp = s.nextInt();

        String ans;

        double time = 1.0 * d / sp;
        if(time <= t)
        {
            ans = "Yes";
        }else{
            ans = "No";
        }
        System.out.println(ans);
        
    }
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef unsigned long long ll;

int main(){
    int w, h, x, y;
    cin >> w >> h>> x >> y;

    std::cout << std::setprecision(9) << std::fixed;
    cout << (double)w*(double)h/2;

    if (x + x == w && y + y == h){
        cout << " 1" << endl;
    }
    else{
        cout << " 0" << endl;
    }
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
 
#define ll long long
#define ll128 __uint128_t
#define ld long double
#define pll pair <ll, ll>
 
#define vll vector <ll>
#define vld vector<ld>
#define vpll vector<pll>
 
#define vvll vector <vll>
 
#define rep(i, a, b) for(ll i = (ll)a; i < (ll)b; i++)
#define per(i, a, b) for(ll i = (ll)a - 1; i >= (ll)b; --i)
 
#define endl "\n"
#define pb push_back
#define pf push_front
 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
 
#define sorta(v) sort(all(v))
#define sortd(v) sort(rall(v))
 
#define debug if (1)
#define log(val) debug {cout << "\n" << #val << ": " << val << "\n";}
 
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define file(name) freopen(name".in", "r", stdin); freopen(name".out", "w", stdout);
#define FILE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
 
#define mod (ll)(1e9 + 7)
#define inf (mod * mod)
 
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
 
ostream & operator << (ostream & out, vll & a) {
    for(auto i : a) out << i << " ";
    return out;
}
 
istream & operator >> (istream & in, vll & a) {
    for(auto &i : a) in >> i;
    return in;
}
 
const ll N = 2e5 + 5;
ll md = 1e9 + 7;
 
ll fact[N], revfact[N];
 
ll cnk1(ll n, ll k) {
    if (n < k || k == 0) return 1;
    return (((1LL * fact[n] % md * revfact[n - k] % md) % md) * revfact[k] % md) % md;
}
 
ll cnk(ll n, ll k) {
    return cnk1(n + k - 2, n - 1);
}
 
ll binpow (ll a, ll n, ll m) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return res;
}
 
void precalc() {
    fact[0] = 1;
    fact[1] = 1;
    rep(i, 2, N) {
        fact[i] = (1LL * fact[i - 1] % md * i % md) % md;
    }
    revfact[0] = 1;
    revfact[N - 1] = binpow(fact[N - 1], md - 2, md);
    for(ll i = N - 2; i >= 1; i--) {
        revfact[i] = (1LL * revfact[i + 1] % md * (i + 1) % md) % md;
    }
}
 
int main() {
    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    precalc();
 
 
    ll curi = h - a;
    ll ans = 0;
    rep(j, b + 1, w + 1) {
        ans += (cnk(curi, j) * (cnk(a, w - j + 1)));
        ans %= md;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6716
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll H,N;
    cin>>H>>N;
    ll sum=0, x;
    loop(i,0,N) {
        cin >>x;
        sum+=x;
    }
    if (sum>=H) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") // wonderful

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


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

	int res = 0;

	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		if (x >= k)
			res++;
	}

	cout << res;
	return 0;

}

Measured memory_bytes: 3636
N = int(input())
list = []
for i in range(N):
    list.append(input())
C0 = 0
C1 = 0
C2 = 0
C3 = 0
for i in range(N):
    if list[i] == "AC":
        C0 += 1
    elif list[i] == "WA":
        C1 += 1
    elif list[i] == "TLE":
        C2 += 1
    elif list[i] == "RE":
        C3 += 1
        
print("AC x",C0)
print("WA x", C1)
print("TLE x", C2)
print("RE x", C3)

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

int main()
{
    int n, w[100], ans;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> w[i];
    }
    ans = abs(accumulate(w, w + 1, 0) - accumulate(w + 1, w + n, 0));
    for (int i = 1; i < n; ++i)
    {
        ans = min(ans, abs(accumulate(w, w + i, 0) - accumulate(w + i, w + n, 0)));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()

def isMonth(n):
	return n <=12 and n > 0
a = isMonth(int(s[:2]))
b = isMonth(int(s[2:]))

if a and b:
	print("AMBIGUOUS")
if a and not b:
	print("MMYY")
if not a and b:
	print("YYMM")
if not a and not b:
	print("NA")

Measured memory_bytes: 3060
N,K = map(int,input().split()) #N = 4,K=5
A = [int(i)-1 for i in input().split()]
log_K = K.bit_length() #3bit (5 = 101)
next = [[-1]*N for _ in range(log_K)]

for i in range(N):
    next[0][i] = A[i]
    
for k in range(log_K - 1):
    for i in range(N):
        next[k+1][i] = next[k][next[k][i]]  

now = 0
for i in range(log_K)[::-1]: 
    if ((K >> i) & 1) == 1: 
        now = next[i][now]
print(now + 1) 

Measured memory_bytes: 174912
#include<iostream>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
#pragma warning(disable:4996)
int n, m, q, a[1 << 18], b[1 << 18], c[1 << 18], d[1 << 18], e[1 << 18], dist[1 << 18]; vector<pair<int, int>>x[1 << 18], y[1 << 18];
void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) reader(&a[i]), reader(&b[i]);
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= m; i++) {
		x[a[i]].push_back(make_pair(b[i], d[i]));
		x[b[i]].push_back(make_pair(a[i], d[i]));
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	queue<int> Q1; Q1.push(1);
	while (!Q1.empty()) {
		int a1 = Q1.front(); Q1.pop();
		for (pair<int, int> i : x[a1]) {
			if (dist[i.first] == -1) {
				dist[i.first] = dist[a1] + 1;
				Q1.push(i.first);
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		for (pair<int, int> j : x[i]) {
			if (dist[i] < dist[j.first]) y[i].push_back(j);
		}
	}
	priority_queue<pair<int, int> >Q; Q.push(make_pair(1 << 30, 1)); e[1] = (1 << 30);
	while (!Q.empty()) {
		int a1 = Q.top().first, a2 = Q.top().second; Q.pop();
		for (int i = 0; i < y[a2].size(); i++) {
			if (e[y[a2][i].first] < min(y[a2][i].second, a1)) {
				e[y[a2][i].first] = min(y[a2][i].second, a1);
				Q.push(make_pair(e[y[a2][i].first], y[a2][i].first));
			}
		}
	}
	sort(e + 1, e + n + 1);
	int T = 1;
	for (int i = 1; i <= q; i++) {
		while (e[T] <= i) T++;
		printf("%d\n", T - 1);
	}
	return 0;
}

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


void solve(long long N, long long K){
    long long int a = N%K;
    long long int t = N;
    long long int b = abs(K-a);
    long long int c = abs(K-b);
    long long int k = min(a,b);
    k = min(k,c);

    // int o = abs(N-K);
    // a = o%K;
    // b = K-a;
    // c = K-b;
    // int t = min(a,b);
    // t = min(t,c);

    // int p = min(k,t);
    cout << k << endl;
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], m = tmp[1], c = tmp[2];
    int[] b = readln.split.to!(int[]);
    int cnt;
    foreach (i; 0 .. n) {
        int[] a = readln.split.to!(int[]);
        int src = c;
        foreach (j; 0 .. m) {
            src += a[j] * b[j];
        }
        if (src > 0) ++cnt;
    }
    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 256
// by adiforluls
#pragma GCC optimize ("-O2")
#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 FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul             1000000007
#define rep(i,a,b)      for(int i=a;i<b;i++)
#define rfor(i,a,b)     for(int i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define lul2            998244353 
#define pll             pair<ll,ll>
#define endl            '\n'
#define SIZE            1000005
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void mod(ll &x)
{
    if(x>=lul) x-=lul;
    if(x<0) x+=lul;
}

int n,k,ans=1;
vector<int> a;
bool ok(int fact)
{
    vector<int> temp;
    for(auto i:a)
    {
        temp.pb(i%fact);
    }
    sort(all(temp));
    int moves = 0, rem = 0, l = 0, r = n-1;
    while(l<=r)
    {
        if(rem<=0)
        {
            moves+=temp[l];
            rem+=temp[l];
            l++;
        }
        else{
            moves+=(fact-temp[r]);
            rem-=(fact-temp[r]);
            r--;
        }
    }
    return ((moves<=2*k) and (rem == 0));
}
void solve()
{
    cin>>n>>k;
    a.resize(n);
    int sum = 0;
    rep(i,0,n)
    {
        cin>>a[i];
        sum+=a[i];
    }
    for(int i=1; i*i<=sum; i++)
    {
        if(sum%i == 0)
        {
            if(ok(i)) ans = max(ans,i);
            if(i*i!=sum)
            {
                if(ok(sum/i)) ans = max(ans,sum/i);
            } 
        }
    }
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; /*cin>>t;*/ t=1;
    rep(i,1,t+1){
        solve();
    }
    return 0;
}

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

using namespace std;

struct point
{
    double x,y;
};

void solve(point a,point b,int n)
{
    if(!n)
    {
        return;
    }

    point s,t,u;

    double th=M_PI/3.0;

    s.x=(2*a.x+b.x)/3;
    s.y=(2*a.y+b.y)/3;
    t.x=(a.x+2*b.x)/3;
    t.y=(a.y+2*b.y)/3;

    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

    n--;
    solve(a,s,n);
    printf("%.8lf %.8lf\n",s.x,s.y);
    solve(s,u,n);
    printf("%.8lf %.8lf\n",u.x,u.y);
    solve(u,t,n);
    printf("%.8lf %.8lf\n",t.x,t.y);
    solve(t,b,n);
}


int main()
{
    int n;

    while(scanf("%d",&n)!=EOF)
    {
        point a,b;

        a.x=0,a.y=0;
        b.x=100,b.y=0;

        printf("%.8lf %.8lf\n",a.x,a.y);
        solve(a,b,n);
        printf("%.8lf %.8lf\n",b.x,b.y);
    }



    return 0;
}



Measured memory_bytes: 3220
N,X,M=map(int, input().split())
A=[X]
for i in range(1,M+1):
  d=pow(A[i-1],2,M)
  if d in A:
    break
  A.append(d)
c=A.index(d)
e=len(A)
cy=e-c
ans=0
if N<=e:
  for i in range(N):
    ans+=A[i]
  print(ans)
else:
  m=sum(A[:c])
  n=sum(A[c:e])
  #print(m,n)
  f=(N-c)//cy
  ans=m+n*f+sum(A[c:c+((N-c)%cy)])
  print(ans)


Measured memory_bytes: 67784
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
	int n,i,a[1000000],max=0,tmp=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]>max) max=a[i];
	}
	for(i = 0; i < n; i++){
        if(abs(max / 2 - tmp) > abs(max / 2 - a[i])){
            tmp = a[i];
        }
    }
    printf("%d %d\n",max,tmp);
	return 0;
}

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

int main()
{
	int n,a;
	cin>>n;
	a=n%10;
	if(a==2||a==4||a==5||a==7||a==9)
		cout<<"hon";
	else if(a==0||a==1||a==6||a==8)
		cout<<"pon";
	else if(a==3)
		cout<<"bon";
	return 0;
}

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

int main()
{
    int n ;
    cin>>n;
    map<string , int> m;
    for(int i=0;i<n;i++)
    {
        string x;
        cin>>x;
        m[x]++;
    }
    map<string , int>::iterator it = m.begin();
    int max = 0;
    while( it!= m.end() )
    {

        if( it->second > max)
        {
            max = it->second;
        }
        it++;
    }
    vector<string> ans;

    it = m.begin();
    while( it!= m.end())
    {
        if( it->second == max)
        {
            string temp = it->first;
            ans.push_back(temp);
        }
        it++;
    }
    sort( ans.begin() , ans.end());
    for(int i=0;i<ans.size();i++)
    {
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 27092
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int a, e;
	double c, f = 0;
	string d;
	cin >> a;
	for (int h = 1; h <= a; h++) {
		cin >> c >> d;
		if (d == "BTC") {
			c = c * 380000;
		}
		f = c + f;
	}
	cout << f << "\n";
	cin >> e;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long k = long.Parse(Console.ReadLine());
		long[] answers = new long[50];
    Console.WriteLine(50);
    long quotient = k / 50;
    int remainder = (int)(k % 50);

    if(k <= 50)
    {
      for(int i = 0; i < k; i++) answers[i] = 50;
    }else
    {
      for(int i = 0; i < remainder; i++)
      {
        answers[i] = 50+quotient-i;
      }
      for(int i = remainder; i < 50; i++)
      {
        answers[i] = 50+quotient-i-1;
      }
    }
    
    Console.WriteLine(string.Join(" ", answers));
	}
}

Measured memory_bytes: 13268
#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>;
 
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};
 
const int MX = 200005;
int in[MX], out[MX], k;
vector<int> to[MX];
void dfs(int v, int p=-1) {
  in[v] = k++;
  for (int u : to[v]) {
    if (u == p) continue;
    dfs(u,v);
  }
  out[v] = k;
}
 
vector<int> vs[MX];
 
ll c2(ll n) { return n*(n+1)/2;}
 
int main() {
  int n;
  cin >> n;
  vector<int> c(n);
  rep(i,n) cin >> c[i];
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  dfs(0);
  rep(i,n) vs[c[i]-1].push_back(i);
  ll tot = c2(n);
  BIT<int> d(n);
  rep(i,n) d.add(i,1);
  rep(i,n) {
    ll ans = tot;
    vector<int>& nvs = vs[i];
    sort(nvs.begin(), nvs.end(), [&](int a, int b) {
      return in[a] > in[b];
    });
    vector<P> history;
    for (int v : nvs) {
      int cnt = 1;
      for (int u : to[v]) {
        if (in[u] < in[v]) continue;
        int num = d.sum(in[u], out[u]);
        ans -= c2(num);
        cnt += num;
      }
      d.add(in[v], -cnt);
      history.emplace_back(in[v], cnt);
    }
    ans -= c2(d.sum(0,n));
    for (auto p : history) {
      d.add(p.first, p.second);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 35240
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
//#define lli long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod  1000000007
using namespace std;
bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{
       if(a.first!=b.first) return(a.first > b.first);
       else return (a.second<b.second);
} 
ll power(ll x,ll n,ll m)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%m;
        x=(x*x)%m;
        n=n/2;
    }
    return result%m;
}
bool isPrime(ll k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    ll i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}
 
ll bin(ll n)
{
    int di= 0;
    while(n)
    {   di=di+n%10;
        n=n/10;
        
    }
    return di;
}
 

int main(){
   IOS;
ll t;
t=1;
//cin>>t;

while(t--){
ll n;cin>>n;
ll a[n];
for(ll i=0;i<n;i++) cin>>a[i];sort(a,a+n);
ll ans=0;
if(n%2==0){
    for(ll i=n/2;i<n-1;i++) ans=ans+2*a[i];
    cout<<ans+a[n-1];
}
else{
    for(ll i=n/2+1;i<n-1;i++) ans=ans+2*a[i];
    cout<<ans+a[n-1]+a[n/2];
}
}
return 0;}

Measured memory_bytes: 5200
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
	int a[30][30]={{0}};
	char str;
	int cnt=0,m;
	int ans=0;
	int x,y,z;
	while(scanf("%d%c%d%c%d",&x,&str,&y,&str,&z)!=EOF){
	    x+=10,y+=10;
        if(z==1){
            a[x][y]++;
            a[x+1][y]++;
            a[x-1][y]++;
            a[x][y+1]++;
            a[x][y-1]++;

        }
        else if(z==2){
            a[x][y]++;
            a[x+1][y+1]++;
            a[x+1][y-1]++;
            a[x+1][y]++;
            a[x-1][y+1]++;
            a[x-1][y-1]++;
            a[x-1][y]++;
            a[x][y+1]++;
            a[x][y-1]++;


        }
        else if(z==3){
            a[x+1][y]++;
            a[x+2][y]++;
            a[x][y+1]++;
            a[x][y+2]++;
            a[x-1][y]++;
            a[x-2][y]++;
            a[x][y-1]++;
            a[x][y-2]++;
            a[x+1][y+1]++;
            a[x-1][y-1]++;
            a[x+1][y-1]++;
            a[x-1][y+1]++;
            a[x][y]++;




        }


	}
	for(int i=10;i<20;i++){
            for(int j=10;j<20;j++){
                if(a[i][j]==0)cnt++;
                ans=max(ans,a[i][j]);
            }
        }
        cout<<cnt<<endl<<ans<<endl;



	return 0;
}

Measured memory_bytes: 1208
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        for (int i = 1; i <= n; i++) {
            int counter = 0;
            for (int x = 1; x <= Math.sqrt(n); x++) {
                for (int y = 1; y <= Math.sqrt(n); y++) {
                    final int tmp = 4 * i - 2 * x * y - 3 * x * x - 3 * y * y;
                    if (tmp <= 0) {
                        break;
                    }

                    final int root = (int) Math.sqrt(tmp);
                    final int z = (-(x + y) + root) / 2;
                    if (z > 0 && x * x + y * y + z * z + x * y + y * z + z * x == i) {
                        counter++;
                    }
                }
            }

            System.out.println(counter);
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}
    

Measured memory_bytes: 36316
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define bit(x,j) ((x>>j)&1)
using namespace std;
// bitset<8>set1(p);
// __builtin_popcountll(x);
// bitset<100> b("1010");
ll int mod=1e9+7;//998244353;
int mul(ll int x, ll int y)
{
    return (x * 1ll * y) % mod;
}

int add(int x, int y)
{
    x += y;
    while(x >= mod) x -= mod;
    while(x < 0) x += mod;
    return x;
}

long long power(long long a, long long b,ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = mul(res,a);
        a = mul(a,a);
        b >>= 1;
    }
    return res%m;
    }


  ll int binomial(ll int n, ll int k) 
{ 
    ll int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll int i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = C[j]+C[j-1]; 
    } 
    return C[k]; 
} 
  vector<int> pr;
  bool prime[10000000];
void Sieve(ll int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            pr.push_back(p);
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}
 


//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}
int sum(int n)  
{  
    if (n == 0)  
    return 0;  
    return (n % 10 + sum(n / 10));  
}  
ll int factorial(ll int n,ll int m) 
{ 
    ll int fact = 1; 
    for(int i=2;i<=n;i++) { 
        fact = (fact * i)%m; 
    } 
    return fact%m; 
} 

int reduce(int x, int y) 
{ 
    int d; 
    d = __gcd(x, y); 
  
    x = x / d; 
    y = y / d; 
    return x; 
} 

int main() {
  ios;
  string s;
  cin>>s;
  int l=0;
  int m=0;
  for(int i=0;i<3;i++)
  {
     if(s[i]=='S')
     {
         m=max(l,m);
         l=0;
     }
     else
     {
         l++;
     }
  }
  m=max(l,m);
  cout<<m<<endl;
}


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

int main() {
    int n;
    cin >> n;
    set<string> s;
    for(int i = 0; i < n; i++){
        string ss;
        cin >> ss;
        s.insert(ss);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 19232
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
N, K = map(int,input().split())
#A = [0]*N
H = sorted(list(map(int,input().split())),reverse=True)	
if len(H)<=K:
    print("0")
else:
    del H[0:K]
    print(sum(H))
    
    





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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

void solve(){
	//code
	int n,count=0;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
		if((i+1)%2==1 && arr[i]%2==1)
			count++;
	}
	cout<<count;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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; }

ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main () {
  ll a, b;
  cin >> a >> b;
  cout << lcm(a,b) << endl;
  return 0;
}

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

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    int count = 0; 
    for(int i=0; i<m; i++){
        cin >> b[i];
    }
    for(int i=0; i<n; i++){
        int sum = 0;
        for(int j=0; j<m; j++){
            int tmp;
            cin >> tmp;
            sum += tmp*b[j];
        }
        if(sum+c > 0){
            count++;
        }
    }

    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <typeinfo>
#include <numeric>
#include "math.h"
#include <cstdlib>
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
using namespace std;


//Forbidden List
//*
int main() {
	int x,n,pp,ppp=1000,sa=1000;
	vector<int> p;
	cin >> x >> n;
	if (n == 0) {
		cout << x;
		return 0;
	}

	for (int i = 0; i < n;i++) {
		cin >> pp;
		p.push_back(pp);
	}	

	for (int i = 101; i > -2;i--) {
		if (find(p.begin(), p.end(), i) != p.end()) {
			continue;
		}
		if (abs(i - x) <= sa) {
			ppp = i;
			sa = abs(i - x);
		}
	}

	cout << ppp;
	
	return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

int odd, mod2, mod4;

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

    REP0(i, N)
    {
        int a;
        cin >> a;
        if (a % 4 == 0)
            mod4++;
        else if (a % 2 == 0)
            mod2++;
        else
            odd++;
    }
    // 奇数が存在すれば mod4 で囲わなければならない
    // そのためには, mod2 が存在しなければ odd-1 以上
    // mod2 が存在すれば, odd 以上
    cout << ((mod4 >= odd - (mod2 == 0)) ? "Yes" : "No") << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long lucas(long long x1, long long x2, int cnt, int n)
{
    if (cnt < n)
        return lucas(x2, x1 + x2, cnt + 1, n);
    return x2;
}

int main()
{
    int n;
    cin >> n;
    if (n == 0) {
        cout << 2;
        return 0;
    }
    if (n == 1) {
        cout << 1;
        return 0;
    }
    cout << lucas(2, 1, 1, n);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
Int dp[2020][2020];
signed main(){
  Int n,m,l;
  cin>>n>>m>>l;
  vector<Int> k(n),s(m);
  for(Int i=0;i<n;i++) cin>>k[i];
  for(Int i=0;i<m;i++) cin>>s[i];
  vector<Int> a(m+1,0);
  for(Int i=0;i<m;i++) a[i+1]=a[i]+s[i];
  memset(dp,-1,sizeof(dp));
  sort(k.begin(),k.end());
  auto calc=[&](Int x,Int y){
    if(k[x]>k[y]) swap(x,y);
    return (a[k[y]]-a[k[x]-1])/l;
  };
  Int inf=1LL<<55LL;
  for(Int i=0;i<2020;i++)
    for(Int j=0;j<2020;j++)
      dp[i][j]=inf;
  
  dp[1][0]=calc(1,0);
  //cout<<dp[1][0]<<endl;
  for(Int i=2;i<n;i++){
    for(Int j=0;j<n;j++){
      dp[i][i-1]=min(dp[i][i-1],dp[i-1][j]+calc(i,j));
      dp[i][j]=min(dp[i][j],dp[i-1][j]+calc(i,i-1));
    }
  }
  Int ans=inf;
  for(Int i=0;i<n;i++) ans=min(ans,dp[n-1][i]+calc(n-1,i));
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n;
    cin >> n;
    vll v(5, 0);
    const string t = "MARCH";
    rep(i, n)
    {
        string s;
        cin >> s;
        rep(j, t.length())
        {
            if (s.front() == t[j])
            {
                ++v[j];
            }
        }
    }

    ll ans = 0;
    rep(i, 5)
    {
        REP(j, i + 1, 5)
        {
            REP(k, j + 1, 5)
            {
                ans += v[i] * v[j] * v[k];
            }
        }
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
 
lli calc(lli a,lli num){
    return a/num;
}
 
int main(){
 
    lli a,b,n;
    cin>>a>>b>>n;
    lli ans = calc(b,n)-calc(max(a-1,0LL),n);
    if(a==0)ans++;
    cout<<ans<<endl;
 
    return 0;
}

Measured memory_bytes: 256
val nodeList = arrayListOf<Long?>(null)

fun main(args: Array<String>) {

    val nodeCount = readLine()!!.toInt()

    val nodeKeys = readLine()!!.split(" ")

    // ヒープに格納
    for (i in 1..nodeCount) {
        nodeList.add(i, nodeKeys[i - 1].toLong())
    }

    buildMaxHeap()

    nodeList.filterNotNull().forEach {
        print(" $it")
    }
    println()
}


fun getLeftIndex(index: Int): Int {
    return index * 2
}

fun getRightIndex(index: Int): Int {
    return index * 2 + 1
}

fun getParentIndex(index: Int): Int {
    return Math.floor(index.toDouble() / 2).toInt()
}

fun getLeftNode(index: Int): Long? {
    return nodeList.getOrNull(getLeftIndex(index))
}

fun getRightNode(index: Int): Long? {
    return nodeList.getOrNull(getRightIndex(index))
}

fun getParentNode(index: Int): Long? {
    return nodeList.getOrNull(getParentIndex(index))
}

fun maxHeapify(i: Int) {
    val myKey = nodeList[i]!!

    val leftIndex = getLeftIndex(i)
    val rightIndex = getRightIndex(i)
    val leftKey = getLeftNode(i) ?: Long.MIN_VALUE
    val rightKey = getRightNode(i) ?: Long.MIN_VALUE

    if (myKey > leftKey && myKey > rightKey) {
        // 終了
        return
    }

    if (leftKey > rightKey) {
        // swapする
        val tempMyValue = nodeList[i]
        nodeList[i] = leftKey
        nodeList[leftIndex] = tempMyValue
        maxHeapify(leftIndex)
    } else {
        // swapする
        val tempMyValue = nodeList[i]
        nodeList[i] = rightKey
        nodeList[rightIndex] = tempMyValue
        maxHeapify(rightIndex)
    }
}


fun buildMaxHeap() {
    val lastIndex = nodeList.filterNotNull().count()

    // 子供を持つ最後のノード番号
    val lastNodeIndexWithChild = getParentIndex(lastIndex)

    // ボトムアップで計算
    for (index in lastNodeIndexWithChild.downTo(1)) {
        maxHeapify(index)
    }
}


Measured memory_bytes: 159956
use std::ascii::AsciiExt;

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

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

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

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

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

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

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

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

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
    "atcoder beginner contest" => "ABC",
    "resident register number" => "RRN",
    "k nearest neighbor" => "KNN",
    "async layered coding" => "ALC",
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        s: [String; 3],
    }

    let mut ans = String::new();

    for word in s.iter() {
        ans.push(word.chars().nth(0).unwrap().to_ascii_uppercase());
    }

    ans
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
#include<regex>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

int main(void) {
	int a, b;
	cin >> a >> b;

	vector<int> ruiseki(1000);
	rep(i, 1000) ruiseki[i] = i * (i + 1) / 2;

	cout << ruiseki[b - a] - b << endl;

	return 0;
}

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

int main() {
    int N, Y;
    cin >> N >> Y;
    int m = Y / 1000;
    int z = m % 5;
    m -= z;
    for (int c = 0; c <= m; c += 5) {
        for (int a = 0; c + a * 10 <= m; a++) {
            int b = (m - (a * 10 + c)) / 5;
            if (b < 0)
                continue;

            if (a + b + c + z == N) {
                cout << a << ' ' << b << ' ' << c + z;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1";
}

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

int main(){
  int count=0,a,b,c,n;
  cin >> a >> b >> c >> n;
  r(i,n){
    r(j,n){
      if((n-i*a-j*b)>=0&&(n-i*a-j*b)%c==0)count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long long a;
    cin >> a;
    if (a < 10) {
        cout << a << endl;
    } else {
        int flag = 0;
        if ((a + 1) % 10 == 0) {
            flag = 1;
        }
        int y;
        int count = 0;
        while (a > 9) {
            a /= 10;
            count++;
        }
        if (flag != 1) { y = a - 1; }
        else {
            y=a;
        }

        cout << 9 * count + y << endl;
    }

    return 0;
}

Measured memory_bytes: 256