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

using namespace std;

#define int long long

int solve(int w, int h) {
    return (h + 1) / 2 * ((w + 1) / 2) + h / 2 * (w / 2);
}

int solve2(int w, int h) {
    /*int cnt = 0;
    for (int i = 0; i < w; ++i) {
        for (int j = 0; j < h; ++j) if ((i + j) % 2 == 0) ++cnt;
    }
    return cnt;*/
    return (w * h + 1) / 2;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*while (true) {
        int w = rand() % 100 + 1, h = rand() % 100 + 1;
        if (solve(w, h) != (solve2(w, h))) {
            cout << w << ' ' << h << endl;
            break;
        }
        cout << "OK!" << endl;
    }*/
    int w, h;
    cin >> w >> h;
    if (w == 1 || h == 1) {
        cout << 1;
        return 0;
    }
    cout << solve2(w, h);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s,t,u;
  cin >> s >> t >> u;
  if(s.at(s.size()-1)==(t.at(0))&&(t.at(t.size()-1)==u.at(0)))
  cout << "YES" << endl;
  else
  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <chrono>
#include <random>
#include <ctime>
#include <algorithm>
#include <iosfwd>
#include <iostream>
#include <list>
#include <ostream>
#include <streambuf>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long int ll;
typedef long long int ull;
typedef long double ld;
#define fori(i, n) for(ll i = 0; i < (n); ++i)
#define forI(i, n) for(ll i = 1; i <= (n); ++i)
#define pll pair<ll, ll>
#define ff first
#define ss second

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#define pt pair<ll, ll>
#define x first
#define y second

pll operator+(pll a, pll b) { return {a.x + b.x, a.y + b.y}; }
pll operator-(pll a, pll b) { return {a.x - b.x, a.y - b.y}; }

ll rand0m() {return (ull(rand()) << 15ull | ull(rand()));}                   //[0 ... n)
ll rand0m(ll x) {return rand0m() % x;}               //[0 ... n)
ll rand0m(ll minn, ll maxx) {return rand0m(maxx - minn + 1) + minn;}   //[minn ... maxx]

const ll MAXN = 6e5 + 1;
const ll mod = 1e9 + 7;
const ll INF = 1e18;

ll n, m;
ll dp[3001];
pll sq[3001];
ll f[MAXN];

ll pw(ll a, ll p){
    if(p == 0) return 1;
    ll res = pw(a, p / 2);
    if(p % 2 == 1) return res * res % mod * a % mod;
    return res * res % mod;
}

ll C(ll n, ll k){
    return f[n] * pw(f[k] * f[n - k] % mod, mod - 2) % mod;
}

void solve(){
    f[0] = 1;
    forI(i, MAXN - 1) f[i] = f[i - 1] * i % mod;
    ll w, h;
    cin >> w >> h >> n;
    fori(i, n) cin >> sq[i].x >> sq[i].y;
    fori(i, n) --sq[i].x, --sq[i].y;
    sort(sq, sq + n);
    sq[n] = {w - 1, h - 1};
    fori(i, n + 1){
        ll min = 0;
        fori(j, i){
            if(sq[j].x <= sq[i].x && sq[j].y <= sq[i].y){
                min += dp[j] * C(sq[i].x - sq[j].x + sq[i].y - sq[j].y, sq[i].x - sq[j].x) % mod;
                if(min >= mod) min -= mod;
            }
        }
        dp[i] = (C(sq[i].x + sq[i].y, sq[i].x) - min + mod) % mod;
    }
    cout << dp[n];
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //stress();
    solve();
}


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

int water[70], sugar[3050];
int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	water[0]=sugar[0]=1;
	for(int i=0; i*100<=F; ++i){
	    if(water[i]==1) water[i+A]=water[i+B]=1;
	}
	for(int i=0; i<=F; ++i){
	    if(sugar[i]==1){
	        sugar[i+C]=sugar[i+D]=1;
	        sugar[i]=i;
	    }
	    else sugar[i]=sugar[i-1];
	}
	double mx=-1; int p, q;
	for(int i=1; i*100<=F; ++i){
	    if(water[i]==1){
	        int S=sugar[min(i*E, F-i*100)];
	        if(mx<(double) S/(i*100+S)){
	            p=i*100+S;
	            q=S;
	            mx=(double) S/(i*100+S);
	        }
	    }
	}
	cout << p << ' ' << q << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, s, sum = 0, min_10t = 1000;
    cin >> N;
    REP(i, N) {
        cin >> s;
        sum += s;
        if (s < min_10t && s % 10 != 0) min_10t = s;
    }

    if (sum % 10 == 0) {
        if (min_10t == 1000) cout << 0 << endl;
        else cout << sum - min_10t << endl;
    }
    else cout << sum << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

template <class T>
void read(T& x, T f = 1, char ch = getchar()) {
    x = 0;
    while (ch < '0' || ch > '9') f = (ch == '-' ? -1 : 1), ch = getchar();
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}
int n;
int main() {
    cin >> n;
    if (n >= 30)
        puts("Yes");
    else
        puts("No");
    return 0;
}


Measured memory_bytes: 3628
N,K=map(int, input().split())
AA=list(map(int, input().split()))
A=sorted(AA)
B=sorted(AA)[::-1]
mod=10**9+7

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
n = 10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, n+1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans=0
for i in range(N-K+1):
  d=(A[K-1+i]%mod)*cmb(K-1+i,K-1,mod)
  e=(B[K-1+i]%mod)*cmb(K-1+i,K-1,mod)
  ans+=d%mod-e%mod
  ans%=mod
print(ans)

Measured memory_bytes: 79268
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n, k; cin >> n >> k;
  int pt, cnt;
  double ans=0;
  
  for (int i=0; i<n; i++) {
    cnt = 1;
    pt = i + 1;
    while (pt < k) {
      pt *= 2;
      cnt *= 2;
    }
    ans += 1 / double(cnt);
  }
  cout << setprecision(13) << (ans / double(n)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int count[4][3][10];
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				count[i][j][k] = 0;
			}
		}
	}
	int n, b, f, r, v;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> b >> f >> r >> v;
		count[b - 1][f - 1][r - 1] = count[b - 1][f - 1][r - 1] + v;
	}
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				if (k == 9)cout <<" "<< count[i][j][k] << endl;
				else cout <<" "<< count[i][j][k] ;
				if (k == 9 && j == 2)
				{
					if (i < 3)cout << "####################" << endl;
				}
			}
		}
	}
	


	return 0;

}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl
#define rep(n, i) for (int i = 0; i < n; i++)

