akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define LL 					long long
#define ULL 				unsigned long long
#define pii 				pair<int,int>
#define fi 					first
#define se 					second
#define vi 					vector<int>
#define psb 				push_back
#define ppb 				pop_back
#define all(x)			 	(x).begin(),(x).end()
#define sz(x)				(int)(x).size()
#define endln 				printf("\n")
#define gc					getchar_unlocked
#define setmin(x)			memset((x), -1, sizeof((x)))
#define setnul(x)			memset((x), 0, sizeof((x)))
#ifndef getchar_unlocked
#define getchar_unlocked 	getchar
#endif
const int inf = 1e9 + 5;
const int mod = 1e9 + 7;

template <typename T>
void gi(T &ret) {
	ret = 0; char inp=gc(); int kl=1;
	while (inp<'0' || inp>'9') {if (inp=='-') kl=-1; inp=gc();}
	while ('0'<=inp && inp<='9') ret=(ret<<3)+(ret<<1)+(inp-'0'), inp=gc();
	if (kl<1) ret=-ret;
}

const int MAXN = 1e5+5;
int n, ans = 0, root = 0;
vi adj[MAXN];

int dfs (int now, int par) {
	int ch = 0, dpt = 0;
	for (auto nex : adj[now]) {
		if (nex==par) continue;
		dpt += dfs (nex,now);
		ch++;
	}
	ch--;
	if (ch) {
		if (dpt<ch) {
			ans += ch-dpt;
			dpt = ch;
		}
	} else if (now==root) ans++;
	if (dpt) return 1;
	else return 0;
}

int main() {
	gi(n);
	for (int i=1; i<n; i++) {
		int a,b; gi(a); gi(b);
		adj[a].psb(b);
		adj[b].psb(a);
	}
	for (int i=0; i<n; i++) if (sz(adj[i])>2) root = i;
	dfs (root,-1);
	printf ("%d\n", ans);
	return 0;
}



