akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1);
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
struct Pt {
double x, y;
Pt() {}
Pt(double x, double y) : x(x), y(y) {}
Pt operator+(const Pt &a) const { return Pt(x + a.x, y + a.y); }
Pt operator-(const Pt &a) const { return Pt(x - a.x, y - a.y); }
Pt operator*(const Pt &a) const { return Pt(x * a.x - y * a.y, x * a.y + y * a.x); }
Pt operator-() const { return Pt(-x, -y); }
Pt operator*(const double &k) const { return Pt(x * k, y * k); }
Pt operator/(const double &k) const { return Pt(x / k, y / k); }
double abs() const { return sqrt(x * x + y * y); }
double abs2() const { return x * x + y * y; }
double arg() const { return atan2(y, x); }
double dot(const Pt &a) const { return x * a.x + y * a.y; }
double det(const Pt &a) const { return x * a.y - y * a.x; }
};
double tri(const Pt &a, const Pt &b, const Pt &c) { return (b - a).det(c - a); }
int iSP(Pt a, Pt b, Pt c) {
int s = sig((b - a).det(c - a));
if (s) return s;
if (sig((b - a).dot(c - a)) < 0) return -2; // c-a-b
if (sig((a - b).dot(c - b)) < 0) return +2; // a-b-c
return 0;
}
int iLL(Pt a, Pt b, Pt c, Pt d) {
if (sig((b - a).det(d - c))) return 1; // intersect
if (sig((b - a).det(c - a))) return 0; // parallel
return -1; // correspond
}
bool iLS(Pt a, Pt b, Pt c, Pt d) {
return (sig(tri(a, b, c)) * sig(tri(a, b, d)) <= 0);
}
bool iSS(Pt a, Pt b, Pt c, Pt d) {
return (iSP(a, b, c) * iSP(a, b, d) <= 0 && iSP(c, d, a) * iSP(c, d, b) <= 0);
}
bool iSSstrict(Pt a, Pt b, Pt c, Pt d) {
return (sig(tri(a, b, c)) * sig(tri(a, b, d)) < 0 && sig(tri(c, d, a)) * sig(tri(c, d, b)) < 0);
}
Pt pLL(Pt a, Pt b, Pt c, Pt d) {
b = b - a; d = d - c; return a + b * (c - a).det(d) / b.det(d);
}
int x[110];
int y[110];
pair<double,double> z[110];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			scanf("%d%d",x+i,y+i);
			x[i]+=2010;
			y[i]+=2010;
		}
		x[a]=x[0];
		y[a]=y[0];
		int ret=0;
		for(int i=0;i<=4020;i++){
			int sz=0;
			Pt U1=Pt(EPS+i,-3000);
			Pt U2=Pt(1.0-EPS+i,-3000);
			Pt A1=Pt(EPS+i,5000);
			Pt A2=Pt(1.0-EPS+i,5000);
			for(int j=0;j<a;j++){
				if(iSS(U1,A1,Pt(x[j],y[j]),Pt(x[j+1],y[j+1]))){
					z[sz++]=make_pair(pLL(U1,A1,Pt(x[j],y[j]),Pt(x[j+1],y[j+1])).y,pLL(U2,A2,Pt(x[j],y[j]),Pt(x[j+1],y[j+1])).y);
		//			printf("%d %f\n",j,z[sz-1]);
				}
			}
		//	if(sz)printf("%d %d\n",i,sz);
			std::sort(z,z+sz);
			int last=-10000;
			for(int j=0;j<sz/2;j++){
				ret+=max((int)(z[j*2+1].first+1-EPS),(int)(z[j*2+1].second+1-EPS))-max(last,min((int)(z[j*2].first+EPS),(int)(z[j*2].second+EPS)));
				last=max((int)(z[j*2+1].first+1-EPS),(int)(z[j*2+1].second+1-EPS));
		//		printf("%f %f %d\n",(z[j*2+1]-2010),(z[j*2]-2010),(int)(z[j*2+1]+1-EPS)-(int)(z[j*2]+EPS));
			}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1032
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int H, W;
char F[333][333];

const int LIMIT = 611;
bool B[621][621];
int M[621][621];

void MAIN() {
    scanf("%d%d", &H, &W);
    REP (i, H) scanf("%s", F[i]);
    REP (i, H) REP (j, W) if (F[i][j] == '#') {
	int y = i - j + 300;
	int x = i + j;
	B[y][x] = true;
    }
    LL ans = 0;

    REP (i, LIMIT) REP (j, LIMIT) {
	M[i][j+1] = M[i][j] + (int)B[i][j];
    }

    REP (i, LIMIT) REP (j, LIMIT) if (B[i][j]) {
	for (int k=j+1; k<LIMIT; k++) if (B[i][k]) {
	    int d = k-j;
	    if (0 <= i-d) {
		ans += M[i-d][k+1] - M[i-d][j];
	    }
	    if (i+d < LIMIT) {
		ans += M[i+d][k+1] - M[i+d][j];
	    }
	}
    }

    memset(M, 0, sizeof M);
    REP (i, LIMIT) REP (j, i) swap(B[i][j], B[j][i]);
    REP (i, LIMIT) REP (j, LIMIT) {
	M[i][j+1] = M[i][j] + (int)B[i][j];
    }

    REP (i, LIMIT) REP (j, LIMIT) if (B[i][j]) {
	for (int k=j+1; k<LIMIT; k++) if (B[i][k]) {
	    int d = k-j;
	    if (0 <= i-d) {
		ans += M[i-d][k] - M[i-d][j+1];
	    }
	    if (i+d < LIMIT) {
		ans += M[i+d][k] - M[i+d][j+1];
	    }
	}
    }

    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 2176
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;
const int mx=200005;
//abc175

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int ans=0;
    int k=0;
    while(k<3){
        int cnt=0;
        while(s[k]=='S'&&k<3) k++;
        while(k<3&&s[k]=='R'){
            cnt++;
            k++;
        }
        chmax(ans,cnt);
    }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3612
use std::io::{self, BufRead};

fn main() {
  let stdin = io::stdin();
  for line in stdin.lock().lines() {
    let mut is: Vec<i32> = line.unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
    let tmp = is[0];
    is[0] = is[1];
    is[1] = tmp;
    let tmp = is[0];
    is[0] = is[2];
    is[2] = tmp;
    println!("{} {} {}", is[0], is[1], is[2]);
  }
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

int main()
{
    long N;
    std::cin >> N;
    for(long i=0; i<=N/7; i++){
        if((N-7*i)%4==0){
            std::cout << "Yes" << std::endl;
            break;
        }
        if(i==N/7){
            std::cout << "No" << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
from dataclasses import dataclass
from collections import deque


@dataclass
class Query:
    now: int
    prev: int
    cost: int


N, M = map(int, input().split())
E = [[] for _ in range(N + 1)]

for e in range(M):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)

res = [-1 for _ in range(N + 1)]
cost = [float('inf') for _ in range(N + 1)]
cost[1] = 0

queue = deque()

for next in E[1]:
    queue.append(Query(next, 1, 1))

while len(queue):
    q = queue.popleft()
    if cost[q.now] > q.cost:
        res[q.now] = q.prev
        cost[q.now] = q.cost

        for next in E[q.now]:
            if cost[next] > q.cost + 1:
                queue.append(Query(next, q.now, q.cost + 1))

for r in res[2:]:
    if r == -1:
        print('No')
        exit()

print('Yes')
for r in res[2:]:
    print(r)


Measured memory_bytes: 57044
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int arr[upperlimit];
int inp[12]={1,6,9,36,81,216,729,1296,7776,46656,6561,59049};
int main() {
	int n;
	sd(n);
	int x;
	for(int i = 1; i <= n; i++){
		x=INF;
		for(int j = 0; j < 12; j++){
			if(inp[j]<=i){
				x=min(x,arr[i-inp[j]]);
			}
		}
		arr[i]=x+1;
	}
	pd(arr[n]);
	return 0;
}

Measured memory_bytes: 640
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define fun function
#define vi vector<int>
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);

using namespace std;

const int INF = 0x3f3f3f3f;


int main() {
	IOS;
#ifdef xiaofan
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
#endif

	string s;
	cin>>s;
	if(s.size()%2){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0; i<s.size(); i++) {
		if(s[i]=='h'&&s[i+1]=='i')i++;
		else{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;




	return 0;
}



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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;
const int maxn = 1e6 + 10;

int findGreatNum(const vector<int>& primes, int target) {
    int res = 0;
    for (auto& x : primes) {
        if (x >= target) ++res;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    vector<int> primes(n + 1);
    for (int i = 2; i <= n; ++i) {
        int cur = i;
        for (int j = 2; j <= i; ++j) {
            while (cur % j == 0) {
                primes[j]++;
                cur /= j;
            }
        }
    }
    int ans = 0;
    // 75
    ans += findGreatNum(primes, 74);
    // 25 * 3
    ans += findGreatNum(primes, 24) * (findGreatNum(primes, 2) - 1);
    // 15 * 5
    ans += findGreatNum(primes, 14) * (findGreatNum(primes, 4) - 1);
    // 5 * 5 * 3
    ans += findGreatNum(primes, 4) * (findGreatNum(primes, 4) - 1) * (findGreatNum(primes, 2) - 2) / 2;
    cout << ans << endl;
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, d;
    scanf("%d", &n);
    set<int> s;
    for(int i = 0; i < n; i++){
        int x;
        scanf("%d", &x);
        s.insert(x);
    }
    int len = s.size();
    printf("%d\n", len);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <queue>
#include <map>
#include <stack>
using namespace std;
 
int dx[8]={1,-1,0,0,1,1,-1,-1};
int dy[8]={0,0,1,-1,-1,1,-1,1};
 
 
int main() {
string s;
	while(getline(cin,s)){
//		cout<<s<<endl;
		if(s==".") break;
	int ans=1;
	int l=s.length();
	stack<int> st; 
	for(int i=0;i<l;i++){
		if(s[i]=='(') st.push(1);
		else if(s[i]=='[') st.push(2);
		else if(s[i]==')'){
		if(st.empty()==true){
		ans=0;
		break;		
		}
		if (st.top()==1){
		st.pop();		
		}
		else{
		ans=0;
		break;
		}
		}

else if(s[i]==']'){
if(st.empty()==true){
		ans=0;
		break;		
		}
		if (st.top()==2){
		st.pop();		
		}
		else{
		ans=0;
		break;
		}
}
		}
	if(ans==1 && st.empty()==true) cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	}


	return 0;
 
   }

Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>

int H,W;
char data[101][101];
char done[101][101];

int X,Y;

int main()
{
  scanf("%d%d",&H,&W);

  if(H==0&&W==0) return 0;

  memset(done, 0, sizeof(done));

  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      scanf(" %c",&data[i][j]);

  X = Y = 0;
  for(;;){
    if(done[X][Y]){
      puts("LOOP");
      goto NEXT;
    }

    done[X][Y] = 1;

    switch(data[X][Y]){
    case '>':
      Y+=1;
      break;
    case '<':
      Y-=1;
      break;
    case 'v':
      X+=1;
      break;
    case '^':
      X-=1;
      break;
    case '.':
      printf("%d %d\n",Y,X);
      goto NEXT;
    }
  }

 NEXT:
  main();
}

Measured memory_bytes: 0
<?php
ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d %d %d", $N, $M, $K);

$array = array();

for ($i = 0; $i <= $N; $i++) {
    for ($j = 0; $j <= $M; $j++) {
        $x = $i * $j + ($N - $i) * ($M - $j);
        $array[$x] = 1;
    }
}

echo $array[$K] ? "Yes" . "\n" : "No" . "\n";


Measured memory_bytes: 24056
#include <bits/stdc++.h>
using namespace std;
#define int long long int

#undef int
int main()
{
#define int long long int
 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    int n, m;
    cin>>n>>m;
    vector< vector<int> > v(n);
    for(int i = 0;i<m;i++)
    {
        int a, b;
        cin>>a>>b;
        v[a-1].push_back(b-1);
        v[b-1].push_back(a-1);
    }
    string ans = "IMPOSSIBLE";
    for(int i = 0;i<v[0].size();i++)
        for(int j = 0;j<v[v[0][i]].size();j++)
            if(v[v[0][i]][j]==n-1)
                ans = "POSSIBLE";
    cout<<ans<<endl;

    return 0;
} 

Measured memory_bytes: 12776
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n,k,i,j;long long ans=0;
	scanf("%d%d",&n,&k);
	for(i=k+1;i<=n;++i)for(j=0;j<=n;j+=i)ans+=max(0,min(n+1,j+i)-j-k);
	printf("%lld",ans-(k?0:n));
}

Measured memory_bytes: 128
# エラトステネスの篩, フェルマーの小定理
max_A = 1000000

N = int(input())
A = list(map(int, input().split()))

m = 1000000007

sieve = [0] * (max_A + 1)
sieve[0] = -1
sieve[1] = -1
for i in range(2, max_A + 1):
    if sieve[i] != 0:
        continue
    sieve[i] = i
    for j in range(i * i, max_A + 1, i):
        if sieve[j] == 0:
            sieve[j] = i

lcm_factors = {}
for i in range(N):
    t = []
    a = A[i]
    while a != 1:
        if len(t) != 0 and t[-1][0] == sieve[a]:
            t[-1][1] += 1
        else:
            t.append([sieve[a], 1])
        a //= sieve[a]
    for k, v in t:
        if k not in lcm_factors or lcm_factors[k] < v:
            lcm_factors[k] = v

lcm = 1
for k in lcm_factors:
    for i in range(lcm_factors[k]):
        lcm *= k
        lcm %= m

result = 0
for i in range(N):
    result += lcm * pow(A[i], m - 2, m)
    result %= m
print(result)


Measured memory_bytes: 20204
//高さを0にもできることに注意！！！！
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

void chmin(int &a, int b) { a = min(a, b); }

int INF = 1e+13;
int n, K;
int h[301];
vector<int> sortH;
int ordH[301];
int dp[302][302][302];	//dp[i][j][k] = i個見た. 最後の高さはsortH[j]. k回変更.

signed main() {
	int i, j, k;
	
	cin >> n >> K;
	h[0] = 0;
	rep(i, n) cin >> h[i + 1];
	sortH.push_back(h[0]);
	rep(i, n) sortH.push_back(h[i + 1]);
	sort(sortH.begin(), sortH.end());
	sortH.erase(unique(sortH.begin(), sortH.end()), sortH.end());
	n = n + 1;
	
	rep(i, n) ordH[i] = lower_bound(sortH.begin(), sortH.end(), h[i]) - sortH.begin();
	
	rep(i, n + 1) rep(j, n) rep(k, K + 1) dp[i][j][k] = INF;
	dp[0][0][0] = 0;
	
	for (i = 0; i < n; i++) {
		rep(j, n) {
			rep(k, K + 1) {
				if (dp[i][j][k] >= INF) continue;
				//h[i]を変更しない
				chmin(dp[i + 1][ordH[i]][k], dp[i][j][k] + h[i] - min(h[i], sortH[j]));
				//h[i]をsortH[j]に変更する
				if (k + 1 <= K) chmin(dp[i + 1][j][k + 1], dp[i][j][k]);
			}
		}
	}
	
	int ans = INF;
	rep(j, n) rep(k, K + 1) chmin(ans, dp[n][j][k]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 215552
from itertools import accumulate

N, M = map(int, input().split())
S = list(map(int, input()))
cum = list(accumulate([0] + S))
ok = [False] * (N+1)
for i in range(N):
    if S[i] == 0 and cum[i+1] - cum[max(0, i-M+1)] < min(i+1, M):
        ok[i] = True
s = N
t = N
i = N
ans = []
while t > 0:
    if s - i > M:
        if s == t:
            print(-1)
            exit()
        ans.append(s - t)
        s = t
        i = s
        continue
    if ok[i]:
        t = i
    i -= 1
ans.append(s)
print(*ans[::-1])

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

using namespace std;

typedef long long ll;

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

    vector<ll> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];

    bool flag = true;
    for (int i = N-1; i > 0; i--) {
        if (H[i-1] - H[i] > 1) {
            flag = false;
            break;
        } else if (H[i-1] - H[i] == 1) {
            H[i-1]--;
        }
   }

    cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1024
# region header
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
import copy
# @lru_cache(maxsize=None)
# sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
# endregion
# region input function


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


# endregion

n = inp()
ans = 0
for i in range(1, n + 1):
    ans += n // i
    if n % i == 0:
        ans -= 1
print(ans)


Measured memory_bytes: 70264
#include<iostream>
using namespace std;
int main(){
 int a;
 char c;
  int b;
  while(cin>>a>>c>>b){
    if(c=='?'){
      break;
    }
    else{
      if(c=='+'){
        cout<<a+b<<endl;
      }
      else if(c=='-'){
        cout<<a-b<<endl;
      }
      else if(c=='*'){
        cout<<a*b<<endl;
      }
      else{
       cout<<a/b<<endl; 
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3080
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb emplace_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 31000000
// #define M 19
 
#define mod  100007
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 2000000000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

inline ll mul(ll a, ll b) { return (long long) a*b%mod;}
inline ll add(ll a, ll b) { return a+b < mod? a+b: a+b-mod;}
inline void Mul(ll &a, ll b) { a = (long long) a*b%mod;}
inline ll bp(ll a, ll p){
	ll ret;
	for(ret = 1; p; p>>=1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1);
	return ret;
}

static inline void read(ll &result) {
    bool minus = false;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' and ch <= '9') break;
        ch = getchar();
    }
    (ch == '-')? minus = true: result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' or ch > '9') break;
        result = (result<<3)+ (result<<1) + (ch - '0');
    }
    if(minus) result=-result;
}

ll ar[1<<17], br[1<<17], cr[1<<17];

int main(){
	fastio;
	ll x, y, a, b, c; cin>>y>>x>>a>>b>>c;
	ll tot = x + y, ans = 0;
	vii tnt;
	FER(i, 0, a) cin>>ar[i], tnt.pb(ii{ar[i], 1});
	FER(i, 0, b) cin>>br[i], tnt.pb(ii{br[i], 2});
	FER(i, 0, c) cin>>cr[i], tnt.pb(ii{cr[i], 3});
	sort(all(tnt));
	ll acum = 0;
	while(sz(tnt)){
		if(acum == x + y) break;
		auto it = tnt.back();
		if(it.ss == 3){
			acum ++;
			ans += it.ff;
		}
		else if(it.ss == 2 and x){
			x--;
			ans += it.ff;
		}
		else if(it.ss == 1 and y){
			y--;
			ans += it.ff;
		}
		tnt.pop_back();
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 13756
#include <stack>
#include <iostream>

int main()
{
  std::stack<int> train;
  int num;
  while(std::cin >> num){
    if(num != 0){
	  train.push( num );
	}
	else {
	  std::cout << train.top() << std::endl;
      train.pop();
    }
  }
  return 0;
}

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

int main() 
{
    int n,i,count=0;
    cin>>n;
    int arr[n],a[n];
    
    for( i=0;i<n;i++)
        cin>>arr[i];
        
    for(i=0;i<n;i++)
        a[i]=arr[i];
        
    sort(a,a+n);
    
    for(i=0;i<n;i++)
    {
        if(a[i]!=arr[i])
            count++;
    }
    if(count<3)
        cout<<"YES";
    else
        cout<<"NO";
}


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

const int maxn = 100010;
int n;
pair<int, int> p[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &p[i].second);
    }
    for (int i = 1; i <= n; i++) {
        scanf("%d", &p[i].first);
    }
    sort(p + 1, p + n + 1);
    set<pair<int, int>> S;
    for (int i = n; i > 1; i--) {
        S.insert(make_pair(p[i].second, i));
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (p[i].second <= p[i].first) continue;
        if (i == n) printf("No\n"), exit(0);
        cnt++;
        auto it = S.lower_bound(make_pair(p[i].first + 1, 0));
        if (it == S.begin()) printf("No\n"), exit(0);
        S.erase(make_pair(p[i].second, i));
        swap(p[i].second, p[(--it)->second].second);
        S.erase(it), S.insert(make_pair(p[it->second].second, it->second));
    }
    printf("%s\n", cnt < n - 1 ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

int a[1000100];

int main() {
    #ifdef LOCAL
    assert(freopen("b.in", "r", stdin));
    #else
    #endif
    int n, x;
    cin >> n >> x;
    if (x == 1 || x == 2 * n - 1) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    if (n == 2) {
        cout << 1 << '\n' << 2 << '\n' << 3 << '\n';
        return 0;
    }
    set<int> v;
    if (x + 1 == 2 * n - 1) {
        a[n - 1] = x + 1;
        a[n] = x;
        a[n - 2] = x - 1;
        a[n + 1] = x - 2;
        v.insert(x + 1);
        v.insert(x);
        v.insert(x - 1);
        v.insert(x - 2);
    } else {
        a[n - 1] = x - 1;
        a[n] = x;
        a[n - 2] = x + 1;
        a[n + 1] = x + 2;
        v.insert(x - 1);
        v.insert(x);
        v.insert(x + 1);
        v.insert(x + 2);
    }
    int y = 1;
    forn (i, n - 2) {
        while (v.count(y))
            ++y;
        a[i] = y;
        v.insert(y);
    }
    for (int i = n + 2; i < 2 * n - 1; ++i) {
        while (v.count(y))
            ++y;
        a[i] = y;
        v.insert(y);
    }
    forn (i, 2 * n - 1)
        cout << a[i] << '\n';
}


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

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1) 
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__)
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__) 
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__)
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__)
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__)
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__)
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__)

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__)

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32") == 0) return "%d";
  if(strcmp(fmt, "u32") == 0) return "%u";
  if(strcmp(fmt, "f32") == 0) return "%f";
  if(strcmp(fmt, "f64") == 0) return "%lf";
  if(strcmp(fmt, "i64") == 0) return "%lld";
  if(strcmp(fmt, "u64") == 0) return "%llu";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { const type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__)
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__)
#define RF(...)   _FCN(_R, f32, __VA_ARGS__)
#define RD(...)   _FCN(_R, f64, __VA_ARGS__)
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__)
#define RULL(...) _FCN(_R, u64, __VA_ARGS__)

#define PI(...)   _FCN(_P, i32, __VA_ARGS__)
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__)
#define PF(...)   _FCN(_P, f32, __VA_ARGS__)
#define PD(...)   _FCN(_P, f64, __VA_ARGS__)
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__)
#define PULL(...) _FCN(_P, u64, __VA_ARGS__)