using namespace std;
using i64 = long long;

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

    int ans = abs(n - 1);
    cout << ans << endl;

    return 0;
}

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

int main() {
	char s[4];
	int count;
	string res;

	cin >> s;

	res = "Yes";

	for (int j=0; j<4; j++){
		count = 0;
		for (int i=0; i<4; i++){
			if (s[j] == s[i]) count++; 
		}
		if (count != 2){
			res = "No";
			break;
		}
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]


from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

li = list(map(int,input().split()))
A, B, C, D, E, F = li[0], li[1], li[2], li[3], li[4], li[5]

A, B = A*100, B*100

N = F//A

waters = set()
sugers = set()

for i in range(N+1):
    j = 0
    while True:
        water = A*i + B*j
        if  water <= F:
            waters.add(water)
        else:
            break
        j += 1

M = F//C

for i in range(M+1):
    j = 0
    while True:
        suger = C*i + D*j
        if suger <= F:
            sugers.add(suger)
        else:
            break
        j += 1

ans = 0
ans_water = 0
ans_suger = 0
for water in waters:
    for suger in sugers:
        if water == 0 or E/(100+E) < suger/(water+suger) or suger+water > F:
            # print("{} {}".format(ans_water+ans_suger, ans_suger))
            continue
        tmp_p = (100*suger)/(water+suger)
        if tmp_p >= ans:
            ans = tmp_p
            ans_water = water
            ans_suger = suger

print("{} {}".format(ans_water+ans_suger, ans_suger))

Measured memory_bytes: 12352
#include <iostream>
#include <limits.h>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	int n,maxv=INT_MIN,minv;
	cin >> n;
	int coin[n];
	for(int i=0; i<n; i++){	//??\???
		cin >> coin[i];
	}

	minv = coin[0];
	for(int i=1; i<n; i++){
		maxv = max(maxv,coin[i]-minv);
		minv = min(minv,coin[i]);
	}

	cout << maxv << endl;
	return 0;
}

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

int main(){
  long long H, W, N;
  cin >> H >> W >> N;
  map<pair<int, int>, int> mp;
  for (int i=0; i<N; i++){
    int a, b; cin >> a >> b;
    for (int x=-1; x<=1; x++){
      for (int y=-1; y<=1; y++){
        if (a+x<=1||a+x>=H||b+y<=1||b+y>=W) continue;
        mp[make_pair(a+x, b+y)]++;
      }
    }
  }
  vector<long long> ans(10,0);
  for (auto k: mp){
    // cout << k.first.first << ' ' << k.first.second << endl;
    ans[k.second]++;
  }
  long long sum = 0;
  for (int i=1; i<=9; i++){
    sum += ans[i];
  }
  ans[0] = (H-2)*(W-2) - sum;
  for (int i=0; i<=9; i++){
    cout << ans[i] << endl;
  }
}


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