Measured memory_bytes: 11904
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int A = 0, B = 0;
	int a1, a2, a3, ans;
	scanf("%d %d", &A, &B);
	a1 = A + B;
	a2 = A - B;
	a3 = A * B;
	if (a1 > a2) {
		if (a1 > a3) {
			ans = a1;
		} else {
			ans = a3;
		}
	} else {
		if (a2 > a3) {
			ans = a2;
		} else {
			ans = a3;
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll N;

int main(){
  cin>>N;
  repl(h,1,3501)repl(w,1,3501){
    ll t=4*h*w-N*w-N*h;
    if(t>0&&h*N*w%t==0&&(h*N*w/t)>=1&&(h*N*w/t)<=3500){
      cout<<h<<" "<<w<<" "<<h*N*w/t<<endl;
      return 0;
    }
  }
	return 0;
}


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

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

    int sum=0;
    int tmp=n;
    while(tmp>0){
        sum+=(tmp%10);
        tmp/=10;
    }
    if(n%sum==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int X,t;
	cin>>X>>t;
	ce(max(X-t,0))
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    ll K, A, B;
    cin >> K >> A >> B;
    if(B <= A + 2) {
        cout << 1 + K << endl;
        return 0;
    }
    if(K + 1 <= A) {
        cout << 1 + K << endl;
        return 0;
    }
    K -= (A - 1);
    ll ans = A;
    if(K % 2 == 1) {
        K--;
        ans++;
    }
    ans += (K / 2) * (B - A);
    cout << ans << endl;
    return 0;
}


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

using ll=long long;
const ll MOD=998244353;

const int SIZE=5000;
ll dp[SIZE][SIZE];
ll p2[SIZE];
ll comb(ll n,ll k){
    return dp[n][k];    
}
ll pow2(ll x){
    return p2[x];
}
ll g(int n,int k){
    if(n<0) return 0;
    if(n+k-1<n) return 0;
    return comb(n+k-1,n);
}
ll f(int n,int p,int k){
    if(n<0 || p<0 || k<0) return 0;
    ll res=0;
    for(int i=0;i<=p;i++){
        res+=pow2(i)*comb(p,i)%MOD*g(n-i,k+i)%MOD;
        res%=MOD;
    }
    return res;
}
void init(){
    for(int i=0;i<SIZE;i++){
        dp[i][i]=1;
        dp[i][0]=1;
    }
    for(int i=2;i<SIZE;i++){
        for(int j=1;j<i;j++){
            dp[i][j]=(dp[i-1][j]+dp[i-1][j-1])%MOD;
        }
    }
    p2[0]=1;
    for(int i=0;i+1<SIZE;i++){
        p2[i+1]=p2[i]*2%MOD;
    }
}
int main(){
    init();
    int k,n;
    cin>>k>>n;
    for(int i=2;i<=2*k;i++){
        if(i%2==0){
            int c=min(i/2-1,k-i/2);
            ll v0=f(n-1,c,k-1-2*c);
            ll v1=f(n,c,k-1-2*c);
            cout<<(v0+v1)%MOD<<endl;
        }
        else{
            int c=min((i-1)/2,k-(i-1)/2);
            ll v0=f(n,c,k-2*c);
            cout<<v0<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 193792
/**
 * @author karayuu
 */
fun main(args: Array<String>) {
    val (a, b, c, d) = readLine()!!.split(" ").map { it.toInt() }


    fun canTalk(a: Int, c: Int, d: Int): Boolean {
        return Math.abs(a - c) <= d
    }

    fun canTalkByQSY(a: Int, b: Int, c: Int, d: Int): Boolean {
        return canTalk(a, b, d) && canTalk(b, c, d)
    }

    if (canTalk(a, c, d) || canTalkByQSY(a, b, c, d)) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 37948
def main():
    N = list(map(int, input().split()))
    ans = [False]*4
    for n in N:
        if n == 1:
            ans[0] = True
        elif n == 9:
            ans[1] = True
        elif n == 7:
            ans[2] = True
        elif n == 4:
            ans[3] = True
    if all(ans):
        print("YES")
    else:
        print("NO")

    return 0

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
   int n,m;
   int item[1000];
   while(cin>>n>>m,n){
       int sum=0;
       for(int i=0;i<n;i++){
           cin>>item[i];
           sum+=item[i];
       }
       sort(item,item+n);
       for(int i=n-m;i>=0;i-=m) sum-=item[i];
       cout<<sum<<endl;
   }
    return 0;
}


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

main()
{
	int n; cin >> n; int a[n][3];
	for(int i=0;i<n;i++)
	{
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	
	
	
	
	int dp[n][3];
	dp[0][0]=a[0][0]; dp[0][1]=a[0][1]; dp[0][2]=a[0][2];
	
	for(int i=1;i<n;i++)
	{
		dp[i][0]= a[i][0] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]= a[i][1] + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]= a[i][2] + max(dp[i-1][0],dp[i-1][1]);
	}
	
	
	cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << endl;
}

Measured memory_bytes: 2560
H, W = map(int, input().split())
now = 0
for _ in range(H):
    A = input()
    for i in range(W):
        a = A[i]
        if a == "#":
            if i < now:
                print("Impossible")
                exit()
            now = i
        else:
            if i == now:
                print("Impossible")
                exit()
print("Possible")

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

int main() {
  int n,m;
  ll a,s=0;
  cin >> n >> m;

  rep(i,m) {
    cin >> a;
    s += a;
  }
  if (n-s>=0)  cout << n-s << endl;
  else cout << "-1" << endl;
  return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;
 
public class Main
{
 
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
double r = scan.nextDouble();
double pai=3.141592653589;
double men =r*r*pai;
double naga= r*2*pai;

  System.out.println(String.format("%.6f", men)+" "+String.format("%.6f", naga));
}
}



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

typedef long long ll;


int main(){
    int N, M;
    cin >>N >> M;
    int ans = N;
    int min_m = 1000;
    for(int i = 0; i < N; i++){
        int m;
        cin >> m;
        M -= m;
        if(m < min_m){
            min_m = m;
        }
    }
    ans += M / min_m;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int cunt=0;
string s;
int main()
{
    cin >> s;
   // cout << s.length();
    for(int i=0,j=s.length()-1;i<s.length()/2;i++,j--){
            if(s[i]!=s[j]){
                cunt++;
                //cout << s[i] << endl;
            }
    }
    cout << cunt;
    return 0;
}


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

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

const int INF = 1 << 30;

int main(void) {
	char c;
	cin >> c;

	if (c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,a[100],ans=0;

int main()
{
	cin>>n;
	rep(i,n) cin>>a[i];
	rep(i,n)
	{
		bool ok=true;
		for(int j=0;j<i;j++) if(a[j]>a[i]) ok=false;
		if(ok) ans++;
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 256
class ModComb
  def initialize(max, mod)
    @mod = mod
    @fac = Array.new(max + 1)
    @finv = Array.new(max + 1)
    @inv = Array.new(max + 1)
    @fac[0] = @fac[1] = 1
    @finv[0] = @finv[1] = 1
    @inv[1] = 1
    (2..max).each do |i|
      @fac[i] = @fac[i - 1] * i % @mod
      @inv[i] = @mod - @inv[@mod % i] * (@mod / i) % @mod
      @finv[i] = @finv[i - 1] * @inv[i] % @mod
    end
  end

  def comb(n, k)
    return 0 if n < k
    return 0 if n < 0 || k < 0
    @fac[n] * (@finv[k] * @finv[n - k] % @mod) % @mod
  end
end

require 'prime'

N = gets.to_i

n = (1..N).reduce(:*)
# [3, 5, 5], [15, 5], [3, 25], [75]
es = n.prime_division.map { |_, e| e }
count3 = es.count { |e| e >= 3 - 1 }
count5 = es.count { |e| e >= 5 - 1 }
count15 = es.count { |e| e >= 15 - 1 }
count25 = es.count { |e| e >= 25 - 1 }
count75 = es.count { |e| e >= 75 - 1 }
ans = 0
comb = ModComb.new(1000, 10 ** 9 + 7)
ans += comb.comb(count5, 2) * comb.comb(count3 - 2, 1)
ans += comb.comb(count15, 1) * comb.comb(count5 - 1, 1)
ans += comb.comb(count25, 1) * comb.comb(count3 - 1, 1)
ans += comb.comb(count75, 1)
puts ans


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

int main()
{
	int n,m;
	cin>>n>>m;
	vector<int> a(n);
	int asum = 0;
	for(size_t i = 0; i<n; i++)
	{
		cin>>a[i];
		asum += a[i];
	}
	sort(a.begin(),a.end());
	if((a[n-m]*4*m)<asum)
	{
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>

// ref : https://img.atcoder.jp/abc123/editorial.pdf
using ll = long long;

int main(){
    ll n, cap[5];
    std::cin >> n;
    ll minCap = 1e15;
    for(int i = 0; i < 5; i++){
        std::cin >> cap[i];
        minCap = std::min(minCap, cap[i]);
    }

    ll ans = 4; // (i - 1) + (5 - 1)
    if(n % minCap == 0) ans += n / minCap;
    else ans += n / minCap + 1;

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


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

using namespace std;
int main(){
    int n;cin>>n;
    string s;cin>>s;
    vector<ll> cnt(3);
    rep(i,n){
        if(s[i]=='R') cnt[0]++;
        else if(s[i]=='G') cnt[1]++;
        else cnt[2]++;
    }

    ll ans =cnt[0]*cnt[1]*cnt[2];
    rep(j,n){
        rep(i,j){
            int k=2*j-i;
            if(k<n){
                if(s[i]==s[j]) continue;
                if(s[j]==s[k]) continue;
                if(s[i]==s[k]) continue;
                ans--;
            }
        }
    }
    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 3628
if __name__ == '__main__':
    mountain_count = int(input())
    mountains = list(map(int, input().split()))
    ans = 0
    for i in range(mountain_count):
        can_watch = True
        for j in range(mountain_count):
            if i == j:
                break
            if mountains[i] < mountains[j]:
                can_watch = False
                break
        if can_watch:
            ans += 1
    print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
typedef long long ll;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
const int nINF = 1<<31;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

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

const int N = 1e5+10;
int n, k, h[N];
ll dp[N];

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    fill(dp, dp+N, INF);
    dp[1] = 0;
    cin >> n >> k;
    FOR(i, 1, n) cin >> h[i];
    FOR(i, 1, n) {
    	FOR(j, 1, k) {
    		if(i+j > n) break;
    		dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]));
    	}
    }
    cout << dp[n] << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE)
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - integer division (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting min to 0 instead of -INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)


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

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
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; }

int x, a, b;

int main() {
    cin >> x >> a >> b;
    if(a+x >= b) {
        if(a >= b) {
            cout << "delicious" << endl;
        }else {
            cout << "safe" << endl;
        }
    }else {
        cout << "dangerous" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int bucket[24 * 60];
 
int main()
{
    int n;
    int cnt = 0;
 
    scanf("%d", &n);
 
    for (int i = 0; i < n; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        bucket[a * 60 + b]++;
        if (bucket[a * 60 + b] == 1) cnt++;
    }
 
    scanf("%d", &n);
 
    for (int i = 0; i < n; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        bucket[a * 60 + b]++;
        if (bucket[a * 60 + b] == 1) cnt++;
    }
 
    for (int i = 0; i < 24 * 60; i++){
        if (bucket[i]){
            printf("%d:%02d", i / 60, i % 60);
            if (--cnt) printf(" ");
            else printf("\n");
        }
    }
 
    return (0);
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int N, K;
  cin >> N >> K;
  int a, b;
  ll cnt = 0;
  for (b = 1; b <= N; b++) {
    int p = N / b;
    int r = N % b;
    cnt += (ll)max(b - K, 0) * p + max(r - K + 1, 0);
    if (K == 0) cnt -= 1; // if a == 0 && K == 0 then do not count
  }
  cout << cnt << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 384
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let s: String = read();
    // vec化
    let s_vec: Vec<char> = s.chars().collect();
    let mut count: u32 = 0;

    for i in 0..(s_vec.len() / 2) as usize
    {
        if s_vec[i] != s_vec[s_vec.len() - 1 - i] { count += 1; }
    }

    println!("{}", count);
}


Measured memory_bytes: 4352
# https://atcoder.jp/contests/abc149/submissions/9219994
  
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# 価値 x 以上の握手を全て行うとする
# 握手回数が決まる。左手ごとに集計できる。

import numpy as np

N,M = map(int,readline().split())
A = np.array(read().split(),np.int64)

A.sort()

def shake_cnt(x):
    # x 以上の握手を全て行うとして、握手の回数を数える
    # 行わない握手を数える
    X = np.searchsorted(A,x-A)
    return N * N - X.sum()

left = 0 # 握手の回数がM以上
right = 10 ** 6 # 握手の回数がM未満
while left + 1 < right:
    x = (left + right) // 2
    if shake_cnt(x) >= M:
        left = x
    else:
        right = x

left,right

# right 以上の握手を全て行ったとして、回数と総和を計算

X = np.searchsorted(A,right-A) # 行わない人数
Acum = np.zeros(N+1,np.int64) # 人数 -> 累積和
Acum[1:] = np.cumsum(A)

shake = N * N - X.sum()
happy = (Acum[-1] - Acum[X]).sum() + (A * (N - X)).sum()

happy += (M - shake) *left
print(happy)


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

int main() {
	int a,b,c,k;
	cin>>a>>b>>c;
	cin>>k;
	int cnt=0;
	while(a>=b){
		b=b*2;
		cnt++;
	}
	while(b>=c){
		c=c*2;
		cnt++;
	}
	if (cnt<=k){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
int main()
{
	int a, b;
	std::cin >> a >> b;
	if (a < b)
		std::cout << "a < b\n";
	else if (a > b)
		std::cout << "a > b\n";
	else
		std::cout << "a == b\n";
	return 0;
}



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

using namespace std;

pair<int, int> select_subarray(vector<int> &arr) {
    int start = -1;
    int end = -1;
    int size = arr.size();
    for (int i = 0; i < size; i++) {
        if (start == -1 && arr[i] > 0) {
            start = i;
            end = start;
        }
        if (start != -1 && arr[i] != 0) {
            end++;
        }
        if (start != -1 && arr[i] == 0) {
            break;
        }
    }

    return make_pair(start, end);
}

int main(int argc, char *argv[]) {
    int N;
    cin >> N;

    vector<int> arr;
    int cur;
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> cur;
        arr.push_back(cur);
        sum += cur;
    }

    int ans = 0;
    while (sum > 0) {
        pair<int, int> p = select_subarray(arr);
        int start = p.first;
        int end = p.second;

        int subarray_min = arr[start];
        for (int k = start; k < end; k++) {
            if (arr[k] <= subarray_min) {
                subarray_min = arr[k];
            }
        }
        for (int j = start; j < end; j++) {
            arr[j] -= subarray_min;
            sum -= subarray_min;
        } 
        if (start == end) {
            arr[start] -= subarray_min;
            sum -= subarray_min;
        }

        ans += subarray_min;
    }

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	int A, B;
	int ans = 0;
	int s = 0;

	cin >> A >> B;

	if (B == 1) {
		cout << 0 << endl;
		return 0;
	}

	s = A;
	ans = 1;
	while (true) {
		if (s >= B) {
			break;
		}
		s = s - 1 + A;
		ans++;
	}

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


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public void Run()
        {
            int[] A3 = new int[] { 2, 5, 63 };
            int[] A4 = new int[] { 2, 5, 20, 63 };
            int[,] V = new int[,]
            {
                { 0, 0,0,0,0,0,0,0 },
                { 6, 0,0,0,0,0,0,0 },
                { 2, 4,0,0,0,0,0,0 },
                { 2, 4,6,0,0,0,0,0 },
                { 2, 4,6,12,0,0,0,0 },
                { 2, 3,4,6,9,0,0,0 },
                { 2, 3,4,8,9,10,0,0 },
                { 2, 3,4,6,8,9,10,0 },
                { 2, 3,4,6,8,9,10,12 }
            };

            N = Input.ReadInt();
            if (N == 3)
            {
                Console.WriteLine(string.Join(" ", A3));
            }
            else if (N == 4)
            {
                Console.WriteLine(string.Join(" ", A4));
            }
            else
            {
                List<int> ret = new List<int>();
                int M = N % 8;
                int C = N / 8;
                for (int i = 0; i < C; i++)
                {
                    for(int j = 0; j < 8; j++)
                        ret.Add(V[8, j] + 12 * i);
                }

                {
                    for (int j = 0; j < 8; j++)
                    {
                        int v = V[M, j];
                        if (v != 0)
                            ret.Add(v + 12 * C);
                    }
                }

                Console.WriteLine(string.Join(" ", ret));   
            }
        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 14048
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
int n, A[102];
int main()
{
	cin >> n;
	loop(i, 0, n)cin >> A[i];
	int ans = 0;
	sort(A, A + n);
	set<pair<pair<int, int>, int>>s;
	loop(i, 0, n)
	{
		loop(j, i + 1, n)
		{
			loop(k, j + 1, n)
			{
				if (A[i] + A[j] > A[k] and A[j] + A[k] > A[i] and A[i] + A[k] > A[j] and A[i]!=A[j] and A[j]!=A[k] and A[i]!=A[k])ans++;
			}
		}
	}
	///for (auto it : s)cout << it.first.first<<","<<it.first.second<<","<<it.second << " ";
	cout << ans;
}

Measured memory_bytes: 3608
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 30
#define MAX_LINE 2000000
#define MAX_HUMAN 200000

char sLongInputLine[MAX_LINE+1]="";
int  anComingSec[MAX_HUMAN];

int main() {

	char sInput[MAX_STRING+1]="";
	char* psWord=NULL;
	char* psInput=NULL;

	int nHumanNumber=0;
	int nNextHumanIndex=0;
	int nWaterLength=0;
	int nWaterLife=0;
	int nStart=0;
	int nStop=0;

	int nIndex=0;
	int i=0;
	int j=0;

	// read line 1
	fgets(sInput,MAX_STRING,stdin);
	if (strchr(sInput, '\n') != NULL) {
	    sInput[strlen(sInput) - 1] = '\0';
	}
	psInput = strtok(sInput, " ");
	nHumanNumber = atoi(psInput);
	psInput = strtok(NULL, " ");
	nWaterLength = atoi(psInput);

	fgets(sLongInputLine,MAX_LINE,stdin);
	if (strchr(sLongInputLine, '\n') != NULL) {
		sLongInputLine[strlen(sLongInputLine) - 1] = '\0';
	}
	psInput = strtok(sLongInputLine, " ");
	for (i=0;i<nHumanNumber;i++){
		anComingSec[i]=atoi(psInput);
		psInput = strtok(NULL, " ");
	}

	nStart = anComingSec[0];

	while(nNextHumanIndex<nHumanNumber){
		if (nNextHumanIndex == nHumanNumber){
			break;
		} else {
			nStop=nStart+nWaterLength;
			if (anComingSec[nNextHumanIndex]<nStop){
				while(nNextHumanIndex<nHumanNumber && anComingSec[nNextHumanIndex] < nStop){
					if (nStop <= anComingSec[nNextHumanIndex]+nWaterLength){
						nStop = anComingSec[nNextHumanIndex]+nWaterLength;
						nNextHumanIndex++;
					}
				}
				if (nNextHumanIndex == nHumanNumber){
					nWaterLife = nWaterLife + (nStop-nStart);
					break;
				}
			}
			nWaterLife = nWaterLife + (nStop-nStart);
			nStart=nStop;
			if (nStart<anComingSec[nNextHumanIndex]){
				nStart=anComingSec[nNextHumanIndex];
			}
		}
	}
	printf("%d\n",nWaterLife);

	return 0;

}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <map>

using namespace std;

int main(){
  int i,j,k,n,m;
  string s;
  cin >> s;
  if(s[0]=='1')s[0]='9';
  else if(s[0]=='9')s[0]='1';
  if(s[1]=='1')s[1]='9';
  else if(s[1]=='9')s[1]='1';
  if(s[2]=='1')s[2]='9';
  else if(s[2]=='9')s[2]='1';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define w(t) ll t;cin>>t; while(t--)
ll ks(ll  n, ll W, ll w[], ll v[])
{
  ll i,j;
  ll k[n+1][W+1];
  for(i=0;i<=n;i++)
  {
    for(j=0;j<=W;j++)
    {
      if(i==0 || j==0)
      k[i][j]=0;
      else if(w[i-1]<=j)
      
        k[i][j]=max(v[i-1]+k[i-1][j-w[i-1]],
          k[i-1][j]);
      
          else
          k[i][j]=k[i-1][j];
      }
    }
    return k[n][W];
  
}
int main()
{

 // w(t)
  //{
    
     ll n,x,y,W,i,j,z=0,k=0,c=0,s=0;
    cin>>n>>W;
    ll w[n],v[n];
   // map<ll,ll>mp;
    for(i=0;i<n;i++)
    {
      cin>>w[i]>>v[i];
     // cout<<w[i]<<v[i];
    }
    cout<<ks(n,W,w,v)<<endl;
    
}      
      
 //   
  //  cout<<a[i]<<b[j];
    

/*if(flag==1)
    cout<<"NO"<<endl;
    else
    cout<<"YES"<<endl;*/
    
    
    
  
 


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

int main() {
  int N;
  cin>>N;
  int k;
  int ans=0;
  std::vector<int> v(100001,0);
  for(int i=0;i<N;i++){
    cin>>k;
    if(k>100000)ans++;
    else v[k]++;
  }
  for(int i=0;i<100001;i++){
    if(v[i]>i)ans+=v[i]-i;
    if(v[i]<i)ans+=v[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
using System;
using System.Linq;

class C
{
	static void Main()
	{
		Console.ReadLine();
		Console.WriteLine(Console.ReadLine().Split().Select(int.Parse).Aggregate((x, y) => Gcd(x, y)));
	}

	static int Gcd(int x, int y) { for (int r; (r = x % y) > 0; x = y, y = r) ; return y; }
}


Measured memory_bytes: 18272
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int D;
    cin >> D;
    
    if (D == 25) {
        cout << "Christmas" << "\n";
    } else if (D == 24) {
        cout << "Christmas Eve" << "\n";
    } else if (D == 23) {
        cout << "Christmas Eve Eve" << "\n";
    } else {
        cout << "Christmas Eve Eve Eve" << "\n";
    }
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
        int w, h, x, y, r;
        scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
        if((x>=-100 && x<=100) && (y>=-100 && y<=100) && (w>=0 && w<=100) && (h>=0 && h<=100) && (r>=0 && r<=100)){
                if(x-r>=0 && x+r<=w && y-r>=0 && y+r<=h)
                        puts("Yes");
                else
                        puts("No");
        }
        return 0;
}

Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 ,-1};
signed main() {
    string s;
    int K;
    cin >> s >> K;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'a') {
            continue;
        }
        else if('z'-s[i]+1 <= K) {
            K-='z'-s[i]+1;
            s[i] = 'a';
        }
    }
    K%=26;
    s[s.size()-1] = (s[s.size()-1]-'a'+K)+'a';
    cout << s << endl;
}


Measured memory_bytes: 3732
import math
def fac(k):
    return(math.factorial(k)//(math.factorial(k-2)*2))


n,k = input().split()
n = int(n) 
k = int(k)
se = 0

if k > 1:
    if n > 1:
        se = fac(k) + fac(n)
    else:
        se= fac(k)
else:
    if n > 1:
        se =  fac(n)
    else:
        se = 0
print(se)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ull = unsigned long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;
using vpii = vector<pii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {
    
    int N,M;
    cin >>N>>M;
    vs A(N),B(M);
    string AA="",BB="";
    FOR(i,0,N-1) {
        cin >>A[i];
        FOR(j,0,N-1) {
            if(A[i][j]=='.') A[i][j]='a';
        }
        AA+=A[i];
    }
    FOR(i,0,M-1) {
        cin >>B[i];
        FOR(j,0,N-1) {
            if(B[i][j]=='.') B[i][j]='a';
        }
        BB+=B[i];
        if(i!=(M-1)) {
            FOR(j,1,N) {
                BB+=".";
            }
        }
    }
    Yn(regex_search(AA, regex(BB)));

    return 0;
}

Measured memory_bytes: 1536
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
const ll INF = (1ll << 60);

int main() {
  ll N;
  cin >> N;

  vi V(N);
  vector<vpii> G(N);
  vi ans(N - 1);

  for (ll i = 0; i < N - 1; i++) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].emplace_back(b, i);
    G[b].emplace_back(a, i);
  }

  queue<ll> q;
  q.push(0);
  unordered_set<ll> visited;
  V[0] = 0;
  ll m = 0;

  while (q.size()) {
    ll fr = q.front();
    q.pop();
    ll j = 1;
    if (V[fr] == 1) j = 2;
    for (ll i = 0; i < G[fr].size(); i++) {
      if (visited.find(G[fr][i].first) != visited.end()) continue;
      ans[G[fr][i].second] = j;
      V[G[fr][i].first] = j;
      m = max(m, j);
      if (j + 1 == V[fr]) j += 2;
      else j += 1;
      q.push(G[fr][i].first);
    }
    visited.insert(fr);
  }

  cout << m << endl;
  for (auto i : ans) cout << i << endl;
}


Measured memory_bytes: 13604
#include<bits/stdc++.h>
#include<stdlib.h>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
	string s;
	cin >> s;
	if((s[2]==s[3]) && (s[4]==s[5])) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k <= a){
		cout << k << endl;
	}
	else{
		int t = a;
		k -= a;
		if (k <= b){
			cout << t << endl;
		}
		else{
			k -= b;
			cout << a - k << endl;
		}
	}
	return 0;
}


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

int main() {
  vector<int> t(5);
  for (int i=0; i< t.size(); i++) {
    cin >> t.at(i);
  }
  int poyo = 10;
  int lo = 0;
  for (int i=0; i< t.size(); i++) {
    if (t.at(i) %10 > 0 && t.at(i) %10 < poyo) {
      poyo = t.at(i) %10;
      lo = i;
    }
  }

  int time = 0;
  for (int i=0; i< t.size(); i++) {
    if (i == lo) {
      time += t.at(i);
    }
    else {
      time += int(ceil(t.at(i)/10.0))*10;
    }
  }

  cout << time << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define DIV (long) (1e9+7)

int main(void) {
	long n, k;
	scanf("%ld%ld", &n, &k);
	long count = 0;
	for (int i = k; i <= n + 1; i++) {
		count = (count + i * (n - i + 1) + 1) % DIV;
	}
	// k = 2: (2n + 1) - 3 + 1
	printf("%ld\n", count);
	return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a; cin>>a;
	cout<<(ll)a+(a*a)+(a*a*a)<<endl;
	
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
#define REP(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define fi first
#define sc second
#define pb push_back
#define double long double
#define all(x) x.begin(), x.end()
 
using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int>> vpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<int, int> pii;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;
 
const i64 MOD = 1000000007;
const i64 INF = 2e15;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
                                  
    int n, d;
    cin >> n >> d;
    vector<vector<double>> v(n, vector<double>(d));
    REP(j, 0, n-1) {
    	REP(i, 0, d-1) {
    		cin >> v[j][i];
	    }
    }

    int ans = 0;
    
    REP(i, 0, n-2) {
    	REP(j, i+1, n-1) {
    		double r = 0;
    		REP(z, 0, d-1) {
    			r += (v[i][z] - v[j][z]) * (v[i][z] - v[j][z]);
    		} 
    		r = sqrt(r);

    		if (r - floor(r) == 0) ans++;
    	}
    }


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

Measured memory_bytes: 384
#!/usr/bin/env python3
n = int(input())
cnt = [0] * (1 + n)
for a in range(1, 100):
    for b in range(1, 100):
        for c in range(1, 100):
            k = a ** 2 + b ** 2 + c ** 2 + a * b + b * c + c * a
            if k > n:
                continue
            else:
                cnt[k] += 1
for i in range(1, n + 1):
    print(cnt[i])


Measured memory_bytes: 68832
def main():
    abcd = input()
    s = list(map(int, list(abcd)))
    n = 3
    for i in range(2 ** n):
        total = s[0]
        sign = []
        for j in range(n):
            if ((i >> j) & 1):
                total += s[j + 1]
                sign += ['+']
            else:
                total -= s[j + 1]
                sign += ['-']
        if total == 7:
            print(str(s[0]) + sign[0] + str(s[1]) +
                  sign[1] + str(s[2]) + sign[2] + str(s[3]) + '=7')
            return


if __name__ == '__main__':
    main()


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

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

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

    vector<vector<int>> A(2,vector<int>(N));
    REP(i,2){
        REP(j,N){
            cin >> A[i][j];
        }
    }

    int dp[5][110] = {0};

    dp[0][0] = A[0][0];
    dp[1][0] = A[0][0] + A[1][0];

    for(int j = 1; j < N; j++){
        dp[0][j] = dp[0][j-1] + A[0][j]; 
        dp[1][j] = max(dp[0][j], dp[1][j-1]) + A[1][j];
    }

    cout << dp[1][N-1] << endl;

    return 0;
}


Measured memory_bytes: 3632
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define cases int tc;cin>>tc;while(tc--)
#define N 100003
#define M 1003
#define inf LLONG_MAX
#define Arena ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//int mod=1e9+7;
//int mod=998244353;

signed main()
{
    Arena
    
    string s;
    cin>>s;
    int c=0,i;
    for(i=0;i<s.size();++i)
        c+=(s[i]=='o');
    cout<<(((c+15-s.size())>=8)?"YES":"NO");
    
    
    return 0;
}


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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007)
#define IINF (1<<28)
#define LINF (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"

namespace solver {
  using namespace std;
  typedef long long ll;

  int N, as[16][16];
  ll sum[1<<16], dp[1<<16];

  void init() {
    cin >> N;
    rep(i, N) rep(j, N) {
      cin >> as[i][j];
    }
  }

  void build_sum() {
    rep(i, 1<<N) {
      sum[i] = 0;
      if(__builtin_popcount(i) <= 1) continue;
      int j = i & -i;
      int k = i & ~j;
      sum[i] = sum[k];
      rep(l, N) if((k >> l) & 1) {
        sum[i] += as[l][__builtin_ffs(j)-1];
      }
    }
  }

  void solve() {
    build_sum();
    rep(i, 1<<N) {
      dp[i] = sum[i];
      if(__builtin_popcount(i) <= 2) continue;
      int j = i;
      do {
        int k = i & ~j;
        if(j != 0 || k != 0) {
          dp[i] = max(dp[i], dp[j] + dp[k]);
          j = (j - 1) & i;
        }
      } while(j != i);
    }
    cout << max(0LL, dp[(1<<N)-1]) << "\n";
  }
}

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

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))

using namespace std;

int n, y, b[100], t[100], r[100];

int solve()
{
	int res = 0;
	double costm = 0, cost = 0;
	
	FOR(i, 0, n)
	{
		if( t[i] == 1 )
		{
			cost = 1 + y*r[i]/100.0f;
		}
		else
		{
			cost = pow(1 + r[i]/100.0f, y);
		}
		
		if( cost > costm )
		{
			costm = cost;
			res = b[i];
		}
	}	
	
	return res;
}

int main()
{
	while( cin >> n, n)
	{
		cin >> y;
		
		FOR(i, 0, n)
		{
			cin>> b[i];
			cin >> r[i];
			cin >> t[i];
		}
		
		cout << solve() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
N = int(input())
a = list(map(int, input().split()))

left_sum = [0] * (N - 1)
right_sum = [0] * (N - 1)

left_sum[0] = a[0]
right_sum[0] = a[-1]
for i in range(1,len(a) - 1):
    left_sum[i] = left_sum[i-1] + a[i]

for i in reversed(range(1,len(a) - 1)):
    right_sum[N-1-i] = right_sum[N-2-i] + a[i]


ans = 9999999999999999

for i in range(len(left_sum)):
    ans = min(ans, abs(left_sum[i] - right_sum[N-2-i]))
print(ans)

Measured memory_bytes: 28664
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second

using namespace std;
using ll = long long;
using namespace __gnu_pbds;

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5 + 10 , inf = 2e9 + 7;
const ll INF = 1e18 ,   mod = 1e9+7;

int a[N];

void solve() {
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++) {
        cin >> a[i];
    }
    int cnt = 0;
    for(int i = 1; i <= n; i ++) {
        for(int j = i+1; j <= n; j ++) {
            for(int k = j+1; k <= n; k ++) {
                if(a[i]+a[j] > a[k] && a[i]+a[k] > a[j] && a[k]+a[j] > a[i] && a[i] != a[j] && a[i] != a[k] && a[j] != a[k]) {
                    cnt ++;
                }
            }
        }
    }
    cout << cnt;
}

/*
1 1 5 5
1 2 13
*/
main() {
    ios;
    int tt = 1;
   // cin >> tt;
    while(tt --) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    stack<int> a;
    //int a[1005]={0};
    int s1,t=0,a1,a2;
    getline(cin,s);
    s=s+' '; s1=0;
    for (int i=0; i<s.length(); i++){
    	if (s[i]==' '){
    		if (s[i-1]<='9' && s[i-1]>='0'){
    			t++;
    			int tmp=0;
    			for (int j=s1; j<i; j++){
    				int m=s[j]-'0';
    				tmp+=pow(10,i-j-1)*m;
				}
				a.push(tmp);
				s1=i+1;
			}
			else{
				s1=i+1;
				switch (s[i-1]){
					case '+':{
						a1=a.top();
						a.pop();
						a2=a.top();
						a.pop();
						a.push(a1+a2);
						break;
					}
					case '-':{
						a1=a.top();
						a.pop();
						a2=a.top();
						a.pop();
						a.push(-a1+a2);
						break;
					}
					case '*':{
						a1=a.top();
						a.pop();
						a2=a.top();
						a.pop();
						a.push(a1*a2);
						break;
					}
				}					
			}
		}
	}
	cout<<a.top()<<endl;
    return 0;
} 


Measured memory_bytes: 3384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
    string S;
    cin >> S;
    
    int org_size = S.length();
    for (int i=0; i+1<S.length(); i++) {
        if (S[i]!=S[i+1]) {
            S.erase(S.begin()+i, S.begin()+i+2);
            if(i==0){
                i--;
            }
            else{
                i = i - 2;
            }
        }
    }
    cout << org_size - S.length() << endl;
}


Measured memory_bytes: 512
import sys

def count(c,num,N):
        x = 0
        for i in range(num*2,N+1,num):
                x += c[i]
        return x%2


N = int(input())
b = input()
a = list(b.split())
a = [int(s) for s in a]
a = [-1] + a
#print(a)
c = [0 for i in range(N+1)]
if max(a) == 0:
        print("0")
        sys.exit()
for i in range(N,0,-1):
        if i > N//2:
                c[i] = a[i]
        else:
                x = count(c,i,N)
                if a[i] != x: c[i] = 1

#print(c[i])
print(sum(c))
f = 1
for i in range(1,N+1):
        if c[i]:
                if f:
                        print("{}".format(i),end="")
                        f = 0
                else: print(" {}".format(i),end="")
print()

Measured memory_bytes: 7476