#define REP(n) for (int _i = 0; _i < n; _i++)

const u64 mod = 1000000007;

int main() {
  RULL(D);
  cout << "Christmas";

  while (D != 25) {
    cout << " Eve";
    D++;
  }
  
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

main() {
    int ans=0; int N; cin >> N;
    rep(i,N){
        int x; cin >> x;
        ans+=(x-1);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
dp = [float('inf')]*(N+1)
dp[0] = 0#i円を引き出す最小の操作回数
for i in range(1,N+1):
    dp[i] = 1 + dp[i-1]
    j,k = 1,1
    while pow(6,j)<=i:
        dp[i] = min(dp[i],1+dp[i-pow(6,j)])
        j += 1
    while pow(9,k)<=i:
        dp[i] = min(dp[i],1+dp[i-pow(9,k)])
        k += 1
print(dp[-1])

Measured memory_bytes: 74436
#include<bits/stdc++.h>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
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;}

string S;
int c0,c1,L,i;
inline void solve(){
  IN(S);
  L=S.size();
  REP(i,L){
    if(S[i]=='0')c0++;
    if(S[i]=='1')c1++;
  }
  OUT(min(c0,c1)*2);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 512
C[1<<21]={0,1};main(a,d,n){for(;++a<5e5;)for(d=a;d<1e6;)C[d+=a]=1;for(;scanf("%d%d%d",&a,&d,&n)*n;printf("%d\n",a))for(a-=d;C[a+=d]||--n;);}

Measured memory_bytes: 6268
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 c = sc.nextInt();
        int d = sc.nextInt();
        while(true){
            c -= b;
            if(c <= 0){
                System.out.println("Yes");
                break;
            }
            a -= d;
            if(a <= 0){
                System.out.println("No");
                break;
            }
        }
        sc.close();

    }

}


Measured memory_bytes: 35792
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	ll ans=0;
	map<pair<int,int>,ll> mp;
	for(int i=1;i<=n;i++){
		string s=to_string(i);
		mp[make_pair(s[0]-'0',s[s.size()-1]-'0')]++;
	}
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			ans+=mp[make_pair(i,j)]*mp[make_pair(j,i)];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a,b,c;
int main()
{
    scanf("%d%d%d",&a,&b,&c);
    if((a==b&&b==c)||(a!=b&&b!=c&&c!=a))
    {
        printf("No");
    }
    else
    {
        printf("Yes");
    }
}

Measured memory_bytes: 768
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	sort.Ints(arr)

	count := 1
	for i := 1; i < n; i++ {
		if arr[i] > arr[i-1] {
			count++
		}
	}

	fmt.Println(count)
}


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

