akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstring>
#include <unordered_set>
#include <chrono>
#include <cassert>

//#pragma GCC optimize("Ofast,unroll-loops,fast-math,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt")
//#pragma GCC target("avx,avx2")

using namespace std;

#define int long long
#define pii pair<int, int>
#define mp make_pair
const int SZ = 5e5 + 4;
const int inf = 2e9;
int hashpow = 41;
int mod = 1e9 + 7;

int n;
int a[SZ];

inline void read() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
}

inline void solve() {
    vector<vector<int>> p;
    vector<int> ans;
    ans.push_back(a[0]);
    for (int i = 1; i < n; ++i) {
        if (a[i] > a[i - 1]) {
            ans.push_back(a[i]);
        } else {
            p.push_back(ans);
            ans.clear();
            ans.push_back(a[i]);
        }
    }
    p.push_back(ans);

    int tmp = 1000;
    for (auto& v : p) {
        int x = tmp / v.front() * v.back();
        tmp = tmp % v.front() + x;
    }
    cout << tmp << "\n";
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
        read();
        solve();
//    }

    return 0;
}

Measured memory_bytes: 3652
// Problem : B - Power Socket
// Contest : AtCoder - AtCoder Beginner Contest 139
// URL : https://atcoder.jp/contests/abc139/tasks/abc139_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int a,b;
	cin >> a >> b;
	if(b == 1)
	{
		cout << 0;
		return;
	}
	int cnt=a;
	int ans=1;
	while(cnt < b)
	{
		cnt +=a;
		cnt -= 1;
		ans++;
	}
	//cout << cnt <<" ";
	cout << ans ;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3592
def main():
    S = input()
    from string import ascii_lowercase
    dic = {a: i for i, a in enumerate(ascii_lowercase)}
    rdic = {i: a for i, a in enumerate(ascii_lowercase)}
    if len(S) != 26:
        for s in ascii_lowercase:
            if s not in S:
                return print(S + s)
    elif S == "zyxwvutsrqponmlkjihgfedcba":
        return print(-1)

    pre = S[-1]
    mi = [pre]
    for i, s in enumerate(S[-2::-1], start=2):
        if s < pre:
            m = min(mi, key=lambda p: s > p)
            return print(S[:-i] + m)
        pre = s
        mi.append(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
//============================================================================
// Name        : ITP_1_7_A.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int m,f,r;
	do {
		cin >> m >> f >> r;
		if (m==-1&&f==-1&&r==-1) break;
		if (m==-1||f==-1) {
			cout << "F" << endl;
		} else if (m+f>=80) {
			cout << "A" << endl;
		} else if (m+f>=65) {
			cout << "B" << endl;
		} else if (m+f>=50) {
			cout << "C" << endl;
		} else if (m+f<30) {
			cout << "F" << endl;
		} else if (r>=50) {
			cout << "C" << endl;
		} else {
			cout << "D" << endl;
		}
	} while(1);
	return 0;
}

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

int Matriz[505][505];
int Resultados[250005][4];

int main(){
	int H,W;
	int aux;
	scanf("%d %d",&H,&W);
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			scanf("%d",&aux);
			Matriz[i][j]=aux;
		}
	}
	int contador=0;
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			aux = Matriz[i][j];
			if (aux%2==1){
				if (j<W-1){
					Matriz[i][j+1]++;
					Resultados[contador][0]=i+1;
					Resultados[contador][1]=j+1;
					Resultados[contador][2]=i+1;
					Resultados[contador][3]=j+2;
					contador++;
				}else{
					if (i<H-1){
						Matriz[i+1][j]++;
						Resultados[contador][0]=i+1;
						Resultados[contador][1]=j+1;
						Resultados[contador][2]=i+2;
						Resultados[contador][3]=j+1;
						contador++;
					}
				}
			}
		}
	}
	cout << contador << endl;
	for (int i = 0; i < contador; ++i)
	{
		cout << Resultados[i][0] << " " << Resultados[i][1] << " " << Resultados[i][2] << " " << Resultados[i][3] << endl;
	}
	return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

