akhauriyash/Code-Regression huggingface dataset:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,K = map(int,input().split())

MOD = 10**9 + 7
ans = 0
lis = list(range(0,N+1))

for i in range(K,N+1+1):
    start = (i-1)*i//2
    end = N*i - start
    if end<=start:
        start,end = end,start
    num = end - start +1
    ans += num
ans %= MOD
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 49916
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Integer[] a = new Integer[n];
		Integer[] tmpA = new Integer[n];

		for (int i=0; i<n; i++) {
			a[i] = sc.nextInt();
			tmpA[i] = a[i];
		}

		Arrays.sort(tmpA, Collections.reverseOrder());

		int first = tmpA[0];
		int second = tmpA[1];

		for (int i=0; i<n; i++) {
			if (a[i] == first) {
				System.out.println(second);
			} else {
				System.out.println(first);
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 107184
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut it = s.split_whitespace();
	let n: usize = it.next().unwrap().parse().unwrap();
	let c: usize = it.next().unwrap().parse().unwrap();
	let mut prg = vec![vec![]; c];
	for _ in 0..n {
		let s: i32 = it.next().unwrap().parse().unwrap();
		let t: i32 = it.next().unwrap().parse().unwrap();
		let c: usize = it.next().unwrap().parse().unwrap();
		prg[c - 1].push((s, t));
	}
	let prg = {
		let mut res = vec![vec![]; c];
		for c in 0..c {
			prg[c].sort();
			let prg = &prg[c];
			let mut l = 0;
			while l < prg.len() {
				let mut cur = prg[l];
				let mut r = l + 1;
				while r < prg.len() && cur.1 == prg[r].0 {
					cur.1 = prg[r].1;
					r += 1;
				}
				res[c].push(cur);
				l = r;
			}
		}
		res
	};
	let mut all = vec![0; 100002];
	for prg in prg.iter() {
		for &(l, r) in prg {
			all[l as usize - 1] += 1;
			all[r as usize] -= 1;
		}
	}
	let mut ans = all[0];
	for i in 1..all.len() {
		all[i] += all[i - 1];
		if ans < all[i] {
			ans = all[i];
		}
	}
	println!("{}", ans);
}


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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
  ll a,b,n; cin>>a>>b>>n;
  if(n>=b) cout<<(a*(b-1))/b<<endl;
  else cout<<(a*n)/b-a*(n/b)<<endl;
}

Measured memory_bytes: 3636
#![allow(non_snake_case)]
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n:usize = sc.read();
    let k:i64 = sc.read();
    let mut a:Vec<i64> = sc.vec(n);
    let mut f:Vec<i64> = sc.vec(n);
    a.sort();
    f.sort();

    let mut l: i64 = 0;
    let mut r: i64 = 1000000000001;
    while r - l >= 2{
        let m = (l+r)/2;
        let mut t: i64 = 0;
        for i in 0..n{
            if a[i]*f[n-1-i] <= m{
                continue
            }
            t += (a[i]*f[n-1-i]-m+f[n-1-i]-1)/f[n-1-i];
        }
//        println!("{} {} {} {}", t,l, m,r );
        if t <= k{
            r = m
        }else{
            l = m
        }
    }
    // if l == 0 {
    //     println!("{}", l);
    // }else{
    //     println!("{}", l+1);
    // }
    let mut g:i64 = 0;
    for i in 0..n {
        g += a[i];
    }

    if g <= k{
        println!("0");
    }else{
        println!("{}", r);
    }
    
    
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,n,r;
    cin>>n>>k;
    int a[n];
    for(int i=0; i<n; i++)
        cin>>a[i];
    sort(a, a+n);
    r=a[k-1]-a[0];
    for(int i=1;i<=n-k;i++)
        r=min(r, a[i+k-1]-a[i]);
    cout<<r<<endl;
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if(a>c){
    int tmp;
    tmp = a;
    a = c;
    c = tmp;
    tmp = b;
    b = d;
    d = tmp;
  }
  int ans;
  if(d<b)ans = d-c;
  else ans = max(0, b-c);
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    ll p00=INT_MIN, p11=INT_MIN, p10=INT_MIN, p01=INT_MIN;
    pii arr[n];
    
    rep(i,0,n)
    {
        ll x,y;
        cin>>x>>y;
        arr[i]={x,y};
        p00=max(p00,x+y);
        p11=max(p11,-x-y);
        p01=max(p01,x-y);
        p10=max(p10,-x+y);
    }
    ll ans=0;
    rep(i,0,n)
    {
        int x=arr[i].F,y=arr[i].S;
        ans=max(ans,p00 - x-y);
        ans=max(ans,p11 + x+y);
        ans=max(ans,p01 - x+y);
        ans=max(ans,p10 + x-y);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5152
#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [[0 for j in range(3)] for i in range(100010)]


DP= [[0 for j in range(3)] for i in range(100010)]

N=int(input())

for i in range(N):
    L=list(map(int,input().split()))
    for j in range(len(L)):
        S[i][j]=L[j]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j==k:
                pass
            else:
                if DP[i+1][k]<DP[i][j]+S[i][k]:
                    DP[i+1][k]=DP[i][j]+S[i][k]

ans=0
for j in range(3):
    if ans<DP[N][j]:
        ans=DP[N][j]
print(ans)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    ll s; cin >> s;
    int N = 0;
    ll tmp = s;
    while(tmp!=0){
        tmp /= 10;
        N++;
    }
    ll ans = 0;
    for (int bit = 0; bit < (1 << N-1); ++bit) {
        ll stmp = s;
        ll it = 0;
        rep(i,N-1){
            if (bit & (1 << i)) {
                ll p = pow(10,i+1-it);
                ans += stmp % p;
                stmp /= p;
                it = i+1;
            }
        }
        ans += stmp;
    }
    cout << ans << endl;
}

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