string s;
int n;
int cnt;

int main(){
    cin >> n >> s;
    for (int i = 0; i < 1000; i++){
        int c[3] = {i/100, (i/10) % 10, i %10};
        int f = 0;
        for (int j = 0; j < n; j++){
            if (s[j] == ('0' + c[f]))f++;
            if (f == 3) break;
        }
        if (f == 3) cnt++;
    }
    cout << cnt << endl;
}

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

using namespace std;

#define MOD 100000

int main(void){
	int w,h;
	
	while(cin >> w >> h){
		if((w|h) == 0) break;
		int dpr[h][w];
		int dpu[h][w];
		memset(dpr, 0, sizeof(dpr));
		memset(dpu, 0, sizeof(dpu));
		dpr[0][0] = 1;
		dpu[0][0] = 1;
		
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if((i|j) == 0){
					dpr[0][1] = 1;
					dpu[1][0] = 1;
				}else{
					if(i+2 < h) dpu[i+2][j] += dpr[i][j] % MOD;
					if(j+1 < w) dpr[i][j+1] += dpr[i][j] % MOD;
					if(j+2 < w) dpr[i][j+2] += dpu[i][j] % MOD;
					if(i+1 < h) dpu[i+1][j] += dpu[i][j] % MOD;
					if(i == h-1 && j == w-2){
						dpr[h-1][w-1] += dpu[h-1][w-2] % MOD;
					}else if (i == h-2 && j == w-1){
						dpu[h-1][w-1] += dpr[h-2][w-1] % MOD;
					}
 				}
			}
		}
		cout << (dpu[h-1][w-1] + dpr[h-1][w-1]) % MOD << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using ll = long long;
