akhauriyash/Code-Regression huggingface dataset:
// テ・ツ淞コテヲツ慊ャテ」ツδ?」ツδウテ」ツδ療」ツδャテ」ツδシテ」ツδ?

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int M, N;
map<string, pii> m;

signed main() {
    cin >> M;
    rep(i,0,M) {
        string s; int l, r;
        cin >> s >> l >> r;
        m[s] = pii(l, r);
    }

    cin >> N;
    stack< vector<int> > st;
    string pat = "+-*/";
    rep(i,0,N) {
        string s; cin >> s;
        vector<int> v(256);
        if(m.count(s)) {
            // variable
            repq(x,m[s].first,m[s].second) v[x] = 1;
            st.push(v);
        }
        else if(s == "+") {
            vector<int> a, b, nx(256);
            b = st.top(); st.pop();
            a = st.top(); st.pop();
            rep(p,0,256) rep(q,0,256) {
                if(a[p] && b[q]) nx[ (p+q) % 256 ] = 1;
            }
            st.push(nx);
        }
        else if(s == "-") {
            vector<int> a, b, nx(256);
            b = st.top(); st.pop();
            a = st.top(); st.pop();
            rep(p,0,256) rep(q,0,256) {
                if(a[p] && b[q]) nx[ (p-q+256) % 256 ] = 1;
            }
            st.push(nx);
        }
        else if(s == "*") {
            vector<int> a, b, nx(256);
            b = st.top(); st.pop();
            a = st.top(); st.pop();
            rep(p,0,256) rep(q,0,256) {
                if(a[p] && b[q]) nx[ (p*q) % 256 ] = 1;
            }
            st.push(nx);
        }
        else if(s == "/") {
            vector<int> a, b, nx(256);
            b = st.top(); st.pop();
            a = st.top(); st.pop();
            rep(p,0,256) rep(q,0,256) {
                if(a[p] && b[q]) {
                    // printf("p = %lld, q = %lld\n", p, q);
                    if(q == 0) {
                        cout << "error" << endl;
                        return 0;
                    }
                    nx[ (p/q) % 256 ] = 1;
                }
            }
            st.push(nx);
        }
        else {
            // number
            int val = 0;
            rep(j,0,s.length()) val = val * 10 + (s[j] - '0');
            v[val] = 1;
            st.push(v);
        }
    }
    cout << "correct" << endl;
    return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, h;
    cin >> n >> h;
    vector<int> a(n), b(n);
    rep(i,n) cin >> a[i] >> b[i];
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    int ans = 0, idx = 0;
    while(idx < n && b[idx] > a[0] && h > 0){
        h -= b[idx++];
        ++ans;
    }
    if(h > 0) ans += (h + a[0] - 1) / a[0];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3976
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
	int N, T, S, M[3001]={};
	cin >> N >> T >> S;
	if(S==0){
		for(int n=0; n<N; n++){
			int mise_fun, mise_time;
			cin >> mise_fun >> mise_time;
			for(int t=T; t>=mise_time; t--)
				M[t] = max(M[t], M[t-mise_time] + mise_fun);
		}
	}
	else{
		for(int n=0; n<N; n++){
			int mise_fun, mise_time;
			cin >> mise_fun >> mise_time;
			for(int t=T; t>=mise_time; t--)
				if(t<=S || t >= S  + mise_time) M[t] = max(M[t], M[t-mise_time] + mise_fun);
		}
	}
	cout << *max_element(M+1, M+T+1) << endl;
	return 0;
}

Measured memory_bytes: 1216
N, K, C = map(int, input().split(" "))
S = input()

L = [0]     # L[i]->前から決めてi回目に働く日
R = []      # R[i]->後ろから決めてi回目に働いていなければいけない日

i = 0
while i < N:
    if S[i] == 'o':
        L.append(i + 1)
        i += C
    i += 1

i = N - 1
while i > -1:
    if S[i] == 'o':
        R.append(i + 1)
        i -= C
    i -= 1
R.append(0)
R.reverse()

ans = []
for i in range(1, K + 1):
    if L[i] == R[i]:
        ans.append(L[i])


if min(len(L), len(R)) > K + 1:
    print()
else:
    print('\n'.join([str(a) for a in ans]))


