akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static List<int>[] li;
	static bool[] b;
	static long[] h;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		int n=s[0],m=n-1;
		li=new List<int>[n+1];
		b=new bool[n+1];
		h=new long[n];
		for(int i=1;i<=n;i++){li[i]=new List<int>();}
		for(int i=0;i<m;i++){
			int[] e=sc.Ia;
			li[e[0]].Add(e[1]);
			li[e[1]].Add(e[0]);
		}
		for(int i = 0;i<s[1];i++) {
			int[] e=sc.Ia;
			h[e[0]-1]+=e[1];
		}
		Fu(1,0);
		Console.WriteLine("{0}",String.Join(" ",h));
	}
	static void Fu(int a,long g){
		b[a]=true;
		long p=h[a-1];
		h[a-1]+=g;
		g+=p;
		for(int i=0;i<li[a].Count;i++){
			if(!b[li[a][i]]){
				Fu(li[a][i],g);
			}
		}
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 68728
s = input()[::-1]
from collections import defaultdict
amari = defaultdict(int)
keta_ = defaultdict(int)

cur = 0
keta = 1

for i in range(len(s)):
    cur += int(s[i]) * keta
    cur %= 2019

    keta *= 10
    keta %= 2019
    
    amari[cur] += 1
    keta_[keta] += 1

#print('%')
#print(2114%2019)
#print(181712114%2019)

#print(81712114%2019)
#print(1817181712114%2019)

#print('%')

#print(amari)
#print(keta_)
ans = 0
if 0 in amari:
    ans += amari[0]

for n in amari.values():
    ans += (n * (n-1)) // 2
  
print(ans)


Measured memory_bytes: 69072
from itertools import combinations_with_replacement as cwr
[N, M, Q] = [int(i) for i in input().split()]
req = [list(map(int, input().split())) for _ in range(Q)]

ans = 0
for seq in cwr(range(1, M+1), N):
    sco = 0
    for i in range(Q):
        if seq[req[i][1]-1] - seq[req[i][0]-1] == req[i][2]:
            sco += req[i][3]
    s = max(ans, sco)
    ans = s
print(ans)

Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Mid ((l+r)/2)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define file(a) freopen(#a".in","r",stdin),freopen(#a".out","w",stdout);
const int maxn=2e3+5,mod=1e9+7,inf=0x3f3f3f3f;
int n,m,Q,K,T;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}char c[maxn];
bool a[maxn][maxn];
bool b[maxn][maxn];
int pre[maxn][maxn];
int stk[maxn],top;
int h[maxn];
signed main(){
    //file(a);
    n=read();m=read();
    rep(i,1,n){
        scanf("%s",c+1);
        rep(j,1,m)a[i][j]=(c[j]=='.');
    }
    rep(i,1,n-1)rep(j,1,m-1){
        int cnt=0;
        rep(ii,i,i+1)rep(jj,j,j+1)cnt+=a[ii][jj];
        b[i][j]=(!(cnt&1));
    }
    rep(j,1,m-1){
        int now=1;
        rep(i,1,n-1){
            if(b[i][j]!=b[now][j])now=i;
            pre[i][j]=now;
        }
    }int ans=0;
    rep(i,1,n-1){
        rep(j,1,m-1)h[j]=i-pre[i][j]+1;
        stk[0]=0;stk[top=1]=1;
        rep(j,2,m){
            if(b[i][j]!=b[i][j-1]||j>=m){
                while(top){
                    int x=j-stk[top-1]-1,y=h[stk[top]];
                    ans=max(ans,(x+1)*(y+1));--top;
                }stk[0]=j-1,stk[top=1]=j;continue;
            }
            while(top&&h[stk[top]]>=h[j]){
                int x=j-stk[top-1]-1,y=h[stk[top]];
                ans=max(ans,(x+1)*(y+1));--top;
            }stk[++top]=j;
        }
    }printf("%d\n",(max(ans,max(n,m))));


    return 0;
}


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

public class Main {
	static int a,b;
    
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       while(true) {
    	   int n = sc.nextInt();
    	   if(n==0)break;
    	   int sum = 0;
    	   Integer[] a = new Integer[n];
    	   for(int i=0;i<n;i++) {
    		   a[i] = sc.nextInt();
    		   sum += a[i];
    	   }
    	   double ave = sum/n;
    	   Arrays.sort(a);
    	   int ans = 0;
    	   for(int i= 0;i<n;i++) {
    		   if(a[i] <= ave) {
    			   ans += 1;
    		   }
    		   else {
    			  break;
    		   }
    	   }
    	   System.out.println(ans);
      }
    }
}


