akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main(){
    int N,M;
    cin >> N >> M;
    vector<vector<P>>ID(N);
    for(int i = 0; i < M; i++) {
        int P,Y;
        cin >> P >> Y;
        P--;
        ID[P].push_back({Y,i});
    }
    vector<P>ans(M);
    for(int i = 0; i < N; i++) {
        sort(ID[i].begin(),ID[i].end());
        int cnt = 1;
        for(int j = 0; j < ID[i].size(); j++) {
            ans[ID[i][j].second] = {i+1,cnt};
            cnt++;
        }
    }
    for(int i = 0; i < M; i++) {
        int X = ans[i].first;
        int Y = ans[i].second;
        printf("%06lld%06lld\n",X,Y);
    }
}


Measured memory_bytes: 10304
/*input
5
10 1 5 4 17
*/
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_
}

fn main() {
    read_line();
    let v: Vec<i64> = read_line()
        .trim()
        .split_whitespace()
        .map(|x| x.parse().expect(""))
        .collect();
    println!(
        "{} {} {}",
        v.iter().min().unwrap(),
        v.iter().max().unwrap(),
        v.iter().fold(0, |x, y| x + y)
    );
}



Measured memory_bytes: 5036
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int H = in.nextInt();
			int W = in.nextInt();
			String[] array = new String[H];
			for(int i = 0; i < array.length; i++) {
				array[i] = "#" + in.next() + "#";
			}
			String repeated = new String(new char[W + 2]).replace("\0", "#");
			out.println(repeated);
			for(int i = 0; i < array.length; i++) {
				out.println(array[i]);
			}
			out.println(repeated);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}
}


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

int main() {

  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ( A + B > C + D ) {
    cout << "Left" << endl;
  }
  
  else if ( A + B == C + D ) {
    cout << "Balanced" << endl;
  }
  
  else if ( A + B < C + D ) {
    cout << "Right" << endl;
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>

typedef long long ll;
typedef unsigned long long ull;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

int saiki(string, int, int);

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

	int n;
	cin >> n;
	vector<int> w(n+1);
	w[0] = 0;
    
	rep(i, n)
	{
		cin >> w[i + 1];
		w[i + 1] += w[i];
	}

	int min_ = INF;
	int ans1, ans2;

	rep(i, n)
	{
		ans1 = w[i];
		ans2 = w[n] - w[i];
		min_ = min(min_, abs(ans1 - ans2));
	}

	cout << min_ << endl;

}

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

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
const int INF = 2147483647;
const ll  MOD = 1000000007;

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

    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;


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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>str;
    rep(i,str.length()){
        if(str[i]=='0') f++;
        else sum++;
    }
    maxi=min(sum,f);
    cout<<maxi*2<<endl;

    return 0;
}


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