Measured memory_bytes: 34876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    map<string, int> sm;
    rep(i,n){
        string s;cin>>s;
        sort(s.begin(), s.end());
        sm[s]++;
    }
    ll ans = 0;
    for(auto a : sm){
        ll t = a.second;
        ans += (t*(t-1))/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11264
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<deque>
using namespace std;

int main()
{
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}


Measured memory_bytes: 3568
while gets
  a = $_.split.map(&:to_i)
  b = gets.split.map(&:to_i)
  hit = blow = 0

  for i in 0...4
    if a[i] == b[i]
      hit += 1
      next
    end

    for j in 0...4
      if a[i] == b[j]
        blow += 1
        break
      end
    end
  end

  printf("%d %d\n", hit, blow)
end

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

using lli = long long int;
using ll = long long;

lli n, m, h, a, b;

std::vector<lli> vec;
std::vector<lli> viewpoints;
std::vector<std::vector<lli>> vec2;

int main() {
    std::cin >> n >> m;
    vec.assign(n+1, 0);
    viewpoints.assign(n+1, -1);
    vec2.assign(n+1, std::vector<lli>(0, 0));
    for (int i = 1; i <= n; i++) {
        std::cin >> vec[i];
    }
    for (int i = 0; i < m; i++) {
        std::cin >> a >> b;
        if (vec[a] <= vec[b]) {
            viewpoints[a] = 0;
        }
        if (vec[b] <= vec[a]) {
            viewpoints[b] = 0;
        }
    }
    lli ans = std::count(viewpoints.begin()+1, viewpoints.end(), -1);
    std::cout << ans << std::endl;
}


Measured memory_bytes: 7184
n, d = gets.split.map &:to_i
x = []
n.times do
  x << gets.split.map(&:to_i)
end
r = 0
for i in 0...n
  for j in i...n
    next if i == j
    s = 0
    for k in 0...d
      s += (x[j][k] - x[i][k])**2
    end
    s = Math.sqrt(s)
    r += 1 if s.ceil == s.floor
  end
end
p r

Measured memory_bytes: 14292
N = int(input())
a = [int(i) for i in range(1,10)]
t = 0
for i in range(9):
  b = int(N/a[i])
  if N % a[i] == 0 and 0<b<10:
    t += 1
if t > 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
#include <numeric>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }






int main(int argc, char* argv[])
{
	for (;;) {
		int N;
		cin >> N;
		if (cin.fail()) break;

		using P = array<ll, 2>;
		vector<P> V(N);
		for (int i = 0; i < N; i++) {
			cin >> V[i][0] >> V[i][1];
		}
		sort(V.begin(), V.end(), [](P& a, P& b) { return (a[0] + a[1]) > (b[0] + b[1]); });
		ll ans[2]{};
		for (int i = 0; i < N; i++) {
			ans[i & 1] += V[i][i & 1];
		}
		cout << ans[0] - ans[1] << endl;
	}

	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
using namespace std;

vector<int> check(vector<int>data,int i)
{
  vector<int> ans;
  ans.push_back(0);
  if(data.size()<=i)
    return ans;
  ans.clear();
  vector<int> tmp=check(data,i+1);
  if(data[i]!=1)
    {
      for(int j=0;j<tmp.size();j++)
          if(data[i]+tmp[j]<=21)
              ans.push_back(data[i]+tmp[j]);
    }
  else
    {
      for(int j=0;j<tmp.size();j++)
        {
          if(1+tmp[j]<=21)
            ans.push_back(1+tmp[j]);
          if(11+tmp[j]<=21)
            ans.push_back(11+tmp[j]);
        }
    }

  return ans;

}

int main()
{
  string s;
  for(;getline(cin,s),s!="0";)
    {
      istringstream ss(s);
      vector<int> data;
      int tmp;
      for(;ss>>tmp;)
        {
          if(tmp>10)
            tmp=10;
          data.push_back(tmp);
        }
      vector<int> ans=check(data,0);
      int out=0;
      for(int i=0;i<ans.size();i++)
        {
          out=max(out,ans[i]);
        }
      cout<<out<<endl;
    }
}

Measured memory_bytes: 1296
#include <cstdio>
#define MAX 100000

using namespace std;

int isPrime[MAX+1];
int count[MAX+1], tmp;

int main(void){
  int q,l,r;
  
  // pre-process
  for (int i=2; i<=MAX; i++){
    if (isPrime[i]==0){
      isPrime[i] = 1;
      for (int j=2*i; j<=MAX; j+=i){
        isPrime[j] = -1;
      }
    }
  }
  for (int i=2; i<=MAX; i++){
    if (isPrime[i]==1 && isPrime[(i+1)/2]==1){
      tmp++;
    }
    count[i] = tmp;
  }
  
  scanf("%d", &q);
  for (int i=0; i<q; i++){
    scanf("%d%d",&l,&r);
    printf("%d\n", count[r]-count[l-1]);
  }
  
  return 0;
}

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

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

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

// Sieve of Eratosthenes
struct Sieve {
  int n;
  vector<int> table, primes;
  // constructor
  Sieve(int n=1):n(n), table(n+1) {
    table[0] = table[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (table[i]) continue;
      primes.push_back(i);
      table[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!table[j]) table[j] = i;
      }
    }
  }

  // 素数判定: 素数ならTRUE;
  bool isPrime(int x) { return table[x] == x;}

  // 素因数分解: 素因数を小さい順にvectorで返す
  vector<int> factorList(int x) {
    vector<int> fl;
    while (x != 1) {
      fl.push_back(table[x]);
      x /= table[x];
    }
    return fl;
  }

  // 素因数分解した時のペアリストを返す ex ) x = 2^3 + 3^5 -> {<2, 3>, <3, 5>}
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> fl_pair(1, P(fl[0], 0));
    for (int p : fl) {
      if (fl_pair.back().first == p) {
        fl_pair.back().second++;
      } else {
        fl_pair.emplace_back(p, 1);
      }
    }
    return fl_pair;
  }
};


