akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005;

int main(){
    
    ll N;cin>>N;
    ll K;cin>>K;
    vector<ll> A(45,0),B(45,0);//上からbitをみたときの個数
    
    ll ans=0;
    for(int i=0;i<N;i++){
        ll a;cin>>a;
        for(int j=0;j<45;j++){
            if(a&(1LL<<j)) A[44-j]++;
            else B[44-j]++;
        }
        ans+=a;
    }
    
    /*for(int i=0;i<45;i++){
        cout<<A[i]<<" "<<B[i]<<endl;
    }*/
    
    for(int i=0;i<45;i++){
        
        if(!(K&(1LL<<(44-i)))) continue;
        ll sum=0;
        for(int j=0;j<i;j++){
            if(K&(1LL<<(44-j))) sum+=B[j]*(1LL<<(44-j));
            else sum+=A[j]*(1LL<<(44-j));
        }
        sum+=A[i]*(1LL<<(44-i));
        for(int j=i+1;j<45;j++){
            sum+=max(A[j],B[j])*(1LL<<(44-j));
        }
        //cout<<sum<<" "<<i<<endl;
        ans=max(ans,sum);
    }
    
    ll sum=0;
    for(int i=0;i<45;i++){
        if(!(K&(1LL<<(44-i)))) sum+=A[i]*(1LL<<(44-i));
        else sum+=B[i]*(1LL<<(44-i));
    }
    
    ans=max(ans,sum);
    
    cout<<ans<<endl;
    
}


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

int N, M;
LL X[100000];

int main() {
    scanf("%d%d", &N, &M);
    rep(i, M) scanf("%lld", &X[i]);
    sort(X, X + M);
    rep(i, M - 1) X[i] = X[i + 1] - X[i];
    sort(X, X + M - 1);
    LL ans = 0;
    rep(i, M - N) ans += X[i];
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 4488
#include <iostream>
#include <algorithm>
using namespace std;
int a[100000];
int c[100000];
int main(){
	int n;
	for(int i = 0;i < 100000;i++){
		c[i] = 0;
	}
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		if(a[i] > 0){
			c[a[i] - 1]++;
		}
		c[a[i]]++;
		if(a[i] < 99999){
			c[a[i] + 1]++;
		}
	}
	sort(c, c + 100000);
	cout << c[99999] << endl;
}

Measured memory_bytes: 1024
arr = gets.chomp.split('')
i = 0
switch = true
while i < arr.size
  if i%2 == 0 && arr[i] == "L"
    switch = false
  elsif i%2 == 1 && arr[i] == "R"
    switch = false
  end
  i+=1
end

if switch == true
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 14264
x = gets()
y = x.split()
h = y[0].to_i
w = y[1].to_i

until h == 0 && w == 0
 i = 1
 while i <= h
  if i == 1 || i == h
  puts "#" * w
  i += 1
  else
  puts "#" + "." * (w - 2) + "#"
  i += 1
  end

 end
 puts ""
 x = gets()
 y = x.split()
 h = y[0].to_i
 w = y[1].to_i
end


Measured memory_bytes: 6968
#include <iostream>
#include <string>
using namespace std;
string s;

int main(){
    cin>>s;
    int ans=s.size();
    for(int i=0;i<s.size()-1;i++){
        if(s[i]==s[i+1]){
            ans--;
            i+=2;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 640
#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 rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define all(x)                (x).begin(), (x).end()

vector<int> g[101010];

int dfs(int s) {
        int res = 0;
        vector<int> v;
        for (auto ns : g[s]) v.push_back(dfs(ns));
        sort(all(v)); //削除コスト順にソート
        rep(i, v.size()) res = max(res + 1, v[i]);  //小さいものから見ていき、今見ているノードか、時刻＋１の大きい方をとる
        // cout<<s<<" "<<res<<endl;
        return res + 1; //親ノードを削除するコストを足す
}

signed main() {
        int n;
        cin >> n;
        rep(i, n - 1) {
                int a;
                cin >> a;
                a --;
                g[a].push_back(i + 1);
        }
        cout << dfs(0) - 1 << endl;
        return 0;
}


Measured memory_bytes: 13568
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int R;
	std::cin >> R;
	
	std::cout << (R * 3.141592 * 2) << "\n";
}


Measured memory_bytes: 3756
import java.util.*;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int inN = stdin.nextInt();
		Map<Integer, Integer> numCountMap = new HashMap<>();
		for (int i = 0; i < inN; i++) {
			int inA = stdin.nextInt();
			int count = numCountMap.getOrDefault(inA, 0) + 1;
			numCountMap.put(inA, count);
		}

		int sum = 0;
		for (Map.Entry<Integer, Integer> element : numCountMap.entrySet()) {
			int num = element.getKey();
			int count = element.getValue();

			if (num > count) {
				sum += count;
			}
			else if (num < count) {
				sum += (count - num);
			}
		}

		System.out.println(sum);
	}

}


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

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b,t;
	cin>>a>>b>>t;
	cout<<(int)(t/a)*b;
	return 0;
}

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

