akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {


	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int ans = 0,temp = 0;
		String str;
		String[] s;
		str = bf.readLine();
		s = str.split("");
		for(int i = 0;i < s.length;++i) {
			switch(s[i]) {
			case "A":
			case "T":
			case "G":
			case "C":
				temp++;
				break;
			default:
				if(ans < temp) {
					ans = temp;
				}
				temp = 0;
			}
		}
		if(ans < temp) {
			ans = temp;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

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

    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;

    int ruiseki[N], tmp = 1;
    memset(ruiseki, 0, sizeof(ruiseki));

    rep(i, 1, N) {
        if(S[i - 1] == 'A' and S[i] == 'C') {
            ruiseki[i] = 1;
        }
    }
    rep(i, 1, N) ruiseki[i] += ruiseki[i - 1];

    vector<int> rsl;
    rep(i, 0, Q) {
        int l, r;
        cin >> l >> r;
        rsl.push_back(ruiseki[r - 1] - ruiseki[l - 1]);
    }
    rep(i, 0, rsl.size()) cout << rsl[i] << endl;


}


Measured memory_bytes: 1864
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='1') f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
int n,m;
int main()
{   
    n=read();m=(n+3)/4*2;
    if(n==1) return 0*puts("1\n1");
    int dif=m*2-n;printf("%d\n",m);
    for(int i=1;i<=m;++i,puts(""))
        for(int j=1;j<=m;++j)
        {
            int x=(i+j-1)%m+1;
            x=x+(i%2)*m;
            if(x>n) x-=m;
            printf("%d ",x);
        }
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int H, W;
vector<string>S;
set<int>st;
set<pair<int, int>>p;
int nouse = -1;

int solve(int r){
	vector<string>tate(W);
	for (int i = 0; i < W; i++)tate[i].resize(H);
	for (int i = 0; i < W; i++) {
		int idx = 0;
		fore(x, p) {
			tate[i][idx] = S[x.first][i];
			tate[i][H-1-idx] = S[x.second][i];
			idx++;
		}
		if (H % 2 == 1)tate[i][H/2] = S[r][i];
	}

	int rem = -1;
	set<int>vis;
	for (int i = 0; i < W; i++) {
		if (vis.count(i))continue;
		for (int j = i + 1; j < W; j++) {
			if (vis.count(j) || i == j)continue;
			int ok = 1;
			for (int k = 0; k < H; k++)if (tate[i][k] != tate[j][H-1-k])ok = 0;
			if (ok) { vis.insert(i); vis.insert(j); break; }
		}
	}
	for (int i = 0; i < W; i++)if(!vis.count(i))rem = i;

	if (W % 2 == 0) {
		if (vis.size() != W)return 0;
		else return 1;
	}
	else {
		if (vis.size() != W - 1)return 0;
		for (int i = 0; i < H; i++)if (tate[rem][i] != tate[rem][H - 1 - i])return 0;
		return 1;
	}
}

int dfs(){
	if (st.size() == 0)return solve(nouse);
	int beg = *st.begin();
	set<int>temp = st;
	fore(x,temp) {
		if (x != beg) {
			st.erase(x);
			st.erase(beg);
			p.insert({x,beg});
			if (dfs())return 1;
			st.insert(x);
			st.insert(beg);
			p.erase({x,beg});
		}
	}
	return 0;
}

int b(){
	if (H % 2 == 0)return dfs();
	else {
		for (int i = 0; i < H; i++) {
			st.erase(i);
			nouse = i;
			if (dfs())return 1;
			st.insert(i);
		}
		return 0;
	}
}

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

	cin >> H >> W;
	S.resize(H);
	for (int i = 0; i < H; i++) {
		cin >> S[i];
		st.insert(i);
	}
	if (b())puts("YES");
	else puts("NO");


	return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <utility>
using namespace std;
typedef pair<int, int> pii;

const pii INIT = pii(-1,-1);
int board[33][33];
int acc[33][33];
pii memo[33][33][33][33];
int H, W, E, S;

int getsum(int p, int q, int x, int y){
  return board[x][y] - board[p][y] - board[x][q] + board[p][q];
}

pii solve(int l, int t, int r, int b){
  pii& ans = memo[l][t][r][b];
  if(ans != INIT) return ans;

  int sum = getsum(l,t,r,b);
  if(sum < E - S) return ans = pii(0, 0);
  
  ans = pii(1, S - E + sum);
  
  for(int i = l+1; i < r; ++i){
    pii ra = solve(l,t,i,b);
    pii rb = solve(i,t,r,b);
    pii temp = pii(ra.first + rb.first, min(ra.second, rb.second));
    ans = max(ans, temp);
  }

  for(int i = t+1; i < b; ++i){
    pii ra = solve(l,t,r,i);
    pii rb = solve(l,i,r,b);
    pii temp = pii(ra.first + rb.first, min(ra.second, rb.second));
    ans = max(ans, temp);
  }

  return ans;
}

int main(){
  while(cin >> H >> W >> S, H){
    memset(board, 0, sizeof(board));
    for(int i = 0; i < 33; ++i)
      for(int j = 0; j < 33; ++j)
	for(int k = 0; k < 33; ++k)
	  for(int l = 0; l < 33; ++l)
	    memo[i][j][k][l] = INIT;
    for(int i = 0; i < H; ++i)
      for(int j = 0; j < W; ++j)
	cin >> board[i+1][j+1];

    for(int i = 0; i < H; ++i)
      for(int j = 0; j < W; ++j)
	board[i+1][j+1] += board[i+1][j];

    for(int i = 0; i < H; ++i)
      for(int j = 0; j < W; ++j)
	board[i+1][j+1] += board[i][j+1];

    E = getsum(0,0,H,W);
    pii ans = solve(0,0,H,W);
    cout << ans.first << " " << ans.second << endl;
  }
  return 0;
}

Measured memory_bytes: 12360
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sz(s) (int)(s.size())
#define all(v) v.begin(),v.end()
#define endl "\n"
using namespace std;
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x % y); }
void Run() {

    // freopen("mex.in", "r", stdin);
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin); freopen("outt.txt", "w", stdout);
#endif
}

