akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,k,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>k;
  std::vector<ll> v(n);
  rep(i,n) cin>>v[i];
  ll p =0;
  ll pp = INF;
  rep(i,n){
    if(pp>v[i]){
      p = i;
      pp = v[i];
    }
  }
  cout<<(n-k)/(k-1) + ((n-k)%(k-1) != 0 ? 1 : 0)+ 1<<endl;
}

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


Measured memory_bytes: 1024
n=input()
x=len(n)-1
if n[x]=="2" or n[x]=="4" or n[x]=="5" or n[x]=="7" or n[x]=="9":
  print("hon")
elif n[x]=="0" or n[x]=="1" or n[x]=="6" or n[x]=="8":
  print("pon")
else:
  print("bon")

Measured memory_bytes: 61808
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;
const long long mod = 1e9 + 7;

long long mod_pow(long long x, long long k){
  x += mod;
  x %= mod;
  long long ret = 1;
  while(k){
    if(k&1) ret *= x, ret %= mod;
    x *= x, x %= mod;
    k >>= 1;
  }
  return ret;
}

int main(){
  long long N, A, B, C;
  cin >> N >> A >> B >> C;
  A *= mod_pow(100,mod-2);
  A %= mod;
  B *= mod_pow(100,mod-2);
  B %= mod;
  C *= mod_pow(100,mod-2);
  C %= mod;
  vector<long long> F(2*N), F_(2*N);
  F[0] = 1;
  for(long long i = 1; i < 2*N; ++i){
    F[i] = (F[i-1]*i)%mod;
  }
  F_.back() = mod_pow(F.back(),mod-2);
  for(long long i = 2*N-2; i >= 0; --i){
    F_[i] = (F_[i+1]*(i+1))%mod;
    assert((F[i]*F_[i])%mod == 1);
  }
  auto comb = [&](long long n, long long k){
                return F[n]*F_[n-k]%mod*F_[k]%mod;
              };
  long long ans = 0;
  long long X = mod+1-C;
  X %= mod;
  long long Y = mod_pow(X,mod-2);
  for(long long i = 0; i < N; ++i){
    long long t = 1;
    long long s = (i+N)%mod;
    t *= s*mod_pow(Y,s)%mod;
    t *= ((C*mod_pow(X,s)%mod+mod-mod_pow(X,s)+1)%mod)*Y%mod;
    t %= mod;
    t += s;
    t %= mod;
    t *= mod_pow(A,N)*mod_pow(B,i)%mod*comb(N-1+i,i)%mod;
    t %= mod;
    ans += t;
    ans %= mod;
  }
  for(long long i = 0; i < N; ++i){
    long long t = 1;
    long long s = (i+N)%mod;
    t *= s*mod_pow(Y,s)%mod;
    t *= ((C*mod_pow(X,s)%mod+mod-mod_pow(X,s)+1)%mod)*Y%mod;
    t %= mod;
    t += s;
    t %= mod;
    t *= mod_pow(B,N)*mod_pow(A,i)%mod*comb(N-1+i,i)%mod;
    t %= mod;
    ans += t;
    ans %= mod;
  }
  cout << ans%mod << endl;
}


Measured memory_bytes: 3328
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>

#define REPI(i, S, N) for(int i=int(S); i<int(N); i++)
#define REP(i, N) REPI(i, 0, N)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N;
  invec<ll> A(N);
  ll max = A[0];
  ll r = 0;
  
  for (auto i : A) {
    if (max < i) {
      max = i;
      
    }
    else
      r += max - i;
  }


  return r;
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 4760
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef vector<int> vi;
int N,M;
const int MAX_V=210000;
string s[100];
vector<int> wG[100],wGrev[100];

vector<int> G[MAX_V];
int ord[MAX_V],low[MAX_V];
bool inS[MAX_V];
stack<int> S;
int cnt;
vector<vi> scc;
int cmp[MAX_V];

vector<int> sco[MAX_V];
vector<int> cG[MAX_V],csco[MAX_V];

