akhauriyash/Code-Regression huggingface dataset:
table = {
    2 => 1,
    3 => 2,
    4 => 3,
    5 => 4,
    6 => 5,
    7 => 6,
    8 => 7,
    9 => 8,
    10 => 9,
    11 => 10,
    12 => 11,
    13 => 12,
    1 => 13,
}

a, b = gets.chomp.split(' ').map(&:to_i)

if table[a] < table[b]
  puts 'Bob'
elsif table[a] > table[b]
  puts 'Alice'
else
  puts 'Draw'
end

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int n=sc.nextInt(),rm=0,gm=0,bm=0;
	  long count=0,buff=0;
	  String s=sc.next();
	  int[] r=new int[s.length()],g=new int[s.length()],b=new int[s.length()];
	  for(int i=0;i<s.length();i++) {
		  if(s.substring(i, i+1).equals("R"))rm++;
		  if(s.substring(i, i+1).equals("G"))gm++;
		  if(s.substring(i, i+1).equals("B"))bm++;
	  }
	  for(int i=0;i<s.length();i++) {
		  r[i]=rm;
		  g[i]=gm;
		  b[i]=bm;
		  if(s.substring(i, i+1).equals("R"))rm--;
		  if(s.substring(i, i+1).equals("G"))gm--;
		  if(s.substring(i, i+1).equals("B"))bm--;
	  }
	  for(int i=0;i<s.length()-1;i++) {
		  for(int j=i+1;j<s.length();j++) {
			  if(!s.substring(i, i+1).equals(s.substring(j, j+1))) {
				  if(2*j-i+1<=s.length()) {
					  if(!s.substring(2*j-i,2*j-i+1).equals(s.substring(i, i+1)) && !s.substring(2*j-i,2*j-i+1).equals(s.substring(j, j+1))) {
						  buff++;
					  }
				  }
			  }
		  }
	  }
	  boolean R=true,G=true,B=true;
	  for(int i=0;i<s.length()-2;i++) {
		  for(int j=i+1;j<s.length()-1;j++) {
			  if(s.substring(i, i+1).equals(s.substring(j, j+1)))continue;
			  else {
				  if(s.substring(i, i+1).equals("R"))R=false;
				  if(s.substring(i, i+1).equals("G"))G=false;
				  if(s.substring(i, i+1).equals("B"))B=false;
				  if(s.substring(j, j+1).equals("R"))R=false;
				  if(s.substring(j, j+1).equals("G"))G=false;
				  if(s.substring(j, j+1).equals("B"))B=false;
				  if(R) {
					  count+=r[j+1];
				  }else if(G) {
					  count+=g[j+1];
				  }else if(B) {
					  count+=b[j+1];
				  }
			  }
			  R=true;
			  G=true;
			  B=true;
			//System.out.println(count);
		  }
	  }
	  /*System.out.println(Arrays.toString(r));
	  System.out.println(Arrays.toString(g));
	  System.out.println(Arrays.toString(b));*/
	  System.out.println(count-buff);
  }
}

Measured memory_bytes: 57976
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <string.h>

using namespace std;
static const int MAXV = 81;

bool hantei(char* data);
void irekae(char* data);

int main() {
  while(!feof(stdin)) {
    char data[MAXV];
    if(fgets(data, sizeof(data), stdin)==NULL) break;
    while(!hantei(data))
      irekae(data);
    printf("%s", data);
  }
}

bool hantei(char* data) {
  if(strstr(data, "the")) return 1;
  if(strstr(data, "this")) return 1;
  if(strstr(data, "that")) return 1;
  return 0;
}

void irekae(char* data) {
  for(int i=0;data[i]!=0;i++) {
    if(data[i]>='a' && data[i]<='z') {
      if(data[i]=='z')data[i]='a';
      else data[i]++;
    }
  }
}

Measured memory_bytes: 0
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long ans[200000] = {};
long long pre_cost[200000] = {};
int main() {
	int n, r, l;
	cin >> n >> r >> l;
	vector<tuple<int, int, int>> hogea;
	hogea.push_back(make_tuple(0, 0, 0));
	REP(i, r) {
		int a, b, c;
		cin >> a >> b >> c;
		hogea.push_back(make_tuple(n-a,b, c));
	}
	hogea.push_back(make_tuple(0, l, 0));
	priority_queue<pair<int,int>> nexting;
	for (int i = 0; i < n; ++i) {
		nexting.push(make_pair(0, i));
		pre_cost[i] = 0;
	}
	r += 2;
	for (int i = 1; i < r; ++i) {
		while (true) {
			if (pre_cost[nexting.top().second] == nexting.top().first) {
				break;
			}
			nexting.pop();
		}
		ans[nexting.top().second] += get<1>(hogea[i]) - get<1>(hogea[i-1]);
		pre_cost[get<0>(hogea[i])] += get<2>(hogea[i]);
		nexting.push(make_pair(pre_cost[get<0>(hogea[i])], get<0>(hogea[i])));
	}
	long long bobo = -1;
	long long itr = 0;
	for (int i = 0; i < n; ++i) {
		if (bobo < ans[i]) {
			bobo = ans[i];
			itr = n - i;
		}
	}
	cout << itr << endl;
	return 0;
}


