akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
///////////////////////////////////////////////////////////
int main(){
 ll n;sc(n);
 ll p,q;llfor;
 llpvec a(n),c(n);
 bool flag1[1000]={false},flag2[1000]={false};
 rep(i,0,n){
  sc(p);sc(q);a[i]={p,q};
 }
 rep(i,0,n){
  sc(p);sc(q);c[i]={p,q};
 }
 sort(a);sort(c);
 ll o,r;
 ll maxx,maxy;
 rrp(i,n,0){
  maxx=990;maxy=990;
  o=a[i].first;p=a[i].second;
  if(!flag1[i]){
   rrp(j,n,0){
    if(!flag2[j]){
     q=c[j].first;r=c[j].second;
     if(o<q&&p<r){
      if(maxy>r||maxy==990){maxy=r;maxx=j;}
     }
    }
   }
   //printf("%lld %lld\n",i,maxx);
   flag1[i]=true;flag2[maxx]=true;
  }
 }
 ll ans=0;
 rep(i,0,n){
  if(flag2[i]){ans++;}
 }
 pr(ans);
  
return 0;}

Measured memory_bytes: 256
n, q = gets.split.map(&:to_i)
s = gets.strip

ac = s.split('AC', -1)[0..-2].inject([]) do |memo, item|
  memo << ((memo.last || -2) + 2 + item.size)
end

arr = [0]
memo = 0

n.times.map do |i|
  if ac.first == i
    ac.shift
    memo += 1
  end
  arr << memo
end

q.times do
  l, r = gets.split.map(&:to_i)
  puts arr[r-1] - arr[l-1]
end


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

int n;
double p;

int main()
{
	cin >> n;

	if (n % 2 == 0)
		p = 0.5;
	else
		p = ((double)(n / 2) + 1) / (double)n;

	cout << p << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int L;
	cin >> L;
	int A[200000];
	rep(i, L) {
		cin >> A[i];
	}

	ll dp[200001][4];
	rep(i, 200001) rep(j, 4) dp[i][j] = 1e18;
	ll goukei = 0;
	rep(i, L) {
		dp[i + 1][0] = goukei + A[i] % 2;
		if (A[i]) dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + A[i] % 2);
		else dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + 2);

		dp[i + 1][1] = min(goukei, dp[i][1] + (A[i] + 1) % 2);
		dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + (A[i] + 1) % 2);

		if (A[i]) {
			if (A[i] >= 2) dp[i + 1][2] = goukei;
			else dp[i + 1][2] = goukei + 1;
			dp[i + 1][2] = min(dp[i + 1][2], dp[i][2] + A[i] % 2);
			dp[i + 1][2] = min(dp[i + 1][2], dp[i][1] + A[i] % 2);
		}
		else {
			dp[i + 1][2] = min(goukei, dp[i][2]) + 2;
			dp[i + 1][2] = min(dp[i + 1][2], dp[i][1] + 2);
		}
		dp[i + 1][3] = min(goukei, dp[i][1]);
		dp[i + 1][3] = min(dp[i + 1][3], dp[i][1]);
		dp[i + 1][3] = min(dp[i + 1][3], dp[i][2] + A[i] % 2);
		dp[i + 1][3] = min(dp[i + 1][3], dp[i][3] + A[i]);

		cesp(dp[i + 1][0]);
		cesp(dp[i + 1][1]);
		cesp(dp[i + 1][2]);
		ce(dp[i + 1][3]);


		goukei += A[i];
	}

	co(*min_element(dp[L], dp[L] + 4));

	Would you please return 0;
}

Measured memory_bytes: 7296
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}