#define    ll    long long int

int main( )
{
    ll n, rt, i, j, k, mn = 1e15;
    cin >> n;
    rt = sqrt(n);
    for (i = 1; i <= rt; i++)
    {
        if (n % i == 0)
        {
            j = n / i;
            mn = min(mn, abs(i - 1) + abs(j - 1));
        }
    }
    cout << mn << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;

ll gcd(ll a,ll b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}

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

  ll n,k;
  std::cin>>n>>k;

  std::vector<P> a(n);
  rep(i,0,n)std::cin>>a[i].first>>a[i].second;

  std::sort(all(a));

  ll cnt=0;

  rep(i,0,n){
    if(cnt+a[i].second>=k){
      std::cout<<a[i].first<<"\n";
      return 0;
    }
    cnt+=a[i].second;
  }

  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		long max = 1;
		for (int i = 1; i <= Math.sqrt(X); i++) {
			for (int j = 2; j <= Math.sqrt(X); j++) {
				long let = (long)Math.pow(i, j);
				if (let <= X && let > max) {
					max = let;
				}
			}
		}
		System.out.println(max);
		}

}


Measured memory_bytes: 35572
#include <stdio.h>

int main(void) {

        int i, x;

        

        i = 0;

        while(i < 10000) {

            scanf("%d", &x);

            if(x == 0) {

                break;

            }

            else {

                printf("Case %d: %d\n", i + 1, x);

                i++;

            }

        }

        return 0;

}



Measured memory_bytes: 1952
#include<iostream>
#include<math.h>
#include<set>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#include<string>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
typedef long long ll;
using namespace std;

int main()
{
    
    ios_base:: sync_with_stdio(0);
    cin.tie();
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    int ev = 0 , odd = 0 , four = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(a[i] % 4 == 0 ) four ++;
        else
            if(a[i] % 2 == 0) ev++;
            else odd++;
        a[i] = -1;
    }
    if( ev >= 1) odd++;
    
    //cout << odd << " " << four << " " << ev;
    if( odd - four > 1  ) cout << "No";
        else
    cout << "Yes";
    cout <<  "\n";
    return 0;
}

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

