akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>

#define fir first
#define sec second
#define pb push_back
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define prfi(n) printf("%d", &n);
#define prfd(n) printf("%lf", &n);
#define All(s) (s).begin(), (s).end()
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define repk(i, j, k) for(int (i)=(j);(i)<(k);(i)++)
#define repdown(i, j, k) for(int (i)=(j);(i)>=(j);(i)--)
#define dump(x)  std::cout << #x << " = " << (x) << std::endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using ll = long long;
using vi = std::vector<int> ;
using vvi = std::vector<vi> ;
using vd = std::vector<double> ;
using vvd = std::vector<vd> ;
using qi = std::queue<int> ;
using namespace std;

const int Mod = 1e9 + 7;
const int max_n = 3 * 1e5 + 1;
const int max_m = 83 * 1e5 + 1;
const ll INF = 10241024;
long double INFD = 100100100;

//_________template______________
inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

//_____________________array calc____________________________________//
/*
vvi mul(vvi &A, vvi &B){
  vvi C(A.size(), vi(B.size()))
  rep(i,A.size()){
    rep(j,B.size()){
      rep(k,B[0].size()){
        C[i][j] = (C[i][j] A[i][k] + B[k][j]) % Mod;
      }
    }
  }

  return C;
}

vvi pow(vvi A, ll n){
  vvi B(A.size(), vi(A.size()));
  rep(i=0;i<A.size();i++){
    B[i][i] = 1;
  }

  while (n >0){
    if (n & 1) B = mul(B, A);
    A = mul(A, A);
    n = n >> 1;
  }
  return B;
}
*/
//_____________________Bynary Indexed Tree __________________________//
/*
const max_st = (1 << 15) - 1;
int bit[max_st];
int sum (int i){
  int s = 0;
  while(i > 0){
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

void add(int i, int x){
  while(i <= n){
    bit[i] += x;
    i += i & -i;
  }
}
*/
//_____________________　following sorce code_________________________//
int n,m;

void input(){
  IN(n,m);
}

void solve(){
  input();
  vvi vec(m+1);
  rep(i,n){
    int a, b;IN(a,b);
    if( a > m) continue;
    vec[m-a].pb(b);
  }
  priority_queue<int> q;
  ll ans = 0;
  for(int i=m-1;i>=0;i--){
    for(int b : vec[i]){
      q.push(b);
    }
    if(!q.empty()){
      ans += q.top();
      q.pop();
    }
  }
  OUT(ans);
}

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





Measured memory_bytes: 5632
fun main (args : Array<String>) {
	val str1 = readLine()
	val str2 : String = str1.toString()
	var result : String = ""
	for (i in str2) {
		if (i.toString() == "A") {
			result += "T"
		} else if (i.toString() == "T") {
			result += "A"
		} else if (i.toString() == "C") {
			result += "G"
		} else if (i.toString() == "G") {
			result += "C"
		}
	}
	println("${result}")
}

Measured memory_bytes: 31760
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;

int main()
{
    int H, W;
    cin >> H >> W;
    char tmp[H][W];
    
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> tmp[i][j];
        }
    }
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cout << tmp[i][j];
        }
        cout << endl;
        for(int j=0; j<W; j++){
            cout << tmp[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if( op == '?')break;
        else if( op == '+')
            printf("%d\n",a+b);
        
        else if(op=='-')
            printf("%d\n",a-b);
        
        else if(op=='*')
            printf("%d\n",a*b);
        
        else if(op=='/')
            printf("%d\n",a/b);
    }
    return 0;
}


Measured memory_bytes: 2112
import java.util.*;
import java.math.*;
class Main {
    //
    static final int MOD = 1_000_000_007; // 10^9+7
    //static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s;
        int[] ary;
        int a = sc.nextInt();
        int b = sc.nextInt();
        for(int i = 0;i < 100000;i++){
            if(i*8/100==a&&i/10==b){
                System.out.println(i);
                return;
            }
        }
        System.out.println(-1);
    }
}



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

int n;

int main()
{
    cin >> n;
    map<pair<char, int>, int> mp;
    for (int i = 0; i < n; i++)
    {
        char a;
        int b;
        cin >> a >> b;
        pair<char, int> c = make_pair(a, b);
        mp[c]++;
    }
    char p[4] = {'S', 'H', 'C', 'D'};
    for (int i = 0; i < 4; i++)
    {
        for (int j = 1; j <= 13; j++)
        {
            pair<char, int> c = make_pair(p[i], j);
            if (mp[c] == 0)
                printf("%c %d\n", p[i], j);
        }
    }
}


Measured memory_bytes: 3140
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

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

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

const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;

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

using MIte = multimap<ll, ll, greater<ll> >::iterator;