main() {
	int n, a, b;
	cin>>n>>a>>b;
	if((b-a)%2==0){
		cout<<(b-a)/2;
		return 0;
	}
	else{
		int ans1;
		int ans2;
		int cnt=a;
		int pos=b-a;
		ans1=cnt+((b-a-1)/2);
		cnt=n-b+1;
		pos=a+cnt;
		ans2=cnt+((n-pos)/2);
	
		cout<<min(ans1, ans2);
	}
	return 0;
}

Measured memory_bytes: 3532
#include <stdio.h>
#include <stdlib.h>

int main()
{
    float n, sum=0;
    int i;
    scanf("%f", &n);
    float a[10000];
    for(i=0; i<n; i++){
		scanf("%f", &a[i]);
		a[i]=1/a[i];
    }

    for(i=0; i<n; i++){
		sum+=a[i];
    }

	printf("%f", 1/sum);

    return 0;
}


Measured memory_bytes: 128
let () = Scanf.scanf "%d %d\n" @@ fun h w ->
  let ass = Array.init h @@ fun _ ->
    Scanf.scanf "%s\n" @@ fun as_ -> as_ in
  print_endline (String.make (w + 2) '#');
  Array.iter (Printf.printf "#%s#\n") ass;
  print_endline (String.make (w + 2) '#')

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


void solve(long long N, std::string S){
    long long r = 0, g = 0, b = 0;
    for(auto c: S){
        if(c == 'R') r++;
        else if(c == 'G') g++;
        else b++;
    }

    long long ans = r * g * b;
    long long sub = 0;

    for(long long i = 0;i < N-1; i++){
        for(long long j = i;j < N; j++){
            if (S[i] == S[j]) continue;
            long long k = 2 * j - i;
            if (k >= N || S[j] == S[k] || S[i] == S[k]) continue;
            sub ++; 
        };
    };

    cout << ans - sub << endl;
}

// 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);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


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