int main()
{
	int n,m;cin >> n >> m;
	vector<int> A(n);
	rep(i, n)cin>>A[i];
	vector<pair<int , int>> BC(m);
	rep(i, m)
	{
		int b, c; cin >> b >> c;
		BC[i] = make_pair(c, b);
	}

	sort(A.begin(),A.end(),greater<int>());
	sort(BC.begin(),BC.end());

	//rep(i,BC.size())cout<<BC[i].first;
	
	
	for(int i=A.size()-1;i>=0;i--)
	{
		if(A[i]<BC[BC.size()-1].first)
		{
			A[i]=BC[BC.size()-1].first;
			BC[BC.size()-1].second--;
		}
		else break;

		//cout<<BC[0].second<<endl;
		if(BC[BC.size()-1].second==0)
		{
			BC.pop_back();
		}
		if(BC.size()==0)break;
	}

	ll sum=0;
	rep(i,A.size())sum+=A[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1408
#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;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

template<class D>
vector<D> dijkstra(const vector<vector<pair<int,D>>>& G, int s = 0){	//G:(v,cost)
	using P = pair<D,int>;
	priority_queue<P,vector<P>,greater<P> > que;
	int N = G.size();

	D inf = 1e9;
	vector<D> d(N,inf);
	d[s] = 0;
	que.push(P(0,s));

	while(!que.empty()){
		P p=que.top();
		que.pop();
		int v = p.sc;
		D c = p.fs;
		if(d[v]!=c) continue;
		for(auto p:G[v]){
			int to=p.fs;
			if(d[to]>d[v]+p.sc){
				d[to]=d[v]+p.sc;
				que.push(P(d[to],to));
			}
		}
	}

	return d;
}

int main(){
	int N;
	cin>>N;
	using P = pair<int,int>;
	vector<vector<P>> G(N+1);
	rep(i,N-1){
		int a,b;
		cin>>a>>b;
		G[a].pb(P(b,1));
		G[b].pb(P(a,1));
	}
	vector<int> lim(N+1,-1);
	int K;
	cin>>K;
	rep(i,K){
		int v,p;
		cin>>v>>p;
		G[0].pb(P(v,p));
		lim[v] = p;
	}
	vector<int> d = dijkstra(G,0);

	rep1(i,N){
		if(lim[i] != -1 && lim[i] != d[i]){
			puts("No");
			return 0;
		}
		for(P p:G[i]){
			int j = p.fs;
			if(abs(d[i]-d[j])!=1){
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	rep1(i,N) cout<<d[i]<<endl;
}

Measured memory_bytes: 9332
#include<iostream>

using namespace std;
int main() {
	string S, T, U;
	int A, B;

	cin >> S >> T;
	cin >> A >> B;
	cin >> U;

	if (U == S) {
		A--;
	}
	else {
		B--;
	}
	cout << A << " " << B << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } else return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } else return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;

bool solve(string S) {
	if (S[0] != 'A') return false;
	
	int pos = -1;
	FOR(i, 2, S.size() - 1) if (S[i] == 'C') {
		if (pos != -1) return false;
		pos = i;
	}
	if (pos == -1) return false;
	
	FOR(i, 1, S.size()) if (i != pos) {
		if (isupper(S[i])) return false;
	}
	
	return true;
}

int main() {
	string S;
	cin >> S;
	puts(solve(S) ? "AC" : "WA");
	
}

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
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;}

int N,M;
bool ok[111111];
int cnt[111111];

signed main(){
    cin>>N>>M;
    rep(i,N)cnt[i]=1;
    ok[0]=1;
    rep(i,M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        cnt[b]++;
        cnt[a]--;
        ok[b]|=ok[a];
        if(cnt[a]==0)ok[a]=0;
    }
    cout<<accumulate(ok,ok+N,0ll)<<endl;
    return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>

int CountSwap=0;

void swap(int* a,int* b){
  int tmp=*a;
  *a=*b;
  *b=tmp;
  CountSwap++;
}

void SelectionSort(int list[],int num){
  int i,j,min,key;
  for(i=0;i<num;i++){
    min=list[i];key=i;
    //i+1~num-1?????§????????¢??¢?´¢???????°???????????????????
    for(j=i+1;j<num;j++){
      if(list[j]<min){min=list[j];key=j;}
    }
    if(i!=key)swap(&list[i],&list[key]);
  }
}

int main(void){
  int N,i;
  scanf("%d",&N);

  int* list=(int*)malloc(sizeof(int)*N);
  if(list==NULL)exit(0);

  for(i=0;i<N;i++)scanf("%d",&list[i]);

  SelectionSort(list,N);
  for(i=0;i<N-1;i++)printf("%d ",list[i]);
  printf("%d\n%d\n",list[N-1],CountSwap);

  free(list);
  return 0;
}

Measured memory_bytes: 1804
{-# OPTIONS_GHC -O2 #-}

import           Control.Applicative
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.Vector                 as V
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM


main :: IO ()
main = do
    n <- readLn
    edges <- U.unfoldrN (n-1) (readInt3.B.dropWhile isSpace) <$> B.getContents
    print $ solve $ undirectedGraph n edges

solve :: Graph -> Cost
solve gr = diameter gr

readInt3 :: B.ByteString -> Maybe ((Int,Int,Int), B.ByteString)
readInt3 bs = Just ((x,y,z),bsz)
  where
    Just (x, bsx) = B.readInt bs
    Just (y, bsy) = B.readInt $ B.unsafeTail bsx
    Just (z, bsz) = B.readInt $ B.unsafeTail bsy

type Vertex = Int
type Cost = Int
type Edge = (Vertex, Vertex, Cost)
type Graph = V.Vector (U.Vector (Vertex, Cost))

directedGraph :: Int -> U.Vector Edge -> Graph
directedGraph numV edges = V.map U.fromList
    . V.unsafeAccumulate (flip (:)) (V.replicate numV [])
    . U.convert
    . U.map (\(src, dst, cost) -> (src, (dst, cost)))
    $ edges

undirectedGraph :: Int -> U.Vector Edge -> Graph
undirectedGraph numV edges = directedGraph numV
    $ edges U.++ U.map reverseEdge edges

reverseEdge :: Edge -> Edge
reverseEdge (src, dst, cost) = (dst, src, cost)
{-# INLINE reverseEdge #-}

diameter :: Graph -> Cost
diameter tree = U.maximum
    . shortestPath tree
    . U.maxIndex
    $ shortestPath tree 0

shortestPath :: Graph -> Vertex -> U.Vector Cost
shortestPath tree root = U.create $ do
    dist <- UM.unsafeNew (V.length tree)
    UM.unsafeWrite dist root 0
    U.forM_ (V.unsafeIndex tree root) $ \(v, cost) ->
        fix `flip` root `flip` v `flip` cost $ \dfs p u c -> do
            UM.unsafeRead dist p >>= UM.unsafeWrite dist u . (+c)
            U.mapM_ (uncurry $ dfs u)
                . U.filter ((/=p).fst)
                $ V.unsafeIndex tree u
    return dist

Measured memory_bytes: 80464
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	int sum=0;
    REP(i,3){
        int a;
        cin>>a;
        sum+=a;
    }
    if(sum>=22) OUT("bust");
    else OUT("win");
	return 0;
}


Measured memory_bytes: 256
ARG_N = gets.to_i
ARG_s = Array.new ARG_N
ARG_t = Array.new ARG_N
ARG_N.times do |i|
  ARG_s[i], t = gets.split
  ARG_t[i] = t.to_i
end
ARG_X = gets.chop

result = 0
a = ARG_s.find_index ARG_X
s = a+1
while(s < ARG_N) do
  result += ARG_t[s]
  s+=1
end

puts result

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n;
	cin>>n;
	set<string>a;
	for(ll i=0;i<n;i++){
		string now;
		cin>>now;
		a.insert(now);
	}
	cout << a.size();
	// your code goes here
	return 0;
}

Measured memory_bytes: 19124
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.flush();
	ll t=1;
	ll CaseN=1; 
	//cin>>t;
	while(t--)
	{
		ll a,b,c,k;
		cin>>a>>b>>c>>k;
		ll ans =0;
		if(k<=a)
		{
		ans = k;	
		}
		else
		{
		ans = ans+ a;	
		k = k-a;	
			
			if(k<=b)
			{
			ans += 0;	
				
			}
			else
			{
			k=k-b;	
			ans+=0;
			
			if(k<=c)
			{
			ans = ans - k;	
			}
			else
			{
			// 	
			ans =-1; // not possible to choose;	
			}
			
				
			}
			
		}
		
		
		//cout<<"Case #"<<CaseN<<": ";
		CaseN++;
		// print your ans below;
		cout<<ans<<endl;
	}

return 0;
}


Measured memory_bytes: 3656
#![allow(dead_code,unused_variables)]
use proconio::{fastout, input};
use std::ops::*;
use std::mem::swap;
use std::fmt;
const MOD : usize= 1_000_000_007;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize;n],
    }

    let mut aa : Vec<Modint>= Vec::new();
    for e in a{
        let x = e.into();
        aa.push(x);
    }
    let mut sum : Modint= 0.into();
    for i in 0..n{
        sum = sum + aa[i];
    }

    let mut ans : Modint = 0.into();

    for i in 0..n{
        let tmp = (sum - aa[i]) * aa[i];
        ans = ans + tmp;
    }

    println!("{}",ans/2.into());
}