main(){
	bool isp[10001];
	memset(isp,true,sizeof(isp));
	isp[1]=false;
	for(int i=2;i<10001;i++){
		if(isp[i]){
			for(int j=2;i*j<10001;j++){
				isp[i*j] = false;
			}
		}
	}
	int n;
	while(cin >> n){
		int ret=0;
		for(int i=1;i<=n;i++){
			if(isp[i] && isp[n-i+1]) ret++;
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int n;
    scanf("%d", &n);
    if(100<=n&&n<=111) n = 111;
    if(111<n&&n<=222) n = 222;
    if(222<n&&n<=333) n = 333;
    if(333<n&&n<=444) n = 444;
    if(444<n&&n<=555) n = 555;
    if(555<n&&n<=666) n = 666;
    if(666<n&&n<=777) n = 777;
    if(777<n&&n<=888) n = 888;
    if(888<n&&n<=999) n = 999;
    printf("%d", n);
}


Measured memory_bytes: 128
#include<stdio.h>

int main() {
  int A, B;
  int max = 0;
  int i;

  scanf("%d %d", &A, &B);

  for(i = 0; i < 2; i++) {
    if(A > B) {
      max += A;
      A--;
    } else {
      max += B;
      B--;
    }
  }

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

  return 0;
}


Measured memory_bytes: 128
<?php
fscanf(STDIN, "%d %d %d", $square, $FeeStationNum, $location);
$allStationLocation = trim(fgets(STDIN));
$stationLocation = explode(" ", $allStationLocation);
$leftcount = 0;

for($i=0; $i<$FeeStationNum; $i++){
    if($stationLocation[0]<=$location){
        $split = array_splice($stationLocation, 0, 1);
        $leftcount++;
    }
    else{
        break;
    }
}

//回答出力
if($leftcount >= count($stationLocation)){
    echo count($stationLocation);
}else{
    echo $leftcount;
}

Measured memory_bytes: 4604
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <tuple>
using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	if (B%A == 0) cout << A + B << endl;
	else cout << B - A << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int main (void){
    int a, b;
    cin >> a >> b;
    if(0 < a - (b * 2)){
        cout << a - (b * 2) << endl;
    }else{
        cout << "0" << endl;
    }
    return 0;
}



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

using namespace std;

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

	int n;
	cin >> n;
	
	bool flag = false;
	char c;
	for (int i = 0;i < n;i++){
		cin >> c;
		if (c == 'Y') flag = true;	
	}	

	cout << (flag ? "Four" : "Three") << endl;
	
	return 0;

}


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

bool isPalinedrome(string s, int start, int end)
{
    //cout << s.substr(start, end - start) << "\n";
    
    for(int i = start; i < start + (end - start) / 2; i++)
    {
        if(s[i] != s[end - i - 1])
        {
            return false;
        }
    }
    
    return true;
}

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    
    if(isPalinedrome(s, 0, n) && isPalinedrome(s, 0, (n - 1) / 2) && isPalinedrome(s, (n + 3) / 2 - 1, n))
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	vector<string> s={"Sunny", "Cloudy", "Rainy","Sunny"};
	string t;
	cin >> t;
	for(ll i=0; i<4; i++){
		if(s[i]==t){
			cout << s[i+1];
			return 0;
		}
	}
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int N, B[SIZE];

  cin >> N;

  for(int i=0; i<N-1; i++) cin >> B[i];

  B[N-1] = INF;

  ll ans = 0;

  for(int i=0; i<N; i++) {
    if (i == 0) ans += B[i];
    else ans += min(B[i-1],B[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100000+10;

int n,a[N];

int main() {
	n=read();
	for (int i=1;i<=n;++i) a[i]=read();
	ll ans1=0,ans2=0,sum=0;
	for (int i=1;i<=n;++i) {
		if (i&1) {
			if (sum+a[i]>0) sum+=a[i];
			else ans1+=1-(sum+a[i]),sum=1;
		} else {
			if (sum+a[i]<0) sum+=a[i];
			else ans1+=(sum+a[i])+1,sum=-1;
		}
	}
	sum=0;
	for (int i=1;i<=n;++i) {
		if (i&1) {
			if (sum+a[i]<0) sum+=a[i];
			else ans2+=(sum+a[i])+1,sum=-1;
		} else {
			if (sum+a[i]>0) sum+=a[i];
			else ans2+=1-(sum+a[i]),sum=1;
		}
	}
	printf("%lld\n",min(ans1,ans2));
	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int d;
    while (cin >> d)
    {
        int area = 0;
        for (int i = d; i <= 600 - d; i += d)
        {
            area += d * pow(i, 2);
        }
        OP(area)
    }

    return 0;
}


Measured memory_bytes: 3096
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod1 1000000007
#define mod2 1000000009
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class DSumOfDivisors {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int n;
        cin>>n;
        ll ans=0,val;
        vector<int> v(n+1,1);
        for (ll i=2;i<=n;i++){
            for (ll j=i;j<=n;j+=i)
                v[j]++;
        }
        for (ll i=1;i<=n;i++){
            val=v[i];
            ans+=i*val;
        }
        cout<<ans;
	}
};


int main() {
	DSumOfDivisors solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 42260
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
bool check (int n) {
    int x = n%10;
    n /= 10;
    while (n>0) {
        if (x!=(n%10)) return false;
        n /= 10;
    }
    return true;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    while (1) {
        if (check(n)) {
            cout<<n;
            return 0;
        }
        n++;
    }
}


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

int main() {
  string s;
  cin >> s;
  
  int a_position = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i)=='A') {
      a_position = i;
      break;
    }
  }

  int z_position = 0;
  for (int i = s.size()-1; a_position < i; i--) {
    if (s.at(i)=='Z') {
      z_position = i;
      break;
    }
  }

  cout << z_position-a_position+1 << endl;
}

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????


		int yama[] = new int[10];

		Scanner sc = new Scanner(System.in);
		for(int i = 0;i < yama.length;i++){
			yama[i] = sc.nextInt();
		}
		Arrays.sort(yama);
		for(int j = 9;j >= 7;j--){
			System.out.println(yama[j]);
		}


	}

}

