akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <numeric>
#define M 1000000007
#define inf 1e18+1
#define pb push_back
// #define mp make_pair
#define forz(i,s,n) for(lli i=s;i<n;i++)
#define fore(i,n,s) for(lli i=n;i>=s;i--)
#define binod ios_base ::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

typedef long long int lli;
//typedef pair<long long int, long long int> pll;
typedef unsigned long long int ull;
using namespace std;

lli recpow(lli x, lli n, lli mod)
{
    if (n == 0)
        return 1;
    else if (n % 2 == 0) //n is even
        return recpow((x * x) % mod, n / 2, mod);
    else //n is odd
        return (x * recpow((x * x) % mod, (n - 1) / 2, mod)) % mod;
}

const int nax=402;
lli dp[nax][nax];
lli n, a[nax], p[nax],ps;

lli sum(lli i,lli j)
{
    if(i>j)
    return 0;
    if(i-1<0)
    return p[j];
    return p[j]-p[i-1];
}

lli func(lli i, lli j)
{
    if(i==j)
    return dp[i][j]=0;
    if(j==i+1)
    return dp[i][j]=a[i]+a[j];
    if(dp[i][j]!=-1)
    return dp[i][j];
    dp[i][j]=inf;
    forz(i1,i,j)
    dp[i][j]=min(dp[i][j],func(i,i1)+func(i1+1,j)+sum(i,i1)+sum(i1+1,j));
    return dp[i][j];
}

//code begins here
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    binod
    //sieve();
    cin>>n;
    ps=0;
    forz(i,0,n)
    {
        cin>>a[i];
        ps+=a[i];
        p[i]=ps;
    }
    forz(i,0,nax)
    forz(j,0,nax)
    dp[i][j]=-1;
    cout<<func(0,n-1);
    return 0;
}

Measured memory_bytes: 4896
#include <iostream>
     
    using namespace std;
     
    int main() {
      int i, res = 0;
      cin >> i;
      int a = i / 500, b;
      res += 1000 * a;
      i -= a * 500;
      res += 5* (i / 5);
      cout << res << "\n";
    }

Measured memory_bytes: 256
#include<stdio.h>

int H[1000000],h;
int binarySearch(int);

int main(){
  
  int i,q,a,sum=0;

  scanf("%d",&h);
  
  for(i=0;i<h;i++){
    
    scanf("%d",&H[i]);
    
  }

  scanf("%d",&q);
  
  for(i=0;i<q;i++){
    
    scanf("%d",&a);
    
    if(binarySearch(a))sum++;
      
    
  }
  
  printf("%d\n",sum);
  
  return 0;
  
}

int binarySearch(int key){
  
  int left = 0;
  
  int right = h;
  
  int mid;
  
  while(left < right){
    
    mid = (left + right)/2;
    
    if(key == H[mid])return 1;
    
    if( key > H[mid])left= mid + 1;
    
    else if(key < H[mid])right = mid;

  }
  
  return 0;
  
}


    
  



Measured memory_bytes: 2248
#include<bits/stdc++.h>
using namespace std;
int n,t=2,f=1;
long long ans[100005];
struct N{int data,num;}a[100005];
bool comp(N x,N y){if(x.data==y.data) return x.num<y.num;else return x.data>y.data;}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i].data),a[i].num=i;
	sort(a+1,a+n+1,comp);
	while(t<=n){
		while(a[t].data==a[t-1].data) t++;
		ans[a[f].num]+=1ll*(a[f].data-a[t].data)*(t-1);
		if(a[t].num>a[f].num) a[f].data=a[t].data;
		else f=t;
		t++;
	}
	ans[a[f].num]+=1ll*a[f].data*n;
	for(int i=1;i<=n;++i) printf("%lld\n",ans[i]);
}

Measured memory_bytes: 2688
def lscan; gets.split.map(&:to_i); end

D = [ 0,2,5,5,4,5,6,3,7,6 ]

N, M = lscan
A = lscan

dp = [-1]*(N+10)
dp[0] = 0

N.times do |i|
    next if dp[i] == -1
    A.each do |a|
        dp[i+D[a]] = [dp[i+D[a]], dp[i]*10 + a].max
    end
end

p dp[N]

Measured memory_bytes: 29180
n = int(input())

robots = []
for i in range(n):
    x, l = map(int, input().split())
    robots.append([x + l, x - l])

robots.sort()

ans = n
n_r = robots[0][0]
for i in range(1, n):
    r = robots[i][0]
    l = robots[i][1]
    if n_r > l:
        ans -= 1
    else:
        n_r = r

print(ans)


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


#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ll long long


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

    int a, b;

   	cin >> a >> b;

   	cout << max(a + b, max(a - b, a * b)) << endl;

    return 0;
}


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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>