// main
int main(){
    Sieve sieve(1e6);
    int N; cin >> N;
    vector<int> A(N); rep(i, N) cin >> A[i];

    map<int, int> lcm_mp;
    rep(i, N){
        auto factor_pair = sieve.factor(A[i]);
        for(auto p : factor_pair){
            lcm_mp[p.first] = max(lcm_mp[p.first], p.second);
        }
    }

    mint lcm = 1;
    for (auto p : lcm_mp){
        rep(i, p.second){
            lcm *= p.first;
        }
    }

    mint ans;
    rep(i,N){
        mint b = lcm/A[i];
        ans += b;
    }
    cout << ans << endl;

    return 0;
}

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

int con[210000];
int main() {
  int N, M, T; cin >> N >> M >> T;
  memset(con, 0, sizeof(con));
  for (int i = 0; i < N; ++i) {
	int a; cin >> a;
	for (int b = a - M; b < a + M; ++b) {
	  con[b]++;
	}
  }
  int res = 0;
  for (int t = 0; t < T; ++t) if (!con[t]) ++res;
  cout << res << endl;
}



Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


const int mod = 1000000007;
const int max_n = 200005;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(max_n);


int main(){
    ll n,k;cin >> n >>k;
    vl a(n);rep(i,n)cin >> a[i];
    vl b(2*n);rep(i,2*n)b[i]=a[i%n];
    vl cnt(2*n);
    rep(i,2*n){
        repl(j,i+1,2*n){
            if(b[i]>b[j])cnt[i]++;
        }
    }
    //rep(i,2*n)cout << cnt[i] <<" ";
    mint res=0;
    rep(i,n){
        mint init=cnt[i+n];
        mint dif=cnt[i];dif-=init;
        mint las=init+dif*(k-1);
        res+=(init+las)*k/2;
    }
    cout << res <<endl;
}

Measured memory_bytes: 6236
#include <bits/stdc++.h>
using namespace std;
int main()
{
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   #define int long long int
   int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
   int k;
   cin>>k;
   cout<<a[k-1]<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		double[] x = new double[n];
		String[] u = new String[n];

		for (int i = 0; i < n; i++) {
			x[i] = sc.nextDouble();
			u[i] = sc.next();
		}

		double sum = 0;

		for (int i = 0; i < n; i++) {
			if (u[i].equals("JPY")) {
				sum += x[i];
			} else {
				sum += x[i] * 380000.0;
			}
		}

		System.out.print(sum);
	}
}

Measured memory_bytes: 22868
// In the name of Allah. Ya ali!
#include<bits/stdc++.h>
#define double long double
typedef long long ll;
const ll MAX_N = 2e5+100;
const ll MOD = 1e9+7;
using namespace std;

int main()
{
    string s;
    cin >> s;
    ll cnt = 0;
    ll ans = 0;
    for(int i = 0;i<s.length();++i)
    {
        cnt+=(s[i]=='B');
        ans+=cnt*(s[i]=='W');
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3 4 9 0");
            //5.00000000000000000000
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3 4 10 40");
            //4.56425719433005567605
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();

        int A = wkArr[0];
        int B = wkArr[1];
        int H = wkArr[2];
        int M = wkArr[3];

        //合計分数を求める
        double TotalMin = 60 * H + M;

        double HourDec = 0; //時針の角度(度数法)
        double MinuteDec = 0; //分針の角度(度数法)

        //時針は1分で0.5度進む
        //分針は1分で6度進む
        HourDec = (TotalMin * 0.5) % 360;
        MinuteDec = (TotalMin * 6) % 360;

        double ThetaDec = Math.Abs(HourDec - MinuteDec);
        ThetaDec = Math.Min(ThetaDec, 360 - ThetaDec);

        double ThetaRad = ThetaDec * Math.PI / 180;

        Console.WriteLine(Math.Sqrt(A * A + B * B - 2 * A * B * Math.Cos(ThetaRad)));
    }
}


