akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}



signed main(){
  int n,m; cin>>n>>m;
  if(n==m) cout << "Yes" << endl;
  else cout << "No" << endl;


  return 0;
}


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

int dp[100005];

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

    int arr[n];

    for(int i=0;i<n;i++)
        cin>>arr[i];


    dp[0]=0;
    if(n==1)
        cout<<0<<endl;

    else{
        dp[1]=abs(arr[1]-arr[0]);


        for(int i=2;i<n;i++){
            dp[i]=min((dp[i-1]+abs(arr[i]-arr[i-1])),dp[i-2]+abs(arr[i]-arr[i-2]));

        }
    }

    cout<<dp[n-1]<<endl;
    return 0;



}


Measured memory_bytes: 1024
// https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b
//
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::fmt::*;
use std::io::*;
use std::str::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        r: i32, g: i32, b: i32, n: i32
    };
    let mut total = 0;
    for i in 0..3001 {
        for j in 0..3001 {
            let left = n - i * r - j * g;
            if left < 0 {
                continue;
            }
            if left % b == 0 {
                total += 1;
            }
        }
    }
    println!("{}", total);
}


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

int main() {
    int d;
    cin >> d;
    if(d == 22) cout << "Christmas Eve Eve Eve";
    if(d == 23) cout << "Christmas Eve Eve";
    if(d == 24) cout << "Christmas Eve";
    if(d == 25) cout << "Christmas";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=1e3,MAX_M=2e3;
const ll MOD=1e9+7;
int N,M;
bool used[MAX_M];
ll X;
ll mstc;
struct edge{
	int to;
	ll cost;
	edge(int t=-1,ll c=0):to(t),cost(c){}
};
struct edge2{
	int u,v;
	ll w;
	edge2(int u=-1,int v=-1,ll w=0):u(u),v(v),w(w){}
	bool operator < (const edge2 &e)const{
		return w<e.w;
	}
};
edge2 E[MAX_M];
vector<edge> mst[MAX_N];
ll dst[MAX_N][MAX_N];
struct uf{
	vector<int> par,rank;
	void init(int n){
		par.resize(n);
		rank.resize(n);
		REP(i,n){
			par[i]=i;
			rank[i]=0;
		}
	}
	int fpar(int v){
		if (par[v]==v){
			return v;
		}
		return par[v]=fpar(par[v]);
	}
	void unite(int u,int v){
		u=fpar(u);
		v=fpar(v);
		if (u!=v){
			if (rank[u]<rank[v]){
				par[u]=v;
			}else{
				par[v]=u;
				if (rank[u]==rank[v]){
					rank[u]++;
				}
			}
		}
	}
	bool same(int u,int v){
		u=fpar(u);
		v=fpar(v);
		return u==v;
	}
};
void bfs(int s){
	fill(dst[s],dst[s]+N,-1);
	dst[s][s]=0;
	queue<int> que;
	que.push(s);
	while(!que.empty()){
		int v=que.front();
		que.pop();
		for(auto e:mst[v]){
			if (dst[s][e.to]==-1){
				dst[s][e.to]=max(dst[s][v],e.cost);
				que.push(e.to);
			}
		}
	}
}
ll mpw(ll n,ll m){
	ll ret=1;
	while(m){
		if (m&1){
			ret*=n;
			ret%=MOD;
		}
		n*=n;
		n%=MOD;
		m>>=1;
	}
	return ret;
}
ll solve(ll x){
	ll ret=0;
	if (mstc<x){
		ret+=(mpw(2,N-1)-2+MOD)%MOD*mpw(2,M-N+1)%MOD;
		ret%=MOD;
	}
	int cnt=0;
	REP(i,M){
		if (!used[i]){
			if (mstc+E[i].w-dst[E[i].u][E[i].v]<x){
				cnt++;
			}
		}
	}
	ret+=(2*(mpw(2,cnt)-1+MOD)%MOD*mpw(2,M-N+1-cnt)%MOD);
	ret%=MOD;
	return ret;
}
int main(){
	cin>>N>>M>>X;
	REP(i,M){
		int u,v;
		ll w;
		cin>>u>>v>>w;
		u--;
		v--;
		E[i]=edge2(u,v,w);
	}
	{
		uf u;
		u.init(N);
		sort(E,E+M);
		REP(i,M){
			edge2 e=E[i];
			if (!u.same(e.u,e.v)){
				u.unite(e.u,e.v);
				mstc+=e.w;
				used[i]=true;
				mst[e.u].push_back(edge(e.v,e.w));
				mst[e.v].push_back(edge(e.u,e.w));
			}
		}
	}
	REP(v,N){
		bfs(v);
	}
	cout<<(solve(X+1)-solve(X)+MOD)%MOD<<endl;
	return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod = 1000000007;

const int MAX = 300005;
using namespace std;

	

//Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1
///    *check mod
///    *check input file  
///    *NO IDIOT SUBMISSION
int main(){
	IOS ;
	int a , b  ; cin >> a >> b ;
	if((a + b) % 2 == 0)cout << (a + b) / 2 << endl ;
	else cout << "IMPOSSIBLE" << endl ;
	return 0;
}





Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int N;
  	cin>>N;
  	int L[N];
  	rep(i,N) cin>>L[i];
  	sort(L,L+N);
  	int count=0;
  	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			for(int k=j+1;k<N;k++){
             	if(L[i]+L[j]>L[k]) count++; 
            }
        }
    }
  	
  	cout<<count<<endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(),d.end());
    cout << d[n/2]-d[(n-1)/2] << "\n";
    return 0;
}   