i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

i64 cup(i64 xxx, i64 yyy) {//切り上げ
	return (xxx + yyy - 1) / yyy;
}

//メモリ置き場
i64 n,a,b;


//inputします
void input() {
	cin >> n >> a >> b;
}

//ライブラリ置き場

//main
int main() {
	input();
	i64 c = a + b;
	i64 ans = n / c;
	ans *= a;
	i64 rem = n % c;
	if (rem > a)ans += a;
	else ans += rem;
	cout << ans << endl;
	return 0;
}

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

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

    int ans = 0;

    for(int i = 1; i <= 100; i++)
        ans |= (a * i) % b == c;

    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

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

int main()
{
  int n, y, flag = 0;
  
  cin >> n >> y;
  
  int a = -1, b = -1, c = -1;
  
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n - i; j++) {
      int k = n - i - j;
      if (k >= 0) {
        if (10000 * i + 5000 * j + 1000 * k == y) {
          a = i, b = j, c = k;
          i = n;
          break;
        }
      }
      else {
        break;
      }
    }
  }
  
  cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#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 ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int n,t;
int main(){
    
    cin >> n>> t;
    int ans = inf;
    
    rep(i,0,n){
        int c,tt;
        cin >> c >> tt;
        if(tt <= t){
            ans = min(ans,c);
        }
    }
    if(ans == inf)P("TLE");
    else P(ans);
	return  0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n,d,x;
	scanf("%d %d %d",&n,&d,&x);
	for(int i=1;i<=n;i++){
		int a;
		scanf("%d",&a);
		x+=(d-1)/a+1;
	}
	printf("%d",x);
	return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N; cin >> N;
  vector<int> A(N);
  ll S = 0;
  rep(i, N) cin >> A[i], S += A[i];
  // X_1 + X_2 + ... + X_N = A_1 + A_2 + ... + A_N = S
  // A_i = (X_i + X_{i+1}) / 2
  // X_i + X_{i+1} = 2 * A_i
  // X_1 = S - (X_2 + ... + X_N)
  //     = S - 2 * (A_2 + A_4 + ... A_{N-1})
  // X_{i+1} = 2 * A_i - X_i
  vector<int> X(N);
  ll x = 0;
  for (int i = 1; i < N - 1; i += 2) x += A[i];
  X[0] = S - 2 * x;
  REP(i, 1, N) X[i] = 2 * A[i - 1] - X[i - 1];
  rep(i, N) {
    if (i) cout << " ";
    cout << X[i];
  }
  cout << "\n";
}


Measured memory_bytes: 2048
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstdlib>
#include <bitset>
#include <algorithm>
#include <queue>
using namespace std;

int main() {
	
	int n, m;

	cin >> n >> m;
	vector<int> a,b;
	vector<int> c;

	int t=0;

	

	for (int i = 0; i < m; i++) {
		int d, e;
		cin >> d >> e;
		a.push_back(d);
		b.push_back(e);
	}

	for (int i = 1; i <= n; i++) {
		c.push_back(i);
	}

	do {
		vector<bool>f(m, 0);

		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n-1; j++) {
				if (((a[i] == c[j] && b[i] == c[j + 1]) || (a[i] == c[j + 1] && b[i] == c[j])) && f[i] == 0) f[i] = 1;
			}

		}
	
		if (c[0] == 1) {
			int s = 0;
			for (int i = 0; i < m; i++) {
				if (f[i] == 1) s++;
			}

			if (s == n - 1) t++;

		}

	} while (next_permutation(c.begin(), c.end()));


	cout << t << endl;

	
	


	return 0;
}

Measured memory_bytes: 256
def output(n,x):
    count = 0
    for a in range(n): # a = 0,1,2,3,... n-1
        for b in range(n)[a+1:]: # b =1,2,3,... n-1
            for c in range(n)[b+1:]: # c = 2,3,4,5,...n-1
                if (a+1)+(b+1)+(c+1) == x:
                    count += 1
    return count

Data_set = []

# 入力
while True:
    n,x = input().split()
    n = int(n)
    x = int(x)
    if n == 0 and x == 0:
        break
    Data_set.append([n,x])

for a in Data_set:
    print(output(a[0],a[1]))



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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double ans = n;
		if(n % 2 == 1) {
			ans--;
		}
		ans = ans / 2;
		ans = 1 - (ans / n);
		System.out.println(ans);
	}

}



Measured memory_bytes: 23764
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N=4001;
const ll p=1e9+7;
int A[200010],B[200010];
ll a[N+5][N+5],tag[N+5][N+5];
ll fac[(N<<1)+10],ifac[(N<<1)+10];