void vis(int v){
	ord[v]=low[v]=++cnt;
	S.push(v);
	inS[v]=true;
	for(int u:G[v]){
		if(ord[u]==0){
			vis(u);
			chmin(low[v],low[u]);
		}else if(inS[u]){
			chmin(low[v],ord[u]);
		}
	}
	if(low[v]==ord[v]){
		vector<int> vc;
		while(true){
			int w=S.top();S.pop();
			inS[w]=false;
			vc.pb(w);
			if(v==w) break;
		}
		scc.pb(vc);
	}
}
void SCC(){
	rep(i,N*N*21) if(ord[i]==0) vis(i);
	int K=scc.size();
	rep(i,K){
		for(int v:scc[i]) cmp[v]=K-1-i;
	}
	rep(i,N*N*21){
		rep(j,G[i].size()){
			int v=cmp[i];
			int u=cmp[G[i][j]],c=sco[i][j];
			cG[v].pb(u),csco[v].pb(c);
		}
	}
}


int I(int a,int b,int c){
	return a*N*21+b*21+(c+10);
}
bool ispal(string s){
	int N=s.size();
	rep(i,N/2) if(s[i]!=s[N-1-i]) return 0;
	return 1;
}
int inf=1e9;
int main(){
	cin>>N>>M;
	rep(i,N) cin>>s[i];
	rep(i,M){
		int a,b;
		cin>>a>>b;
		wG[a-1].pb(b-1);
		wGrev[b-1].pb(a-1);
	}
	rep(i,N) rep(j,N) for(int k=-10;k<=10;k++){
		int id=I(i,j,k);
		if(k>=0){	//left
			int L=k;
			if(s[i].size()>=L){
				string st=s[i].substr(0,L);
				reverse(all(st));
				for(int v:wG[j]){
					int Lv=s[v].size();
					if(L<=Lv){
						if(s[v].substr(0,L)==st) G[id].pb(I(i,v,L-Lv)),sco[id].pb(Lv);
					}else{
						if(st.substr(0,Lv)==s[v]) G[id].pb(I(i,v,L-Lv)),sco[id].pb(Lv);
					}
				}
			}
		}
		if(k<=0){	//right
			int L=-k;
			if(s[j].size()>=L){
				string st=s[j].substr(s[j].size()-L,L);
				reverse(all(st));
				for(int v:wGrev[i]){
					int Lv=s[v].size();
					if(L<=Lv){
						if(s[v].substr(Lv-L,L)==st) G[id].pb(I(v,j,Lv-L)),sco[id].pb(Lv);
					}else{
						if(st.substr(L-Lv,Lv)==s[v]) G[id].pb(I(v,j,Lv-L)),sco[id].pb(Lv);
					}
				}
			}
		}
	}
	SCC();
	int K=scc.size();

	int dp[MAX_V]={};
	//init
	rep(i,N){
		int L=s[i].size();
		for(int j=-L;j<=L;j++){
			int id=cmp[I(i,i,j)];
			if(j>=0){
				if(ispal(s[i].substr(j,L-j))) dp[id]=L;
			}else{
				int k=-j;
				if(ispal(s[i].substr(0,L-k))) dp[id]=L;
			}
		}
	}
	rep(v,K){
		if(dp[v]==0) continue;
		if(scc[K-1-v].size()>=2) dp[v]=inf;
		rep(j,cG[v].size()){
			int u=cG[v][j],ad=csco[v][j];
			chmax(dp[u],min(inf,dp[v]+ad));
		}
	}
	int ans=0;
	rep(i,N) rep(j,N){
		int id=cmp[I(i,j,0)];
		chmax(ans,dp[id]);
	}
	if(ans==inf) ans=-1;
	cout<<ans<<endl;
}

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

#define ll long long int
#define vi vector<int> 

ll permut(int a){
    ll prod=1;
    for(int i=1;i<=a;i++){
        prod*=i;
    }
    
    return prod;
}


int main() {
  int n;
  cin >> n;
  ll a=0;
  ll b=0;
  vector<ll> v(n);
  vector<ll> v1(n);
  for(int i=0;i<n;i++)
  cin >> v[i];
  for(int i=0;i<n;i++)
  cin >> v1[i];
  
  for(int i=0;i<n;i++){
      ll cnt=0;
      for(int j=i+1;j<n;j++)if(v[j]<=v[i])cnt++;
      a+= cnt*(permut(n-i-1));
  
  }
    
    for(int i=0;i<n;i++){
     ll cnt=0;
      for(int j=i+1;j<n;j++)if(v1[j]<v1[i])cnt++;
      //cout << min<<"\n";
      b+= cnt*(permut(n-i-1));
  }
    
 cout << abs(a-b);
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int s = 0;
        int t = 0;
        for(int i = 0;i < 4;i++){
            s += sc.nextInt();
        }
        for(int i = 0;i < 4;i++){
            t += sc.nextInt();
        }
        if(s >= t){
            System.out.println(s);
        }else{
            System.out.println(t);
        }
    }
}