Measured memory_bytes: 3728
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N,M,X;
	vector<int> A;
	cin >> N >> M >> X;
	A.resize(M);
	for(int i=0;i<M;i++) cin >> A[i];
	
	vector<int> c(N + 10);
	for(auto n : A) c[n] = 1;
//for(int i=0;i<c.size();i++) cout << c[i] << " " ; cout << endl;	
	
	int l = 0;
	for(int i=0;i<=X;i++) l += c[i];
	
	int r = 0;
	for(int i=X;i<=N;i++) r += c[i];
	
	cout << min(l, r) << endl;
	
	
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int X,N;cin>>X>>N;
  set<int>S;
  for(int i=0;i<N;i++){
  int a;cin>>a;
    S.insert(a);
  }int ans=0;int d=X;
  for(int i=0;i<=101;i++)
    if(!S.count(i)){if(abs(X-i)<d){ans=i;d=abs(X-i);}}
                    cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3612
<?php

$line = fgets(STDIN);

$lines = explode(" ", $line);

$lines[0] = trim($lines[0]);
$lines[1] = trim($lines[1]);
$lines[2] = trim($lines[2]);

if ($lines[0] < $lines[1] and $lines[1] < $lines[2]){
    echo "Yes";
}else{
    echo "No";
}
?>

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

const int MAXN = 4e5 + 10; //dummy
const ll MOD = 1e9 + 7;

template<typename T>
T fast_powerModulo( T a, T b, T M){T res = (T)1;a %= M;while( b ){if( b & 1 ) res = (res * a) % M;b >>= 1;a *= a;a %= M; }return res;}

