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

long long n, res = 0;
const long long MAXN = 4010;
string s;

long long pr[MAXN], pg[MAXN], pb[MAXN];

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

    cin >> n >> s;
    if(s[0] == 'R') pr[0] = 1;
    else if(s[0] == 'G') pg[0] = 1;
    else pb[0] = 1;

    for(long long i = 1; i < n; ++i) {
        pr[i] = pr[i - 1];
        pg[i] = pg[i - 1];
        pb[i] = pb[i - 1];
        if(s[i] == 'R') pr[i]++;
        else if(s[i] == 'G') pg[i]++;
        else pb[i]++;
    }

    for(long long i = 0; i < n; ++i) {
        if(s[i] == 'R') {
            for(long long j = i + 1; j < n; ++j) {
                if(s[j] == 'R') continue;
                else if(s[j] == 'G') {
                    res += pb[n - 1] - pb[j];
                    if(2 * j - i < n && s[2 * j - i] == 'B') res--;
                }
                else {
                    res += pg[n - 1] - pg[j];
                    if(2 * j - i < n && s[2 * j - i] == 'G') res--;
                }
            }
        }
        else if(s[i] == 'G') {
            for(long long j = i + 1; j < n; ++j) {
                if(s[j] == 'G') continue;
                else if(s[j] == 'R') {
                    res += pb[n - 1] - pb[j];
                    if(2 * j - i < n && s[2 * j - i] == 'B') res--;
                }
                else {
                    res += pr[n - 1] - pr[j];
                    if(2 * j - i < n && s[2 * j - i] == 'R') res--;
                }
            }
        }
        else {
            for(long long j = i + 1; j < n; ++j) {
                if(s[j] == 'B') continue;
                else if(s[j] == 'R') {
                    res += pg[n - 1] - pg[j];
                    if(2 * j - i < n && s[2 * j - i] == 'G') res--;
                }
                else {
                    res += pr[n - 1] - pr[j];
                    if(2 * j - i < n && s[2 * j - i] == 'R') res--;
                }
            }
        }
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 3688
#include <stdio.h>
int main(void)
{
int a,b;
scanf("%d%d",&a,&b);
if(a > b){
    printf("a > b\n");
}
else if(a == b){
    printf("a == b\n");
}
else
    printf("a < b\n");
return 0;
}



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

using namespace std;

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

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    cout << min(min(abs(a-b),abs(a-c))+abs(b-c),abs(a-b)+abs(a-c));
    return 0;
}


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

static inline int in()
{
	int n = 0, c = getchar_unlocked();
	do {
		n = 10 * n + c - '0';
		c = getchar_unlocked();
	} while (c >= '0');
	return n;
}

int main()
{
	int C = 0;

	int n;
	n = in();
	int S[n];
	for (int &x: S) {
		x = in();
	}

	auto s = S, e = S + n;
	n = in();
	while (n--) {
		if(binary_search(s, e, in()))
			C++;
	}

	printf("%d\n", C);
}



Measured memory_bytes: 3076
A,B,C,K = map(int,input().split())
ans = 0

if A >= K:
    ans = 1*K
else:
    ans += 1*A
    K = K - A
    if B >= K:
        ans += 0*K
    else:
        ans += 0*B
        K = K - B
        ans += (-1)*K
        
print(ans)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}
/*
	SegmentTree
	last verified	: 2020/09/17, AtCoder
		problem			: https://atcoder.jp/contests/practice2/tasks/practice2_b
		submission		: https://atcoder.jp/contests/practice2/submissions/16796625
		problem			: https://atcoder.jp/contests/arc033/tasks/arc033_3
		submission		: https://atcoder.jp/contests/arc033/submissions/16796544
*/
#include <iostream>
#include <vector>
#include <functional>