Measured memory_bytes: 26020
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>

using namespace std;

int main()
{
	string s;
	cin >> s;
	int c=0;
	for(int i=0;i<s.size();i++)
		if(s[i]=='o')c++;
	for(int i=s.size();i<15;i++)
		c++;

	cout << (c>=8 ? "YES":"NO") << endl;



}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator <<(std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator <<(std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec << std::endl; }
  os << "--------" << std::endl;
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

// DIGNUM
std::vector<ll> dignum(ll x) {
  if (x == 0) return {0};
  std::vector<ll> res;
  while (x) {
    res.push_back(x % 10);
    x /= 10;
  }
  std::reverse(res.begin(), res.end());
  return res;
}

// FAIL
void fail(){ print(-1); std::exit(0); }
//void fail(){ print("No"); std::exit(0); }

void solve()
{
  ll N;
  std::cin >> N;

  ll ans = 0LL;
  for (ll i = 1; i <= (ll)1e6; i++) {
    ll j = N - i;
    if (j > i) ans++;
  }

  print(ans);
  return;
}

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

  solve();
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int match( char*, char* );
int main(){
    int times = 0;
    int winner;
    int t_point = 0;
    int h_point = 0;
    char t_card[100] = {'\0'};
    char h_card[100] = {'\0'};
    int i;
    int cnt = 0;
    
    scanf( "%d", &times );
    
    for( i = 0; i < times; i++ ){
        scanf( "%s %s", &t_card, &h_card );
        
        winner = match( t_card, h_card );
        
        if( winner == 1 ){
            t_point += 3;
        }
        else if( winner == 2 ){
            h_point += 3;
        }
        else{
            t_point += 1;
            h_point += 1;
        }
    }
    
    printf( "%d %d\n", t_point, h_point );
    
    return 0;
}

int match( char* a, char* b ){
    int winner;
    int cnt = 0;
    
    while( 1 ){
        if( a[cnt] == b[cnt] ){
            winner = 0;
			if( a[cnt] == '\0' ){
				break;
			}
        }
        else if( a[cnt] > b[cnt] ){
            winner = 1;
            break;
        }
        else if( a[cnt] < b[cnt] ){
            winner = 2;
            break;
        }
        else{
            /* 処理なし */
        }
        cnt++;
    }
    return winner;
}


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

public class Main{

	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		
		BufferedReader reader =  new BufferedReader(new InputStreamReader(System.in));
		
		String str[] = reader.readLine().split(" ");
		
		int H = Integer.parseInt(str[0]);
		int W = Integer.parseInt(str[1]);
		char[][] ch = new char[H][W];
		for(int i=0; i<H; i++)
		{
			String str1 = reader.readLine();
			char c[] = str1.toCharArray();
			for(int j=0; j<W; j++)
			{
				ch[i][j] = c[j];
			}
		}
		
		System.out.println(calculateTotalPath(ch, H, W));

	}

	private static int calculateTotalPath(char[][] ch, int h, int w) {
		// TODO Auto-generated method stub
		int mod = (int)Math.pow(10, 9) + 7;
		int dp[][] = new int[h+1][w+1];
		
		for(int i=0; i<h; i++)
		{
		    if(ch[i][0] == '#')
		    	break;
			dp[i][0] = 1;
		}
		for(int j=0; j<w; j++)
		{
			if(ch[0][j] =='#')
				break;
			dp[0][j] = 1;
		}
		
		for(int i=1; i<h; i++)
		{
			for(int j=1; j<w; j++)
			{
				if(ch[i][j] == '#')
				{
					continue;
				}
				else {
					if(ch[i-1][j] =='.' && ch[i][j-1] == '.')
						dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
					else if(ch[i-1][j] =='#' && ch[i][j-1]=='.' )
						dp[i][j] = dp[i][j-1];
					else
						dp[i][j] = dp[i-1][j];		
				}		
			}
		}
		
		
		return dp[h-1][w-1];
	}

}


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