constexpr ll MOD = 1000000007LL;
int main()
{
    int H, W, K;
    std::cin >> H >> W >> K, K--;
    constexpr int t[] = {1, 1, 2, 3, 5, 8, 13, 21, 34};
    std::vector<ll> dp(W, 0);
    dp[0] = 1;
    for (int i = 0; i < H; i++) {
        std::vector<ll> tmp(W, 0);
        for (int i = 0; i < W; i++) {
            (tmp[i] += (t[i] * t[W - 1 - i] % MOD) * dp[i] % MOD) %= MOD;
            if (i != W - 1) {
                (tmp[i + 1] += (t[i] * t[W - 2 - i] % MOD) * dp[i] % MOD) %= MOD;
            }
            if (i != 0) {
                (tmp[i - 1] += (t[i - 1] * t[W - 1 - i] % MOD) * dp[i] % MOD) %= MOD;
            }
        }
        dp = tmp;
    }
    std::cout << dp[K] << std::endl;
    return 0;
}


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

const int INF = 200005;
int main() {
    int n;
    cin >> n;
    map<pair<int, int>, int> mp;
    for (int i = 1; i <= n; ++i) {
        int a, b;
        a = i;
        while (a/10 != 0) a /= 10;
        b = i % 10;
        mp[make_pair(a, b)]++;
    }
    long long ans = 0;
    for (auto i = mp.begin(); i != mp.end(); ++i) {
        ans += (long long)i->second * mp[make_pair(i->first.second, i->first.first)];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    int n;
    cin >> n;
    set<string> s ;
    rep0(i,n){
        string input ;
        cin >> input;
        s.insert(input);
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 19084
#include<bits/stdc++.h>
#define re register
#define rep(i,a,b) for(re int i=a,i##end=b; i<=i##end; i++)
#define drep(i,a,b) for(re int i=a,i##end=b; i>=i##end; i--)
#define repp(i,a,b) for(re int i=a,i##end=b; i<i##end; i++)
#define drepp(i,a,b) for(re int i=a,i##end=b; i>i##end; i--)
#define Erep(i,x) for(int i=head[x]; ~i; i=Edge[i].nxt)
#define ms(x,a) memset(x,a,sizeof x)
#define se second
#define fi first
#define lowbit(x) (x&-x)
#define debug(x) cerr<<#x<<" = "<<x<<endl
#define coint const int
typedef long long ll;
using namespace std;
template<class T>inline T rd(){
	static char ch;static bool neg;static T x;
	for(neg=0,ch=0; ch>'9'||ch<'0'; neg|=(ch=='-'),ch=getchar());
	for(x=0; ch<='9'&&ch>='0'; x=(x<<1)+(x<<3)+(ch-'0'),ch=getchar());
	return neg?-x:x;
}
template<class T>inline T Max(const T &x, const T &y){
	return x>y?x:y;
}
template<class T>inline T Min(const T &x, const T &y){
	return x<y?x:y;
}
coint N=1e5+5;
int A[N];
int n;

int main(){
	n=rd<int>();
	rep(i,1,n) A[i]=rd<int>();
	int sum=0,ans=0;
	rep(i,2,n){
		if(A[i]<=A[i-1]) sum++;
		else sum=0;
		ans=Max(ans,sum);
	}
	printf("%d\n",ans);	
	return 0;
}



Measured memory_bytes: 640
import java.util.*;

public class Main {
		public static void main(String[] args) {
			
			Scanner sc = new Scanner(System.in);
			
			int H = sc.nextInt();
			int A = sc.nextInt();
			
			int i = 0;
          
			while(H>0){
				H = H-A;
			    i++;
			}
			System.out.println(i);
		}
		}

Measured memory_bytes: 23124
import math
A, B = list(map(int,input().split()))
min1 = math.ceil(A / 0.08)
min2 = math.ceil(B / 0.1)
ans = max(min1, min2)

if int(ans * 0.08) == A and int(ans * 0.1) == B:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 38384
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	private static List<A> list = new ArrayList<>();

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int q = sc.nextInt();

		for (int i = 0; i < q; i++) {
			list.add(new A(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()));
		}
		sc.close();

		int max = search(0, n, 1, m, new ArrayList<>());
		System.out.println(max);

	}

	public static int search(int a, int n, int s, int e, List<Integer> l) {
		int max = 0;
		for (int i = s; i <= e; i++) {
			l.add(i);
			int sum = 0;
			if (a == n) {
				for (A la : list) {
					if (l.get(la.b) - l.get(la.a) == la.c) {
						sum += la.d;
					}
				}
			} else {
				sum = search(a + 1, n, i, e, l);
			}
			max = Math.max(max, sum);
			l.remove(l.size() - 1);
		}
		return max;
	}

	public static class A {
		public int a;
		public int b;
		public int c;
		public int d;

		public A() {

		}

		public A(int a, int b, int c, int d) {
			this.a = a;
			this.b = b;
			this.c = c;
			this.d = d;
		}
	}
}


Measured memory_bytes: 35392
#include<cstdio>
using namespace std;
char s[]={'R','Y','G','B'};
int h,w,d;
int main(){
    scanf("%d%d%d",&h,&w,&d);
    for (int i=1;i<=h;++i){
        for (int j=1;j<=w;++j){
            int x=i+j+w,y=i-j+w;
            printf("%c",s[((x/d)&1)*2+((y/d)&1)]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 384
import java.util.*;
import 	java.math.*;

public class Main{
	public static void main(String[] args){
    	Scanner s=new Scanner(System.in);	
      int n=s.nextInt();
      int d=s.nextInt();
      int[][] arr=new int[n][d];
      for(int i=0;i<n;i++){
      	for(int j =0;j<d;j++){
        	arr[i][j]=s.nextInt();
        }
      }
      int count=0;
      for(int i=0;i<n;i++){
      	for(int j=i+1;j<n;j++){
        	double squares=0.0;
          	for(int k=0;k<d;k++){
            	squares+=(arr[i][k]-arr[j][k])*(arr[i][k]-arr[j][k]);
            }
          double value=Math.sqrt(squares);
          if(value-(int)value==0.0)count++;
        }
      }
      System.out.println(count);
    }
}

Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{
   
   
    string s, t;
    cin >> s >> t;
    int ans = 99999999;
    for (int i = 0; i <= s.size() - t.size(); i++) {
        int a = 0;
        for (int j = 0; j < t.size(); j++) {
            if (s[i+j] != t[j])a++;
        }
      
        ans = min(a, ans);
    }

    cout << ans << endl;
   
    return 0;

}

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

unsigned long long c[21], d[21];

int main() {

  int n, x;
  scanf("%d", &n);
  scanf("%d", &x);
  rep (i,21) { c[i] = d[i] = 0; }
  c[x] = 1;
  rep (i, n-2) {
    int x; scanf("%d", &x);
    rep (k, 21) {
      if (k-x >= 0) d[k - x] += c[k];
      if (k+x < 21) d[k + x] += c[k];
    }
    rep (k, 21) { c[k] = d[k]; d[k] = 0; }
  }

  {
    int x; scanf("%d", &x);
    printf("%Ld\n", c[x]);
  }

  return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> ans(n);

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

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

	for(int i=0;i<n;i++){
		cout << ans[i] << endl;
	}
}

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

int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n], minimum[n];
    for(int i=0; i<n; ++i)
    {
        cin>>arr[i];
        minimum[i] = 1000000000;
    }
    minimum[0] = 0;
    for(int i=1; i<n; ++i)
    {
        for(int j=i-1; j>=max(0,i-k); --j)
        {
            minimum[i] = min(minimum[i], minimum[j] + abs(arr[i] - arr[j]));
        }
    }
    cout<<minimum[n-1];
    return 0;
}


Measured memory_bytes: 1024
N,K = map(int,input().split())
A = list(map(int,input().split()))
if K==1:
    print(0)
    exit()

ans = 10**12
for b in range(1<<(N-1)):
    h = A[0]
    k = 1
    cost = 0
    for i in range(N-1):
        a = A[i+1]
        if a > h:
            k += 1
            h = a
        elif b&(1<<i):
            k += 1
            cost += h+1 - a
            h += 1
    if k >= K:
        ans = min(ans, cost)
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main (){
    int *m,n[4];

    for(m=n;m<n+4;m++)
        scanf("%d",m);
    m=n;
    if(n[1]<=n[2]||n[3]<=n[0])  printf("0\n");
        else if(n[0]>=n[2]&&n[1]<=n[3]) printf("%d\n",*(m+1)-*m);
            else if(n[0]<=n[2]&&n[1]>=n[3]) printf("%d\n",*(m+3)-*(m+2));
                else if(n[0]>=n[2]&&n[1]>=n[3]) printf("%d\n",*(m+3)-*m);
                    else  printf("%d\n",*(m+1)-*(m+2));
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>

int n, k;
long long a[1010];
int main()
{
    std::cin >> n >> k;
    for (int i = 0; i < n; ++i)
        std::cin >> a[i];

    std::vector<long long> data;
    long long sum;
    for (int i = 0; i < n; ++i)
    {
        sum = 0;
        for (int j = i; j < n; ++j)
        {
            sum += a[j];
            data.emplace_back(sum);
        }
    }

    long long ans = 0;
    int count;
    for (int i = 40; i > 0; --i)
    {
        count = 0;
        const long long tmp = ans | (1LL << (i - 1));
        for (size_t j = 0, end = data.size(); j < end; ++j)
        {
            if ((tmp & data[j]) == tmp)
                ++count;
        }
        if (count >= k)
            ans |= tmp;
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 6256
#include <iostream>
#include <cstdio>
#include <set>
using namespace std;

int n, q, t, l, r, ans;
string s;
char c;
set<int> st[30];
int main() {
	int i, j;
	cin >> n >> s >> q;
	for(i=0; s[i]; i++) st[s[i]-97].insert(i);
	while(q--) {
		cin >> t;
		if(t==1) {
			cin >> l >> c;
			l--;
			st[s[l]-97].erase(l);
			s[l] = c;
			st[s[l]-97].insert(l);
		} else {
			cin >> l >> r;
			l--; r--;
			ans = 0;
			for(j=0; j<26; j++) {
				if(*st[j].lower_bound(l)<=r && st[j].lower_bound(l)!=st[j].end()) ans++;
			}
			cout << ans << endl;
		}
	}
	return 0;
}

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

//足し算引き算の問題

int main(){
	int total;
	int cost;
	int totalCost;

	while(cin >> total, total){
		totalCost = 0;
		for(int i=0; i < 9; i++){
			cin >> cost;
			totalCost += cost;
		}
		total -= totalCost;

		cout << total << endl;
	}
}

Measured memory_bytes: 1160
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;

#define INF ( 1 << 30 )
typedef multimap<int,int>::iterator itr;

int main()
{
  int N, Q;
  int stmp[1000000], comp[1000000], a;
  char buff[1024];
  scanf( "%d %d", &N, &Q);
  for(int i = 0 ; i < N ; i++ ){
    scanf( "%d", &stmp[i]);
    comp[i] = stmp[i];
  }
  sort( comp, comp + N);

  multimap< int , int > sym;
  while(Q--){
    scanf("%s %d", buff, &a);
    if(*buff == 'A'){ //ADD

      sym.insert(make_pair(stmp[a - 1] , a - 1));

    } else if(*buff == 'R'){ //REMOVE
      try{
        sym.erase( sym.lower_bound( stmp[a - 1]));
      }catch( ... ){}
    } else { //CHECK

      int left = 0, right = INF;
      while(left != right){
        int center = ( left + right ) / 2;
        int pre = 0, BAN = 0;
        for(itr it = sym.begin() ; it != sym.end() ; it++ ){
          int p = distance( comp,lower_bound( comp, comp + N, (*it).first - center));
          BAN += max( p - pre, 0);
          pre = distance( comp, upper_bound( comp, comp + N, (*it).first));
        }
        BAN += max( N - pre, 0);
        if(BAN <= a) right = center;
        else left = center + 1;
      }
      if( left != INF) printf("%d\n", left);
      else puts("NA");

    }
  }
  return false;
}

Measured memory_bytes: 8884
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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



int main(){
	int n;
	cin >> n;
   
    if(n >= 64)P(64);
    else if(n >= 32)P(32);
    else if(n >= 16)P(16);
    else if(n >= 8)P(8);
    else if(n >= 4)P(4);
    else if(n >= 2)P(2);
    else if(n >= 1)P(1);
    
	return  0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

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

	a := strings.Split(s, "")
	if strings.Join(a[:n/2], "") == strings.Join(a[n/2:], "") {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

int main() {
    double m,n;
    cin>>n>>m;
    double all=0;
    vll a(n);
    rep(i,n){
        cin>>a.at(i);
        all+=a.at(i);
    }
    sort(all(a));
    reverse(all(a));
    if(a.at(m-1)>=(0.25/m)*all){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

int main() {
    ull n,gr=1,pr=1,x=26;
    char c;
    stack<char> st;
    cin>>n;
    if(n<=x){
        cout<<char(n-1+'a');
        return 0;
    }
    while(x<n){
        pr=x+1;
        gr++;
        x=x*26+26;
      //  cout<<pr<<" "<<x<<endl;
    }
    n=n-pr;
    while(n!=0){
        c=char(n%26+'a');
        st.push(c);
        n=n/26;
        gr--;
    }
    for(int i=1;i<=gr;i++){
        cout<<'a';
    }
    while(!st.empty()){
        cout<<st.top();
        st.pop();
    }
    return 0;
}

Measured memory_bytes: 3628