akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  ll a;
  cin>>a;
  string s;
  cin>>s;
  
  if(a>=3200){
    cout<<s<<endl;
  }
  else{
    cout<<"red"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    string ans = "";
    ans += s1[0];
    ans += s2[0];
    ans += s3[0];
    rep(i, 3) ans[i] = toupper(ans[i]);
    
    cout << ans << endl;
    return 0;
}


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

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int ans = 180 * (n - 2);

            // 出力
            out.println(ans);

        }

    }
}



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

int main(){
    ll n;
    cin >> n;
    ll a[n+1];
    for(ll i = 1;i<=n;i++){
      cin >> a[i];
    }
    ll num = 1;
    vector<ll>  v;
    for(ll i = 1;i<=n;i++){
        if(a[i]==num) {
            v.push_back(i);
            num++;
        }
   }
   if (v.size() == 0){
      cout << -1 << endl;
      return 0;
}
   ll  ans = n - v.size();
    cout  <<  ans << endl;
    return 0;
}

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

int main() {
	string s;
	cin >> s;
	int res = 0;
	for (int i = 0;i <= s.size()-1 / 2;++i) {
		if (s[2 * i] == 'L')res++;
		else if (s[2 * i + 1] == 'R')res++;
	}
	if (res == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

using namespace std;
typedef long long i64;

const int INF = 1000000000;
const int N = 100005;


int main ()
{
    i64 n, k, ans = 0;
    cin >> n >> k;
    for (i64 i = 1; i <= n; ++i) {
        i64 m = n % i;
        ans += (n - m) / i * max(i - k, 0ll) + max(m - k + 1, 0ll);
        //printf("%lld\n", (n - m) / i * max(i - k, 0ll) + max(m - k + 1, 0ll));
    }
    if (k == 0) ans -= n;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// class
// ------------------------------------------------
class Combi
{
  public:
    Combi();
    long long Combination(long long n, long long k);
  private:
    vector<vector<long long>> memo;
    long long n_num;
    long long k_num;
    void Resize(long long n, long long k);
};

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {

  ll n;cin >> n;
  vll a(n),r(n+1,0);

  rep(i,n) cin >> a[i];

  rep(i,n) r[i+1] = r[i] + a[i];

  ll sum = r[n];

  ll ans = LLONG_MAX;

  for(ll i = 1;i < n; ++i)
  {
    ll ara = sum - r[i];
    ans = min(ans, abs(ara - r[i]));
  }

  cout << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Combi::Combi(){
  n_num = -1;
  k_num = -1;
};
ll Combi::Combination(ll n, ll k)
{
  Resize(n,k);

  ll ret;
  if(memo[n][k] != 0)
  {
    ret = memo[n][k];
  }
  else if(n == k || k == 0)
  {
    memo[n][k] = 1;
    ret = 1;
  }
  else
  {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

void Combi::Resize(ll n, ll k)
{
  if(n_num <= n || k_num <= k)
  {
    n_num = (n + 1) * 2;
    k_num = (k + 1) * 2;
    memo.resize(n_num);
    for(auto itr = memo.begin(); itr != memo.end(); ++itr)
    {
      itr->resize(k_num);
    }
  }
}

Measured memory_bytes: 3328
#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 MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;

int n, MOD;
int inv[6005];
int mem[4][12010];
int* dp[4] = {mem[0] + 6005, mem[1] + 6005, mem[2] + 6005, mem[3] + 6005};

int main()
{
	scanf("%d%d", &n, &MOD);
	n *= 3;
	rep1(i, n) inv[i] = i == 1 ? 1 : MOD - 1LL * (MOD / i) * inv[MOD % i] % MOD;
	
	dp[0][0] = 1;
	rep1(i, n) dp[0][0] = 1LL * dp[0][0] * i % MOD;
	rep1(i, n) {
		for(int j = -i; j <= i; j ++) dp[i & 3][j] = 0;
		for(int j = -i; j <= i; j ++) {
			dp[i & 3][j] = 0;
			if(i >= 1) dp[i & 3][j] = (dp[i & 3][j] + dp[i - 1 & 3][j - 1]) % MOD;
			if(i >= 2) dp[i & 3][j] = (dp[i & 3][j] + dp[i - 2 & 3][j + 1]) % MOD;
			if(i >= 3) dp[i & 3][j] = (dp[i & 3][j] + dp[i - 3 & 3][j]) % MOD;
			dp[i & 3][j] = 1LL * dp[i & 3][j] * inv[i] % MOD;
		}
	}
	int ans = 0;
	for(int i = 0; i <= n; i ++) ans = (ans + dp[n & 3][i]) % MOD;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vector<int>>;

int main(){
    int n; cin>>n;
    map<string,int> memo;
    for(int i=0; i<n; i++){
        string s;
        cin>>s;
        memo[s] += 1;
    }
    
    int maxv = 0;
    for (const auto& x : memo){
        int v = x.second;
        if(v>maxv) maxv = v;
    }
    for (auto it = memo.begin(); it != memo.end(); it++){
        if(it->second == maxv){
            if(it->second == maxv){
                cout << it->first << endl;
            }
        }
    }
    
}

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

using namespace std;


#define modulo 1000000007

int min(int x, int y)
{
	return x<y?x:y;
}
int abs(int x)
{
	return x>=0?x:(-1*x);
}
int main()
{
	int n, arr[100005];
	cin>>n;
	int memo[100005];
	for (int i = 0; i < n; ++i)
	{
		cin>>arr[i];
	}
	memo[0] = 0;
	memo[1] = abs(arr[0] - arr[1]);
	// memo[2] = abs(arr[0] - arr[2]);
	for (int i = 2; i < n; ++i)
	{
		memo[i] = min(memo[i-1] + abs(arr[i-1] - arr[i]), memo[i-2] + abs(arr[i-2] - arr[i]));
	}
	cout<<memo[n-1]<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    if (a <= 0 && b >= 0) {
        puts("Zero");
    } else if (a > 0 || (b-a+1)%2 == 0) {
        puts("Positive");
    } else {
        puts("Negative");
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main ( ) {
   int n ;
   scanf ("%d", &n) ;


   int a = n ;
   int suma = 0 ;
   while ( n != 0) {
   suma += n % 10 ;
   n /= 10 ;
   }

   if ( a % suma == 0 ){
     printf("Yes" ) ;
   } else {
     printf ("No");
   }
}


Measured memory_bytes: 128
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
using namespace std;

typedef complex<double> xy_t;
double dot_product(xy_t a, xy_t b){ return (conj(a) * b).real(); }
double cross_product(xy_t a, xy_t b){ return (conj(a) * b).imag(); }
xy_t projection(xy_t p, xy_t b) {return b * dot_product(p,b) / norm(b);}

int main(){
    xy_t P1,Q,S,R;
    double x1,y1,x2,y2,xq,yq;
    while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq)){
        P1 = xy_t(x1,y1);
        Q = xy_t(xq,yq);
        S = projection(Q - P1, xy_t(x2,y2) - P1) + P1;
        R = S+S-Q; // Q + 2*(S - Q)
        cout << fixed << setprecision(6) << real(R) << ' ' << imag(R) << endl;
    }
}

Measured memory_bytes: 1312
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
public class Main {
	static final long C =  1000000007;
	static final int CY = 1000000000;
	StringBuilder sb;
	public void calc() {
		sb = new StringBuilder();


		FastScanner sc = new FastScanner();

		char[] s = sc.next().toCharArray();
		long k = sc.nextLong();

		String ans = "";
		//先頭からaにできるやつはしていく
		for (int i=0; i < s.length; i++) {
			int t = 26 - (s[i] - 'a');
			if (t <= k && t != 26) {
				k -= t;
				s[i] = 'a';
			}
		}
		//余ったら最後のやつに全投入
		s[s.length-1] = (char)(((s[s.length-1]-'a'+k)%26)+'a');

		System.out.println(String.valueOf(s));
	}



	public static void main(String[] args) {
		Main main = new Main();
		main.calc();

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


Measured memory_bytes: 10708
#include <iostream>

using namespace std;

int main()
{
	int N;
	int64_t answer = 0;
	cin >> N;
	for (int count = 0; count < N; count++)
	{
		if ((count + 1) % 3 != 0 && (count + 1) % 5 != 0)
			answer += count + 1;
	}
	cout << answer << endl;
}

Measured memory_bytes: 3564
n=int(input())
ac=0
wa=0
tle=0
re=0

for i in range(n):
    tmp=input()
    if tmp == 'AC':
        ac += 1
    if tmp == 'WA':
        wa += 1
    if tmp == 'TLE':
        tle += 1
    if tmp == 'RE':
        re += 1

print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))

Measured memory_bytes: 9212
N = int(input())
a = [int(input()) for i in range(N)]
if a[0] > 0:
    print(-1)
    exit()

ans = 0
for i in range(1, N):
    if a[i - 1] + 1 < a[i]:
        print(-1)
        exit()
    elif a[i - 1] + 1 == a[i]:
        ans += 1
    else:
        ans += a[i]

print(ans)

Measured memory_bytes: 57688
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func min(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func joinInts(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func divUp(x, y int64) int64 {
	return (x + y - 1) / y
}

func main() {
	solve()
	writer.Flush()
}

func solve() {
	m := make(map[int64]struct{})
	for i := 0; i < 3; i++ {
		m[nextInt()] = struct{}{}
	}
	out(len(m))
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin>>n;
    vector<string> vs(n);
    REP(i,n){
        string s; cin>>s;
        vs.pb(s);
    }
    sort(ALL(vs));

    int m; cin>>m;
    bool f=false;
    REP(i,m){
        string s; cin>>s;
        if(!binary_search(ALL(vs),s)){
            cout<<"Unknown "<<s<<endl;
        } else{
            f=!f;
            if(f) cout<<"Opened by "<<s<<endl;
            else cout<<"Closed by "<<s<<endl;
        }
    }

}

Measured memory_bytes: 3260
#include <iostream>

using namespace std;

int main(void)
{
    long long X, div, a;

    cin >> X;

    div = X / 100;

    a = X % 100;

    if(a <= div * 5){
        cout << 1 << endl;
    }

    else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
  int i, n;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    int x = i;
    if (x % 3 == 0) {
      printf(" %d", i);
    } else {
      while (x) {
        if (x % 10 == 3) {
          printf(" %d", i);
          break;
        }
        x /= 10;
      }
    }
  }
  printf("\n");
}


Measured memory_bytes: 2088
#include <iostream>
#include <vector>
#include <bits/stdc++.h>

using namespace std;


int b[1007],a,ant=1;

int main(){
  cin >> a;
  
	long long int ans =1,num =1;

	for(int i=0;i<=a;i++){
      b[i] = 1;
      
    }
  
  for(int j=1;j<=a;j++){
    num = j;
	for (int i = 2; i <= j; i++) {
      
		while(num%i == 0) {
          b[i]++;
          num /= i;
		}
	}
  }
  
 for(int i=1;i<=a;i++){
   ans *= b[i];
   ans %= 1000000007;
 }
  
cout << ans << endl;
	return 0 ;
}





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

typedef long long ll;
ll n, m, s, ans, mn[2005], a[2005];
int main()
{
	ll i, j;
	cin >> n >> m;
	for (i = 0; i < n; i++) {
		scanf ("%lld", &a[i]);
	}
	for (i = 0; i < n; i++) {
		mn[i] = 2e9;
	}
	for (i = 0; i < n; i++) {
		s = i * m;
		for (j = 0; j < n; j++) {
			mn[j] = min(mn[j], a[(i - j + n) % n]);
			s += mn[j];
		}
		if (i == 0 || s < ans) ans = s;
	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc;
	int N;
	int[][] P;
	
	public Main() {
		sc = new Scanner(System.in);
	}
	
	private void calc() {
		N = sc.nextInt();
		P = new int[N][2];
		for (int i = 0; i < N; i++) {
			P[i][0] = i;
			P[i][1] = sc.nextInt();
		}
		Arrays.sort(P, (a,b) -> -Integer.compare(a[1],b[1]));
		TreeSet<Integer> t = new TreeSet<>();
		long s = 0;
		for (int i = 0; i < N; i++) {
			int ind = P[i][0];
			t.add(ind);
			Iterator<Integer> tail = t.tailSet(ind, false).iterator();
			int c = tail.hasNext()?tail.next():N;
			int d = tail.hasNext()?tail.next():N;
			Iterator<Integer> head = t.headSet(ind, false).descendingIterator();
			int b = head.hasNext()?head.next():-1;
			int a = head.hasNext()?head.next():-1;
			s += ((long)P[i][1])* ( (c-ind)*(b-a) + (d-c)*(ind-b) );
		}
		System.out.println(s);
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;

map<int, int> mp;
int n, q;
int a[N];

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        mp[a[i]] += 1;
        ans += a[i];
    }
    cin >> q;
    for (int i = 1; i <= q; i++) {
        int u, v;
        cin >> u >> v;
        long long tmp_s = (long long)u * mp[u];
        int tmp = mp[u];
        mp[u] = 0;
        mp[v] += tmp;
        long long tmp_t = (long long)tmp * v;
        cout << ans - tmp_s + tmp_t << endl;
        ans = ans - tmp_s + tmp_t;
    }
    return 0;
}

Measured memory_bytes: 8324
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for (int i=0;i<n;i++)
using namespace std;
typedef long long ll;

ll Count(ll X,ll &c){
  ll half = X/2;
  if(half == 0){
    c++;
    return c * 2; 
  }
  else{
    return Count(half,c) * 2;
  }
}

int main(){
  ll H;
  ll ans;
  ll count = 0;
  cin >> H;

  ans = Count(H,count);
  cout << ans-1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

class Monster
{
private:
	int HP;
	int AP;

public:
	Monster(int HP, int AP) {
		this->HP = HP;
		this->AP = AP;
	}

	int getAP(){
		return AP;
	}

	int Damaged(int AP) {
		HP -= AP;
		return HP;
	}
};


int main()
{
	int HP_Takahasi, AP_Takahashi;
	int HP_Aoki, AP_Aoki;

	std::cin >> HP_Takahasi >> AP_Takahashi >> HP_Aoki >> AP_Aoki;

	Monster Takahashi(HP_Takahasi, AP_Takahashi);
	Monster Aoki(HP_Aoki, AP_Aoki);

	while (1) {
		if (Aoki.Damaged(Takahashi.getAP()) <= 0) {
			std::cout << "Yes" << std::endl;
			break;
		}
		if (Takahashi.Damaged(Aoki.getAP()) <= 0) {
			std::cout << "No" << std::endl;
			break;
		}
	}
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;
int main(){
  int n; cin >>n;
  vector<int>a(n); vector<int>b(n);
  for(int i=0; i<n; i++) cin >>a[i] >>b[i];
  sort(a.begin(),a.end()); sort(b.begin(),b.end());
  if(n%2) cout <<b[n/2]-a[n/2]+1;
  else cout <<b[n/2-1]+b[n/2]-a[n/2-1]-a[n/2]+1;
return 0;}

Measured memory_bytes: 4852
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int chain(int idx,int col);
int model[10002];
int n;
int main(void){
   while(scanf("%d",&n),n){
      int mi = n;
      memset(model,0,sizeof(model));
      for(int i = 0;i < n;i++){
         scanf("%d",&model[i]);
      }

      for(int i = 0;i < n;i++){
         for(int j = 1;j <= 3;j++){
            mi = min(mi,chain(i,j));
         }
      }
      printf("%d\n",mi);
   }
   return 0;
}

int chain(int idx,int col){
   if(model[idx] == col) return n;
   int c[10002];
   int f[10002] = {0};
   for(int i = 0;i < n;i++){
      if(idx == i)
         c[i] = col;
      else c[i] = model[i];
   }
   c[n] = 100;

   while(1){
      int flag = 0;
      int curr = c[0],cnt = 1;
      for(int i = 1;i <= n;i++){
         if(c[i] == 0) continue;
         if(c[i] == curr) cnt++;
         else{
            curr = c[i];
            if(cnt >= 4){
               flag = 1;
               for(int j = 0;j < cnt;j++){
                  if(f[i-1-j] == 1) cnt++;
                  f[i-1-j] = 1;
                  c[i-1-j] = 0;
               }
               break;
            }
            cnt = 1;
         }
      }
      if(flag == 0) break;
   }

   int cnt = 0;
   for(int i = 0;i < n;i++){
      if(f[i] == 0) cnt++;
   }
   return cnt;
}

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

vector<vector<int>> A;
vector<vector<int>> id;

int toId(int i, int j) {
  int a = i;
  int b = A.at(i).at(j); // 対戦相手
  if (a > b) swap(a, b);
  return id.at(a).at(b);
}

vector<vector<int>> G;
vector<int> dp;
vector<bool> reached;
vector<bool> completed;

int dfs(int v) {
  if (reached.at(v)) {
    if (!completed.at(v)) return -1;
    return dp.at(v);
  }
  reached.at(v) = true;
  dp.at(v) = 1;
  for (int u : G.at(v)) {
    int res = dfs(u);
    if (res == -1) return -1;
    dp.at(v) = max(dp.at(v), res + 1);
  }
  completed.at(v) = true;
  return dp.at(v);
}

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

  A.resize(N, vector<int>(N - 1));
  rep(i, N) {
    rep(j, N - 1) {
      cin >> A.at(i).at(j);
      A.at(i).at(j)--;
    }
  }

  // 試合用のidを作成、参加者を行と列に持つので、N * N の大きさが必要
  id.resize(N, vector<int>(N));
  int V = 0;
  rep(i, N) {
    rep(j, N) {
      if (i >= j) continue;
      id.at(i).at(j) = V++;
    }
  }

  int NUMV = N * (N - 1) / 2;
  G.resize(NUMV);
  dp.resize(NUMV);
  reached.resize(NUMV);
  completed.resize(NUMV);

  rep(i, N) {
    rep(j, N - 2) {
      G.at(toId(i, j + 1)).push_back(toId(i, j)); // 辺を逆順に張っておく
    }
  }

  int ans = 0;
  rep(i, NUMV) {
    int res = dfs(i);
    if (res == -1) {
      cout << -1 << endl;
      return 0;
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 37632
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll ans=0;
	if(k<a){
		ans = k;
	}
	else if(k>=a && k<=a+b){
		ans = a;
	}
	else{
		ans = a - (k-(a+b));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    int** a;
    int* b;
    cin >> n >> m;
    a = new int*[n]; b = new int[m];
    for (int i = 0; i < n; i++)
        a[i] = new int[m];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> a[i][j];
    for (int i = 0; i < m; i++)
        cin >> b[i];
    for (int i = 0; i < n; i++) {
        int v = 0;
        for (int j = 0; j < m; j++)
            v += a[i][j] * b[j];
        cout << v << "\n";
    }
}

Measured memory_bytes: 3196
n,x = list(map(int,input().split()))

a = list(map(int,input().split()))

ans = 0

if a[0] > x:
    ans += a[0]-x
    a[0] = x

for i in range(n-1):
    if a[i+1]+a[i] > x:
        ans += a[i+1]+a[i]-x
        a[i+1] = x-a[i]
print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int a[33]={0,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 main(){
    int k;
  cin>>k;
  cout<<a[k]<<endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
a = 0
b = 0
check = False

for i in range(1, N):
    if check == True:
        check = False
        pass
    else:
        if A[i-1] == A[i]:
            if a == 0:
                a = A[i]
            elif b == 0:
                b = A[i]
                print(a * b)
                exit()
            check = True

print(0)

Measured memory_bytes: 14252
N,M=map(int,input().split())
red=[0]*(N+1)
cnt=[1]*(N+1)
red[1]=1
for i in range(M):
    x,y=map(int,input().split())
    if red[x]==1:
        red[y]=1
        if cnt[x]==1:
            red[x]=0
    cnt[x]-=1
    cnt[y]+=1
print(red.count(1))

Measured memory_bytes: 4596
import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
n,k=map(int,stdin.readline().split())
ans=n
done=defaultdict(lambda:False)
for _ in range(k):
    d=int(input())
    a=list(map(int,stdin.readline().split()))
    for i in a:
        if(i not in done):
            ans-=1
            done[i]=True
print(ans)


Measured memory_bytes: 68156
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

   int n; cin>>n;

   vi a(n);

   int s= 0;
   for(int & x : a)cin>>x, s += x;

   int pre = 0;
   int ans = 1e9;

   for(int i = 0; i < n; i++){
       pre += a[i];
       ans = min(ans, abs(s - 2 * pre));
   }

   cout<<ans<<"\n";



    







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll h,w;
ll ans=0;
int field[105][105]={0};
bool used[105][105];
int ex[6] = {-1,0,-1,1,-1,0};
int ey[6] = {-1,-1,0,0,1,1};
int ox[6] = {0,1,-1,1,1,0};
int oy[6] = {-1,-1,0,0,1,1};

int main() {
  int n,m;
  cin >> n >> m;
  vvi root(n);
  REP(i,m) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    root[a].push_back(b);
    root[b].push_back(a);
  }
  vi mejirushi(n,-1);
  qi que;
  que.push(0);
  mejirushi[0]=0;
  int cnt=0;
  while(!que.empty()) {
    int now= que.front();
    que.pop();
    for(auto i:root[now]) {
      if(mejirushi[i]!=-1) continue;
      mejirushi[i]=now+1;
      que.push(i);
      cnt++;
    }
  }
  if(cnt==n-1) {
    cout << "Yes" << endl;
    REP1(i,n-1) {
      cout << mejirushi[i] << endl;
    } 
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main(){
  int N;
  string S;
  
  cin >> N >> S;
  
  rep(i,S.size()){
    int tmp;
    tmp = S.at(i) + N;
    if(tmp > 'Z'){
      tmp = tmp - 'Z' - 1 + 'A';
    }
    S.at(i) = (char)tmp;
  }
  
  cout << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int f(ll x){
    if(!x) return 1;
    else return f(x%__builtin_popcountll(x))+1;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,p{};
    string x;
    cin>>n>>x;
    for(auto c:x) if(c=='1') ++p;
    if(p==1){
        if(x[n-1]=='1'){
            fr(i,n-1) cout<<2<<'\n';
            cout<<0<<'\n';
        }
        else{
            fr(i,n-1){
                if(x[i]=='1') cout<<0<<'\n';
                else cout<<1<<'\n';
            }
            cout<<2<<'\n';
        }
        return 0;
    }
    vector<ll> p2(n),P2(n);
    p2[0]=P2[0]=1;
    fr(i,n-1){
        (p2[i+1]=p2[i]*2)%=p-1;
        (P2[i+1]=P2[i]*2)%=p+1;
    }
    ll xp{},XP{};
    fr(i,n) if(x[i]=='1'){
        (xp+=p2[n-1-i])%=p-1;
        (XP+=P2[n-1-i])%=p+1;
    }
    fr(i,n){
        if(x[i]=='1') cout<<f((xp+p-1-p2[n-1-i])%(p-1))<<'\n';
        else cout<<f((XP+P2[n-1-i])%(p+1))<<'\n';
    }
}

Measured memory_bytes: 6760
N = input()
if len(N)==1:
    print(int(N))
elif len(N)==2:
    print(9)
elif len(N)==3:
    print(int(N)-99 + 9)
elif len(N)==4:
    print(999-100+1+9)
elif len(N)==5:
    print(int(N)-9999 + 999-100+1+9)
elif len(N)==6:
    print(90909)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;

int main() {
  //
  ll n, k;
  cin >> n >> k;
  vvl data(2 * k + 1, vl(3 * k + 1, 0));
  rep(i, n) {
    ll x, y;
    string s;
    cin >> x >> y >> s;
    if (s == "B") {
      x += k;
    }
    x = x % (2 * k);
    y = y % (2 * k);
    if (y >= k) {
      if (x < k) {
        y -= k;
        x += k;
      } else {
        y -= k;
        x -= k;
      }
    }
    cerr << x << ":" << y << endl;
    ll a, b, c, d;
    //    if (s == "W") {
    a = y - k + 1;
    b = x - k + 1;
    c = y + 1;
    d = x + 1;
    cerr << a + k << "," << b + k << "," << c + k << "," << d + k << endl;
    vector<ll> dx = {k, k, -k, -k};
    vector<ll> dy = {k, -k, k, -k};
    data[a + k][b + k] += 1;
    data[a + k][d + k] -= 1;
    data[c + k][b + k] -= 1;
    data[c + k][d + k] += 1;
    rep(i, 4) {
      ll na = min(k, max(-k, a + dy[i]));
      ll nb = min(2 * k, max(-k, b + dx[i]));
      ll nc = min(k, max(-k, c + dy[i]));
      ll nd = min(2 * k, max(-k, d + dx[i]));
      data[na + k][nb + k] += 1;
      data[na + k][nd + k] -= 1;
      data[nc + k][nb + k] -= 1;
      data[nc + k][nd + k] += 1;
    }
  }
  for (int i = 0; i < data.size(); i++) {
    for (int j = 1; j < data[i].size(); j++) {
      data[i][j] += data[i][j - 1];
    }
  }
  for (int i = 1; i < data.size(); i++) {
    for (int j = 0; j < data[i].size(); j++) {
      data[i][j] += data[i - 1][j];
    }
  }
  ll ans = 0;
  rep(i, data.size()) {
    rep(j, data[i].size()) { ans = max(ans, data[i][j]); }
  }
  cout << ans << endl;

  return 0;
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)((n)-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    vl a(n),s(n+1);
    rep(i,n) cin >> a[i];
    rep(i,n) s[i+1] = (s[i]+a[i]) % mod;

    ll ans = 0;
    REP(i,1,n){
        ans += a[i] * s[i] % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

ll dp[MAX];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    memset(dp,0, sizeof(dp));
    fill(dp,dp+MAX,INF);
    Vec h(n);
    rep(i,n){
        cin>>h[i];
    }
    dp[0] = 0;
    rep(i,n){
        chmin(dp[i+1],abs(h[i+1]-h[i])+dp[i]);
        chmin(dp[i+2],abs(h[i+2]-h[i])+dp[i]);
    }
    ll ans=dp[n-1];
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 1792
#include <iostream>
#include<stdio.h>
#include <bits/stdc++.h>

using namespace std;

int main(){
    long long n,a,b,x,y,res;
    cin >> n>>a>>b;
    x = n/(a+b);
    y = n%(a+b);
    res = x*a;
    if(y>a)res+=a;
    else res += y;

    cout << res <<endl;
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <stdio.h>
#include <queue>
#include <stack>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <vector>
//#include <bits/stdc++.h>
#define ll long long
#define wtcl return
#define PI acos(-1)
#define maxn 1e18
#define debug(a) cout<<" ++ "<<a<<" ++ "<<endl;
using namespace std;
const ll mod = 1e9+7;
inline ll read()
{
	ll s = 0, f = 1;
	char ch = getchar();
	for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = - 1;
	for(; ch >= '0' && ch <= '9'; ch = getchar()) s = ((s << 3ll) + (s << 1ll) + (ch ^ 48ll));
	return s * f ;
}
inline void out(ll x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) out(x/10);
	putchar(x%10+'0');
}

int main()
{
	std::ios::sync_with_stdio(false);
	int n,m;
	cin>>n;
	map<string,int>mp;
	string s;
	for(int i=0; i<n; i++)
	{
		
		cin>>s;
		mp[s]++;
	}
	cin>>m;
	for(int i=0; i<m; i++)
	{
		cin>>s;
		mp[s]--;
	}
	map<string,int>::iterator it;
	it = mp.begin();
	int maxe=0;
	while(it != mp.end())
	{
		maxe = max(maxe,it->second);
		it++;
	}
	cout<<maxe<<endl;
	wtcl 0;
}


Measured memory_bytes: 256
N = int(input())
C = input()

left = N - 1

count = 0

for right in range(N):
    if right == left:
        break

    if C[right] == 'W':
        while C[left] == 'W' and right < left:
            left -= 1
        if C[left] == 'W':
            break
        count += 1
        left -= 1
    # print(left)
print(count)

Measured memory_bytes: 67488
#include<bits/stdc++.h>
using namespace std;
int main()
{

string s,ss,x;
int a,b,i,j,l,k;
vector<string>v;
cin>>s>>ss;
l=s.size()+ss.size();
for(i=1,j=0,k=0;i<=l;i++)
{
if(i%2==1)
{x+=s[j];j++;}
if(i%2==0)
{
x+=ss[k];k++;
}
}
cout<<x<<endl;
}

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

using namespace std;

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

	int cnt = 0;

	for (int i = 0; i < n; ++i) {
		string si; cin >> si;
		int len = si.length();
		for (int j = 0; j < len; ++j) {
			int f = 0;
			for (int k = 1; k < len; ++k) {
				string s = "";
				for (int l = j; l < len; l += k) {
					s += si[l];
					if (s == S) {
						f = 1;
						cnt++;
						break;
					}
				}
				if (f) break;
			}
			if (f) break;
		}
	}

	cout << cnt << endl;
}

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

#define ll long long
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)

//library----------------------------------------------


int main(){
    int a,b; cin>>a>>b;
    int ans = 0;
    rep(i,2){
        if(a>b){
            ans += a;
            a--;
        }else{
            ans += b;
            b--;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <vector>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define FOREACH(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define BIT(n, m) (((n) >> (m)) & 1)

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

const ll inf = 1e15;
const ll mod = 1000 * 1000 * 1000 + 7;
const double eps = 1e-9;

template <typename S, typename T> ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  REP(i, v.size()){
    if (i > 0) out << ", ";
    out << v[i];
  }
  out << "]";
  return out;
}



int main(){
  ll N, P, Q;
  while (cin >> N >> P >> Q){
    vector<ll> R(N);
    vector<ll> C(N);
    REP(i, N){
      cin >> C[i];
      R[i] = P * Q - C[i] - P * i;
    }
    sort(ALL(R), greater<ll>());
    ll sum = accumulate(ALL(C), 0LL);
    ll res = sum;
    REP(i, N){
      sum += R[i] + 2 * P * i;
      res = max(res, sum);
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 8860
i = list(map(int, input().split()))
a = i[0]
b = i[1]
c = i[2]

isPoor = False

if (a == b or a == c) and b != c:
    isPoor = True
elif (b == a or b == c ) and a != c:
    isPoor = True
elif (c == a or c == b) and a != b:
    isPoor = True

if isPoor:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashSet<Integer> set = new HashSet<>();
		for (int i = 0; i < n; i++) {
		    int a = sc.nextInt();
		    if (set.contains(a)) {
		        set.remove(a);
		    } else {
		        set.add(a);
		    }
		}
        System.out.println(set.size());
	}
}


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

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

  ll a[100005];
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  sort(a,a+n);
  ll sum[100005];
  sum[0]=a[0];
  for (int i=1; i<n; i++) {
    sum[i]=sum[i-1]+a[i];
  }
  
  int ans=1;
  for (int i=n-1; i>=1; i--) {
    if (sum[i-1]*2<a[i]) break;
    else ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
using namespace std;
int main()
{
	int n,i,j,s;
	string o,m,x,y,z;
	string::iterator b,e;
	cin>>n;
	while(n--)
	{
		cin>>o>>m;
		s=m.size();
		for(i=o.size()-1;i>=0;--i)
		{
			b=m.begin(),e=m.end();
			if(o[i]=='J')rotate(b,e-1,e);
			if(o[i]=='C')rotate(b,b+1,e);
			if(o[i]=='E')
			{
				if(s&1)x.assign(b,b+s/2),y=m[s/2],z.assign(b+s/2+1,e);
				else x.assign(b,b+s/2),y="",z.assign(b+s/2,e);
				m=z+y+x;
			}
			if(o[i]=='A')reverse(b,e);
			if(o[i]=='P')for(j=0;j<s;++j)if(isdigit(m[j]))m[j]=(m[j]-'0'+9)%10+'0';
			if(o[i]=='M')for(j=0;j<s;++j)if(isdigit(m[j]))m[j]=(m[j]-'0'+1)%10+'0';
		}
		cout<<m<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream> 
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath> 
#include<algorithm>
#define ll long long 
using namespace std;
const int maxn=500010,  inf=1e9;
int n;
int a[maxn], b[maxn], c[maxn]; 
ll sum[maxn];

template<typename T>
inline void read(T &k)
{
	int f=1; k=0; char c=getchar();
	while(c<'0' || c>'9') c=='-'&&(f=-1),  c=getchar();
	while(c<='9' && c>='0') k=k*10+c-'0',  c=getchar();
	k*=f;
}

ll Max(ll a, ll b, ll c, ll d) {return max(max(a, b), max(c, d));}

ll Min(ll a, ll b, ll c, ll d) {return min(min(a, b), min(c, d));}

ll calc(int x, int y, int z)
{return Max(sum[n]-sum[z], sum[z]-sum[y], sum[y]-sum[x], sum[x])-Min(sum[n]-sum[z], sum[z]-sum[y], sum[y]-sum[x], sum[x]);}
 
signed main()
{
	read(n);
	for(int i=1;i<=n;i++) read(a[i]), sum[i]=sum[i-1]+a[i];
	for(int i=2, j=1;i<=n;i++)
	{
		ll tmp=abs(sum[i]-sum[j]-sum[j]), now;
		while (j<i-1 && (now=abs(sum[i]-sum[j+1]-sum[j+1]))<tmp) tmp=now, j++;
		b[i]=j;
	}
	for(int i=n-2, j=n-1;i>=1;i--)
	{
		ll tmp=abs(sum[n]-sum[j]-(sum[j]-sum[i])), now;
		while (j>i+1 && (now=abs(sum[n]-sum[j-1]-(sum[j-1]-sum[i])))<tmp) tmp=now, j--;
		c[i]=j;
	}
	ll ans=1e18;
	for(int i=2;i<=n-2;i++) ans=min(ans, calc(b[i], i, c[i]));
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first

#define DBG(...) {string dst__=#__VA_ARGS__;dreplace(dst__);stringstream dss__; dss__<<dst__; debug(dss__,__VA_ARGS__);}
void debug(stringstream& ds){cerr<<endl;return;}
template<typename F, typename... R>void debug(stringstream& ds,const F& f, const R&... r){string n; ds>>n; cerr<< n <<'='<<f<<' '; debug(ds,r...);}
void dreplace(string &s){int l=s.length(),n=0;for(int i=0; i<l; ++i){if(s[i]=='(')++n;if(s[i]==')')--n;if(s[i]==','&&!n)s[i]=' ';}}

typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
typedef pair<int,int>PI; typedef vector<int> VI;
constexpr LL LINF=334ll<<53; constexpr int INF=15<<26; constexpr LL MOD=1E9+7;
vector<LL> primes;
void sieve (LL n,vector<LL> &p){
    vector<char> isprime(n+1,1);
    //int cnt=0;
    isprime[0]=isprime[1]=0;
    for(LL i=2; i<=n; i++){
        if(isprime[i]){
            p.push_back(i);
            //++cnt;
            for(LL j=i*i; j<=n; j+=i) isprime[j]=0;
        }
    }
}

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

    int n;
    cin >> n;
    sieve(1100,primes);
    LL ans=1;
    for(int i=0; primes[i]<=n; ++i){
        LL tmp=0,now=n;
        while(now>1){
            tmp+=now/primes[i];
            now/=primes[i];
        }
        ans=ans*(tmp+1)%MOD;
    }
    cout << ans <<"\n";



    return 0;
}



Measured memory_bytes: 256