#[derive(Copy,Clone)]
struct Modint{
    val : usize,
}

impl Modint{
    pub fn new(val : usize) -> Self{
        Modint{
            val : val%MOD,
        }
    }

    fn inv(&self) -> Self{
        let mut x : i32= 1;
        let mut u : i32= 0;
        let mut s : i32= self.val as i32;
        let mut t : i32= MOD as i32;

        while t != 0{
            let k = s/t;
            s -= k * t;
            swap(&mut s,&mut t);
            x -= k * t;
            swap(&mut x, &mut u);
        }
        x %= MOD as i32;
        if x < 0{
            x += MOD as i32;
        }
        
        let x = x as usize;
        Modint{
            val : x,
        }
    }
}

impl Add for Modint{
    type Output = Self;

    fn add(self, rhs: Self) -> Self {
        Self {
            val : (self.val + rhs.val) % MOD,
        }
    }
}

impl AddAssign for Modint {
    fn add_assign(&mut self, rhs: Modint) {
        *self = *self + rhs;
    }
}

impl Sub for Modint{
    type Output = Self;

    fn sub(self, other: Self) -> Self {
        Self {
            val :(MOD + self.val - other.val) % MOD,
        }
    }
}

impl SubAssign for Modint {
    fn sub_assign(&mut self, rhs: Modint) {
        *self = *self - rhs;
    }
}

impl Mul for Modint {
    type Output = Modint;

    fn mul(self, rhs: Modint) -> Self {
        Modint{
            val : (self.val * rhs.val) % MOD,
        }
    }
}

impl MulAssign for Modint {
    fn mul_assign(&mut self, rhs: Modint) {
        *self = *self * rhs;
    }
}