Measured memory_bytes: 28716
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	int answer = n / 500 * 1000;
	n %= 500;
	answer += n / 5 * 5;
	cout << answer << '\n';
 	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n;
    int p[4][3][10] = {0};
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        int b, f, r, v;
        scanf("%d %d %d %d", &b, &f, &r, &v);
        p[b - 1][f - 1][r - 1] += v;
    }
    for (int b = 0; b < 4; b++)
    {
        for (int f = 0; f < 3; f++)
        {
            for (int r = 0; r < 10; r++)
            {
                printf(" %d", p[b][f][r]);
            }
            printf("\n");
        }
        if (b != 3){
        printf("####################\n");
        }
    }
    return 0;
    
}


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

int dp[(int)1e5+1];

int solve(int *h, int n, int k)
{
    if(n == 0)
        return 0;
    if(dp[n] != -1)
        return dp[n];
    int op = 1e9;
    for(int i = 1; i <= min(n, k); i++)
        op = min(op, solve(h, n-i, k) + abs(h[n]-h[n-i]));
    return dp[n] = op;
}

int main() {
    int t = 1;
    while(t--)
    {
    	int n, k;
    	cin >> n >> k;
    	int h[n];
    	for(int &val : h) 
    	    cin >> val;
    	memset(dp, -1, sizeof dp);
    	cout << solve(h, n-1, k);
    }
	return 0;
}

Measured memory_bytes: 12252
#include<iostream>
#include<set>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

vector<string> solve(string s,int st){
	vector<string> ans;
	
	string s1 = s.substr(0,st);
	string s2 = s.substr(st,s.size()-st);
	
	// 両方正
	ans.push_back(s1+s2);
	ans.push_back(s2+s1);

	reverse(s1.begin(),s1.end());

	//s1が逆
	ans.push_back(s1+s2);
	ans.push_back(s2+s1);

	reverse(s2.begin(),s2.end());

	//両方逆
	ans.push_back(s1+s2);
	ans.push_back(s2+s1);

	reverse(s1.begin(),s1.end());

	//s2が逆
	ans.push_back(s1+s2);
	ans.push_back(s2+s1);

	return ans;
}

int main(){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		set<string> s;
		string buf;
		cin >> buf;
		for(int j=1;j<buf.size();j++){
			vector<string> buf2 = solve(buf,j);
			for(int k=0;k<buf2.size();k++){
				s.insert(buf2[k]);
			}
		}

		cout << s.size() << endl;
	}
}

Measured memory_bytes: 1300
#include<bits/stdc++.h>
#define f first
#define s second
#define inf 999999999999
#define N  500009
#define M  (L+R)/2
#define ll long long
#define pb push_back
using namespace std;

ll n,ans,sum,i,j,dp[30][200];

string a[3];

int main()
{

	ios::sync_with_stdio(0);
	
	cin>>n;
	cin>>a[0]>>a[1]>>a[2];
	
	for(i=0;i<n;i++)
	{
		sum=0;
		for(j=0;j<3;j++)
		{
			for(int i1=j+1;i1<3;i1++)
			{
				if(a[j][i]==a[i1][i])sum++;
			}
		}
		ans+=max(3-sum-1,0ll);
	//	cout<<sum<<" "<<ans<<endl;
	}
	cout<<ans<<endl;

return 0;
}






Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int m=n;
    int k=0;
    while(m){
        k+=m%10;
        m/=10;
    }
    if(n%k)no;
    else yes;
}


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

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  rep(i,n)rep(j,n)rep(k,n) ans += gcd(i,gcd(j,k));
  cout << ans << endl;
  return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s[101][101];
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>b>>a;
      cout<<100<<" "<<100<<"\n";
      a--;b--;
      rep(i,100){
        rep(j,100){
          if(i<50){
            s[i][j]='.';
          }
          else{
            s[i][j]='#';
          }
        }
      }
      ll cnta=0,cntb=0;
      if(cnta!=a){
      rep(i,50){
        rep(j,100){
          if(i%2==0){
            if(j%2==0){
              s[i][j]='#';
              cnta++;
            }
          }
          if(cnta==a)break;
        }
        if(cnta==a)break;
      }
      }

      if(cntb!=b){
      rrrep(i,99,50){
        rep(j,100){
          if(i%2!=0){
            if(j%2==0){
              s[i][j]='.';
              cntb++;
            }
          }
          if(cntb==b)break;
        }
        if(cntb==b)break;
      }
      }

      rep(i,100){
        rep(j,100){
          cout<<s[i][j];
        }
        cout<<"\n";
      }

     

       