int main(){
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    cout<<(H-h)*(W-w)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int a,b,c ;

int main(void){
    
    scanf("%d%d%d",&a,&b,&c) ;
    
    if ( b-a==c-b ){
        printf ("YES\n") ;
    } else {
        printf ("NO\n") ;
    }

    return 0 ;
    
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <iomanip>
#include <math.h>
#include <time.h>
#include <chrono>
#include <sstream>
#include <sys/stat.h>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <numeric>

using namespace std;

int main(){
	double l;
	cin >>l;

	printf("%.12f",(l/3)*(l/3)*(l/3));

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
typedef pair<int,int> PII;
#define FF first
#define SS second
const int N = 50 + 5;

int arr[N];
vector<PII> ans;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n; cin >> n;
	for(int i=1;i<=n;i++) cin>>arr[i];
	int mx=1, mi=1;
	for(int i=2;i<=n;i++){
		if(arr[i]>arr[mx]) mx=i;
		if(arr[i]<arr[mi]) mi=i;
	}
	cout << 2*n-1 << '\n';
	if(abs(arr[mx]) >= abs(arr[mi])){
		for(int i=1;i<=n;i++){
			if(i==mx) continue;
			arr[i] += arr[mx];
			cout << mx << ' ' << i << '\n';
		}
		arr[mx] += arr[mx];
		cout << mx << ' ' << mx << '\n';
		for(int i=2;i<=n;i++){
			arr[i] += arr[i-1];
			cout << i-1 << ' ' << i << '\n';
		}
	}else{
		for(int i=1;i<=n;i++){
			if(i==mi) continue;
			arr[i] += arr[mi];
			cout << mi << ' ' << i << '\n';
		}
		arr[mi] += arr[mi];
		cout << mi << ' ' << mi << '\n';
		for(int i=n-1;i>=1;i--){
			arr[i] += arr[i+1];
			cout << i+1 << ' ' << i << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1505;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
char s[MAXN][MAXN]; int n, a[MAXN][MAXN];
int l[MAXN][MAXN], r[MAXN][MAXN], res[MAXN][MAXN];
int main() {
	read(n);
	for (int i = 1; i <= n; i++) {
		scanf("%s", s[i] + 1);
		for (int j = 1; j <= n; j++)
			if (s[i][j] == '#') a[i][j] = 0;
			else a[i][j] = s[i][j] - '0';
	}
	ll finalans = 0;
	for (int i = n; i >= 1; i--)
	for (int j = n; j >= 1; j--) {
		if (a[i][j] != 0) {
			if (a[i + 1][j] == 0 && a[i][j + 1] == 0) l[j][i] = r[j][i] = j;
			else if (a[i + 1][j] == 0) {
				for (int k = i; k <= n; k++) {
					l[j][k] = l[j + 1][k];
					r[j][k] = r[j + 1][k];
				} l[j][i] = j;
				res[i][j] = res[i][j + 1];
			} else if (a[i][j + 1] == 0) {
				l[j][i] = r[j][i] = j;
				res[i][j] = res[i + 1][j];
			} else {
				int Max = 0, ans = res[i + 1][j] + res[i][j + 1];
				l[j][i] = j, r[j][i] = r[j + 1][i];
				for (int k = i + 1; k <= n; k++) {
					if (r[j][k] >= l[j + 1][k] && l[j + 1][k] > Max) ans -= res[k][l[j + 1][k]];
					chkmax(Max, r[j][k]);
					chkmax(r[j][k], r[j + 1][k]);
					chkmin(l[j][k], l[j + 1][k]);
				}
				res[i][j] = ans;
			}
			finalans += a[i][j] * res[i][j];
			res[i][j] += a[i][j];
		} else {
			for (int k = i; k <= n; k++)
				l[j][k] = n + 1, r[j][k] = 0;
		}
	}
	cout << finalans << endl;
	return 0;
}

Measured memory_bytes: 37888
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n = ni()
    c = ns()
    r = c.count('R')
    print(r - c[:r].count('R'))
    return

solve()


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

int main() {
  string o,e; cin >>o >>e;
  bool baba = o.size() - e.size();
  
  if (baba){
    for (int i=0; i<e.size(); i++){
      cout <<o.at(i) <<e.at(i);
    }
    cout <<o.at(o.size()-1) <<endl;
  }else{
    for (int i=0; i<o.size(); i++){
      cout <<o.at(i) <<e.at(i);
    }
    cout <<endl;
  }
}


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

signed main(){
  int N,A,B;
  cin>>N>>A>>B;
  int ans=0;
  if(A*N>=B)ans=B;
  if(A*N<B)ans=A*N;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    char ch;
    int ch_;
    int ans[10001];
    int k = 3;
    int i;
    for( i = 1; i<= k; i++){
        k++;
        scanf("%c", &ch);
        if( ch >= 'A' && ch <= 'Z' ){
            ans[i] = ch + 32;
        } else if( ch >= 'a' && ch <= 'z' ){
            ans[i] = ch - 32;
        } else if( ch != '\n' ){
            ans[i] = ch;
        } else {
            break;
        }
    }
    for(int j = 1; j<=i - 1;j++){
        printf("%c", ans[j]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n, before = 0, after = 0;
    string s;
    cin >> n >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '(') after++;
        else after--;
        if (after < 0)
        {
            before++;
            after++;
        }
    }
    for (int i = 0; i < before; i++) cout << '(';
    cout << s;
    for (int i = 0; i < after; i++) cout << ')';
}

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

int main() {
  int a, b; cin >> a >> b;
  int ans = 0;
  for (int n=a; n<=b; ++n) {
    string s = to_string(n);
    if (s[0] == s[4] && s[1] == s[3]) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
l=list(map(int,input().split()))
d=[0]*n
for i in range(1,n):
    x=l[i]
    d[i]=min([d[j]+abs(l[j]-x) for j in range (max (0,i-k),i)])
print(d[n-1])

Measured memory_bytes: 13980
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,s[100],ans,rans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
        rans+=s[i];
    }
    sort(s,s+n);
    for(int i=0;i<n;i+=2){
        ans+=s[i];
    }
    cout<<abs(2*ans-rans)<<endl;
}


Measured memory_bytes: 256
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*  ________       __      ________  _    __       __       ________               *
* |  ______|     /  \    |  ____  || |  / /      /  \     |  ____  |              *
* | |______     / /\ \   | |____| || |_/ /      / /\ \    | |____| |              *
* |______  |   / /__\ \  |  __  __||  __ \     / /__\ \   |  __  __|              *
*  ______| |  / ______ \ | |  \ \  | |  \ \   / ______ \  | |  \ \                *
* |________| /_/      \_\|_|   \_\ |_|   \_\ /_/      \_\ |_|   \_\               *
*                                                                                 *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________

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

int main()
{
	int N,M,i;

	cin >> N >> M;
	if(N >= M)
	{
	    for(i = 1; i <= N; i++)
	    {
		    cout << M;
	    }

        cout << endl;
    }

    else
    {
    	for(i = 1; i <= M; i++)
	    {
		    cout << N;
	    }

        cout << endl;

    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    string s; cin >> s;
    int c0=0;
    int c1=0;
    rep(i,s.size()){
        if (s[i]=='0'){
            c0++;
        }else{
            c1++;
        }
    }
    cout << 2*min(c0,c1) << endl;
}


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

using namespace std;

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

    for(int i = 0; i < 3; i++) {
        if(n[i] == '1'){
            n[i] = '9';
            continue;
        }
        else if (n[i] == '9'){
            n[i] = '1';
        }
    }
    cout << n << endl;

    return 0;
}

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

const int N = 21;
const int inf = 1e9;

int mat[N][N];
int dist[N][N][N][N];

void getAC() {	
	ios_base :: sync_with_stdio(false); cin.tie(0);
	int n , m; cin >> n >> m;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= m; ++j) {
			char c; cin >> c;
			mat[i][j] = c == '.';
		}
	}

	for(int a = 1; a <= n; ++a) {
		for(int b = 1; b <= m; ++b) {
			for(int c = 1; c <= n; ++c) {
				for(int d = 1; d <= m; ++d) {
					if(a == c && b == d) {
						dist[a][b][c][d] = 0;
						continue;
					}
					if(!mat[a][b] || !mat[c][d]) {
						dist[a][b][c][d] = inf;
						continue;
					}
					if(a == c && abs(b - d) == 1) {
						dist[a][b][c][d] = 1;
						continue;
					}
					if(b == d && abs(a - c) == 1) {
						dist[a][b][c][d] = 1;
						continue;
					}
					dist[a][b][c][d] = inf;
				}
			}
		}
	}

	for(int a = 1; a <= n; ++a) {
		for(int b = 1; b <= m; ++b) {
			for(int c = 1; c <= n; ++c) {
				for(int d = 1; d <= m; ++d) {
					for(int e = 1; e <= n; ++e) {
						for(int f = 1; f <= m; ++f) {
							dist[c][d][e][f] = min(dist[c][d][e][f], dist[c][d][a][b] + dist[a][b][e][f]);
						}
					}
				}
			}
		}
	}

	int ans = 0;

	for(int a = 1; a <= n; ++a) {
		for(int b = 1; b <= m; ++b) {
			for(int c = 1; c <= n; ++c) {
				for(int d = 1; d <= m; ++d) {
					if(mat[a][b] && mat[c][d]) {
						ans = max(ans, dist[a][b][c][d]);
					}
				}
			}
		}
	}
	cout << ans << '\n';

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

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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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

const int N = 1e5 + 5;

int C[N];
vector<int> G[N];
bool ok = true;

int DFS(int v, int c = 1) {
	C[v] = c;
	int sz = 1;
	for (int u : G[v]) {
		if (!C[u]) sz += DFS(u, 3 - c);
		else if (C[u] == C[v]) ok = false;
	}
	return sz;
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);


	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int v, u; cin >> v >> u;
		G[v].push_back(u);
		G[u].push_back(v);
	}
	int iso = 0, bip = 0, pib = 0;
	for (int i = 1; i <= n; i++) if (!C[i]) {
		ok = true;
		int sz = DFS(i);
		if (sz == 1) iso++;
		else if (ok) bip++;
		else pib++;
	}
	cout << 1LL * iso * iso + 1LL * (n - iso) * iso + 1LL * iso * (n - iso) + 2LL * bip * bip + 1LL * bip * pib + 1LL * pib * bip + 1LL * pib * pib << endl;

	return 0;
}


Measured memory_bytes: 9984
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int a[]=new int[N];
		for(int i=0;i<N;i++) {
			a[i]=sc.nextInt();
		}
		sc.close();
		int cost[]=new int[201];
		for(int i=0;i<201;i++)
			cost[i]=0;
		for(int i=0;i<201;i++) {
			for(int j=0;j<N;j++) {
				cost[i]+=Math.pow(a[j]-(i-100), 2);
			}
		}
		int min=cost[0]; 
		for(int i=0;i<201;i++) {
			if(min>cost[i])
				min=cost[i];
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep(i, n) for(int i=0; i<n; i++)
#define rep_one(i, n) for(int i=1; i<n; i++)
using namespace std;
typedef long long ll;

int main(){
    int n; cin >> n;
    int count[100003];
    rep(i, 100003) count[i] = 0;
    int tmp;
    ll sum=0;
    rep(i, n){
        cin >> tmp;
        count[tmp]++;
        sum += tmp;
    }
    int q; cin >> q;
    int b[q], c[q];
    rep(i, q) cin >> b[i] >> c[i];
    ll ans[q+1];
    ans[0] = sum;
    rep(i, q){
        ans[i+1] = ans[i] + (c[i]-b[i])*count[b[i]];
        count[c[i]] += count[b[i]];
        count[b[i]] = 0;
    }
    rep(i, q) cout << ans[i+1] << endl;
}


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll n,a,b; cin >> n >> a >> b;
    vector<ll> x(n); rep(i,n) cin >> x[i];
    ll ans = 0;
    rep(i,n-1){
        ll cost = (x[i+1]-x[i])*a;
        ans += (cost < b) ? cost : b;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

#define MAX_N 100
#define MIL_DAYS 196470

int main()
{
	int i, N;
	int y, m, d;
	int days = 0;
	scanf("%d", &N);
	for (i = 0; i < N; i++)
	{
		scanf("%d %d %d", &y, &m, &d);
		if(y % 3 == 0){
			days += (d-1);
			days += 20*(m-1);
		}else{
			days += (d-1);
			days += (19+20)*((m-1)/2)+((m-1)%2)*20;
		}
		days += ((y-1)/3)*10*20+((y-1)-(y-1)/3)*5*(20+19);
		printf("%d\n", MIL_DAYS-days);
		days = 0;
	}
	return 0;
}

Measured memory_bytes: 1028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        
        static void Solve()
        {
            var o = ReadAndParseIntArr();
            var hash = new HashSet<int>();
            foreach(int i in o)
            {
                if( !hash.Contains(i))
                {
                    hash.Add(i);
                }
            }
            Console.WriteLine(hash.Count);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int N,M;
	cin>>N>>M;
	int n1,n2,n3;
	int a,b,c;
	a=10000;b=5000;c=1000;
	int s1=-1,s2=-1,s3=-1;
	if(N*a<M||c*N>M)
	{
		s1=s2=s3=-1;
	}
	else
	{
		
		n1 = M/a;
		for(n1;n1>=0;n1--)
		{
			int flag=0;
			n2 = (M-n1*a)/b;
			for(n2;n2>=0;n2--)
			{
				n3=(M-n1*a-n2*b)/c;
				if(n1+n2+n3==N&&n1*a+n2*b+n3*c==M)
				{
					s1=n1;
					s2=n2;
					s3=n3;
					flag=1;
					break;
				}
			}
			if(flag==1) break;
		}
	}
	cout<<s1<<" "<<s2<<" "<<s3<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

//Calculation of Area
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		System.out.printf("%.8f\n", sc.nextInt()*sc.nextInt()/3.305785);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 17344
#include<stdio.h>
#define N 101
#define INF 1e9

int n,M[N][N];

int prim(){
  int i,j,u,v,min,sum;
  int d[N],p[N],col[N];

  for(i=1;i<=n;i++){
    d[i]=INF;
    p[i]=-1;
    col[i]=0;
  }
  
  d[1]=0;

  while(1){
    min=INF;
    u=-1;
    for(i=1;i<=n;i++){
      if(min>d[i] && col[i]!=2){
	u=i; min=d[i];
      }
    }
    if(u==-1) break;
    col[u]=2;
    for(v=1;v<=n;v++){
      if(col[v]!=2 && M[u][v]!=INF){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v]; p[v]=u; col[v]=1;
	}
      }
    }
  }sum=0;
  for(i=1;i<=n;i++){
    if(p[i]!=-1) sum+=M[i][p[i]];
  }
  return sum;
}

int main(){
  int i,j,e;
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&e);
      M[i][j]=(e==-1)? INF:e;
    }
  }

  printf("%d\n",prim());

  return 0;
}