/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
 
 
ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/
int main(){
    int N;
    cin>>N;
    vector<int> A(N-1);
    for(int i=0;i<N-1;i++){
        cin>>A.at(i);
    }
    map<int,int> mp;
    for(int i=0;i<N-1;i++){
        mp[A.at(i)]++;
    }
    for(int i=1;i<=N;i++){
        cout<<mp[i]<<endl;
    }
}

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

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

    cout << ((a < b) ? string(b, '0' + a) : string(a, '0' + b)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int N;
  char s1[60],s2[60];
  cin >> N;
  if(N%2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  int i;
  for(i=0;i<N/2;i++)cin >> s1[i];
  for(i=0;i<N/2;i++)cin >> s2[i];
  for(i=0;i<N/2;i++) {
    if(s1[i] != s2[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
X,Y,Z,K = list(map(int,input().split()))
A = [(sorted(list(map(int,input().split())))[::-1]) for i in range(3)]
b = sorted([i+j for i in A[0] for j in A[1]])[-K:]
for i in sorted([i+j for i in b for j in A[2]])[-K:][::-1] :
  print(i)

Measured memory_bytes: 186032
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define MAXN 200005
#define INT_SIZE 32
#define debug cout<<"we are debugging"<<endl;
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
const ll MAX = 2000000;
ll fac[MAX], finv[MAX], inv[MAX];
void cmbinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i=2;i<MAX;i++) {
		fac[i] = fac[i-1]*i%MOD;
		inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
		finv[i] = finv[i-1]*inv[i]%MOD;
	}
}
ll cmb(ll n, ll k) {
	if(n<k) return 0;
	if(n<0 || k<0) return 0;
	return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
int main()
{
     fast;
     cmbinit();
    ll n;
    cin>>n;
    ll ans=fast_expo(10,n);
    ans%=MOD;
    ll val=0,ans1;
    for(ll i=1;i<=n;i++)
    {
         ans1=((cmb(n,i))%MOD*(fast_expo(8,n-i))%MOD)%MOD;
         val=val+ans1;
         val%=MOD;
    }
    val=(val*2)%MOD;
    ll ans3=fast_expo(8,n)%MOD;
    val=(val+ans3)%MOD;
    cout<<(ans-val+MOD)%MOD;
}


Measured memory_bytes: 50516
/*ITP1_6_B:Finding Missing Cards*/
#include <iostream>
using namespace std;


int main() 
{
  int n,x;
  char ch; 
  int cards[4][13] = {0}; // bool でもよい
  char pattern[4] = { 'S', 'H', 'C', 'D' };
  cin >> n;

  for(int i=1; i<=n; i++)
  {
    cin >> ch >> x; // cin は空白改行を読み飛ばします
    if(ch=='S')
      cards[0][x-1] = 1;
    else if(ch=='H')
      cards[1][x-1] = 1;
    else if(ch=='C')
      cards[2][x-1] = 1;
    else if(ch=='D')
      cards[3][x-1] = 1;
  }

  for(int i=0; i<4; i++)
  {
    for(int j=0; j<13; j++)
    {   
      if( cards[i][j] == 0 ) 
        cout << pattern[i] << " " << j+1 << endl;
    }   
  }
  return 0;
}



Measured memory_bytes: 3092
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 20
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int N;
int A[MAX_N];
int x[MAX_N][MAX_N], y[MAX_N][MAX_N];

int par[MAX_N];
int rnk[MAX_N];
const int LIEAR = -1;

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

int find(int x) {
  if (par[x] == LIEAR) return LIEAR;
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

// おかしいとき false
bool unite(int x, int y) {
  x = find(x), y = find(y);
  // x は正直者のはずなのに、LIEAR なのはおかしい
  if (x == LIEAR) return false;
  // x は正直者のはずなのに、LIEAR と統合するのはおかしい
  if (y == LIEAR) return false;
  if (x == y) return true;

  if (rnk[x] < rnk[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
  return true;
}

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

int count(int n) {
  int cnt = 0;
  map<int, int> mp;
  REP(i, n) if (par[i] != LIEAR) mp[par[i]]++;
  for (auto m : mp) {
    cnt = max(cnt, m.second);
  }
  return cnt;
}

bool setAttr(int n, int val) {
  // n でもなく、 val でもないときはすでに設定をしているのに違う値
  if (par[n] != n && par[n] != val) {
    return false;
  }
  par[n] = val;
  return true;
}

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

  cin >> N;
  REP(i, N) {
    cin >> A[i];
    REP(j, A[i]) {
      int xx;
      cin >> xx >> y[i][j];
      x[i][j] = xx - 1;
    }
  }

  int ans = 0;
  for (int i = 0; i < (1 << N); i++) {
    // 0000000000 1 の人が正直者であり、それ以外の人は不親切
    // cout << i << endl;
    bool isAntinomy = false;
    int n = i, cnt = 0, truman = 0;
    init(N);
    while (n > 0) {
      if (n & 1) {
        truman++;
        REP(j, A[cnt]) {
          // 正直ものの仮定と違ってたら break する
          if (y[cnt][j] != ((i >> (x[cnt][j])) & 1)) {
            isAntinomy = true;
            break;
          }
          // 正直者なら同じグループにする
          if (y[cnt][j]) isAntinomy = !unite(cnt, x[cnt][j]);
          // 不明なら不明と印をつける
          else
            isAntinomy = !setAttr(x[cnt][j], LIEAR);
          if (isAntinomy) break;
        }
      }
      if (isAntinomy) {
        truman = 0;
        break;
      }
      cnt++;
      n >>= 1;
    }
    // int sum = count(N);
    // cout << "矛盾: " << isAntinomy << "正: " << truman << endl;
    // REP(k, N) cout << par[k] << " ";
    // cout << endl;
    // cout << "(" << sum << ")" << endl;
    if (!isAntinomy) ans = max(ans, truman);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n,m=list(map(int,input().split()))
g=[[] for _ in range(n+1)]
visited=[0]*(n+1)
x=[0]*(n+1)

for _ in range(m):
    l,r,d=list(map(int,input().split()))

    g[r].append((l,d))
    g[l].append((r,-d))

stack=list(range(1,n+1))

while len(stack)>0:
    u=stack.pop()

    visited[u]=1

    for v,d in g[u]:
        if visited[v]==1:
            continue

        x[v]=x[u]-d

        stack.append(v)

flag=True

for i in range(1,n+1):
    for j,d in g[i]:
        if x[i]-x[j]!=d:
            flag=False

if flag:
    print('Yes')
else:
    print('No')

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

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

const int MAX = 5E5 + 100;
int BLOCK;
int n, q;
int c[MAX], res[MAX];

struct Query {
	int l, r;
	int pos;

	Query(int _l, int _r, int _pos) : l(_l), r(_r), pos(_pos) {}
	bool operator < (const Query& query) const {
		if(l/BLOCK == query.l/BLOCK)
			return r < query.r;
		return l/BLOCK < query.l/BLOCK;
	}
};

vector<Query> Q;

int main() {
	fast();
	
	cin >> n >> q;
	BLOCK = sqrt(n);
	for(int i = 0; i < n; i++)
		cin >> c[i];
	for(int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		--l, --r;
		Q.push_back(Query(l, r, i));
	}

	sort(Q.begin(), Q.end());

	int pl = 0, pr = -1;
	int cur = 0;
	vector<int> cnt(MAX);
	for(Query query : Q) {
		int l = query.l, r = query.r, pos = query.pos;
		while(pr < r) {
			pr++;
			if(++cnt[c[pr]] == 1)
				cur++;
		}

		while(pl > l) {
			pl--;
			if(++cnt[c[pl]] == 1)
				cur++;
		}

		while(pl < l) {
			if(--cnt[c[pl]] == 0)
				cur--;
			pl++;
		}

		while(pr > r) {
			if(--cnt[c[pr]] == 0)
				cur--;
			pr--;
		}

		res[pos] = cur;
	}

	for(int i = 0; i < q; i++)
		cout << res[i] << '\n';
}


Measured memory_bytes: 15508
import java.util.*;

public class Main {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  String s1 = sc.next();
  String s2 = sc.next();
  String s3 = "";
  int len = s1.length() < s2.length() ? s1.length() : s2.length();
  for(int i = 0; i < s1.length() + s2.length(); i++) {
    if(i < len * 2) {
        if(i==0){
            s3 += s1.substring(0,1);
        } else if (i == 1){
            s3 += s2.substring(0,1);
        }
        else if(i % 2 == 0)  {
            s3 += s1.substring(i /2, i /2 +1);
        } else {
            s3 += s2.substring(i / 2, i /2 + 1);
        }
    } else {
    	if(s1.length() < s2.length()) {
    		s3 += s2.substring(len);
    	} else {
    		s3 += s1.substring(len);
    	}
    }

  }
  System.out.println(s3);
 }
}

Measured memory_bytes: 21716
def nm(n, m, k):
    for i in range(n+1):
        for j in range(m+1):
            black = (n - i) * j + (m - j) * i
            if black == k:
                return "Yes"
    return "No"


if __name__ == "__main__":
    n, m, k = map(int, input().split())
    ans = nm(n, m, k)
    print(ans)


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

using namespace std;

int main(){
    long long n, ans = 0;
    cin >> n;
    vector<long long> v(n);
    for (auto & a: v){
        cin >> a;
        ans ^= a;
    }
    for (int i = 0; i < n; ++i){
        cout << (v[i]^ans);
        if (i == n - 1) cout << '\n';
        else cout << ' ';
    }
    return 0;
}

Measured memory_bytes: 4820
n,k,q=map(int,input().split())
d=[]
p=[]
for i in range(n):
   p.append(k-q)
for i in range(q):
   d.append(int(input()))
   p[d[i]-1] +=1
for i in range(n):
   if p[i]>0:
      print("Yes")
   else:
      print("No")

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

#define rev(v) reverse(v.begin(), v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end()); 
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));

//ffs = lsb, clz = l0's, ctz = r0's, popcount = 1's 
 //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
 //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
    fastio();
    ld W,H,x,y; cin >> W >> H >> x >> y;
    ld ans = H * W / 2;
    int cnt = 0;
    if(x == W / 2 && y == H / 2){
        cnt = 1;
    }
    if((x > W || y > H ) || (x < 0 || y < 0)){
        ans = H - H;
        cnt = 0;
    }

    //2 5 2 4 --> 5
    cout << ans << " " << cnt << '\n';
    //cout << " " << cnt;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
using namespace std;
int main(void) {
  int n, k;
  cin >> n >> k;
  if (n % k)
    cout << 1;
  else
    cout << 0;
  cout << endl;

  return 0;
}


Measured memory_bytes: 888
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val l = scanner.nextInt()
    var sum = 0
    var sub = 0
    var check = false
    for(i in 1..n) {
        if(l+i-1 === 0) check = true
        sum += (l+i-1)
    }
    if(l+n-1 < 0) sub = l+n-1
    else sub = l
    if(check) println(sum)
    else println(sum-sub)
}

Measured memory_bytes: 31392
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N; ll A[int(1e5 + 5)];
ll cnt = 0, head = 1, ans = 1;

int Prepare(){
  for (int i = 0; i < N; i++){
    ll now = 0;
    ans *= A[i];
    while (A[i] > 0){
      if (A[i] <= 9){
        head *= A[i];
      }
      A[i] /= 10;
      now++;
    }
    cnt += now - 1;

    if (head >= 10){
      head /= 10; cnt++;
    }
    if (cnt > 18){
      cout << -1 << endl;
      return 0;
    }
  }

  if (cnt == 18 && head > 1){
    cout << -1 << endl;
    return 0;
  }

  if (ans <= (ll)1e18) cout << ans << endl;
  else cout << -1 << endl;

  return 0;
}


int main(){
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  Prepare();


  return 0;
}


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

int main(){
	int N, K, r, l, is_necessary, m, a;
	cin >> N >> K;
	int A[N];
	for (int i = 0; i < N; ++i){
		cin >> A[i];
	}
	sort(A, A+N);
	l = -1;
	r = N;
	while(r - l > 1){
		m = (r+l)/2;
		is_necessary = 0;
		if(A[m] >= K){
			is_necessary = 1;
		}else{
			int dp[N][K];
			for (int i = 0; i < N; ++i){
				for (int j = 0; j < K; ++j){
					if (j == 0){
						dp[i][j] = 1;
					}else{
						dp[i][j] = 0;
					}
				}
			}

			for (int i = 0; i < N; ++i){
				if(i == 0){
					if(m != 0 && A[0] < K){
						dp[0][A[0]] = 1;
					}
				}else if(i == m){
					for (int j = 0; j < K; ++j){
						dp[i][j] = dp[i-1][j];
					}
				}else if(A[i] >= K){
					break;
				}else{
					a = A[i];
					for (int j = 0; j < K; ++j){
						if(dp[i-1][j] == 1 && j + a < K){
							dp[i][j+a] = 1;
							if(j + a >= K - A[m]){
								is_necessary = 1;
							}
						}
						if(dp[i][j] == 0){
							dp[i][j] = dp[i-1][j];
						}
					}
				}
			}
		}
		if(is_necessary){
			r = m;
		}else{
			l = m;
		}
	}
	cout << l+1 << endl;
	return 0;
}

Measured memory_bytes: 97920
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int max = 0;
        for (int i=1;i<N;i++){
            String str1 = S.substring(0,i);
            String str2 = S.substring(i);
            int count = 0;
            boolean[] ar1 = new boolean[26];
            boolean[] ar2 = new boolean[26];
          
            for (int j=0;j<str1.length();j++){
                ar1[str1.charAt(j)-'a']=true;
            }
            for (int j=0;j<str2.length();j++){
                ar2[str2.charAt(j)-'a']=true;
            }
            for (int j=0;j<26;j++){
                if (ar1[j]&&ar2[j]){
                  count++;
                }
            }
            max = Math.max(max,count);
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 35728
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    int n;
    cin >> n;
    ll a[n];
    REP(i, n)
    {
    	cin >> a[i];
    }

    ll ans;
    // sum[i] : s[0] ~ s[i] までの和
    ll sum[n];
    bool plusSumFlg;
    ll opCount[2];

    // 偶数番目を正にするか、奇数番目を正にするかの2通りを試す
    // 最小の操作回数になる方が解答
    REP(count, 2)
    {
	    // 初期化
	    opCount[count] = 0;
	    REP(i, n) sum[i] = 0;
	    if (count == 0) plusSumFlg = false;
	    else plusSumFlg = true;

	    for (int i = 0; i < n; ++i) {
	    	if (i == 0) sum[i] = a[i];
	    	else sum[i] = sum[i - 1] + a[i];

	    	if (plusSumFlg)
	    	{
	    		// sum[i] は負にしないといけない
	    		plusSumFlg = false;
	    		if (sum[i] >= 0)
	    		{
	    			opCount[count] += 1 + sum[i];
	    			sum[i] = -1;
	    		}
	    	}
	    	else
	    	{
	    		// sum[i] は正にしないといけない
	    		plusSumFlg = true;
	    		if (sum[i] <= 0)
	    		{
	    			opCount[count] += 1 - sum[i];
	    			sum[i] = 1;
	    		}
	    	}
	    }
	}

	ans = min(opCount[0], opCount[1]);

    cout << ans << endl;
}


Measured memory_bytes: 1792
n =  int(input())
ls = list(map(int, input().split()))
sorted_ls = ls.copy()
sorted_ls.sort()
f = sorted_ls[int(n/2)]
b = sorted_ls[int(n/2)-1]

for i in ls:
    if i < f:
        print(f)
    else:
        print(b)
    

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

    public static long Combination(long n, long r){
        long A = 1;
        long B = 1;
        for(long i = 0; i < r; i++){
            A = A*(n-i);
            B = B*(r-i);
        }
        if(A == 0) return 0;
        return A/B;
    }

    public static long solve(int i, int j, boolean check, int N, String S){
        if(i == N){
            if(j == 0){
                return 1;
            }else{
                return 0;
            }
        }

        if(j == 0) return 1;

        if(check){
            return Combination(N-i, j)*(long)Math.pow(9, j);
        }else{
            if(S.charAt(i) == '0') return solve(i+1, j, false, N, S);
            long Z = solve(i+1, j, true, N, S);
            long A = solve(i+1, j-1, true, N, S)*(S.charAt(i)-'1');
            long P = solve(i+1, j-1, false, N, S);
            return Z+A+P;
        }


    }
 
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int K = s.nextInt();
        List<Integer> list = new ArrayList<Integer>();
        for(int i = 0; i < N; i++){
            list.add(s.nextInt());
        }
        Collections.sort(list);
        
        long min = 0;
        for(int i = 0; i < N - K; i++){
            min = min + list.get(i);
        }

        System.out.println(min);
	}
} 

Measured memory_bytes: 94860
//
//  main.cpp
//  201910
//
//  Created by Hajime Sakamoto on 2019/10/09.
//  Copyright © 2019 Hajime Sakamoto. All rights reserved.
//

#include <iostream>
#include <stdio.h>

using namespace std;

int A, B, C;

int count_five=0;
int count_seven=0;


void count (int a){
    if (a==5){
        count_five++;
    }
    else if (a==7){
        count_seven++;
    }
}


int main(int argc, const char * argv[]) {
    cin >> A;
    cin >> B;
    cin >> C;
    
    count(A);
    count(B);
    count(C);
    
    if (count_five==2 && count_seven==1){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
    return 0;
}


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

int main(){
    int sum = 0;
    vector<int> diff;
    for(int i = 0; i < 5; i++)
    {
        int x;
        cin >> x;
        int y = x;
        while(true){
            if (x % 10 == 0) {
                break;
            }
            x++;
        }
        sum += x;
        diff.push_back(x - y);
    }
    sort(diff.begin(), diff.end());
    cout << sum - diff[4] << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) (((a%MOD+MOD)%MOD+(b%MOD+MOD)%MOD)%MOD)
#define SUB(a, b) (((a%MOD+MOD)%MOD-(b%MOD+MOD)%MOD+MOD)%MOD)
#define MUL(a, b) ((((a%MOD+MOD)%MOD)*((b%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) (x/gcd(x,y)*y)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }
template<typename I> int ACC(I f, I l, int i = 0){ return accumulate(f, l, i); }


int N, K;
int A[200010];
int F[200010];


bool judge(int x, int k = K){
    rep(i, 0, N) if(x < A[i]*F[i]) k -= (A[i]-x/F[i]);
    return k >= 0;
}


signed main(){
    cin >> N >> K;
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) cin >> F[i];

    sort(RNG(A, 0, N));
    sort(RNG(F, 0, N), greater<int>());

    int l = -1, u = 1e13;
    while(abs(u-l) > 1){
        int mid = (u+l)/2;
        if(judge(mid)) u = mid;
        else l = mid;
    }

    cout << u << endl;

    return 0;
}

Measured memory_bytes: 3328
import numpy as np

h, w, k = map(int, input().split())

area = np.zeros([h, w], dtype=int)

for i in range(h):
    s = input()
    for j in range(w):
        if s[j] == "#":
            area[i, j] = 1


ans = 0

for i in range(2**(h+w)):
    area_ = area.copy()

    for j in range(h+w):
        if ((i >> j) & 1):
            if j < h:
                area_[j, :] = 0
            else:
                area_[:, j-h] = 0
    
    if np.sum(area_) == k:
        ans += 1
print(ans)


Measured memory_bytes: 27240
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string w="";
	cin>>w;
	if(w=="Sunny")
	cout << "Cloudy"<< endl;
	if(w=="Cloudy")
	cout << "Rainy"<< endl;
	if(w=="Rainy")
	cout << "Sunny"<< endl;
	
 } 

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001

struct team {
    int id;
    int correct = 0;
    int wrong[10] = {};
    int penalty = 0;
};

bool operator<(const team &a, const team &b) {
    if (a.correct != b.correct) return a.correct > b.correct;
    if (a.penalty != b.penalty) return a.penalty < b.penalty;
    return a.id < b.id;
}


int main(){
    cin.sync_with_stdio(false);
    int t, p, r;
    while(cin >> t >> p >> r, t) {
        team tm[t];
        rep(i, t) tm[i].id = i + 1;
        rep(i, r) {
            int tid, pid, time;
            string msg;
            cin >> tid >> pid >> time >> msg;
            if (msg == "WRONG") tm[tid - 1].wrong[pid - 1]++;
            else {
                tm[tid - 1].correct++;
                tm[tid - 1].penalty += time + 1200 * tm[tid - 1].wrong[pid - 1];
            }
        }
        sort(tm, tm + t);
        rep(i, t) cout << tm[i].id << " " << tm[i].correct << " " << tm[i].penalty << endl;
    }

    return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;

int main()
{
	ll N, M;
	cin >> N >> M;
	vector<pair<ll, ll>> ab(N);
	for (auto& i : ab) {
		cin >> i.first >> i.second;
	}

	sort(ab.begin(), ab.end(), [](const pair<ll, ll>& i, const pair<ll, ll>& j) {
		return i.first < j.first;
	});

	ll ret = 0;
	for (auto& i : ab) {
		if (0 <= M - i.second) {
			ret += i.first * i.second;
			M -= i.second;
		}
		else {
			ret += i.first * M;
			break;
		}
	}

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

vector<long long> divisor(long long n) {
  vector<long long> d;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      d.push_back(i);
      if(i != n / i) d.push_back(n / i);
    }
  }
  sort(d.begin(), d.end());
  return d;
}

map<ll,int>mp;

int main(){
  ll n;
  cin>>n;
  vector<ll>d=divisor(n);
  int ans=0;
  for(auto x:d){
    if(x==1)continue;
    ll m=n;
    while(m%x==0)m/=x;
    if(m%x==1){
      mp[x]++;
    }
  }
  n--;
  vector<ll>e=divisor(n);
  for(auto x:e){
    if(x==1)continue;
    mp[x]++;
  }
  cout<<mp.size()<<endl;
  return(0);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int n; cin >>n;
  vector<ll> a(n); rep(i, n) cin >>a[i];
  ll res1 = 0;
  ll res2 = 0;
  ll sum = 0;
  // 和が正負正負… か 負正負正… になるかで場合分け
  for (int i=0; i<n; i++){
    sum += a[i];
    // iが偶数なら和が正になるようにする
    if (i%2==0) if (sum <= 0){ res1 += 1 - sum; sum = 1; }
    // i が奇数なら和が負になるようにする
    if (i%2==1) if (sum >= 0){ res1 += sum - (-1); sum = -1; }
  }
  sum = 0;
  for (int i=0; i<n; i++){
    sum += a[i];
    if (i%2==0) if (sum >= 0){ res2 += sum - (-1); sum = -1; }
    if (i%2==1) if (sum <= 0){ res2 += 1 - sum; sum = 1; }
  }
  ll res = min(res1, res2);
  cout <<res <<endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
	long long n, k, ans = 0;
	cin >> n >> k;
	if (k == 0) {
		cout << n*n << endl;
		return 0;
	} else {
		for (int b = k + 1; b <= n; b++) {
			ans += (n / b) * (max((long long)0, (b - k)));
			ans += max((long long)0, ((n % b) - k + 1));
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//🅰🅸🅸🆂🅼🅴
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <numeric>
#include <stdlib.h>

using namespace std;

typedef long long ll;

const int AI1 = 10005;
const int AIMAX = 1e6 + 1;

int main()
{
    string s; cin >> s;
    if (s.length() < 4)
    {
        cout << "No" << endl;
    }
    else if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int max(int x, int y);
int min(int x, int y);

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

	int d;
	d = b / a;

	cout << min(c, d);

	return 0;
}

int max(int x, int y)
{
	int max;

	if (x < y)
		max = y;
	else
		max = x;

	return max;
}

int min(int x, int y)
{
	int min;

	if (x < y)
		min = x;
	else
		min = y;

	return min;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 100000
#define LEN 100000

typedef struct pro{
  char name[100];
  int t;
} P;

P Q[LEN+1];
int head, tail, n;

void initialize(){
  head = tail = 0;
}

int isEmpty(){
  if(head == tail) return 0;
  else return 1;
}

int isFull(){
  if(head == ((tail + 1) % MAX)) return 0;
  else return 1;
}

void enqueue(P x){
  if(isFull() == 0 ){
    fprintf(stderr,"エラー（オーバーフロー）\n");
    exit(8);
  }
  Q[tail] = x;
  if(tail+1 == MAX) tail = 0;
  else tail++;
}

P dequeue(){
  P x;
  if(isEmpty() == 0 ){
    fprintf(stderr,"エラー（アンダーフロー）\n");
    exit(8);
  }
  else{
    x = Q[head];
    if(head + 1 == MAX) head = 0;
    else head++;
    return x;
  }
}

int main(){
  int elaps = 0, c;
  int i,j,q,result;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n + 1;

  for(i = 0 ; head != tail ;i++){
    u = dequeue();
    if(q < u.t) c = q;
    else c = u.t;
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else printf("%s %d\n",u.name,elaps);
  }

  return 0;
}



Measured memory_bytes: 11852
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

N = ri()
T = rli()
sm = sum(T)
M = ri()
for i in range(M):
    p, x = rli()
    print(sm - T[p-1] + x)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int mod = 1000000007;
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
        sum %= mod;
    }
 
    long ans = 0;
 

    for (int i = 0; i < N; i++)
    {
        //Update the values of A[i+1] ... A[N]
        sum -= A[i];
        if (sum < 0) sum += mod;
 
        ans += A[i] * sum;
        ans %= mod;
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double PI = 3.14159265358979323846;

int main(void) {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end(), greater<ll>());
  ll ans = 0;
  if (n >= 2) ans += a[0];
  n -= 2;
  int ind = 1;
  while (n > 1) {
    ans += a[ind] * 2;
    n -= 2;
    ind++;
  }
  if (n == 1) ans += a[ind];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4832
#include<stdio.h>
#define M 300000
int main(){
  int n,i,j;
  char p[M]={1,1};
  for(i=6;i*i<M;i+=5){
    if(p[i]==0){
      for(j=i*i;j<M;j+=i)p[j]=1;
    }
    i+=2;
    if(p[i])continue;
    for(j=i*i;j<M;j+=i)p[j]=1;
  }
  while(scanf("%d",&n),n-1){
    printf("%d:",n);
    for(i=6;i<=n;i+=7){
      if(p[i  ]==0&&n% i   ==0)printf(" %d",i  );
      if(p[i+2]==0&&n%(i+2)==0)printf(" %d",i+2);
    }
    printf("\n");
  }
  return 0;
}
  
     

Measured memory_bytes: 900
using System;

namespace beginner754
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Trim().ToCharArray();
            int m = int.MaxValue;
            for(int i = 0;i<l.Length - 2;i++)
            {
                var x = Math.Abs(int.Parse(new string(l, i, 3)) - 753);
                if(m > x)
                {
                    m = x;
                }
            }
            Console.WriteLine("{0}", m);
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<string.h>

int main(void){

int i, len;
char s[4096];  
while(scanf("%s", s) != EOF){
     if(s[0] == '0'){
      break;
      } 
    int ans = 0;
    len = strlen(s);
    for(i = 0; i < len; i++) {
       ans += s[i]-'0';
    }
  
printf("%d\n",ans);
}
return 0;
}


Measured memory_bytes: 2048
import sys

def bubble_sort(size, numbers):
    swap_count = 0

    for i in range(size):
        sorted = True
        for j in range(size - 1, i, -1):
            if numbers[j] < numbers[j - 1]:
                sorted = False
                swap_count += 1
                numbers[j], numbers[j - 1] = numbers[j - 1], numbers[j]
        if sorted:
            break

    return swap_count

def main(stdin=None, stdout=None):
    if stdin is None:
        stdin = sys.stdin
    if stdout is None:
        stdout = sys.stdout

    size = int(stdin.readline().strip())
    numbers = [int(x) for x in stdin.readline().strip().split(" ")]

    swap_count = bubble_sort(size, numbers)
    stdout.write(" ".join([str(x) for x in numbers]) + "\n")
    stdout.write(str(swap_count) + "\n")

main()


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

int main(void) {
    int H,W;
    cin>>H>>W;
    for (int i = 1; i <= W + 2; i++) cout << "#";
    cout << endl;
    for (int i = 1; i <= H; i++) {
        string a;
        cin >> a;
        cout << "#" << a << "#" << endl;
    }
    for (int i = 1; i <= W + 2; i++) cout << "#";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end
n = gets_i

def calc(x, y, z)
  x**2 + y**2 + z**2 + x * y + y * z + z * x
end

x, y, z = 1,1,1

ans = []

x.upto(100) do |xi|
  y.upto(100) do |yi|
    z.upto(100) do |zi|
      ans.push(calc(xi, yi, zi))
    end
  end
end
ans.sort

ha = ans.sort.group_by(&:itself).map{|k,v| [k, v.count] }.to_h

1.upto(n) do |i|
  if ha[i]
    puts ha[i]
  else
    puts 0
  end
end

Measured memory_bytes: 58844
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b,c;
    cin>>a>>b>>c;
    if(a>=b&&a>=c)
        cout<<c*b/2<<endl;
    else if(c>=b&&c>=a)
    cout<<a*b/2<<endl;
    else if(b>=a&&b>=c)
    cout<<a*c/2<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256