//1652
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	// long long?
	int A,B,C,D,E,F;
	cin >> A >> B >> C >> D >> E >> F;

	set<int> water;
	for (int i = 0; i != 30; ++i) {
		for (int j = 0; j != 30; ++j) {
			int wa = 100 * A * i + 100 * B * j;
			if (wa <= F) {
				water.insert(wa);
			}
		}
	}

	set<int> suger;
	for (int i = 0; i != 3000; ++i) {
		for (int j = 0; j != 3000; ++j) {
			int su = C * i + D * j;
			if (su <= F) {
				suger.insert(su);
			}
		}
	}

	vector<int> vsuger(suger.begin(), suger.end());
	double density = -1.0;
	int ans_wa = 0;
	int ans_su = 0;
	for (set<int>::iterator it = water.begin(); it != water.end(); ++it) {
		int wa = *it;
		int maxsu = min(wa / 100 * E, F - wa);
		auto it_upper = upper_bound(vsuger.begin(), vsuger.end(), maxsu);
		int idx = distance(vsuger.begin(), it_upper) - 1;
		int su = vsuger[idx];
		if (wa + su != 0) {
			double tmp_dens = (double)su / (double)(wa + su);
			if (density < tmp_dens) {
				density = tmp_dens;
				ans_wa = wa;
				ans_su = su;
			}
		}
	}

	cout << ans_wa + ans_su << " " << ans_su << endl;

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
class kuohao{
    public:
    int must_have=0;
    int this_num=0;
    int countl=0;
    bool operator<(const kuohao& a){
        if(this->must_have>0&&a.must_have>0){
            if(this->this_num<0&&a.this_num<0){
                return this->countl>a.countl;
            }
            return this->this_num>a.this_num;
        }
        return (this->must_have)<(a.must_have);
    }
};
int main(){
    int n;
    std::cin>>n;
    std::string strs[n];
    kuohao k[n];
    for(int i=0;i<n;++i){
        std::cin>>strs[i];
    }
    for(int i=0;i<n;++i){
        int temp=strs[i].size(); 
        int count=0;
        int countl=0;
        int countMH=0;
        for(int j=0;j<temp;++j){
            if(strs[i][j]=='('){
                ++count;
                ++countl;
            }
            if(strs[i][j]==')'){
                --count;
                --countl;
            }
            if(count<countMH){
                ++(k[i].must_have);
                countMH=count;
                countl=0;
            }
        }
        k[i].this_num=count;
        k[i].countl=countl;
    }
    std::sort(k,k+n);
    int count=0;
    for(int i=0;i<n;++i){
        if(count>=k[i].must_have){
            count+=(k[i].this_num);
        }
        else{
            int j;
            for(j=i+1;j<n;++j){
                if(count>=k[j].must_have&&k[j].must_have!=-1){
                    count+=(k[j].this_num);
                    k[j].must_have=-1;
                    k[j].this_num=0;
                    --i;
                    break;
                }
            }
            if(j>=n){
                std::cout<<"No"<<std::endl;
                return 0;
            }
        }
    }
    if(count==0){
        std::cout<<"Yes"<<std::endl;
    }
    else{
        std::cout<<"No"<<std::endl;
    }
    return 0;
}

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

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

int main() {
#ifdef cute
	freopen("in", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	string s;
	cin >> n >> s;
	
	if(n & 1) cout << "No";
	else {
		int half = n >> 1;
		for(int i = 0; i < half; i++) {
			if(s[i] ^ s[i+half]) {
				cout << "No";
				return 0;
			}
		}
		cout << "Yes";
	}



#ifdef cute
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif
}

// g++ o .cpp -O2 -std=c++11 -D cute -Wall -Wno-unused-result



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

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

    int n = stoi(a + b);
    int i = sqrt(n);
    if(i * i == n) cout << "Yes" << endl;
    if(i * i != n) cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 384
N=int(input())
list = list(map(int, input().split()))
c=100
l=len(list)
m=0
k=0
i=0
while(k<l):
  m+=(list[k]-1)**2
  k+=1
j=1
while(j<c):
  r=0
  i=0
  while(i<l):
    r+=(list[i]-j) ** 2
    i+=1
  if(r<m):
    m=r
  j+=1
print(m)

Measured memory_bytes: 3064
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    int a[3];rep(i,0,3)cin>>a[i];
    sort(a,a+3);reverse(a,a+3);
    cout<<10*a[0]+a[1]+a[2]<<endl;return 0;
}



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