fn main() {
    use std::collections::*;
    let N = get!(usize);
    let SPs = get!(String, isize; N);
    let mut map = HashMap::new();
    for (S, _) in SPs.clone() {
        map.insert(S, Vec::new());
    }
    for (i, &(ref S, P)) in SPs.iter().enumerate() {
        let mut vec = map.get_mut(S).expect("A");
        vec.push((i+1, P));
    }
    for vec in map.values_mut() {
        vec.sort_by_key(|x| -x.1);
    }
    let mut Ss = map.keys().collect::<Vec<_>>();
    Ss.sort();
    for S in Ss {
        for &(i, P) in map.get(S).expect("B") {
            println!("{}", i);
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
main()
{
	int n;
	string s;
	cin>>n>>s;
	
	for(int i=0;i<=s.length();++i)
	{
		int m=int(s[i]);
		if(m+n>90)
		{
			m=m+n-90;
			m+=64;
		}
		else m+=n;
		s[i]=char(m);
	}
	
	cout<<s<<endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    string s;cin >> s;
    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
        if(s[i]=='x') ans++;
    }
    if(ans>=8) puts("NO");
    else puts("YES");
    return 0;
}


Measured memory_bytes: 256
void main()
{
    long[] tmp = rdRow;
    long a = tmp[0], b = tmp[1];
    long c = tmp[2], d = tmp[3];
    long e = tmp[4], f = tmp[5];

    long x, y;
    double smax = -1.0;
    for (long i = 0; a * i <= f; ++i)
    {
        for (long j = 0, water = 100 * a * i; water <= f; ++j, water += 100 * b)
        {
            if (water == 0) continue;
            for (long k = 0; water + c * k <= f; ++k)
            {
                for (long l = 0, sugar = c * k; water + sugar <= f; ++l, sugar += d)
                {
                    if (smax < 100.0 * sugar / (water + sugar) && sugar <= water / 100 * e)
                    {
                        smax = 100.0 * sugar / (water + sugar);
                        x = water + sugar;
                        y = sugar;
                    }
                }
            }
        }
    }

    writeln(x, " ", y);
}

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

b = [abs(i) for i in a]

if (sum([i < 0 for i in a]) + sum([i == 0 for i in a])) % 2 == 0:
    print(sum(b))
else:
    print(sum(b) - min(b) * 2)

Measured memory_bytes: 19968
#include<bits/stdc++.h>
using namespace std;
int main() 
{
    long long a,b,c,d;
    // cout<<"Enter a,b,c,d:"<<endl;
    cin>>a>>b>>c>>d;
    long long x=a*c;
    long long y=a*d;
    long long w=b*c;
    long long z=b*d;
    long long i=max(x,y);
    long long j=max(w,z);
    cout<<max(i,j)<<endl;
    // cout<<x<<endl;
    
    return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(m);
    vector<int> d(m);
    for(int i = 0;i < n;i++)cin >> a.at(i) >> b.at(i);
    for(int i = 0;i < m;i++)cin >> c.at(i) >> d.at(i);
    vector<int> ans(n);
    for(int i = 0;i < n;i++){
        int min = INT_MAX;
        int memo, memoJ;
        for(int j = 0;j < m;j++){
            memo = abs(a.at(i) - c.at(j)) + abs(b.at(i) - d.at(j));
            if(min > memo){
                min = memo;
                memoJ = j;
            }
        }
        ans.at(i) = memoJ + 1;
    }
    for(int i = 0;i < n;i++){
        cout << ans.at(i) << endl;
    }
}

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

int n,m,L,a[2222],b[200000],dp[2002][2002];

int cost(int r,int l){ return (b[a[l]]-b[a[r]-1])/L; }

int dfs(int l,int r,int dep){
  if(dp[l][r]!=-1)return dp[l][r];
  if(dep==n)return dp[l][r]=max( cost(l,dep-1) , cost(r,dep-1) );
  if(dp[l][r]!=-1)return dp[l][r];
  return dp[l][r] = min( dfs(dep,r,dep+1)+cost(l,dep) , dfs(l,dep,dep+1)+cost(r,dep) );
}

signed main(){
  memset(dp,-1,sizeof(dp));
  cin>>n>>m>>L;
  r(i,n)cin>>a[i];
  r(i,m)cin>>b[i+1],b[i+1]+=b[i];
  sort(a,a+n);
  cout<<dfs(0,0,1)<<endl;
}


Measured memory_bytes: 35404
#include  <bits/stdc++.h>
#pragma GCC optimize ("O3")
using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }
const int N = (1<<21)+5; 
const ll mod  = 1e9+7 ; 
ll dp[N]; 
int n , a[21][21];

int main(){
	fastio; 
cin >> n ; 
for(int i =0 ; i<  n ; i++ )for(int j =0 ; j < n ; j++ )cin >> a[i][j] ; 
dp[0]=1; 
for(int W = 0 ; W < (1<<n) ; W++ ){
	int paired = 0 ; 
	for(int w = 0 ; w < n ; w++ ){
		paired += ((W&(1<<w))!=0) ; 
	}
	for(int w = 0 ; w < n ; w++ ){
		if(a[paired][w] && !(W&(1<<w)))
			dp[W|(1<<w)]+=dp[W] , dp[W|(1<<w)] %= mod ; 
	}
}
cout << dp[(1<<n)-1]<<endl; 
}

Measured memory_bytes: 16640
// #include<bits\stdc++.h>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

void solve(){
    int n;
    cin >> n;
    int arr[n];
    for(int i = 0; i < n; i++) cin >> arr[i];
    sort(arr, arr + n);
    int cnt = 0;
    for(int i = n - 1; i >= 0; i--){
        for(int j = i - 1; j >= 0; j--){
            for(int k = j - 1; k >= 0; k--){
                if (arr[i] == arr[j] || arr[j] == arr[k] || arr[i] == arr[k]) continue;
                else if(arr[k] + arr[j] > arr[i]) cnt++;
            }
        }
    }
    cout << cnt;
}

int main()
{   
    ios::sync_with_stdio(0);
    cin.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    solve();
}  

Measured memory_bytes: 3648
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        // Your code here!
        int K = int.Parse(Console.ReadLine());
        int ans = 0;
        
        if(K % 2 == 0)
        {
            ans = (K / 2) * (K / 2);
        }
        else
        {
            ans = (K / 2) * ((K / 2) + 1);
        }
        
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <unordered_map>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;
 
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define y1 abcde
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>
#define BUG cout << "acdsfas" << endl
#define int long long

struct seg {
    int l, r, val;
    bool operator < (const seg &b) const {
        return mp(l, r) < mp(b.l, b.r);
    }
};

const int mod = 1e9 + 7;
const ll inf = 2e15;
const int N = 2e5 + 15;
int n, m, dp[N], t[N << 2], add[N << 2];
multiset <pll> cur;
seg a[N];

inline void push(int v) {
    if(v < N + N) {
        t[v << 1] += add[v];
        t[v << 1 | 1] += add[v];
        add[v << 1] += add[v];
        add[v << 1 | 1] += add[v];
        add[v] = 0;
    }
}

int get(int v, int tl, int tr, int l, int r) {
    if(tl > r || tr < l)
        return -inf;
    push(v);
    if(tl >= l && tr <= r)
        return t[v];
    int mid = tl + tr >> 1;
    return max(get(v << 1, tl, mid, l, r), get(v << 1 | 1, mid + 1, tr, l, r));
}

void multiupdate(int v, int tl, int tr, int l, int r, int val) {
    if(tl > r || tr < l)
        return;
    push(v);
    if(tl >= l && tr <= r) {
        t[v] += val;
        add[v] += val;
        return;
    }
    int mid = tl + tr >> 1;
    multiupdate(v << 1, tl, mid, l, r, val);
    multiupdate(v << 1 | 1, mid + 1, tr, l, r, val);
    t[v] = max(t[v << 1], t[v << 1 | 1]);
}

vector <pll> ev[N];

main() {
    cin >> n >> m;
    for(int i = 1; i <= m; ++i) {
        cin >> a[i].l >> a[i].r >> a[i].val;
        ev[a[i].l].pb({a[i].l - 1, a[i].val});
        ev[a[i].r + 1].pb({a[i].l - 1, -a[i].val});
    }
    for(int i = 1, j = 1; i <= n; ++i) {
        for(pll x : ev[i])
            multiupdate(1, 0, n, 0, x.f, x.se);
        dp[i] = get(1, 0, n, 0, i - 1);
        multiupdate(1, 0, n, i, i, dp[i]);
    }
    cout << max(0LL, *max_element(dp + 1, dp + 1 + n)) << endl;
    return 0;
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector <ull> A(N, 0);
	vector <ull> B(N, 0);

	vector <pair<ull, ull>> P;
	for (int ii = 0; ii < N; ++ii){
		ull A, B;
		cin >> A >> B;
		P.push_back(make_pair(B, A));
	}

	sort(P.begin(), P.end());

	bool ans = true;
	ull time = 0;
	for (int ii = 0; ii < N; ++ii){
		time += P[ii].second;
		if (time > P[ii].first){
			ans = false;
			break;
		}
	}

	if (ans){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;		
	}


	return 0;
}


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

typedef long long ll;

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

    ll fraction = 1;
    ll power = 0;
    while(1){
        if (fraction >= k) break;
        fraction *= 2;
        ++power;
    }

    ll numerator = 1;
    for (int i = 2; i <= n; ++i){
        if (i >= k) numerator += fraction;
        else {
            ll f = i;
            int count = 0;
            while(1){ if (f >= k) break; f *= 2; ++count; }
            ll additional = pow(2,power-count);
            numerator += additional;
        }
    }

    fraction *= n;
    
    cout << fixed << setprecision(12);
    cout << (double)numerator / fraction << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class T> using MAX_pq = priority_queue<T>;
template <class T> using MIN_pq = priority_queue<T,vector<T>,greater<T>>;
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol Mod=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r,q;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol x;
  cin >>x>>n;
  vector<int> a(n);
  vector<int> de(3*x,0);
  for(auto&& o:a){
    cin >>o;
    de[o]++;
  }
  lol ans=mod;
  lol r=x,l=x;
  while(1){
    if(de[l]==0){
      ans=l;
      break;
    }
    if(de[r]==0){
      ans=r;
      break;
    }
    l--;
    r++;
  }
  cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 3644
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}