template<typename T> struct segment_tree {
	int N;
	std::vector<T> V;
	std::function<T(T, T)> F;
	T E;

	segment_tree(std::vector<T>& a, std::function<T(T, T)> f, T e) : F(f), E(e) {
		int m = 1;
		while (m < a.size()) m *= 2;
		V.resize(N = m * 2, E);
		for (int i = 0; i < a.size(); i++) V[m + i] = a[i];
		for (int i = m - 1; i > 0; i--) V[i] = F(V[i * 2], V[i * 2 + 1]);
	}

	segment_tree(int n, std::function<T(T, T)> f, T e) : F(f), E(e) {
		int m = 1;
		while (m < n) m *= 2;
		V.resize(N = m * 2, E);
	}

	void point_update(int i, T x, std::function<T(T, T)> update) {
		int idx = N / 2 + i;
		V[idx] = update(V[idx], x);
		while (idx /= 2) V[idx] = F(V[idx * 2], V[idx * 2 + 1]);
	}

	T range_fold(int L, int R, int idx = 1, int l = 0, int r = -1) {
		if (r == -1) r = N / 2;
		if (L <= l && r <= R) return V[idx];
		if (r <= L || R <= l) return E;
		return F(range_fold(L, R, idx * 2, l, (l + r) / 2), range_fold(L, R, idx * 2 + 1, (l + r) / 2, r));
	}
};

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

	long long n, q;
	cin >> n >> q;
	long long ans = (n - 2) * (n - 2);

	segment_tree<int> highest(n, [](int a, int b){return min(a, b);}, n - 1);
	segment_tree<int> leftest(n, [](int a, int b){return min(a, b);}, n - 1);

	while (q--) {
		int op, x;
		cin >> op >> x;
		x--;
		int m;
		if (op == 1) {
			m = highest.range_fold(x, n);
			ans -= m - 1;
			leftest.point_update(m - 1, x, [](int a, int b){return min(a, b);});
		} else {
			m = leftest.range_fold(x, n);
			ans -= m - 1;
			highest.point_update(m - 1, x, [](int a, int b){return min(a, b);});
		}
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;

#define INF 		2000000007
#define MINF		-2000000007
#define MOD			10e9+7
#define MAX 		100005
// テンプレ終了
//====================================================================//

int dp[MAX];

// abc118
int main(){
	int N,M;cin>>N>>M;
	vector<int> A(M);
	REP(i,M)cin>>A[i];

	int cost[10] = {0,2,5,5,4,5,6,3,7,6};

	REPS(i,1,N+1)dp[i]=MINF;

	REPS(i,2,N+1){
		REP(j,M){
			if(i-cost[A[j]]<0)continue;
			dp[i] = max(dp[i],dp[i-cost[A[j]]]+1);
		}
	}

	sort(ALL(A),[&](int x,int y){
		return x > y;
	});
	
	string str;
	for(int i=N;i>0;){
		REP(j,M){
			if(i-cost[A[j]] < 0)continue;
			if(dp[i-cost[A[j]]] == dp[i]-1){
				str += to_string(A[j]) ;
				i -= cost[A[j]];
				break;
			}
		}
	}

	cout << str << endl;

	return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;

import static java.util.Arrays.fill;
import static java.lang.Math.*;
import static java.util.Arrays.sort;
import static java.util.Collections.sort;

public class Main {
	static int mod = 1000000007;
	static InputReader in = new InputReader(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {

		int n=in.nextInt();
		if(n==1)
		{
			System.out.println("Hello World");
			return;
		}
		else
		{
			out.println(in.nextInt()+in.nextInt());
		}
		out.close();

	}

	static class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public String readString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
	}

	private static void tr(Object... o) {
		if (!(System.getProperty("ONLINE_JUDGE") != null))
			System.out.println(Arrays.deepToString(o));
	}
}




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

int main()
{
  ll n, q;
  string s;
  cin >> n >> q >> s;
  vector<ll> v(n, 0);

  for (ll i = 1; i < n; i++)
  {
    if (s[i - 1] == 'A' && s[i] == 'C')
    {
      v[i] = v[i - 1] + 1;
    }
    else
    {
      v[i] = v[i - 1];
    }
  }

  for (ll i = 0; i < q; i++)
  {
    ll l, r;
    cin >> l >> r;
    cout << v[r - 1] - v[l - 1] << endl;
  }
}


Measured memory_bytes: 4320
#include<iostream>
using namespace std;
int main(){
    int n,a;
    cin >> n >> a;
    int m = n % 500;
    bool flag = false;
    if(m != 0){
        int k = n / 500; //500円を何枚使うか
        n -= k * 500;
        for(int i = 0; i <= a; i++){
            if(i == n){
                flag = true;
            }
        }
    }
    else{
        flag = true;
    }
    cout << (flag ? "Yes" : "No") << endl;
}


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

int main()
{
  int N,M,i;
  int pos,goal;
  int t;
  vector<int> v;
  while(cin>>N>>M,N||M){
    v.resize(N);
    for(i=0;i<N;i++){
      cin>>t;
      v[i]=t;
    }

    goal=0;
    pos=0;
    for(i=0;i<M;i++){
      cin>>t;
      if(goal)continue;
      pos+=t;
      if(pos>=N-1) goal=i+1;
      pos+=v[pos];
      if(pos>=N-1) goal=i+1;
    }

    cout<<goal<<endl;
  }
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

string a[11];
string dp[1 << 10][11];
int n;

string g(string a, string b) {
  //cout << a << " " << b << endl;
  int m = min(a.size(), b.size());
  for (int i = m; i >= 0; --i) {
    //cout << i << endl;
    bool ok = true;
    for (int j = 0; j < i; ++j) {
      if (a[a.size() - i + j] != b[j]) {
	ok = false;
	break;
      }
    }
    if (ok) {
      //cout << i << endl;
      //cout << a << " " << b <<" " << a + b.substr(i)<< endl;;
      return a + b.substr(i);
    }
  }
}

void f(int bit, int k) {
  if (dp[bit][k] != "") return;
  if (n == 0) return;
  rep (i, n) if (bit & (1 << i)) {
    f(bit ^ (1<<i), k - 1);
    string s = "";
    string ss;
    if (k == 1) {
      dp[bit][i] = a[i];
      continue;
    }
    rep (j, n) if ((bit^(1<<i)) & (1 << j)){
      ss = g(dp[bit^(1<<i)][j], a[i]);
      if (s == "" || ss.size() < s.size() || (ss.size() == s.size() && ss < s)) s = ss;
    }
    dp[bit][i] = s;
 
  }

}


int main() {
  for (;;) {
    cin >> n;
    if (n == 0) break;
    int k = 0;
    rep (i, n) {
      cin >> a[k];
      rep (i, k) {
	if (string::npos != a[i].find(a[k])) {
	  --k; break;
	}
	if (string::npos != a[k].find(a[i])) {
	  a[i] = a[k];
	  --k;break;
	}
      }
      ++k;
    }
    n = k;
    rep (i, 1<<n) rep (j , 11) dp[i][j] = "";
    f ((1 << n) - 1, n);
    string res = "";
    rep (i, n) if (res == "" || dp[(1<<n)-1][i].size() < res.size() || (dp[(1 << n) - 1][i].size() == res.size() && dp[(1<<n)-1][i] < res)) res = dp[(1<<n)-1][i];
    cout << res << endl;
  }
}

Measured memory_bytes: 1360
import java.util.Scanner;

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

    Scanner sc = new Scanner(System.in);

    long a = sc.nextLong();
    long b = sc.nextLong();
    long n = sc.nextLong();

    long x;

    if (b <= n) {
      x = b - 1;
    } else {
      x = n;
    }

    long ret1 = a * x / b;
    long ret2 = x / b;
    long ret3 = ret1 - a * ret2;

    System.out.println(ret3);

  }
}


Measured memory_bytes: 35712
import numpy as np
n = int(input())
num_list = list(map(int,input().split()))

even_cnt = [0]*(10**5 + 10)
odd_cnt = [0]*(10**5 +10)
for i in range(n):
    if i % 2 == 0:
        even_cnt[num_list[i]] += 1
    else:
        odd_cnt[num_list[i]] += 1
ame = np.argmax(even_cnt)
amo = np.argmax(odd_cnt)
if ame != amo:
    print(len(num_list) - max(even_cnt) -  max(odd_cnt))
    
    
else:
    tmp_e_max =  max(even_cnt)
    tmp_o_max = max(odd_cnt)
    even_cnt[ame] = 0
    odd_cnt[amo] = 0
    if tmp_e_max-max(even_cnt) >=  tmp_o_max - max(odd_cnt):
        print(len(num_list) - max(odd_cnt) -  tmp_e_max)
    else:
        print(len(num_list) - max(even_cnt) -  tmp_o_max)

Measured memory_bytes: 23392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const int maxn = 500050;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const ll linf = 7e18;
ll power(ll x, ll y)
{
    ll ans = 1;
    while (y)
    {
        if (y & 1)
            ans = ans * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return ans;
}

ll gcd(ll x, ll y)
{
    if (x % y == 0)
        return y;
    return gcd(y, x % y);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    cout << n * m << "\n";
    return 0;
}


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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    ll X;
    cin >> X;
    ll t = 100;
    int i;
    for (i=0; t<X; ++i) {
        t += t / 100;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N;
	cin >> N;
	double ans = 0;
	for(int i=0; i<N; i++){
		double tmp;
		string type;
		cin >> tmp >> type;
		if(type == "JPY"){
			ans += tmp;
		}
		else{
			ans += tmp * (double)380000;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;



int main(void) {
	ll n;
	cin >> n;
	vl cnts(100001,0);
	ll sum = 0;
	rep(i, n) {
		ll a;
		cin >> a;
		sum += a;
		cnts[a]++;
	}
	ll q;
	cin >> q;
	rep(i, q) {
		ll b, c;
		cin >> b >> c;
		sum -= cnts[b] * b;
		sum += cnts[b] * c;
		cout << sum << endl;
		cnts[c] += cnts[b];
		cnts[b] = 0;

	}
	return 0;
}


Measured memory_bytes: 3984
#include <iostream>
#include <cmath>

int main(void){
  int n;
  std::cin >> n;

  int count = 0;
  for(int i=1; i<=n; i++){
    if(((int) std::log10(i) + 1) % 2){
      count++;
    }
  }
  std::cout << count << std::endl;
  return 0;

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,x;
    cin>>n>>m>>x;
    vector<vector<int>> books(n,vector<int>(m,0));
    vector<int> c(n);
    for(int i=0;i<n;i++)
    {
        int t1;
        cin>>t1;
        c[i]=t1;
        for (int j = 0; j < m; j++)
        {
            int t2;
            cin>>t2;
            books[i][j]=t2;
        }
    }
    // for(int i=0;i<n;i++)
    // {
    //     for(int j=0;j<m;j++)
    //         cout<<books[i][j]<<" ";
    //     cout<<endl;
    // }
    int a=1<<n;
    int res=INT_MAX;
    for(int mask=0;mask<a; mask++)
    {
        int cost=0;
        vector<int> level(m,0);
        for (int i = 0; i < n; i++)
        {
            if((1<<i) & mask)
            {
                cost+=c[i];
                for(int j=0;j<m;j++)
                    level[j]+=books[i][j];
            }
        }
        bool ok=true;
        // for(int i=0;i<m;i++)
        //     cout<<level[i]<<" ";
        // cout<<endl;
        for(int i=0;i<m;i++)
        {
            if(level[i]<x)
            {
                ok=false;break;
            }
        }
        if(ok)
            res=min(res,cost);
    }
    if(res==INT_MAX)
        cout<<-1<<endl;
    else
        cout<<res<<endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int read(){
	int x=0,f=1;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return x*f;
}
const int N=400010,INF=0x3f3f3f3f;
int a[N],n;
struct DATA{
	int x,y;
}s[N];
int ls,mid;
inline void insert(int x){
	if (s[ls].x>x){
		while (s[ls].x>x) --ls;
		if (s[ls].x<x) s[++ls]=(DATA){x,1};
	}
	if (s[ls].x==x){
		++s[ls].y;
		if (s[ls].y>mid) insert(x-1),s[++ls]=(DATA){x,1};
	}
	else s[++ls]=(DATA){x,1};
}
inline bool judge(){
	ls=0;
	s[++ls]=(DATA){0,0};
	for (int i=1;i<=n;++i){
		if (mid==1&&a[i]<=a[i-1]) return 0;
		insert(a[i]);
		if (s[1].y) return 0;
	}
	return 1;
}
int main(){
	n=read();
	for (int i=1;i<=n;++i) a[i]=read();
	int l=1,r=n;
	while (l<r){
		mid=(l+r)>>1;
		if (judge()) r=mid;
		else l=mid+1;
	}
	printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 3840
use proconio::{input, fastout};
use proconio::marker::Chars;
use std::cmp::Reverse;

#[derive(Debug)]
struct LR {
    l: isize,
    r: isize,
}

impl LR {
    fn new () -> Self {
        Self { l: 0, r: 0 }
    }
}

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

    let mut lrs1 = vec![];
    let mut lrs2 = vec![];

    for s in ss {
        let mut lr = LR::new();
        let mut num = 0;
        for c in s {
            match c {
                '(' => {
                    num += 1;
                },
                ')' => {
                    if num == 0 {
                        lr.l += 1;
                    } else {
                        num -= 1;
                    }
                }
                _ => {},
            }
        }
        if num > 0 {
            lr.r = num;
        }

        if lr.l <= lr.r {
            lrs1.push(lr)
        } else {
            lrs2.push(lr);
        }
    }



    lrs1.sort_by_key(|x| (x.l, x.r));
    lrs2.sort_by_key(|x| (Reverse(x.r), x.l));


    let mut num = 0;
    for lr in lrs1{
        num -= lr.l;
        if num < 0 {
            println!("No");
            return;
        }
        num += lr.r;
    }
    for lr in lrs2 {
        num -= lr.l;
        if num < 0 {
            println!("No");
            return;
        }
        num += lr.r;
    }
    
    if num == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 66684
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A[3],max,sum,ans;
    cin >> A[0] >> A[1] >> A[2];
    while(1) {
        sort(A, A+3);
        if(A[0]==A[2]){
            break;
        } else if (A[0] + 2 <= A[2]) {
            A[0] += 2;
            ans++;
        } else {
            A[0]++;
            A[1]++;
            ans++;
        }
    }
    cout << ans;
}

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

string find_word1 = "0";
string find_word2 = "1";

ll maxAns(string s, int count)
{
  int max = count;
  int tmp = 0;
  int c0 = 0;
  int c1 = 0;
  std::string::size_type pos;
  if ( s.size() < 2 ) return count;
  //if ( mp[s] > 0 ) return mp[s];

  pos = s.find(find_word1);
  while (pos != std::string::npos) {
    c0++;
    pos = s.find(find_word1, pos + find_word1.length());
  }
  pos = s.find(find_word2);
  while (pos != std::string::npos) {
    c1++;
    pos = s.find(find_word2, pos + find_word2.length());
  }
  if ( c0 < c1 ) max = c0*2;
  else max = c1*2;
  return max;
}

void solve() {
  string s;
  cin >> s;
  ll count=0;
  ll ret = maxAns(s,0);
  std::cout << ret << std::endl;
}

int main(int argc, char *argv[])
{
  solve();
  return 0;
}

Measured memory_bytes: 512
/**
 *      purpose : ABC 122 A
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

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

  char t; cin >> t;
  if (t == 'A') print('T');
  else if (t == 'T') print('A');
  else if (t == 'C') print('G');
  else print('C');

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
  string s;
  cin >> s;
  vector<char> v;
  int n=s.size();
  for(int i=0;i<n;i++){ 
    char t=s[i];
    if(i==0){
      v.push_back(t);
      continue;
    }
    if(s[i]!=v.back()){
      v.push_back(t);
    }else{
      if(i==n-1) continue;
      t=t+s[i+1];
      v.push_back(t);
      i++;
    }
  }
  int ans=v.size();
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 772
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    if K % 7 == 0:
        L = (9*K) // 7
    else:
        L = 9 * K
    temp = 10 % L
    if temp == 1:
        print(1)
    else:
        for i in range(L):
            temp = (temp*10) % L
            if temp == 1:
                print(i+2)
                break

Measured memory_bytes: 9192
import queue
class gridMan:
  def __init__(s, L):
    s.L = L
    s.H = len(s.L)
    s.W = len(s.L[0])
  def makeWall(s, x = -2):
    w = len(s.L[0]) + 2
    s.L = [[x] * w] + [[x] + i + [x] for i in s.L] + [[x] * w]
  def dist(s, S): #Sから上下左右に進んで何手かかるかのリスト　および　最大値
    T = [[-1] * s.W for _ in range(s.H)]
    q = queue.Queue()
    q.put([S[0], S[1]])
    T[S[0]][S[1]] = 0
    k = 0
    D = [[S[0], S[1]]]
    while True:
      while not q.empty():
        h, w = q.get()
        k = T[h][w]
        for i, j in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
          hh = h + i
          ww = w + j
          if s.L[hh + 1][ww + 1] >= 0 and (T[hh][ww] == -1 or T[hh][ww] > k):
            q.put([hh, ww])
            D.append([hh, ww])
            T[hh][ww] = k
      if len(D) == 0: break
      ND = []
      for h, w in D:
        for i in range(-2, 3):
          for j in range(-2, 3):
            hh = h + i
            ww = w + j
            if hh < 0: continue
            if hh > H: continue
            if ww < 0: continue
            if ww > W:continue
            if s.L[hh + 1][ww + 1] >= 0 and (T[hh][ww] == -1 or T[hh][ww] > k + 1):
              q.put([hh, ww])
              ND.append([hh, ww])
              T[hh][ww] = k + 1
      D = ND

    return T, k


H, W = list(map(int, input().split()))
C = list(map(int, input().split()))
D = list(map(int, input().split()))
S = [list(input()) for _ in range(H)]

for i in range(H):
  for j in range(W):
    if S[i][j] == ".":
      S[i][j] = 0
    else:
      S[i][j] = -1

G = gridMan(S)
G.makeWall()

T, k = G.dist([C[0] - 1, C[1] - 1])

print(T[D[0] - 1][D[1] - 1])


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

int main() {
	int n;
	cin >> n;
	double t, x;
	cin >> t >> x;
	vector<double> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	double ans = 1e9;
	int index = 0;
	for (int i = 0; i < n; ++i) {
		double p = abs(x - t  + v[i] * 0.006);
		//cout << p << endl;
		if (p < ans) {
			index = i;
			ans = p;
		}
	}
	cout << index + 1;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    long long tmp1 = a * c;
    long long tmp2 = a * d;
    long long tmp3 = b * c;
    long long tmp4 = b * d;
    if (a * b <= 0 || c * d <= 0) {
        long long tmp5 = 0;
        ans = max(tmp1, tmp2);
        ans = max(ans, tmp3);
        ans = max(ans, tmp4);
        ans = max(ans, tmp5);
    } else {
        ans = max(tmp1, tmp2);
        ans = max(ans, tmp3);
        ans = max(ans, tmp4);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
typedef pair<int,int>P;
vector<P>ans;
//map<int,int>m;

int search(int n,int A,int B){
	int nn=n;
	int a=0;
	REP(i,N){
		if(((n>>i)&1)==0){
			int C=(A|n)^(1<<i);
			int D=(B|n);
			if(C!=D)return (A^(1<<i));
		}
		nn%=2;
	}
	return -1;
}

void dfs(int A,int B,int n){
	//cout<<A<<" "<<B<<" "<<n<<endl;
	int c=0;
	int nn=n;
	while(nn!=0){
		c+=(nn%2);
		nn/=2;
	}
	if(c==N-1){
		ans.push_back(P(A,B));
		return;
	}
	int a=-1;
	int C=A;
	int D=B;
	REP(i,N){
		if((C%2!=D%2)&&(((n>>i)&1))==0){
			int X;
			int Y;
			if(C%2==0){
				X=search(n|(1<<i),A,B);
				Y=X;
				//X=(X|(n|1<<i));
				//Y=(Y|(n|1<<i))^(1<<i);
				Y^=(1<<i);
				//cout<<X<<" "<<Y<<endl;
				//cout<<A<<" "<<X<<" "<<Y<<"b "<<B<<endl;
				dfs(A,X,n|(1<<i));
				ans.push_back(P(X,Y));
				dfs(Y,B,n|(1<<i));
			}else{
				X=search(n|(1<<i),A,B);
				Y=X;
				//Y=(Y|(n|1<<i))^(1<<i);
				//X=(X|(n|1<<i));
				Y^=(1<<i);
				//cout<<A<<" "<<X<<" "<<Y<<"a "<<B<<endl;
				dfs(A,X,n|(1<<i));
				ans.push_back(P(X,Y));
				dfs(Y,B,n|(1<<i));
			}
			break;
		}
		C/=2;
		D/=2;
	}
}

int main(){
	cin>>N;
	int A;
	int B;
	cin>>A>>B;
	int C=A;
	int D=B;
	int c=0;
	/*REP(i,(1<<N)){
		m[i]=1;
	}*/
	while(C!=0||D!=0){
		int a=C%2;
		int b=D%2;
		if(a!=b)c++;
		C/=2;
		D/=2;
	}
	if(c%2==0){
		cout<<"NO"<<endl;
	}else{
		//m.erase(A);
		//m.erase(B);
		cout<<"YES"<<endl;
		dfs(A,B,0);
		cout<<ans[0].first;
		REP(i,ans.size()){
			//cout<<" "<<ans[i].first<<" "<<ans[i].second<<endl;
			cout<<" "<<ans[i].second;
		}
		cout<<endl;
	}
	//cout<<1<<endl;
}

Measured memory_bytes: 2164
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int w = sc.nextInt();
	int n = sc.nextInt();
	int[] values = new int[w];
	for (int i = 0; i < values.length; i++) {
		values[i] = i + 1;
	}
	for (int i = 0; i < n; i++) {
		String str = sc.next();
		String[] ab = str.split(",");
		int a = Integer.parseInt(ab[0]) - 1;
		int b = Integer.parseInt(ab[1]) - 1;
		int num;

		num=values[a];
		values[a]=values[b];
		values[b]=num;

		}
		for(int x=0;x<w;x++){
		System.out.println(values[x]);
	}	
}
}

Measured memory_bytes: 26068
'use strict'

function main(input) {

    input = input.split(/\n|\s/).map(v => ~~v)
    const n = input[0]
    const a = input[1]
    const b = input[2]

    let total = 0
    for (let i = 1; i <= n; i++) {

        let tmp = i.toString().split('').map(v => ~~v).reduce((a, b) => a + b)

        if (a <= tmp && tmp <= b) {
            total += i
        }

    }
    console.log(total)

}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 10856
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b, c; cin >> a >> b >> c;
    cout << (a + b + c >= 22 ? "bust" : "win") << endl;
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)


/* ---------- container ---------- */

#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
const ll INF = 1LL << 50;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

template <typename T>

void testVector(T& v) {
  REP(i, SZ(v)) {
    cout << i << ":" << v << endl;
  }
}


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */

ll H, W;
ll ans = INF;

/* ---------- Functions ---------- */

PL split(ll h, ll w) {
  PL vert = {h * (w / 2), h * (w - w / 2)};
  PL hol = {(h / 2) * w, (h - h / 2) * w};
  if (abs(vert.fst - vert.snd) < abs(hol.fst - hol.snd)) {
    return vert;
  } else {
    return hol;
  }
}

/* ---------- Main Function ---------- */

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

  cin >> H >> W;

  NREP(i, H - 1) {
    ll Sa = i * W;
    PL Sb = split(H - i, W);
    ll diffa = max(abs(Sa - Sb.fst), abs(Sa - Sb.snd));
    ll diffb = abs(Sb.fst - Sb.snd);
    ll diff = max(diffa, diffb);
    ans = min(diff, ans);
  }

  NREP(i, W - 1) {
    ll Sa = i * H;
    PL Sb = split(H, W - i);
    ll diffa = max(abs(Sa - Sb.fst), abs(Sa - Sb.snd));
    ll diffb = abs(Sb.fst - Sb.snd);
    ll diff = max(diffa, diffb);
    ans = min(diff, ans);
  }

  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;





//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define RALL(x) (x).rbegin(),(x).rend() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define seq vector
#define READLINE(vec,time) for(int indexofvec=0;indexofvec<time;indexofvec++)cin>>vec[indexofvec]


vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}




signed main(){
    int N,M,AC=0,WA=0;
    cin >> N >> M;
    vector<bool> isAC(N,false);
    vector<int> waCount(N,0);
    for(int i =0;i<M;i++){
        int p;
        string s; 
        cin >> p >> s;
        p--;
        if(s=="AC" && !isAC[p]){
            AC+=1;
            isAC[p]=true;
        }

        if(s=="WA" && !isAC[p]){
            waCount[p]+=1;
        }        


    }

    cout << AC << " ";
    for(int i=0;i<N;i++){
        if(isAC[i]){

            WA+=waCount[i];

        }
    }
    cout << WA << endl;

   



}

Measured memory_bytes: 5376
#70 行列の積

n, m, l = map(int,input().split())

a = []
for i in range(n):
    a.append(list(map(int,input().split())))

b = []
for i in range(m):
    b.append(list(map(int,input().split())))
    
c = [[0] * l for i in range(n)]    
    
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
    print(*c[i])



Measured memory_bytes: 7028
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using P = pair<int, int>;
using LL = long long;

#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN_LL(v) LL v;cin>>v;
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl
#define MOD 1000000007

int main() {
  IN(W);
  IN(H);
  IN(N);

  int tile[H][W];
  REP(i, H)
    REP(j, W)
      tile[i][j] = 0;

  REP(i, N) {
    IN(x); IN(y); IN(a);
    int left = 0, right = W;
    int top = 0, bottom = H;
    if (a == 1)
      right = x;
    else if (a == 2)
      left = x;
    else if (a == 3)
      bottom = y;
    else
      top = y;
    FOR(i, top, bottom)
      FOR(j, left, right)
          tile[i][j] = 1;
  }
  int count = 0;
  REP(i, H)
    REP(j, W)
      if (tile[i][j] == 0)
        ++count;
  OUT(count);

  return 0;
}


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

int main() {
  ll n;
  cin >> n;
  ll ppmax = -1e10, ppmin = 1e10;
  ll pmmax = -1e10, pmmin = 1e10;
  for (int i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    ppmax = max(ppmax, x + y);
    ppmin = min(ppmin, x + y);
    pmmax = max(pmmax, x - y);
    pmmin = min(pmmin, x - y);
  }
  cout << max(ppmax - ppmin, pmmax - pmmin) << endl;
}


Measured memory_bytes: 3620
s = input() 
if s[-1]=="0" or s[-1]=="1" or s[-1]=="6" or s[-1]=="8":
    print("pon")
    
elif s[-1]=="3":
    print("bon")
    
elif s[-1]=="2" or s[-1]=="4" or s[-1]=="5" or s[-1]=="7" or s[-1]=="9":
    print("hon")

Measured memory_bytes: 9120
import sys
x=int(input())
l=[]
for i in range(-500,500):
  l.append([i**5,i])
for i in range(len(l)):
  for j in range(len(l)):
    if l[i][0]-l[j][0]==x:
      print(l[i][1],l[j][1])
      sys.exit()

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


void solve() {
  int N;
  scanf("%d", &N);
  int arr[N];
  rep(i,N) {
    scanf("%d", &arr[i]);
  }
  int ans=0;
  for (int i = 1; i < N-1; i++) {
    if ((max(arr[i-1],arr[i])==arr[i] && min(arr[i],arr[i+1])==arr[i])
          || (max(arr[i+1],arr[i])==arr[i] && min(arr[i],arr[i-1])==arr[i])) {
            ans++;
    }
  }

  cout << ans << "\n";
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,b,e) for(int i=b; i<e; i++)

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	int dist[n][n], a[m], b[m], c[m];
	REP(i, 0, n) REP(j, 0, n) dist[i][j] = 1e9;
	REP(i, 0, m){
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
		a[i]--, b[i]--;
		dist[a[i]][b[i]] = c[i];
		dist[b[i]][a[i]] = c[i];
	}

	REP(k, 0, n) REP(i, 0, n) REP(j, 0, n) {
		dist[i][j] = std::min(dist[i][j], dist[i][k]+dist[k][j]);
	}

	int ans = 0;
	REP(i, 0, m){
		if(dist[a[i]][b[i]]!=c[i]) ans++;
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 3860
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int r,D,x2000,x20[11],i;
    cin>>r>>D>>x2000;
    x20[0]=x2000;
    for(i=1;i<11;i++)
    {
        x20[i]=r*x20[i-1]-D;
    }
    for(i=1;i<11;i++)
    {
        printf("%d\n",x20[i]);
    }
    return 0;
}


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

using namespace std;

int
main(int argc, char **argv)
{
    int n;
    cin >> n;

    int x;
    vector<int> v;
    int ave;

    for(int i=0;i<n;i++){
        cin >> x;
        v.push_back(x);
        ave += x;
    }

    int min = *std::min_element(v.begin(), v.end());
    int max = *std::max_element(v.begin(), v.end());
    int a = 0;
    vector<int> vv;

    for(int j = min; j<=max;j++){
        for(int i=0;i<n;i++){
            a += pow(v[i]-j,2);
        }
        vv.push_back(a);
        a = 0;
    }

    int minmin = *std::min_element(vv.begin(), vv.end());
    cout << minmin << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=x-1;i>=;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;

ll a(ll x){
    if(x>1)return a(x/2)*2 + 1;
    return 1;
}

int main(){
    ll h;
    cin>>h;
    cout<<a(h)<<endl;;
    
}


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

using namespace std;

int a[77];

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  long long ans = 1e18;
  for (int i = 0; i < (1 << n); ++i) {
    int cnt = 0;
    for (int j = 0; j < n; ++j) {
      if ((i >> j) & 1) {
        ++cnt;
      }
    }
    if (cnt != k) {
      continue;
    }
    long long cur = 0;
    int mx = 0;
    for (int j = 0; j < n; ++j) {
      if ((i >> j) & 1) {
        if (a[j] <= mx) {
          cur += mx - a[j] + 1;
          ++mx;
        }
      }
      mx = max(mx, a[j]);
    }
    ans = min(ans, cur);
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), a = ip[0], b = ip[1], c = ip[2];
	if(a==b) writeln(c);
	else if(b==c) writeln(a);
	else writeln(b);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[3][3];
    for(int i=0;i<3;i++)cin>>a[i][0]>>a[i][1]>>a[i][2];
    int n;
    cin>>n;
    int b[n];
    for(int i=0;i<n;i++)cin>>b[i];
    bool p[3][3]={{false,false,false},{false,false,false},{false,false,false}};
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<n;k++){
                if(a[i][j]==b[k]){
                    p[i][j]=true;
                    break;
                }
            }
        }
    }
    bool can=false;
    for(int i=0;i<3;i++){
        if(p[i][0]==true&&p[i][1]==true&&p[i][2]==true){
            can=true;
            break;
        }
        else if(p[0][i]==true&&p[1][i]==true&&p[2][i]==true){
            can=true;
            break;
        }
    }
    if(p[0][0]==true&&p[1][1]==true&&p[2][2]==true)can=true;
    else if(p[2][0]==true&&p[1][1]==true&&p[0][2]==true)can=true;
    if(can)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