inline void add(ll &a,ll b)
{
	a=a+b>=p?a+b-p:a+b;
}

ll fpm(ll a,ll b)
{
	ll ret=1;
	for(;b;b>>=1) ret=(b&1)?ret*a%p:ret,a=a*a%p;
	return ret;
}

int main()
{
	int n,mx=0,my=0;scanf("%d",&n);
	for(int i=1,x,y;i<=n;++i)
	{
		scanf("%d %d",&x,&y);
		A[i]=x;B[i]=y;
		mx=max(mx,x);my=max(my,y);
		++a[2001+x][2001+y];
		++tag[2001-x][2001-y];
	};
	mx+=2001;my+=2001;ll ans=0;
	for(int i=mx;i>=1;--i)
		for(int j=my;j>=1;--j)
		{
			add(a[i][j-1],a[i][j]);add(a[i-1][j],a[i][j]);
			if(tag[i][j]) add(ans,tag[i][j]*a[i][j]%p);
		};

	fac[1]=1;
	for(int i=2;i<=(N<<1);++i) fac[i]=fac[i-1]*i%p;
	ifac[N<<1]=fpm(fac[N<<1],p-2);
	for(int i=(N<<1)-1;i>=1;--i) ifac[i]=ifac[i+1]*(i+1)%p;
	
	ll tmp=0;
	for(int i=1;i<=n;++i) add(tmp,fac[2*(A[i]+B[i])]*ifac[2*A[i]]%p*ifac[2*B[i]]%p);
	add(ans,p-tmp);
	ans=ans*fpm(2,p-2)%p;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 190464
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9
import itertools

def main():
    n = int(input())
    D = list(map(int, input().split()))

    C = itertools.combinations(D, 2)
    ans = 0
    for c in C:
        ans += c[0]*c[1]

    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std;
void chmax(int& a, int b) { if (a < b) a = b; }

int main() {
    int n;
    cin >> n;
    vector<int> id(n), a(n), b(n);
    for (int& e : id) { cin >> e; e--; }
    for (int i = 0; i < n; i++) {
        a[i] = b[n-1-i] = (n+1) * (i+1);
    }
    
    int nin = 0;
    for (const int& i : id) {
        int d = max(0, nin+1 - (a[i] + b[i]));
        int pa = d/2, pb = d - pa;
        a[i] += pa; b[i] += pb;
        nin = a[i] + b[i];
    }
    
    for (int i = 0; i < n; i++) {
        cout << a[i] << (i+1 == n ? '\n' : ' ');
    }
    for (int i = 0; i < n; i++) {
        cout << b[i] << (i+1 == n ? '\n' : ' ');
    }
    return 0;
}

Measured memory_bytes: 896
#include<iostream>
 
#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
 
int main(int argsc, char* argsv[]){
    int n, k; scanf("%d%d", &n, &k);
    int m = ((n-1) * (n-2)) >> 1;
    if(m < k) puts("-1");
    else{
        printf("%d\n", (n-1)+m-k);
        for(int i = 2; i <= n; ++i) printf("1 %d\n", i);
        int l = 2, r = 3;
        REP(_, m-k){
            printf("%d %d\n", l, r);
            if(r++ == n){ r = ++l + 1; }
        }
    }
    return 0;
}

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

int gcd(int a, int b) {
    return (b == 0 ? a : gcd(b, a % b));
}

signed main() {
    int n, x;
    cin >> n >> x;
    vector <int> a(n);
    rep (i, n) cin >> a[i];

    /*
    if (n == 1) {
        cout << abs(a[0] - x) << endl;
        return 0;
    }
    */
    sort(a.begin(), a.end());
    x -= a.front();
    range (i, 1, n) a[i] -= a.front();
    a[0] = 0;

    int ans = 0;
    rep (i, n) ans = gcd(ans, a[i]);
    cout << abs(gcd(ans, x)) << endl;
    return 0;
}

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

//dp[i][j] = max a person can get from strones from i to  j

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

	if(n==0)
	{
		cout<<0;
		return 0;
	}
	if(n==1)
	{
		cout<<x[0];
		return 0;
	}
	vector<long long int> ab(n+1);
	vector<vector<long long int> > dp(n+1,ab);

	for(long long int i=1;i<n;i++)
		{
			dp[i][i]=x[i-1];
			
			if(x[i-1]>x[i])
				dp[i][i+1]=x[i-1];
			else
				dp[i][i+1]=x[i];
		}

	dp[0][0]=0;
	dp[n][n]=x[n-1];

	

	for(long long int len=2;len<=n;len++)
	{
		for(long long int i=1;i<=n-len;i++)
		{
			
			long long int j=i+len;	
			
			long long int a=min(dp[i+2][j],dp[i+1][j-1]) + x[i-1];
			long long int b=min(dp[i][j-2],dp[i+1][j-1]) + x[j-1];
			
			dp[i][j]=max(a,b);
		}
	}
	long long int a=dp[1][n];
	long long int b=min(dp[2][n],dp[1][n-1]);
	cout<<a-b;
	return 0;

}