return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]

class Util():
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)

N = 0
ans = 0
def rec(n):
    global ans
    if n > N:
        return
    m = _collections.defaultdict(int)
    for i in sorted(str(n)):
        m[i] += 1
    if m["3"] > 0 and m["5"] > 0 and m["7"] > 0:
        ans += 1
    rec(n * 10 + 3)
    rec(n * 10 + 5)
    rec(n * 10 + 7)

def main():
    global N
    N = cin.int()
    rec(3)
    rec(5)
    rec(7)
    print(ans)
    return
if __name__ == "__main__":
    main()


Measured memory_bytes: 46040
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}


ll dp[1111][11111];

int main(void) {
  ll N;
  cin >> N;
  ll i, j;
  ll cnt[10][10]={};
  
  for(i=1; i<N+1; i++) {
    string n=to_string(i);
    cnt[n[0]-'0'][n[n.size()-1]-'0']++;
  }
  
  ll ans=0;
  for(i=1; i<10; i++) {
    for(j=1; j<10; j++) {
      ans+=cnt[i][j]*cnt[j][i];
    }
  }
  
  pt(ans);
  
  
}



Measured memory_bytes: 384
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

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

Node T[MAX];
int n,D[MAX];

void print(int u){
    int i,c;
    cout<<"node "<< u <<": ";
    cout<<"parent = "<< T[u].p <<", ";
    cout<<"depth = "<< D[u] <<", ";
    
    if(T[u].p==NIL) cout<<"root, ";
    else if(T[u].l==NIL) cout<<"leaf, ";
    else cout<<"internal node, ";
    
    cout<<"[";
    
    for(i=0,c=T[u].l;c !=NIL;i++,c=T[c].r){
        if(i) cout<<", ";
        cout<<c;
    }
    cout<<"]"<<endl;
}

int rec(int u,int p){
    D[u]=p;
    if(T[u].r !=NIL) rec(T[u].r,p);
    if(T[u].l !=NIL) rec(T[u].l,p+1);
}

int main(){
    int i,j,d,v,c,l,r;
    cin>>n;
    for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;
    
    for(i=0;i<n;i++){
        cin>>v>>d;
        for(j=0;j<d;j++){
            cin>>c;
            if(j==0) T[v].l=c;
            else T[l].r=c;
            l=c;
            T[c].p=v;
        }
    }
    for(i=0;i<n;i++){
        if(T[i].p==NIL) r=i;
    }
    
    rec(r,0);
    
    for(i=0;i<n;i++) print(i);
    
    return 0;
}


Measured memory_bytes: 7744
n,m=map(int,input().split())
l,r=[],[]
for i in range(m):
    a,b=map(int,input().split())
    l.append(a)
    r.append(b)
s=0
t=n+1
for i in range(m):
    if l[i]>s:
        s=l[i]
    if r[i]<t:
        t=r[i]
if s>t:
    print(0)
else:
    print(t-s+1)

Measured memory_bytes: 85436
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s, w, r;
	int q, i, j, a, b;
	cin >> s >> q;
	
	for(i = 0; i < q; ++i){
		cin >> w >> a >> b;
		if( w == "replace" ){
			cin >> r;
			for( j = a; j <= b; ++j)
				s[j] = r[j-a];			
		}else if( w == "print" ){
			for( j = a; j <= b; ++j)
				cout << s[j];
			cout << "\n";
		}else if( w == "reverse" ){
			string c = s;
			for( j = a; j <= b; ++j)
				s[j] = c[b+a-j];
		}
	}

	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define RFOR(i, begin, end) for(int i=(end)-1, i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, N) FOR(i, 0, N)