int main(){
    int a[3],b[3],c[3][3];
    rep(i,3)rep(j,3) cin >> c[i][j];
    a[0]=0;
    
    rep(i,3) b[i]=c[0][i]-a[0];
    rep(i,3) a[i]=c[i][0]-b[0];
    bool ans=true;
    
    rep(i,3){
        rep(j,3){
            if(a[i]+b[j]!=c[i][j]) ans=false;
        }
    }
  
    if(ans) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include <iostream>

const int NMAX = 100005;

using namespace std;

int N;
int a[NMAX];
int pos[NMAX];
int answer;

int main()
{
    cin >> N;
    for (int i = 1; i <= N; ++i)
    {
        cin >> a[i];
        a[i] += 1;

        pos[a[i]]++;
        pos[a[i] - 1]++;
        pos[a[i] + 1]++;
    }

    answer = 100003;

    for (int i = 0; i <= 100001; ++i) {
        if (pos[i] > pos[answer])
        {
            answer = i;
        }
    }

    cout << pos[answer] << '\n';

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }

int main() {
    string s,t;
    cin >> s >> t;
    if(s.length() > t.length()){
        cout << "GREATER\n";
        return 0;
    }
    else if(s.length() < t.length()){
        cout << "LESS\n";
        return 0;
    }
    else if(s == t){
        cout << "EQUAL\n";
        return 0;
    }else {
        rep(i,s.length()){
            if(s[i] > t[i]){
                cout << "GREATER\n";
                return 0;
            }
            else if(s[i] < t[i]){
                cout << "LESS\n";
                return 0;
            }
        }
    }
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
a = [0] + a
for i in range(n,0,-1):
    a[i] = sum(a[i::i]) % 2
ans = []
for i in range(len(a)):
    if a[i] == 1:
        ans.append(i)
print(len(ans))
if len(ans) != 0:
    print(' '.join(map(str,ans)))

Measured memory_bytes: 18476
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;

const string yey = "Yay!";
const string sad = ":(";

ll mx[3][5001];
ll dp[5001];
ll ans[5001];
void solve() {
	int n; cin >> n;
	vector<ll> v[2];
	rep(i, 2) {
		v[i].resize(3);
		rep(j, 3)cin >> v[i][j];
	}
	int cnt = 0;
	bool y[3] = {};
	rep(i, 3) {
		if (v[0][i] < v[1][i]) {
			cnt++; y[i] = true;
		}
	}
	if (cnt == 0) {
		swap(v[0], v[1]);
		cnt = 3;
	}
	if (cnt == 3) {
		rep(i, 3) {
			ll l = v[0][i], r = v[1][i];
			rep(j, n + 1) {
				mx[i][j] = j % l + r * (j / l);
			}
		}
		rep(i, n + 1) {
			rep(j, n + 1) {
				if (i + j > n)break;
				dp[i + j] = max(dp[i + j], mx[1][i] + mx[2][j]);
			}
		}
		rep(i, n + 1) {
			rep(j, n + 1) {
				if (i + j > n)break;
				ans[i + j] = max(ans[i + j], mx[0][i] + dp[j]);
			}
		}
		ll out = 0;
		rep(i, n + 1)out = max(out, ans[i]);
		cout << out << endl;
	}
	else if(cnt==2){
		int tmp = 0;
		rep(i, 3) {
			if (y[i]) {
				ll l = v[0][i], r = v[1][i];
				rep(j, n + 1) {
					mx[tmp][j] = j % l + r * (j / l);
				}
				tmp++;
			}
		}
		rep(i,n+1){
			rep(j, n + 1) {
				if (i + j > n)break;
				dp[i + j] = max(dp[i + j], mx[1][i] + mx[0][j]);
			}
		}
		ll cur = 0;
		rep(i, n + 1)cur = max(cur, dp[i]);
		ll out = 0;
		rep(i, 3) {
			if (!y[i]) {
				ll l = v[1][i], r = v[0][i];
				ll pro = cur % l + r * (cur / l);
				out = max(out, pro);
			}
		}
		cout << out << endl;
	}
	else {
		ll cur = 0;
		rep(i, 3) {
			if (y[i]) {
				ll l = v[0][i], r = v[1][i];
				cur = n % l + r * (n / l);
			}
		}
		ll l[2], r[2];
		int tmp = 0;
		rep(i, 3) {
			if (!y[i]) {
				l[tmp] = v[1][i];
				r[tmp] = v[0][i];
				tmp++;
			}
		}
		ll out = 0;
		rep(i, cur + 1) {
			ll sum = i % l[0] + r[0] * (i / l[0]);
			ll rest = cur - i;
			sum += rest % l[1] + r[1] * (rest / l[1]);
			out = max(out, sum);
		}
		cout << out << endl;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(9);
	//init();
	//while (cin >> n>>m>>l,n)solve();
	solve();
	//stop
	return 0;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  char con[60];
  for (int i = 0; i < 60; i++) {
    con[i] = 'A' + i % 26;
  }
  for (int i = 0; i < s.length(); i++) {
    s[i] = con[s[i] - 'A' + n];
  }
  cout << s << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(final String[] args) {
		@SuppressWarnings("resource")
		final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		final int R = in.nextInt();
		final int G = in.nextInt();
		final int B = in.nextInt();
		final int N = in.nextInt();

		int ans = solve(R, G, B, N);
		// N = R * r + G * g + B * b
		System.out.println(ans);
	}

	static int solve(int R, int G, int B, int N) {
		int ans = 0;
		for (int r = 0; r <= 3000; ++r)
			for (int g = 0; g <= 3000; ++g) {
				final int rest = N - r * R - g * G;
				if (rest < 0)
					continue;
				if (rest % B != 0)
					continue;
				++ans;
			}
		return ans;
	}
}


Measured memory_bytes: 23380
#include<string>
#include<iostream>
#include<set>
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
//#define scanf scanf_s
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<30);
const llint mod=1000000007;
int main(void){
	int N,i,j,ansb,anse;
	string s;
	vector<string> as;
	vector<string> zs;
	string t;
	scanf("%d",&N);
	
	as.resize(N);
	zs.resize(N);
	for(i=0;i<N;i++){
		cin>>s;
		as[i]=s;
		zs[i]=s;
		for(j=0;j<s.size();j++){
			if(s[j]=='?'){
				as[i][j]='a';
				zs[i][j]='z';
			}
		}
	}
	cin>>t;
	sort(as.begin(),as.end());
	sort(zs.begin(),zs.end());
	ansb=upper_bound(as.begin(),as.end(),t)-as.begin()+1;
	anse=lower_bound(zs.begin(),zs.end(),t)-zs.begin()+1;
	for(i=anse;i<=ansb;i++){
		printf("%d",i);
		if(i<ansb){
			printf(" ");
		}
	}
	printf("\n");
	return 0;

}


Measured memory_bytes: 1408
N = int(input())
a = [int(input()) for i in range(N)]

push = [False] * N

ans = 0
i = 0
while True:
    ans += 1
    if a[i] == 2:
        break
    if push[i]:
        ans = -1
        break
    push[i] = True
    i = a[i] - 1

print(ans)

Measured memory_bytes: 7852
#include <iostream>
#include <fstream>	// require freopen

using namespace std;

int main()
{
	int price[][7] = { 
			{   0, 300, 500, 600, 700,1350,1650 },
			{   0,   0, 350, 450, 600,1150,1500 },
			{   0,   0,   0, 250, 400,1000,1350 },
			{   0,   0,   0,   0, 250, 850,1300 },
			{   0,   0,   0,   0,   0, 600,1150 },
			{   0,   0,   0,   0,   0,   0, 500 },
			{   0,   0,   0,   0,   0,   0,   0 } };
	int dist[][7] = {
			{   0,   0,   0,   0,   0,   0,   0 },
			{   6,   0,   0,   0,   0,   0,   0 },
			{  13,   7,   0,   0,   0,   0,   0 },
			{  18,  12,   5,   0,   0,   0,   0 },
			{  23,  17,  10,   5,   0,   0,   0 },
			{  43,  37,  30,  25,  20,   0,   0 },
			{  58,  52,  45,  40,  35,  15,   0 } };

	for (int i = 0; i < 7; ++i ){
		for (int j = 0; j < 7; ++j ){
			if (i != j ){
				if (price[i][j] == 0 ){
						price[i][j] = price[j][i];
				} // end if
				if (dist[i][j] == 0 ){
					dist[i][j] = dist[j][i];
				} // end if
			} // end if
		} // en for
	} // end for

//	cut here before submit 
//	freopen ("testcase.highwaytoll", "r", stdin );
	int from;

	while (cin >> from && from ){
		int fromh, fromm;
		cin >> fromh >> fromm;
		int to,toh, tom;
		cin >> to >> toh >> tom;
		from--;to--;
		int res = 0;
		int em = fromh*60 + fromm;
		int dm = toh*60 + tom;

		// ツ環暗クツ妥篠湘崢づ個篠楪甘板妥堕づづ債づ按つ「
		if ( (17*60 + 30 <= em && em <= 19*60 + 30 ) 
		||   (17*60 + 30 <= dm && dm <= 19*60 + 30 ) ){ 
			int d = dist[from][to];
			if (d > 40 ){
				res = price[from][to];
			}else{
				res = (price[from][to]/2 + 49)/50*50;
			} // end if
 		}else{
				res = price[from][to];
		} // end if

		cout << res << endl;	
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
def main():
    N, M, K = list(map(int, input().split()))
    ans = False
    for i in range(N+1):
        for j in range(M+1):
            x = i * M + j * N - (i * j) * 2
            # print(i, j, x)
            if x == K:
               ans = True 
    if ans:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
  
typedef struct node{
    int p;
    int left;
    int right;
} Node;
  
int searchHight(int);
  
Node *trees;
  
int main(){
      
    int n,i,id,depth,tmpP,deg,nowNode,sibling;
  
    scanf("%d", &n);
  
    trees = malloc(sizeof(Node)*n);
  
    for (i = 0; i < n; ++i){
        trees[i].p = -1;
    }
  
    for (i = 0; i < n; ++i){
        scanf("%d",&id);
        scanf("%d%d",&trees[id].left,&trees[id].right);
        trees[trees[id].left].p = id;
        trees[trees[id].right].p = id;
    }
  
    nowNode = 0;
    while(1){
        if (trees[nowNode].left != -1 && trees[nowNode].right != -1)
        {
            break;
        } else if (trees[nowNode].left == -1)
        {
            nowNode = trees[nowNode].right;
        } else {
            nowNode = trees[nowNode].left;
        }
    }
  
    for (i = 0; i < n; ++i){
          
        tmpP = trees[i].p;
        if (tmpP == -1) sibling = -1;
        else if(trees[tmpP].left == i) sibling = trees[tmpP].right;
        else sibling = trees[tmpP].left;

        depth = 0;
        while(tmpP != -1){
            tmpP = trees[tmpP].p;
            depth++;
        }
  

        deg = 0;
        if (trees[i].left != -1) deg++;
        if (trees[i].right != -1) deg++;
  
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "
            ,i,trees[i].p,sibling,deg,depth,searchHight(i));
  
        if(trees[i].p == -1) printf("root\n");
        else if(trees[i].left == -1 && trees[i].right == -1) printf("leaf\n");
        else printf("internal node\n");
    }
  
    return 0;
}
  
int searchHight(int index){
    int hLeft = 0;
    int hRight = 0;
  
    if (trees[index].left != -1){
        hLeft = searchHight(trees[index].left) +1;
    }
    if (trees[index].right != -1){
        hRight = searchHight(trees[index].right) +1;
    }
    if (hLeft < hRight) return hRight;
    else return hLeft;
}

Measured memory_bytes: 612
N, Z, W = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

INF = 1 << 60
def dfs(i, x_turn, dp)
  return dp[i][x_turn] if dp[i][x_turn]
  if x_turn == 0
    x = A[-1]
    y = i == 0 ? W : A[i - 1]
    ret = (y - x).abs
    min = INF
    ((i + 1)...N).each do |j|
      a = dfs(j, (x_turn + 1) % 2, dp)
      min = a if a < min
    end
    ret = min if min != INF && min > ret
  else
    x = A[i - 1]
    y = A[-1]
    ret = (y - x).abs
    max = -INF
    ((i + 1)...N).each do |j|
      a = dfs(j, (x_turn + 1) % 2, dp)
      max = a if a > max
    end
    ret = max if max != -INF && max > ret
  end
  dp[i][x_turn] = ret
end

dp = Array.new(N) { Array.new(2) }
puts dfs(0, 0, dp)

Measured memory_bytes: 7420
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC172E
//ABC172D
//ABC172C
//ABC172B
//ABC172A

int main(void) {
  int n, k, i, a, cou=0, tmp;
  scanf("%d", &a);
  printf("%d", a+a*a+a*a*a);
}


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


def main():
    import sys
    input = sys.stdin.readline

    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    LV = K.bit_length()
    nxt = [[0] * (LV+1) for _ in range(N+1)]
    for i in range(N):
        nxt[i+1][0] = A[i]
    for lv in range(1, LV+1):
        for i in range(1, N+1):
            nxt[i][lv] = nxt[nxt[i][lv-1]][lv-1]

    i = 1
    for j in range(LV+1):
        if K >> j & 1:
            i = nxt[i][j]
    print(i)


if __name__ == '__main__':
    main()


Measured memory_bytes: 201496
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
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;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    //cout<<max(0LL,a[n/2]-a[n/2-1])<<endl;
    cout<<a[n/2]-a[n/2-1]<<endl;
}

Measured memory_bytes: 3988
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
#include <vector>
#include<cstdio>
#include <numeric>
#include <queue>
#include <list>
#include <math.h>
#include <stdio.h>
#include <math.h>
#include <errno.h>
#include <fenv.h>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
long long mod=1000000007;
int main(){
  int X,N;cin>>X>>N;
  vector<int>p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  int ans=1000;
  int ans1=X;
  int ans2=X;
  int flg1=1;
  int flg2=1;
  while(flg1==1&&flg2==1){
    flg1=0;
    flg2=0;

    for(int i=0;i<N;i++){
      if(p[i]==ans1){
        flg1=1;
      }
      
      if(p[i]==ans2){
       flg2=1;
      } 
      }
      if(flg1==0){
        //cout<<"flg1"<<endl;
        ans=ans1;
      }
      else if(flg2==0){
        ans=ans2;
        //cout<<"flg1"<<endl;
      }
      else {
        ans1-=1;
        ans2+=1;
      }




  }
  cout<<ans<<endl;
  





}

Measured memory_bytes: 3628
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
ll dp[200000];
int main(){
int n;
cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++){cin>>a[i];a[i]--;}
vector<int> idx(n);//場所
for(int i=0;i<n;i++)idx[a[i]]=i;
set<int> s;
ll ans=0;
for(int x=n-1;x>=0;x--){
int i=idx[x];//i=場所
ll c=0;//個数
s.insert(i);
vector<int> l(2,-1),r(2,n),ls(2),rs(2);//左右それぞれのxより大きい数
auto ite=s.find(i);
//大きい方から入れるので必然とぶつかるイテレーターはその数より大きい数になる
for(int j=0;j<2;j++){
    if(ite==s.begin())break;
    ite--;
    l[j]=*ite;
}
ite=s.find(i);
for(int j=0;j<2;j++){
     ite++;//範囲外を参照しないために先に足す
    if(ite==s.end())break;
    r[j]=*ite;
}
ls[0]=i-l[0];//左1個目
ls[1]=l[0]-l[1];//左２個目
rs[0]=r[0]-i;//右1個目
rs[1]=r[1]-r[0];//右2個目
//cout<<ls[0]<<" "<<ls[1]<<" "<<rs[0]<<" "<<rs[1]<<endl;
c=(ll)ls[0]*rs[1]+(ll)ls[1]*rs[0];
ans+=(x+1)*c;
}
cout<<ans<<endl;
}


Measured memory_bytes: 5760
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    #n=int(input())
    n,k= map(int, sys.stdin.readline().split(' '))
    if(n==k):
        print(0)
        continue
    if(n<k):
        print(min(n,k-n))
        continue
    else:
        n=(n%k)
        print(min(n,k-n))
        continue
    #a=list(map(int,sys.stdin.readline().split(' ')))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

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

vector<int> solve() {
    ll N;
    string S;
    cin >> N >> S;
    vector<bool> SS(N);
    for ( int i = 0; i < N; i++ ) {
        SS[i] = S[i] == 'x';
    }
    bool ok = false;
    int b[] = {0, 1};
    for ( int i1 = 0; i1 < 2; i1++ ) {
        for ( int i2 = 0; i2 < 2; i2++ ) {
            vector<int> v(N);
            v[0] = b[i1];
            v[1] = b[i2];
            for ( int i = 1; i < N-1; i++ ) {
                v[i+1] = v[i] ^ v[i-1] ^ SS[i];
            }
            if ( v[0] != v[N-1] ^ v[N-2] ^ SS[N-1] ) continue;
            if ( v[1] != v[0] ^ v[N-1] ^ SS[0] ) continue;
            return v;
        }
    }
    return vector<int>();
}

int main() {
    auto ans = solve();
    if ( ans.size() == 0 ) {
        cout << -1 << "\n";
    } else {
        for ( int i = 0; i < ans.size(); i++ ) {
            cout << (ans[i] == 0 ? 'S' : 'W' );
        }
        cout << "\n";
    }
    return 0;
}

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


int A[100];

int bubbleSort(int A[], int n) {
	int cnt = 0;
	bool flag = true;
	while (flag) {
		flag = false;
		for (int i = n - 1; i >= 1; i--) {
			if (A[i] < A[i - 1]) {
				swap(A[i], A[i - 1]);
				cnt++;
				flag = true;
			}
		}
	}
	return cnt;
}

int main(void) {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> A[i];

	int cnt = bubbleSort(A, n);

	for (int i = 0; i < n; i++) {
		if (i == n - 1) {
			cout << A[i] << endl;
			break;
		}
		cout << A[i] << " ";
	}

	cout << cnt << endl;
		
	return 0;

}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int A[N];
    int min = INT32_MAX;
    int vice_min = INT32_MAX;
    int tmp;
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i] < vice_min) vice_min = A[i];
        if(vice_min < min){
            tmp = min;
            min = vice_min;
            vice_min = tmp;
        }
    }

    //cout << vice_min << endl;

    int c = 0;

    int ans;

    for(int i=vice_min;i>= 1;i--){
        c = 0;
        for(int j=0;j<N;j++){
            if(A[j]%i != 0) c++;
            if(c >= 2) break;
        }

        if(c == 0 or c == 1){
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    long long s, c;
    cin >> s >> c;

    long long ans = min(s, c / 2);
    ans += (c - 2 * ans) / 4;
    cout << ans << endl;

    return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int> ar(N);
  for(int i=0;i<N;i++){
    cin>>ar[i];
  }
  sort(ar.begin(), ar.end());
  int maxhen=ar[N-1];
  int sum = accumulate(ar.begin(),ar.begin() + N-1,0);
  if (maxhen>=sum){
    cout<< "No"<<endl;
    return 0;
  }
  cout<< "Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] hl = new long[n];
        for(int i = 0; i < n; i++){
            hl[i] = sc.nextLong();
        }
        long[] dp = new long[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for(int i = 0; i < n; i++){
            int min = Math.min(k,n-i-1);
            for(int j = i+1; j <= i+min; j++){
                dp[j] = Math.min(dp[j], dp[i] + Math.abs(hl[j] - hl[i]));
            }
        }
        System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 58700
n = int(raw_input())
def positive(n):
    m = 1
    d = 0
    while m < n:
        d += 2
        m += 2**d
    d -= 1
    s = "1"
    while d >= 0:
        if d % 2 == 1:
            if m + (-2)**d >= n:
                s += "1"
                m += (-2)**d
            else:
                s += "0"
        else:
            if m - 2**d >= n:
                m -= 2**d
                s += "0"
            else:
                s += "1"
        d -= 1
    return s
            
def negative(n):
    if n == -1:
        return "11"
    m = -2
    d = 1
    while m > n:
        d += 2
        m += (-2)**d
    s = "1"
    d -= 1
    while d >= 0:
        if d % 2 == 0:
            if m + 2**d <= n:
                s += "1"
                m += 2**d
            else:
                s += "0"
        else:
            if m - (-2)**d <= n:
                s += "0"
                m -= (-2)**d
            else:
                s += "1"
        d -= 1
    return s
    
                
        

def makeS(n):
    if n == 0:
        return "0"
    elif n > 0:
        return positive(n)
    else:
        return negative(n)
print makeS(n)
        

Measured memory_bytes: 2696
#include <stdio.h>
#include <stdlib.h>
  
int main()
{

int so[2001]={1};

    int a, n, m, q;
    int i, j;
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf("%d", &a);
        for(j=2000-a; j>=0; j--) {
            if(so[j])so[j+a]=1;
        }
    }
 
    scanf("%d", &q);
    for(i=0; i<q; i++) {
        scanf("%d", &m);
        if(so[m]) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}

Measured memory_bytes: 588
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

bool perfect[10];

bool check(int n){
	int t=n;
	while(t>0){
		if(!perfect[t%10])return false;
		t/=10;
	}
	return true;
}

int main(){
    memset(perfect,true,sizeof(perfect));
    int n,d,k;
    cin>>n>>k;
    for(int i=0;i<k;i++){
    	cin>>d;
    	perfect[d]=false;
	}
	for(;;n++){
		if(check(n)){
			cout<<n;
			break;
		}
	}
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
using namespace std;

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ex[1001] = {0};

  for(int i = 0; i < N; i++) {
      ex[S[i]] = 1;
  }

  string s[1000];
  for(int i = 0; i < 10; i++) {
    s[i] = "00" + to_string(i);
  }
  for(int i = 10; i < 100; i++) {
    s[i] = "0" + to_string(i);
  }
  for(int i = 100; i < 1000; i++) {
    s[i] = to_string(i);
  }

  int count = 0;

  for(int i = 0; i < 1000; i++) {
    int first = S.find_first_of(s[i][0]);
    int second = S.find(s[i][1], first+1);
    int third = S.find(s[i][2], second+1);
    if(first >= 0 && second >= 0 && third >= 0) {
      count++;
    }
  }

  cout << count << endl;


  return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX_N (1<<17)
int n;
vector<int> a(111111);
using Int = long long;

template<typename T> 
struct BIT{
  Int n;
  vector<T> bit;
  //1-indexed
  BIT():n(-1){}
  BIT(Int n_,T d):n(n_),bit(n_+1,d){}
  
  T sum(Int i){
    T s=bit[0];
    for(Int x=i;x>0;x-=(x&-x))
      s+=bit[x];
    return s;
  }
  void add(Int i,T a){
    if(i==0) return;
    for(Int x=i;x<=n;x+=(x&-x))
      bit[x]+=a;
  }
  
  Int lower_bound(Int w){
    if(w<=0) return 0;
    Int x=0,r=1;
    while(r<n) r<<=1;
    for(Int k=r;k>0;k>>=1){
      if(x+k<=n&&bit[x+k]<w){
	w-=bit[x+k];
	x+=k;
      }
    }
    return x+1;
  }
  
  T sum0(Int i){
    return sum(i+1);
  }
  void add0(Int i,T a){
    add(i+1,a);
  }
 
  T query(Int l,Int r){
    return sum(r-1)-sum(l-1);
  }
 
  T query0(Int l,Int r){
    return sum(r)-sum(l);
  }
};

int rec(int mid){
  vector<int> c(111111);
  BIT<int> bit(2*n+2,0);
  
  for(int i=0;i<n;i++)
    c[i]=(a[i]<mid?-1:1);
  
  int k=0;
  int sum=0;
  bit.add(n,1);
  for(int i=0;i<n;i++){
    k+=c[i];
    sum+=bit.sum(k+n);
    bit.add(k+n,1);
  }

  return sum>=((n+1)*n/2+1)/2;
}

signed main(){
  cin>>n;
  vector<int> b;
  for(int i=0;i<n;i++){
    cin>>a[i];
    b.push_back(a[i]);
  }
  sort(b.begin(),b.end());
  
  int ok=0,ng=n,mid;
  while(ng-ok>1){
    mid=(ok+ng)/2;
    if(rec(b[mid]))ok=mid;
    else ng=mid;
  }
  
  cout<<b[ok]<<endl;
  return 0;
}


Measured memory_bytes: 4468
#include<stdio.h>
int main(void)
{
	int a,b,c,temp;
	char x,y;
	a=1;
	b=0;
	c=0;
	while(scanf("%c,%c",&x,&y)!=EOF) {
		if(x=='A' && y=='B') {
			temp=a;
			a=b;
			b=temp;
		}
		if(x=='A' && y=='C') {
			temp=a;
			a=c;
			c=temp;
		}
		if(x=='B' && y=='A') {
			temp=b;
			b=a;
			a=temp;
		}
		if(x=='B' && y=='C') {
			temp=b;
			b=c;
			c=temp;
		}
		if(x=='C' && y=='A') {
			temp=c;
			c=a;
			a=temp;
		}
		if(x=='C' && y=='B') {
			temp=c;
			c=b;
			b=temp;
		}
	}
	if(a==1) {
		printf("A\n");
	}
	if(b==1) {
		printf("B\n");
	}
	if(c==1) {
		printf("C\n");
	}
	return 0;
}

Measured memory_bytes: 524
#include <stdio.h>

int main(void){
    
    char S[3];
    char T[3];
    int sum = 0;
    int i;
    
    scanf("%s",S);
    scanf("%s",T);
    
    for(i=0;i<3;i++){
        if(S[i]==T[i]){
            sum++;
        }
    }
    
    printf("%d\n", sum);
    
    return 0;
}


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

using namespace std;

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

    int cnt = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i+1; j < n; ++j){
            for(int k = j+1; k < n; ++k){
                int A = min({l[i], l[j], l[k]});
                int C = max({l[i], l[j], l[k]});
                int B = l[i]^l[j]^l[k]^A^C;
                bool cst1 = A != B and B != C;
                bool cst2 = A+B > C;
                if(cst1 and cst2) ++cnt;
            }
        }
    }
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 3628
import math

N=int(input())

keta=0
while N>=math.pow(10,keta):
	keta += 1

count=0
if keta%2==1:
	count = N-int(math.pow(10,keta-1))+1
	keta -= 1
while keta>=2:
	count += 9*int(math.pow(10,keta-2))
	keta -= 2

print(count)

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

using std::cout;
using std::endl;
using std::cin;
using std::max;
using ll = long long;

int main() {
	// Input
	ll N, K; cin >> N >> K;
	// Calculation
	ll ans;
	for(ll b = K + 1; b <= N; ++b) {
		ll q = (N+1) / b;
		ans += (b-K)*q;
		ans += max(0LL, N-q*b-K+1);
	}
	if(K == 0LL) ans -= N;
	// Output
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
			s[i] = sort(s[i]);
		}
		HashMap<String, Long> map = new HashMap<String, Long>();
		for (int i = 0; i < n; i++) {
			if (!map.containsKey(s[i])) {
				map.put(s[i], 1L);
			} else {
				map.put(s[i], map.get(s[i]) + 1);
			}
		}
		long ans = 0;
		for (String key : map.keySet()) {
			ans += map.get(key) * (map.get(key) - 1) / 2;
		}
		System.out.println(ans);
	}
	static String sort(String s) {
		for (int i = 0; i < 10; i++) {
			for (int j = i; j < 10; j++) {
				char a = s.charAt(i);
				char b = s.charAt(j);
				if (a > b) {
					s = s.substring(0, i) + b + s.substring(i + 1, j) + a + s.substring(j + 1);
				}
			}
		}
		return s;
	}
}

