akhauriyash/Code-Regression huggingface dataset:
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  h, a = map(int, readline().split())
  print(ceil(h/a))
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5076
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int an,dp[SIZE];
int main(){
    int N;
    R(N);
    FOR(i,1,N){
        int x;
        R(x);
        an=max(an,dp[x-1]+1);
        dp[x]=dp[x-1]+1;
    }
    W(N-an);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N, X;
    cin >> N >> X;
    int L[N];
    for(int i = 0; i < N; i++) cin >> L[i];

    int sum = 0, ans = 0;
    for(int i = 0; i < N; i++) {
        if(sum <= X) ans++;
        sum += L[i];
    }
    if(sum <= X) ans++;
    cout << ans << "\n";
    return 0;
}

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


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

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
#else
#define print(...)
#endif


int main(void){

    ll n,k,ans;

    cin >> n >> k;

    ans = 0;
    for(ll i=k-1; i<=n; i++){
        ll min_i = (i*(i+1)/2);
        ll max_i = ((i+1)*(2*n-i)/2);
        ans = (ans + (max_i - min_i + 1))%MOD;
        //print(i, ":", min_i, max_i, ans); 
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>

main(){
    int N;
    scanf("%d",&N);
    char W[200][20];
    scanf("%s",W[0]);
    char check=W[0][strlen(W[0])-1];

    for (int i = 1; i < N; ++i){
        scanf("%s",W[i]);
        if(check!=W[i][0]){
            printf("No");
            return 0;
        } else {
            check=W[i][strlen(W[i])-1];
        }
    }

    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            if(!strcmp(W[i],W[j])){
                printf("No");
                return 0;
            }
        }
    }

    printf("Yes");
}


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

int n, a, o;

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
  	cin >> a; 
    o += (a & 1);
  }
  cout << (o & 1? "NO": "YES") << '\n';
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int width, height, point_x, point_y, r;
    width = Integer.parseInt(sc.next());
    height = Integer.parseInt(sc.next());
    point_x = Integer.parseInt(sc.next());
    point_y = Integer.parseInt(sc.next());
    r = Integer.parseInt(sc.next());
    if((0 <= point_x - r && point_x + r <= width) && (0 <= point_y - r && point_y + r <= height)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    X -= A.at(i);
    if (X < 0) break;
    cnt++;
  }

  cout << ((X > 0) ? cnt - 1 : cnt) << "\n";
}

Measured memory_bytes: 256
import math
import os
import sys
from decimal import Decimal

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

A, B, X = list(map(Decimal, sys.stdin.readline().split()))

# 平面にする
X /= A
if X <= A * B / 2:
    # 半分より小さい
    ans = math.atan2(B, X * 2 / B) / math.pi * 180
    print(ans)
else:
    X = A * B - X
    ans = math.atan2(X * 2 / A, A) / math.pi * 180
    print(ans)


Measured memory_bytes: 5076
#include<stdio.h>