public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		FastScanner fs = new FastScanner();
		int X = fs.nextInt();

		int a = (int)(X / 500);
		int b = (int)((X - 500*a)/5);


		System.out.println(1000*a + 5*b);
	}

}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Prison | diff Prison.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Prison.cpp && ./a.out

/*
 
 5/25/2019
 
 5:05-
 
 */

const int MAX_N=1e6+1;
int L[MAX_N],R[MAX_N];
int N,M;

void solve() {
  int l=0,r=MAX_N;
  REP(i,M) {
    SMAX(l,L[i]),SMIN(r,R[i]);
  }
  int res=max(r-l+1,0);
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>M;
  REP(i,M) cin>>L[i]>>R[i];
  solve();
  
  return 0;
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

void solve(){
   int n,m,k;
   cin >> n >> m >> k;

   int a[n] , b[m];
   f(i,0,n) cin >> a[i];
   f(i,0,m) cin >> b[i];

   int ans = 0 ; 

   f(i,1,n) a[i] += a[i-1];
   f(i,1,m) b[i] += b[i-1];

   ans = upper_bound(b,b+m,k) - b;
   f(i,0,n) if(a[i] <= k){
      int it = upper_bound(b,b+m,k-a[i]) - b;
      ans = max(ans , i+1+it);
   }
   cout << ans << "\n";
}

int32_t main(){
   fast;
   int t = 1;
   // cin >> t;
   while(t--)  solve();   
}

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

#define reg register
#define pr std::pair<int, int>
#define fi first
#define se second
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define lep(i, l, r) for (int i = l; i < r; ++i)
#define irep(i, r, l) for (int i = r; i >= l; --i)
#define ilep(i, r, l) for (int i = r; i > l; --i)
#define Rep(i, n) rep(i, 1, n)
#define Lep(i, n) lep(i, 1, n)
#define IRep(i, n) irep(i, n, 1)
#define ILep(i, n) ilep(i, n, 1)
typedef long long ll;
typedef long double ld;

namespace modular {
    const int MOD = 1000000007;
    inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }
    inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }
    inline int mul(int x, int y) { return 1LL * x * y % MOD; }
    inline int qpow(int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x))
            if (y & 1)
                ans = mul(ans, x);
        return ans;
    }
}; // namespace modular