Measured memory_bytes: 162556
#include <bits/stdc++.h>
using namespace std;
typedef long long int  ll;
long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
long long bigpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int gcd(int a,int b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
int main() 
{
	int s,w;
	cin>>s>>w;
	if(w>=s)
	{
		cout<<"unsafe\n";
	}
	else cout<<"safe\n";
	return 0;
}


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

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

  if (k >= 1 << m) {
    cout << -1 << endl;
    return 0;
  }

  if (m == 0 && k == 0) {
    cout << "0 0" << endl;
    return 0;
  }

  if (m == 1) {
    if (k == 0) {
      cout << "0 0 1 1" << endl;
      return 0;
    }
    if (k == 1) {
      cout << -1 << endl;
      return 0;
    }
  }

  for (int i = 0; i < 1 << m; i++) {
    if (i == k) continue;
    cout << ' ' << i;
  }
  cout << ' ' << k;
  for (int i = (1 << m) - 1; i >= 0; i--) {
    if (i == k) continue;
    cout << ' ' << i;
  }
  cout << ' ' << k << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <utility>
#include <map>
#include <functional>
#include <initializer_list>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;


int main(){
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll count = 0;
    if(K<=A){
        cout << K;
        }
    else{
        if(K-A <= B){
            cout << A;
            }
        else{
            cout << A-(K-A-B);
            }
        }

}

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

ifstream in("test.in");
ofstream out("test.out");

int main(void) {
    ios :: sync_with_stdio(false);
    cin.tie(); cout.tie();
    
    string str;
    cin >> str;
    
    if (str.length() >= 4 and str[0] == 'Y' and str[1] == 'A' and  str[2] == 'K' and str[3] == 'I' )
        cout << "Yes";
    else
        cout << "No";
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int q =sc.nextInt();
		for(int i = 0; i < q; i++) {
			String command = sc.next();
			
			switch(command) {
				case "print": {
					int a =sc.nextInt();
					int b =sc.nextInt();
					pr(a, b, str);
					break;
				}
				case "reverse": {
					int a =sc.nextInt();
					int b =sc.nextInt();
					str = rv(a, b, str);
					break;
				}
				case "replace": {
					int a =sc.nextInt();
					int b =sc.nextInt();
					String p = sc.next();
					str = rp(a, b, p, str);
					break;
				}
			}
		}
		sc.close();
	}
	
	//printメソッド
	static void pr(int a, int b, String str) {
		if(b < str.length()) {
			System.out.println(str.substring(a, b + 1));
		} else {
			System.out.println(str.substring(a));
		}
	}
	//reverseメソッド
	static String rv(int a, int b, String str) {
		if (b < str.length()) {
			String f = str.substring(0, a);
			String l = str.substring(b + 1);
			StringBuilder c = new StringBuilder(str.substring(a, b + 1));
			StringBuilder sb = new StringBuilder();
			sb.append(f);
			sb.append(c.reverse().toString());
			sb.append(l);
			return(sb.toString());
		} else {
			String f = str.substring(0, a);
			StringBuilder c = new StringBuilder(str.substring(a));
			StringBuilder sb = new StringBuilder();
			sb.append(f);
			sb.append(c.reverse().toString());
			return(sb.toString());
		}
	}
	//replaceメソッド
	static String rp(int a, int b, String p, String str) {
		if (b < str.length()) {
			String f = str.substring(0, a);
			String l = str.substring(b + 1);
			StringBuilder sb = new StringBuilder();
			sb.append(f);
			sb.append(p);
			sb.append(l);
			return(sb.toString());
		} else {
			String f = str.substring(0, a);
			StringBuilder sb = new StringBuilder();
			sb.append(f);
			sb.append(f);
			return(sb.toString());
		}
	}
}