auto isprime = [](auto n){
  bool isPrime = true;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return isPrime;
};

int main() {
    ll n,k;
    cin>>n>>k;


    unordered_set<ll> divn,divk;
    divn = divv(n);
    divk = divv(k);
    ll sum=0;
    for(auto it:divk) if(divn.count(it)) if(isprime(it)) sum++;
    pr(sum);
}


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

bool dp[8005][16010]; // i回目のx軸方向の移動の後にx座標がxになっているか
int main(){
  string s;
  int gx, gy;
  cin >> s >> gx >> gy;
  // Tを区切りとしてi番目の区間のFの個数をカウントする
  vector<int> dx, dy;
  int cnt = 0, dir = 1;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'T'){
      dir ? dx.push_back(cnt) : dy.push_back(cnt);
      cnt = 0;
      dir = !dir;
      continue;
    }
    cnt++;
  }
  dir ? dx.push_back(cnt) : dy.push_back(cnt);
  dp[0][8000] = dp[1][dx[0]+8000] = true;
  for(int i = 1; i < dx.size(); i++){
    for(int x = -8000; x <= 8000; x++){
      if(dp[i][x+8000])
        dp[i+1][x-dx[i]+8000] = dp[i+1][x+dx[i]+8000] = true;
    }
  }
  bool ans = dp[dx.size()][gx+8000];
  memset(dp, false, sizeof(dp));
  dp[0][8000] = true;
  for(int i = 0; i < dy.size(); i++){
    for(int y = -8000; y <= 8000; y++){
      if(dp[i][y+8000])
        dp[i+1][y-dy[i]+8000] = dp[i+1][y+dy[i]+8000] = true;
    }
  }
  ans &= dp[dy.size()][gy+8000];
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


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

int main() {
    int n, t, a;
    int h[1010];
    double diff;
    double min_diff = 999.9;
    int min_index = -1;
    
    cin >> n >> t >> a;
    
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    
    for (int i = 0; i < n; i++) {
        diff = abs(a - (t - h[i] * 0.006));
        
        if (
            (i == 0) ||
            (diff < min_diff)
        ) {
            min_diff = diff;
            min_index = i;
        }
    }
    
    cout << (min_index + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)


def main():
    N, K = MAP()

    print(len(Base_10_to_n(N, K)))


if __name__ == '__main__':
    main()


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

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

   int ans = 0;

   rep(i, n+1) {
       ans += i;
   }

   cout << ans << endl;
}

Measured memory_bytes: 256