impl Div for Modint {
    type Output = Modint;

    fn div(self, rhs: Modint) -> Self {
        Modint{
            val : (self.val * rhs.inv().val) % MOD,
        }
    }
}

impl DivAssign for Modint {
    fn div_assign(&mut self, rhs: Modint) {
        *self = *self / rhs;
    }
}

impl From<i32> for Modint{
    fn from(x : i32) -> Self {
        let mut tmp = x;
        while tmp < 0{
            tmp += MOD as i32;
        }
        let res = Modint::new(tmp as usize);
        res
    }
}

impl From<usize> for Modint{
    fn from(x : usize) -> Self {
        let res = Modint::new(x);
        res
    }
}

impl fmt::Display for Modint{
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.val)
    }
}

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

int main(){
    string S;
    cin >> S;
    string T;
    for (const auto &s: S){
        if (s != 'B'){
            T.push_back(s);
            continue;
        }
        if (T.size() > 0)
            T.pop_back();
    }

    cout << T << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define in(a) cin >> a;
#define out(a) cout << a << endl;
#define inV(A) REP(i,A.size()) in(A[i]);
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-----------------------------------
int main(){
    init();
    ll n;
    cin >> n;
    // vl A(n);
    // inV(A);
    // (()?"Yes":"No")
    n=(n+1)/2;
    cout <<n<< endl;
}

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

int main(){
    ll N, M; cin >> N >> M;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    priority_queue<double> Q;
    rep(i, N) Q.push(A[i]);
    rep(i, M){
        double T = Q.top();
        Q.pop();
        T /= 2;
        Q.push(T);
    }
    ll ans = 0;
    while(!Q.empty()){
        ans += Q.top(); Q.pop();
    }
    cout << ans << endl;

    return 0;
}

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

int main() {

for(int i=0;i<3001;i++){
  int x,y;
  cin>>x>>y;

  if(x==0&&y==0) break;

  if(x>=y) cout<<y<<" "<<x<<endl;
  else cout<<x<<" "<<y<<endl;
}

}



Measured memory_bytes: 3080
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,k;
vector<int> p,q;
vector<int> id()
{
    vector<int> ret;ret.resize(n);
    for(int i=0;i<n;i++) ret[i]=i;
    return ret;
}
vector<int> getinv(vector<int> &p)
{
    vector<int> ret;ret.resize(n);
    for(int i=0;i<n;i++) ret[p[i]]=i;
    return ret;
}
vector<int> mul(vector<int> p,vector<int> q)
{
    vector<int> ret;ret.resize(n);
    for(int i=0;i<n;i++) ret[i]=p[q[i]];
    return ret;
}
vector<int> pow_(vector<int> &a,int x)
{
    vector<int> ret;ret.resize(n);
    for(int i=0;i<n;i++) ret[i]=i;
    while(x)
    {
        if(x&1) ret=mul(ret,a);
        a=mul(a,a);
        x>>=1;
    }
    return ret;
}
void go()
{
    vector<int> r=getinv(p);
    r=mul(q,r);
    p=q;q=r;
}
//lhs=qp'q'p
//rhs=p'qpq'
int main()
{
    scanf("%d%d",&n,&k);
    p.resize(n);q.resize(n);
    for(int i=0;i<n;i++) {scanf("%d",&p[i]); p[i]--;}
    for(int i=0;i<n;i++) {scanf("%d",&q[i]); q[i]--;}
    if(k==1)
    {
        for(int i=0;i<n;i++) printf("%d ",p[i]+1);
        return 0;
    }
    k-=2;
    while(k%6) {go(); k--;}
    vector<int> lhs=id(),rhs=id();
    lhs=mul(lhs,q);lhs=mul(lhs,getinv(p));lhs=mul(lhs,getinv(q));lhs=mul(lhs,p);
    rhs=mul(rhs,getinv(p));rhs=mul(rhs,q);rhs=mul(rhs,p);rhs=mul(rhs,getinv(q));
    lhs=pow_(lhs,k/6);rhs=pow_(rhs,k/6);
    lhs=mul(lhs,q);lhs=mul(lhs,rhs);
    for(int i=0;i<n;i++) printf("%d ",lhs[i]+1);
    return 0;
}



Measured memory_bytes: 3980
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  int n; scanf("%d",&n);
  ll sum = 0;
  REP(i,n){
    int tmp; scanf("%d",&tmp);
    sum += tmp;
  }
  cout << sum/n << endl;
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)
using namespace std;