Measured memory_bytes: 29476
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include<random>

//#pragma comment(linker, "/STACK:512000000")

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const int infi = 1e9 + 7;
const ll infl = (ll)1e18 + (ll)7;

ll solve(string &s) {
    ll ans = 0;
    ll cnt_a = 0;
    for (char c : s) {
        if (c == 'a') {
            ++cnt_a;
        } else {
            ans += cnt_a;
        }
    }
    return ans;
}

int32_t main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    //srand(time(NULL));
   // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    string s, t;
    cin >> s;
    ll ans = 0;
    s += '#';
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'A') {
            t += 'a';
        } else if (s[i] == 'B' && i + 1 < s.size() && s[i + 1] == 'C') {
            t += 'b';
            ++i;
        } else {
            ans += solve(t);
            t.clear();
        }
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 916
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <iostream>

// template <class ForwardIt>
// void inspect(ForwardIt first, ForwardIt last) {
//   while (first != last) {
//     std::cerr << *first++;
//     if (first == last) {
//       std::cerr << std::endl;
//       break;
//     }
//     std::cerr << ' ';
//   }
// }

constexpr intmax_t MOD = 1e9+7;

int main() {
  char buf[131072];
  scanf("%s", buf);
  std::string S = buf;
  size_t N = S.length();

  std::vector<std::vector<intmax_t>> dp(N+1, std::vector<intmax_t>(4));
  dp[0][0] = 1;
  for (size_t i = 1; i <= N; ++i) {
    bool wild = (S[i-1] == '?');
    // mark
    for (size_t j = 1; j <= 3; ++j) {
      if (S[i-1] == "ABC"[j-1] || wild) {
        (dp[i][j] += dp[i-1][j-1]) %= MOD;
      }
    }

    // left unmarked
    for (size_t j = 0; j <= 3; ++j) {
      (dp[i][j] += (wild? 3:1) * dp[i-1][j]) %= MOD;
    }
  }

  printf("%jd\n", dp[N][3]);
}


Measured memory_bytes: 7424
#include<stdio.h>
#include<math.h>
double dist(double,double,double,double);
int main(void)
{
  double x1,y1,x2,y2;
  scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
  printf("%f\n",dist(x1,y1,x2,y2));
  return 0;
}
double dist(double x1,double y1,double x2,double y2)
{
  return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}


Measured memory_bytes: 2112