#define rrep(i, N) RFOR(i, 0, N)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long int;
using V = vector<ll>;
using P = pair<ll, ll>;
using VP = vector<P>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
constexpr int inf = 1e9;
constexpr int mod = 1e9+7;
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() {
    string s;
    cin >> s;
    if (s == "Sunny") {
        cout << "Cloudy" << endl;
    }
    else if (s == "Cloudy") {
        cout << "Rainy" << endl;
    }
    else {
        cout << "Sunny" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $x);

$a = -118;
$b = -119;
for ($i=$a; $i < 119; $i++) {
  for ($j=$b; $j < 118; $j++) {
    if (pow($i, 5) - pow($j, 5) == $x) {
      echo $i . ' ' . $j;exit;
    }
  }
}


Measured memory_bytes: 16168
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass #sortされていない

def main():
    A, B = map(int, input().split())
    div_A = set(divisor(A))
    div_B = set(divisor(B))
    com_div = div_A & div_B
    cnt = 1
    for a in com_div:
        if is_prime(a):
            cnt += 1

    print(cnt)



if __name__ == "__main__":
    main()

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

const int Max = 200;
const int W = 10005;
struct Node
{
    int v, w;
};
Node item[Max];
int C[Max][W];

int main()
{
    int N, W;
    cin >> N >> W;
    for(int i=1; i<=N; i++)
    {
        cin >> item[i].v >> item[i].w;
    }
    for(int i=0; i<=N; i++)
    {
        C[i][0] = 0;
    }
    int sumW = 0;
    for(int i=1; i<=N; i++)
    {
        for(int w=1; w<=W; w++)
        {
            if(item[i].w<=w)
            {
                C[i][w] = max(C[i-1][w], C[i-1][w-item[i].w]+item[i].v);
            }
            else
            {
                C[i][w] = C[i-1][w];
            }
        }
    }
    cout << C[N][W] << endl;
    return 0;
}



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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

long long a[53];

void solve() {
  long long k; scanf("%lld", &k);
  int n = 50;
  puts("50");
  for (int i = 0; i < n; ++i) {
    a[i] = (k+n-1)/n+i;
  }
  if (k%n) {
    k = n-(k%n);
    for (int i = 0; i < k; ++i) {
      int x = max_element(a, a+n)-a;
      a[x] -= n;
      for (int j = 0; j < n; ++j) {
	if (j == x) continue;
	++a[j];
      }
    }
  }
  for (int i = 0; i < n; ++i) printf("%lld ", a[i]);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  int ab[n+10];

  for(int i= 0;i < n;i++) {
      ab[i] = 0;
  }


  for(int i = 0;i < m;i++) {
    int a,b;
    cin >> a >> b;
    ab[a-1]++;
    ab[b-1]++;
  }
  
  for(int i = 0;i <n;i++) {
    cout << ab[i] << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N,n,minus[4000][3]={0},plus[4000][3]={0};
	int a[4000];
	int p[3];
	long long sum=0;
	string S;
	cin>>N>>S;
	for(int i=0;i<N;i++){
		if(S[i]=='R')a[i]=0;
		else if(S[i]=='G')a[i]=1;
		else if(S[i]=='B')a[i]=2;
	}
	for(int i=0;i<N-2;i++){
		for(int j=i+1;j<N-1;j++){
			for(int k=0;k<3;k++){
				if(a[i]==k){
					if(a[j]==(k+1)%3){
						plus[j+1][(k+2)%3]++;
						if(j+j-i<N)minus[j+j-i][(k+2)%3]++;
					}else if(a[j]==(k+2)%3){
						plus[j+1][(k+1)%3]++;
						if(j+j-i<N)minus[j+j-i][(k+1)%3]++;
					}
				}
			}
		}
	}
	for(int i=0;i<N;i++){
		p[0]+=plus[i][0];
		p[1]+=plus[i][1];
		p[2]+=plus[i][2];
		sum+=p[a[i]]-minus[i][a[i]];
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define F(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define f(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define file(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
 int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}
int n;
int a[200005],b[200005];
int dp[5005][5005];
int f[100005],inv[100005];
const int mod=1e9+7;
long long qpow(long long x,long long y){
     long long res=1;
	 while(y){
	    if(y&1)res=res*x%mod;
		x=x*x%mod;
		y>>=1;
	 }
	  return res;
}
int main () {
n=read();
F(i,1,n){
	a[i]=read(),b[i]=read();
    dp[2000-a[i]][2000-b[i]]++;
}
F(i,0,4000){
  F(j,0,4000){
    dp[i][j]=((j==0?0:dp[i][j-1])+(i==0?0:dp[i-1][j])+dp[i][j])%mod;
  }
}
   int ans=0;
   F(i,1,n){
      ans=(ans+dp[a[i]+2000][b[i]+2000])%mod;
   }
   f[0]=1;
   F(i,1,30000)f[i]=f[i-1]*1ll*i%mod;
   inv[30000]=qpow(f[30000],mod-2);
   f(i,30000-1,0)inv[i]=1ll*inv[i+1]*(i+1)%mod;
//   F(i,1,30000)cout<<f[i]<<" "<<inv[i]<<endl;
   F(i,1,n){
     ans=(ans-f[a[i]+a[i]+b[i]+b[i]]*1ll*inv[b[i]+b[i]]%mod*inv[a[i]+a[i]]%mod+mod)%mod;
   }
    ans=(1ll*ans*qpow(2,mod-2))%mod;
   printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 81152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, s, cnt=0;
    cin >> n;
    if(n%2==0)
    cout<<fixed<<setprecision(10)<<(double)(n/2)/n;
    else 
        cout<<fixed<<setprecision(10)<<(double)((n+1)/2)/n;
}

Measured memory_bytes: 764
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		// create prime number list
		int max = (int)Math.sqrt(7368791)+5;
		while(true){	
			int m = sc.nextInt();
			int n = sc.nextInt();
			if(m==0 && n==0){
				break;
			}
			boolean[] flag = new boolean[7368800];
			Arrays.fill(flag,true);
			int now = 0;
			int count = 0;
			boolean f = false;
			for(int i=m;i<flag.length;i++){
				if(count==n){
					f = true;
				}
				if(flag[i]){
					if(f){
						now = i;
						break;
					}
					count++;
					for(int j=i*2;j<flag.length;j+=i){
						flag[j] = false;
					}
				}
			}
			System.out.println(now);
		}
	}
}

Measured memory_bytes: 58960
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int k = sc.nextInt();
		long[] a = new long[x];
		long[] b = new long[y];
		long[] c = new long[z];
		for (int i = 0; i < x; i++) {
			a[i] = sc.nextLong();
		}
		for (int i = 0; i < y; i++) {
			b[i] = sc.nextLong();
		}
		for (int i = 0; i < z; i++) {
			c[i] = sc.nextLong();
		}
		Arrays.sort(a);
		Arrays.sort(b);
		Arrays.sort(c);
		long[] ab = new long[x * y];
		for (int i = 0; i < x; i++) {
			for (int j = 0; j < y; j++) {
				ab[i * y + j] = a[i] + b[j];
			}
		}
		Arrays.sort(ab);
		long[] abc = new long[k * z];
		for (int i = x * y - 1; i >= Math.max(0, x * y - k); i--) {
			for (int j = 0; j < z; j++) {
				abc[(x * y - 1 - i) * z + j] = ab[i] + c[j];
			}
		}
		Arrays.sort(abc);
		for (int i = 0; i < k; i++) {
			System.out.println(abc[k * z - i - 1]);
		}
	}
}

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

//#include "atcoder.hpp"

long long gcd(long long a, long long b) {
    if (a>b) swap(a,b);
    
    auto r = b % a;
    
    return (r ? gcd(r, a) : a);
}

int main() {
    int N;string S;
    
    cin >> N >> S;
    
    int white = 0, black = 0;
  S = "." + S;
    for (auto i : S) {
        if (i == '#')
        black++;
        else white++;
    }
    auto it = S.rbegin();
    bool pre = true;
    int cnt = 0, now = 0, nowbr = black,  min = 99999999;
    while (it != S.rend()) {
        if (!pre && *it == '#') {
            if (cnt + nowbr < min)
                min = cnt + nowbr;
            now = cnt;
            pre = true;
        }
        else if (pre && *it == '.') {
            if (now + nowbr < min)
            min = now + nowbr;
            pre = false;
        }
        if (*it == '#') nowbr--;
        else cnt++;
        ++it;
    }

    cout << min << endl;
    
    return 0;
}



Measured memory_bytes: 772
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >> N;
	long long A[N];
	long long M = 1000;
	long long kab = 0;
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	for(int i=0;i<N-1;i++){
		if(A[i] <= A[i+1]){
			long long tmp = M / A[i];
			M %= A[i];
			kab += tmp;
		}
		else{
			M += A[i] * kab;
			kab = 0;
		}
	}
	M += A[N-1] * kab;
	cout << M << endl;
}


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

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

    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    if(K <= A) {
        cout << K << endl;
    } else if(K <= A + B) {
        cout << A << endl;
    } else {
        cout << A - (K - A - B) << endl;
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const string D_blue    = "\x1b[36m";
const string D_green   = "\x1b[32m";
const string D_red     = "\x1b[31m";
const string D_yellow  = "\x1b[33m";
const string Db_red    = "\x1b[41m";
const string Db_yellow = "\x1b[43m";
const string D_end     = "\x1b[39m";
const string Db_end    = "\x1b[49m";

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


Measured memory_bytes: 256
#include<cstdio>
int main()
{
     int n,k,ans,bbb;
     while(scanf("%d%d",&n,&k)==2)
     {
          ans=0;
          for(int i=81;i<=117;i=i+9)
          {
               int jj=0,tt=0;
               for(int j=i; ;j=j+63)
               {    jj++;
                    if(j%11==k)
                    {
                        if((n-2)<11){ans++;break;}
                        bbb=jj;
                     tt=(n-2)/11;
                     ans=ans+tt;
                     if((n-2)%11>=bbb)
                     ans++;
                     break;
                    }
                    if(jj+2>=n)break;
               }
          }
          printf("%d\n",ans);
     }
     return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	
	public static void Main(string[] args)
	{
 		var s = Console.ReadLine();
 		var n = s.Length;
 		
 		
 		if(!IsKaibun(s) || !IsKaibun(s.Substring(0, n/2)) || !IsKaibun(s.Substring((n+3)/2-1, n/2)))
 		{
 				Console.WriteLine("No");
 				return;
 		
 		}
 				Console.WriteLine("Yes");
 		
	}
	
	static bool IsKaibun(string s)
	{
		var n = s.Length;
		for(int i = 0; i < n / 2; i++)
 		{
 			if(s[i] != s[n - i - 1])
 			{
 				return false;
 			}
 		}
 		return true;
	}
	
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 13140
import java.util.Scanner

fun main(args: Array<String>) {
    try {
        val sc = Scanner(System.`in`)
        val n = sc.nextInt()
        var c = 0
        for (i in 0 until n) {
            val a = sc.nextInt()
            if (a < 2 || a > 100_000_000) {
                throw Exception("Illegal input.")
            }
            if (isPrimeFast(a)) c++
        }
        println(c)
    } catch (e: Exception) {
        println(e)
    }
}

fun isPrimeFast(a: Int): Boolean {
    val p = Math.sqrt(a.toDouble()).toInt()
    for (i in 2..p) {
        if (a % i == 0) {
            return false
        }
    }
    return true
}

fun isPrimeSlow(a: Int): Boolean {
    for (i in 2..a) {
        if (a % i == 0) {
            return false
        }
    }
    return true
}



Measured memory_bytes: 41384
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	unordered_set<long long> ks;
	long long n;
	cin >> n;

	auto check = [&](long long k) {
		if(k==1) return false;
		long long pw = 1;
		while(pw>0&&pw<=n) {
			if(pw==n) return true;
			pw = pw * k;
		}
		pw = 1;
		while(pw>0&&pw<=n/(1+k)){
			if(n%pw==0&& (n/pw-1)%k==0) return true;
			pw=pw*k;
		}
		return false;
	};

	for(long long k = 1; k * k <= n; k++) {
		if(n % k != 0) continue;
		if(check(k)) ks.insert(k);
		if(check(n/k)) ks.insert(n/k);
	}
	for(long long k = 1; k * k <= n - 1; k++) {
		if( (n-1) % k != 0) continue;
		ks.insert(k);
		ks.insert((n-1)/k);
	}
	ks.erase(1);
	cout << ks.size();
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main() {
	long long a, b, k;
	cin >> a >> b >> k;

	if (k > a) {
		k -= a;
		a = 0;
		b -= k;
		if (b < 0)b = 0;
	}
	else {
		a -= k;
	}

	cout << a << " " << b << endl;

	return 0;
}

//AAAAAAAAAAAAAAAAA
//int main() {
//	string s, t;
//	cin >> s >> t;
//
//	cout << t << s << endl;
//
//	return 0;
//}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
int MOD = 1000000007;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> dp(N + 1, 0);
  dp[0] = 1;
  for (int i = 0; i < M; i++){
    int a;
    cin >> a;
    dp[a] = -1;
  }
  for (int i = 1; i <= N; i++){
    if (dp[i] != -1){
      if (dp[i - 1] != -1){
        dp[i] += dp[i - 1];
      }
      if (i > 1){
        if (dp[i - 2] != -1){
          dp[i] += dp[i - 2];
        }
      }
    }
    dp[i] %= MOD;
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 640
def abc091_c():
    n = int(input())
    red = []
    blue = []
    for _ in range(n):
        a, b = (int(x) for x in input().split())
        red.append((a, b))
    for _ in range(n):
        c, d = (int(x) for x in input().split())
        blue.append((c, d))
    blue = sorted(blue, key=lambda x: x[0])

    ans = 0
    r_used = [False]*n
    for c, d in blue:
        match = -1
        y_high = -1
        for i, (a, b) in enumerate(red):
            if r_used[i]: continue
            if not (a < c and b < d): continue
            if y_high < b:
                match = i
                y_high = b
        if match != -1:
            ans += 1
            r_used[match] = True
    print(ans)

if __name__ == '__main__':
    abc091_c()

Measured memory_bytes: 9172