public class Main{
  public static void main(String[] args) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   //??????????????¶??°?????\???
   int n = Integer.parseInt(br.readLine());
   int[][][] room = new int[4][3][10];//??¨?±?????????°
    
   for(int i = 0;i < 4;i++){
     for(int j = 0;j < 3;j++){ 
       for(int k = 0;k < 10;k++){
         room[i][j][k] = 0;//??????????????°???0????????????
       }
     }
   }
     
    for(int i = 0;i < n;i++){   
     String line = br.readLine();  
     String[] token = line.split(" ");
     int b, f, r, v; //?£?????????°?????¨?±???????,????????\?±?       
     b = Integer.parseInt(token[0]);
     f = Integer.parseInt(token[1]);
     r = Integer.parseInt(token[2]);
     v = Integer.parseInt(token[3]);
     room[b-1][f-1][r-1] += v;
 
    } 

    for(int i = 0;i < 4;i++){
     for(int j = 0;j < 3;j++){ 
       for(int k = 0;k < 10;k++){
         System.out.print(" " + room[i][j][k]);
       }
       System.out.println();
     }
      if(i != 3){   
       System.out.println("####################");
      }
    }

  }
}

Measured memory_bytes: 24532
#include <iostream>
#include <set>

using namespace std;

int main() {
    int a, b, c;

    cin >> a >> b >> c;
    
    multiset<int> data{ a, b, c };
    multiset<int>::iterator i = data.begin();
    
    int result = *i + *(++i);

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
} edge;
int main( void ){
	ll A, B, C; cin >> A >> B >> C;
	if (A == 0)
		cout << B / C + 1 << endl;
	else
		cout << B / C - ( A - 1 ) / C << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

int main()
{
  int n;
  cin >> n;
  long f[n + 1];
  for (int i = 1; i <= n; i++) f[i] = 1;
  long x = 1;
  for (int i = 2; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      f[j]++;
    }
    x += f[i] * i;
  }
  cout << x << endl;
  return 0;
}


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


Measured memory_bytes: 1020
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int n, m;
	cin >> n >> m;
	vi v(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		v[a]++;
		v[b]++;
	}
	rep(i, n) cout << v[i] << endl;
	return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
static const int N = 1001;
int dp[N][N];
int stl(string a, string b) {
	a = " " + a;
	b = " " + b;
	for (int i = 0; i < a.length(); i++) {
		for (int j = 0; j < b.length(); j++)
			dp[i][j] = 0;
	}
	for (int i = 1; i < a.length(); i++) {
		for (int m = 1; m < b.length(); m++) {
			if (a[i] == b[m]) dp[i][m] = dp[i - 1][m - 1] + 1;
			else dp[i][m] = max(dp[i][m - 1], dp[i - 1][m]);
		}
	}
	return dp[a.length() - 1][b.length() - 1];
}
int main(void) {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string a, b;
		cin >> a >> b;
		cout << stl(a, b)<<endl;
	}
}


Measured memory_bytes: 7076
#include <iostream>
using namespace std;
int a[6];
string s;
void C(int i,int j,int k,int l){
  int t;t=a[i];a[i]=a[j];a[j]=a[k];a[k]=a[l];a[l]=t;
}
int main(){
  for(int i=0;i<6;i++)cin>>a[i];
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='E')for(int j=0;j<3;j++)C(0,2,5,3);
    if(s[i]=='W')C(0,2,5,3);
    if(s[i]=='S')for(int j=0;j<3;j++)C(0,1,5,4);
    if(s[i]=='N')C(0,1,5,4);
  }
  cout<<a[0]<<endl;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 0;

typedef long long int ll;

using namespace std;

int main(){
    int a,b,c;cin>>a>>b>>c;
    if(a+b+c>=22){
        cout<<"bust";
    }else{
        cout<<"win";
    }
	return 0;
}

Measured memory_bytes: 256
//AOJ-GRL-7-A
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

#define MAX_V 200

int V;//頂点数
vector<int> G[MAX_V];//グラフの隣接リスト表現
int match[MAX_V];//マッチングのペア
bool used[MAX_V];//DFSですでに調べたかのフラグ