Measured memory_bytes: 59684
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    string S; cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int x = 1;
  int ans = 0;
  bool ok = false;
  for (int i = 0; i < n; ++i) {
    if (a[i] == 1) {
      ok = true;
    }
    if (a[i] != x) {
      ++ans;
    } else {
      ++x;
    }
  }
  if (ok) {
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int n,l;
	cin >> n >> l;
	vi a(n);
	a[0] = l;
	for(int i = 1; i < n; i++) a[i] = a[i-1]+1;

	int mi_i,mi_num = INF;
	for(int i = 0; i < n; i++){
		if(abs(a[i]) < mi_num){
			mi_i = i;
			mi_num = abs(a[i]);
		}
	}

	int ans = 0;
	for(int i = 0; i < n; i++){
		if(i == mi_i) continue;
		ans += a[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int maxn=(1e5)+10;
typedef long long ll;
int n,m,X[maxn],Y[maxn];
vector<int> g[maxn];
ll ans;
bool f[maxn][2],v[maxn];
void dfs(int a,int dis) {
	if (f[a][dis]) return;
	f[a][dis]=1;
	v[a]=1;
	for (int i=0;i<g[a].size();i++)
		dfs(g[a][i],1-dis);
	v[a]=0;
}
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%d %d",&n,&m);
	for (int i=1;i<=m;i++) {
		int x,y;
		scanf("%d %d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
		X[i]=x; Y[i]=y;
	}
	dfs(1,0);
	ll a1=0,a2=0,a3=0,a4=0;
	for (int i=1;i<=n;i++) {
		a1+=f[i][0]; a2+=f[i][1];
		a3+=f[i][0]&f[i][1];
		//printf("%d %d %d\n",i,f[i][0],f[i][1]);
	}
	for (int i=1;i<=m;i++) {
		int x=X[i],y=Y[i];
		if (f[x][0]&&f[x][1]&&f[y][0]&&f[y][1])
			a4++;
	}
	//printf("%lld %lld %lld %lld\n",a1,a2,a3,a4);
	ans=a1*a2-a3*(a3-1)/2-a3-m;
	printf("%lld\n",ans);
	return 0;
}

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

int n,h;
int a,b;
bool c[500*500*500];
string z;

int main(){
  for(;;){
    cin >> n >> h;
    if(!n && !h)break;
    fill(c,c+n*n*n,0);
    /*
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	for(int k=0;k<n;k++)c[i*n*n+j*n+k] = true;
    */

    int cnt = 0;
    for(int i=0;i<h;i++){
      cin >> z >> a >> b;
      a--;
      b--;
      if(z == "xy")
	for(int j=0;j<n;j++){
	  if(!c[a*n*n+b*n+j]){
	    cnt++;
	    c[a*n*n+b*n+j] = true;
	  }
	}
      else if(z=="yz")
	for(int j=0;j<n;j++){
	  if(!c[j*n*n+a*n+b]){
	    cnt++;
	    c[j*n*n+a*n+b] = true;
	  }
	}
      else 
	for(int j=0;j<n;j++){
	  if(!c[a*n*n+j*n+b]){
	    cnt++;
	    c[a*n*n+j*n+b]= true;
	  }
	}
    }

    cout << n*n*n-cnt << endl;
  }
}

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

#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi vector<int> 
#define vll vector < long long > 
#define vld vector < long double >
#define vs vector<string> 
#define vb vector<bool> 
#define vin(v, n) for (ll i = 0; i < n; i++) cin >> v[i];
#define vout(v, n) for (ll i = 0; i < n; i++) cout << v[i] << " ";
#define all(x) x.begin(), x.end()
#define sortall(x) sort(x.begin(), x.end())
#define ll long long
#define ld long double
#define sp " "
#define nl "\n"
#define mod 1e9 + 7
#define pb push_back
#define prec(n) fixed<<setprecision(n)
#define llsetBits(x) __builtin_popcountll(x)            //counts number of set bits in ll x
#define setBits(x) __builtin_popcount(x)                //counts number of set bits in int x
#define llcountTz(x) __builtin_ctzll(x)                 //counts trailing zeroes in ll x
#define countTz(x) __builtin_ctz(x)                     //counts trailing zeroes in int x
#define debug(x) cout << #x << " " << x;
#define fo(i, n) for (int i = 0; i < n; i++)
#define foexc(i, a, b) for (int i = a, ; i < b; i++)
#define foinc(i, a, b) for (int i = a, ; i <= b; i++)
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
ll power(ll x, ll n);

void solve()
{
	int k;
	cin >> k;
	string s;
	cin >> s;
	int n=s.length();
	if(n<=k)
	{
		cout << s;
	}else
	{
		cout << s.substr(0,k)+"...";
	}
}

int main()
{
	fio()
	ll t;
	//cin >> t;
	t=1;
	while (t--) {solve();}
	return 0;
}

ll gcd(ll a,ll b)
{
	if(b==0) {return a;}
	else {return gcd(b,a%b);}
}
ll lcm(ll a, ll b)
{
	return (a*b)/(gcd(a,b)) ;
}
ll power(ll x, ll n)
{
	if(n==0) { return 1ll;}
	else if(n%2==0) { return power((x*x),n/2);}
	else { return x*power((x*x),(n-1)/2);}
}

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

void DFS(int node, vector < vector <int> > &adjList, vector < bool > &visited, vector <int> &depth)
{
    visited[node]=1;
    int cDepth=0;
    for (auto z: adjList[node])
    {
        if (!visited[z])
        {
            DFS(z, adjList, visited, depth);
        }
        cDepth=max(cDepth, depth[z]+1);
    }
    depth[node] = cDepth;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N, M;
    cin >> N >> M;
    vector < vector <int> > adjList(N+1);
    vector < int > indegree(N+1, 0);
    vector <bool> visited(N+1, false);
    vector <int> depth(N+1,0);
    loop(i,0,M)
    {
        int u,v;
        cin >> u >> v;
        adjList[u].push_back(v);
        indegree[v]++;
    }
    int ans=0;
    loop(i,1,N+1)
    {
        if (indegree[i]==0)
        {
            DFS(i, adjList, visited, depth);
            ans=max(ans, depth[i]);
        }
    }
    cout << ans <<  "\n";
    return 0;
}

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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 100100;

int n, qn;

pair<int, int> a[maxn + 5];

vector<pair<int, int> > all[maxn + 5];
int b[maxn + 5];

bool used[maxn + 5];

int sum[maxn + 5];

int Min[maxn + 5];

int dis[maxn + 5];

inline int init()
{
	memset(used, 0, sizeof used);
	set<pair<int, int> > cur;
	int ret = 0;
	sum[n + 1] = 0;
	for (int i = n; i >= 0; --i)
	{
		sum[i] += sum[i + 1];
		for (auto u : all[i]) --sum[i], cur.insert(u);
		while (sum[i] < i - n)
		{
			if (cur.empty() || cur.begin()->x >= i)
			{
				return -1;
			}
			++ret;
			++sum[i];
			--sum[cur.begin()->x];
			used[cur.begin()->y] = 1;
			cur.erase(*cur.begin());
		}
	}
	REP(i, 0, n + 1) sum[i] = 0;
	memset(Min, oo, sizeof Min);
	REP(i, 0, n - 1) 
		if (!used[i])
		{
			--sum[a[i].x];
			chkmin(Min[a[i].x], a[i].y);
		}
		else --sum[a[i].y];
	Min[n + 1] = oo;
	for (int i = n; i >= 0; --i)
	{
		chkmin(Min[i], Min[i + 1]);
	}
	for (int i = n - 1; i >= 0; --i) sum[i] += sum[i + 1];
	REP(i, 0, n + 1) sum[i] += n - i;
	vector<int> zeros;
	REP(i, 0, n + 1) if (!sum[i]) zeros.pb(i);
	memset(dis, oo, sizeof dis);
	dis[0] = 0;
	REP(i, 1, n + 1)
	{
		if (!sum[i]) 
		{
			if (Min[i] < i) chkmin(dis[i], dis[Min[i]] + 1);
		}
		else dis[i] = dis[i - 1];
	}
	return ret;
}

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	++n;
	REP(i, 0, n - 1) scanf("%d%d", &a[i].x, &a[i].y);
	REP(i, 0, n) scanf("%d", b + i);
	sort(b, b + n);
	REP(i, 0, n - 1) 
	{
		a[i].x = lower_bound(b, b + n, a[i].x) - b, a[i].y = lower_bound(b, b + n, a[i].y) - b;
		all[a[i].x].pb(mp(a[i].y, i));
	}

	scanf("%d", &qn);

	int A = init();
	if (!~A)
	{
		REP(i, 0, qn) printf("-1\n");
	}
	else
	{
		REP(i, 0, qn)
		{
			int x, y;
			scanf("%d%d", &x, &y);
			x = lower_bound(b, b + n, x) - b, y = lower_bound(b, b + n, y) - b;
			int ans = min(A + dis[x], A + 1 + dis[y]);
			if (ans >= oo) printf("-1\n");
			else printf("%d\n", n - ans);
		}
	}
	return 0;
}


Measured memory_bytes: 13684
#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() {
    ll n; cin >> n;
    map<ll, ll> mp;
    rep(i, n) {
        ll a; cin >> a;
        mp[a]++;
    }
    vector<ll> vc;
    for (auto it=mp.begin();it!=mp.end();it++) {
        if(it->second >= 2) {
            rep(i, it->second/2)
            vc.push_back(it->first);
        }
    }
    sort(vc.begin(), vc.end());
    ll m = vc.size();
    if(m < 2) cout << 0;
    else cout << vc[m-1] * vc[m-2];
}


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

int main() {
	int N,X,m,ans=0,sum=0,mini=100000;
	cin>>N>>X;
	for(int i=0;i<N;i++)
	{
		cin>>m;
		sum+=m;
		mini=min(mini,m);
	}
	ans=N+(X-sum)/mini;
	cout<<ans;
	}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#define fo(i,n) for(long long i=0;i<n;i++)
#define ll long long int
#define inf 999999999999999999
#define pb push_back
#define fi first
#define se second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define pi pair<ll,ll>
#define mp make_pair
#define MOD 1000000007
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
//freopen("explicit.in", "r", stdin);
//freopen("explicit.out", "w", stdout);
 
void SieveOfEratosthenes() 
{ 
    bool prime[10000001];
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=10000000; p++) 
    { 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (ll i=p*p; i<=10000000; i += p) {
                prime[i] = false; 
            }
        } 
    }  
} 
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
	if(b%a==0)
	   return a;
	return gcd(b%a,a);
}
ll nCrModpDP(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C));   
    C[0] = 1;
    for (ll i = 1; i <= n; i++) 
    {
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 
ll nCrModp(ll n, ll r, ll p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
   ll ni = n%p, ri = r%p; 
  
   return (nCrModp(n/p, r/p, p) * 
           nCrModpDP(ni, ri, p)) % p; 
}
ll c=0; 
bool vis[200005];
vector<ll> adj[200005];
void dfs(ll s)
{
	vis[s]=true;
	c++;
	for(ll j=0;j<adj[s].size();j++)
	{
		if(vis[adj[s][j]]==false)
		{
			dfs(adj[s][j]);
		}
	}
}
int32_t main() 
{
    fio
	ll j,i,n,t,l,r,h,k,m,u,v,maxi,d,x;
	cin>>n>>m;
	for(j=0;j<m;j++)
	{
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	ll ans=0;
	for(j=1;j<=n;j++)
	{
		if(vis[j]==false)
		{
			c=0;
			dfs(j);
			ans=max(ans,c);
		}
	}
	cout<<ans;
}



	

		

Measured memory_bytes: 20964
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(e,r){e.exports=function(e){for(var r=Number(e[0]),t=e[1].split(" ").map(function(e){return Number(e)}),n=new Array(r).fill(0),o=0;o<r;o++)n[o]=t[o]-o-1;n.sort(function(e,r){return e-r});var u=0;u=r%2==0?(n[r/2-1]+n[r/2])/2:n[Math.floor(r/2)];for(var i=0,f=0;f<r;f++)i+=Math.abs(n[f]-u);console.log(i)}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 38408
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[55];
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>a[i];
    int cnt=0;
    for(int i=1; i<=n; i++)
    {
        if(a[i]!=i)
            cnt++;
    }
    if(cnt<=2)
        cout<< "YES\n";
    else
        cout<< "NO\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1e9;

int main() {
  srand(0);

  // input
  constexpr int n = 26;
  int d;
  cin >> d;
  vector<int> c(n);
  for (auto &e : c) cin >> e;
  vector<vector<int>> s(d, vector<int>(n));
  for (auto &se : s) {
    for (auto &e : se) cin >> e;
  }

  // solve
  int satisfaction = 0;
  vector<set<int>> v(n);
  for (auto &e : v) e.insert(-1);
  vector<int> t(d);
  for (int i = 0; i < d; i++) {
    t[i] = max_element(s[i].begin(), s[i].end()) - s[i].begin();
    satisfaction += s[i][t[i]];
    v[t[i]].insert(i);

    for (int j = 0; j < n; j++) {
      int last_i = *v[j].rbegin();
      satisfaction -= c[j] * (i - last_i);
    }
  }

  auto calculate_decline = [](int c, int d) { return -c * ((d - 1) * d / 2); };

  auto calculate_difference = [&](int i, int j) {
    int difference = 0;
    difference -= s[i][t[i]];
    difference += s[i][j];

    auto it1_to = v[t[i]].upper_bound(i);
    auto it1_from = it1_to;
    it1_from--;
    it1_from--;
    int i1_to = it1_to == v[t[i]].end() ? d : *it1_to, i1_from = *it1_from;

    auto it2_to = v[j].upper_bound(i);
    auto it2_from = it2_to;
    it2_from--;
    int i2_to = it2_to == v[j].end() ? d : *it2_to, i2_from = *it2_from;

    difference -= calculate_decline(c[t[i]], i - i1_from) + calculate_decline(c[t[i]], i1_to - i);
    difference += calculate_decline(c[t[i]], i1_to - i1_from);

    difference -= calculate_decline(c[j], i2_to - i2_from);
    difference += calculate_decline(c[j], i - i2_from) + calculate_decline(c[j], i2_to - i);

    return difference;
  };

  double temperature_from = 1e4, temperature_to = 0;

  for (int iteration = 0, iteration_end = 8e6; iteration < iteration_end; iteration++) {
    double temperature = temperature_from + (temperature_to - temperature_from) * iteration / iteration_end;

    if (rand() % 2) {
      int i = rand() % d, j = rand() % n;
      if (t[i] == j) continue;

      int difference = 0;
      difference += calculate_difference(i, j);

      double probability = exp(difference / temperature);

      if ((rand() % INF) / (double)INF < probability) {
        satisfaction += difference;
        v[t[i]].erase(i);
        v[j].insert(i);
        t[i] = j;
      }
    } else {
      int i = rand() % (d - 1);
      if (t[i] == t[i + 1]) continue;

      int difference = 0;
      difference += calculate_difference(i, t[i + 1]);
      difference += calculate_difference(i + 1, t[i]);

      double probability = exp(difference / temperature);

      if ((rand() % INF) / (double)INF < probability) {
        satisfaction += difference;
        v[t[i]].erase(i);
        v[t[i]].insert(i + 1);
        v[t[i + 1]].erase(i + 1);
        v[t[i + 1]].insert(i);
        swap(t[i], t[i + 1]);
      }
    }
  }

  // output
  cerr << "satisfaction: " << satisfaction << endl;
  cerr << "score: " << max((int)1e6 + satisfaction, 0) << endl;

  for (auto e : t) cout << e + 1 << endl;
}


Measured memory_bytes: 4404
#include<string>
#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int cnt=0;
  string a,b;
  cin>>a;
  b=a;
  reverse(b.begin(),b.end());
  for(int i=0;i<a.size()/2;i++){
    if(a[i]!=b[i])cnt++;
  }
  printf("%d\n",cnt);
}

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


int main() {
    int n;
    cin >> n;
    vector<pair<int,int>> P;
    rep(i,n) {
        int a,b;
        cin >> a >> b;
        P.push_back(make_pair(a,b));
    }
    sort(P.begin(),P.end());
    int ans = 0;
    rep(i,n-1) {
        ans += P[i+1].first - P[i].first;
    }
    ans += P[0].first - 1;
    ans += P[n-1].second;
    cout << ans + 1 << "\n";
    return 0;
}

Measured memory_bytes: 1400
//abc110_b.cpp
//Sat Sep 29 15:28:15 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n,m,xc,yc;
	cin >> n >> m >> xc >> yc;

	int x[n],y[m];
	for (int i=0;i<n;i++){
		cin >> x[i];
	}
	for (int i=0;i<m;i++){
		cin >> y[i];
	}

	sort(x,x+n);
	sort(y,y+m);
//	cout << x[n-1] << " " << y[0] << endl;

	int capstart = xc+1;
	int capend = yc;
	int citystart = x[n-1]+1;
	int cityend = y[0];

	int flag = 0;
	if (citystart > cityend){
	}else{
		int xcount = citystart;
		while (xcount <= cityend){
			if (xcount>=capstart && xcount <=capend){
				flag = 1;
				break;
			}
			xcount++;
		}
	}

	if (flag == 1){
		cout << "No War" << endl;
	}else{
		cout << "War" << endl;
	}
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,c=0,r=0;
	cin>>n;
	for (int N=0;N<n;N++){
		int a,b;
		cin>>a>>b;
		if(a==b){
			c++;
		}else{
			c=0;
		}

		if(c>=3){
			r=1;
		}

	}
	if(r==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3624
#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) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#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 pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int N;
	cin >> N;
	int n = N % 10;
	if (n==2||n==4||n==5||n==7||n==9) {
		ce("hon")
	}
	else if (n==3) {
		ce("bon")
	}
	else {
		ce("pon")
	}
    return 0;
}



Measured memory_bytes: 3632
#

#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop
import math

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

    ans = [0] * n
    ans[-1] = al[-1]

    for i in range(n-1, -1, -1):
        num = i + 1
        val = 0
        for j in range(num * 2 - 1, n, num):
            # print(j)
            val += ans[j]

        val %= 2
        ans[i] = 0 if val == al[i] else 1

    c = ans.count(1)
    print(c)
    if c > 0:
        boxes = [i + 1 for i in range(len(ans)) if ans[i] == 1]
        print(' '.join(map(str, boxes)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 85360
#include<bits/stdc++.h>
using namespace std;
#define IO {ios_base::sync_with_stdio(false); cin.tie(0);}
#define ll long long
#define pi pair<ll,ll>
ll a[300008], b[10000005], vs[10000007], ans[10000007];
string s, s1;
map<ll, ll>mp;

int main()
{
    IO;
    ll i, j, k=0, l, n, m, t, h, cnt=0, curr, mx;
    cin>>n;
    for(i=1; i<=n; i++) b[i]=i;
    for(i=1; i<=n; i++) ans[i]=1;
    for(i=2; i*i<=n; i++){
        if(!vs[i]){
            for(j=i*i; j<=n; j+=i){
                vs[j]=1; cnt=0;
                while(b[j]%i==0) {b[j]/=i; cnt++; }
                ans[j]*=cnt+1;
            }
        }
    }
    for(i=1; i<=n; i++) {

            if(b[i]!=1) ans[i]*=2;//cout<<ans[i]<<endl;
            ans[i]=ans[i]*i+ans[i-1];
    }
    cout<<ans[n]<<endl;
    return 0;
}


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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define double long double

typedef long long ll;

const int N = 1e5;
const int M = N + 7;
const int MOD = 1e9 + 7;
const ll INF = 1e16 + 17;

int a[M];

int main(){
	#ifdef ADIKON
		freopen("problem.in", "r", stdin);
		freopen("problem.out", "w", stdout);
	#endif
	int n;
	scanf("%d", &n);
	ll sum = 0;
	int mx = 0;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		sum += a[i];
		if (i > 1)
			mx = max(mx, a[i] - a[i - 1]);
	}
	mx = max(mx, a[1] - a[n]);
	if (sum % ((ll)n * (n + 1) / 2) || (sum / ((ll)n * (n + 1) / 2) - mx) % n || (mx - (a[1] - a[n])) % n || mx > a[1] || mx - a[1] + a[n] > a[n]) {
		printf("NO");
		return 0;
	}
	for (int i = 2; i <= n; ++i) {
		if ((mx - a[i] + a[i - 1]) % n || mx > a[i] || mx - a[i] + a[i - 1] > a[i - 1]) {
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
 
typedef long long ll;
 
ll n,k;
ll w[100001];
 
bool C( int p ) { //判定
  ll sum = 0;
  ll cnt = 0;
 
  for ( ll i = 0; i < n; i++ ) {
    sum += w[i];
    while ( sum > p ) {
      sum = w[i];
      cnt++;
      if ( cnt == k )return false;
    }
  }
  return true;
}
 
int main() {
  cin >> n >> k;
  for ( ll i = 0; i < n; i++ ) cin >> w[i];
  ll lb = 0,ub = 1000000000; // 二分探索
  for ( int i = 0; i < 1000; i++ ) {
    ll mid = (lb + ub) / 2;
    if (C(mid)) ub = mid;
    else lb = mid;
  }
 
  cout << ub << endl;
  return 0;
}

Measured memory_bytes: 1936
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from collections import deque
# people on a line
n, m = map(int, input().split())

graph = {i: {} for i in range(1, n + 1)}


for _ in range(m):
    a, b, c = map(int, input().split())
    graph[a][b] = c
    graph[b][a] = -c



distance = ["inf" for i in range(n + 1)]

# グラフにおいて順に点を決めてって、矛盾がないかどうかを調べる
visited = [False for i in range(n + 1)]
visited[0] = True


def find(x):
    d = deque()
    visited[x] = True
    distance[x] = 0
    d.append(x)
    flag = True
    while d and flag:

        x = d.popleft()
        for node in graph[x]:
            if visited[node] == False:
                visited[node] = True
                d.append(node)
                if distance[node] == "inf":
                    distance[node] = distance[x] + graph[x][node]
                else:
                    if  distance[node] != distance[x] + graph[x][node]:
                        flag = False
                        break
            elif visited[node]==True:
                if distance[node]!=distance[x]+graph[x][node]:
                    flag=False
                    break
         
    if flag:
        return False
    else:
        return True

all_flag = True
not_visited = True
while not_visited and all_flag:
    judge = False
    for i in range(1, n + 1):
        if visited[i] == False:
            judge = True
            if find(i):
                all_flag = False
                break
            else:
                pass

    if not judge:
        not_visited = False

if all_flag:
    print("Yes")

else:
    print("No")


Measured memory_bytes: 113380
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
int a,b,c;
cin>>a;
if(a<10){cout<<a;}
 else if(a>9&&a<100){cout<<9;}
  else if(a>99&&a<1000){cout<<a-90;}
  else if(a>999&&a<10000){cout<<909;}
  else if(a>9999&&a<100000){cout<<a-9090;}
  else cout<<90909;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	typedef double dbl;
	dbl d, e;
	while (cin >> d >> e){
		if (d == 0 && e == 0)return 0;
		double diff;
		for (int i = 0; i <= d / 2; i++) {
			dbl dis = sqrt(i*i + (d - i)*(d - i));
			if (i == 0) diff = abs(e - dis);
			else diff = min(diff, abs(e - dis));
		}
		printf("%.10f\n", diff);
	}
}

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

int main(){
    int n,sum = 0;
    cin >> n;
    vector<int> data(n);
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
    }
    sort(data.begin(), data.end());//小さい順に並べる
    reverse(data.begin(), data.end());//リバース
    bool flag = 1;
    for (int i = 0; i < n-1; i++){
        sum += data.at(i+1);
    }
    if(sum <= data.at(0))flag = 0;

    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

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

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    int part1 = min(N, K);
    int part2 = N - part1;
    int totalCost = part1 * X + part2 * Y;
    cout << totalCost << endl;
    return 0;
};


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

#define DEBUG_MSG_off

int N;
vector<pair<int, int> > a_b_pair_list;

// sort B1 ... BN
// A1 ... AN
//             time limit
//             0    
// - A1 2 4 -> 2    4(ok)
// - A3 1 8 -> 3    8(ok)
// - A2 1 9 -> 4    9(ok)
// - A4 4 9 -> 8    9(ok)
// - A5 3 12 -> 12  12(ok)
bool cmp(pair<int,int> a, pair<int,int> b) {
  if (a.second < b.second)
    return true;
  else return false;
}

int main() {
  cin >> N;
  a_b_pair_list.resize(N);
  for(int i=0;i<N;i++) {
    int a,b; cin >> a >> b;
    a_b_pair_list[i] = make_pair(a,b);
  }
  sort(a_b_pair_list.begin(), a_b_pair_list.end(), cmp);
  int cur_time = 0;
  for(auto s: a_b_pair_list) {
    cur_time += s.first;
    if (cur_time>s.second) {
      cout << "No\n";
      return 0;
    }
  }

  cout << "Yes\n";

#ifdef DEBUG_MSG
  cerr << N << "\n";
  for(auto s: a_b_pair_list) {
    cerr << s.first << "," << s.second  << "\n"; 
  }
#endif
  return 0;
}

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

#define llong long long 
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define rand __rand
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());  // or mt19937_64
template<class T = int> T rand(T range = numeric_limits<T>::max()) { return (T)(rng() % range); }

#define CONCAT_(x, y) x##y/*{{{*/
#define CONCAT(x, y) CONCAT_(x, y)
#ifdef LOCAL_DEBUG   
int __db_level = 0;
bool __db_same_line = false;
#define clog cerr << string(!__db_same_line ? __db_level * 2 : 0, ' ')
struct debug_block {
    function<void()> fn;
    void print_name() { __db_same_line = true; fn(); clog << endl; __db_same_line = false;  }
    debug_block(function<void()> fn_): fn(fn_) { clog << "{ "; print_name(); ++__db_level; }
    ~debug_block() { --__db_level; clog << "} "; print_name(); }
};
#define DB(args...) debug_block CONCAT(dbbl, __LINE__)([=]{ clog << args; })
#define deb(...)  if (1) { (clog << "[" #__VA_ARGS__ "] = [" << __VA_ARGS__) << "]"; if (!__db_same_line) clog << endl; }
#else
#define clog if (0) cerr
#define DB(...)
#define deb(...)
#endif
template<class T>
ostream& operator,(ostream& out, const T& thing) { return out << ", " << thing; }
template<class U, class V>
ostream& operator<<(ostream& out, const pair<U, V>& p) { return (out << "(" << p.first, p.second) << ")"; }
template<class A, class B>
ostream& operator<<(ostream& out, const tuple<A, B>& t) { return (out << "(" << get<0>(t), get<1>(t)) << ")"; }
template<class A, class B, class C>
ostream& operator<<(ostream& out, const tuple<A, B, C>& t) { return (out << "(" << get<0>(t), get<1>(t), get<2>(t)) << ")"; }
template<class T> ostream& operator<<(ostream& out, const vector<T>& container) { 
    out << "{";
    if (len(container)) out << container[0];
    rep1(i, len(container) - 1) out, container[i];
    return out << "}";
}
template<class x> vector<typename x::value_type> $v(const x& a) { return vector<typename x::value_type>(a.begin(), a.end()); }
#define ptrtype(x) typename iterator_traits<x>::value_type
template<class u> vector<ptrtype(u)> $v(u a, u b) { return vector<ptrtype(u)>(a, b); }/*}}}*/
// ACTUAL SOLUTION BELOW ////////////////////////////////////////////////////////////

const int maxn = 201010;
int n, k;
int a[maxn];
int main(void) {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    rep(i, n) cin >> a[i];
    rep(i, n - k) {
        if (a[i] < a[i + k]) cout << "Yes\n";
        else cout << "No\n";
    }

    return 0;
}

// Remember:
// - Multitest? REFRESHING the data!!!
// - Constrains for each set of data may differs. Should NOT USE the same max constant (maxn)
//   for all of them.
// vim: foldmethod=marker


Measured memory_bytes: 4368
const txt = require('fs').readFileSync('/dev/stdin', 'utf8')

const input = txt.split('\n')
const A: number = Number(input[0])
const B: number = Number(input[1])
const C: number = Number(input[2])
const D: number = Number(input[3])
const E: number = Number(input[4])
const K: number = Number(input[5])
if (E - A <= K) {
  console.log('Yay!')
}
else {
  console.log(':(')
}

Measured memory_bytes: 9420
#include <stdio.h>
int main(){
	int H[100]={1},W[100]={1},s,t,a;
	//??\???
	for(a=0;H[a]!=0 && W[a]!=0 && a<100-1;a++){
		do{
			printf("");
			scanf("%d %d",&H[a+1],&W[a+1]);
		}while(!(H[a+1]>=0 && H[a+1]<=300 && W[a+1]>=0 && W[a+1]<=300));
	}
	
	//??????
	for(a=1;W[a]!=0 && H[a]!=0;a++){
		for(s=1;s<=H[a];s++){
			for(t=1;t<=W[a];t++){
				if((t==1 || t==W[a]) || (s==1 || s==H[a])){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
MOD = 10**9+7
n = int(input())
A = ['{:060b}'.format(a)[::-1] for a in map(int, input().split())]
c = [a.count('1') for a in zip(*A)]
print(sum(c[d]*(n-c[d])*pow(2, d, MOD) %
          MOD for d in range(60)) % MOD)

Measured memory_bytes: 68012
#include<stdio.h>

int main(void) {
  int a, b, c;
  scanf("%d%d", &a, &b);
  if(a+b==3) {
    printf("3\n");
  }
  else if(a+b==4) {
    printf("2\n");
  }
  else {
    printf("1\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
object Main {
  def main(args: Array[String]) = {
    
    val input: String = readLine()
    val list: Array[String] = input.split(" ")
    
    val a: Int = list(0).toInt
    val b: Int = list(1).toInt

    var sign = "=="
    if (a > b) {
      sign = ">"
    } else if (a < b) {
      sign = "<"
    }
    println("a " + sign + " b")
  }
  
//  def readLine(): String = {"5 5"}
}



Measured memory_bytes: 43532
N,K=map(int,input().split())
ans=0
if K==0:
  print(N**2)
else:
  for i in range(K+1,N+1):
    ans+=(N//i)*(i-K)
    if (N%i)-K+1>0:
      ans+=(N%i)-K+1
  print(ans)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  bool t = true;
  REP(i,A+B+1){
    if(i==A){
      if (S[i] != '-') t = false;
      continue;
    }
    if('0'<=S[i]&&S[i]<='9'){

    }else{
      t = false;
    }
  }
  if (t) cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

using namespace std;

int main()
{
    long long int N;
    cin>>N;
    long long int L[2*N];

    for(int x = 0;x<2*N;x++){
        cin>>L[x];
    }
    sort(L,L+2*N);

    long long int Ans = 0;

    for(int x = 0;x<2*N;x+=2){
        Ans+=L[x];

    }
    cout<<Ans<<"\n";

}


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

/*** Template Begins ***/

typedef long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;

#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p){ ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;} return res; } 

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

// Constants //

const int N = 1e5+7;
const int xinc[] = {0, 0, 1, -1};
const int yinc[] = {1, -1, 0, 0};

/*** Template Ends ***/
std::vector<string> p;
void permute(string str, string out) 
{ 
    // When size of str becomes 0, out has a 
    // permutation (length of out is n) 
    if (str.size() == 0) 
    { 
        p.push_back(out);
        return; 
    } 
  
    // One be one move all characters at 
    // the beginning of out (or result) 
    for (int i = 0; i < str.size(); i++) 
    { 
        // Remove first character from str and 
        // add it to out 
        permute(str.substr(1), out + str[0]); 
  
        // Rotate string in a way second character 
        // moves to the beginning. 
        rotate(str.begin(), str.begin() + 1, str.end()); 
    } 
} 

   void solve()
{
    ll n;
    cin>>n;
    std::vector<ll> v(n+1);
    ll i;
    std::vector<ll> dp(n+1);
    for(i=1;i<n+1;i++)
      cin>>v[i];
    dp[1]=0;
    dp[2]=abs(v[2]-v[1]);
    for(i=3;i<=n;i++)
      dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
    cout<<dp[n];
}
  
int main(){
  
  ios;
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  int t;
  //cin >> t;
  t = 1;
  while(t--)
    solve();

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n;
    cin>>n;
    pair<pair<string,int>,int> s[n];
    for(int i=0;i<n;i++){
        cin>>s[i].first.first>>s[i].first.second;
        s[i].second=i+1;
        s[i].first.second*=-1;
        
    }
    std::sort(s,s+n);
    for(int i=0;i<n;i++){
      cout<<s[i].second<<endl;
    }
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<vector<vector<int> > > vvvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vll h(n+1);
    h[0]=0;
    REP(i,n) cin >> h[i+1];
    vvll dp(n+1, vll(n+1,LLINF));
    dp[0][0] = 0LL;
    //dp[1][0]=0;
    dp[1][1] = h[1];
    for(int i=2;i<=n;++i){
        //dp[i][0] = 0;
        dp[i][1]=h[i];
        for(int j=2;j<=i;++j){
            for(int l=1;l<i;++l){
                dp[i][j] = min(dp[i][j], dp[l][j-1]+max(0LL,h[i]-h[l]));
            }
        }
    }
    ll ans = LLINF;
    /* 
    REP(i,n){
        REP(j,n){
            if(dp[i+1][j+1]==LLINF){
                cout << -1 << " ";
            }else{
                cout << dp[i+1][j+1] << " ";
            }
            
        }
        cout << endl;
    }
    */
    REP(i,n+1){
        ans = min(ans, dp[i][n-k]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld double
#define ff first
#define ss second
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	set<int> s;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	cout<<s.size()<<"\n";
	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	while(n--)
	{
		int num1 = 0;
		int num2 = 0;
		string str1, str2;
		cin >> str1 >> str2;
		int temp = 1;
		for(int i = 0; i < str1.size(); ++i)
		{
			switch(str1[i])
			{
			case 'm': num1 += temp * 1000; temp = 1; break;
			case 'c': num1 += temp * 100; temp = 1; break;
			case 'x': num1 += temp * 10; temp = 1; break;
			case 'i': num1 += temp; temp = 1; break;
			default: temp = str1[i] - '0'; break;
			}
		}
		for(int i = 0; i < str2.size(); ++i)
		{
			switch(str2[i])
			{
			case 'm': num2 += temp * 1000; temp = 1; break;
			case 'c': num2 += temp * 100; temp = 1; break;
			case 'x': num2 += temp * 10; temp = 1; break;
			case 'i': num2 += temp; temp = 1; break;
			default: temp = str2[i] - '0'; break;
			}
		}
		int sum = num1 + num2;
		string str;

		char a;
		if(sum)
		{
			a = sum % 10 + '0';
			if('1' <= a && a <= '9')
			{
				str.push_back('i');
			}
			if(a != '1' && a!= '0')
				str.push_back(a);
			sum /= 10;
		}

		if(sum)
		{
			a = sum % 10 + '0';
			if('1' <= a && a <= '9')
			{
				str.push_back('x');
			}
			if(a != '1' && a!= '0')
				str.push_back(a);
			sum /= 10;
		}

		if(sum)
		{
			a = sum % 10 + '0';
			if('1' <= a && a <= '9')
			{
				str.push_back('c');
			}
			if(a != '1' && a!= '0')
				str.push_back(a);
			sum /= 10;
		}

		if(sum)
		{
			a = sum % 10 + '0';
			if('1' <= a && a <= '9')
			{
				str.push_back('m');
			}
			if(a != '1' && a!= '0')
				str.push_back(a);
		}
		reverse(str.begin(), str.end());
		cout << str << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MAX = 999999;
const static int MOD = 1000000007;
const static int IINF = INT_MAX;
const static llong LINF = LLONG_MAX;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}
template<typename T> T my_lcm(T a, T b) {
    return a * b / my_gcd(a, b);    
}

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> X(n);
    rep(i, n) cin >> X[i];

    llong ans = LINF, res = 0;
    for (int i = 1; i < 101; ++i) {
        res = 0;
        for (int j = 0; j < n; ++j) res += (X[j] - i) * (X[j] - i);
        ans = min(ans, res);
    }

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

Measured memory_bytes: 256