int main(){
  int k, a, b;
  cin >> k;
  cin >> a >> b;
  bool flag = false;
  rep2(i, a, b+1){
    if (i % k == 0){
      flag = true;
      break;
    }
  }
  if (flag)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
  
  return 0;
}

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

int main(void) {
	int A, B, K;
	cin >> A >> B >> K;

	if (B - A + 1 > 2 * K) {
		for (int i = A; i < A + K; ++i)
			cout << i << '\n';
		for (int i = B - K + 1; i <= B; ++i)
			cout << i << '\n';
	}
	else {
		for (int i = A; i <= B; ++i)
			cout << i << '\n';
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#define MAX 100003
using namespace std;

void eratos ( int n, bool prime[]){
    for ( int i = 0; i <= n; i++ ) prime[i] = false;
    for ( int i = 3; i <= n; i += 2 ) prime[i] = true;
    prime[2] = true;
    int limit = (int)sqrt((double)n) + 1;
    for ( int i = 3; i <= limit; i += 2 ){
	if ( !prime[i] ) continue;
	for ( int j = i + i; j <= n; j += i ) prime[j] = false;
    }
}

int main(void){
    bool prime[MAX + 1];
    eratos(MAX, prime);

    int P[MAX];
    int size = 0;
    for ( int i = 2; i <= MAX; i++ ) if ( prime[i] ) P[size++] = i;

    int a, b, m, p, q, maxv, mp, mq;
    while(1){
	cin >> m >> a >> b;
	if ( a == 0 && b == 0 && m == 0 ) break;

	double r = 1.0*a/b;
	maxv = 0;
	mp = mq = -1;
	for ( int i = 0; i < size; i++ ){
	    p = P[i];
	    q = m/p;
	    for ( int q = m/p; q >= p; q-- ){
		if ( !prime[q] ) continue;
		
		if ( r > 1.0*p/q ) continue;
		if ( maxv < p*q ){
		    maxv = p*q;
		    mp = p;
		    mq = q;
		}
	    }
	}
	cout << mp << " " << mq << endl;

    }

    return 0;
}

Measured memory_bytes: 1004
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int K = scanner.nextInt();

        long sum = 0;
        for (int a=1; a<=K; a++) {

            for (int b=1; b<=K; b++) {

                for (int c=1; c<=K; c++) {
                    int gcd = gcd(a, b, c);
                    sum += gcd;
                }
            }
        }
        System.out.println(sum);
    }

    private static int gcd(int a, int b, int c) {
        int gcd = gcd(a, b);
        int gcd1 = gcd(a, c);
        return gcd(gcd, gcd1);
    }

    private static int gcd (int a, int b) {return b>0 ? gcd(b,a%b): a;}
}


Measured memory_bytes: 35792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int m, k;
    cin >> m >> k;
    int power = 1;
    for(int i = 1; i <= m; i++){
        power = power * 2;
    }
    if(k >= power){
        cout << "-1";
        return 0;
    }
    if(m == 1 && k == 1){
        cout << "-1";
        return 0;
    }
    if(m == 1 && k == 0){
        cout << "0 0 1 1";
        return 0;
    }
    else{
        for(int i = 0; i < power; i++){
            if(i == k){
                continue;
            }
            cout << i << ' ';
        }
        cout << k << ' ';
        for(int i = power - 1; i >= 0; i--){
            if(i == k){
                continue;
            }
            cout << i << ' ';
        }
        cout << k << ' ';
    }
    return 0;
}

Measured memory_bytes: 1792
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt() + sc.nextInt()
    val b = sc.nextInt() + sc.nextInt()
    println(when {
        a > b -> "Left"
        a < b -> "Right"
        else -> "Balanced"
    })
}

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