Measured memory_bytes: 26192
/*input
5
24 11 8 3 16
*/
 
 
 
#include <bits/stdc++.h>
using namespace std;
 
 
 
#define int long long int
#define rep(i,n) \
    for(int i = 0; i < n; i++)
#define rep2(i, a, b) \
    for(int i = a; i < b; i++)
#define all(c) \
    c.begin(), c.end()
#define init(arr, num) \
    memset(arr, num, sizeof(arr))
#define fast\
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inputFile \
    freopen("input.txt", "r", stdin); 
#define outputFile \
    freopen("output.txt", "w", stdout);
#define modM 1000000007
#define PI 3.1415926535897932
#define F first
#define S second  
#define pb push_back  
#define INF 3e18
#ifdef gaviria
#define TRACE
#endif
#ifdef TRACE
#define trace(...) _f(#VA_ARGS, __VA_ARGS_)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
 
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< ll, ll > ii;
typedef unordered_set<int> usi;
 


ll n,i,j,k,m;

void solve()
{
cin>>n;

int a[n];
set <int> s;
map <int,int> mp;
rep(i,n)
{
cin>>a[i];
mp[a[i]]++;
}
sort(a,a+n);
int ans=0;
int c=0;
for(i=0;i<n;i++)
{c=1;
    if(mp[a[i]]>1)
    {
       
    }
    else ans++;

    for(j=2*a[i];j<=a[n-1];j+=a[i])
    {
        mp[j]+=2;
    }
 



}
cout<<ans;

}



 
 
 
signed main()
{
 
    // inputFile;
    // outputFile;
    fast;
    int T = 1;
 // cin >> T;
ll h=T;
    while(T--){
 
        solve();
        cout<<endl;
 
     
        
        
 
    }
    
    
    return 0;
 
}

Measured memory_bytes: 67252
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

import itertools

a = [i for i in range(1, n + 1)]

cnt = 0
t = []
for i in itertools.permutations(a, n):
    cnt += 1
    if list(i) == p:
        t.append(cnt)
    if list(i) == q:
        t.append(cnt)
print(abs(t[0] - t[1]))


Measured memory_bytes: 3064
def make(x):
    x = bin(x)[2:]
    while len(x) < len(S) - 1:
        x = "0" + x
    return list(x)

S = input()
a = pow(2, len(S) - 1)
b = []

for i in range(0, a):
    b.append(make(i))

i = 0
j = 0
key = int(S[0])
snum = 1
ans = 0
if len(S) != 1:
    for i in b:
        snum = 1
        key = int(S[0])
        for j in i:
            if j == "0":
                key *= 10
                key += int(S[snum])
            elif j == "1":
                ans += key
                key = int(S[snum])
            #print(i, j, key)
            snum += 1
        ans += key
    print(ans)
else:
    print(S)


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

using namespace std;

int n, q, k;