namespace Base {
    template <typename Tp> inline Tp input() {
        Tp x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-')
                y = -1;
            c = getchar();
        }
        if (c == EOF)
            return 0;
        while ('0' <= c && c <= '9')
            x = x * 10 + c - '0', c = getchar();
        return x *= y;
    }
    template <typename Tp> inline void read(Tp &x) { x = input<Tp>(); }
    template <typename Tp> inline void chmax(Tp &x, Tp y) { x < y ? x = y : 0; }
    template <typename Tp> inline void chmin(Tp &x, Tp y) { x > y ? x = y : 0; }
}; // namespace Base
using namespace Base;
/*----------------------------------------------------------------------------*/

#define MAX_N 200007

int N;

void solve() {
    int u = 0, v = 0;
    if (!(N & 1)) {
        lep(i, 2, N) if ((N ^ 1 ^ i) < N) {
            u = i, v = N ^ 1 ^ i;
            break;
        }
        if (!u) return puts("No"), void();
    }
    if (u == v) v += N;
    puts("Yes");
    for (int i = 2; i + 1 <= N; i += 2) {
        printf("%d %d\n", i, 1);
        printf("%d %d\n", i + 1, 1);
        printf("%d %d\n", i, i + 1 + N);
        printf("%d %d\n", i + N, i + 1);
    }
    printf("%d %d\n", N + 1, N + 3);
    if (u) {
        printf("%d %d\n", N, u);
        printf("%d %d\n", N * 2, v);
    }
}