Measured memory_bytes: 25332
import java. util.Scanner; 

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h,m,s;
		int S = sc.nextInt();
		 h = S/3600;    		
		 m = S/60;
		 S = S%3600;
		 m= S/60;
		 S= S%60;
		System.out.println(h+":"+m+":"+S);
		
	
		
	}
}

Measured memory_bytes: 26256
#include <stdio.h>
 
int main() {
  double r, a, b;
  scanf("%lf",&r);
  a = r*r*3.14159265358979;
  b= 2*r*3.14159265358979;
 
  printf("%.8lf %.8lf\n",a,b);
  return 0;
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 998244353
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int gcd(int x,int y){
	while( x > 0 && y > 0){
		if(x>y) x %= y;
		else y %= x;
	}
	return x+y;
}
signed main(){
	int a,b;
	cin>>a>>b;
	int g = gcd(a,b);
	int ans = 1;
	for(int i=2; i*i <= g; i++){
		if( g%i == 0)ans ++;
		while( g % i == 0){
			g /= i;
		}
	}
	if( g != 1 ) ans ++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <math.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define repP(i, a, b) for(int i = a; i < b; i++)
#define repM(i, a, b) for(int i = a - 1; i >= b; i--)

using namespace std;

int main()
{
  int a = 0 , b = 0, c = 0, d = 0, e = 0, f = 0, i = 0, j = 0;
  int sum = 0, num = 0, count = 0, ans = 0, min = 0, max = 0;
  double d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0;
  int a1[999999], a2[999999], a3[999999];
  //char s1[200000], s2[200000], s3[200000];
  string s1, s2, s3;
  
  cin >> s1;
  if(s1 == "SUN"){
    cout << 7 << endl;
  }else if(s1 == "MON"){
    cout << 6 << endl;
      }else if(s1 == "TUE"){
    cout << 5 << endl;
      }else if(s1 == "WED"){
    cout << 4 << endl;
    }else if(s1 == "THU"){
    cout << 3 << endl;
   }else if(s1 == "FRI"){
    cout << 2 << endl;
    
    }else{
    cout << 1 << endl;
  }
}


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

int main()
{
    int n;
    bool was=false;
    cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
    }

    vector<int> cp(n);
    for(int i=0; i<n; i++){
        cp[i]=i+1;
    }
    
    int count = 0;
    for(int i=0; i<n; i++){
        if(p[i] != cp[i]) count++;
    }
    

    if(count == 2 || count  == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 384
n=int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)
for i in range(1,n+1):
    t[i],x[i],y[i]=map(int,input().split())
flag=True
for i in range(1,n+1):
    d=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
    tt=t[i]-t[i-1]
    if d<=tt and d%2==tt%2:
        continue
    else:
        flag=False
        break
print('Yes') if flag else print('No')


Measured memory_bytes: 11636
#include "bits/stdc++.h"
using namespace std;

int main() {
	int H, W;
	cin >> H >> W; 
	vector<vector<int>> A(H, vector<int>(W));
	for (int h = 0;h<H;++h) {
		for (int w = 0;w<W;++w) {
			cin >> A[h][w];
		}
	}
	vector<vector<int>> Ans;
	int memo = 1;
	for (int h = 0; h < H; ++h) {
		for (int w = 0; w < W; ++w) {
			if (1 == memo) {
				if (1 == A[h][w] % 2) {
					if (w != W-1) {
						A[h][w]--;
						A[h][w+1]++; 
						vector<int> vec = { h + 1,w + 1,h + 1,w + 2 };
						Ans.push_back(vec);
					}
					else {
						if (h != H - 1) {
							A[h][w]--;
							A[h + 1][w]++;
							vector<int> vec = { h + 1,w + 1,h + 2,w + 1 };
							Ans.push_back(vec);
						}
					}
				}
			}
			else {
				if (1 == A[h][W-1-w] % 2) {
					if (w != W - 1) {
						A[h][W - 1 - w]--;
						A[h][W - 2 - w]++;
						vector<int> vec = { h + 1,W - w,h + 1,W - 1 - w };
						Ans.push_back(vec);
					}
					else {
						if (h != H - 1) {
							A[h][W - 1 - w]--;
							A[h + 1][W - 1 - w]++;
							vector<int> vec = { h + 1,W - w,h + 2,W - w };
							Ans.push_back(vec);
						}
					}
				}
			}

		}
		memo *= -1;
	}
	cout << Ans.size()<<endl;
	for (int n = 0;n<Ans.size();++n) {
		cout << Ans[n][0]<<" " << Ans[n][1] << " " << Ans[n][2] << " " << Ans[n][3] <<endl;
	}
	return 0;
}

Measured memory_bytes: 11172
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
using namespace std;

int main() {
	int n;
	double value[55];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> value[i];
	}
	for (int i = 0; i < n - 1; i++) {
		for (int j = i; j < n; j++) {
			if (value[i] > value[j]) {
				swap(value[i], value[j]);
			}
		}
	}
	for (int i = 0; i < n - 1; i++) {
		value[i + 1] = (value[i] + value[i + 1]) / 2;
	}
	cout << value[n-1] << endl;
}

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

int main(){
string s;
  cin>>s;
  string ans="No";
  if(s.size()>=4){
    if(s.at(0)=='Y'&&s.at(1)=='A'&&s.at(2)=='K'&&s.at(3)=='I'){
      ans="Yes";
    }
  }
  cout<<ans<<endl;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll H[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    REP(i, N) {
        cin >> H[i];
    }
    sort(H, H + N);

    ll ans = INF;
    REP(i, N) {
        if (i + K - 1 >= N)
            break;
        ll h = abs(H[i + K - 1] - H[i]);
        ans = std::min(ans, h);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
using System;

public class Test
{
	public static void Main()
	{
		// your code goes here
		string s = Console.ReadLine();
		int k = s.Length;
		int win = 0, lose = 0;
		
		for(int i = 0; i < k; i++)
		{
			if(s[i] == 'o') win++;
			else lose++;
		}
		if(win + (15 - k) >= 8) Console.WriteLine("YES");
		else Console.WriteLine("NO");
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MX = 2005;
int N,X,Y;

int dp[MX][MX];

void bfs(int u){
	queue<int> q;
	int s = 0;
	q.push(u);
	set<int> st;
	st.insert(u);
	while(q.size()>0){
		int lq = q.size();
		for(int i=0; i<lq; i++){
			int v = q.front(); q.pop();
			dp[u][v] = min(dp[u][v], s);

			if(v-1>=1 && st.find(v-1)==st.end()){
				st.insert(v-1);
				q.push(v-1);
			}
			if(v+1<=N && st.find(v+1)==st.end()){
				st.insert(v+1);
				q.push(v+1);
			}

			if(v==X && st.find(Y)==st.end()){
				st.insert(Y);
				q.push(Y);
			}
		}
		s++;
	}
}

void solve(){
	for(int i=1; i<=N; i++){
		bfs(i);
	}
	vector<int> res(N, 0);

	for(int u=1; u<=N; u++){
		for(int v=u+1; v<=N; v++){
			int d = dp[u][v];
			res[d]++;
		}
	}

	for(int d=1; d<N; d++){
		cout<<res[d]<<endl;
	}
}


int main(){
	memset(dp, 0x0a, sizeof(dp));
	cin>>N>>X>>Y;
	solve();
    return 0;
}


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

int main(int argc, char** argv) {
  std::vector<int> v;
  int n, i;

  std::cin >> n;
  while (std::cin >> i) {
    v.push_back(i);
  }

  int lcm = 0;
  for (auto e : v) {
    lcm += (e - 1);
  }
  
  std::cout << lcm << std::endl;
  return 0;
}

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

#include <bits/stdc++.h>
using namespace std;

const int MX=100005;

int main()
{
    int n;
    cin>> n;
    int x=1000;
    while(x<n) x+=1000;
    cout<< x-n <<endl;
    return 0;
}

Measured memory_bytes: 3636
N, M = list(map(int, input().split(' ')))
A_list = list(map(int, input().split(' ')))
sum_A = sum(A_list)

count = 0
for A in A_list:
  if A >= sum_A / (4 * M):
    count += 1

if count >= M:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 38384
#python3
INF = int(1e9)
def main():
    a, b, c, x, y = map(int, input().split())
    ans = INF
    for i in range(2*10**5+100):
        t = 2*c*i + max(x-i, 0) * a + max(y-i, 0) * b
        ans = min(ans, t)
    print(ans)
main()

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b == c || a + c == b || b + c == a) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
const int INF=10000000;
const int MAX_N=50;

int main() {
    int n;
    cin >> n;
    vector <int> a(n);
    for(int i=0;i<n;++i) cin >> a[i];
    sort(a.begin(), a.end());
    int ans=a[n-1]-a[0];
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
char s[101],t[101];
int i,j,siz,c;
  scanf("%s %s",s,t);
  for(i=0;s[i]!='\0';i++);
  siz=i;
  c=siz-1;
  for(i=0;i<siz;i++){
  for(j=siz-1-i;j>-1-i;j--){
  if(j>=0){if(s[j]!=t[c])break;}
  else{if(s[siz+j]!=t[c])break;}
    c--;
  }
    if(j==-1-i)break;
    c=siz-1;
  }
  if(i==siz)printf("No");
  else printf("Yes");
  return 0;
 
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll d,t,s;
    cin>>d>>t>>s;
    if(d%s==0)
    {
        if((d/s) <= t)
            cout<<"Yes";
        else
            cout<<"No";
    }
    else
    {
        ll qu=(d/s)+1;
        if(qu <= t)
            cout<<"Yes";
        else
            cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3648
h,w,c,S,max;
int *_M;
int D(x,y,c,n){
	int r=1;
	_M[x+(w+2)*y]=n;
	if(_M[x-1+(w+2)*y]==c)r+=D(x-1,y,c,n);
	if(_M[x+1+(w+2)*y]==c)r+=D(x+1,y,c,n);
	if(_M[x+(w+2)*(y-1)]==c)r+=D(x,y-1,c,n);
	if(_M[x+(w+2)*(y+1)]==c)r+=D(x,y+1,c,n);
	return r;
}
E(int d,int *M){if(d<4||M[1+w+2]!=c){
	int *m=malloc(S);
	if(d==4){
		memcpy(_M=m,M,S);
		D(1,1,m[1+w+2],c);
		int k=D(1,1,m[1+w+2],-1,m);
		if(max<k)max=k;
	}else{
		int i=1;
		for(;i<7;i++)if(M[1+w+2]!=i){
			memcpy(_M=m,M,S);
			D(1,1,m[1+w+2],i,m);
			E(d+1,m);
		}
	}
	free(m);
}}
a[100];
main(i,j){for(;scanf("%d%d%d",&h,&w,&c),c;printf("%d\n",max)){
	memset(a,0,S=4*(w+2)*(h+2));
	for(j=1;j<h+1;j++)for(i=1;i<w+1;i++)scanf("%d",a+i+(w+2)*j);
	E(max=0,a);
}}

Measured memory_bytes: 624
#include<iostream>
#include<vector>
#include<queue>
#include<climits>
#include<cfloat>
#include<algorithm>
using namespace std;

#define NIL INT_MAX

class Node {
public:
    int vertex, ticket;
    double cost;
    Node(int v, int t, double c) :vertex(v), ticket(t), cost(c) {}
    bool operator<(Node a) const {
        if(cost != a.cost) return cost < a.cost;
        if(ticket != a.ticket) return ticket < a.ticket;
        return vertex < a.vertex;
    }
};

int n, m, p, a, b;
vector< vector<double> > matrix;
vector<double> cab;

void Dijkstra() {
    double answer = DBL_MAX;
    vector< vector<double> > distance(m, vector<double>(1<<n, NIL));
    priority_queue<Node> q;
    q.push(Node(a, 0, 0));
    while(!q.empty()) {
        Node now = q.top();
        q.pop();
        if(now.vertex == b) answer = min(answer, now.cost);
        for(int v=0; v<m; v++) {
            if(now.vertex == v) continue;
            if(matrix[now.vertex][v] == NIL) continue;
            for(int t=0; t<n; t++) {
                if(now.ticket & (1<<t)) continue;
                Node next(v, now.ticket ^ (1<<t), now.cost + matrix[now.vertex][v] / cab[t]);
                if(distance[v][next.ticket] <= next.cost) continue;
                distance[v][next.ticket] = next.cost;
                q.push(next);
            }
        }
    }
    if(answer == DBL_MAX) cout<<"Impossible"<<endl;
    else cout<<answer<<endl;
}

int main() {
    while(cin>>n>>m>>p>>a>>b, n|m|p|a|b) {
        a--; b--;
        matrix = vector< vector<double> >(m, vector<double>(m, NIL));
        cab.resize(n);
        for(int i=0; i<n; i++) cin>>cab[i];
        for(int i=0; i<p; i++) {
            int x, y;
            double z;
            cin>>x>>y>>z;
            x--; y--;
            matrix[x][y] = matrix[y][x] = z;
        }
        Dijkstra();
    }
}

Measured memory_bytes: 1432
from bisect import bisect,bisect_left
import sys
input=sys.stdin.readline

def main():
    n,q=map(int,input().split())
    xst=[]
    for i in range(n):
        s,t,x=map(int,input().split())
        xst.append([x,s-x,t-x])
    xst.sort()
    d=[None]*q
    for i in range(q):
        d[i]=int(input())
    ans=[-1]*q
    skip=[-1]*q
    for u in xst:
        x ,left ,right = u
        a=bisect_left(d,left)
        b=bisect_left(d,right)
        while a < b:
            if skip[a] == -1:
                ans[a]=x
                skip[a]=b
                a+=1
            else:
                a=skip[a]
    for u in ans:
        print(u)

if __name__=="__main__":
    main()

Measured memory_bytes: 58616
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>

const int kN = 2000 + 5;
int a[kN][kN], n, m;
char s[kN];

int work()
{
    int ret = std::max(n, m);
    int wall[kN] = {};
    std::fill(wall, wall + m, 1);
    for (int i = 1; i < n; ++ i) {
        for (int j = 1; j < m; ++ j) {
            if (a[i][j] == a[i - 1][j])
                wall[j] ++;
            else 
                wall[j] = 1;
        }
        std::vector<std::pair<int, int>> stack;
        for (int j = 1; j <= m; ++ j) {
            int rem = j;
            while (!stack.empty() && stack.back().second >= wall[j]) {
                int a = stack.back().first;
                int b = stack.back().second;
                stack.pop_back();
                ret = std::max(ret, (j - a + 1) * b);
                rem = a;
            }
            stack.emplace_back(rem, wall[j]);
        }
    }
    return ret;
}

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++ i) {
        scanf("%s", s);
        for (int j = 1; j < m; ++ j)
            a[i][j] = (s[j] == '#') ^ (s[j - 1] == '#');
    }
    printf("%d\n", work());
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
int n, a[100010];
int main()
{
    int n;
    scanf("%d", &n);
    int num = 0;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
        ans += a[i] * a[i];
        num += a[i];
    }
    int x = round(num * 1.0 / n);

    printf("%d\n", ans + n * x * x - 2 * num * x);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<int> vi;

signed main(){
    int a, b, c;
    cin >> a >> b;
    c = b/a;
    if(c*a==b) {
        cout << a+b << endl;
    } else {
        cout << b-a << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    int ans[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i<b&&j<a){ans[i][j]=1;}
            else if(i>=b&&j>=a){ans[i][j]=1;}
            else{ans[i][j]=0;}
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<ans[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 5120
#include <stdio.h>
#include <math.h>
#define min(a,b) ((a) > (b) ? (b) : (a))
int main() {
    long long int x,ans, a, b,n;
    scanf("%lld %lld %lld",&a, &b, &n);

     x = min(n, b-1);
    ans = floor(a*x/b) - a * floor(x/b);
    printf("%lld\n", ans);

}


Measured memory_bytes: 1732
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n ;
  string s;cin>>s;
  REP(i,n-2){
    if (s[i]=='A'){
      if (s[i+1]=='B'){
        if (s[i+2]=='C'){
          ans++;
        }
      }
    }
  }

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

Measured memory_bytes: 256
A = gets.split.map(&:to_i)
A.sort!
c = A[0]
b = A[1]
a = A[2]

ans = 0

if b % 2 != c % 2
  a += 1
  b += 1
  ans += 1
end

pls = a - (b + c) / 2
ans += pls
p ans

Measured memory_bytes: 1788
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>

#define ll long long int

using namespace std;

const int INF = (1<<30) - 1;

int to_right[6][6] = {
    {-1, 3, 5, 2, 4, -1},
    {4, -1, 1, 6, -1, 3},
    {2, 6, -1, -1, 1, 5},
    {5, 1, -1, -1, 6, 2},
    {3, -1, 6, 1, -1, 4},
    {-1, 4, 2, 5, 3, -1}
};

class Dice{
private:
    //female

    
    void init(int t, int f, int r){
        face = vector<int>(6);
        face[5] = t; face[4] = 7-t;
        face[0] = f; face[2] = 7-f;
        face[1] = r; face[3] = 7-r;
    }
    
public:
    // front right back left bottom top
    vector<int> face;
    
    Dice(int t, int f, int r){
        init(t, f, r);
    }
    Dice(int t, int f){
       init(t, f, to_right[t-1][f-1]);
    }
    
    void rot(int dir){
        int tmp = face[5];
        face[5] = face[(dir+2)%4]; face[(dir+2)%4] = face[4];
        face[4] = face[dir]; face[dir] = tmp;
    }
};

int hight[200][200];
int face[200][200];

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    while(cin>>N, N){
        memset(hight, 0, sizeof(hight));
        memset(face, 0, sizeof(face));
        
        while(N--){
            int t, f; cin >> t >> f;
            Dice dice = Dice(t, f);
            int x = 100, y = 100;
            while(true){
                int m = 0;
                int dir = -1;
                for(int i=0; i<4; i++){
                    int spot = dice.face[i];
                    int nx = x + dx[i];
                    int ny = y + dy[i];
                    if(4 <= spot && hight[ny][nx] < hight[y][x] && m < spot){
                        m = spot;
                        dir = i;
                    }
                }
                if(dir == -1)
                    break;
                dice.rot(dir);
                x += dx[dir]; y += dy[dir];
            }
            hight[y][x]++;
            face[y][x] = dice.face[5];
        }
        
        vector<int> ans(6);
        
        for(int x=0; x<200; x++)
            for(int y=0; y<200; y++) if(face[y][x] > 0)
                ans[face[y][x]-1]++;
        
        for(int i=0; i<6; i++)
            cout << ans[i] << (i !=5 ? " " : "\n");
    }
    return 0;
}

Measured memory_bytes: 1520
import math
N = int(input())
res = [0 for _ in range(N + 1)]

for i in range(1, N + 1):
	for j in range(1, N + 1):
		if j < i or j % 2 == 0: continue
		if j % i == 0:
			res[j] += 1
ctr = 0			
for r in res:
	if r == 8:
		ctr += 1
		
print(ctr)

Measured memory_bytes: 39792
#include<bits/stdc++.h>
using namespace std;
 
int main(){
   
  int n,c;
  
  cin >> n >> c;
  
  int ans = 0,cake = 0;
  
  for(int i=0; i<c; i++){
  	int p;
  	cin >> p;
  	cake += p;
  }
  
  ans = cake / (1+n);
  
  if(cake%(1+n) > 0){
  	ans++;
  }
  
  cout << ans << endl;
  
  
 
  return 0;
}


Measured memory_bytes: 3124
#include<iostream>

using namespace std;

int main() {
	int a[2][3], b[2][3], c[2][3];
	int aa, bb, cc;
	for (int i = 0; i < 2; i++){
		for (int j = 0; j < 3; j++){
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> b[i][j];
		}
	}
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}
	aa = a[1][0] * 3600 + a[1][1] * 60 + a[1][2] - (a[0][0] * 3600 + a[0][1] * 60 + a[0][2]);
	bb = b[1][0] * 3600 + b[1][1] * 60 + b[1][2] - (b[0][0] * 3600 + b[0][1] * 60 + b[0][2]);
	cc = c[1][0] * 3600 + c[1][1] * 60 + c[1][2] - (c[0][0] * 3600 + c[0][1] * 60 + c[0][2]);
	cout << (aa - (aa % 3600 - aa % 60) - aa % 60) / 3600 << " " << (aa % 3600 - aa % 60) / 60 << " " << aa % 60 << endl;
	cout << (bb - (bb % 3600 - bb % 60) - bb % 60) / 3600 << " " << (bb % 3600 - bb % 60) / 60 << " " << bb % 60 << endl;
	cout << (cc - (cc % 3600 - cc % 60) - cc % 60) / 3600 << " " << (cc % 3600 - cc % 60) / 60 << " " << cc % 60 << endl;

}

Measured memory_bytes: 3072
#include <vector>
#include <iostream>

using namespace std;

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

	vector<int> key(H + 1, 0);

	for (int i = 1; i <= H; i++)
		cin >> key[i];

	for (int i = 1; i <= H; i++)
	{
		cout << "node " << i << ": key = " << key[i] << ", ";

		if (i / 2 != 0)
		{
			cout << "parent key = " << key[i / 2] << ", ";
		}

		if (2 * i <= H)
		{
			cout << "left key = " << key[2 * i] << ", ";
		}

		if (2 * i < H)
		{
			cout << "right key = " << key[2 * i + 1] << ", ";
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3080
//
// Created on 2020/05/14.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    vector<int>x(11);
    int d;
    int r;
    cin>>r>>d>>x[0];

    for (int i = 1; i <= 10; ++i) {
        x[i] = x[i-1] * r - d;
        cout<<x[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
// B_i >= max(A_i, A_{i+1})より
// A_i <= B_i		(1)
// A_{i+1} <= B_i	(2)
// (2)より, i=2,...,N-1のときは
// A_i <= B_{i-1}
// これらより
// A_1 <= B_1
// A_i <= min(B_{i-1}, B_i)	(i=2,...,N-1)
// A_N <= B_{N-1}

// ゆえに考えうる最大値は
// sum = B_1 + min(B_1, B_2) + ... + min(B_{N-2}, B_{N-1}) + B_{N-1}

#include<stdio.h>
int main(){
  int n;
  int sum = 0;
  int b_now, b_pre;
  scanf("%d", &n);
  
  // B_1の取得
  scanf("%d", &b_now);
  sum += b_now;
  b_pre = b_now;
  
  // B_iの取得と計算
  int i;
  for(i=2; i<n; i++){
    scanf("%d", &b_now);
    sum += (b_pre < b_now) ? b_pre : b_now;
    b_pre = b_now;
  }
  
  sum += b_pre;
  printf("%d", sum);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/
/*
int dfs(int foo, int timer)
{
    //foo is node number
    if (finds[foo].first != -1)
        return timer;
    finds[foo].first = ++timer;
    int result = timer;
    if (data[foo].size() != 0)
    {
        rep(i, data[foo].size())
        {
            result = dfs(data[foo][i], result);
        }
    }
    finds[foo].second = ++result;
    return result;
}
*/
int main(){
    string str;
    cin>>str;
    int changepoint=0;
    int now=str[0];
    REP(i,1,str.size()){
        if(str[i]==now) continue;
        else{
            now= str[i];
            changepoint++;
        }
    }
    cout<<changepoint<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;
int main() {
  int N,D,sum,ans = 0;
  int x[10][10];
  int i,j,k;
  cin >> N >> D;
  for(i=0;i<N;i++)for(j=0;j<D;j++)cin >> x[i][j];
  for(i=0;i<N-1;i++)for(j=i+1;j<N;j++) {
    sum=0;
    for(k=0;k<D;k++)sum += pow(x[i][k]-x[j][k],2.0);
    if(sqrt(sum) == floor(sqrt(sum)))ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    fun calcMana(a: Pair<Int, Int>, b: Pair<Int, Int>) =
            (Math.abs(a.first - b.first) + Math.abs(a.second - b.second)).toLong()
    val (h, w, d) = readLine()!!.split(' ').map(String::toInt)
    val pArray = Array((h * w + 1)) { Pair(0, 0) }
    val mArray = Array((h * w + 1)) { 0L }
    for (i in 1..h) {
        val aList = readLine()!!.split(' ').map(String::toLong)
        for (j in 1..w) {
            pArray[aList[j - 1].toInt()] = Pair(i, j)
        }
    }
    for (start in 1..d) {
        var curP = start
        var nextP = curP + d
        while (nextP <= h * w) {
            val mana = calcMana(pArray[curP], pArray[nextP])
            mArray[nextP] = mArray[curP] + mana
            curP = nextP
            nextP += d
        }
    }

    val q = readLine()!!.toInt()
    for (i in 1..q) {
        val (l, r) = readLine()!!.split(' ').map(String::toInt)
        println(mArray[r]-mArray[l])
    }
}

Measured memory_bytes: 80652
#include<stdio.h>
int main(){
    int box[100000];
    int count=0;
    int sum=0;
    int N,M,C;
    scanf("%d%d%d",&N,&M,&C);
    for(int i=0;i<M*(N+1);i++){
        scanf("%d",&box[i]);
    }
    for(int n=1;n<N+1;n++){
        for(int m=0;m<M;m++){
            sum=sum+box[m+M*n]*box[m];
        }
        if((sum+C)>0){
            count++;
        }
        sum=0;
    }
    printf("%d\n",count);
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void) {
	int a, b, d, r;
	double f;

	scanf("%d %d", &a, &b);
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	printf("%d %d %.5lf\n", d, r, f);

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[100010];

int main() {
	ll n,x;
	cin>>n>>x;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
		ll now=abs(x-a[i-1]-a[i]);
		if(a[i-1]+a[i]>x){
			ans+=now;
			a[i]=a[i]-now;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int n;cin>>n;
    int r;cin>>r;
    cout<<r+max(0,100*(10-n))<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll a;
	cin >> a;
	if(a%2==1)
	cout << 0 << endl;
	else{
		ll t=10;
		ll ans=0;
		ll c;
		while(c=a/t){
			ans+=c;
			t*=10;
		}
		t=50;
		while(c=a/t){
			ans+=c;
			t*=5;
		}
		t=100;
		while(c=a/t){
			ans-=c;
			t*=10;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    IOS;
    //freopen("inputfile.txt","r",stdin);
    ll d,t,s;cin>>d>>t>>s;
    //cout<<(double)d/s<<endl;cout<<t<<endl;
    if((double)((double)d/(double)s)<=t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
#include <queue>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

/*struct three {
    int warter;
    int sugar;
    double nodo;

    bool operator<( const three& right) const {
        return nodo < right.nodo;
    }
}*/


int main(int argc, char const *argv[]) {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    double nodo = 0.0;
    int ans_w = 100*a;
    int ans_s = 0;
    for (int i = 0; 100*i*a <= f; ++i) {
        for (int j = 0; 100*i*a+100*j*b <= f; ++j) {
            int wat = 100*i*a+100*j*b;
            if (wat == 0) continue;
            for (int k = 0; wat+k*c <= f; ++k) {
                for (int l = 0; wat+k*c+l*d <= f; ++l) {
                    int sug = k*c+l*d;
                    if ((double)sug/wat <= e/100.0) {
                        if ((double)sug/(wat+sug) > nodo) {
                            ans_w = wat;
                            ans_s = sug;
                            nodo = (double) sug/(wat+sug);
                        }
                    }
                }
            }
        }
    }

    cout << ans_w+ans_s << " " << ans_s << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	if(m1>m2)
	{
		h2--;
		m2+=60;
	}
	int x=(h2-h1)*60+(m2-m1);
	cout<<x-k<<endl;
	return 0;
}




Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int h[100000];
int main(int argc, const char * argv[])
{
    int n,k,ans;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>h[i];
    sort(h, h+n);
    for(int i=0;i<n-k+1;i++)
    {
        int diff=h[i+k-1]-h[i];
        if(i==0 || diff<ans)
            ans=diff;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
using P = pair<int, int>;

vector<int>  dx = {1, 0, -1, 0};
vector<int>  dy = {0, 1, 0, -1};

const int INF = 1<<30;

int main(void){
    int h, w;
    cin >> h >> w;
    
    vector<string> maze(h);
    rep(i, h) cin >> maze[i];
    
    int ans = 0;
    
    rep(sx, h) rep(sy, w){
        
        //スタート地点が壁マスならば, そもそもBFSする必要がない
        if(maze[sx][sy] == '#') continue;
        
        //距離を記録する配列を用意する
        vector<vector<int>> dist(h, vector<int>(w, INF));
        
        
        queue<P> que;
        
        que.push(P(sx, sy));
        dist[sx][sy] = 0;
        
        while(que.size()){
            P p = que.front();
            que.pop(); //queueから取り出した点（探索を行う点）をqueueから除去しないと無限ループに陥る
            
            rep(i, 4){
                int nx = p.first + dx[i];
                int ny = p.second + dy[i];
                
                if(nx < 0 || h <= nx || ny < 0 || w <= ny) continue;//迷路の外ならば探索をしない
                if(maze[nx][ny] == '#') continue; //壁マスならば探索をしない
                if(dist[nx][ny] != INF) continue; //すで一度訪れているマスならば探索をしない
                
                que.push(P(nx, ny));
                dist[nx][ny] = dist[p.first][p.second] + 1;
            }
            
        }
        
        //ゴール地点の候補をすべて探索してansを更新する
        rep(i, h) rep(j, w){
            if(dist[i][j] == INF) continue;
            ans = max(ans, dist[i][j]);
        }
        
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    rep(i,s.size()){
        cout << 'x';
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a * b // gcd(a, b)

n = int(input())
a = [int(input()) for _ in range(n)]

if n == 1:
    print(a[0])
    exit()

for i in range(n-1):
    if i == 0:
        b = lcm(a[i],a[i+1])
    else:
        b = lcm(b,a[i+1])
print(b)

Measured memory_bytes: 3064
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto S = readln.chomp;
    long solve(size_t i, long sum) {
        if (i == S.length) return sum;
        long r;
        foreach (j; i+1..S.length+1) {
            r += solve(j, sum + S[i..j].to!long);
        }
        return r;
    }
    writeln(solve(0, 0));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, k; cin >> n >> k;
	ll ans = 0;
	for(int b = k + 1; b <= n; b++){
		ans += ((n - b + 1) / b + 1) * (b - k);
		
		if((n - b + 1) / b != (n - k) / b){
			ans += min((n - k) % b + 1, b - k);
		}
		//dbg(b, ans);
	}
	if(k == 0) ans -= n;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
def make_2d_array(n, m, init)
  n.times.map{[init] * m}
end

def min(a, b)
  a < b ? a : b
end

n, _   = gets.split(' ').map(&:to_i)
# Available coins
coins = gets.split(' ').map(&:to_i)

# Initialize DP table
dp_table = make_2d_array(coins.size+1, n+1, 0) # (coins.size + 1).times{[nil] * (coins.size + 1)}
(1..n).each{|j|
  dp_table[0][j] = Float::INFINITY
}
dp_table[0][0] = 0


(1..coins.size).each{|i|
  (0..n).each{|j|
    coin = coins[i-1]
    if 0 <= j - coin
      dp_table[i][j] = min(dp_table[i-1][j], dp_table[i][j - coin] + 1)
    else
      dp_table[i][j] = dp_table[i-1][j]
    end
  }
}


puts(dp_table[-1][-1])


Measured memory_bytes: 15124
import Control.Applicative
import Control.Monad
import Data.List

main = do
  [n, k] <- map read . words <$> getLine
  xy <- map (map read) . map words <$> replicateM n getLine
  print $ solve xy k

solve :: [[Int]] -> Int -> Int
solve xy k = minimum . map (\(x1, y1, x2, y2) -> (x2 - x1) * (y2 - y1)) . filter ((>= k) . count xy) $ bs
  where
    [xs, ys] = transpose xy
    bs = [(x1, y1, x2, y2) | x1 <- xs, x2 <- xs, y1 <- ys, y2 <- ys, x1 < x2, y1 < y2]

count :: [[Int]] -> (Int, Int, Int, Int) -> Int
count xy (x1, y1, x2, y2) = length . filter (\[x, y] -> x1 <= x && x <= x2 && y1 <= y && y <= y2) $ xy

Measured memory_bytes: 2428
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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 N;
ll A, B, C;
vll L;

ll rec(ll n, ll a, ll b, ll c)
{
    if (n == N)
    {
        if (a == 0 || b == 0 || c == 0)
        {
            return INF;
        }

        return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    }

    ll ans = INF;
    chmin(ans, rec(n + 1, a       , b       , c       )     );
    chmin(ans, rec(n + 1, a + L[n], b       , c       ) + 10);
    chmin(ans, rec(n + 1, a       , b + L[n], c       ) + 10);
    chmin(ans, rec(n + 1, a       , b       , c + L[n]) + 10);

    return ans;
}

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    in1(N);
    in3(A, B, C);

    L.resize(N);
    rep(i, N) in1(L[i]);

    outl(rec(0, 0, 0, 0));

    return 0;
}


Measured memory_bytes: 3664
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

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

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll A, B;
    cin >> A >> B;

    if(A>8 || B>8){
        p(":(");
    }else{
        p("Yay!");
    }
    
    return 0;
}

Measured memory_bytes: 256
//
//AtCoder Beginner Contest 127
//B - Algae
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#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 ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int r, d, x;
    cin >> r >> d >> x;

    REP(i,10){
        x = x*r-d;
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	ll a[3];
	for(ll i=0;i<3;i++)
    {
        cin>>a[i];
    }
	sort(a,a+3);
	if(a[0]==a[1]&&a[1]!=a[2]) cout<<"Yes";
	else if(a[1]==a[2]&&a[0]!=a[1]) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
using namespace std;
int N;
long A,B,S;
long dp[50][2][2];
main()
{
	cin>>N>>A>>B;
	for(int i=2;i<N;i++)
	{
		long x;cin>>x;S^=x;
	}
	for(int i=0;i<50;i++)
	{
		int a=A>>i&1,b=B>>i&1;
		for(int j=0;j<2;j++)for(int k=0;k<2;k++)
		{
			long now=A;
			for(int J=0;J<2;J++)for(int K=0;K<2;K++)for(int x=0;x<2;x++)
			{
				int aa=a+2*j-x-J,bb=b-2*k+x+K;
				if(0<=aa&&aa<=1&&0<=bb&&bb<=1&&(aa^bb)==(S>>i&1))
				{
					if(i==0)
					{
						if(J==0&&K==0)now=min(now,(long)x);
					}
					else
					{
						now=min(now,dp[i-1][J][K]+((long)x<<i));
					}
				}
			}
			dp[i][j][k]=now;
		}
	}
	long ans=dp[49][0][0];
	cout<<(ans<A?ans:-1)<<endl;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	LL n;
	cin>>n;
	FOR(i,1,3501){
		FOR(j,1,3501){
			LL s=n*i*j;
			LL t=4*i*j-n*j-n*i;
			if(t<=0||s%t!=0)continue;
			if(s/t<=3500){
				cout<<i<<" "<<j<<" "<<s/t<<endl;
				return 0;
			}
		}
	}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, k;
	scanf("%d%d%d", &a, &b, &k);
	for(int i = 1; i <= k; ++ i)
		if(i & 1)
		{
			if(a & 1)
				-- a;
			b += a / 2;
			a /= 2;
		}
		else
		{
			if(b & 1)
				-- b;
			a += b / 2;
			b /= 2;
		}
	printf("%d %d", a, b);
	return 0;
}

Measured memory_bytes: 256