Measured memory_bytes: 2104
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#define FOR(i,a,n) for(i=(a);i<(n);i++)
#define swap(type,a,b) do{type t=a; a=b; b=t}while(0)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define SIZE 100005
typedef long long ll;
const ll INF=100000000;
const ll MOD=1000000007;
typedef struct{
    int v1,v2;
}Pair;
int comp(const void *a,const void *b){
    return ((Pair*)a)->v1 - ((Pair*)b)->v1;
}
Pair p[SIZE];
int main(void){
    int n,m,i;
    ll res;
    scanf("%d%d",&n,&m);
    FOR(i,0,n) scanf("%d%d",&p[i].v1,&p[i].v2);
    qsort(p,n,sizeof(Pair),comp);
    FOR(i,0,n){
        int k=MIN(m,p[i].v2);
        res += (ll)k*(ll)p[i].v1;
        m -= k;
        if(m==0) break;
    }
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main(void)
{
	int a,b;
	
	while(cin>>a>>b)
	{
		if ((a>0 && a<10) && (b>0 && b<10))
		{
			cout<<a*b<<endl;
		}

		else
			cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)2e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (2 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 1) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

signed  main(){
    int N;
    while(cin>>N&&N){
        LL sum = 0;
        vector<LL> line(N);
        for(auto &i:line){
            cin >> i;
            sum += i;
        }
        LL avg=sum/N;
        int ans = 0;
        for(auto i:line){
            ans += i <= avg;
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3156
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		Set<Integer> set = new HashSet<>();
		for(int i = 0 ; i < n ; i++) {
			if(set.contains(a[i])) {
				set.remove(a[i]);
			} else {
				set.add(a[i]);
			}
		}
		System.out.println(set.size());
	}
}

Measured memory_bytes: 56440
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);



int main(){
  FAST_IO  
  
  int N, a, b, sum = 0; cin >> N >> a >> b;
  
  auto ok = [&](int n){
    int digit = 0;
    while(n){
      digit += n % 10;
      n /= 10;
    }

    if(digit >= a && digit <= b) return true;
    return false;
  };

  for(int num = 1; num <= N; ++num){
    if(ok(num)) sum += num;
  }

  cout << sum << "\n";


  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

public class Main {
    public static void main(String args[]){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line;
            
            while((line=br.readLine())!=null){  if(line.equals(""))break;
                String[] splited = line.split(" ");
                int n = Integer.parseInt(splited[0]);
                int grams[] = new int[10];
                String str="";
                for(int i=0; i<10; i++){
                    grams[i]=n%2; n/=2;
                    if(grams[i]==1)str+=(int)Math.pow(2,i)+" ";
                }
                str=str.trim();
                System.out.println(str);
               
            }         
        }catch(Exception e){e.printStackTrace();}
        
    }
    
}

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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

int main()
{
    int P[1005];
    int sum1[1002005], sum2[1002005];
    int N;
    int M;

    for(;;){
        cin >> N >> M;
        //cout << N << " " << M << endl;
        if(N == 0 && M == 0)
            break;
        P[0] = 0;
        REP(i, N)
            cin >> P[i + 1];
        sort(P, P + N + 1);
        REP(i, N + 1)
            REP(j, N + 1){
                sum1[i * (N + 1) + j] = P[i] + P[j];
                sum2[i * (N + 1) + j] = M - P[i] - P[j];
            }
        sort(sum1, sum1 + (N + 1) * (N + 1));
        sort(sum2, sum2 + (N + 1) * (N + 1));
        long ans = 0;
        REP(i, (N + 1) * (N + 1)){
            int temp = (int)(lower_bound(sum2, sum2 + (N + 1) * (N + 1), sum1[i]) - sum2);
            //cout << N << " " << M << " " << sum1[i] << " " << sum2[temp] << endl; 
            if(temp != (N + 1) * (N + 1) && ans < (long)sum1[i] + (long)M - (long)sum2[temp] && M >= (long)sum1[i] + (long)M - (long)sum2[temp])
                ans = (long)sum1[i] + (long)M - (long)sum2[temp];
        }
        cout << ans << endl;
    }

    return 0;
}




Measured memory_bytes: 10980
import java.lang.reflect.Array;
import java.util.*;

public class Main {

	 private static int[] rs;

		public static int compute_maxprofit(int[] R) {
		      int max_profit = Integer.MIN_VALUE;
		      int smallest = R[0];
		      for(int i=1; i<R.length; i++) {
		      if(max_profit < R[i] - smallest) {
		    	  max_profit = R[i] - smallest;
		      }
		      smallest = Math.min(R[i], smallest);
		      }
		      return max_profit;
		}
		  
		  public static void main(String[] args) {
			  Scanner input = new Scanner(System.in);
			  int n = input.nextInt();
			  rs = new int[n];
			  for(int i=0; i<n; i++) {
				  rs[i] = input.nextInt();
		      }
			  System.out.println(compute_maxprofit(rs));
		  }
}



Measured memory_bytes: 102544
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
typedef pair<int, int> P;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int P[N], Q[N], R[N];
  FOR(i,0,N) cin >> P[i];
  FOR(i,0,N) cin >> Q[i];
  FOR(i,0,N) R[i] = i + 1;
  int cnt = 0;
  int cnt1 = 0;
  int cnt2 = 0;
  do {
    cnt++;
    bool ok1 = true;
    bool ok2 = true;
    FOR(i,0,N) {
      if (R[i] != P[i]) {
        ok1 = false;
      }
      if (R[i] != Q[i]) {
        ok2 = false;
      }
    }
    if (ok1) {
      cnt1 = cnt;
    }
    if (ok2) {
      cnt2 = cnt;
    }
  } while (std::next_permutation(R, R+N));

  cout << abs(cnt1 - cnt2) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <queue>

using namespace std ;
map<string , int> m ;
void solve()
{
	m["01234567"] = 1 ;
	queue<string> q ;
	q.push("01234567") ;
	
	while (!q.empty())
	{
		int p ;
		string s= q.front(); q.pop();
		for (int i=0 ; i<8;i++)
			if (s[i]=='0')
			{
				p = i ;
				 break ;
			}
			
		
		if (p>=4)
		{
			string s2 = s ;
			swap(s2[p],s2[p-4]);
			if (m[s2] == 0)
			{
				m[s2] = m[s]+1;
		    	q.push(s2);
			}
			
		}
		
		if (p<4)
		{
			string s2 = s ;
			swap(s2[p],s2[p+4]);
			if (m[s2] == 0)
			{
				m[s2] = m[s]+1;
				q.push(s2);
			}

		}
		
		if (p!=0 && p!=4)
		{
			string s2 = s ;
			swap(s2[p],s2[p-1]);
			if (m[s2] == 0)
			{
				m[s2] = m[s]+1;
				q.push(s2);
			}
		}
		
		if (p!=3 && p!=7)
		{
			string s2 = s ;
			swap(s2[p],s2[p+1]);
			if (m[s2] == 0)
			{
				m[s2] = m[s]+1;
			q.push(s2);
			}
		}
		
	}
	
}

int main ()
{
	solve();
	int n;
	while (cin >> n)
	{
		string s ;
		s +='0'+n;
		for (int i=0;i<7;i++)
		{
			cin >> n;
			s +='0'+n;
		}
		cout <<m[s]-1<<endl;
	}
	
	
	return 0 ;
}


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

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

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

#define INF INT_MAX/3

int h,w,r,c;
bool bh[2][555][555],bw[2][555][555];
int win[555][555];
int dd[]={-1,0,1,0,-1};

bool valid(int i,int j){
  return i>=0&&i<=h+1&&j>=0&&j<=w+1;
}

int main(){
	cin.sync_with_stdio(false);
  while(1){
    cin>>h>>w>>r>>c;
    if(h==0)break;
    memset(bh,0,sizeof(bh));
    memset(bw,0,sizeof(bw));
    rep(i,h){
      repl(j,1,w+1){
        cin>>bh[0][i][j];
        bh[1][i][j]=1-bh[0][i][j];
      }
      rep(j,w+1){
        cin>>bw[0][i+1][j];
        bw[1][i+1][j]=1-bw[0][i+1][j];
      }
    }
    repl(j,1,w+1){
      cin>>bh[0][h][j];
      bh[1][h][j]=1-bh[0][h][j];
    }
    memset(win,-1,sizeof(win));
    rep(i,h+2){
      win[i][0]=1;
      win[i][w+1]=1;
    }
    rep(j,w+2){
      win[0][j]=1;
      win[h+1][j]=1;
    }
    queue<P> que;
    repl(i,1,h+1){
      que.push(P(i,1));
      que.push(P(i,w));
    }
    repl(j,1,w+1){
      que.push(P(1,j));
      que.push(P(h,j));
    }
    while(que.size()){
      P np=que.front(); que.pop();
      int i=np.fi,j=np.se;
      if(win[i][j]!=-1)continue;
      bool ok=true;
      rep(k,2){
        bool okk=false;
        rep(d,4){
          int ni=i+dd[d],nj=j+dd[d+1];
          if(valid(ni,nj)&&((dd[d]!=0&&!bh[k][min(i,ni)][nj])||(dd[d+1]!=0&&!bw[k][ni][min(j,nj)]))){
            if(win[ni][nj]==1)okk=true;
          }
        }
        if(!okk)ok=false;
      }
      if(ok){
        win[i][j]=1;
        rep(d,4){
          int ni=i+dd[d],nj=j+dd[d+1];
          if(valid(ni,nj)&&win[ni][nj]==-1)que.push(P(ni,nj));
        }
      }
    }
    bool awin=win[r][c]==1;
    rep(d,4){
      int ni=r+dd[d],nj=c+dd[d+1];
      if(valid(ni,nj)&&((dd[d]!=0&&!bh[0][min(r,ni)][nj])||(dd[d+1]!=0&&!bw[0][ni][min(c,nj)]))&&win[ni][nj]==1)awin=true;
    }
    if(awin)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 5544
s = input()

if s.replace("A", "") == "KIHBR":
    b1 = bool(s == "AKIHBR")
    b2 = bool(s == "KIHABR")
    b3 = bool(s == "KIHBAR")
    b4 = bool(s == "KIHBRA")
    b5 = bool(s == "AKIHABR")
    b6 = bool(s == "AKIHBAR")
    b7 = bool(s == "AKIHBRA")
    b8 = bool(s == "AKIHABAR")
    b9 = bool(s == "AKIHABRA")
    b10 = bool(s == "AKIHBARA")
    b11 = bool(s == "KIHABARA")
    b12 = bool(s == "AKIHABARA")
    B1 = b1 or b2 or b3 or b4
    B2 = b5 or b6 or b7 or b8
    B3 = b9 or b10 or b11 or b12
    if B1 or B2 or B3 or s == "KIHBR":
        print("YES")
        exit()
print("NO")

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

using namespace std;

//typeDef
typedef long long           lli;
typedef long                li;
typedef vector<int>         vi;
typedef vector<li>          vli;
typedef vector<lli>         vlli;
typedef map<int, int>       mii;
typedef set<int>            seti;
typedef queue<int>          qi;
typedef deque<int>          dqi;
typedef stack<int>          stacki;
typedef multiset<int>       mseti;

//loop
#define rep(i, n)         for(int i = 0; i < n; ++i)
#define fori(i, a, b)     for(int i = a; i <= b; ++i)
#define ifor(i, a, b)     for(int i = a; i >= b; --i)

//Pair
#define mp                  make_pair
#define iPair               pair<int, int>
#define lliPair             pair<lli, lli>

//Extras
#define mod1                    1e9 + 7
#define mod2                    1e9 + 9
#define inf                     int(1e9)
#define INF                     lli(1e18)
#define pi                      3.14159265358979
#define pb                      push_back
#define pf                      push_front
#define popb                    pop_back()
#define popf                    pop_front()
#define ff                      first
#define ss                      second
#define all(v)                  v.begin(), v.end()
#define iter(container, it)     for(auto it = container.begin(); it != container.end(); ++it)

//functions
lli gcd(lli a, lli b) { return (a == 0) ? b : gcd(b % a, a); }
lli lcm(lli a, lli b) { return a / gcd(a, b) * b; }

vector< vector <int> > graph (200001);

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

      int n, m;
      cin >> n >> m;
      
      rep (i, m){
            int x, y;
            cin >> x >> y;
            if (x == 1 or y == 1){
                  if (x == 1){
                        graph[1].push_back(y);
                  }
                  else{
                        graph[1].push_back(x);
                  }
            }
            
            if (x == n or y == n){
                  if (x == n){
                        graph[y].push_back(n);
                  }
                  else{
                        graph[x].push_back(n);
                  }
            }
      }
      
      bool check = false;
      for (auto x : graph[1]){
            if (!graph[x].empty()){
                  graph[x][0] == n;
                  check = true;
                  false;
            }
      }
      
      if (check){
            cout << "POSSIBLE";
      }
      else{
            cout << "IMPOSSIBLE";
      }
      
      return 0;
}

Measured memory_bytes: 8440
from itertools import accumulate

N, M, Q, *I = map(int, open(0).read().split())
LR, PQ = I[:2 * M], I[2 * M:]

M = [[0] * (N + 1) for _ in range(N + 1)]
for l, r in zip(*[iter(LR)] * 2):
    M[l][r] += 1

A = [list(accumulate(reversed(a)))[::-1] for a in zip(*[accumulate(m) for m in M])]

for p, q in zip(*[iter(PQ)] * 2):
    print(A[q][p])

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

int main(void){
  int n,d;
  cin >> n >>d;
  vector<vector<int>> X(n,vector<int>(d));
  for(int i=0; i<n; i++){
    for(int j=0; j<d; j++) {
      cin >> X.at(i).at(j);
    }
  }
  int ans=0;
  for(int i=0; i<n; i++) {
    for(int j=i+1; j<n; j++) {
      int norm=0;
      for(int k=0; k<d; k++) {
        int diff = abs(X[i][k] - X[j][k]);
        norm += diff * diff;
      }

  for(int k=0; k<=norm; k++) {
    if(k*k == norm){
      ans++;
    }
  }
    }
  }
  cout << ans << endl;
}


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

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

    scanf("%d %d %d", &a, &b, &c);

    if (c - (a - b) > 0)
        printf("%d\n", c - (a - b));
    else 
        puts("0");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb             push_back
#define conv(a)        bitset<30>(a).to_string() ;
#define mxpq           priority_queue <int>
#define mnpq           priority_queue<int,vector<int>,greater<int>>
#define S(v)           sort(v.begin(),v.end())
#define RS(v)          sort(v.rbegin(),v.rend())
#define R(v)           reverse(v.begin(),v.end())
#define print          printf("%.16f\n", ans)
#define inf            LLONG_MAX
#define mini           LLONG_MIN
#define T              int tc;cin>>tc;while(tc--)
#define MSET(tabl,i)   memset(tabl, i, sizeof(tabl))
#define int            long long 
#define MAXN           10000001
#define M              1000000007
#define fio            cin.sync_with_stdio(false) ; cin.tie(0);cout.tie(0) ;
#define endl           "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> Set;


void Xarr(){
     
       int a,b ; cin>>a>>b ;
       cout<<a*b<<endl ;
} 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
int32_t main(){
 
    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
 
    #ifndef ONLINE_JUDGE
     freopen("input.txt",  "r",  stdin);
     freopen("output.txt", "w", stdout);
    #endif
    
    cout << setprecision(9) << fixed;
     clock_t z = clock();
     
     Xarr();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
 
     return 0;

}

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

int main() {
  int x; cin >> x;
  int ans = 0;
  int dist = 0;
  REP(i,x) {
    if (x <= dist) break;
    dist += i+1;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include<iostream>

using namespace std;


char s[100001];
long int k = 0;
int n = 0;
int main(void) {
	

	

	cin >> s;
	cin >> k;


	int Len = strlen(s)-1;

	for (int i = 0; i < Len; i++) {
		if (s[i] != 'a') {
			//aにするのに必要な数
			n = ('z' - s[i]) + 1;
			if (k - n >= 0) {
				k -= n;
				s[i] = 'a';
			}
		}
		
	}	
	if (k != 0) {
		s[Len]=('a'+(((s[Len] - 'a') + k) % 26));
	}
	cout << s;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.141592653289793;
using namespace std;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define lld long double
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> vp;
typedef vector<tuple<ll, ll, ll>> vt;
//vector<vector<ll>> vv(n, vector<ll>(n));

int main()
{
	ll a, b, c;
	cin >> a >> b >> c;
	if (a == b) cout << c;
	else if (b == c) cout << a;
	else cout << b;
	cout << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll N, K;

void solve() {
	cin >> N >> K;
	if(K == 0) {
		cout << N * N << "\n";
		return;
	}
	ll res = 0;
	rep(b, K + 1, N + 1) {
		ll to = N / b;
		int a = 0;
		res += to * (b - K);
		a += to * (b - K);
		res += max(0LL, N - (to * b + K - 1));
		a += max(0LL, N - (to * b + K - 1));
		// debug(b, a, to);
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256