int main(){
  int x,y,n,d;
  
  scanf("%d%d",&x,&y);
  
  if(x==y){
      printf("%d\n",x);
      return 0;
  }else if(x>y){
    n=y;
  }else{
    n=x;
  }


  
  for(d=n/2;d>0;d--){
    if(x%d==0&&y%d==0){
      printf("%d\n",d);
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 2084
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

from functools import lru_cache

def F(N):
    if N < 10:
        return N
    q, r = divmod(N, 10)
    x1 = F(q) + r
    x2 = F(q-1) + 9
    return max(x1, x2)
ans = F(int(input()))
print(ans)

Measured memory_bytes: 9496
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}
int comb(int n, int k) {
	k = min(k, n - k);
	int x = 1, y = 1;
	rep(i, k) {
		y *= i + 1;
		y %= MOD;
	}
	for (int i = n - k + 1; i <= n; i++) {
		x *= i;
		x %= MOD;
	}
	return x * modinv(y, MOD) % MOD;
}

signed main() {
	int n, c;
	int x[100005], v[100005];
	cin >> n >> c;
	rep(i, n) cin >> x[i] >> v[i];

	P lsum[100005];
	P rsum[100005];
	lsum[0] = { 0,0 };
	rep(i, n) lsum[i + 1] = { x[i],lsum[i].second + v[i] };
	rsum[n] = { 0,0 };
	for (int i = n - 1; i >= 0; i--) {
		rsum[i] = { c - x[i],rsum[i + 1].second + v[i] };
	}

	/*rep(i, n + 1) {
		cout << lsum[i].first << " " << lsum[i].second << endl;
	}
	cout << endl;
	rep(i, n + 1) {
		cout << rsum[i].first << " " << rsum[i].second << endl;
	}
	cout << endl;*/

	int ans = 0;
	/*rep(i, n + 1) {
		ans = max(ans, lsum[i].second - lsum[i].first);
		ans = max(ans, rsum[i].second - rsum[i].first);
	}*/
	int nowma = 0;
	rep(i, n + 1) {
		nowma = max(nowma, lsum[i].second - lsum[i].first * 2);
		ans = max(ans, nowma + (rsum[i].second - rsum[i].first));
	}
	nowma = 0;
	for (int i = n; i >= 0; i--) {
		nowma = max(nowma, rsum[i].second - rsum[i].first * 2);
		ans = max(ans, nowma + (lsum[i].second - lsum[i].first));
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4992
#include<cstdio>
int n, m, w[101000], a, b;
int main(){
    int i;
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d%d",&a,&b);
        w[a]^=1,w[b]^=1;
    }
    for(i=1;i<=n;i++)if(w[i]){printf("NO\n");return 0;}
    printf("YES\n");
}


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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;


int main(){
  while(1) {
    string x; cin >> x;
    if (x == "0") break;
    ll r=0;
    rep(i, x.size()) {
      r += x[i] - '0';
    }
    cout << r << endl; 
  }
}



Measured memory_bytes: 3216
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll a, b ; cin >> a >> b ;
  cout << ((a+b) % 24) << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

#define int long long
#define endl '\n'
#define eps  1e-9
const double pi=acos(-1);
const int mod=1e9+7;
//____________________

int dp[50];
int a[100002];
int n,k;

int32_t main()
{ 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);  
  int x=0LL;
  cin>>n>>k;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    for(int j=0;j<41;j++)
    {
        if(a[i]&(1LL<<j))
            dp[j]++;
    }
  }

  for(int i=40;i>=0;i--)
  {
    if(dp[i]<=n/2 and (x|(1LL<<i))<=k)
        x|=(1LL<<i);
  }
  int sum=0;
  for(int i=0;i<n;i++)
    sum+=(a[i]^x);

  cout<<sum;

 return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n;
  string s;
  cin >> n >> s;
  rep(i, s.size()) {
    s[i] += n;
    if (s[i] > 'Z') s[i] -= 26;
  }

  cout << s << endl;
  return 0;
}


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

using namespace std;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int a[100000];
bool used[100000];
bool used_root[1400000];

int main(){
    long n, m, q;
    cin >> n >> m >> q;
    for(int i = 0; i < q; i++) {
        cin >> a[i];
        used[a[i]] = true;
    }
    int M;
    if(m%7 != 0) M =  min(7*m, 7*n);
    else  M =  min(m, 7*n);
    UnionFind uf(2*M);
    for(int i = 0; i < M; i++){
        if(used[i%m]) continue;
        if(i%7 != 6){
            if(!used[(i+1)%m]) uf.unionSet(i, i+1);
        }
        if(i+7 < M){
            if(!used[(i+7)%m]) uf.unionSet(i, i+7);
        }
    }
    long cnt = 0;
    for(int i = 0; i < M; i++){
        if(!used[i%m]){
            int r = uf.root(i);
            //cout << r << endl;
            if(!used_root[r]){
                cnt++;
                used_root[r] = true;
            }
        }
    }
    //cout << M << endl;
    //cout << cnt << endl;

    for(int i = 0; i < 2*M; i++){
        if(used[i%m]) continue;
        if(i%7 != 6){
            if(!used[(i+1)%m]) uf.unionSet(i, i+1);
        }
        if(i+7 < 2*M){
            //cout << i << ' ' << i+7 << endl;
            if(!used[(i+7)%m]) uf.unionSet(i, i+7);
        }
    }

    long cnt_ = 0;
    for(int i = 0; i < 2*M; i++){
        used_root[i] = false;
    }
    for(int i = 0; i < 2*M; i++){
        if(!used[i%m]){
            int r = uf.root(i);
            //cout << r << endl;
            if(!used_root[r]){
                cnt_++;
                used_root[r] = true;
            }
        }
    }
    cnt_ -= cnt;
    //cout << cnt << endl;
    //cout << cnt_ << endl;
    long s = (7*n)/M;
    //cout << s << endl;
    long ans = cnt+cnt_*(s-1);
    cout << ans << endl;
}

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

string a, b;
int res=0;
int main() {
	cin >> a >> b;
        for(int i=0; i<a.length(); i++) {
                if(a[i]!=b[i]) res++;
        }
        printf("%d", res);
        return 0;
}


Measured memory_bytes: 3844
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
using namespace std;

const long long MOD = 1000000007;

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

    cout << n%k << endl;
    
    return 0;
}