//uとvを結ぶ辺をグラフに追加する
void add_edge(int u, int v){
    G[u].push_back(v);
    G[v].push_back(u);
}

//増加パスをDFSで探す
bool dfs(int v){
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        int u = G[v][i], w = match[u];
        if(w < 0 || !used[w] && dfs(w)){
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

//二部グラフの最大マッチングを求める
int bipartite_matching(){
    int res = 0;
    memset(match, -1, sizeof(match));
    for(int v = 0; v < V; v++){
        if(match[v] < 0){
            memset(used, 0, sizeof(used));
            if(dfs(v)){
                res++;
            }
        }
    }
    return res;
}

signed main(){
    int X,Y,e;
    cin >> X >> Y >> e;
    V = X + Y;
    int x,y;
    REP(i,e){
        cin >> x >> y;
        add_edge(x, X + y);
    }
    cout << bipartite_matching() << endl;
    return 0;
}


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

#define rep(i, n) for (Int i = 0; i < (Int)n; i++)
#define rep2(i, s, n) for (Int i = s; i < (Int)(n); i++)
#define rep3(i, n, s) for (Int i = n - 1; i >= s; i--)
#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).end()
 
double EPS = 1e-10;
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int a, b, c;
    cin >> a >> b >> c;
    dump(max((Int)0, b + c - a));
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, m, a[50], b[50], c[50], d[50];

int main() {
	cin >> n >> m;
	inc(i, n) { cin >> a[i] >> b[i]; }
	inc(i, m) { cin >> c[i] >> d[i]; }
	
	inc(i, n) {
		int v = 1000000000, ans = 0;
		inc(j, m) {
			if(setmin(v, abs(a[i] - c[j]) + abs(b[i] - d[j]))) { ans = j + 1; }
		}
		cout << ans << "\n";
	}
	
	return 0;
}


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

int main(){
	int A, B, answer = 0;
	
	cin >> A >> B;
	
	int currentPort = 1;
	while(currentPort < B){
		if(currentPort == 1) currentPort = A;
		else				 currentPort += A - 1;
		answer++;
	}
	
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
// Created by martinezdiego on 27/5/19

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int l, r;
  for (int i = 0; i < m; i++) {
    int li, ri;
    cin >> li >> ri;
    if (i == 0) l = li, r = ri;
    else l = max(l, li), r = min(r, ri);
  }
  if (l <= r) cout << r-l+1 << '\n';
  else cout << 0 << '\n';
  return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
ren=[0]*n
ren[0]= A[0]
for i in range(n-1):
    ren[i+1]= ren[i]+ A[i+1]
import bisect as bi
ans=float("inf")
for cen in range(1, n-2):
    maru= ren[cen]
    a=ren[bi.bisect(ren, maru//2)-1]
    if a==ren[-1]: a=float("inf")
    b=maru-a
    c=ren[bi.bisect(ren, maru//2)]
    if c==maru: c=float("inf")
    d=maru-c
    
    e=ren[bi.bisect(ren,(maru+ren[-1])//2)-1]-maru 
    if e==0: e= float("inf")
    f=ren[-1]-e-maru
    g=ren[bi.bisect(ren,(maru+ren[-1])//2)]-maru
    if g==ren[-1]-maru: g=float("INF")
    h=ren[-1]-g-maru

    q=[max(a,b,e,f)-min(a,b,e,f), max(a,b,g,h)-min(a,b,g,h), max(c,d,e,f)-min(c,d,e,f), max(c,d,g,h)-min(c,d,g,h)]
    ans= min(ans, min(q))
    
    #print(ren)
    
    #print(a,b,c,d,e,f,g,h)
print(ans)

Measured memory_bytes: 32788
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    vector<string>s(2*n),ts(2*n,"");
    rep(i,n){
        string ss;cin>>ss;
        ss+=ss;
        s[i]=ss;
        s[i+n]=s[i];
    }
    rep(i,2*n){
        rep(j,2*n){
            ts[i]+=s[j][i];
        }
    }
    ll cnt=0;
    rep(a,n){
        bool f=1;
        rep(i,n){
            rep(j,n){
                if(s[a+i][j]!=s[a+j][i])f=0;
            }
        }
        if(f)cnt++;
    }
    cout<<cnt*n<<endl;
}

Measured memory_bytes: 1536
<?php

$N = trim(fgets(STDIN));
$H = explode(' ', trim(fgets(STDIN)));

$ans = 0;
$count = 0;
for ($i = 0; $i < $N - 1; ++$i) {
    $sub = $H[$i] - $H[$i + 1];
    if ($sub >= 0) {
        ++$count;
        if ($count > $ans) {
            $ans = $count;
        }
    } else {
        $count = 0;
    }
}

echo $ans, "\n";


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while (A > 0 && C > 0) {
    C -= B;
    if (C > 0) {
      A -= D;
      if (A <= 0) {
        cout << "No" << endl;
      }
    }
    else {
      cout << "Yes" << endl;
    }
  }
}

Measured memory_bytes: 3596
use std::io::Read;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let k: i64 = iter.next().unwrap().parse().unwrap();
    let q_n: usize = iter.next().unwrap().parse().unwrap();
    let mut qs: Vec<usize> = Vec::new();
    for _ in 0..q_n {
        qs.push(iter.next().unwrap().parse::<usize>().unwrap() - 1);
    }

    let mut v = vec![0; n];
    for q in qs {
        v[q] += 1;
    }

    let ss = v.into_iter()
        .map(|x| if k + x - q_n as i64 > 0 { "Yes" } else { "No" })
        .collect::<Vec<_>>();
    println!("{}", ss.join("\n"));
}

Measured memory_bytes: 10744
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
long long n,m;

int main()
{
    IO;
    int n;
    int flag=0;
    cin>>n;
    while(n--)
    {
        int a,s;
        cin>>a>>s;
        if(a==s)
            flag++;
        else
            flag=0;
        if(flag==3)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;

    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
string ans[20005];
map<string,int>ma;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		ma[s]++;
	}
	int max=-1;
	for(auto it=ma.begin();it!=ma.end();it++){
		if(it->second>max) {
			max=it->second;
		}
	}
	for(auto it=ma.begin();it!=ma.end();it++){
		if(it->second==max)
			cout<<it->first<<endl;
	}
} 

Measured memory_bytes: 25344
from itertools import combinations
N, M, X = map(int, input().split())
CAs = [[int(n) for n in input().split()] for _ in range(N)]

MAX = 10 ** 5 * 12 + 1
min_ = MAX

for i in range(1, N + 1):
    for cas in combinations(CAs, i):
        rikai = [0] * M
        kakaku = 0
        for ca in cas:
            for j in range(M):
                rikai[j] += ca[j + 1]
            kakaku += ca[0]
        if len(list(filter(lambda x: x < X, rikai))) == 0:
            min_ = min(min_, kakaku)
if min_ == MAX:
    print('-1')
else:
    print(min_)

Measured memory_bytes: 74072
#include <iostream>

using namespace std;

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

    int c_min = 1001;
    for (int i = 0; i < n; i++) {
        int ci, ti;
        cin >> ci >> ti;

        if (c_min > ci && t >= ti) {
            c_min = ci;
        }
    }

    if (c_min <= 1000) {
        cout << c_min << endl;
    } else {
        cout << "TLE" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	string s,t;
	cin >> s >> t;
	int ans = 0;
	for(int i = 0;i < s.length(); i++){
		if(s[i]!=t[i]) ans++;
	}
	cout << ans;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=200010; //check the limits, dummy
int a[N];
int n, m;
int main(){
	int t;
		scanf("%d",&n);
		int ans=0;
		for(int i=1; i<=n; ++i){
			for(int j=1; j*i<n; ++j){
				++ans;
			}
		}
		cout<<ans<<endl;
}

Measured memory_bytes: 3800
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007

using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}

int main()
{
	fast();
	ll n,i;
	cin>>n;
	string a,b,ans="";
	cin>>a>>b;
	for(i=0;i<n;i++)
	{
		ans+=a[i];
		ans+=b[i];
	}
	cout<<ans;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int n,k;	cin >> n >> k;
    vector<int>x(n);
    rep(i, n)	cin >> x[i];
    int ans = 0;
    rep(i, n){
	ans += 2*min(x[i], k-x[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <queue>
#include <map>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_V = 4000*2;
const int MAX_C = 200*10;
const int INF = 1<<29;

int V, C, S, G;
int dist[MAX_V][MAX_C+1];
bool has_station[MAX_V];

struct edge{
	int to, cost;
};

vector<edge> graph[MAX_V];

struct state{
	int v, res, dist;
};

bool operator<(const state& lhs, const state& rhs){
	return lhs.dist > rhs.dist;
}

bool init(){
	int N, M;
	scanf("%d%d%d ", &N, &M, &C);
	if(N==0 && M==0 && C==0){
		return false;
	}
	C *= 10;
	memset(has_station, false, sizeof(has_station));
	for(int i=0; i<MAX_V; i++){
		graph[i].clear();
	}

	char buf1[20], buf2[20];
	scanf("%s %s ", buf1, buf2);
	string  start(buf1), goal(buf2);
	
	map<string, int> dict;
	V = 0;
	if(dict.find( start ) == dict.end()){
		dict[start] = V++;
	}
	if(dict.find( goal ) == dict.end()){
		dict[goal] = V++;
	}

	for(int i=0; i<N; i++){
		int d;
		scanf("%s %s %d ", buf1, buf2, &d);
		string s1(buf1), s2(buf2);
		if(dict.find( s1 ) == dict.end()){
			dict[s1] = V++;
		}
		if(dict.find( s2 ) == dict.end()){
			dict[s2] = V++;
		}
		graph[dict[s1]].push_back( (edge) { dict[s2], d } );
		graph[dict[s2]].push_back( (edge) { dict[s1], d } );
	}

	for(int i=0; i<M; i++){
		scanf("%s ", buf1);
		string s(buf1);
		if(dict.find( s ) == dict.end()){
			dict[s] = V++;
		}
		has_station[dict[s]] = true;
	}
	S = dict[start];
	G = dict[goal];
	return true;
}

int solve(){
	for(int i=0; i<V; i++){
		fill(dist[i], dist[i]+MAX_C+1, INF);
	}
	
	priority_queue<state> que;
	que.push( (state){S, C, 0} );
	dist[S][C] = 0;

	while(!que.empty()){
		state tp = que.top(); que.pop();
		int v = tp.v, d = tp.dist, res = tp.res;
		if(dist[v][res] < d){
			continue;
		}
		
		for(int i=0; i<(int)graph[v].size(); i++){
			int u = graph[v][i].to, nd = d + graph[v][i].cost;
			if(res < graph[v][i].cost){
				continue;
			}
			int nres = has_station[u] ? C : res - graph[v][i].cost;
			if(nd < dist[u][nres]){
				dist[u][nres] = nd;
				que.push( (state){u, nres, nd} );
			}
		}
	}
	
	int ans = *min_element(dist[G], dist[G]+C+1);
	
	return ans == INF ? -1 : ans;
}

int main(){
	while(init()){
		printf("%d\n", solve());
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

void quick(int a[],int left,int right);

int main(){
  int N,ans=1;
  scanf("%d",&N);
  int D[N];
  for (int i = 0; i < N; i++){ scanf("%d",&D[i]);}
  int M;
  scanf("%d",&M);
  int T[M];
  for (int i = 0; i < M; i++){ scanf("%d",&T[i]);}

  quick(D,0,N-1);
  quick(T,0,M-1);

  int i=0,j=0,k=0,count_T=0,count_D=0;
  while (i<M&&N>=M)
  {
    while (T[i]==T[k]&&k<M){ count_T++; k++;}
    while (T[i]!=D[j]&&j<N){ j++; }
    while (T[i]==D[j]&&j<N){ count_D++; j++; }
    if(count_D<count_T){
      ans=1;
      break;
    }else{
      ans=0;
    }
    
    i=k;
    count_D=0;
    count_T=0;
  }

  ans > 0 ? puts("NO") : puts("YES");
  
  return 0;
}

void quick(int a[],int left,int right)
{
    int s,t,i,j;

    if (left<right){
        s=a[left];            
        i=left; j=right+1;      
        while (1){              
            while (a[++i]<s);
            while (a[--j]>s);
            if (i>=j) break;
            t=a[i]; a[i]=a[j]; a[j]=t;
        }
        a[left]=a[j]; a[j]=s;

        quick(a,left,j-1);
        quick(a,j+1,right);
    }
}

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

const int INF = 2147483647;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int x,y;cin >> x >> y;
    bool ok = false;
    for(int i=0;i<=x;i++){
       int j=x-i;
       if((2*i+j*4) == y) ok = true;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3532
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int N,K;
    cin >> N >> K;
    vector<int> A(N), species;
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    int tmp=A[0], cnt=1;
    for(int i=1; i<N; i++){
        if(tmp==A[i])cnt++;
        else{
            species.push_back(cnt);
            cnt=1;
            tmp=A[i];
        }
    }
    species.push_back(cnt);
    sort(species.begin(), species.end());
    int ans=0;
    for(int i=0; i< max(0, (int)species.size()-K) ; i++){
        ans+=species[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2168
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<int> va(n);
  bool exists = false;
  for (auto &a : va) {
    cin >> a;
    if (a == 1) {
      exists = true;
    }
  }

  if (!exists) {
    cout << -1 << '\n';
    return 0;
  }

  int cur = 1, ans = 0;
  for (auto &a : va) {
    if (a != cur) {
      ans++;
    } else {
      cur++;
    }
  }

  cout << ans << '\n';
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  int N = S.size();
  if(S.substr(0, (N - 1) / 2) == S.substr((N + 3) / 2 - 1, (N - 1) / 2))cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int input = new Scanner(System.in).nextInt();
        int h = input / 3600;
        input = input % 3600;
        int m = input / 60;
        input = input % 60;
        int s = input;
        System.out.println(h+":"+m+":"+s);
    }
}



Measured memory_bytes: 26172
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;

int main(void){
  int x,a,b;
  cin>>x>>a>>b;
  if(b-a<=0) cout<<"delicious"<<endl;
  else if(b-a<=x) cout<<"safe"<<endl;
  else cout<<"dangerous"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int rght, acute, obtuse;
bool flag = false;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    int e[3];
    while (true) {
        rep(i, 0, 3) cin >> e[i];
        sort(e, e+3);
        int a = e[0], b = e[1], c = e[2];
        if (a + b <= c) {
            printf("%d %d %d %d\n", rght+acute+obtuse, rght, acute, obtuse);
            break;
        }
        if (a * a + b * b == c * c) rght++;
        else if (a * a + b * b > c * c) acute++;
        else obtuse++;
    }
    return 0;
}


Measured memory_bytes: 3276
#include <iostream>
using namespace std;
int main(void){
    
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    if(x - r < 0 || y - r < 0 || x + r > W || y + r > H){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    
    
}



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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	string n;
	cin>>n;
	
	int sum = 0;
	
	for(int i=0;i<n.length();i++)
	{
	    sum += (int)n[i] - 48;
	}
	
	
	if(sum % 9 == 0)
	{
	    cout<<"Yes\n";
	}
	else
	{
	  cout<<"No\n";   
	}
	 
	 
	 
	return 0;
}


Measured memory_bytes: 3736
#include <stdio.h>
int main(void) {

  int n;
  scanf("%d",&n);

  int i,a=-1000000000,b=1000000000;

  for(i=0; i<n; i++) {
    int x;
    scanf("%d",&x);
    if(i && x-b>a)
      a=x-b;
    if(b>x)
      b=x;
  }

  printf("%d\n",a);
  
  return 0;
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAX_N = 1 << 18;
struct BIT{
  int bit[MAX_N+1],n;
  //1-indexed
  BIT(){init();}
  BIT(int n):n(n){init();}
  void init(){
    memset(bit,0,sizeof(bit));
  }
  int sum(int i){
    int s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
  void add(int i,int x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  int sum0(int i){
    return sum(i+1);
  }
  void add0(int i,int x){
    add(i+1,x);
  }
};
signed main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  int b[n];
  for(int i=0;i<n;i++) b[i]=a[i];
  sort(b,b+n);
  map<int,int> m;
  for(int i=0;i<n;i++) m[b[i]]=i+1;
  BIT bit(n);
  int ans=0;
  for(int i=0;i<n;i++){
    //cout<<i<<" "<<m[a[i]]<<endl;
    ans+=i-bit.sum(m[a[i]]);
    bit.add(m[a[i]],1);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 20784
S=input()
cnt=0;l='@';i=0
while(i<len(S)):
    if(S[i]==l):
        if(i<len(S)-1):
            l=S[i:i+2]
            cnt+=1
        i+=2
    else:
        l=S[i];cnt+=1;i+=1
print(cnt)

Measured memory_bytes: 3500