Measured memory_bytes: 70784
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	llint m;cin>>m;
	llint ans=0;
	while(m--){
		llint d,c;cin>>d>>c;
		ans+=(d+9)*c;
	}
	cout<<(ans-10)/9<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,k = na()
p = na()
c = na()

s = set(range(n))

ans = 0
loops = []
while s:
    loop = [0]
    a = s.pop()
    while True:
        loop.append(loop[-1]+c[p[a]-1])
        if p[a]-1 not in s:
            break
        a = p[a]-1
        s.discard(a)
    loops.append(loop[1:])

ans = -1000000000000000
for tmp in loops:
    kk = k
    if k > len(tmp): kk = k%len(tmp)+len(tmp)
    loop = [0]+tmp+[tmp[-1]+u for u in tmp]+[tmp[-1]*2+u for u in tmp]
    x = -1000000000000
    for i in range(1,kk+1):
        for j in range(len(tmp)+1):
            x = max(x,loop[j+i]-loop[j])
    if k > len(tmp) and tmp[-1] > 0:
        x += tmp[-1]*(k//len(tmp)-1)
    ans = max(ans,x)

print(ans)

Measured memory_bytes: 69392
#include<bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int main(){
  int N, T;
  cin >> N >> T;
  int ans = inf;
  for(int i = 0; i < N; i++){
    int c, t;
    cin >> c >> t;
    if(t <= T) ans = min(ans, c);
  }
  if(ans == inf) cout << "TLE";
  else cout << ans;
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
      string str,fc,p;
      int q,i=0,a,b;
      cin>>str>>q;
      for(;i<q;i++){
            cin>>fc>>a>>b;
            switch(fc[2]){
                  case 'i':
                        cout<<str.substr(a,b-a+1)<<endl;
                        break;
                  case 'v':
                        p=str.substr(a,b-a+1);
                        reverse(p.begin(),p.end());
                        str.replace(a,b-a+1,p);
                        break;
                  case 'p':
                        cin>>p;
                        str.replace(a,b-a+1,p);
                        break;
            }
      }

}

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

int main() {
  int X, Y;
  cin >> X >> Y;
  bool can = false;
  for(int kame = 0; kame <= X; kame++){
    int legs;
    legs = kame * 4 + (X - kame) * 2;
    if(legs == Y){
      cout << "Yes" << endl;
      can = true;
      break;
    }
  }
  
  if(!can)
    cout << "No" << endl;
  
  
}



Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        try{
            int n = sc.nextInt();
            int[] a = new int[n];
            for(int i=0;i<a.length;i++){
                a[i]= sc.nextInt();
            }
            for(int i=a.length-1;i>=0;i--){
                if(i==a.length-1){
                    System.out.print(a[i]);
                }else{
                    System.out.print(" "+a[i]);
                }
            }
            System.out.println();
        }finally{
            sc.close();
        }
    }
    
}


Measured memory_bytes: 26356
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 2e5;

ll N;
vector<ll> a;
ll sum[100001];

bool judge(ll x) {
  ll size = a[x]+sum[x];
  FOR (i, x+1, N) {
    if (size*2 >= a[i]) {
      size += a[i];
    } else return false;
  }
  return true;
}

int main() {
  cin >> N;
  REP (i, N) {
    ll x;
    cin >> x;
    a.push_back(x);
  }

  sort(ALL(a));
  REP (i, N) sum[i+1] = sum[i]+a[i];

  ll lo = -1, hi = N-1;
  while (hi-lo > 1) {
    ll mid = (hi+lo)/2;
    if (judge(mid)) hi = mid;
    else lo = mid;
  }

  cout << N-hi << endl;

  return 0;
}

Measured memory_bytes: 1908
#include <stdio.h>