int main() {
  cin >> n >> k >> q;
  int a[q];
  int score[n];
  rep(i, n) score[i] = k - q;
    
  rep(i, q) {
    cin >> a[i];
    score[a[i]-1]++;
  }
  
  rep(i, n) {
    if(score[i] <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n,ans=0; cin>>n;
	int arr[n];
	for (int i = 0; i < n; i++){
		cin>>arr[i];
	}
	for(int i=1; i<n-1; i++){
		set<int> s;
		s.insert(arr[i]); s.insert(arr[i+1]); s.insert(arr[i-1]); 
		if(*(++s.begin()) == arr[i])ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3556
#include <iostream>

int main() {
  std::ios_base::sync_with_stdio(false);

  std::string a;
  std::string b;

  std::cin >> a;
  std::cin >> b;

  bool match = false;

  if (a.size() < b.size()) {
      return 0;
  }

  for (int i = 0; i <= (a.size() - b.size()); i++) {
    match = true;
    
    for (int j = 0; j < b.size(); j++) {
      if (a[i + j] != b[j]) {
	match = false;
	
	break;
      }
    }

    if (match) {
      std::cout << i << std::endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1188
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        ans = a+b;
        if(ans<a-b)ans=a-b;
        if(ans<a*b)ans=a*b;
        System.out.println(ans);
    }
}

Measured memory_bytes: 22868
#include<iostream>
using namespace std;
long N,P,cnt[10101],T[2<<17],ans,mod,i;
string s;

int main()
{
    cin>>N>>P>>s;
    if(P==2||P==5)
    {
        for(int i =0;i<N;i++)
        {
            if((s[i]-'0')%P==0)
                ans+=i+1;
        }
        cout<<ans<<endl;return 0;
    }
    T[N-1]=1;
    for(int i=N-2;i>=0;i--) T[i]=T[i+1]*10%P;
    cnt[0]=1;
    for(int i=0;i<N;i++)
    {
        mod=(mod+(s[i]-'0')*T[i])%P;
        ans+=cnt[mod]++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 2180
#include<stdio.h>
int main(void)
{
 int n,i=0,j;
 scanf("%d",&n);
if(n==999999999){
printf("1999999998\n");
}else if(n%2==0){
 printf("%d\n",n);
 }else{
    for(i=0;;){
        i=i+2;
    if(i%n==0){
        printf("%d\n",i);
        break;
        }
    }
    }



return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
    string s,t;
    cin>>s>>t;
    int ans=0;
    rep(i,3) if(s[i]==t[i]) ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int a, b;
cin >> a >> b;
if (a == b){
cout << "Draw\n";
}else if ( (b>= a && a!= 1) || b == 1){
cout << "Bob\n";
}else{
cout << "Alice\n";
}
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

int main(void) {
	long long n, p;
	cin >> n >> p;
	long long ans;
	if (n == 1) {
		cout << p;
	}
	else {
		for (long long i = 1; i <= p && pow(i, n) <= p; i++) {
			if (p % ((long long)pow(i, n)) == 0) {
				ans = i;
			}
			//cout << i << endl;
		}
		cout << ans;
	}
	
	return 0;
}

Measured memory_bytes: 256
import bisect

A, B, Q = map(int, input().split())
s = [None] * A
t = [None] * B
for i in range(A):
  s[i] = int(input())
for i in range(B):
  t[i] = int(input())
  
for _ in range(Q):
  x = int(input())
  sr = bisect.bisect_left(s, x)
  if sr == A:
    sr -= 1
  sl = max([0, sr - 1])
  tr = bisect.bisect_left(t, x)
  if tr == B:
    tr -= 1
  tl = max([0, tr - 1])
  sr = s[sr]
  sl = s[sl]
  tr = t[tr]
  tl = t[tl]
  cand = [abs(tl - x) + abs(sl - tl), abs(tl - x) + abs(sr - tl),
         abs(tr - x) + abs(sl - tr), abs(tr - x) + abs(sr - tr),
         abs(sl - x) + abs(tl - sl), abs(sl - x) + abs(tr - sl),
         abs(sr - x) + abs(tl - sr), abs(sr - x) + abs(tr - sr),]
  print(min(cand))

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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

int main(){
  int n,m;
  cin >> n >> m;
  cout << conbination(n,2) + conbination(m,2) << endl;
}


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

using namespace std;
#define int long long
typedef long long int64;

const int64 INF = 1LL << 58;

struct CumulativeSum
{
  vector< int64 > data;

  CumulativeSum(int sz) : data(++sz, 0) {};

  inline void add(int k, int x)
  {
    data[k] += x;
  }

  void build()
  {
    for(int i = 1; i < data.size(); i++) {
      data[i] += data[i - 1];
    }
  }

  inline int64 query(int k)
  {
    if(k < 0) return (0);
    return (data[min(k, (int) data.size() - 1)]);
  }
};

CumulativeSum sum1(100000), sum2(100000);

int64 sums1(int l, int r)
{
  return (sum1.query(r) - sum1.query(l));
}

int64 sums2(int l, int r)
{
  return (sum2.query(r) - sum2.query(l));
}

signed main()
{
  int N, K, A[100000];

  cin >> N >> K;

  for(int i = 0; i < N; i++) {
    cin >> A[i];
    sum1.add(i, max(0LL, A[i]));
    sum2.add(i, A[i]);
  }
  sum1.build();
  sum2.build();

  int64 ret = 0;
  for(int i = 0; i <= N - K; i++) {
    ret = max(ret, sums1(-1, i - 1) + sums1(i + K - 1, N - 1) + sums2(i - 1, i + K - 1));
    ret = max(ret, sums1(-1, i - 1) + sums1(i + K - 1, N - 1));
  }
  cout << ret << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
using namespace std;
using ll = long long;
using pii = pair<int,int>;
template<typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a){
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os, vector<T> v){
    for(auto x:v)os << x << ' ';
    return os;
}
void debug(){cerr << '\n';}
template<typename H, typename... T>
void debug(H a, T... b){
    cerr << a;
    if(sizeof...(b))cerr << ", ";
    debug(b...);
}
const int mod = 1e9+7;
int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    ll ans = 0;
    rep(i,n){
        for(int j = i + 1; j < n; j++){
            if(a[i] < a[j]){
                ans += k * (k - 1) / 2 % mod;
                ans %= mod;
            }
            if(a[i] > a[j]){
                ans += k * (k + 1) / 2 % mod;
                ans %= mod;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        d: i64,
        a: [i64; n],
    }
    let mut g = vec![Vec::new(); 2 * n];
    for i in 0 .. n {
        g[i].push((n + i, a[i]));
        g[n + i].push((i, a[i]));
    }
    for i in 0 .. n - 1 {
        g[n + i].push((n + i + 1, d));
        g[n + i + 1].push((n + i, d));
    }
    let mut que = BinaryHeap::new();
    const INF: i64 = 1 << 50;
    let mut dp = vec![(INF, 2 * n); 2 * n];
    for i in 0 .. n {
        que.push((-a[i], i, n + i));
        dp[i] = (0, i);
    }
    let mut tot = 0;
    while let Some((dist, v, w)) = que.pop() {
        let dist = -dist;
        if dp[w].0 == INF {
            dp[w] = (dist, v);
            for &(u, cost) in g[w].iter() { 
                que.push((-dist - cost, v, u));
            }
        } else {
            // dp[w].1 and v meets
            if v != dp[w].1 {
                tot += dp[w].0 + dist;
            }
        }
    }
    puts!("{}\n", tot / 2);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 71160
#include <cstdio>
#include <algorithm>
using namespace std;
long long dp[410][410], s[410];
int a[410];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		s[i+1] = s[i] + a[i];
	}
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j < n - i + 1; j++) {
			dp[j][i+j] = 1ll << 61;
			for (int k = 1; k < i; k++) {
				dp[j][i+j] = min(dp[j][i+j], dp[j][j+k] + dp[j+k][i+j]);
			}
			dp[j][i+j] += s[i+j] - s[j];
		}
	}
	printf("%lld\n", dp[0][n]);
	return 0;
}


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

#define ll long long
#define all(x) x.begin(), x.end()

const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
const int INF = 0x3f3f3f3f;

ll knapSack(int W, vector<int> &wt, vector<int> &val){ 
    int n = wt.size();
    int V = accumulate(all(val), 0);
    ll K[n+1][V+1];

    for(int i=0; i<=n; i++)
        for(int v=0; v<=V; v++){
            K[i][v] = INF;
            if(v==0)
                K[i][v] = 0;
            else if(i==0)
                continue;
            else if(val[i-1]<=v)
                K[i][v] = min(wt[i-1]+K[i-1][v-val[i-1]], K[i-1][v]);
            else
                K[i][v] = K[i-1][v];
        }

    int res = INT_MIN;
    for(int v=0; v<=V; v++)
        if(K[n][v]<=W)
            res = max(v, res);

    return res; 
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, w;
    cin >> n >> w;
    vector<int> wt(n), val(n);
    for(int i=0; i<n; i++)
        cin >> wt[i] >> val[i];
    cout << knapSack(w, wt, val) << endl;
    
    return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N;
int A[310][310];

int main(void) {
	cin >> N;
	rep(i, N)rep(j, N) cin >> A[i][j];
	ll ans = 0;
	bool flag = true;
	rep(i, N)reps(j, i + 1, N) {
		// i -> jが隣り合う頂点かしらべる
		ll mi = INFF;
		// printf("i %d j %d\n", i, j);
		rep(k, N) {
			if(i == k || j == k) continue;
			chmin(mi, A[i][k] + A[k][j]);
		}
		// printf("mi %lld\n", mi);
		if(A[i][j] < mi) ans += A[i][j];
		else if(A[i][j] > mi)flag = false;
	}
	if(!flag) printf("-1\n");
	else printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
#define pb push_back
#define INF 1e5
#define REP(i,a,b) for(int i=a;i<b;++i)
#define REPN(i,a,b) for(int i=a;i<=b;++i)

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    
    
    	string s,t;
    	cin>>s>>t;
    	int a,b;
    	cin>>a>>b;
    	string u;
    	cin>>u;
    	if(u==s) a--;
    	else b--;
    	cout<<a<<" "<<b<<"\n";    	
	
      
	return 0;
    
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  long long int h,w;
  cin>>h>>w;
  long long int ans=h*w;
  if(h==1||w==1){ cout<<"1"; return 0;}
  else if(ans%2==0) cout<<ans/2;
  else cout<<ans/2+1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
static const int INFTY = (1 << 21);
ll func(ll a){
    ll b = 0;
    while(a != 0){
        a /= 10;
        b++;
    }
    return b;
}
int main(){
    ll N;
    cin >> N;
    ll ans = 0, fans = INFTY;
    for(ll i = 1; i * i <= N; i++){
        if(N % i == 0){
            ans = max(func(i), func(N / i));
            fans = min(fans, ans);
        }
    }
    cout << fans << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const* argv[])
{
	int m,f,r;
	std::cin >> m>>f>>r;
	while (!(m == -1 && m == f && m == r)) {
		if (m == -1 || f == -1 || m + f < 30) {
			std::cout << "F";
		} else if (m + f >= 80) {
			std::cout << "A";
		} else if (m + f >= 65) {
			std::cout << "B";
		} else if (m + f >= 50) {
			std::cout << "C";
		} else {
			if (r >= 50) {
				std::cout << "C";
			} else {
				std::cout << "D";
			}
		}
		std::cin >> m>>f>>r;
		std::cout << std::endl;
	}
}

Measured memory_bytes: 1156
N, K = map(int, input().split())

h_list = [int(input()) for _ in range(N)]

h_list.sort()

answer = 1e+9

for i in range(N-K+1):
	h_min = h_list[i]
	h_max = h_list[i+K-1]

	if answer > (h_max - h_min):
		answer = h_max - h_min

print(answer)

Measured memory_bytes: 7384
#include<bits/stdc++.h>
	#define int long long
	#define rep(i,m,n) for(int i=m;i<n;i++)
	#define repr(i,n,m) for(int i=n;i>=m ;i--)
	#define mod 1000000007
	#define float long double
	#define pb push_back
	#define mp make_pair
	#define print(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
	using namespace std;
	 
	bool sortbysec(const pair<int,int> &a, 
	              const pair<int,int> &b) 
	{ 
	    return (a.second < b.second); 
	}
	bool sortinrev(const pair<int,int> &a,  
	               const pair<int,int> &b) 
	{ 
	       return (a.first > b.first); 
	}
	void swap(int *a,int *b)
	{
		int t=*a;
		*a=*b;
		*b=t;
	}
	void solve()
	{
		int n;
		cin>>n;
		int total=0;
		int x=n/500;
		total=x*1000;
		int y=(n%500)/5;
		total+=(y*5);
		cout<<total;
	}
	signed main()
	{ 
		// #ifndef ONLINE_JUDGE
	 //   freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	 //   #endif  
	   int t=1; 	
	   //cin>>t;
	   while(t--)
	   {
	      solve();
	      cout<<"\n";
	   }
	   cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	  return 0;
	 }		

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

vector<P> direc {P(1, 1), P(1, -1), P(-1, 1), P(-1, -1)};

bool eightQueen(int x, vector<vector<bool>> grid, vector<P>& ans) {
    if (x == 8) return true;

    rep(i, 8) {
        if (grid[i][x]) return eightQueen(x + 1, grid, ans);
    }

    bool res = false;
    rep(y, 8) {
        bool found = false;
        rep(j, 8) {
            if (grid[y][j]) found = true;
        }
        if (found) continue;

        rep(j, 4) {
            int nx = x + direc[j].first;
            int ny = y + direc[j].second;
            while (nx >= 0 && nx < 8 && ny >= 0 && ny < 8 && !found) {
                if (grid[ny][nx]) found = true;
                nx += direc[j].first;
                ny += direc[j].second;
            }
        }
        if (found) continue;

        grid[y][x] = true;
        res |= eightQueen(x + 1, grid, ans);
        if (res) {
            ans.push_back(P(y, x));
            break;
        }
        grid[y][x] = false;
    }
    return res;
}

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

    int n;
    cin>>n;
    vector<vector<bool>> grid(8, vector<bool>(8, false));
    vector<P> ans;
    rep(i, n) {
        int h, w;
        cin>>h>>w;
        ans.push_back(P(h, w));
        grid[h][w] = true;
    }

    eightQueen(0, grid, ans);
    for (auto a : ans) {
        int y = a.first;
        int x = a.second;
        grid[y][x] = true;
    }
    rep(i, 8) {
        rep(j, 8) {
            if (grid[i][j]) cout<<"Q";
            else cout<<".";
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3232
# include <bits/stdc++.h>
using namespace std;
int n,a[100];
bool sorted()
{
	for(int i=0;i<n-1;i++)
		if(a[i]>a[i+1])
			return false;
	return true;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	if(sorted())
	{
		cout<<"YES"<<endl;
		return 0;
	}
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
		{
			swap(a[i],a[j]);
			if(sorted())
			{
				cout<<"YES"<<endl;
				return 0;
			}
			swap(a[i],a[j]);
		}
	cout<<"NO"<<endl;
	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

bool pass[100002] = {false,};

int main(){
	int N,A,B;
	char S[100002];
	char enter;

	scanf("%d%d%d",&N,&A,&B);

	scanf("%c",&enter);

	for(int i = 0 ; i < N ; i++){
		scanf("%c",&S[i]);
	}

	int definitely_passed = 0;
	int oversea_passed = 0;

	for(int i = 0 ; i < N ; i++){
		if(S[i] == 'a'){
			if(A+B > definitely_passed){
				pass[i] = true;
				definitely_passed++;
			}
		}
		else if(S[i] == 'b'){
			if(A+B > definitely_passed && oversea_passed + 1 <= B){
				pass[i] = true;
				definitely_passed++;
				oversea_passed++;
			}
		}
		else{
			pass[i] = false;
		}
	}
	for(int i = 0 ; i < N ; i++){
		if(pass[i])
			printf("Yes\n");
		else
			printf("No\n");
	}
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
char c[3]={'r','g','b'};
main(){
  string s[3];
  while(cin>>s[0],s[0][0]!='0'){
    cin>>s[1]>>s[2];
    if(s[0][0]=='b'&&s[0][1]=='b'&&s[0][2]=='b')goto B;
    if(s[1][0]=='b'&&s[1][1]=='b'&&s[1][2]=='b')goto B;
    if(s[2][0]=='b'&&s[2][1]=='b'&&s[2][2]=='b')goto B;
    if(s[0][0]=='b'&&s[1][0]=='b'&&s[2][0]=='b')goto B;
    if(s[0][1]=='b'&&s[1][1]=='b'&&s[2][1]=='b')goto B;
    if(s[0][2]=='b'&&s[1][2]=='b'&&s[2][2]=='b')goto B;
    if(s[0][0]=='b'&&s[1][1]=='b'&&s[2][2]=='b')goto B;
    if(s[0][2]=='b'&&s[1][1]=='b'&&s[2][0]=='b')goto B;
    if(s[0][0]=='w'&&s[0][1]=='w'&&s[0][2]=='w')goto W;
    if(s[1][0]=='w'&&s[1][1]=='w'&&s[1][2]=='w')goto W;
    if(s[2][0]=='w'&&s[2][1]=='w'&&s[2][2]=='w')goto W;
    if(s[0][0]=='w'&&s[1][0]=='w'&&s[2][0]=='w')goto W;
    if(s[0][1]=='w'&&s[1][1]=='w'&&s[2][1]=='w')goto W;
    if(s[0][2]=='w'&&s[1][2]=='w'&&s[2][2]=='w')goto W;
    if(s[0][0]=='w'&&s[1][1]=='w'&&s[2][2]=='w')goto W;
    if(s[0][2]=='w'&&s[1][1]=='w'&&s[2][0]=='w')goto W;
    cout<<"NA"<<endl;
    if(0)B:cout<<'b'<<endl;
    if(0)W:cout<<'w'<<endl;
  }
}

Measured memory_bytes: 3132
S = input()[::-1]
T = [s[::-1] for s in ["dream", "dreamer", "erase", "eraser"]]

i = 0
flg = False
while i < len(S):
  flg = False
  for t in T:
    if S[i:i+len(t)] == t:
      i += len(t)
      flg = True
  if not flg:
    break

if flg:
  print('YES')
else:
  print('NO')


Measured memory_bytes: 3188
from fractions import gcd

n = int(input())
s = list(map(int, input().split()))
def ngcd(a):
    y = a[0]
    for i in range(1, len(a)):
        y = y * a[i] // gcd(y, a[i])
    return y
g = ngcd(s)
ans = 0
for i in range(n):
    ans += g // s[i]
print(ans%1000000007)

Measured memory_bytes: 6116
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊
    assert!(0 == 0); //😇

    let (n, m) = (io.read::<usize>(), io.read::<usize>());
    let x = io.readn::<i64>(n);
    let y = io.readn::<i64>(m);

    let mut xa = 0;
    let mut ya = 0;

    xa = x.iter().enumerate().fold(0, |sum, (i, x)| {
        sum % MOD + MOD + i as i64 * x % MOD - (n - i - 1) as i64 * x % MOD
    });
    ya = y.iter().enumerate().fold(0, |sum, (i, x)| {
        sum % MOD + MOD + i as i64 * x % MOD - (m - i - 1) as i64 * x % MOD
    });
    io.writeln(xa * ya % MOD);
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 6396