// #define MULTI_TEST
#ifdef LOCAL
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
    out << '[' << p.first << ", " << p.second << ']';
    return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
    while (*name == ',' || *name == ' ')
        name++;
    std::cerr << name << " { ";
    for (const auto &v : arg)
        cerr << v << ' ';
    cerr << " }\n";
}
template <typename Arg1, typename... Args>
void PC(const char *names, Arg1 &&arg1, Args &&... args)
{
    while (*names == ',' || *names == ' ')
        names++;
    const char *comma = strchr(names, ',');
    std::cerr.write(names, comma - names) << " { ";
    for (const auto &v : arg1)
        cerr << v << ' ';
    cerr << " }\n";
    PC(comma, args...);
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
    std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    std::cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
auto TimeStart = chrono::steady_clock::now();
auto seed = TimeStart.time_since_epoch().count();
std::mt19937 rng(seed);
template <typename T>
using Random = std::uniform_int_distribution<T>;

const int NAX = 2e5 + 5, MOD = 1000000007;

void solveCase(int caseNo)
{
    int n;
    cin >> n;
    string str;
    cin >> str;
    int cnt = 0;
    for (int i = 0; i + 2 < n; i++)
    {
        if (str[i] == 'A' && str[i + 1] == 'B' && str[i + 2] == 'C')
            cnt++;
    }

    cout << cnt << '\n';
}

int main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
#ifdef MULTI_TEST
    cin >> t;
#endif
    for (int i = 1; i <= t; ++i)
    {
        solveCase(i);
#ifdef TIME
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve();

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

int nCk[51][51];

void solve() {
  int N, A, B;
  cin >> N >> A >> B;

  for (int i = 0; i <= 50; i++) {
    nCk[0][i] = 1;
    nCk[i][i] = 1;
  }

  for (int k = 2; k <= 50; k++) {
    for (int n = 1; n < k; n++) {
      nCk[n][k] = nCk[n-1][k-1] + nCk[n][k-1];
    }
  }

  map<int, int> cnt;

  vector<int> V(N);
  for (int &v:V) {
    cin >> v;
    cnt[v]++;
  }

  sort(V.begin(), V.end());
  reverse(V.begin(), V.end());

  int sum = 0;
  map<int, int> cnt_sum;

  for (int i = 0; i < A; i++) {
    sum += V[i];
    cnt_sum[V[i]]++;
  }

  int a = V[A-1];

  double maxi = sum/(double)A;
  int ans = nCk[cnt_sum[a]][cnt[a]];

  if (sum%A == 0 && sum/A == a) {
    for (int i = 1; i <= min(B-A, cnt[a]-cnt_sum[a]); i++) {
      ans += nCk[cnt_sum[a]+i][cnt[a]];
    }
  }

  printf("%.6lf\n%lld\n", maxi, ans);
}


Measured memory_bytes: 3260
"""

https://atcoder.jp/contests/abc134/tasks/abc134_f

少ないのは何？
一応マッチングの問題といえる

dp？
数字 >= index の位置と、数字 < index の場合がある。
前の場合の数字の和を An
indexの和をAi
後者を Bn / Biとする

(An-Ai) + (Bi-Bn) = k となるようにすればいい


箱根的に左から見ていく場合を考える。
そこのindexと、そこに置いてあった数字をどうするか考える

●そこのindex
    取っておいた数字を置く→数字 < indexとなるので Biに加算 (正の寄与)
        →とっておいた数字が1以上ないとダメ
    開けておく　→ Aiに加算 (負の寄与)・後で埋めないとダメ

●そこの数字
    左の空いてるところに入れる　→　Anに加算 (正の寄与)・空きがないとダメ
    取っておく　→ Bnに加算 (負の寄与)

dp[i][score][x][y] = i番目まで見て左に空きマスがx個あり、y個数字を取ってある場合の場合の数
dp[n][score][0][0] が答え
空きマスの数ととってある数字の個数は同じなので添え字を減らせる

→ dp[i][score][x] = i番目まで見て左に空きマスがx個あり、x個数字を取ってある場合の場合の数
dp[n][k][0] が答え
scoreの取りうる範囲は -n**2 ～ n**2でいいよね

"""

n,k = map(int,input().split())

scr = 10000

dp = [[[0] * (n+1) for i in range(scr)] for j in range(n+1)]
dp[0][0][0] = 1
mod = 10**9+7

for i in range(0,n):
    for nsc in range(-scr//2,scr//2):
        for x in range(n):

            #今見ている数字はi+1で求められる
            nownum = i+1

            #何もしない場合
            dp[i+1][nsc][x] += dp[i][nsc][x]
            dp[i+1][nsc][x] %= mod

            #数字を←に置き、取っておいた数字を置く場合
            #どちらも正の寄与なので +2nownum
            #xは1減る
            if x > 0:
                dp[i+1][(nsc+2*nownum)%scr][x-1] += dp[i][nsc][x] * x * x
                dp[i+1][(nsc+2*nownum)%scr][x-1] %= mod

            #数字を左に置き、マスを空ける場合
            #寄与は0
            #xは変わらず
            if x > 0:
                dp[i+1][nsc][x] += dp[i][nsc][x] * x
                dp[i+1][nsc][x] %= mod

            #数字をとっておき、マスに入れる場合
            #寄与は0
            #xは変わらず
            if x > 0:
                dp[i+1][nsc][x] += dp[i][nsc][x] * x
                dp[i+1][nsc][x] %= mod

            #数字をとっておき、マスもとっておく場合
            #どちらも負の寄与
            #xは1ふえる
            if x < n:
                dp[i+1][(nsc-2*nownum)%scr][x+1] += dp[i][nsc][x]
                dp[i+1][(nsc-2*nownum)%scr][x+1] %= mod

print (dp[n][k][0] % mod)
            
            


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

int main(){
    int A,B,C;cin>>A>>B>>C;
    if(A>B)swap(A,B);if(B>C)swap(B,C);if(A>B)swap(A,B);

    C-=A;B-=A;A=0;

    int ans=0;
    if(B%2==0){
        ans=(C-A+C-B)/2;
    }
    else{
        ans=(C-A+C-B+3)/2;
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    long n;
    long temp;
    long max=9223372036854775807;
    long result;
    cin >> n;
    for(long i=1;(n/i)>=i;i++){
        if((n%i)==0){
            temp = n/i;
            if((i+temp)<max){
                max=i+temp;
            }
        }
    }
    result = max-2;
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	count := 0
	for i := 0; i < n; i++ {
		var h int
		fmt.Scan(&h)
		if h >= k {
			count++
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 5504
#include<iostream>
#include<map>
using namespace std;
int t,n;
map<int,int> mm;
int main(){
	cin>>n;
	int a, no = 0;
	for(int i = 0;i<n;i++) cin>>a, mm[a]++;
	for(auto e : mm){
		if(e.second > 1) {
			no = 1;
			cout<<"NO\n";break;
		}
	}
	if(!no) cout<<"YES\n";
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define ll long long

using namespace std;
int p[200100],q[200100],r[200100];
vector < pair < ll , int > > v;
vector < ll > temp;

int main()
{
    ll x,y,A,B,C;  cin >> x >> y >> A >> B >> C;
    for(int i = 0;i<A;i++)  cin >> p[i] , v.push_back({p[i] , 1});
    for(int i = 0;i<B;i++)  cin >> q[i] , v.push_back({q[i] , 2});
    for(int i = 0;i<C;i++)  cin >> r[i] , v.push_back({r[i] , 3});
    sort(v.rbegin() , v.rend());
    ll Ans = 0;
    for(int i = 0;i<v.size();i++)  {
        if(v[i].second == 1)  {
                if(x > 0)  x-- , Ans+=v[i].first;
        }
        else if(v[i].second == 2){
                if(y > 0)  y-- , Ans+=v[i].first;
        }
        else {
            temp.push_back(v[i].first);
        }
        if(temp.size() == x + y)  break;
    }
    for(auto it : temp)  Ans+=it;
    cout << Ans;
    return 0;
}


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

int n;
int a[500010];


int solve(){
    int c[3] = {};
    rep(i,n) ++c[a[i]%3];
    int x = c[0];
    int y = c[1];
    int z = c[2];
    if(y > z) swap(y,z);
    if(y == 0 && z == 0) return 1;
    int ans = 0;
    ans += x;
    if(y > 0 || z > 0){
        int l = min(y,z);
        ans += l*2;
        y -= l;
        z -= l;
        ans += max(min(y,3), min(z,3));
    } else {
        ans += y + z;
    }
    return ans;
}

int main(){
    while(cin >> n){
        rep(i,n) cin >> a[i];
        cout << solve() << endl;
    }
}

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

int main(){
  int n,m,x,j=0,ans=0,c=0;cin>>n>>m>>x;
  vector<int> a(m,0);
  REP(i,m) cin>>a.at(i);
  while(a.at(j)<x) j++;
  for(int i=0;i<j;i++) ans++;
  for(int i=j;i<m;i++) c++;
  ans=min(ans,c);
  cout<<ans;
}

Measured memory_bytes: 256
//abc078_a.cpp
//Sat Feb 24 17:21:56 2018

#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	string x;
	string y;
	cin >> x;
	cin >> y;
	unordered_map<string, int> hex;
	hex["A"] = 11;
	hex["B"] = 12;
	hex["C"] = 13;
	hex["D"] = 14;
	hex["E"] = 15;
	hex["F"] = 16;

	if (hex[x]>hex[y]){
		cout << ">" << endl;
	}else if (hex[x]<hex[y]){
		cout << "<" << endl;
	}else {
		cout << "=" << endl;
	}

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
  int W,H,x,y,r;

  cin >> W >> H >> x >> y >> r;

  if ((x-r)>=0 && (y-r)>=0 && (x+r)<=W && (y+r)<=H) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;		 
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int N,A,B,C;
vector<int> L;
vector<int> use;

int dfs(int v){
  if (v == N){
    int a = 0; int b = 0; int c = 0;
    int res = -30;
    rep(i, N){
      if (use[i] == 1){
        a += L[i]; res += 10;
      }else if (use[i] == 2){
        b += L[i]; res += 10;
      }else if (use[i] == 3){
        c += L[i]; res += 10;
      }
    }
    if (a == 0 || b == 0 || c == 0) return INT_MAX;
    res += abs(A - a) + abs(B - b) + abs(C - c);
    return res;
  }
  int res = INT_MAX;
  use[v] = 0; chmin(res, dfs(v+1));
  use[v] = 1; chmin(res, dfs(v+1));
  use[v] = 2; chmin(res, dfs(v+1));
  use[v] = 3; chmin(res, dfs(v+1));
  use[v] = 0;
  return res;
}

int main() {
  cin >>N >>A >>B >>C;
  L.assign(N, 0); rep(i, N) cin >>L[i];
  use.assign(N, 0); // 0:not use , 1: a, 2: b, 3: c とする
  int res = dfs(0);
  cout <<res <<endl;
}


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

int main() {
  int A;
  cin >>A;
  
  int a[3];
  
  a[0] = A/100;
  a[1] = (A-a[0]*100)/10;
  a[2] = (A-a[0]*100-a[1]*10);
  
  int flg =0;
  for(int i=0;i<3;i++){
   if(a[i] ==7)
    flg =1; 
  }
  
  if(flg>0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<=(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) ((flag)?(int)1:(int)0)
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

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

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  int k; cin>>k;
  cout<<(k/2)*((k+1)/2);
}












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

using namespace std;

int main()
{
    vector<long long> sumVec;

    long long N;
    cin >> N;

    long long a;
    cin >> a;
    sumVec.push_back(a);

    for (long long i = 1; i < N; i++)
    {
        cin >> a;
        sumVec.push_back(a + sumVec[i - 1]);
    }

    long long ans = LLONG_MAX;
    for (long long i = 0; i < N - 1; i++)
    {
        ans = min(ans, abs(sumVec[i] - (sumVec[N - 1] - sumVec[i])));
    }

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

Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    
    UnionFind tree(n);
    vector<pair<int,int>> tomokan(m), blo(k);
     vector<int> setsize(n,0), result(n,0);
    REP(i,m){
        
        cin >> tomokan[i].first >> tomokan[i].second;
        tomokan[i].first--;
        tomokan[i].second--;
        tree.unite(tomokan[i].first, tomokan[i].second);
        result[tomokan[i].first]--;
        result[tomokan[i].second]--;
    }
    REP(i,k){
        cin >> blo[i].first >> blo[i].second;
        blo[i].first--;
        blo[i].second--;
    }
    REP(i,n){
        setsize[tree.root(i)]++;
    }
    REP(i,n){
        result[i]+=setsize[tree.root(i)];
    }
    REP(i,k){
        if(tree.same(blo[i].first,blo[i].second)){
            result[blo[i].first]--;
            result[blo[i].second]--;
        }
    }
    REP(i,n-1){
        cout << result[i]-1 << " ";
    }
    cout << result[n - 1]-1 << endl;

    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

vi C(26), Last(26, -1), T(365);
vector<vi> S(365, vi(26));
vector<vi> table(365, vi(26));
ll ans = 0;
int D, M;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int cmax, smax;
  cin >> D;
  REP(i, 26) cin >> C.at(i);
  REP(i, D) {
    int smax = 0;
    REP(j, 26) {
      cin >> S.at(i).at(j);
      if (S.at(i).at(smax) < S.at(i).at(j)) smax = j;
    }
    T.at(i) = smax +1;
  }

  REP(i, D) { cout << T.at(i) << endl; }
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

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

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

int main() {
  int H,W;
  cin>>H>>W;
  vector<vector<int>> vv(H);
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      int x;
      cin>>x;
      if(x%2==1) vv[i].push_back(j);
    }
  }
  vector<vector<int>> v;
  vector<vector<int>> memo;
  rep(i,H){
    if((int)vv[i].size()%2==1) memo.push_back({i,vv[i][vv[i].size()-1]});
    for(int j = 0; j < (int)vv[i].size()-1;j+=2){
      for(int k = vv[i][j];k<vv[i][j+1];k++){
        v.push_back({i,k,i,k+1});
      }
    }
  }
  for(auto x:memo){
    for(int i = x[1];i < W-1;i++){
      v.push_back({x[0],i,x[0],i+1});
    }
  }
  for(int i = 0; i < (int)memo.size()-1; i+=2){
    for(int j = memo[i][0];j < memo[i+1][0]; j++){
      v.push_back({j,W-1,j+1,W-1});
    }
  }
  cout<<v.size()<<endl;
  for(auto x:v){
    cout<<x[0]+1<<" "<<x[1]+1<<" "<<x[2]+1<<" "<<x[3]+1<<endl;
  }
}
      

Measured memory_bytes: 9904
n = int(input())

l = []
for i in range(n):
    a = int(input())
    ll = []
    for j in range(a):
        x,y = map(int,input().split())
        ll.append([x,y])
    l.append(ll)

ans = 0
for i in range(1 << n):
    people = []
    t= 0
    for j in range(n):
        if (i & (1 << j)) == 0:
            t+=1
            people.append(1)
        else:
            people.append(-1)

    flg = True
    for j in range(n):
        if (i & (1 << j)) == 0:
            for k in range(len(l[j])):
                x,y = l[j][k]
                if y == 0 and people[x-1]== 1:
                    flg = False
                elif y == 1 and people[x-1] == -1:
                    flg = False

    if flg:
        ans = max(ans , t)        
print(ans)

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

lli n,a,b;
void solve()
{
    lli tot=a+b;
    lli k=n/tot;
    lli m=n%tot;
    lli ans=k*a + min(a,m);
    cout<< ans <<"\n";


}
int main()
{
    cin>>n>>a>>b;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FO(i, a, b) for(int i = a; i <= b; i++)
#define FE(i, a, b) for(int i = a; i < b; i++)
#define R(i) i = read()
double const eps = 1e-12;
using namespace std;

const int N = 123456;

int read()
{
	int x = 0; char c = getchar();
	while((c < 48 || c > 57) && c != '-') c = getchar();
	if(c == '-') {c = getchar(); while(c >= 48 && c <= 57) x = x * 10 - c + 48, c = getchar();}
	else while(c >= 48 && c <= 57) x = x * 10 + c - 48, c = getchar();
	return x;
}

long long n;
int main() {
//	freopen("1.txt", "r", stdin);
	cin >> n;
	double l = (double) 4.0 / n;
	FO(i, 1, 3500)
		FO(j, 1, 3500) {
			long long r = n * i * j;
			long long p = 4 * i * j - n * j - n * i;
			if(p <= 0) continue;
			if(r % p == 0) {
				cout<< i<<' '<< j <<' '<< r / p;
				return 0;
			}
		}
}

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

#define LL                      long long
#define Ulong                   unsigned long long
#define REP(i,n)                for(long long i=0; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-14
#define F                       first
#define S                       second
#define di(x)                   int x; input(x)
#define in(x)                   input(x)
#define in2(x,y)                in(x),in(y)
#define in3(x,y,z)              in(x),in2(y,z)
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl
#define nl                      cout<<endl
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("/home/matrixcode/Desktop/in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
template<class T> inline void input(T &x) {
  register char c = getchar();x = 0;
  int neg = 0;
  for(; ((c<48 || c>57) && c != '-'); c = getchar());
  if(c=='-'){neg = 1;c = getchar();}
  for(; c>47 && c<58 ; c = getchar()){x = (x<<1) + (x<<3) + c - 48;}
  if(neg) x = -x;
}
inline long long bigmod(long long p,long long e,long long M){
  long long ret = 1;
  for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  } return ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/***************************** END OF TEMPLATE *******************************/

const int N = 3e5+5;
int a[N][3];
int dp[N][3];

int main()
{
  int n;
  in(n);
  for(int i = 1; i <= n; i ++) {
    in3(a[i][0], a[i][1], a[i][2]);
  }
  for(int i = 1; i <= n; i ++) {
    for(int j = 0; j < 3; j ++) {
      dp[i][j] = INT_MIN;
      for(int k = 0; k < 3; k ++) {
        if(k != j) dp[i][j] = max(dp[i][j] , dp[i-1][k] + a[i][j]);
      }
    }
  }
  int iMax = INT_MIN;
  for(int i = 0; i < 3; i ++) iMax = max(iMax, dp[n][i]);
  cout << iMax << endl;
}



Measured memory_bytes: 5504
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 150
#define L 1000

int LCSLength(char *X, char *Y){
  int m = strlen(X), n = strlen(Y);
  int i,j;
  int c[m+1][n+1];

  for(i=1; i<=m; i++) c[i][0] = 0;
  for(j=0; j<=n; j++) c[0][j] = 0;

  for(i=1; i<m+1; i++){
    for(j=1; j<n+1; j++){
      if(X[i-1] == Y[j-1]){
	c[i][j] = c[i-1][j-1] + 1;
      }
      else if(c[i-1][j] >= c[i][j-1]){
	c[i][j] = c[i-1][j];
      }
      else {
	c[i][j] = c[i][j-1];
      }
    }
  }

  return c[i-1][j-1];
}

int main(void){
  int q,i,j;
  int LCS[MAX];
  char X[MAX][L], Y[MAX][L];

  // input & calculate
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%s", &X[i]);
    scanf("%s", &Y[i]);
    LCS[i] = LCSLength(X[i],Y[i]);
  }

  // output
  for(i=0; i<q; i++) printf("%d\n", LCS[i]);

  return 0;
}

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

int main() {
   int N, D, M = 9,S = 0;
  cin >> N;
  int NN = N;
  for(int i = 0; ; i++){
    D = NN % 10;
    S += D;
    NN = NN/10;
    if(NN == 0){
      break;
    }
  }
  if(N % S == 0){
    cout << "Yes" << endl;
  }
  else{
     cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#import time
import numpy as np
from math import *

def main():
    A, B, H, M = list(map(int, input().split()))
    pai = 3.1415926535897323846264338327950
    kakuH = H*360/12 + M*30/60
    kakuM = M*360/60
    kakuS = kakuH - kakuM
    #print(kakuH, kakuM, kakuS)
    ans =(A**2 + B**2 - 2*A*B*np.cos(kakuS*pai/180))**(1/2)

    return ans

def absolute(a, b):
    if a>=b:
        if a-b>180:
            return 360-(a-b)
        else:
            return a-b
    else:
        if b-a>180:
            return 360-(b-a)
        else:
            return b-a

if __name__ == '__main__':
    #start = time.time()
    print(main())
    #elapsed_time = time.time() - start
    #print("経過時間:{}".format(elapsed_time * 1000) + "[msec]")

Measured memory_bytes: 27172
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  map<int, int> mp;
  ll ans = 0;
  ll sum = 0;
  mp[0]++;
  FOR(i,0,N) {
    int A;
    cin >> A;
    sum += A;
    ans += mp[sum%M];
    mp[sum%M]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3200
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N,K;
    cin>>N>>K;
    cout<<N-K+1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;


struct Button
{
	int x1, y1, x2, y2;
	string name;
	bool include(int x, int y)
	{
		return x1 <= x && x <= x2
			&& y1 <= y && y <= y2;
	}
	void input()
	{
		cin >> x1 >> y1 >> x2 >> y2 >> name;
	}
};
int main()
{
	int n, m, w, h;
	while (cin >> n, n)
	{
		cin >> w >> h;

		map<string, vector<Button> > page;
		vector<string> buffer;
		rep (i, n)
		{
			string name;
			int b;
			cin >> name >> b;
			if (i == 0)
				buffer.push_back(name);

			while (b--)
			{
				page[name].push_back(Button());
				page[name].back().input();
			}
		}

		cin >> m;
		int pointer = 0;
		while (m--)
		{
			string& b = buffer[pointer];

			string c;
			cin >> c;
			if (c[0] == 'c')
			{
				int x, y;
				cin >> x >> y;
				for (int i = 0; i < page[b].size(); ++i)
				{
					if (page[b][i].include(x, y))
					{
						++pointer;
						buffer.erase(buffer.begin() + pointer, buffer.end());
						buffer.push_back(page[b][i].name);
						break;
					}
				}
			}
			else if (c[0] == 'b')
				pointer = max(0, --pointer);
			else if (c[0] == 'f')
				pointer = min((int)buffer.size() - 1, ++pointer);
			else if (c[0] == 's')
				cout << b << endl;
		}
	}
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

void Main()
{
	int n,m,l; cin >> n >> m >> l;

	vector<vector<LL>> d(n);

	REP(i,n){
		d[i].resize(n,INF_LL);
		d[i][i] = 0;
	}

	REP(i,m){
		int a,b,c;
		cin >> a >> b >> c;
		a--;b--;
		d[a][b] = c;
		d[b][a] = c;
	}	


	REP(k,n){
		REP(i,n){
			REP(j,n){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}

	vector<vector<LL>> dd(n);

	REP(i,n){
		dd[i].resize(n,INF_LL);
		REP(j,n){
			if(d[i][j] <= l){
				dd[i][j] = 1;
			}
		}
	}
	
	REP(k,n){
		REP(i,n){
			REP(j,n){
				dd[i][j] = min(dd[i][j], dd[i][k] + dd[k][j]);
			}
		}
	}
	
	int q;cin>>q;

	//dump(q)

	REP(i,q){
		int s,t;
		cin >> s >> t;
		s--;t--;

		if(dd[s][t] == INF_LL){
			cout << -1 << endl;
			continue;
		}

		cout << dd[s][t]-1 << endl;

	}

	return;
}

int main()
{
	//cin.tie(nullptr);
	//ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 1920
using namespace std;

#include <cstdio>
#include <cstdint>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

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

    long int A = 0;
    long int B = 0;
    long int C = 0;
    long int K = 0;
    long int ans = 0;

    cin >> A >> B >> C >> K;

    if(K <= A+B){
        ans = min(K,A);
    }else if(A+B < K <= A+B+C){
        ans = A - (K - A-B);
    }
    cout << ans << "\n";
    return 0;
    
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



ll dp[3001][3001];

int main() {
    int n;
    cin >> n;
    
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    // 局面の残り石の個数でループ
    rep3(len, 1, n + 1) for (int i = 0; i + len <= n; ++i) {
        // len = j - i
        int j = len + i;
        
        if ((n - len) % 2 == 0) {
            dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1]);
        } else {
            dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1]);
        }
    }
    
    cout << dp[0][n] << endl;
}
 



Measured memory_bytes: 70144
#include <stdio.h>

int main() {
  short input;

  scanf("%hd", &input);

  switch(input % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      printf("%s", "hon\n");
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      printf("%s", "pon\n");
      break;
    default:
      printf("%s", "bon\n");
      break;
  }

  return 0;
}


Measured memory_bytes: 1644
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=200005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n;
int main(){
    scanf("%d",&n);
    int ans=n/500*1000+n%500/5*5;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s1 = scanner.nextLine();
        String s2 = scanner.nextLine();

        int[][] dp = new int[s1.length() + 1][s2.length() + 1];
        for (int i = 1; i <= s1.length(); ++i) {
            for (int j = 1; j <= s2.length(); ++j) {
                if (s1.charAt(i - 1) == s2.charAt(j - 1)) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                } else {
                    dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
                }
            }
        }

        StringBuilder builder = new StringBuilder();
        int i = s1.length();
        int j = s2.length();
        while (i > 0 && j > 0) {
            if (s1.charAt(i - 1) == s2.charAt(j - 1)) {
                builder.append(s1.charAt(i - 1));
                --i;
                --j;
            } else {
                if (dp[i - 1][j] > dp[i][j - 1]) {
                    i--;
                } else {
                    j--;
                }
            }
        }

        System.out.println(builder.reverse().toString());
    }
}


Measured memory_bytes: 82256
import numpy as np
D=int(input())

c_list=list(map(int,input().split()))
c_list=np.array(c_list)
c_ll=np.array([0]*26)

d_list=[]
for i in range(D):
    dl=list(map(int,input().split()))
    d_list.append(np.array(dl))

# score
score=0

#expect
exp=[0]*26
for d in range(D):
    c_ll+=1
    for i in range(26):
        exp[i]+=d_list[d][i]
        c_ll2=c_ll
        c_ll2[i]=0
        exp[i]-=sum(c_list*c_ll)

    j=exp.index(max(exp))
    c_ll[j]=0
    print(j+1)


Measured memory_bytes: 26728
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    string a, b;
    cin >> a >> b;
    if (a == "H") {
        if (b == "H")
            cout << "H";
        else
            cout << "D";
    } else {
        if (b == "H")
            cout << "D";
        else
            cout << "H";
    }
    cout << endl;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<ll, ll>;
#define INF 1001001001
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repX(i, n , x) for (ll i = (ll)(x); i < (ll)(n); ++i)
#define repB(i, n) for (ll i = n; i >= 1; --i)
#define repBX(i, n , x) for (ll i = (ll)(n); i >= ll(X); --i)
#define dup(x,y) (((x)+(y)-1)/(y))
int main() {
    ll A,B,K;
    cin >> A >> B >> K;
    ll lA = A;
    A = max((ll)(0),A-K);
    if(A==0){
        K -= lA;
        B = max((ll)(0),B-K);
    }
    cout << A << " " << B << endl;
    
    return 0;
}

Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime


N = iin()
A = iln()

decreased = False
increased = False
count = 1
for i in range(1, N):
    if not decreased and not increased:
        if A[i-1] > A[i]: decreased = True
        if A[i-1] < A[i]: increased = True
    else: 
        if decreased:
            if A[i-1] < A[i]:
                count += 1
                decreased = False
        else:
            if A[i-1] > A[i]:
                count += 1
                increased = False
print(count)


    


Measured memory_bytes: 16364
N = int(input())
print(0, flush=True)
l = input()
if l == 'Vacant':
    exit()
print(N - 1, flush=True)
t = input()
if t == 'Vacant':
    exit()

top = N - 1
lo = 0
while True:
    mid = (top + lo) // 2
    print(mid, flush=True)
    tmp = input()
    if tmp == 'Vacant':
        exit()
    elif ((mid - lo) % 2 != 0 and l == tmp) or ((mid - lo) % 2 == 0 and l != tmp):
        top = mid
    else:
        lo = mid
        l = tmp


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

int main(){
    int N;
    long Y;

    cin >> N >> Y;
    for(int a=0;a<=2000;a++){
        for(int b=0;b<=2000;b++){
            int c = N - a - b;
            if(c >= 0){
                if(10000*a+5000*b+1000*c == Y){
                    cout << a << " " << b << " " << c << endl;
                    return 0;
                }
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.B
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			int n = cin.NextInt();
			bool ok = false;
            for (int i = 1; i < 10; i++)
            {
                for (int j = i; j < 10; j++)
                {
					if (i * j == n) ok = true;
                }
            }
            if (ok) Console.WriteLine("Yes");
            else Console.WriteLine("No");

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 11092
import sys
sys.setrecursionlimit(10**6)

n = int(input())
C = input()

C = list(C)

d = {0:0}
tot = 0

for i,c in enumerate(C):
    if c == 'R':
        tot += 1
    d[i+1] = tot

ans = tot-d[tot]
print(ans)

Measured memory_bytes: 36804