int main(){
    int n,m,l;
    
    scanf("%d %d %d",&n,&m,&l);
    
    int a[n][m],b[m][l];
    
    long long c[n][l];
    
    //aに入力
    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    
    //bに入力
    for(int i = 0;i < m;i++){
        for(int j = 0;j < l;j++){
            scanf("%d",&b[i][j]);
        }
    }
    
    //cの初期化
    for(int i = 0;i < n;i++){
        for(int j = 0;j < l;j++){
            c[i][j] = 0;
        }
    }
    
    //行列の積を計算
    for(int i = 0;i < n;i++){
        for(int j = 0;j < l;j++){
            for(int k = 0;k < m;k++){
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    
    //出力
    for(int i = 0;i < n;i++){
        for(int j = 0;j < l;j++){
            if(j != 0) {
                printf(" ");
            }
            printf("%lld",c[i][j]);
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2140
object MainKt {
  @JvmStatic fun main(args:Array<String>) {
    val (Q,H,S,D) = readLine()!!.split(" ").map(String::toLong)
    val N=readLine()!!.toLong()

    val equiv_value=arrayOf(Q,H,S,D).zip(arrayOf(8,4,2,1)).map {
      val (v,r)=it
      v*r
    }
    println(equiv_value.min()!!*(N/2)+if(N%2==0L) {0} else {equiv_value.slice(0..2).min()!!/2})
  }
}


Measured memory_bytes: 37900
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define NIL -1
using namespace std;
struct _Node {
	int parent;
	int left;
	int right;
};
_Node T[100001];
vector<long long> arr(87, 0);
int main(void)
{
	ios::sync_with_stdio(false);
	string a;
	cin >> a;
	int A = a[0] - 48, B = a[1] - 48, C = a[2] - 48, D = a[3] - 48;
	if (A + B - C - D == 7)
	{
		cout << A << "+" << B << "-" << C << "-" << D << "=7" << "\n";
	}
	else if (A + B + C - D == 7)
	{
		cout << A << "+" << B << "+" << C << "-" << D << "=7" << "\n";
	}
	else if (A + B + C + D == 7)
	{
		cout << A << "+" << B << "+" << C << "+" << D << "=7" << "\n";
	}
	else if (A + B - C + D == 7)
	{
		cout << A << "+" << B << "-" << C << "+" << D << "=7" << "\n";
	}
	else if (A - B - C - D == 7)
	{
		cout << A << "-" << B << "-" << C << "-" << D << "=7" << "\n";
	}
	else if (A - B + C - D == 7)
	{
		cout << A << "-" << B << "+" << C << "-" << D << "=7" << "\n";
	}
	else if (A - B + C + D == 7)
	{
		cout << A << "-" << B << "+" << C << "+" << D << "=7" << "\n";
	}
	else if (A - B - C + D == 7)
	{
		cout << A << "-" << B << "-" << C << "+" << D << "=7" << "\n";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main()
{
	int n;
	cin>>n;
	long long sum = 0;
	for(int i = 1;i <= n;i++){
		cin>>a[i];
		if(i > 1){
			if(a[i-1] > a[i]){
				sum += a[i-1] - a[i];
				a[i] = a[i-1];
			}
		}
	}
	printf("%lld\n",sum);
	return 0;
}

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

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define ll long long
#define OK puts("OK")
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 2e5+10;
const int inf = 1e9+7;

int n;
int a[N];
int ans[N];
pair <int, int> p[N];

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> p[i].fr;
        p[i].sc = i;

    }
    sort(p + 1, p + n + 1);
    for(int i = 1; i <= n; i++) {
        if(i > n / 2)
            ans[p[i].sc] = p[n / 2].fr;
        else
            ans[p[i].sc] = p[n / 2 + 1].fr;
    }
    for(int i = 1; i <= n; i++)
        cout << ans[i] << endl;
}


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

int main() {
  int64_t A, B, V, W, T ;
  cin >> A >> V ;
  cin >> B >> W ;
  cin >> T ;

  if (V <= W) {
    cout << "NO" << endl;
  } else {
    if (A < B) {
        if ((V-W)*T >= (B-A) ) {
          cout << "YES" << endl;
        } else {
          cout << "NO" << endl;
        }
    } else if (A > B) {
        if ((V-W)*T >= (A-B) ) {
          cout << "YES" << endl;
        } else {
          cout << "NO" << endl;
        }
    }
  }
}


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

  cin >> A >> B;

  if(A == 1 && B != 1){
    cout << "Alice";
  }else if(A != 1 && B == 1){
    cout << "Bob";
  }else if(A > B){
    cout << "Alice";
  }else if(A < B){
    cout << "Bob";
  }else if(A == B){
    cout << "Draw";
  }
}


Measured memory_bytes: 256
def main():
    from math import tan, radians
    a, b, x = (int(i) for i in input().split())

    def is_ok(d):
        if b*tan(radians(90-d)) <= a:
            area = tan(radians(90-d)) * b * b / 2.0
        else:
            area = tan(radians(d)) * a * a / 2.0
            area = a*b - area
        if x / a <= area:
            return True
        else:
            return False

    def binary_search_meguru():
        ok = 0.0
        ng = 90.0
        while abs(ng - ok) > 0.000001:
            mid = ok + (ng - ok) / 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok

    print(binary_search_meguru())


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
import java.io.*;
import java.util.*;
import java.awt.Point;
public class Main {
	static Scanner sc;
	static PrintWriter out;
	static final int uncal = -1;
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		sc = new Scanner(System.in); 
		out = new PrintWriter(System.out);
		int a = sc.nextInt(),b = sc.nextInt(), c = sc.nextInt();
		int t = a;
		a = b;
		b = t;
		t = a;
		a = c;
		c = t;
		out.printf("%d %d %d\n", a,b,c);
		out.close();
	}
	static void shuffle(int[] array) {
		Random rand = new Random();
		for (int i = 0; i < array.length; i++) {
			int randomIndexToSwap = rand.nextInt(array.length);
			int temp = array[randomIndexToSwap];
			array[randomIndexToSwap] = array[i];
			array[i] = temp;
		}
	}
	static boolean isPalindrome(String s) {
		int l = s.length();
		char[] sa = s.toCharArray();
		for(int i=0;i<l/2;i++) {
			if(sa[i] != sa[l-i-1])
				return false;
		}
		return true;
	}
	static class Point extends java.awt.Point implements Comparable<Point>{
		public Point(int x,int y) {
			// TODO Auto-generated constructor stub
			super(x,y);
		}
		public String toString() {
			return x+" "+y;
		}
		@Override
		public int compareTo(Point p) {
			// TODO Auto-generated method stub
			if(x == p.x)
				return y - p.y;
			return x - p.x;
		}
		
	}
	static class Scanner{
		private BufferedReader br;
		private StringTokenizer st;
		public Scanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		public Scanner(String filename) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(filename));
		}
		public String next() throws IOException{
			while(st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException{
			return Long.parseLong(next());
		}
		public double nextDouble() throws IOException{
			return Double.parseDouble(next());
		}
		public int[] inArr(int n) throws Exception{
			int a [] = new int[n];
			st = new StringTokenizer(br.readLine());
			for(int i=0;i<n;i++) {
				a[i] = Integer.parseInt(st.nextToken());
			}
			return a;
		}
	}

}

Measured memory_bytes: 21332
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

const double PI = acos(-1);

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double m_ang = (double)m / 60 * 2 * PI;
    double h_ang = (double)(h * 60 + m)/720 * 2 * PI;
    double m_x = b * cos(m_ang);
    double m_y = b * sin(m_ang);
    double h_x = a * cos(h_ang);
    double h_y = a * sin(h_ang);
    double dist = sqrt((m_x - h_x) * (m_x - h_x) + (m_y - h_y) * (m_y - h_y));
    printf("%.10lf\n", dist);
    return 0;
}


Measured memory_bytes: 4072
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d,x,s=0,k=0;
    cin>>n>>d>>x;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<100;j++)
        {
            if((a[i]*j)+1<=d)
            {
                k++;
            }
            else{
               break;
            }
        }
        s=s+k;
        k=0;
    }
    cout<<s+n+x;
    return 0;
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n;
	cin >> n;
	
	vi v(n);
	for(auto& el : v) cin >> el;
	
	SORT(v);
	
	int mid = n / 2;
	
	dier(v[mid] - v[mid - 1]);
	
	
	
	return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

void reader(int &a) { scanf("%d", &a); }
void reader(double &a) { scanf("%lf", &a); }
void reader(char a[]) { scanf("%s", a); }
void reader(char &a) { scanf(" %c", &a); }
void reader(ll &a) { scanf("%lld", &a); }
void reader(ull &a) { scanf("%llu", &a); }
// void reader(string& a){cin >> a;};
template<class T, class U> void reader(T& t, U& u) { reader(t); reader(u); }
template<class T, class U, class V> void reader(T& t, U& u, V& v) { reader(t); reader(u); reader(v); }

void writer(const int a, char c) { printf("%d", a); putchar(c); }
void writer(const ll a, char c) { printf("%lld", a); putchar(c); }
void writer(const ull a, char c) { printf("%llu", a); putchar(c); }
void writer(const double a, char c) { printf("%.20lf", a); putchar(c); }
void writer(const char a[]) { printf("%s", a); };
void writer(const char a[], char c) { printf("%s", a); putchar(c); };
void writer(const char a, char c) { putchar(a); putchar(c); };
template<class T> void writerLn(T t) { writer(t, '\n'); }
template<class T, class U> void writerLn(T t, U u) { writer(t, ' '); writer(u, '\n'); }
template<class T, class U, class V> void writerLn(T t, U u, V v) { writer(t, ' '); writer(u, ' '); writer(v, '\n'); }
template<class T> void writerArr(T x[], int n) { int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }
template<class T> void writerVec(vector<T> x) { int n = x.size(); int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }

vector<string> split(const string &str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) { v.push_back(buffer); }return v; }
// #define int ll
bool test = 1;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define MAX 300000
//.....................
ull mod = (int)1e9 + 7;