inline ll pp(ll a)
{
    ll start = -1000, end = 1000, mid;
    while (start <= end)
    {

        mid = (start + end) / 2;
        if (mid * mid * mid * mid * mid == a)
            return mid;
        else if (mid * mid * mid * mid * mid > a)
        {
            end = mid - 1;
        }
        else if (mid * mid * mid * mid * mid < a)
        {
            start = mid + 1;
        }
    }
    return -1;

}
int main()
{
    //Run();
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = -500; i <= 500; i++)
    {
        ll a = pow(i, 5) - n;
        ll b = pp(a);
        if (pow(i, 5) - pow(b, 5) == n)
        {
            cout << i << " " << b;
            return 0;
        }

    }
}

Measured memory_bytes: 4088
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<62)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n,k;
    cin >> n >> k;
    int x[n],y[n];
    rep(i,n)cin >> x[i] >> y[i];
    int xs[n],ys[n];
    rep(i,n)xs[i]=x[i];sort(xs,xs+n);
    rep(i,n)ys[i]=y[i];sort(ys,ys+n);
    ll ans = LINF;
    rep(ix,n)rep(jx,ix){
        int lx = xs[jx];
        int rx = xs[ix];
        rep(iy,n)rep(jy,iy){
            int ly = ys[jy];
            int ry = ys[iy];
            {
                int c = 0;
                rep(i,n){
                    if(x[i]<lx||x[i]>rx)continue;
                    if(y[i]<ly||y[i]>ry)continue;
                    c++;
                }
                if(c>=k){
                    ll s = (ll)(rx-lx)*(ll)(ry-ly);
                    chmin(ans,s);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	count := 0
	for i := 0; i <= n; i++ {
		if i%2 == 1 {
			count++
		}
	}

	fmt.Println(float64(count) / float64(n))
}


Measured memory_bytes: 512
#include<stdio.h>

struct Node{
    int p, l, r;
};

#define MAX 25
#define NIL -1

struct Node node[MAX];


void preorder(int u){
    printf(" %d", u);
    if(node[u].l != NIL) preorder(node[u].l);
    if(node[u].r != NIL) preorder(node[u].r);

}

void inorder(int u){
    if(node[u].l != NIL) inorder(node[u].l);
    printf(" %d", u);
    if(node[u].r != NIL) inorder(node[u].r);
    
}

void postorder(int u){
    if(node[u].l != NIL) postorder(node[u].l);
    if(node[u].r != NIL) postorder(node[u].r);
    printf(" %d", u);
}

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

    for(i = 0; i < n; i++) node[i].p = node[i].l = node[i].r = NIL;

    for(i = 0; i < n; i++){
        int id, c1, c2;
        scanf("%d%d%d", &id, &c1, &c2);
        node[id].l = c1;
        node[id].r = c2;
        if(c1 != -1) node[c1].p = id;
        if(c2 != -1) node[c2].p = id;

    }

    int root;
    for(i = 0; i < n; i++) {
        if(node[i].p == NIL) root = i;
    }

    printf("Preorder\n");
    preorder(root);
    printf("\n");
    printf("Inorder\n");
    inorder(root);
    printf("\n");
    printf("Postorder\n");
    postorder(root);
    printf("\n");
    return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define myv vector<int>
using namespace std;
const int N=1010,M=5010,oo=2e9;
int n,f1[N],f2[M],x[N];
int fa[N];
myv son[N];
bool dfs(int k){
	int l=son[k].size(),now,tot=0,temp;
	if(!l) return 1;
	for(int i=0;i<l;i++){
		if(!dfs(son[k][i])) return 0;
		tot+=x[son[k][i]]+f1[son[k][i]];
	}
	memset(f2,0,sizeof(f2));
	for(int i=0;i<l;i++)
		for(int j=x[k];j>=0;j--){
			now=son[k][i];
			temp=-oo;
			if(j>=x[now]) temp=max(temp,f2[j-x[now]]+x[now]);
			if(j>=f1[now]) temp=max(temp,f2[j-f1[now]]+f1[now]);
			f2[j]=temp;
//			if(j<x[now]&&j<f1[now]) f2[j]=-oo;
		}
	if(f2[x[k]]<0) return 0;
	f1[k]=tot-f2[x[k]];
	return 1;
}
int main(){
	scanf("%d",&n);
	for(int i=2;i<=n;i++){
		scanf("%d",&fa[i]);
		son[fa[i]].push_back(i);
	}
	for(int i=1;i<=n;i++) scanf("%d",&x[i]);
	if(dfs(1)) cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 384
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iterator>
#include <functional>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstdio>
using namespace std;
#define sz(a)  int((a).size())
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define CLR(a) memset((a), 0, sizeof(a))
#define INF (1 << 31) - 1
const int dh[8] = {-1, 1, 0, 0,1,1,-1,-1};
const int dw[8] = {0, 0, 1, -1,1,-1,1,-1};
typedef long long ll;
typedef pair<int, int> p;
typedef vector <int> VI;
typedef vector <string> VS;

int table[4][100000];

int main(){

	int n;
	cin >> n;
	
	table[0][0] = 18; table[0][1] = 18;
	table[1][0] = 18; table[1][1] = 22;	
	table[2][0] = 22; table[2][1] = 18;	
	table[3][0] = 22; table[3][1] = 22;			
	
	string s;
	cin >> s;

	for(int i = 0; i < n; i++){
		if(i == 0){
			for(int j = 0; j < 4; j++){
				if((s[i] == 'o' && table[j][0] == 18) || (s[i] == 'x' && table[j][0] == 22))
					table[j][n - 1] = table[j][1];
				else 
					table[j][n - 1] = 40 - table[j][1];
			}					
		}else if(i < n - 2){			
			for(int j = 0; j < 4; j++){
				if((s[i] == 'o' && table[j][i] == 18) || (s[i] == 'x' && table[j][i] == 22))
					table[j][i + 1] = table[j][i - 1];
				else 
					table[j][i + 1] = 40 - table[j][i - 1];
			}			
		}else{
			for(int j = 0; j < 4; j++){
				if((s[i] == 'o' && table[j][i] == 18) || (s[i] == 'x' && table[j][i] == 22))
					if(table[j][i-1] != table[j][(i+1) % n]) table[j][0] = 0;
				if((s[i] == 'x' && table[j][i] == 18) || (s[i] == 'o' && table[j][i] == 22))
					if(table[j][i-1] == table[j][(i+1) % n]) table[j][0] = 0;
			}			
		}
	}
	
	for(int a = 0; a < 4; a++){
		if(table[a][0] == 0) continue;
		for(int i = 0; i < n; i++){
			if(table[a][i] == 18)
				cout << 'S'; 
			else	
				cout << 'W'; 
		}
		cout << endl;
		return 0;
	}

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


Measured memory_bytes: 2176
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	string s,s1;
	cin>>s;
	s1=s;
	reverse(s1.begin(),s1.end());
	for(int i=0;i<s1.length();i++){
		if(s1[i]=='b')s1[i]='d';
		else if(s1[i]=='d')s1[i]='b';
		else if(s1[i]=='p')s1[i]='q';
		else if(s1[i]=='q')s1[i]='p';
	}
	if(s1==s)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <climits>
#define int long long
#define MAX(a,b) ((a) > (b)) ? (a) : (b)
#define MIN(a,b) ((a) < (b)) ? (a) : (b)
using namespace std;

int a[100000];
int d[100000];

signed main()
{
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}

	int total = n * (n + 1) / 2;
	if (sum % total != 0)
	{
		cout << "NO" << endl;
		return 0;
	}
	int k = sum / total;

	for (int i = 0; i < n; i++)
	{
		d[i] = a[(i + 1) % n] - a[i];
	}

	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		int dd = -(d[i] - k);
		if (dd % n != 0 || dd < 0)
		{
			cout << "NO" << endl;
			return 0;
		}

		cnt += dd / n;
	}

	if (cnt == k)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    
    double d=((n+1)/2.0)/n;
    
    if(n%2==1) cout<<fixed<<setprecision(10)<<d<<endl;
    else cout<<fixed<<setprecision(10)<<1/2.0<<endl;
    
    return 0;
}

Measured memory_bytes: 3768
require 'pp'

n = gets.chomp!.to_i
s_n = []
memo = {}

MATCH = %w(M A R C H)

n.times do
    s = gets.chomp!
    s_n << s
    if MATCH.include?(s[0])
        memo[s[0]] ||= 0
        memo[s[0]] += 1
    end
end

sum = 0
memo.keys.combination(3) do |a, b, c|
    sum += memo[a] * memo[b] * memo[c]
end

puts sum


Measured memory_bytes: 9724
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int n,d[110];
  cin>>n;
  for(int i=0;i<n;i++) cin>>d[i];
  sort(d,d +n);
  int sum=1;
  for(int i=1;i<n;i++){
    if(d[i-1]<d[i]) sum++;
  }
  cout<<sum<<'\n';
  return 0;
}


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

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

    vector<ll> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    int ans = 0;
    int count = 0;
    for (int i = 0; i < n - 1; ++i) {
        if (h[i] >= h[i+1]) {
            ++count;
        } else {
            count = 0;
        }
        ans = max(ans, count);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cassert>
#include <string>
#include <set>
#include <map>
#include <random>
#include <bitset>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using ld = long double;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, a, b, c, d;
	string s;
	cin >> n >> a >> b >> c >> d >> s;
	a--; b--; c--; d--;
	int f = 1;
	for (int i = a; i < max(c, d); i++)
		if (s[i] == '#' && s[i + 1] == '#')
			f = 0;
	if (c > d) {
		f = 0;
		for (int i = b - 1; i < d; i++) {
			if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.')
				f = 1;
		}
	}
	if (f)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 592
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;

    if(s.size() < t.size()) { 
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    int idx = -1;
    for(int i = 0; i <= s.size() - t.size(); i++) {
        int cnt = 0;

        rep(j, t.size()) {
            if(s[i+j] == t[j] || s[i+j] == '?') {
                cnt++;
            }
        }

        if(cnt == t.size()) {
            idx = i;
        }
    }
    if(idx == -1) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    
    rep(i, t.size()) {
        s[idx+i] = t[i];
    }
    rep(i, s.size()) {
        if(s[i] == '?') {
            s[i] = 'a';
        }
    }
    
    cout << s << endl;
    return 0;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}



template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstr;

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


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




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    vint a(n), b(n), c(m), d(m);

    rep(i, n)
        cin >> a[i] >> b[i];
    rep(i, m)
        cin >> c[i] >> d[i];

    rep(i, n){
        int cp = 1;
        int min_dis = abs(a[i]-c[0])+abs(b[i]-d[0]);

        rep(j, m){
            int tmp_dis = abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(min_dis > tmp_dis){
                min_dis = tmp_dis;
                cp = j+1;
            }
        }

        ppp(cp);

    }



    return 0;
}


Measured memory_bytes: 256
n = int(input())
#足場の数
h = list(map(int, input().split()))
#足場の高さ

dp = [0]*n
#dynamic programming
dp[0] = 0
#最初立っているところは0
dp[1] = abs(h[0]-h[1])
#次に立っているところは最初立っているところと最初の足場の高さの差


for i in range(2,n):
	#次に立っているところは２パターンある
	#どっちがスコアを低くできるかmin()で比較する
	
	
	a = dp[i-1] + abs(h[i]-h[i-1])
	#一歩すすんだパターン
	b = dp[i-2] + abs(h[i]-h[i-2])
	#二歩すすんだパターン
	#print(a,b)
	dp[i] = min(a,b)	

print(dp[-1])
#print(dp)


Measured memory_bytes: 13928
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

ll n, m ,q;
vector<tuple<ll, ll, ll, ll>> t;

ll score(const vi &v){
    ll ans = 0;
    rep(i, q) if((v[get<1>(t[i])]-v[get<0>(t[i])]) == get<2>(t[i])) ans += get<3>(t[i]);
    return ans;
}

ll dfs(vi &v){
    if(v.size() == n) return score(v);
    ll ans = 0, back = (v.empty() ? 0 : v.back());
    for(ll i=back; i<m; i++){
        v.push_back(i);
        chmax(ans, dfs(v));
        v.pop_back();
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    cin >> n >> m >> q;
    rep(i, q){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        t.push_back(make_tuple(a-1, b-1, c, d));
    }
    vi v;
    cout << dfs(v) << endl;
}

Measured memory_bytes: 3664
x,n=map(int,input().split())
p=list(map(int,input().split()))
y=x
z=x
if x not in p:
    print(x)
    exit()
for i in range(2*len(p)):
    y-=1
    z+=1
    if y not in p:
        print(y)
        exit()
    if z not in p:
        print(z)
        exit()
    

Measured memory_bytes: 9196
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using ll = long long;
#define ull unsigned ll
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pi pair<int,int>
#define pl pair<ll,ll>
#define ppi pair<int, pii>
#define mt make_tuple
#define eb emplace_back
using namespace std;

const ll N = 1e5 + 5, mod = 1e9 + 7;
const ll inf = 1e9;

bool P(const pair<ll, ll> &a, const pair<ll, ll> &b){
    if(a.F == b.F) return a.S < b.S;
    return a.F > b.F;
}

void solve(){
    ll n;
    cin >> n;
    vi a;
    for(ll i = 2; i * i <= n; i++){
        ll j = 0;
        while(n % i == 0){
            n = n / i;
            j++;
        }
        if(j > 0){
            a.pb(j);
        }
    }
    if(n > 1){
        a.pb(1);
    }
    ll ans = 0;
    for(ll i : a){
        ll j = 1;
        while(j * j + j <= 2ll * i){
            j++;
        }
        ans += j - 1;
    }
    cout << ans << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);//cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3588
import math
import collections

N = int(input())
Point = collections.namedtuple('Point', ['x', 'y'])


def koch(d, p1, p2):
    if d == 0:
        return
    th = math.pi * 60 / 180
    s = Point(x=(2 * p1.x + p2.x) / 3, y=(2 * p1.y + p2.y) / 3)
    t = Point(x=(p1.x + 2 * p2.x) / 3, y=(p1.y + 2 * p2.y) / 3)
    u = Point(x=(t.x - s.x) * math.cos(th) - (t.y - s.y) * math.sin(th) + s.x,
              y=(t.x - s.x) * math.sin(th) + (t.y - s.y) * math.cos(th) + s.y)
    koch(d - 1, p1, s)
    print('{:.8f} {:.8f}'.format(s.x, s.y))
    koch(d - 1, s, u)
    print('{:.8f} {:.8f}'.format(u.x, u.y))
    koch(d - 1, u, t)
    print('{:.8f} {:.8f}'.format(t.x, t.y))
    koch(d - 1, t, p2)


p1 = Point(x=0, y=0)
p2 = Point(x=100, y=0)
print('{:.8f} {:.8f}'.format(p1.x, p1.y))
koch(N, p1, p2)
print('{:.8f} {:.8f}'.format(p2.x, p2.y))



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

int main(){
	int N;
	cin >> N;
	int temp;
	int sum = 0;
	temp = N;
	while (temp != 0){
		sum += (temp%10);
		temp /= 10;
	}
	if (N % sum == 0){
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
}



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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

ll dp[51][51][2501];

int main() {
  int n, a;
  cin >> n >> a;
  int x[n];
  int sum = 0;
  REP(i, n) {
    cin >> x[i];
    sum += x[i];
  }
  dp[0][0][0] = 1;
  REP(i, n) {
    for (int j = 0; j <= n; ++j) {
      for (int k = 0; k <= sum; ++k) {
        dp[i + 1][j][k] += dp[i][j][k];
        if (j && x[i] <= k) {
          dp[i + 1][j][k] += dp[i][j - 1][k - x[i]];
        }
      }
    }
  }
  ll ans = 0;
  REP1(i, n) ans += dp[n][i][i * a];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 50048
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

		int n = in.nextInt();
		String s = in.next();
		int k = in.nextInt();

		solve(n, s, k);

		in.close();

	}

	private static void solve(int n, String s, int k) {

		String[] array = s.split("");
		String target = array[k - 1];

		String ans = "";

		for (int i = 0; i < n; i++) {
			if (!target.equals(array[i])) {
				ans += array[i] = "*";
			} else {
				ans += array[i];
			}
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

#define MOD (1000000007)
const int MX = 777777 + 5;

int fac[MX+5],inv[MX+5];
 
int power(int x,int y,int p){
	int res=1;
	x=x%p;
	while(y){
		if(y&1)res=(res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}

void init(){
  int n=MX+4;
	fac[0] = 1;
  for(int i=0;i<n;++i)fac[i+1]=fac[i]*(i+1)%MOD;
  inv[n]=power(fac[n],MOD-2,MOD);
  for(int i=n-1;i>=0;--i)inv[i]=inv[i+1]*(i+1)%MOD;
}

int comb(int n,int r){return (fac[n]*inv[r])%MOD*inv[n-r]%MOD;}
int H(int n,int r){
  return comb(n+r-1,r)%MOD;
}

bool vis[100010];
vi v;
vi G[100010];
bool frag = true;
int K;

void  dfs(int n){
    vis[n] = true;
    int cnt=0;
    if(SZ(G[n])>K) frag = false;
    for(auto a:G[n]){
        if(!vis[a]) {
            cnt++;
            dfs(a);
        }
    }
    if(cnt==0) return;
    else v.pb(cnt);
    return;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);
    init();

    int N; cin >> N >> K;
    rep(i,N-1){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    rep(i,N){
        vis[i] = false;
    }
    vis[0] = true;
    int pos=SZ(G[0]);
    if(pos>=K) frag = false;
    for(auto a:G[0]){
        dfs(a);
    }
    int ans = ((K*comb(K-1,pos))%MOD*fac[pos])%MOD;
    for(auto a:v){
        ans = ((ans*comb(K-2,a))%MOD*fac[a])%MOD;
    }
    if(!frag) cout << 0 << endl;
    else cout << ans << endl;
}


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

signed main(){
    int A,B,T;
    cin>>A>>B>>T;
    cout<<(T/A)*B<<endl;
}

Measured memory_bytes: 256
from functools import reduce
import math

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    x = int(input().rstrip())
    if x <= 6:
        ans = 1
    elif x <=11:
        ans = 2
    else:
        if(x%11 == 0):
            ans = (x // 11) * 2
        elif(x%11 <= 6):
            ans = (x // 11) * 2 +1
        else:
            ans = (x // 11) * 2 +2
    print(ans)
    
if __name__ == '__main__':
    main()


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

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a) {
        if((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a) {
        if((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if(!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if(t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint &operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    ll asum;
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
        asum += A.at(i);
    }

    mint ans = 0;
    ll s = asum;
    for(int i = 0; i < N - 1; i++) {
        s -= A.at(i);
        ans += mint(s) * A.at(i);
    }
    cout << ans.x << endl;

    return 0;
}

Measured memory_bytes: 4768
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    if(n>=10)
        cout<<m<<endl;
    else
        cout<<m+100*(10-n)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

 class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int k=in.nextInt();
        int[] a=new int[n];
        for(int i=0;i<n;i++){
            a[i]=in.nextInt();
        }
        int sum=0;
        int i=0, j;
        for(i=0;i<k;i++)
            sum+=a[i];
        int maxSum=sum;
        int left=0, right=k-1;
        for(i=0, j=k;j<n;j++,i++){
            sum=sum-a[i];
            sum=sum+a[j];
            if(sum>maxSum){
                left=i+1;right=j;
                maxSum=sum;
            }
        }
       // System.out.println(left + " " + right);
        double ans=0;
        for(int l=left;l<=right;l++){
           // System.out.println("For: " + a[l]);
            double temp=(double)((a[l]*(a[l]-1))/2);
            //System.out.println(temp);
            temp=(double)(temp+a[l]);
            //System.out.println(temp);
            temp=(double)(temp/a[l]);
            //System.out.println(temp);
            ans+= temp;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 79564
#include<stdio.h>
int main(void){
	int n;
	int i;
	int x;
	int count = 0;
	while(scanf("%d",&n)){
		if(n == 0){
			break;
		}
		for(i = 1;i <= n;i++){
			if(i % 5 == 0){
				x = i;
				while(1){
					count++;
					i /= 5;
					if(i % 5 != 0 || i == 1){
						break;
					}
				}
				i = x;
			}
		}
		printf("%d\n",count);
		count = 0;
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
#define LL long long
const LL mod = 1000000007;
LL mmod(LL x, LL y)
{
    LL val=1;
    while(y){
        if(y%2)val = (val*x)%mod;
        x = (x*x)%mod;
        y/=2;
    }
    return val;
}

LL C(int a, int b)
{
    LL res = 1;
    for (LL i = 1, j = a; i <= b; i ++, j -- )
    {
        res = (LL)res * j % mod;
        res = (LL)res * mmod(i, mod - 2) % mod;
    }
    return res;
}

LL lucas(LL a, LL b)
{
    if (a < mod && b < mod) return C(a, b);
    return (LL)C(a % mod, b % mod) * lucas(a / mod, b / mod) % mod;
}

int main()
{
    LL n, a, b;
    while(cin>>n>>a>>b)
    {
        LL res = (mmod(2, n) - 1 - (C(n, a)+C(n, b))%mod + mod)%mod;
        cout<<res<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i,a,b,c,k;
  scanf("%d%d%d%d",&a,&b,&c,&k);
  if(a>=c&a>=b)for(;k--;a*=2);
  else if(b>=c&b>=a)for(;k--;b*=2);
  else if(c>=a&c>=b)for(;k--;c*=2);
  printf("%d",a+b+c);
  return 0;
}

Measured memory_bytes: 128
/*                        _
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                   ____/`---'\____
                  /  \\|     |//  \
                 / \\||| /:\ |||// \
                / _||||| -:- |||||- \
               |   | \\\ \-/ /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
            ____'. .'  /--.--\  `. .'_____
          /"" '<  `.___\_<|>_/___.' >' "" \
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
          `-.____`.___ \_____/___.-`___.-'
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <bits/stdc++.h>
#define ii int64_t
#define lli long long int
#define li long int
#define vi vector<int64_t>
#define mii unordered_map<int64_t,int64_t>
#define nl cout<<"\n"
#define deb(x) cout<<"\nhi"<<x<<"\n"
#define mod 1000000007
ii n,t,i,j,k,l,x,y,z,a,b,d,cnt=0,sum=0,mx=-1,mn=INT_MAX;
bool f,f1,f2;
using namespace std;
ii rr=0,gg=0,cc;

priority_queue<ii> r,g,c;

ii ff(ii a,ii b, ii c){
    return max(max(a,b),c);
}
void assign(){
    k=-1;i=-1;j=-1;
    if(rr<x)
    i=r.top();
    if(gg<y)
    j=g.top();
    if(!c.empty())k=c.top();

}
int main()
{fio;
    ii cn;
    cin>>x>>y>>a>>b>>cn;
    for(i=0;i<a;i++)
    {
        cin>>z;r.push(z);
    }
    for(i=0;i<b;i++)
    {
        cin>>z;g.push(z);
    }
    for(i=0;i<cn;i++)
    {
        cin>>z;c.push(z);
    }

    cc=x+y;
    while(cc--)
    {
        assign();
        if(k==ff(i,j,k))
        {
            sum+=c.top();
            c.pop();
            //cout<<"c ";
        }else if(i==ff(i,j,k))
        {
            rr++;
            sum+=r.top();
            r.pop();
            //cout<<"r ";
        }else if(j==ff(i,j,k))
        {
            gg++;
            sum+=g.top();g.pop();
            //cout<<"g ";
        }
  
    }
    cout<<sum;

    
}



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

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if(c-a-b<0){
        puts("No");
        return 0;
    }
    if(4*a*b<(c-a-b)*(c-a-b)){
        puts("Yes");
    }
    else puts("No");
    
    
    return 0;
}






Measured memory_bytes: 256
import math

S = list(input())
a =0
b = 0
n=len(S)
for i in range(0,n,2):
  if(S[i]=="R" or S[i]=="U" or S[i]=="D"):
    a +=1
for j in range(1,n,2):
  if(S[j]=="L" or S[j]=="U" or S[j]=="D"):
    b+=1
if(a==math.ceil(n/2) and b ==math.floor(n/2)):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9124
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N, K; cin >> N >> K;
  vector<ll> result{};
  for (int n = 1; n <= N; ++n) {
    if (n <= K) {
      continue;
    }
    auto cnt = N / n;
    auto res = cnt * (n - K);
    if (cnt * n + K <= N) {
      res += N - (cnt * n + K) + 1;
    }
    else {
      ;
    }
    // (0, n)は例外
    if (K == 0) {
      --res;
    }
    result.push_back(res);
  }
  ll ans = boost::accumulate(result, (ll)0);
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main ()
{
    ll n,a[100005],b[100005],c[100005];
    cin>>n;
    ll dp[n+5][3];
    for (int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);

    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<'\n';


}

Measured memory_bytes: 8268
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,d,x,y,z;
string s,t;
//

signed main() {
  RAPID;
  IN4(a,b,c,d);
  OUT(min({a+c,a+d,b+c,b+d}));
}

Measured memory_bytes: 256
A, B, K = gets.split.map(&:to_i)

k = 1
n = A
while n <= B && k <= K
  puts n
  n += 1
  k += 1
end
k = 1
n = [A + K, B - K + 1].max
while n <= B && k <= K
  puts n
  n += 1
  k += 1
end


Measured memory_bytes: 1788
import copy


def warshalFloyd(n):
    G=[list(map(int,input().split())) for _ in range(n)]
    D=copy.deepcopy(G)
    for k in range(n):
        for i in range(n):
            for j in range(n):
                G[i][j]=min(G[i][j],G[i][k]+G[k][j])

    return G if G==D else -1


n=int(input())
Graph=warshalFloyd(n)
if Graph==-1:print(-1);exit()

for k in range(n):
    for i in range(n):
        for j in range(n):
            if Graph[i][j]!=0 and Graph[i][k]!=0 and Graph[k][j]!=0:
                if Graph[i][j]==Graph[i][k]+Graph[k][j]:
                    Graph[i][j]=0

ans=0
for i in range(n):
    ans +=sum(Graph[i])
print(ans//2)

Measured memory_bytes: 76892
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, Y = LI()
    Y = Y // 1000
    for i in range(N+1):
        for j in range(N-i+1):
            k = N - i - j
            mon = 10 * i + 5 * j + k
            if mon == Y:
                print(i, j, k)
                return
    print('-1 -1 -1')

main()



Measured memory_bytes: 65644
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll X[100009], Y[100009], T;
map<ll,vector<pair<ll,int>>> U,D;
map<ll,set<pair<ll,int>>> US,DS;
ll ret;

void dfs(int cur){
    ll UD = Y[cur]-X[cur];
    ll DD = Y[cur]+X[cur];
    
    US[UD].erase({X[cur],cur});
    DS[DD].erase({X[cur],cur});
    
    ret += lower_bound(all(U[UD+T]),make_pair(X[cur],0)) - lower_bound(all(U[UD+T]),make_pair(X[cur]-T,0));
    ret += lower_bound(all(D[DD+T]),make_pair(X[cur]+T+1,0)) - lower_bound(all(D[DD+T]),make_pair(X[cur],0));
    ret += lower_bound(all(U[UD-T]),make_pair(X[cur]+T,0)) - lower_bound(all(U[UD-T]),make_pair(X[cur],0));
    ret += lower_bound(all(D[DD-T]),make_pair(X[cur],0)) - lower_bound(all(D[DD-T]),make_pair(X[cur]-T+1,0));
    
    while(true){
        auto it=US[UD+T].lower_bound({X[cur]-T,0});
        if(it==US[UD+T].end()||it->first>X[cur]) break;
        dfs(it->second);
    }
    while(true){
        auto it=US[UD-T].lower_bound({X[cur],0});
        if(it==US[UD-T].end()||it->first>X[cur]+T) break;
        dfs(it->second);
    }
    while(true){
        auto it=DS[DD+T].lower_bound({X[cur],0});
        if(it==DS[DD+T].end()||it->first>X[cur]+T) break;
        dfs(it->second);
    }
    while(true){
        auto it=DS[DD-T].lower_bound({X[cur]-T,0});
        if(it==DS[DD-T].end()||it->first>X[cur]) break;
        dfs(it->second);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, a, b;
    cin>>N>>a>>b;
    a--; b--;
    
    rep(i,N){
        cin>>X[i]>>Y[i];
        U[Y[i]-X[i]].push_back({X[i],i});
        D[X[i]+Y[i]].push_back({X[i],i});
        US[Y[i]-X[i]].insert({X[i],i});
        DS[X[i]+Y[i]].insert({X[i],i});
    }
    
    T = abs(X[a]-X[b]) + abs(Y[a]-Y[b]);
    
    for(auto& r:U) sort(all(r.second));
    for(auto& r:D) sort(all(r.second));
    
    dfs(a);
    cout1(ret/2);
}

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

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

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

int n, G[MAX][MAX], d[MAX], f[MAX], Mytime, st[MAX];

void dfs(int r) {
	if (st[r] != 0) return;
	int nt[n + 1], i;
	for (i = 1; i <= n; i++) {
		nt[i] = 1;
	}
	stack<int> S;
	S.push(r);
	d[r] = ++Mytime;
	st[r] = 1;
	while (!S.empty()) {
		int u = S.top();
		int v;
		for (v = nt[u]; v <= n; v++) {
			nt[u] = v + 1;
			if (G[u][v] && st[v] == 0) 
				break;
		}
		if (v <= n) {
			d[v] = ++Mytime;
			st[v] = 1;
			S.push(v);
		} else {
			S.pop();
			f[u] = ++Mytime;
		}
	}
}

int main(void) {
	int i, j, u, k, v;
	for (i = 0; i < MAX; i++) {
		d[i] = 0;
		f[i] = 0;
		st[i] = 0;
		for (j = 0; j < MAX; j++) {
			G[i][j] = 0;
		}
	}
	Mytime = 0;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> u >> k;
		for (j = 0; j < k; j++) {
			cin >> v;
			G[u][v] = 1;
		}
	}
	for (i = 1; i <= n; i++) {
		dfs(i);
	}
	dfs(1);
	for (i = 1; i <= n; i++) {
		cout << i << " " << d[i] << " " << f[i] << endl;
	}
}


Measured memory_bytes: 3144