void solve(long long X)
{
    for (ll i = -120; i <= 120; i++) {
        for (ll j = i + 1; j <= 120; j++) {
            if (j*j*j*j*j - i*i*i*i*i == X) {
                cout << j << " " << i << endl;
                return;
            }
        }
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
#pragma GCC diagnostic ignored "-Wunused-result"
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3756
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<utility>
#include<queue>
using namespace std;
#define INF 1<<30

struct edge {
	int t, d;//to/dist
};

int N, K;
vector<int>C, R, vcos;//ngcos
vector<int> v[5002];//connection
vector<edge> V[5002];//connection
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;//cost/vartex id

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) vcos.push_back(INF);
	for (int i = 0; i < N; i++) {
		int c, r;
		cin >> c >> r;
		C.push_back(c);
		R.push_back(r);
	}
	for (int i = 0; i < K; i++) {
		int A, B; cin >> A >> B; A--; B--;
		v[A].push_back(B);
		v[B].push_back(A);
	}
	//BFS & make graph
	for (int i = 0; i < N; i++) {
		bool vzt[5002];
		for (int j = 0; j < N; j++) vzt[j] = false;

		queue<pair<int, int>> q;
		q.push({ i, 0 });
		while (!q.empty()) {
			pair<int, int> tmp = q.front();
			q.pop();
			for (int j = 0; j < v[tmp.first].size(); j++) {
				if (!vzt[v[tmp.first][j]]) {
					vzt[v[tmp.first][j]] = true;
					q.push({ v[tmp.first][j], tmp.second + 1 });
					if (tmp.second + 1 <= R[i]) {
						edge tm = { v[tmp.first][j], C[i] };
						V[i].push_back(tm);
					}
				}
			}
		}
	}

	//Dijkstra
	pq.push({ 0, 0 });
	while (!pq.empty()) {
		pair<int, int> tp = pq.top();
		pq.pop();
		if (vcos[tp.second] == INF) {
			vcos[tp.second] = tp.first;
			for (int i = 0; i < V[tp.second].size(); i++) {
				pq.push({ vcos[tp.second] + V[tp.second][i].d, V[tp.second][i].t });
				//コストが未確定頂点のうち最小のもの+辺のコスト, 辺の先の頂点
			}
		}
	}
	cout << vcos[N - 1] << endl;
	return 0;
}



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