signed main(void)
{
	while (1) {
		int x, y, s;
		cin >> x >> y >> s;
		if (x == 0) return 0;
		int ans = 0;
		REP(i,1,s) {
			REP(j,1,s + 1 - i) {
				if (i*(100 + x) / 100
					+ j*(100 + x) / 100
					== s) {
					int tmp = i*(100 + y) / 100
						+ j*(100 + y) / 100;
					if (tmp > ans) ans = tmp;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
  int n; cin >> n;
  vector<int> in;

  int min,ans= -1000000000;
  cin >> min;
  for(int i=0; i<n-1; i++){
    int a; cin >> a;
    if(ans < a - min) ans = a - min;
    if(min > a) min = a;
  }
  cout << ans << "\n";

}

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

const ll INF = 1001001001001001001;

int main(){
  vector<ll> a(2), b(2);
  rep(i,2) cin >> a[i];
  rep(i,2) cin >> b[i];
  ll ans = -INF;
  rep(i,2) {
    rep(j,2) {
      ll d = a[i] * b[j];
      ans = max(ans, d);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int N, M; 
    cin >> N >> M;

    int ans=0;
    ans=N*(N-1)/2+M*(M-1)/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3556
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define ll long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12

int main(void)
{
	//変数の宣言
	char s[15];
	
	//データの読み込み
	
	scanf("%s",&s);
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	
//	printf("計算部分終了\n");
	
	//出力
	
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){	
		printf("Yes");
	}else{
		printf("No");
	}
	
	
	//('・ω・'）
	
//	printf("結果の出力終了\n");
	
	return 0;
}



Measured memory_bytes: 128
char buf[1800000],f[5];
sz,osz;
#define rd(x)x=0;for(;;){k=buf[sz++];if(k<'0')break;x=x*10+k-'0';}
#define min(a,b)a<b?a:b
N,M,L,Q;
D[301][301];
i,j,k;
a,b,c;
main()
{
	read(0,buf,1800000);
	rd(N);rd(M);rd(L);
	for(i=0;i<N;i++)for(j=0;j<N;j++)D[i][j]=1000000001;
	for(i=0;i<M;i++)
	{
		rd(a);rd(b);rd(c);
		--a;
		--b;
		D[a][b]=D[b][a]=c;
	}
	for(k=0;k<N;k++)for(i=0;i<N;i++)for(j=0;j<N;j++)
		D[i][j]=min(D[i][j],D[i][k]+D[k][j]);
	for(i=0;i<N;i++)for(j=0;j<N;j++)D[i][j]=D[i][j]>L?1000000000:1;
	for(k=0;k<N;k++)for(i=0;i<N;i++)for(j=0;j<N;j++)
		D[i][j]=min(D[i][j],D[i][k]+D[k][j]);
	rd(Q);
	for(i=0;i<Q;i++)
	{
		rd(a);rd(b);
		--a;
		--b;
		if(D[a][b]<1000000000)
		{
			c=D[a][b]-1;
			k=0;
			do{
				f[k++]=c%10+'0';
				c/=10;
			}while(c);
			for(;k--;)buf[osz++]=f[k];
		}
		else buf[osz++]='-',buf[osz++]='1';
		buf[osz++]='\n';
	}
	write(1,buf,osz);
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){
    ll n,k;cin>>n>>k;
    ll ans=0;
    ll x;
    ll an;
    if(k==0){
        cout<<n*n<<endl;
        return 0;
    }
    
    rep(b,k+1,n){
        an=ans;
        ans+=(n/b)*(b-k);
        x=n-(n/b)*b;
        if(x>=k)ans+=(x-(k-1));
        
    }
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
	#define hell                         1000000007 
	#define M                            1000000007
	#define Maxi                      10000000000000000
	#define lcm(a,b)                     (a*b)/__gcd(a,b)
	#define ll                           long long

	#define vll                          vector<ll>
	#define vi                           vector<long long>
	#define pll                          vector< pair<ll,ll> >
	#define pb                           push_back
	//#define mp                           make_pair
	#define all(v)                       v.begin(),v.end()
	#define lbnd                         lower_bound
	#define ubnd                         upper_bound
	#define bs                           binary_search
	#define F                            first
	#define S                            second
	#define rep(i,a,b)                   for(i=a;i<b;i++)
	#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
	#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
	#define ret(x)                       return cout<<x,0;
	#define dbg(x)                       cout << #x << " is " << x << endl;
	//#define endl                           '\n'


	// Debug //

	#define trace(x)                 cerr << #x << ": " << x << endl;
	#define trace1(x)                cerr << #x << ": " << x << endl;
	#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
	#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
	#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
	#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
	#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;


	using namespace std;
	

	
	int main()
	{

	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);cout.tie(NULL);
		

		
		
		string s1,s2;
		cin>>s1>>s2;
		int i,j;
		i=0;
		j=0;
		int ans=0;
		while(i<3)
		{
			if(s1[i]==s2[i])
			{
				ans++;
				i++;
			}
			else
			{
				i++;
			}

		}
		cout<<ans<<endl;
		return 0;
		}
	











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

int main(){
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  
  for(int i = 0; i < n; i++) {
  	cin >> p.at(i);
  }
  
  for(int i = 0; i < n;i++) {
  	q.at(i) = p.at(i);
  }
  sort(q.begin(), q.end());
  
  int count = 0;
  
  for(int i = 0; i < n; i++) {
  	if(p.at(i) != q.at(i)){
    	count++;
    }
  }
  if(count == 0 || count == 2){
  	cout << "YES" << endl;
  }
  else{
  	cout << "NO" << endl;
  }
}


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

void solve() {
    int n;
    cin >> n;
    int prev = 1e9 + 1, cur;
    int curlen = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> cur;
        if (prev >= cur)
            curlen++;
        else
            curlen = 1;
        ans = max(ans, curlen);
        prev = cur;
    }
    cout << ans - 1;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_f
#include <bits/stdc++.h>
using namespace std;

string longer(string const& a, string const& b) {
  if (a.length() < b.length())
    return b;
  return a;
}

int main() {
  string s, t;
  cin >> s >> t;
  string lcs[2][t.length() + 1];

  for (int i = 1; i <= s.length() + 1; ++i)
    for (int j = 1; j <= t.length(); ++j) {
      lcs[i % 2][j] = longer(lcs[i % 2][j - 1], lcs[(i + 1) % 2][j]); 
      if (s[i - 1] == t[j - 1])
        lcs[i % 2][j] = lcs[(i + 1) % 2][j - 1] + s[i - 1];
    }
      
  cout << lcs[1][t.length()] << endl;
}


Measured memory_bytes: 18644
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
using namespace std;
const int MAX = 1e9 + 10;
const ll MOD = 1e9 + 7;
int N, M, K, Q;
vector<ll> vals[4];
ll pvals[4][110];
ll W;

int main()
{
	ll i, j, k, p;

	scanf("%d%lld", &N, &W);
	ll w, v, offset;
	for (i = 0; i < N; ++i) {
		scanf("%lld%lld", &w, &v);
		if (i == 0) {
			offset = w;
			vals[w - offset].push_back(v);
			continue;
		}
		vals[w - offset].push_back(v);
	}
	for (i = 0; i < 4; ++i) {
		int sz = vals[i].size();
		sort(vals[i].begin(), vals[i].end());
		reverse(vals[i].begin(), vals[i].end());
		pvals[i][0] = 0LL;
		for (j = 1; j <= sz; ++j) {
			pvals[i][j] = pvals[i][j - 1] + vals[i][j - 1];
		}
	}

	ll maxi = 0LL;
	for (i = 0; i <= N && i <= vals[0].size(); ++i) {
		for (j = 0; i + j <= N && j <= vals[1].size(); ++j) {
			for (k = 0; i + j + k <= N && k <= vals[2].size(); ++k) {
				for (p = 0; i + j + k + p <= N && p <= vals[3].size(); ++p) {
					if (i*offset + j * (offset + 1) + k * (offset + 2) + p * (offset + 3) <= W) {
						maxi = max(maxi, pvals[0][i] + pvals[1][j] + pvals[2][k] + pvals[3][p]);
					}
				}
			}
		}
	}
	printf("%lld", maxi);

}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc060/tasks/abc060_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a, b, c;
    cin >> a >> b >> c;
    if (a.back() == b.front() && b.back() == c.front()) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<math.h>
using namespace std;

string input;

string lists[4] = {
    "dreamer"
    ,"dream"
    ,"erase"
    ,"eraser"
};

bool is_found = false;

void func( int index )
{
    for( int i = 0; i < 4; ++i )
    {
        int result = input.find( lists[i], index );
        if( result == index )
        {
            int next_index = index + lists[i].length();
            if( next_index == input.length() ) {
                is_found = true;
                return;
            }
            else
            {
                func( next_index );
            }
        }
    }
}

int main()
{
    cin >> input;
    
    int index = 0;
    func( index );
    if( is_found ) cout << "YES" << endl;
    else cout << "NO" << endl;

    /* cout << input.find( "erasera", 5 ) << endl; */
}




Measured memory_bytes: 1600