Measured memory_bytes: 888
#pragma GCC optimize("Ofast",3,"inline")
#include <bits/stdc++.h>
using namespace std;
map<char ,bool> odd;
map<char ,bool> even;
int main(){
	ios_base::sync_with_stdio(false);
	odd['R']=1;
	odd['U']=1;
	odd['D']=1;
	even['L']=1;
	even['U']=1;
	even['D']=1;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i+=2){
		if(!odd[s[i]]){
			cout<<"No";
			return 0;
		}
	}
	for(int i=1;i<s.size();i+=2){
		if(!even[s[i]]){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 256
longstr = " "
str = " " + gets.chomp.upcase + " "
while true
    d = gets.chomp
    break if d == "END_OF_TEXT"
    longstr += d + " "
end
longstr = longstr.upcase

c = 0
i = -(str.length-2)
while true
    i = longstr.index(str, i+(str.length-2))
    break if i == nil
    c += 1
end

puts c

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

int main() {
  int x,y;
  while(1){
    cin>>x>>y;
    if(x==0 && y==0)
      break;
    if(x>y){
      swap (x,y);
      
    }
    cout<<x<<' '<<y<<endl;
  }
  
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define INF 100005

int main()
{
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    int n,l;
    cin >> n >> l;
    vector<string>a;
    for(int i=0;i<n;i++)
    {
    	string aa;
    	cin >> aa;
    	a.push_back(aa);
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++)
    {
    	cout << a[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std ;

int N , ans ;

int main(){
	scanf( "%d" , &N ) ;
	for( int i = 1 , x ; i <= N ; i ++ ){
		scanf( "%d" , &x ) ;
		while( !( x&1 ) ) x >>= 1 , ans ++ ;
	} printf( "%d" , ans ) ;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define F first
#define S second
#define int long long
#define lint long long
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5 + 5, MOD1 = 1e9 + 7, MOD2 = 998244353;
const lint INF = 1e18;

signed main()
{
    int n;
    cin >> n;
    n%=10;
    if(n==3)
    {
        cout << "bon";
    }
    else if(n<=1 || n==6 || n==8)
    {
        cout << "pon";
    }
    else
    {
        cout << "hon";
    }
}

Measured memory_bytes: 3636
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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; }





void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    int happiness = 0;
    const int hapi_500 = 1000;
    const int hapi_005 = 5;
    happiness += n/500 * hapi_500;
    happiness += (n-n/500*500)/5 * hapi_005;
    
    cout << happiness << endl;
    
    
}



signed main() {
    solve();
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef long long ull;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = ll(b)-1; i >= (a); i--)
#define MAPIT(i,c,k) for (auto i = (c).equal_range((k)).first; i!= (c).equal_range((k)).second; i++)

#define sz(c) ll((c).size())
#define all(c) (c).begin(), (c).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define xx first
#define yy second
#define has(c, i) ((c).find(i) != (c).end())
#define DBG(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })


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

	string x;
	cin >> x;

	int c = 0;

	FOR(i, 1, sz(x)){
		if(x[i] != x[i-1]){
			c++;
		}
	}
	cout << c << endl;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> city(m + 1);
    vector<vector<int>> prefec(n + 1);
    for (auto i = 1; i < m + 1; i++)
    {
        int p, y;
        cin >> p >> y;
        city[i].first = p;
        city[i].second = y;
        prefec[p].push_back(y);
    }

    for (auto i = 1; i < n + 1; i++)
    {
        sort(prefec[i].begin(), prefec[i].end());
    }

    for (auto i = 1; i < m + 1; i++)
    {
        string pre_num = to_string(city[i].first);
        while (pre_num.size() < 6)
        {
            pre_num = "0" + pre_num;
        }

        int perm = lower_bound(prefec[city[i].first].begin(), prefec[city[i].first].end(), city[i].second) - prefec[city[i].first].begin() + 1;
        string perm_num = to_string(perm);
        while (perm_num.size() < 6)
        {
            perm_num = "0" + perm_num;
        }
        cout << pre_num + perm_num << endl;
    }
}

Measured memory_bytes: 7808
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
vector<vector<char> > phone = {
    {},
    {' ', '.', ',', '!', '?'},
    {'c', 'a', 'b'},
    {'f', 'd', 'e'},
    {'i', 'g', 'h'},
    {'l', 'j', 'k'},
    {'o', 'm', 'n'},
    {'s', 'p', 'q', 'r'},
    {'v', 't', 'u'},
    {'z', 'w', 'x', 'y'}
};

int main() {
    int n; cin >> n;
    string s;
    for (int i = 0; i < n; i++) {
        cin >> s;
        int k = 0, kl = 0;
        for (char c : s) {
            if (c - '0' == 0) {
                if (kl == 0) continue;
                cout << phone[kl][k];
                k = 0;
                kl = 0;
            } else {
                kl = c - '0';
                k = (k+1) % phone[kl].size();
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define rep(i, a, b) for(int i = a; i < b; ++i)

int n, d, ans, x, y;
main() {
    cin >> n >> d;
    ans = 0;
    rep(i, 0, n) {
        cin >> x >> y;
        if (x * x + y * y <= d * d) {
            ans++;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;
ll dp[200][100 * 100 + 100];

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

  cin >> n;
  rep(i, n) { cin >> a[i]; }
  bitset<100 * 100 + 100> dp;
  dp[0] = true;
  rep(i, n) { dp |= dp << a[i]; }
  rrrep(i, 100 * 100, 0) {
    ans = i;
    if (ans % 10 == 0 || dp[i] == 0) continue;
    Cout(ans);
    return 0;
  }
  Cout(0);
  return 0;
}

Measured memory_bytes: 2304
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<utility>
#include<map>
#include<stack>
#include<cmath>
using namespace std;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define LARGE 1000000000
#define MOD 100000

int N, M, sum;
int aim[100009], dis[100009];
 
int main() {
	dis[0] = 0;
	cin >> N >> M;
	if (N >= M)sum = 0;
	else {
		for (int i = 0; i < M; i++) cin >> aim[i];
		sort(aim, aim + M);
		for (int i = 1; i < M; i++) dis[i] = aim[i] - aim[i - 1];
		sort(dis, dis + M);
		sum = aim[M - 1] - aim[0];
		for (int i = 0; i < N - 1; i++) sum -= dis[M - 1 - i];
	}
	cout << sum << endl;
	return 0;
}

//チーズ
/*
int H, W, N, ans, tag, si, sj;
char MAP[1009][1009];
int dp[1009][1009];

bool inmap(int i, int j) {
return ((i >= 0 && i <= H - 1) && (j >= 0 && j <= W - 1));
}
bool pass(int i, int j) {
return (MAP[i][j] != 'X');
}

int DFS(int i, int j) {
if (dp[i][j] != LARGE)return dp[i][j];
if (MAP[i][j] - '0' == tag) {
si = i; sj = j;
return 0;
}

if (inmap(i + 1, j) && pass(i + 1, j)) dp[i][j] = min(dp[i][j], DFS(i + 1, j) + 1);
if (inmap(i - 1, j) && pass(i - 1, j)) dp[i][j] = min(dp[i][j], DFS(i - 1, j) + 1);
if (inmap(i, j + 1) && pass(i, j + 1)) dp[i][j] = min(dp[i][j], DFS(i, j + 1) + 1);
if (inmap(i, j - 1) && pass(i, j - 1)) dp[i][j] = min(dp[i][j], DFS(i, j - 1) + 1);
cout << i << " " << j << " " << dp[i][j] << endl;
return dp[i][j];
}

int main() {
cin >> H >> W >> N;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
cin >> MAP[i][j];
if (MAP[i][j] == 'S') {
si = i; sj = j;
}
}
}

for (int i = 1; i <= N; i++) {
cout << i << " " << si << " " << sj << endl << endl;
for (int j = 0; j < H; j++) {
for (int k = 0; k < W; k++) {
dp[j][k] = LARGE;
}
}
tag = i;
ans += DFS(si, sj);

}

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


Measured memory_bytes: 1024
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.size();
    string prev, str;
    int ans = 0;
    for(int i = 0; i < n; i++){
        str += s[i];
        if(prev != str){
            prev = str;
            ans++;
            str = "";
        }
    }
    cout << ans << '\n';
}


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

int main(){
    ll n,m;
    cin>>n>>m;
    vector<string> a(n),b(m);
    rep(i,n) cin>>a[i];
    rep(i,m) cin>>b[i];
    for(ll i=0;i+m<=n;i++){
        for(ll j=0;j+m<=n;j++){
            bool flag=0;
            rep(k,m){
                rep(l,m){
                    if(b[k][l]!=a[i+k][j+l]){
                        flag=1;
                        break;
                    }
                }
                if(flag) break;
            }
            if(!flag){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 	int N,T,cnt,c,bc=0;
  	
  	cin>>N>>T;
  
  	for(int k=0;k<N;k++){
	  	cin>>c;
  		if(c-bc<T)cnt+=(c-bc);
   		else if(c-bc>=T) cnt+=T; 
		bc=c;
    }
	cout<<cnt+T<<endl;
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)

int n;
vector<int> sosuu;
int cnt = 0;

int main(){
  cin >> n;
  sosuu.push_back(2);
  FOR(i,3,100){
    bool flag = true;
    REP(j,sosuu.size()){
      if(i%sosuu[j]==0) flag = false;
    }
    if(flag) sosuu.push_back(i);
  }
  for(int i = 1;i<=n;i+=2){
    map<int,int> mp;
    int num = i;
    REP(j,sosuu.size()){
      while(num%sosuu[j]==0){
        if(mp.find(j)==mp.end()) mp[j] = 1;
        else mp[j]++;
        num /= sosuu[j];
      }
    }
    int tmp = 1;
    for(auto itr = mp.begin();itr!=mp.end();++itr){
      tmp *= itr->second+1;
    }
    if(tmp == 8){
      cnt++;
      //cout << i <<endl;
    }
  }
  cout << cnt <<endl;
}


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

#define M 1050011
#define L 14

char H[M][L];

long long h1(long long k){
  return k % M;
}

long long h2(long long k){
  return 1 + (k % (M - 1));
}

long long h(long long k, long long i){
  return (h1(k) + i * h2(k)) % M;
}

int getChar(char ch){
if ( ch == 'A') return 1;
else if ( ch == 'C') return 2;
else if ( ch == 'G') return 3;
else if ( ch == 'T') return 4;
return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int find(char str[]){
  long long key, i, id;

  key = getKey(str);
  i = 0;

  while(true){
    id = h(key, i);
    if(strcmp(H[id], str) == 0) return 1;
    else if(strlen(H[id]) == 0) return 0;
    i++;
  }
  return 0;
}

int insert(char str[]){
  long long key, i, id;

  key = getKey(str);
  i = 0;

  while(true){
    id = h(key, i);
    if(strcmp(H[id], str) == 0) return 1;
    else if(strlen(H[id]) == 0){
      strcpy(H[id], str);
      return 0;
    }
    i++;
  }
  return 0;
}

int main(){

  int n;
  char str[L], command[10];

  for (int i = 0; i < M; i++ ) H[i][0] = '\0';

  scanf("%d", &n);
  for(int i = 0;i < n;i++){
    scanf("%s %s", command, str);

    if(command[0] == 'i') insert(str);
    else{
      if(find(str)) printf("yes\n");
      else printf("no\n");
    }
  }


  return 0;
}




Measured memory_bytes: 17520
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
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;}

int main(){
	ll int d1,d2;
	int data[10];
	REP(i,10){
		cin >> data[i];
	}
	sort(data,data+10,greater<int>());
	d1 = data[0] + data[1] + data[2];
	REP(i,10){
		cin >> data[i];
	}
	sort(data,data+10,greater<int>());
	d2 = data[0] + data[1] + data[2];
	cout << d1 << " " << d2 << endl;
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
const ll MOD = 1e9+7;

//単位行列
//m...行。m!=nの場合は途切れる
mat E(int m,int n)
{
	mat ret=mat(m,vector<ll>(n));
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i==j)
				ret[i][j]=1;
			else
				ret[i][j]=0;
		}
	}
	return ret;
}
//デバッグ表示
//標準出力なので注意！！！
void debug_err(mat &x)
{
	cout<<"+++matrix log begin+++"<<endl;
	for(int i=0;i<x.size();i++)
	{
		for(int j=0;j<x[i].size();j++)
			cout<<x[i][j]<<" ";
		cout<<endl;
	}
	cout<<"+++matrix log end+++"<<endl;
	return;
}
//足し算
mat operator +(const mat &a,const mat &b)
{
	mat ret=a;
	assert(a.size()==b.size() && a[0].size()==b[0].size());
	for(int i=0;i<ret.size();i++)
	{
		for(int j=0;j<ret[i].size();j++)
			ret[i][j]+=b[i][j];
	}
	return ret;
}
//スカラ積
mat operator *(const ll &a,const mat &x)
{
	mat ret=x;
	for(int i=0;i<ret.size();i++)
	{
		for(int j=0;j<ret[i].size();j++)
			ret[i][j]*=a;
	}
	return ret;
}
//行列積
mat operator *(const mat &a,const mat &b)
{
	mat ret(a.size(),vector<ll>(b[0].size()));
	assert(a[0].size()==b.size());
	for(int i=0;i<a.size();i++)
	{
		for(int k=0;k<b.size();k++)
		{
			for(int j=0;j<b[0].size();j++)
			{
				ret[i][j]=ret[i][j]+a[i][k]*b[k][j];
				ret[i][j]%=MOD;
			}
		}
	}
	return ret;
}

//繰り返し2乗法
mat kuri2(mat &x,ll a)
{
	mat ret=E(x.size(),x[0].size());
	mat tmp=x;
	while(a>0)
	{
		if(a&1LL)
			ret=ret*tmp;
		tmp=tmp*tmp;
		a>>=1LL;
	}
	return ret;
}

int main()
{
	int n;ll k;
	cin>>n>>k;
	mat a=mat(n,vector<ll>(n));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	}
	a=kuri2(a,k);
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			ans+=a[i][j];
			ans%=MOD;
		}
	}
	if(ans<0)
		ans+=MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
# coding: utf-8
# Your code here!

a,b=input().split()
b=list(b)
if a=="0" or b=="0":
    print(0)
else:
    b.remove('.')
    b=''.join(b)
    a=int(a)
    b=int(b)
    c=str(a*b)
    if a*b<100:
        print(0)
    else:
        c=list(c)
        del c[-1]
        del c[-1]
        c=''.join(c)
        print(c)


Measured memory_bytes: 9112
def main():
    w, h, n = map(int, input().split())

    x_min = 0
    x_max = w
    y_min = 0
    y_max = h

    for _ in range(n):
        x, y, a = map(int, input().split())
        if a == 1:
            x_min = max(x_min, x)
        elif a == 2:
            x_max = min(x_max, x)
        elif a == 3:
            y_min = max(y_min, y)
        else:
            y_max = min(y_max, y)

    print(
        (x_max - x_min) * (y_max - y_min)
        if x_min < x_max and y_min < y_max else 0
    )


if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    double n,m,d;cin>>n>>m>>d;
    double ans=2*(m-1)*((n-d)/(n*n));
    if(d==0)ans/=2;
    cout<<setprecision(12)<<ans<<endl;
    return 0;
}




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

int main(void)
{
  int k, a, b;
  cin >> a >> b >> k;
  int cnt = 0;
  int res = 0;
  for(int i = min(a, b); 0 < i; i--)
  {
    if(a % i == 0 && b % i == 0)
    {
      //cout << i << ":" << endl;
      cnt++;
    }
    if(cnt == k)
    {
      res = i;
      break;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]

AB.sort(key=lambda x: [x[1], x[0]])

now = 0
for ab in AB:
    a, b = ab
    if now + a <= b:
        now += a
        continue
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 102664
import sys

debug_mode = True if len(sys.argv) > 1 and sys.argv[1] == "-d" else False
if debug_mode:
    import os
    inf = open(os.path.basename(__file__).replace(".py", ".in"))

    def input():
        return inf.readline()
else:
    inf = sys.stdin

# ==============================================================

def solve():
    abc = input()
    if abc.count("7") == 1 and abc.count("5") == 2:
        print("YES")
    else:
        print("NO")


solve()

# ==============================================================

if debug_mode:
    inf.close()


Measured memory_bytes: 2940
#include <iostream>
#include <vector> 
#include <algorithm>
#include <map>
using namespace std;
 
// ref: http://drken1215.hatenablog.com/entry/2018/09/23/232100
int main() {
  string S, T;
  cin >> S >> T;
  bool ok = true;
  map<char,char> s_map, t_map;
  for (int i = 0; i < S.size(); i++) {
    char s = S[i], t = T[i];
    // m.count()の戻り値が0に等しければキーが存在しない、1に等しければキーが存在する
    if (s_map.count(s)) if (s_map[s] != t) { 
      ok = false;
      break;
    }
    if (t_map.count(t)) if (t_map[t] != s) {
      ok = false;
      break;
    }
    s_map[s] = t; t_map[t] = s;
  }
  if (ok) puts("Yes");
  else puts("No");
}

/**
 * 嘘解法
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  string S,T; cin>>S>>T;
  // int型のvectorを要素数26, 値0で初期化
  vector<int> c1(26,0), c2(26,0);
  for(int i = 0; i<S.length(); i++ ) c1[S[i]-'a']++;
  for(int i = 0; i<T.length(); i++ ) c2[T[i]-'a']++;
  sort(c1.begin(), c1.end());
  sort(c2.begin(), c2.end());
  if( c1 == c2 ) cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}
*/

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

using namespace std;

int main(){
	int n,l;
	cin >> n >> l;
	vector<string> v(n);
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	sort(v.begin(),v.end());
	for(int unsigned i = 0;i<n;i++){
		cout << v[i];
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main(){
	pair<int,int> hiduke;
	string table[12][31];
	string day[] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int dayCounter = 3;


	for(int i = 0; i < 12; i++){
		if(i == 1){
			for(int j = 0; j < 29; j++){
				table[i][j] = day[dayCounter++];
				if(dayCounter % 7 == 0){
					dayCounter = 0;
				}
			}
		}
		else if(i == 3 || i == 5 || i == 8 || i == 10){
			for(int j = 0; j < 30; j++){
				table[i][j] = day[dayCounter++];
				if(dayCounter % 7 == 0){
					dayCounter = 0;
				}
			}
		}
		else{
			for(int j = 0; j < 31; j++){
				table[i][j] = day[dayCounter++];
				if(dayCounter % 7 == 0){
					dayCounter = 0;
				}
			}
		}
	}



	while(cin >> hiduke.first >> hiduke.second && hiduke.first != 0){
		cout << table[hiduke.first - 1][hiduke.second - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
N = int(input())
S = input()

l = 0
r = 0
for i in range(N):
    if S[i] == '(':
        r += 1
    else:
        if r > 0:
            r -= 1
        else:
            l += 1
ans = '('*l + S + ')'*r
print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    akari<int> as(n);
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> as[i];
        sum += as[i];
    }
    i64 ans = 1e15;
    for (int d = 0; d < 2; d++)
    {
        int x = sum / n + d;
        i64 tmp = 0;
        for (int a : as)
        {
            tmp += (x - a) * (x - a);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

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


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

using namespace std;

typedef long long ll;

bool p[111];
int c[111];
vector<int> v;

int main(void){

int i,j,n,m,x,k;
ll ans=0ll;
cin>>n;
fill(p,p+111,true);
fill(c,c+111,0);
p[1]=false;

for(i=2; i<=n; ++i){
if(!p[i]){
continue;
}
j=i*2;
while(j<=n){
p[j]=false;
j+=i;
}
v.push_back(i);
}
m=v.size();
for(i=1;i<=n;++i){
for(j=0;j<m;++j){
x=i;
while(!(x%v[j])){
++c[j];
x /= v[j];
}
}
}

for(i=0; i<m; ++i){
if(c[i]>=74){
++ans;
}
}

for(i=0; i<m; ++i){
for(j=(i+1); j<m; ++j){
for(k=2; k<75; ++k){
if(75%k){continue;}
if(c[i]>=(k-1) && c[j]>=(75/k-1)){
++ans;
}
}
}
}

for(i=0; i<m; ++i){
for(j=(i+1); j<m; ++j){
for(k=0; k<m; ++k){
if(i==k || j==k){
continue;
}
if(c[i]>=4&&c[j]>=4&&c[k]>=2){
++ans;
}
}
}
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
sa = gets.chomp.split('')
sb = gets.chomp.split('')
sc = gets.chomp.split('')

hands = { 'a' => sa, 'b' => sb, 'c' => sc }

top = hands['a'].shift
while true
  p = hands[top]
  if p.empty?
    puts top.upcase
    break
  else
    top = hands[top].shift
  end  
end

Measured memory_bytes: 1788
N = int(input())
S = []
for i in range(N):
  Si = str(input())
  S.append(Si) 
  
M = int(input())
T = []
for i in range(M):
  Ti = str(input())
  T.append(Ti)

max_point = 0
for i in range(N):
  point = len([1 for s in S if s==S[i]]) - len([1 for t in T if t==S[i]])
  max_point = max([max_point,point])
  
print(max_point)

Measured memory_bytes: 3064
def main():
    N = int(input())
    L = list(map(int, input().split()))

    s1, s2 = 0,sum(L)
    ans = sum(L)

    for i in range(N):
        s1 += L[i]
        s2 -= L[i]
        ans = min(ans, abs(s1-s2))

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

int check(int n) {
    int ans = 0;
    for (int i = 1; i <= n; i += 2) {
        int count = 0;
        for (int j = 1; j <= i; ++j) {
            if (i % j == 0) {
                ++count;
            }
        }
        if (count == 8) {
            ans++;
        }
    }
    return ans;
}

int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    cout << check(N) << endl;
}

Measured memory_bytes: 256
function Main(input){
   input = input.split("\n");
   v_args = input[1].split(" ");
   c_args = input[2].split(" ");
  
  var num = parseInt(input[0],10);
  var value = new Array(num);
  var cost = new Array(num);
  var sum = 0;
  for(var i=0;i<num;i++){
    value[i] = parseInt(v_args[i],10);
    cost[i] = parseInt(c_args[i],10);    
  }
  for(var i=0;i<num;i++){
    var bnf = value[i]-cost[i];
    if(bnf > 0){
      sum +=bnf;
  }  
}
  console.log(sum);
}
Main(require("fs").readFileSync("/dev/stdin","utf-8"));

Measured memory_bytes: 7372