int main() {
    int n;
    string s;
    cin >> n >> s;
    for(auto &c : s) {
        c += n;
        if(c > 'Z')
            c -= 26;
    }
    cout << s << endl;
    return 0;
}


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	for (;;) {
		c -= b;
		if (c <= 0) break;
		a -= d;
		if (a <= 0) break;
	}

	if (a > 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int A, B;
  cin >> A >> B;
  int ans;
  if (A >= 13){
    ans = B;
  }
  else if (A >= 6 && A <= 12){
    ans = B / 2;
  } else {
    ans = 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*
    author: Salam_35
    Created at :

*/

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

/*        speed up       */
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF    1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() _fastio;int testsalam;cin >> testsalam;while(testsalam--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
#define endl '\n'
//void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}
string inttostr(ll n){std::stringstream ss;ss << n;string out=ss.str();return out;}
ll stringtoint(string s){istringstream iss (s);ll n;iss >> n;return n;}
template <typename T> T gcd(T a,T b){if(a < 0)return gcd(-a,b);if(b < 0)return gcd(a,-b);return (b == 0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a < 0)return lcm(-a,b);if(b < 0)return lcm(a,-b);return a*(b/gcd(a,b));}
typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

bool cmp(const pair<int,int>&a,const pair<int,int>&b)
{
	if(a.first==b.first)
		return a.second<b.second;
	else return a.first<b.first;
}

int main()
{
	int n;
	cin >> n;
	map<int,int>cnt;
	int arr[n+10];
	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >>a ;
		arr[i]=a;
		cnt[a]++;
		// if(cnt[a]<=1)
		// {
		// 	for(int j=a;j<=100;j+=a)
		// 	{
		// 		//cout<<"marking j "<<j<<endl;
		// 		cnt[j]++;
		// 	}
		// }
	}
	int ans=0;
	for (int i = 0; i < n; ++i)
	{
		int no=0;
		int x=arr[i];
		// cout<<" for "<<x<<endl;
		for(int j=1;j<=sqrt(x+1);j++)
		{
			if(x%j==0)
			{
				if(j==1 )
				{
					if(x==1 and cnt[1]>1)no=1;
					else if(x!=1 and cnt[1])no=1;
				}
				if(j==x or x/j==x)
				{
					if(cnt[j]>1 or cnt[x/j]>1)no=1;
				}
				else if(cnt[j] or cnt[x/j])no=1;
			}
		}
		if(!no)ans++;//cout<<"true for "<<x<<endl;
	}
	cout<<ans<<endl;
}
/*
 		remember:
 		ll vs int
 		array size
 		case for 1 2 3 
*/


Measured memory_bytes: 33404
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll H;
    cin >> H;
    ll ans = 0;
    ll cur = 1;
    while(H) {
        H /= 2;
        ans += cur;
        cur <<= 1;
    }
    output(ans);
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;

int main(){
   int k,x;
   cin >> k >> x;
   
   if(x <= k*500) cout << "Yes\n";
   else cout << "No";
   
   return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    s = S()
    print("x" * len(s))

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
import java.io.*;
import java.lang.*;
import java.util.*;

class Main {
	static int[] parents;
	static int[] weight;
	static int[] rank;
	
	static int find(int x) {
		if (x == parents[x]) 
			return x;
		else {
			int r = find(parents[x]);
			weight[x] += weight[parents[x]];
			return parents[x] = r;
		}
	}

	static int weight(int x) {
		find(x);
		return weight[x];
	}

	static void relate(int x, int y, int z) {
		z += weight(x);
		z -= weight(y);
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rank[x] < rank[y]){
			int tmp = x;
			x = y;
			y = tmp;
			z = -z;
		}

		if(rank[x] == rank[y]){
			rank[x]++;
		}

		parents[y] = x;
		weight[y] = z;
	}

	static void diff(int x, int y) {
		if(find(x) == find(y)) {
			System.out.println(weight(y) - weight(x));
		} else {
			System.out.println("?");
		}
	}

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int q = scanner.nextInt();

		parents = new int[n];
		weight = new int[n];
		rank = new int[n];

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

		int type, x, y, z;
		for (int i = 0; i < q; i++) {
			type = scanner.nextInt();
			x = scanner.nextInt();
			y = scanner.nextInt();

			if(type == 0) {
				z = scanner.nextInt();
				relate(x, y, z);
			} else {
				diff(x, y);
			}
		}
	}

	
}


Measured memory_bytes: 167892
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    string s;
    cin >> s;
    int n = s.size();
    if(s[0]!=s[n-1]){
        if(n%2==1) cout << "First" << endl;
        else cout << "Second" << endl;
    }
    else{
        if(n%2==1) cout << "Second" << endl;
        else cout << "First" << endl;
    }
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

#define ll long long
ll n,W,w[1000000],v[1000000];
ll knapsack(){
	ll dp[n+1][W+1];
	for(ll i=0;i<=n;i++){
		for(ll wt=0;wt<=W;wt++){
			if(i==0 || wt==0)
				dp[i][wt]=0;
			else if(w[i-1]<=wt)
				dp[i][wt]=max(v[i-1]+dp[i-1][wt-w[i-1]], dp[i-1][wt]);
			else
				dp[i][wt]=dp[i-1][wt];
		}
	}
	return dp[n][W];
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n>>W;
	for(ll i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	cout<<knapsack();
	return 0;
}

Measured memory_bytes: 81280
#include<stdio.h>
int main()
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if( (x+r)<=W && (y+r)<=H && x>=r && y>=r){
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 2104
/** author: __nishad__ **/
#pragma GCC optimize(2)
#pragma GCC optimize(3, "Ofast", "inline")
#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a,b) for(ll i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    int a, b;
    cin>>a>>b;
    cout<<a*b;

}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int ggcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,count=0;
  cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  sort(v.begin(),v.end());
  if(vec_sum(v)%10!=0){
    cout<<vec_sum(v)<<endl;
    return 0;
  }else{
    rep(i,n){
      if(v[i]%10!=0){
        cout<<vec_sum(v)-v[i]<<endl;
        return 0;
      }else{
        count++;
      }
    }
  }
  cout<<0<<endl;
  return 0;
}
///////////////////////////

Measured memory_bytes: 256
// https://atcoder.jp/contests/agc029/tasks/agc029_b

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = 0;
    cin >> n;
    vector<int> v(n);
    // 値に対して個数を持つ。ペアとして使用する際に個数を数える。
    multiset<int> m;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        m.insert(a);
    }

    // 大きい値から順に処理する
    while (!m.empty()) {
        auto it = m.rbegin();
        int x = *(it);
        // base()メンバ関数で取得したイテレータの位置を補正する
        m.erase((++it).base());
        // xより大きい２のべき乗を作成
        ll p = 1;
        while (p <= x)
            p *= 2;
        int y = p - x; // ペアとなるyは1通り
        auto itr = m.find(y);
        if (itr != m.end()) {
            m.erase(itr);
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10368
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		int D = sc.nextInt();
		int L = sc.nextInt();
		while(T+D+L != 0) {
			int[] x = new int[T];
			for(int i = 0; i < T; i++) {
				x[i] = sc.nextInt();
			}
			int ans = 0;
			int sec = 0;
			for(int i = 0; i < T-1; i++) {
				if(x[i] >= L) {
					ans ++;
					sec = D-1;
				}else if(sec > 0) {
					ans ++;
					sec --;
				}
			}
			System.out.println(ans);
			T = sc.nextInt();
			D = sc.nextInt();
			L = sc.nextInt();
		}
		sc.close();
	}
}



Measured memory_bytes: 248224
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


int main(void){
	int n;
	cin >> n;
	cout << n / 3 << endl;
}


Measured memory_bytes: 256