int main() {
#ifdef LOCAL
    FIN("in");
#endif
    read(N);
    if (N <= 2) puts("No");
    else solve();
    return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
#define Fr(i,a,b) for(int i=a;i<=b;i++)
#define RF(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<ll,int>
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define vpii vector<pii>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
 
    int t=1;
   // cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vi a;
        vi b;
        int x,y;

        int sum=0;
        Fr(i,0,n-1){
            cin>>x>>y;
            a.pb(x);
            b.pb(y);
            sum+=x;
        }
        vvi dp(n+1,vi(min(k+1,sum+1),-1));
        dp[0][0]=0;
        ll ans=0;
        Fr(i,1,n){
            Fr(j,0,min(sum,k)){
                dp[i][j]=dp[i-1][j];
                if(j-a[i-1]>=0&&dp[i-1][j-a[i-1]]!=-1){
                    dp[i][j]=max(dp[i][j],dp[i-1][j-a[i-1]]+b[i-1]);
                }
                ans=max(ans,dp[i][j]);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
} 

Measured memory_bytes: 80256
#include <iostream>
#include <fstream>
#include <utility>
#include <queue>
#include <vector>
#include <array>
#include <stack>
#include <list>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define bs(n) (1ull<<(n))

int main() {
	int n, m;
	cin >> n >> m;
	int* a = new int[m], * b = new int[m], * c = new int[m];
	rep(i, m) cin >> a[i] >> b[i] >> c[i];
	int d[101][101];
	rep(i, 101)rep(j, 101)d[i][j] = 1000000000;
	rep(i, m) d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
	rep(i, 101)rep(j, 101)rep(k, 101)d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
	int r = 0;
	rep(i, m)if (d[a[i]][b[i]] < c[i])r++;
	cout << r << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string.h>
#include<iostream>
using namespace std;
int cmd(int a ,int b){
    return abs(a)>abs(b);
}
int arr[10000];
int main() {

    int n,x;
    cin >>n>>x;
    for(int i=0;i<n;i++)
        cin >>arr[i];
    int sum=0,cnt=0;
    for(int i=0;i<n;i++){
        if(x>=sum)
        cnt++;
        sum+=arr[i];
    }
    if(x>=sum)cnt++;
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 256
N,M=map(int,input().split())
p=[0]+list(map(int,input().split()))

P=[i for i in range(N+1)]
S=[1 for i in range(N+1)]

def find(a):
    if a==P[a]:
        return a
    else:
        return find(P[a])
        
def union(b,c):
    B=find(b)
    C=find(c)
    if S[B]<S[C]:
        P[B]=P[C]
        S[C]+=S[B]
    else:
        P[C]=P[B]
        S[B]+=S[C]
        
for i in range(M):
    x,y=map(int,input().split())
    union(x,y)
#print(P)
D={}

for i in range(1,N+1):
    D[p[i]]=i
    
#print(D2)
ans=0
for i in range(1,N+1):
    if find(i)==find(D[i]):
        ans+=1
print(ans)

Measured memory_bytes: 25424
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > bridge(m); // pair<int, int>の配列
    for(int i = 0; i < m; i++){
      cin >> bridge[i].first >> bridge[i].second; // .firstで1つ目 .secondで2つ目
    }
    sort(bridge.begin(), bridge.end(), greater<pair<int, int> >()); // pairに入れてsortすることで組を維持しながら並べ替えられる
                                       // greater<型>() をつけると降順
    int last = 1e9, cnt = 0; // 1e9 は (double)1*10^9
    for(int i = 0; i < m; i++){ // 東にある対立から順に
        if(last >= bridge[i].second){ // 行き来できるなら
            last = bridge[i].first; // 最後の破壊場所を西端に
            cnt++; // 回数をカウント
        }
    }
    cout << cnt;
}

Measured memory_bytes: 1024
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <iostream>
#include <algorithm>
using namespace std;

int N, ans = 0;
string s;

int main()
{
	cin >> N;
	cin >> s;
	int i = 0, j = N - 1;
	while(s[i] != 'W' && i <= N - 1)
		++i;
	while(s[j] != 'R' && j >= 0)
		--j;
	while(i < j)
	{
		++ans;
		++i;
		--j;
		while(s[i] != 'W' && i <= N - 1)
			++i;
		while(s[j] != 'R' && j >= 0)
			--j;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3756
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		LL cnt[10][10] = {};
		int n = -1;
		cin >> n;
		if (n < 0) return 0;
		for (int i = 1; i <= n; ++i) {
			string s = to_string(i);
			int a = s[0] - '0';
			int b = s.back() - '0';
			cnt[a][b] += 1;
		}
		LL ans = 0;
		for (int i = 1; i <= 9; ++i) {
			for (int j = 1; j <= 9; ++j) {
				ans += cnt[i][j] * cnt[j][i];
			}
		}
		cout << ans << endl;
	}
	return 0;
}


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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed(n) fixed << setprecision(n)
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

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

   int r,g,b,n,cnt=0,ans;
   cin>>r>>g>>b>>n;

rep(i,0,3001) rep(j,0,3001){
      ans = i*r + j*g;
      if(ans <= n && (n-ans) % b == 0) ++cnt;
   }

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

Measured memory_bytes: 896
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

int N;
long long H;
long long wield;
long long thrower;
vector < pair <long long, int> > katanas;
long long addThis;

int main()
{
	scanf("%d %lld", &N, &H);
	for(int i = 0; i < N; i++)
	{
		scanf("%lld", &wield);
		katanas.push_back(make_pair(wield, 0));
		scanf("%lld", &thrower);
		katanas.push_back(make_pair(thrower, 1));	
	}

	sort(katanas.begin(), katanas.end());
	
	// for(int i = 0; i < katanas.size(); i++)
	// {
	// 	cout << katanas[i].first << " " << katanas[i].second << "\n";
	// }
	int cnt = 0;
	long long sum = 0;
	// if(katanas[N - 1].second == 0)
	// {
	// 	while(sum > H)
	// 	{
	// 		sum += katanas[N - 1].first;
	// 		cnt++;
	// 	}
	// }
	// else
	
	for(int i = katanas.size() - 1; i >= 0; i--)
	{
		if(katanas[i].second == 0)
		{
			addThis = i;
			break;
		}
		else
		{
			sum += katanas[i].first;
			cnt++;
			if(sum >= H)
			{
				break;
			}
		}
	}

	// cout << sum << " " << cnt << " ";
	// cout << katanas.size();

	while(sum < H)
	{
		sum += katanas[addThis].first;
		cnt++;
	}
		
	printf("%d\n", cnt);
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 6256
/* Priyansh Agarwal*/
#include<bits/stdc++.h>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define nline "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define debug(x) cout << #x << " " << x <<endl;
#define set_bits __builtin_popcount
typedef long long ll;
typedef unsigned long long ull;
/*---------------------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod)
{ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
void extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size 3
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
ll combination(ll n, ll r, ll m, ll* fact) {ll val1 = fact[n]; ll val2 = mminvprime(fact[r], m); ll val3 = mminvprime(fact[n - r], m); return ((val1 * val2) % m * val3) % m;}
/*--------------------------------------------------------------------------------------------------------------------------*/
int main()
{
	fastio();
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
	freopen("Error.txt", "w", stderr);
#endif
	int n;
	cin >> n;
	ll arr[n];
	ll sum = 0;
	ll *occ = new ll[100001]();
	for (ll i = 0; i < n; i++)
	{
		cin >> arr[i];
		occ[arr[i]]++;
		sum += arr[i];
	}
	ll q;
	cin >> q;
	while (q--)
	{
		ll a, b;
		cin >> a >> b;
		sum += b * occ[a] - a * occ[a];
		occ[b] += occ[a];
		occ[a] = 0;
		cout << sum << endl;
	}
	return 0;
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

bool check(vector<int> &bingo, int i, int j, int k) {
    return bingo[i] == -1 && bingo[j] == -1 && bingo[k] == -1;
}

int main() {

    vector<int> bingo(9);
    rep(i, 9) cin >> bingo[i];

    int n;
    cin >> n;

    rep(f, n) {
        int a;
        cin >> a;

        rep(i, 9) if (bingo[i] == a) bingo[i] = -1;
    }

    bool b = false;
    b |= check(bingo, 0, 1, 2);
    b |= check(bingo, 3, 4, 5);
    b |= check(bingo, 6, 7, 8);
    b |= check(bingo, 0, 3, 6);
    b |= check(bingo, 1, 4, 7);
    b |= check(bingo, 2, 5, 8);
    b |= check(bingo, 0, 4, 8);
    b |= check(bingo, 2, 4, 6);

    if (b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
import numpy as np
N = int(input())
AllList = list(range(0, N))


Coord = [[] for _ in range(N)]
Distance = [[0 for _ in range(N)] for _ in range(N)]
for i in range(0, N):
    x, y = map(int, input().split())
    Coord[i] = [x, y]


count = 0
for i in range(0, N):
    for q in range(0, N):
        if i == q:
            continue
        Distance[i][q] = np.sqrt((Coord[i][0] - Coord[q][0]) ** 2 + (Coord[i][1] - Coord[q][1]) ** 2)
        count += Distance[i][q]
count = count / N
print(count)

Measured memory_bytes: 12424
import numpy as np
L=[]
bingo = np.zeros([3,3])
for i in range(3):
	L.append(input().split())
L = list(np.reshape(L,9))
N = int(input())
for i in range(N):
	l = input()
	if l in L:
		ptr = L.index(l)
		bingo[ptr/3,ptr%3]=1
#print(bingo)
ans = "No"
flg = 0
for i in range(3):
	flg = flg or bingo[i,0] and bingo[i,1] and bingo[i,2]
for i in range(3):
	flg = flg or bingo[0,i] and bingo[1,i] and bingo[2,i]
flg = flg or bingo[0,0] and bingo[1,1] and bingo[2,2]
flg = flg or bingo[2,0] and bingo[1,1] and bingo[0,2]
if flg == 1:
	ans = "Yes"
print(ans)

Measured memory_bytes: 12496
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
int main()
{
    int n,q; cin >> n >> q;
    vector<vector<int> > v(n);
    for(int i = 0; i < q; i++){
        int a; cin >> a;
        if(a == 0){
            int b,c; cin >> b >> c;
            v[b].push_back(c);
        }else if(a==1){
            int b; cin >> b;
            if(!v[b].empty()){
                cout << v[b].front() << endl;
            }
        }else{
            int b; cin >> b;
            if(!v[b].empty()){
                v[b].erase(v[b].begin());
            }
        }
    }
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    int n, h, w, count = 0;
    cin >> n >> h >> w;
    int a[n], b[n];
    rep(i, n){
        cin >> a[i] >> b[i];
    }
    rep(i, n){
        if(a[i] >= h && b[i] >= w) count++;
    }
    print(count);
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import re

n = input()
n = re.split(" ",n)

m = input()
m = re.split(" ",m)

a = int(n[0])* int(n[1])
b = (int(m[0]) * int(n[1])) + (int(m[1]) * int(n[0]))
b = a-b
c = int(m[0]) * int(m[1])
print(b+c)

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

int dp[100010];

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

    int n;
    cin >> n;
    
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    
    
    
    for(int i = 0; i < n; i++){
        if(i == 0) continue;
        else if(i == 1) dp[i] = dp[i-1]+abs(h[i]-h[i-1]);
        else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    
    cout << dp[n-1] << endl;
}


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

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    vector<ll> p(n), j(n), cj(n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> p[i];
      sum += p[i];
    }
    for (int i = 0; i < n - 1; i++) {
      cin >> j[i];
    }
    sort(j.rbegin(), j.rend());
    for (int i = 1; i < n; i++) {
      cj[i] = j[i - 1] + cj[i - 1];
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
      ans = max(ans, (n - i) * (sum + cj[i]));
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 4364
#include <cstdio>
#include <algorithm>
#include <vector>

int main() {
  size_t n, m;
  scanf("%zu %zu", &n, &m);

  std::vector<int> h(n);
  for (auto& hi: h) scanf("%d", &hi);

  std::vector<bool> ok(n, true);
  for (size_t i = 0; i < m; ++i) {
    size_t a, b;
    scanf("%zu %zu", &a, &b);
    --a, --b;
    if (!(h[a] < h[b])) {
      ok[b] = false;
    }
    if (!(h[b] < h[a])) {
      ok[a] = false;
    }
  }

  int res = 0;
  for (size_t i = 0; i < n; ++i)
    if (ok[i]) ++res;

  printf("%d\n", res);
}


Measured memory_bytes: 3232
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] a) throws IOException{

		String strLine ="";
		BufferedReader stdReader =
				new BufferedReader(new InputStreamReader(System.in));

		int i = 0;
		int max = 50;
		int[] tempInt = new int[2];

		while ( i <= max && ((strLine = stdReader.readLine()) != null) ){


				//??????????????§?????????
				String[] temp = strLine.split(" ",-10);
				tempInt[0] =Integer.parseInt(temp[0]);
				tempInt[1] = Integer.parseInt(temp[1]);

				int maxYakusu = 1;

				for(int k = tempInt[1]-1 ; k > 1 ; k--){

					if((tempInt[0]%k == 0)&&(tempInt[1]%k == 0)){
						tempInt[0] = tempInt[0]/k;
						tempInt[1] = tempInt[1]/k;
						maxYakusu = maxYakusu * k;


					}

				}


				//????°???¬?????°????±????????????????????´???????
				int maxBaisu = maxYakusu * tempInt[0] * tempInt[1];

				System.out.println(maxYakusu+" "+maxBaisu);
				i++;
		}

	}

}

Measured memory_bytes: 25768
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author hakamada
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Nikkei_1 solver = new Nikkei_1();
        solver.solve(1, in, out);
        out.close();
    }

    static class Nikkei_1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int X = in.nextInt();
            int Y = in.nextInt();

            int Max = Math.max(X, Y);

            int a = (X + Y);

            out.print(a - Max);
            out.print(" ");
            if ((a - N) < 0) {
                out.println(0);
            } else {
                out.println(a - N);
            }
        }

    }
}



Measured memory_bytes: 21204
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define ll long long
#define ull unsigned long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define lowbit(x) (x& -x)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define eps 1e-18
#define maxn 1000010
inline ll read(){ll tmp=0; char c=getchar(),f=1; for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1; for(;'0'<=c&&c<='9';c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-'0'; return tmp*f;}
inline ll power(ll a,ll b){ll ans=1; for(;b;b>>=1){if(b&1)ans=ans*a%mod; a=a*a%mod;} return ans;}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void swap(int &a,int &b){int tmp=a; a=b; b=tmp;}
using namespace std;
int a[maxn];
int n,k;
int main()
{
	n=read(); k=read();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
//	for(int i=1;i<=n;i++)printf("%d %d\n",i,a[i]);
	int ans=inf;
	for(int i=k;i<=n;i++)
		ans=min(ans,min(abs(a[i]),abs(a[i-k+1]))+a[i]-a[i-k+1]);
	printf("%d\n",ans);
	return 0;
}

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

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

    int h,w,k;
    cin >> h >> w >> k;

    vector<vector<char>> board(h,vector<char>(w));
    vector<int> num(h);
    vector<vector<int>> ans(h,vector<int>(w));

    rep(i,h){
        rep(j,w) {
            cin >> board[i][j];
            if(board[i][j] == '#') num[i]++;
        }
    }

    int cnt = 1;
    for(int i = 0; i < h; i++){
        if(i != 0 && num[i]) cnt = ans[i-1][w-1] + 1;
        bool first = false;
        for(int j = 0; j < w; j++) {
            if(num[i] == 0 && i != 0) {
                ans[i][j] = ans[i-1][j];
            } else if(num[i] == 0) {
                ans[i][j] = 0;
            } else {
                if(board[i][j] == '#' && first) cnt++;
                else if(board[i][j] == '#' && !first) first = true;
                ans[i][j] = cnt;
            }
        }
    }

    for(int i = h - 2; i >= 0; i--){
        for(int j = 0; j < w; j++){
            if(ans[i][j] == 0){
                ans[i][j] = ans[i+1][j];
            }
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	x=0;char c=getchar();bool f=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return  x;
}
template<class t> inline void write(t x){
	if(x<0){putchar('-'),write(-x);}
	else{if(x>9)write(x/10);putchar('0'+x%10);}
}

char s[100005];
int n;

signed main(){
	read(n);
	scanf("%s",s);
	for(int i=0;s[i];i++) putchar((s[i]-'A'+n)%26+'A');
}


Measured memory_bytes: 256