akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,a,b,c,d;
  cin>>N;
  a = N/1000;
  b = (N - 1000*a)/100;
  c = (N-1000*a-100*b)/10;
  d = N-1000*a-100*b-10*c;
    if((a==b&&b==c)||(b==c&&c==d)){
    cout<<"Yes"<<endl;
   }else{
    cout<<"No"<<endl;
   }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

//??\???????????????
//4
//1 2 2 4
//2 1 4
//3 0
//4 1 3

bool Path[101][101] = {false};

int main(){
    int  N;
    cin >> N;
    int bb;
    for (int i = 1; i <= N; i++) {
        int K;
        scanf("%d %d",&bb,&K);
        for (int k = 0; k < K; k++) {
            int p;
            scanf("%d",&p);
            
            Path[i][p] = true;
        }
    }
    
    for (int r = 1; r <= N; r++) {
        for (int c = 1; c <= N; c++) {
            printf("%d",Path[r][c]);
            if (c != N) printf(" ");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1236
#include<stdio.h>
int main()
{
	int a,b,c,d;
	while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF)
	{
		if(a+b>c+d)
		printf("Left\n");
		else if(a+b<c+d)
		printf("Right\n");
		else if(a+b==c+d)
		printf("Balanced\n");
		
	}
	return 0;
}

Measured memory_bytes: 128
'''
Created on 2020/09/02

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  s=list(pin()[:-1])
  
  cnt=0
  while s:
    if len(s)==1:
      break
    elif s[0]==s[-1]:
      s.pop(0)
      s.pop(-1)
    else:
      if s[0]!='x' and s[-1]!='x':
        print(-1)
        return 
      else:
        if s[0]=='x':
          s.pop(0)
        else:
          s.pop(-1)
        cnt+=1
  print(cnt)
  return 
main()

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

int main(void){
   int N;
   cin>>N;
   vector<int> A(N);
   for(int i=0;i<N;i++){
      cin>>A[i];
   }
   long long ans=1;
   long long reject=1;
   for(int i=0;i<N;i++){
      ans*=3;
      if(A[i]%2==0) reject*=2;
   }
   cout<<ans-reject<<endl;
   return 0;
}


Measured memory_bytes: 3612
N,D = input().split()
N = int(N)
D = int(D)
X = []
Y = []
count = 0
for i in range(N):
  X.append(0)
  Y.append(0)
  X[i],Y[i] = input().split()
  X[i] = int(X[i])
  Y[i] = int(Y[i])
for i in range(N):
  x = X[i]*X[i]
  y = Y[i]*Y[i]
  z = D*D
  if z >= x + y:
    count += 1
print(count)

Measured memory_bytes: 24844
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  
using namespace std;
 
const ll inf = 1e17;
const ll N = 2010;
const ll bits = 30;
const ll mod = 998244353;



int main(){
    FASTIO;
    ll n,w;
    cin>>n>>w;

    vector< vector<ll> >arr(n+1,vector<ll>(2,0));
    ll val_sum = 0;
    for(int i=1;i<=n;i++){
        cin>>arr[i][0]>>arr[i][1];
        val_sum+=arr[i][1];
    }

    vector< ll >dp(val_sum+1,inf);

    ll ans = 0;
    dp[0] = 0;

    for(int i=1;i<=n;i++){
        // for(int j=0;j+arr[i][1]<=val_sum; j++){
        //     dp[j+arr[i][1]] = min(dp[j+arr[i][1]],dp[j]+arr[i][0]);
        // }

        for(int j=val_sum-arr[i][1];j>=0;j--){
            dp[j+arr[i][1]] = min(dp[j+arr[i][1]],dp[j]+arr[i][0]);
        }
    }

    for(int i=val_sum;i>=0;i--){
        if(dp[i]<=w){
            cout<<i<<"\n";
            return 0;
        }
    }

    cout<<ans<<"\n";

    

    // for(int i=1;i<=n;i++){
    //     for(int j=0;j<=w;j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<"\n";
    // }



    
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

N, M = map(int, input().split())


ans = [1] * N
H = list(map(int, input().split()))

G = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    G[A].append(B)
    G[B].append(A)

count = N

for i in range(N):
    tmp = H[i]
    for next_ in G[i]:
        if tmp <= H[next_]:
            count -= 1
            break

print (count)


Measured memory_bytes: 30252
# -*- coding: utf-8 -*-


def main():
    s = [c for c in input()]
    k = int(input())
    l = len(s)

    # See:
    # https://atcoder.jp/contests/code-festival-2016-quala/submissions/1033174
    for i in range(l):
        t = (ord('z') - ord(s[i]) + 1) % 26

        if t <= k:
            k -= t
            s[i] = 'a'

    s[-1] = chr((ord(s[-1]) - ord('a') + k) % 26 + ord('a'))

    print(''.join(s))


if __name__ == '__main__':
    main()


Measured memory_bytes: 4212
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC072
{
    class ProblemB
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            string result = "";
            for(int i = 0; i < s.Length; i++)
            {
                if ((i + 1) % 2 != 0) result += s[i];
            }

            Console.WriteLine(result);
        }
    }
}


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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x) for (auto&& v : (x))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))

pair<ll, ll> m[10100];
ll ans_[10001];
ll n;
ll ans(ll h) {
  if (h <= 0) return 0;
  if (ans_[h] >= 0) return ans_[h];
  ll result = LLONG_MAX;
  rep(i, n) updatemin(result, m[i].second + ans(h - m[i].first));
  return ans_[h] = result;
}
int main() {
  ll h;
  cin >> h >> n;
  rep(i, n) cin >> m[i].first >> m[i].second;
  rep(i, 10001) ans_[i] = -1;
  cout << ans(h) << endl;
}


Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll i,j,k,l,m,n,o,p,q,r;
    ll ans=0;
    string s,t;
    cin>>s>>t;

    for(i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3916
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(x) ((x)>0?(x):(-(x)))
using namespace std;
const int maxn=3e5+10,INF=~0U>>1;
typedef double db;
const db PI=acos(-1);
struct point
{
	int x,y;
}p[maxn];
int X1,Y1,X2,Y2,n,stack[maxn],top=0,e[maxn],cnt=0,mix,maxx,may,miy;
db ans;
bool flag=0;
bool check(point);
bool cmp(const int&,const int&);
void binary_search(int,int,int*);
int main()
{
//	freopen("error_input.in","r",stdin);
	scanf("%d%d%d%d%d",&X1,&Y1,&X2,&Y2,&n);
	if(X1>X2) swap(X1,X2),swap(Y1,Y2);
	if(Y1>Y2) Y1=-Y1,Y2=-Y2,flag=1;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&p[i].x,&p[i].y);
		if(flag) p[i].y=-p[i].y;
		if(check(p[i])) e[++cnt]=i;
	}
	sort(e+1,e+cnt+1,cmp);
	stack[0]=-INF;
	for(int i=1;i<=cnt;i++) 
	{
//		printf("%d ",p[e[i]].y);
		if(!top||p[e[i]].y>p[stack[top]].y)
		{
			stack[++top]=e[i];
		}
		else binary_search(e[i],top,stack);
	}
//	putchar('\n');
//	if(stack[top+1]) top++;
	ans=(X2-X1+Y2-Y1)*100.0;
	if(X1==X2||Y1==Y2)
	{
		if(cnt) ans+=10.0*PI-20.0;
	}
	else
	{
		ans-=(20.0-5.0*PI)*top;
		if(top==min(X2-X1,Y2-Y1)+1) ans+=5*PI;
	}
	printf("%.20f",ans);
	return 0;
}
bool cmp(const int &a,const int &b)
{
	return p[a].x<p[b].x;
}
bool check(point a)
{
	return a.x>=X1&&a.x<=X2&&a.y>=Y1&&a.y<=Y2;
}
void binary_search(int x,int r,int* s)
{
	int l=1,mid;
	while(l<=r)
	{
		mid=(l+r)>>1;
		if(p[x].y>p[s[mid]].y) l=mid+1;
		else r=mid-1;
	}
	s[l]=x;
}

Measured memory_bytes: 3840
class Main {
    public static void main(String[] a) {
        for (int i = 1; i < 10; ++i) {
            for (int j = 1; j < 10; ++j) {
                System.out.printf(i + "x" + j + "=" + (i*j) + "\n");
            }
        }
    }
}

Measured memory_bytes: 16908
N=input()
n=len(N)

if len(N)>1:
    #print(">=10")
    for i in range(n-1):
        now=N[n-1-i]
        #print("i,now",i,now)
        if now!='9':
            #print("not (9 or 8)")
            tosub=int(now)+1
            left=int(N[:n-1-i+1])-tosub
            right=N[n-1-i+1:]
            #print("tosub,left,right",tosub,left,right)
            N=str(left)+str(right)
            N.zfill(n)
            #print("new N",N)

num=0
for i in N:
    num+=int(i)
print(num)

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll MOD = (ll)1e9 + 7;
const int N = (int)1e5 + 9;
ll pwr[N];

int main(){
  fastIO;
  string t;
  cin >> t;
  int n = t.size();
  ll par = 0;
  pwr[0] = 1;
  for(int i = 1; i < n; i ++ ){
    pwr[i] = (pwr[i - 1] * 3ll) % MOD;
    par += pwr[i - 1];
    par %= MOD;
  }
  ll y = 1;
  for(int i = 1 ; i < n; i ++ ){
    if(t[i] == '1'){
      par += (y*pwr[n - i - 1])%MOD;
      par %= MOD;
      y = (y * 2ll) % MOD;
    }
  }
  par=(par+y)%MOD;
  par=(par*2ll)%MOD;
  par=(par+1)%MOD;
  cout << par << "\n";
  return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>

const int N = 305;
const int M = 305;
int main()
{
	int n, m;
	while(scanf("%d %d", &n, &m))
	{
		if(n == 0 && m == n)
		{
			break;
		}
		for(int i = 0;i < m ; i++)
		{
			printf("#");
		}
		printf("\n");
		for(int i = 0; i < n-2; i++)
		{
			printf("#");
			for(int j = 0; j < m-2; j++)
			{
				printf(".");
			}
			printf("#");
			printf("\n");
		}
		for(int i = 0; i < m; i++)
		{
			printf("#");
		}
		printf("\n\n");
	}
	return 0;
}


Measured memory_bytes: 2508
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N;
    cin >> N;
    vector<ll> a(N),b(N);
    rep(i,N) cin >> a[i];
    rep(i,N) cin >> b[i];
    sort(all(a));
    sort(all(b));

    vector<ll> dp(N+10,0);
    dp[0] = 1;
    for(int i=0;i<N;i++){
        if(a[i]==b[i]){
            dp[i+1] = dp[i];
        }else if(a[i] > b[i]){
            int id = upper_bound(a.begin(),a.end(),b[i]) - a.begin();
            int k = i - id + 1;
            dp[i+1]=dp[i]*k%mod;
        }else{
            int id = upper_bound(b.begin(),b.end(),a[i]) - b.begin();
            int k = i - id + 1;
            dp[i+1]=dp[i]*k%mod;
        }
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
using namespace std;
int main() {
	long long k, x; cin >> k >> x;
	for (int i = x - k + 1; i < x + k; i++) {
		if (i < -1000000 || i>1000000) { continue; }
		cout << i << " " ;
	}
	cout << endl;
	return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    int ans = 0;
    vector<int> H(N);
    for(int i = 0; i < N; i++){
        cin >> H[i];
        if(H[i] < K)ans++;
    }
    cout << N - ans << endl;
    return 0;
}

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


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a * b * c == 5 * 5 * 7) cout << "YES" <<endl;
  else cout << "NO" << endl;
  return 0;
}

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

int main()
{   
    string daysOfWeek[7]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
    string day;
    int ans;
    cin>>day;
     for(int i=0;i<7;i++)
        {
            if(day==daysOfWeek[i])
            {   
                ans=6-i;
                if(ans==0)
                {cout<<"7";}
                else {cout<<ans;}
            }
        }
    
    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
p=list(map(int,input().split()))
Exception_p=[]
for i in range(N):
    Exception_p.append((1+p[i])/2)
sum_Exception=[]
sum=0
for k in range(K):
    sum=(p[k]+1)/2+sum
sum_Exception.append(sum)
for i in range(N-K):
    sum=sum_Exception[i]-p[i]/2+p[i+K]/2
    sum_Exception.append(sum)
list.sort(sum_Exception)    
print(sum_Exception.pop(-1))


Measured memory_bytes: 25604
from math import gcd
from functools import reduce

def make_prime_table(n):
    sieve = list(range(n + 1))
    sieve[0] = -1
    sieve[1] = -1
    for i in range(4, n + 1, 2):
        sieve[i] = 2
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i] != i:
            continue
        for j in range(i * i, n + 1, i * 2):
            if sieve[j] == j:
                sieve[j] = i
    return sieve


def prime_factorize(n):#1を除く(素因数,指数)のリスト
    result = []
    while n != 1:
        p = prime_table[n]
        e = 0
        while n % p == 0:
            n //= p
            e += 1
        result.append((p, e)) 
    return result


def f():
    s = set()
    for i in range(N):
        t = prime_factorize(A[i])
        for p, _ in t:
            if p in s:
                return False
            s.add(p)
    return True


N=int(input())
A=list(map(int, input().split()))

prime_table = make_prime_table(10 ** 6)
if f():
    print('pairwise coprime')
elif reduce(gcd, A) == 1:
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 127712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

ll K;
vector<ll> ans;

int main(void){
	
	scanf("%lld", &K);
	
	ll n = K % 50;
	for(int i = 0; i < 50 - n; ++i) ans.push_back(49 - n);
	for(int i = 0; i < n; ++i) ans.push_back(50);
	
	ll m = K / 50;
	for(int i = 0; i < 50; ++i) ans[i] += m;
	
	printf("%lld\n", (ll)ans.size());
	for(int i = 0; i < ans.size(); ++i){
	    if(i) printf(" ");
	    printf("%lld", ans[i]);
	}
	printf("\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int h[n];
  for(int i=1;i<=n;i++)cin>>h[i];
  int dp[n+1];
  dp[1]=0;
  dp[2]=abs(h[2]-h[1]);
  for(int i=3;i<=n;i++){
    dp[i]=INT_MAX;
    for(int j=1;j<=k;j++){
      if(i-j>=1){
        dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
      }
    }
  }
  cout<<dp[n];
}

Measured memory_bytes: 1024
#include<iostream>
#include<stack>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

int main()
{
  stack<int> S;
  char c[10];
  int x,y;
  while((scanf("%s",&c))!=EOF){
    if(c[0]=='+'){
      x=S.top();S.pop();
      y=S.top();S.pop();
      S.push(x+y);
    }
    else if(c[0]=='-'){ 
      x=S.top();S.pop();
      y=S.top();S.pop();
      S.push(y-x);
    }
    else if(c[0]=='*'){
      x=S.top();S.pop();
      y=S.top();S.pop();
      S.push(x*y);
    }
    else{
      S.push(atoi(c));
    }
  }
  cout<<S.top()<<endl;
  return 0;
}

Measured memory_bytes: 1208
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main()
    {
        string s = Console.ReadLine();

        string s_new = s.Replace("2017", "2018");
        
        Console.WriteLine(s_new);
    }
}

Measured memory_bytes: 11092
N = gets.to_i
S = gets.chomp

counter = S.chars.tally
counter.default = 0

ans = counter['R'] * counter['G'] * counter['B']

1.upto(N) do |i|
  j = 0

  while j + 2 * i < N
    ans -= 1 if S[j] != S[j + i] && S[j + i] != S[j + 2 * i] && S[j] != S[j + 2 * i]
    j += 1
  end
end

puts ans


Measured memory_bytes: 14716
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
cin>>a>>b>>c;
if(b>=a){
if(c>=a&&c<=b)cout<<"Yes";
else cout<<"No";
}else if(a>b){if(c>=b&&c<=a)cout<<"Yes";
else cout<<"No";
}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cstdlib>
#include<vector>
#define MAX_V 1000
#define INF 1<<29
#define cl(a,b) for(int i=0;i<a;i++)for(int j=0;j<b;j++)cost[i][j] = INF;
#define de(a)  for(int i=0;i<a;i++){cout << mincost[i] << " "; if(i == a-1){cout << endl;}}
#define de2(a,b) for(int I=0;I<a;I++){for(int j=0;j<b;j++){cout << cost[I][j] << " ";}cout << endl;}cout << endl;
using namespace std;

int cost[MAX_V][MAX_V];
int mincost[MAX_V];
bool used[MAX_V];
int V;
 bool connect[10000];

int prime()
{
  for(int i=0;i<V;++i)
    {
      mincost[i]=INF;
      used[i]=false;
    }

  mincost[0] = 0;
  int res = 0;

  //de(10);
  

  //de2(10,10);
  

  while(true)
    {
      int v = -1; 
      for(int u = 0; u<V ; u++ )
	{
	  if(connect[u] && !used[u] && (v == -1 || mincost[u] < mincost[v]))
	    {
	      v = u;
	    }
	}

      if(v == -1)break;
      used[v] = true;
      res += mincost[v];
     
      for(int u = 0; u < V; u++)
	{
	 
	  mincost[u] = min(mincost[u],cost[v][u]);
	  //cout << "mincost[u] = " << mincost[u] << ", cost[v][u] = " << cost[v][u] << endl;
	  
	}
    }
  return res;
}



int main()
{

  int n,m,a,b;
 

  while(true)
    {
      cin >> n >> m;
      if(n == 0 && m == 0)break;
      cl(n,n);
      memset(connect,false,sizeof(connect));

      V = n;
      for(int i=0;i<m;i++)
	{
	  cin >> a >> b;
	  cin >> cost[a][b];
	  cost[b][a] = cost[a][b];
	  connect[a] = true;
	  connect[b] = true;
	}
      

      cout << prime() << endl;




    }

}

Measured memory_bytes: 0
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;

ll binary_search(function<bool(ll)> func, ll start, ll end) {
    /*      func:int ->bool
            returns smallest int x where func(x) evaluates to true, searches in [start,end), it is assumed the values are false, .. , false, true ...
             */
    if (end <= start) {   return end;  }   // has to be here, otherwise func(end-1) in next line could be a problem
    if (!func(end-1)) {  return end;  }
    while (end-start>1) {
        ll mid = (start+end)/2;
        if (func(mid)) {  end = mid;  } else { start = mid;   }
    }
    if (func(start)) {  return start;  } else {  return end;   }
}; 


int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
 
//    auto start = chrono::steady_clock::now();
  
//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(h);
        ll n = 1; ll ans = 0;
        while (h>0) {
            ans+=n;
            n*=2;
            h/=2;
        }

        cout << ans << endl;
    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;
 
    return 0;
}

Measured memory_bytes: 3652
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
//vector<int> bucket[MAX_N/1000];

int main(void){
    int N,T;
    cin >> N >> T;
    int A[N],B[N];
    rep(i,N) cin >> A[i] >> B[i];
    int dp1[N+1][T+1],dp2[N+1][T+1];
    rep(i,N+1) rep(j,T+1) dp1[i][j]=dp2[i][j]=-INF;
    rep(i,T+1) dp1[0][i]=dp2[N][i]=0;
    rep(i,N) rep(j,T){
        if(j+A[i]<=T) dp1[i+1][j+A[i]]=max(dp1[i+1][j+A[i]],dp1[i][j]+B[i]);
        dp1[i+1][j]=max(dp1[i+1][j],dp1[i][j]);
    }
    reprev(i,N) rep(j,T){
        if(j+A[i]<=T) dp2[i][j+A[i]]=max(dp2[i][j+A[i]],dp2[i+1][j]+B[i]);
        dp2[i][j]=max(dp2[i][j],dp2[i+1][j]);
    }
    int ans=0;
    rep(i,N) rep(j,T){
        int cmp=B[i];
        cmp+=dp1[i][j];
        cmp+=dp2[i+1][T-1-j];
        ans=max(ans,cmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 73968
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
ll x;
cin>>x;
vector<bool>era(pow(10,5)+10);
for(auto f:era){
    f=true;
}
era[0]=false;
era[1]=true;
for(int i=2;i<era.size();i++){
    ll j=2;
    while(i*j<era.size()){
        era[i*j]=false;
        j++;
    }
}
for(int i=x;i<era.size();i++){
    if(era[i]==true){
        cout<<i<<endl;
        break;
    }
}

}





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

int main(){
    int A,B,C,K,i,maxnum,X;
    cin >> A >> B >> C;
    cin >> K;
    maxnum = max(A,B);
    if(maxnum==A){
        X = 0;
    }else{
        X = 1;
    }
    maxnum = max(maxnum,C);
    if(maxnum==C){
        X = 2;
    }
    for(i=0;i<K;i++){
        maxnum *= 2;
    }
    if(X==0){
        cout << maxnum + B + C << endl;
    }else{
        if(X==1){
            cout << maxnum + A + C << endl;
        }else{
            cout << maxnum + A + B << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	unique := func(a []int) []int {
		n := len(a)
		sort.Ints(a)
		j := 0
		for i := 1; i < n; i++ {
			if a[j] != a[i] {
				j++
				a[j] = a[i]
			}
		}
		return a[:j+1]
	}
	discrete := func(a []int) map[int]int {
		ids := make(map[int]int, len(a))
		for i, v := range a {
			ids[v] = i
		}
		return ids
	}
	type line struct{ a, b, c int }
	type pair struct{ x, y int }

	var n, m, a, b, c, ans int
	Fscan(in, &n, &m)
	xs := make([]int, 0, 3+2*n+m)
	ys := make([]int, 0, 3+n+2*m)
	xs = append(xs, -2e9, 0, 2e9)
	ys = append(ys, -2e9, 0, 2e9)
	lr := make([]line, n)
	for i := range lr {
		Fscan(in, &a, &b, &c)
		lr[i] = line{a, b, c}
		xs = append(xs, a, b)
		ys = append(ys, c)
	}
	du := make([]line, m)
	for i := range du {
		Fscan(in, &a, &b, &c)
		du[i] = line{a, b, c}
		xs = append(xs, a)
		ys = append(ys, b, c)
	}
	xs = unique(xs)
	xi := discrete(xs)
	ys = unique(ys)
	yi := discrete(ys)

	lx, ly := len(xi), len(yi)
	glr := make([][]int, lx)
	gdu := make([][]int, lx)
	vis := make([][]bool, lx)
	for i := range glr {
		glr[i] = make([]int, ly)
		gdu[i] = make([]int, ly)
		vis[i] = make([]bool, ly)
	}
	for _, p := range lr {
		glr[xi[p.a]][yi[p.c]]++
		glr[xi[p.b]][yi[p.c]]--
	}
	for _, p := range du {
		gdu[xi[p.a]][yi[p.b]]++
		gdu[xi[p.a]][yi[p.c]]--
	}
	for i := 1; i < lx-1; i++ {
		for j := 1; j < ly-1; j++ {
			glr[i][j] += glr[i-1][j]
			gdu[i][j] += gdu[i][j-1]
		}
	}

	q := []pair{{xi[0], yi[0]}}
	for len(q) > 0 {
		p := q[0]
		q = q[1:]
		x, y := p.x, p.y
		if x == 0 || x == lx-1 || y == 0 || y == ly-1 {
			Fprint(_w, "INF")
			return
		}
		if !vis[x][y] {
			vis[x][y] = true
			ans += (xs[x+1] - xs[x]) * (ys[y+1] - ys[y])
			if glr[x][y] == 0 {
				q = append(q, pair{x, y - 1})
			}
			if glr[x][y+1] == 0 {
				q = append(q, pair{x, y + 1})
			}
			if gdu[x][y] == 0 {
				q = append(q, pair{x - 1, y})
			}
			if gdu[x+1][y] == 0 {
				q = append(q, pair{x + 1, y})
			}
		}
	}
	Fprint(_w, ans)
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 360972
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
        a[i]--;
    }
    int out=0;
    for(int i=0;i<N;i++){
        int l=a[i];
        cerr << a[i] << "\t" << a[l] << "\t" << l << endl;
        if(i==a[l] && i<l) out++;
    }
    cout << out << endl;
    return 0;
}


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

#define MAX 100000+100

bool notPrime[MAX];
int Count[MAX];

void findPrime(){
    notPrime[0] = notPrime[1] = true;
    for(int i=2; i*i<MAX; i++){
        if(!notPrime[i]){
            for(int j=i*i; j<MAX; j+=i)
                notPrime[j] = true;
        }
    }
}

void solve(){
    int cnt = 0;
    for(int i=0; i<MAX; i++){
        if(!notPrime[i] && !notPrime[(i+1)/2])
            ++cnt;
        Count[i] = cnt;
    }
}

int main(){
    findPrime();
    solve();

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

    while(q--){
        int a,b;
        scanf("%d %d",&a,&b);

        printf("%d\n",Count[b] - Count[a-1]);
    }

    return 0;
}



Measured memory_bytes: 1152
// A C++ program to find maximal Bipartite matching.
#include <iostream>
#include <string.h>
#include <vector>
using namespace std;
 
// M is number of applicants and N is number of jobs

bool bpGraph[200][200];
int N;


// A DFS based recursive function that returns true if a
// matching for vertex u is possible
bool bpm(int u, bool seen[], int matchR[])
{
    // Try every job one by one
    for (int v = 0; v < N; v++)
    {
        // If applicant u is interested in job v and v is
        // not visited
        if (bpGraph[u][v] && !seen[v])
        {
            seen[v] = true; // Mark v as visited
 
            // If job 'v' is not assigned to an applicant OR
            // previously assigned applicant for job v (which is matchR[v]) 
            // has an alternate job available. 
            // Since v is marked as visited in the above line, matchR[v] 
            // in the following recursive call will not get job 'v' again
            if (matchR[v] < 0 || bpm(matchR[v], seen, matchR))
            {
                matchR[v] = u;
                return true;
            }
        }
    }
    return false;
}
 
// Returns maximum number of matching from M to N
int maxBPM()
{
    // An array to keep track of the applicants assigned to
    // jobs. The value of matchR[i] is the applicant number
    // assigned to job i, the value -1 indicates nobody is
    // assigned.
    int matchR[N];
 
    // Initially all jobs are available
    memset(matchR, -1, sizeof(matchR));
 
    int result = 0; // Count of jobs assigned to applicants
    for (int u = 0; u < N; u++)
    {
        // Mark all jobs as not seen for next applicant.
        bool seen[N];
        memset(seen, 0, sizeof(seen));
 
        // Find if the applicant 'u' can get a job
        if (bpm(u, seen, matchR))
            result++;
    }
    return result;
}


int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	cin >> N;
	vector<pair<int,int>> ab(N); vector<pair<int,int>> cd(N);
	for(int i=0;i<N;++i) {
		int a,b;
		cin >> a >> b;
		ab[i] = make_pair(a,b);
	}
	for(int i=0;i<N;++i) {
		int a,b;
		cin >> a >> b;
		cd[i] = make_pair(a,b);
	}	


	for(int i=0;i<N;++i) {
		for (int j=0;j<N;++j) {
			if (ab[i].first < cd[j].first && ab[i].second < cd[j].second) {
				bpGraph[i][j] = true;
				//bpGraph[j][i] = true;
			}
		}
	}

	cout << maxBPM() << endl;



}















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"
struct mint{
  ll x;
  mint(ll x = 0): x((x % MOD + MOD) % MOD){}
  mint operator-() const {return mint(-x);}
  mint& operator+=(const mint a){
    if((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD - a.x) >= MOD) x-= MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a){
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a){
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a){
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if(t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a){
    mint res(*this);
    return res/=a;
  }
};
struct Sieve{
  int n;
  vector<int> f, primes;
  Sieve(int n = 1): n(n), f(n+1){
    f[0] = -1; f[1] = -1;
    for(ll i = 2; i <= n; i++){
      if(f[i]) continue;
      primes.push_back(i);
      f[i] = i; 
      for(ll j = i*i; j <= n; j += i){
        if(!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x){return f[x] == x;}
  vector<int> factorList(int x){
    vector<int> res;
    while(x != 1){
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x){
    vector<int> fl = factorList(x);
    if(fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for(int p: fl){
      if(res.back().first == p){
        res.back().second++;
      }
      else{
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  Sieve sieve(1000000);
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  map<int, int> mp;
  for(int i = 0; i < n; i++){
    auto f = sieve.factor(a[i]);
    for(auto p: f){
      mp[p.first] = max(mp[p.first], p.second);
    }
  }
  mint lcm = 1;
  for(auto p: mp){
    for(int i = 0; i < p.second; i++){
      lcm *= p.first;
    }
  }

  mint ans;
  for(int i = 0; i < n; i++){
    mint b = lcm/a[i];
    ans += b;
  }
  cout << ans.x << endl;
}

Measured memory_bytes: 4984
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTA(a,n) sort(a,a+n)
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    string s;
  	cin >> s;
    string ans = "";
    //処理
    REP(i,0,s.length()){
      if(i%2==0) ans += s[i];
    }
    
    //出力
    cout << ans << ENT;
    return 0;
}

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


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

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 


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

    vector<int> A(N);
    LL sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        sum += A[i];
    }
    sum /= 2;

    vector<LL> R(N);

    //! sum = R[0] + R[1] + .. + R[N-1]
    //! A[0] = R[0] + R[1]
    //! A[1] = R[1] + R[2]
    //! therefore
    //! R[0] = sum - (R[1] + R[2] + .... R[N-1] + R[N-1]])
    //! R[0] = sum - (A[1] + A[3] + ... A[N-2])
    LL sub = 0;
    for (int i = 1; i <= N-2; i += 2) {
        sub += A[i];
    }
    R[0] = sum - sub; 

    //! R[i] = A[i-1] - R[i-1];
    for (int i = 1; i < N; ++i) {
        R[i] = A[i-1] - R[i-1];
    }

    for (int i = 0; i < N; ++i) {
        cout << 2 * R[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 2432
#include<iostream>
#include<vector>
#include <utility>
using namespace std;
int main(){
    string s;
    cin>>s;
    vector<pair<int,char>> v;
    int c = 1;
    int flag = 0;
    for(int i=1;i<s.size();i++){
        if(s[i]==s[i-1]){
            c++;
            continue;
        }
        // if(i!=s.size()-1){
        v.push_back(make_pair(c,s[i-1]));
        c = 1;
    }
    v.push_back(make_pair(c,s[s.size()-1]));    
    int fi = -1;
    int ci = 0;
    // cout<<0<<" ";
    for(int i=0;i<v.size();i=i+2){
        int ri = v[i].first;
        while(ri>1){
            cout<<0<<" ";
            ri--;
        }
        int s = v[i].first+v[i+1].first;
        if(s%2==0){
            cout<<s/2<<" "<<s/2<<" ";
        }
        else if((max(v[i].first,v[i+1].first)-1)%2==0){
            if(v[i].first>v[i+1].first){
                cout<<(s/2)+1<<" "<<(s/2)<<" ";
            }
            else{
                cout<<(s/2)<<" "<<(s/2)+1<<" ";
            }
        }
        else{
            if(v[i].first>v[i+1].first){
                cout<<s/2<<" "<<(s/2)+1<<" ";
            }
            else{
                cout<<(s/2)+1<<" "<<s/2<<" ";
            }
        }
        int li = v[i+1].first;
        while(li>1){
            cout<<0<<" ";
            li--;
        }
    }
    // for(int i=0;i<v.size();i++){
    //     cout<<v[i].first<<"->"<<v[i].second<<endl;
    // }
    return 0;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int h[n];
	for(int i = 0; i < n;i++)
	{
		cin >> h[i];
	}
	long long dp[n];
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	dp[2] = abs(h[2]-h[0]);
	for(int i = 3;i < n;i++)
	{
		dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i]-h[i-1]));
	}
	cout << dp[n-1] << endl;	

}

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

int main() {
    string s;
    cin >> s;

    if (s == "AAA" || s == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
             
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout<< name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define end_time()
#endif


#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007


void solve(){
	int n,m;
	cin>>n>>m;
	bool v[n] = {0};
	int pen[n] = {0};
	for(int i = 0; i<m; i++){
		int q;
		cin>>q;
		string s;
		cin>>s;
		if(v[q-1] == 0 && s == "WA") pen[q-1]++;
		if(v[q-1] == 0 && s == "AC")	v[q-1]  = 1;
		
	}
	int ac = 0, p =0;
	for(int i = 0; i<n; i++){
		if(v[i]){
			ac++;
			p+=pen[i];
		}
	}
	cout<<ac<<" "<<p<<"\n";
}
signed main(){
	speedX;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	end_time();
	return 0;
}

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

int main() {
  int a,b,c;
  cin >> a; cin >> b; cin >> c;
  int tmpa, tmpb, tmpc;
  int sum=0;
  rep(i, 100000000) {
    if (a%2!=0 || b%2!=0 || c%2!=0) {
      break;
    } 
    tmpa = a;
    tmpb = b;
    a = tmpb/2 + c/2;
    b = tmpa/2 + c/2;
    c = tmpa/2 + tmpb/2;
    sum++;
    if (i == 99999999) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <float.h>

int main(void)
{
	int N, ans, i;
	double T, A, H[1000], min = DBL_MAX;
	scanf("%d%lf%lf", &N, &T, &A);
	for (i = 0; i < N; ++i) {
		scanf("%lf", &H[i]);
		H[i] = T - H[i] * .006;
		if (fabs(H[i] - A) < min) {
			min = fabs(H[i] - A);
			ans = i + 1;
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
// =====================================================
//   File    :   main.cpp
//   Author  :   eezyl
//   Synopsis:   codeforces/atcoder template
//   Address :
//   Date    :   2020/08/15
// =====================================================

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

#define rep(i, a, b) for (int i = (a); i < int(b); ++i)
typedef long long LL;

const int INF = (1<<31)-1;
const LL LL_INF = (1ll << 63)-1;
const int MOD = 1e9+7;

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

void solve() {
    string s;
    cin >> s;
    int c = 0;
    for (int i = 0; i < 3; ++i)
        if (s[i] == 'R')
            ++c;
    if (c == 2 && s[1] == 'S')
        cout << "1" << endl;
    else
        cout << c << endl;
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
//#define LOCAL
#ifdef LOCAL
freopen("data.in", "r", stdin);
while (!feof(stdin)) {
#endif // LOCAL

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

#ifdef LOCAL
}
printf("Time used = %.2lf\n", (double)clock() / CLOCKS_PER_SEC);
#endif // LOCAL
    return 0;
}


Measured memory_bytes: 3648
### main

while true
  n = gets.strip.to_i
  break if n == 0

  bs = gets.strip.split(' ').map{|s| s.to_i}

  ok = false
  num = 0
  for b in bs
    if b >= 1
      num += 1
      ok = true if b >= 2
    end
  end

  if ok
    puts (num + 1)
  else
    puts "NA"
  end
end

Measured memory_bytes: 9592
#include<bits/stdc++.h>
using namespace std;
const long long INF=1000000000;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n;i++)
#define REP(i, n) for (int i = 0; i <= n;i++)
ll dp[105][100005];

int main(){
    int n,W;
    cin >> n >> W;
    ll sina[n][2];
    REP(i,n)
        REP(j, W)
            dp[i][j] = -INF;
    rep(i, n){
         cin >> sina[i][0] >> sina[i][1];
         dp[i][0] = 0;
    }
    REP(i, W) dp[0][i] = 0;
    rep(i, n){
        REP(j, W){
            if (j < sina[i][0])
                dp[i + 1][j] = dp[i][j];
            else
                dp[i + 1][j] = max(dp[i][j], dp[i][j - sina[i][0]] + sina[i][1]);
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int mod=1e9+7;
const int INF =LONG_LONG_MAX;
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int pow(int a,int n,int mod){if(n==0)return 1;int p=pow(a,n/2,mod);p=(p%mod*p%mod)%mod;if(n%2) return (p%mod*a%mod)%mod;else return p;}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n;
    int a[n];
   int s=0;
    for(int i=0;i<n;i++){
        cin>>a[i];s+=a[i];}
    int dp[n][n];
    for(int len=1;len<=n;len++)
    {
        for(int i=0;i<n-len+1;i++)
        {
            int j=i+len-1;
            //cout<<i<<" "<<j<<endl;
           if(len==1)
           {
               dp[i][j]=a[i];continue;
           }
           if(len==2){dp[i][j]=max(a[i],a[j]);continue;}

           dp[i][j]=max(a[i]+min(dp[i+2][j],dp[i+1][j-1]),a[j]+min(dp[i+1][j-1],dp[i][j-2]));
        }
    }

   cout<<dp[0][n-1]-(s-dp[0][n-1])<<endl;
    return 0;
}


Measured memory_bytes: 70400
using System;
using System.Linq;
class Program
{
 
  static void Main(string[] args)
  {
    var array = new int[] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    int i = int.Parse(Console.ReadLine()) - 1;
    Console.WriteLine(array[i]);
  }
}

Measured memory_bytes: 11092
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int H,W,N;
  cin >> H >> W >> N;
  int x=max(H,W);
  if(N%x==0){
    cout << N/x << endl;
  }
  else{
    cout << N/x+1 << endl;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    int n; cin >> n;
    int k; cin >> k;
    int dist = 0;
    For(i, 0, n) {
        int x; cin >> x;
        dist += min(x, abs(k - x));
    }
    cout << 2*dist;

    
    
    
    return 0;
}

Measured memory_bytes: 3472
#include <iostream>
#include <iomanip>
#include <stdio.h>
using namespace std;

int main()
{
	int x[3000];
	int y[3000];
	int i=0;
	
	while(1){
		cin >> x[i] >> y[i];
		if(x[i] == 0 && y[i] == 0)	break;
		i++;
	}
	
	for(i=0; x[i] != 0 || y[i] != 0 ; i++){
		if(x[i] < y[i])
			cout << x[i] << ' ' << y[i] << endl;
		else
			cout << y[i] << ' ' << x[i] << endl;
	}	

	return 0;
}



Measured memory_bytes: 3020