void solve(){
	ll h ;
	int n;
	cin >> h >> n;
	ll sum = 0;
	for(int i = 0; i < n; ++i){
		ll x;
		cin >> x;
		sum += x;
	}
	if( sum >= h) cout << "Yes\n";
	else cout << "No\n";
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
	//int t; cin >> t;
	//while( t-- )
		solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=4005,M=998244353;
int n,m,fac[N],inv[N],fac2[N];
int ksm(int x,int y){
	if (!y)return 1;
	int z=ksm(x,y/2);
	z*=z;z%=M;
	if (y&1)z*=x;
	return z%M;
}
int C(int x,int y){
	if (x<y)return 0;
	return fac[x]*inv[y]%M*inv[x-y]%M;
}
signed main(){
	scanf("%lld%lld",&m,&n);
	fac[0]=inv[0]=fac2[0]=1;
	for (int i=1;i<N;i++)fac[i]=fac[i-1]*i%M,inv[i]=ksm(fac[i],M-2),fac2[i]=fac2[i-1]*2%M;
	for (int i=2;i<=2*m;i++){
		int ans=0,cnt=0;
		for (int j=1;j<=m;j++)
			if (i-j<=0||i-j>m)cnt++;
		int num=(m-cnt)/2;	
		if (i%2==0){
			for (int j=0;j<=num;j++)
				(ans+=C(num,j)*fac2[j]%M*C(n+cnt-1,j+cnt-1))%=M;
			for (int j=0;j<=num;j++)
				(ans+=C(num,j)*fac2[j]%M*C(n+cnt-2,j+cnt-1))%=M;
			printf("%lld\n",ans);		
		}
		else {
			for (int j=0;j<=num;j++)
				(ans+=C(num,j)*fac2[j]%M*C(n+cnt-1,j+cnt-1))%=M;
			printf("%lld\n",ans);
		}
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  int n;
  cin >> n;
  vector<ll> cnt;
  cnt.assign(1e5+10, 0);
  rep(i, n) {
    int a;
    cin >> a;
    if(a == 0) {
      cnt[a]++;
      cnt[a+1]++;
    } else {
      cnt[a-1]++;
      cnt[a]++;
      cnt[a+1]++;
    }
  }

  ll ans = 0;
  rep(i, 1e5+10) {
    ans = max(ans, cnt[i]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

S = input()

if S[-1] == 's':
    print(S + 'es')
else:
    print(S + 's')

Measured memory_bytes: 78048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string a, b;
int main() {
	cin >> a;
	cin >> b;
	int i, j;
	int n = a.size(), m = b.size();
	int mi = m;
	for (i = 0; i < n; ++i) {
		if (i + m > n)break;
		int cnt = 0;
		for (j = 0; j < m; ++j) {
			if (a[i + j] == b[j])++cnt;
		}
		mi = min(mi, m - cnt);
	}
	cout << mi << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
#define rep(n) for(ll i=0; i<n; i++)
#define MAX_V 100001
const ll INF = 1e+9;
const ll MOD = 1000000007;

ll pow(ll x, ll a)
{
  if(a==0) return 1;
  ll y = pow(x, a/2);
  y *= y;
  if(a%2==1) y *= x;
  return y;
}

bool bit(ll x, ll i)
{
  return (x >> i) & 1;
}

void res(const vector<ll>& D, const P& R, bool isEven)
{
  ll U = pow((ll)2, (ll)31) -1 + R.first;
  U /= 2;
  ll V = pow((ll)2, (ll)31) -1 + R.second;
  V /= 2;

  if(isEven) printf("R");

  for (ll i = 0; i < 31; i++)
  {
    if(bit(U, i))
    {
      if(bit(V,i))
      {
        printf("R");
      } else {
        printf("U");
      }
    } else {
      if(bit(V,i))
      {
        printf("D");
      } else {
        printf("L");
      }
    }
  }
  printf("\n");
}

int main()
{
  ll n;
  cin >> n;
  vector<P> pos;
  for (ll i = 0; i < n; i++)
  {
    ll x, y;
    cin >> x >> y;
    pos.emplace_back(x+y, x-y);
  }

  for (ll i = 0; i < n-1; i++)
  {
    if(abs(pos[i].first)%2 != abs(pos[i+1].first)%2)
    {
      cout << -1 << endl;
      return 0;
    }
  }

  vector<ll> D;
  D.push_back(1);
  for (ll i = 0; i < 30; i++)
  {
    D.push_back(D[i]*2);
  }
  
  bool isEven = pos[0].first % 2 == 0;
  if(isEven)
  {
    for (ll i = 0; i < n; i++)
    {
      pos[i].first--;
      pos[i].second--;
    }    
    printf("32\n");
    printf("1 ");
  } else {
    printf("31\n");
  }

  for(auto d:D) printf("%d ", d);
  printf("\n");

  for (ll i = 0; i < n; i++)
  {
    res(D, pos[i], isEven);
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define true 1
#define false 2

int A[2000],n;
int main(){
  int q,m,i,judge;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    judge=solve(0,m);
    if(judge==true)
      printf("yes\n");
    if(judge==false)
      printf("no\n");
  }
  return 0;
}

solve(i,m){
  int res;
  if (m==0){
    return true;
    }
  if(i>=n){
    return false;
  }
  if(solve(i+1,m)==true){
    res = solve(i+1,m);
    return res;
  }
  if(solve(i+1, m - A[i])==true){
    res = solve(i+1, m - A[i]);
    return res;
  }
  return false;
}




Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int N;
    cin >> N;
    vector<int> b(N);
    rep(i,N) cin >> b[i];
    
    rep(i,N) if(b[i] > i+1){
        cout << -1 << endl;
        return 0;
    }
    
    vector<int> ans;
    
    for (int i = 0; i < N; i++) {
        int a = 0;
        for (int j = 0; j < N-i; j++) {
            if(b[j] == j+1) a = max(a, j+1);
            
        }
        ans.push_back(a);
        b.erase(b.begin()+a-1);
    }
   
    rep(i,N) cout << ans[N-i-1] << endl;
    
    return 0;
}



Measured memory_bytes: 256
import java.io.IOException
import java.io.PrintWriter
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner()
    val n = sc.nextInt()
    val k = sc.nextLong()
    val q = sc.nextInt()
    val a = IntArray(q)
    (0 until q).forEach { a[it] = sc.next().toInt() }
    problem141c(n, q, k, a)
}

fun problem141c(n: Int, q: Int, k: Long, a: IntArray): String {
    val out = PrintWriter(System.out)
    val dp =  LongArray(n)
    for (i in 0 until q) {
        val winner = a[i]
        dp[winner - 1] = dp[winner - 1] + 1
    }
    for (element in dp) {
        out.println(if (q - k >= element) "No" else "Yes")
    }
    out.flush()
    return ""
}

class FastScanner {
    private val `in` = System.`in`
    private val buffer = ByteArray(1024)
    private var ptr = 0
    private var buflen = 0
    private fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            try {
                buflen = `in`.read(buffer)
            } catch (e: IOException) {
                e.printStackTrace()
            }

            if (buflen <= 0) {
                return false
            }
        }
        return true
    }

    private fun readByte(): Int {
        return if (hasNextByte()) buffer[ptr++].toInt() else -1
    }

    private fun isPrintableChar(c: Int): Boolean {
        return c in 33..126
    }

    operator fun hasNext(): Boolean {
        while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++
        return hasNextByte()
    }

    operator fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b)
            b = readByte()
        }
        return sb.toString()
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n: Long = 0
        var minus = false
        var b = readByte()
        if (b == '-'.toInt()) {
            minus = true
            b = readByte()
        }
        if (b < '0'.toInt() || '9'.toInt() < b) {
            throw NumberFormatException()
        }
        while (true) {
            if ('0'.toInt() <= b && b <= '9'.toInt()) {
                n *= 10
                n += (b - '0'.toInt()).toLong()
            } else return if (b == -1 || !isPrintableChar(b)) {
                if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextInt(): Int {
        val nl = nextLong()
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun nextDouble(): Double {
        return java.lang.Double.parseDouble(next())
    }
}

Measured memory_bytes: 39164
n, m = map(int, input().split())

A = [input() for _ in range(n)]
B = [input() for _ in range(m)]

def issubset(l, u, r, d):
    for i, y in enumerate(range(u, d)):
        for j, x in enumerate(range(l, r)):
            res = A[y][x] == B[i][j]
            if not res:
                return False
    return True

if n == m:
    if issubset(0, 0, n, n):
        print("Yes")
    else:
        print("No")
    exit()

for y in range(n - m):
    for x in range(n - m):
        if issubset(x, y, x+m, y+m):
            print("Yes")
            exit()

print("No")

Measured memory_bytes: 3064
def main():
    n = int(input())
    a = [list(map(int, input().split())) for _ in range(2)]
    
    ans = 0
    for i in range(1, n +1):
        ans = max(ans, sum(a[0][:i])+sum(a[1][i - 1:]))
    
    print(ans)
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int main(){
	int n, m, x;
	
	cin >> n >> m >> x;
	
	int u = n, d = 0;
	
	REP(i, m){
		int a;
		
		cin >> a;
		
		if (a > x) break;
		
		d++;
	}
	
	u = m - d;
	
	cout << min(u,d) << endl;
	
	return 0;
}

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

const int N=1e4;

int d()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
long long lld()
{
    long long ret;
    scanf("%lld", &ret);
    return ret;
}
ll mod(ll a,ll b)
{
    return ((a%b +b)%b);
}

ll floor(ll a, ll b)
{
    return (a-mod(a, b))/b;
}

vector<ll> getDivisorsN(ll n)        //O(n)
{
    vector<ll> ret;
    for(ll i = 1 ; i <= n ; ++i)
        if(n%i == 0)    ret.push_back(i);
    return ret;
}
map<ll,ll>f;
vector<long long>vp;
void getDivisors(ll n)        //O(sqrt(n))
{

    ll i;
    for(i = 1 ; i < n/i ; ++i)
    {
        if(n%i == 0)
        {
            f[i]++;
            f[n/i]++;
            if(f[i]==2) vp.push_back(i);
            if(f[n/i]==2) vp.push_back(n/i);

        }
    }
    if(i == n/i && n%i==0)
    {
        f[n/i]++;
        if(f[n/i]==2)
            vp.push_back(n/i);

    }


}
//////////////////////////////////////////////////
vector<ll> getMultiples(ll x, ll n)
{
    vector<ll> ret;
    for(ll m = x ; m <= n ; m += x)
        ret.push_back(m);
    return ret;
}

// bool is_prime[N];
/*
vector<ll>v;

bitset<N> is_prime;
void sieve()        //O(N*log(log(n))) ~= O(N)
{
    v.push_back(1);
    // fill(is_prime, is_prime+N, 1);       //with arrays
    is_prime.set();     //fills with 1
    is_prime[0] = is_prime[1] = 0;
    for(ll p = 2 ; p <= N ; ++p)
        if(is_prime[p])
        {
            v.push_back(p);
            for(ll m = p*p ; m < N ; m += p)
                is_prime[m] = 0;

        }
}
vector<pair<ll, ll>> factorize(ll n)
{
    vector<pair<ll, ll> > ret;
    for(ll p = 2 ; p <= n/p ; ++p)
    {
        int e = 0;
        while(n%p == 0)
        {
            n /= p;
            ++e;
        }
        if(e)   ret.push_back({p, e});
    }
    if(n > 1)   ret.push_back({n, 1});
    return ret;
}
*/

int gcd(int a,int b)
{
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int arr[N];
int main()
{

    int n=d(),sum=0;
    for(int i=0;i<n;i++){ scanf("%d",arr+i); sum+=arr[i];}
    int t=d();

    while(t--){
        int x=d();int p=d();
        cout<<sum-arr[x-1]+p<<endl;;
    }




}


Measured memory_bytes: 256
import sys
import math
from collections import Counter
import itertools
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

b=SR()
if b=='A':
    print('T')
elif b=='T':
    print('A')
elif b=='C':
    print('G')
else:
    print('C')



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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  while(1){
    cin >> n;
    if(n==0) return 0;
    vector<int> a(26,0);
    char c;
    int ma=0,num=0,count=0;
    bool flag,ansflag=false;
    int ansa=-1,ansb;
    for(int i=0;i<n;i++){
      cin >> c;
      a[c-'A']++;
      for(int j=0;j<26;j++){
        if(a[j]>ma){
          ma=a[j];
          num=j;
        }
        if(!ansflag){
          flag=true;
          for(int j=0;j<26;j++){
            if(j!=num){
              if(a[j]+(n-i-1)>=ma){
                flag=false;
              }
            }
          }
          if(flag){
            ansa=num;
            count=i+1;
            ansb=count;
            ansflag=true;
          }
        }
      }
    }

    if(ansa==-1){
      cout << "TIE" << endl;
    }else{
      cout << (char)(ansa+'A') << " " << ansb << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3020
#include <bits/stdc++.h>
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

using namespace std;

int gcd(int a, int b) {
    return (b)? gcd(b,a%b):a;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
//    cout << gcd(a,b) << '\n';
    cout << (((long long)a * b)/gcd(a,b)) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int i = 0;
string W;
string T;
string freqstr;
map<string,int> Map;

int main()
{
  cin >>W;
  transform(W.begin(),W.end(),W.begin(),::toupper);
  while(cin>>T,T !="END_OF_TEXT"){
    transform(T.begin(),T.end(),T.begin(),::toupper);
    if(i <++Map[T]){
      i = Map[T];
      freqstr = T;
  }
  }
      cout <<i<<endl;

  return 0;
}

Measured memory_bytes: 1204
//#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) + 1;
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
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 h,w;
vector<string> s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h>>w;
    for (int i = 0; i < h; i++)
    {
        string temp;
        cin >> temp;
        s.push_back(temp);
    }
    vector<vector<int>> dp(h,vector<int>(w,INF));
    if(s[0][0]=='#')dp[0][0]=1;
    else{
        dp[0][0]=0;
    }
    rep(i,h){
        rep(j,w){
            if(i+1<h){
                if(s[i][j]=='.'&&s[i+1][j]=='#')
                dp[i+1][j]=min(dp[i+1][j],dp[i][j]+1);
                else
                dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            }
            if(j+1<w){
                if(s[i][j]=='.'&&s[i][j+1]=='#')
                dp[i][j+1]=min(dp[i][j+1],dp[i][j]+1);
                else
                dp[i][j+1]=min(dp[i][j+1],dp[i][j]);
            }
        }
    }
    cout << dp[h-1][w-1]<< "\n";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  string s; cin >> s;
  bool a = s[0] == s[1] && s[0] == s[2];
  bool b = s[1] == s[2] && s[1] == s[3];
  if (a || b) COUT("Yes");
  else COUT("No");
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  int ev_cnt = 0, od_cnt = 0;
  for(int i=0;i<s.size();i++){
  	if(i%2 == 0){
      if(s[i] == '0') od_cnt++;
      else ev_cnt++;
    }else{
      if(s[i] == '0') ev_cnt++;
      else od_cnt++;
	}
  }
  cout << min(ev_cnt, od_cnt) << endl;
}

Measured memory_bytes: 512
from pprint import pprint
import sys

s = sys.stdin.readline().strip()
t = sys.stdin.readline().strip()

len_s = len(s)
ss = s+s
 
#table[ord(t)-97][i] = 文字tがi番目orそれ以降で登場する最初のindex
table = [[-1] * (len_s * 2) for _ in range(26)]
prev = [-1] * 26
for i,c in enumerate(ss):
    c_index = ord(c)-97
    # table[c_index][prev[c_index]+1:i+1] = [i] * (i - prev[c_index])
    for j in range(prev[c_index] + 1, i + 1):
        table[c_index][j] = i
    prev[c_index] = i
# pprint(table)

ans = 0
now = 0
for i in t:
    pos = table[ord(i)-97][now]
    if pos == -1:
        print(-1)
        exit()

    ans += pos + 1 - now
    now = ans % len_s

print(ans)

Measured memory_bytes: 83948
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
d=[a[i]-b[i] for i in range(n)]
d.sort()

if sum(a) < sum(b):
  print(-1)
  exit()

diff = 0
ct = 0
for i in range(n):
  if b[i] > a[i]:
    ct += 1
    diff += b[i] - a[i]

while diff > 0:
  ct += 1
  diff = diff - d[-1]
  del d[-1]

print(ct)

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

using namespace std;

void b_i_miss_you(void) {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		cout << "x";
	}
	cout << endl;
}

int main()
{
    b_i_miss_you();

    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){	cerr<<x<<endl;	}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){	cerr<<x<<" , ";	_DO(tail...);	}
#else
#define debug(...)
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define mkp make_pair
#define pb push_back
#define IOS do{ios_base::sync_with_stdio(0); cin.tie(0);}while(0)
const ll INF=4e18;
const ll MAX=1e5+5;
const ll MOD=1e9+7;
//}}}
int n;
int A[MAX];
vector<int> adj[MAX];
bitset<MAX> win,arv;
void dfs(int now){
	arv[now]=1;
	bool meetlose=0;
	for(int i:adj[now]){
		if(!arv[i])	dfs(i);
		if(!win[i])
			meetlose=1;
	}
	if(meetlose)
		win[now]=1;
}
int main(){
	IOS;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>A[i];
	}
	for(int i=1;i<n;i++){
		int a,b;
		cin>>a>>b;
		if(A[a]>A[b])
			adj[a].pb(b);
		else if(A[b]>A[a])
			adj[b].pb(a);
	}
	for(int i=1;i<=n;i++){
		if(!arv[i])
			dfs(i);
		if(win[i])
			cout<<i<< ' ';
	}
	cout<< '\n';
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

const int match[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const string SINF = "-";

vector<string> dp(10100, SINF);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for(int i = 0; i < m; i++) {
        cin >> a[i];
    }
    dp[0] = "";
    for(int i = 0; i <= n; i++) {
        if(dp[i] == SINF) {
            continue;
        }
        for(int j = 0; j < m; j++) {
            if(i + match[a[j]] <= n) {
                string tmp = dp[i] + to_string(a[j]);
                int nxt = i + match[a[j]];
                if(dp[nxt].size() < tmp.size() ||
                   (dp[nxt].size() == tmp.size() && dp[nxt] < tmp)) {
                    dp[nxt] = tmp;
                }
            }
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 33024
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>
#include<numeric>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

int main() {
	long long N, K, cnt = 0, tmp, ans = 0;

	cin >> N;
	vector<long long> d(N);

	for (auto &x : d) {
		cin >> x;
	}
	sort(d.begin(), d.end());

	cout << d[N / 2] - d[N / 2 - 1];


	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string.h>

using namespace std;
 
int main(){
  char S[100];
  int cnt = 0;
  
  cin >> S;
  int len = strlen(S);
  
  for(int i = 0;i < len/2;i++){
    if(S[i] != S[len-1-i]){
      cnt++;
    }
  }
  
  cout << cnt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lli long long int
int main(){
    fast;
    lli x,k,d,ld=0;
    cin>>x>>k>>d;
    if(x<0)x=-x;
    if(k<=x/d)cout<<x-k*d;
    else{
        k-=x/d;
        if(k%2==0)cout<<x%d;
        else cout<<abs(x%d-d);
    }
}

Measured memory_bytes: 3664
#include <iostream>
#include <string.h>
using namespace std;

int main(){
  string s, p, ss;

  cin>>s>>p;
  ss=s+s;
  if(ss.find(p)!=-1){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

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

	vector<int64_t> H(N);
	vector<bool> isGood(N, true);

	vector<vector<int>> E(N);

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

	for (int i = 0; i < M; ++i)
	{
		int a, b;
		cin >> a >> b;
		--a; --b;
		E[a].push_back(b);
		E[b].push_back(a);
	}

	for (int i = 0; i < N; ++i)
	{
		if (!isGood[i])
		{
			continue;
		}

		for (auto e : E[i])
		{
			if (H[i] > H[e])
			{
				isGood[e] = false;
			}
			else if (H[i] == H[e])
			{
				isGood[i] = false;
				isGood[e] = false;
			}
			else
			{
				isGood[i] = false;
			}
		}
	}

	int count = 0;
	for (int i = 0; i < N; ++i)
	{
		if (isGood[i])
		{
			++count;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 8980
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

ll x;

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> x;
    ll y = x / 500;
    ll z = (x%500)/5;

    cout << y*1000 + z*5 << "\n";

    return 0;
}


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

using namespace std;

void Main() {
    string N;
    cin >> N;
    bool reversible = (N[0] == N[2]);

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

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

using namespace std;
#define inf 10000000000LL
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,int> ii;
typedef pair<ii,int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int maxn = 1e5 + 5;

viii listBil;

bool cmp(iii a, iii b){
	if(a.first.first == b.first.first){
		return a.second < b.second;
	}
	return a.first.first > b.first.first;
}

int main(){
	int n;
	ll h;
	ll a[maxn],b[maxn];
	int i,j;
	ll ans = inf;
	scanf("%d %lld",&n,&h);
	for(i=0;i<n;i++){
		scanf("%lld %lld",&a[i],&b[i]);
		iii pas1 = make_pair(ii(a[i],i),1);
		iii pas2 = make_pair(ii(b[i],i),2);
		listBil.pb(pas1); listBil.pb(pas2);
	}

	sort(listBil.begin(), listBil.end(), cmp);
	ll health = h;
	vector<bool> isVisited;
	isVisited.assign(maxn,false);
	ll banyakTebasan = 0;
	//metode kurangin semua dengan id2 sampe ketemu id 1, lalu bagi habis
	for(i=0;i<listBil.size();i++){
		iii bil = listBil[i];
		ll damage = bil.first.first;
		int idx = bil.first.second;
		int id = bil.second;

		if(id==2){
			health-=damage;
			banyakTebasan++;
			isVisited[idx] = true;
			if(health<=0){break;}
		}else{
			if(isVisited[idx]){continue;}
			if(health%damage==0){
				banyakTebasan+=(health/damage);
			}else{
				banyakTebasan+=((health/damage)+1);
			}
		}
		
	}
	if(health>0){banyakTebasan = inf; ans = min(ans,banyakTebasan);}
	else{ans = min(ans,banyakTebasan);}
	//printf("ans: %lld\n",ans);
	health = h;
	//metode 2..cek idx1 tertinggi, 
	for(i=0;i<maxn;i++){isVisited[i] = false;}
	int indeks;
	for(i=0;i<listBil.size();i++){
		iii bil = listBil[i];
		ll damage = bil.first.first;
		int idx = bil.first.second;
		int id = bil.second;

		if(id==1){
			indeks = idx;
			break;
		}
	}

	int idx = i;
	//printf("indeks: %d idx: %d\n",indeks,idx);
	banyakTebasan = 0;
	for(i=0;i<idx;i++){
		iii bil = listBil[i];
		ll damage = bil.first.first;
		int idx = bil.first.second;
		int id = bil.second;

		if(idx!=indeks && id==2){
			health-=damage;
			isVisited[idx] = true;
			banyakTebasan++;
			if(health<=0){
				break;
			}
		}
	}
	if(health<=0){
		//printf("masuk sini\n");
		ans = min(ans,banyakTebasan); printf("%lld\n",ans); return 0;
	}
	//printf("health: %lld\n",health);
	if((health-b[indeks])<=0){
		//printf("masuk sini\n");
		banyakTebasan++;
		ans = min(ans,banyakTebasan);
		printf("%lld\n",ans); 
	}else{
		ll sisa = health-b[indeks];

		// printf("sisa: %lld\n",sisa);
		// printf("banyakTebasan: %lld\n",banyakTebasan);
		ll banyak = sisa/a[indeks] + 1;
		// printf("banyak: %lld\n",banyak);
		if(sisa%a[indeks]!=0){
			banyak++;
		}
		ans = min(ans,banyakTebasan+banyak);
		printf("%lld\n",ans);
	}



	return 0;
};

Measured memory_bytes: 9584
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define divceil(a, b) ((a) + (b)-1) / (b)
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;


int solve() {
    ll k;cin>>k;
    string s;cin>>s;
    if (sz(s)<=k){
        cout << s << endl;
    }
    else{
        cout << s.substr(0, k) + "..." << endl;
    }
    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


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

const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;


int main() {
  int a, b;
  cin >> a >> b;
  cout << max(a+b,max(a-b,a*b)) << endl;
}


Measured memory_bytes: 256
N, D, A = map(int, input().split())
H = [list(map(int, input().split())) for i in range(N)]
H.sort(key = lambda x:x[0])
INF = int(1e18)
H.append((INF, INF))

ans = 0
S = [0] * (N + 1)
l, r = 0, 0
while l < N:
    while H[r][0] - H[l][0] <= D * 2: r += 1
    h = H[l][1] - S[l]
    num = (h - 1) // A + 1 if h > 0 else 0
    ans += num
    S[l] += A * num
    S[r] -= A * num
    l += 1
    S[l] += S[l - 1]
print(ans)


Measured memory_bytes: 90328
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int inf=2147483647;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
int a[5];
int main()
{
	for(int i=1;i<5;i++)a[i]=read();
	sort(a+1,a+5);
	if(a[1]==1&&a[2]==4&&a[3]==7&&a[4]==9)puts("YES");
	else puts("NO");
}

Measured memory_bytes: 256