akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=100005;
const int mod=998244353;
void debug(bitset<max_n> a){
    for(int i=a._Find_first();i<max_n;i=a._Find_next(i))cout<<i<<' ';
    cout<<"ffff"<<endl;
}
inline int Add(int x,int y){
    return (x+=y)>=mod?x-mod:x;
}
bitset<max_n> gcd(bitset<max_n> a,bitset<max_n> b){
    while(1){
        //debug(a),debug(b);
        int n=-1,m=-1;
        for(int i=a._Find_first();i<max_n;i=a._Find_next(i))n=i;
        for(int i=b._Find_first();i<max_n;i=b._Find_next(i))m=i;
        if(n==-1)return b;
        if(m==-1)return a;
        if(n>=m)a^=b<<(n-m);
        else b^=a<<(m-n);
    }
}
int n;
bitset<max_n> x;
bitset<max_n> a;
char s[max_n];
int solve(){
    int res=0;
    int n=-1,m=-1;
    for(int i=x._Find_first();i<max_n;i=x._Find_next(i))n=i;
    for(int i=a._Find_first();i<max_n;i=a._Find_next(i))m=i;
    for(int i=n;i>=m;i--)res=(res*2+x[i])%mod;
    bitset<max_n> r;r.reset();
    for(int i=n;i>=m;i--){
        if(r[i]!=x[i])r^=a<<(i-m);
    }
    int p=m-1;
    while(p>=0&&r[p]==x[p])p--;
    if(p==-1||r[p]<x[p])res=(res+1)%mod;
    return res;
}
int main(){
    scanf("%d",&n);
    scanf(" %s",s);
    x=(bitset<max_n>)s; 
    for(int i=0;i<n;i++){
        scanf(" %s",s);
        a=gcd(a,(bitset<max_n>)s);
    }
    //debug(a);
    printf("%d\n",solve());
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int H[200000];
long long getsum(int n, int k)
{
	int i;
	long long tot=0;
	for(i=0;i<n-k;i++)
			tot += H[i];
	return tot;
}
void swap(int* a, int* b) 
{ 
	int t = *a; 
	*a = *b; 
	*b = t; 
} 

int partition (int low, int high) 
{ 
	int pivot = H[high]; // pivot 
	int i = (low - 1); // Index of smaller element 

	for (int j = low; j <= high- 1; j++) 
	{ 
		// If current element is smaller than the pivot 
		if (H[j] < pivot) 
		{ 
			i++; // increment index of smaller element 
			swap(&H[i], &H[j]); 
		} 
	} 
	swap(&H[i + 1], &H[high]); 
	return (i + 1); 
} 

void quickSort(int low, int high) 
{ 
	if (low < high) 
	{ 
		/* pi is partitioning index, arr[p] is now 
		at right place */
		int pi = partition(low, high); 

		// Separately sort elements before 
		// partition and after partition 
		quickSort(low, pi - 1); 
		quickSort(pi + 1, high); 
	} 
} 


int main()
{
	int K,N;
	scanf("%d %d",&N,&K);
	
	int i=0;
	long long m;
	while(i<N)
	{
		scanf("%d", &H[i]);
		i+=1;
	}
	if (K>=N)
		m=0;
	else if (K==0)
		m = getsum(N,0);
	else
	{
		quickSort(0,N-1);
		m = getsum(N,K);
	}
	printf("%lld",m);	
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define int long long 
bool flag[100010];
ll a[100010];
signed main(){
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int x;
        cin >> x;
        flag[x] = 1;
    }
    a[0] = 1;
    if(!flag[1])a[1] = 1;
    for(int i=2;i<=n;i++){
        if(!flag[i]){
            a[i] = (a[i-1]+a[i-2])%mod;
        }
    }
    cout << a[n] << endl;
    return 0;   
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define sort(vec) sort(vec.begin(),vec.end())
#define reverse(vec) reverse(vec.begin(),vec.end())
#define unsort(vec); sort(vec);reverse(vec);
#define int long long
long long ans;

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

int lcm(int x,int y){
	return x/gcd(x,y)*y;
}
 
signed main(){
	int n,x=0,y=0,c;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]%4==0)x++;
		else if(a[i]%2==0)y++;
	}
	if(n-x-y<=x){
		cout<<"Yes"<<endl;
		return 0;
	}
	else if(y==0){
		if(n-x-y<=x+1){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 1024
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptor/reversed.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

namespace lib
{
	namespace detail
	{
		template<class T>void warshall_floyd(boost::multi_array<T, 2>& ar, std::size_t N)
		{
			auto rng = boost::irange<std::size_t>(0, N);
			auto max = std::numeric_limits<T>::max();
			for (auto k : rng)
			{
				for (auto i : rng)
				{
					for (auto j : rng)
					{
						if (ar[i][k] != max && ar[k][j] != max)
						{
							ar[i][j] = std::min(ar[i][j], ar[i][k] + ar[k][j]);
						}
					}
				}
			}
		}
		std::size_t length(std::vector<std::set<std::size_t>>const& edge, std::size_t a, std::size_t b)
		{
			if (a == b)
			{
				return 0;
			}
			else if (edge[a].count(b))
			{
				return 1;
			}
			else
			{
				return std::numeric_limits<std::size_t>::max();
			}
		}
		template<class T>T length(std::vector<std::map<std::size_t, T>>const& edge, std::size_t a, std::size_t b)
		{
			if (a == b)
			{
				return T();
			}
			else if(edge[a].count(b))
			{
				return edge[a].at(b);
			}
			else
			{
				return std::numeric_limits<T>::max();
			}
		}
	}
	template<class T>auto warshall_floyd(T const& edge)
	{
		auto N = edge.size();
		auto rng = boost::irange<std::size_t>(0, N);
		boost::multi_array<decltype(detail::length(edge, 0, 0)), 2> ar(boost::extents[N][N]);
		for (auto a : rng)
		{
			for (auto b : rng)
			{
				ar[a][b] = detail::length(edge, a, b);
			}
		}
		detail::warshall_floyd(ar, N);
		return ar;
	}
}

void Main()
{
	int N, M;
	std::cin >> N >> M;
	std::vector<std::map<std::size_t, std::int64_t>> graph(N);
	std::vector<std::tuple<std::size_t, std::size_t, std::int64_t>> edges(M);
	for (auto& t : edges)
	{
		std::size_t a, b;
		std::int64_t c;
		std::cin >> a >> b >> c;
		--a; --b;
		graph[a][b] = graph[b][a] = c;
		t = std::make_tuple(a, b, c);
	}
	auto ar = lib::warshall_floyd(graph);
	std::cout << boost::count_if(edges, [&](auto && t)
		{
			auto a = std::get<0>(t);
			auto b = std::get<1>(t);
			auto c = std::get<2>(t);
			return c > ar[a][b];
		}) << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
int Mod;
int qpow(int x,int y,int p=Mod){
	int res=1;
	for (;y;y>>=1,x=1LL*x*x%p)
		if (y&1) res=1LL*res*x%p;
	return res;
}
inline int upd(int x){return x+(x>>31&Mod);}
int C[3100][3100],S[3100][3100];
void init(int x){
	C[0][0]=S[0][0]=1;
	for (int i=1;i<=x;i++){
		C[i][0]=1;
		for (int j=1;j<=i;j++){
			C[i][j]=upd(C[i-1][j]+C[i-1][j-1]-Mod);
			S[i][j]=(S[i-1][j-1]+1LL*j*S[i-1][j])%Mod;
		}
	}
}

int n;
int main()
{
	scanf("%d%d",&n,&Mod);
	init(n+10);
	int res=0;
	for (int i=0,a=1;i<=n;i++,a=upd(-a)){
		int subres=0;
		for (int j=0,b=qpow(2,n-i),c=1;j<=i;j++,c=1LL*c*b%Mod){
			subres=(subres+1LL*S[i+1][j+1]*c)%Mod;
		}
		subres=1LL*subres*a%Mod*C[n][i]%Mod*qpow(2,qpow(2,n-i,Mod-1))%Mod;
		res=upd(res+subres-Mod);
	}
	printf("%d\n",res);
	return 0;
}

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

using namespace std;

int main(){
    int n,d,x;
    cin>>n>>d>>x;
    vector<vector<int>>p(d,vector<int>(n));
    for(int i=0;i<d;++i){
        for(int j=0;j<n;++j)cin>>p[i][j];
    }
    for(int h=0;h<d-1;++h){
        vector<vector<int>>dp(n+1,vector<int>(x+1,0));
        vector<int>a(n);
        for(int i=0;i<n;++i){
            a[i]=p[h+1][i]-p[h][i];
        }
        for (int i = n - 1; i >= 0; i--) {
            for (int j = 0; j <= x; j++) {
                if (j < p[h][i])
                    dp[i][j] = dp[i + 1][j];
                else
                    dp[i][j] = max(dp[i + 1][j], dp[i][j - p[h][i]] + a[i]);
            }
        }
        x+=dp[0][x];
    }
    cout<<x<<endl;
}

Measured memory_bytes: 4068
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

string s;
ll k;

pair<ll, bool> cal(string t)
{
    int ret = 0;
    int sec = 0;
    for(int i=1; i<t.size(); i++)
    {
        if(t[i] == t[i-1])
        {
            t[i] = t[i-1] + 1;
            if(i+1<t.size() && t[i] == t[i+1]) t[i]++;
            ret++;
            if(i == t.size()-1) sec = 1;
        }
    }
    return mp(ret, sec);
}

pair<ll, bool> cal2(string t)
{
    int ret = 0;
    int sec = 0;

    t[0] = t[1] + 1;
    ret++;

    for(int i=1; i<t.size(); i++)
    {
        if(t[i] == t[i-1])
        {
            t[i] = t[i-1] + 1;
            if(i+1<t.size() && t[i] == t[i+1]) t[i]++;
            ret++;
            if(i == t.size()-1) sec = 1;
        }
    }
    return mp(ret, sec);
}

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> s >> k;
    if(s.size() == 1)
    {
        cout << k/2 << endl;
        return 0;
    }
    if(k == 1)
    {
        cout << cal(s).F << endl;
        return 0;
    }
    if(k == 2)
    {
        cout << cal(s+s).F << endl;
        return 0;
    }
    auto one = cal(s);
    auto two = cal2(s);

    //cout << one.F << " " << one.S << endl;
    //cout << two.F << " " << two.S << endl;

    if(one.S)
    {
        cout << k*one.F << endl;
        return 0;
    }
    if(s[0] != s[s.size()-1])
    {
        cout << k*one.F << endl;
        return 0;
    }
    if(two.S)
    {
        ll ans = (one.F + two.F) * (k/2);
        if(k%2 == 1) ans += one.F;
        cout << ans << endl;
        return 0;
    }
    cout << one.F + (k-1) * two.F << endl;
}


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

int main() {
  int N, n, fx = 0;
  cin >> N;
  n = N;
  
  while(n){
    fx += n % 10;
    n /= 10;
  }
  
  if(N % fx){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  
}


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

constexpr int MAX_N = 10;
constexpr int MAX_M = 10;

vector<vector<int>> switches(MAX_M+1);

int p[MAX_M+1];

int main() {
  int N, M; cin >> N >> M;
  for (int m{1}; m <= M; ++m) {
    int k; cin >> k;
    for (int j{}; j < k; ++j) {
      int s; cin >> s;
      switches[m].push_back(s);
    }
  }
  for (int m{1}; m <= M; ++m) {
    cin >> p[m];
  }

  int len{N};
  int ans{};

  for (int i{}; i < (1 << len); ++i) {
    bool judge{true};
    for (int m{1}; m <= M; ++m) {
      int on{};
      for (const int& s : switches[m]) {
        if (i & (1 << (s - 1))) {
          ++on;
        }
      }
      if (on % 2 != p[m]) {
        judge = false;
        break;
      }
    }
    if (judge) ++ans;
  }

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


Measured memory_bytes: 256
from collections import Counter

n = int(input())
d = [int(i) for i in input().split()]
c = Counter(d)

if d[0] != 0 or c[0] > 1:
    print(0)
    exit()

ans = 1
for i in range(1, len(c) + 1):
    ans *= c[i - 1] ** c[i]

print(ans % 998244353)


Measured memory_bytes: 19936
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

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

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

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

int main() {

  int x;
  cin >> x;
  int sum = 0;

  sum += x/500*1000;
  x %= 500;

  sum += x/5*5;

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

const ll MOD=1e9+7;
ll fpow(ll a,ll p){
	ll res=1LL;
	while(p){
		if(p&1LL) res=res*a%MOD;
		a=a*a%MOD;
		p>>=1LL;
	}
	return res;
}
ll n,k;
vector<ll> divisors,dp;

int main() {
	#ifdef kvutxdy
	freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/Codeforces/input.in", "r", stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin>>n>>k;
	for(ll i=1;i*i<=n;++i) if(n%i==0){
		divisors.push_back(i);
		if(i*i!=n) divisors.push_back(n/i);
	}
	sort(divisors.begin(),divisors.end());
	int m=divisors.size();
	ll res=0LL;
	dp.resize(m);
	for(int i=0;i<m;++i){
		dp[i]=fpow(k,(divisors[i]+1)/2);
		for(int j=0;j<i;++j) if(divisors[i]%divisors[j]==0){
			dp[i]-=dp[j];
			if(dp[i]<0) dp[i]+=MOD;
		}
		ll tmp=dp[i]*divisors[i]%MOD;
		if(divisors[i]%2==0) (tmp*=fpow(2LL,MOD-2LL))%=MOD;
		(res+=tmp)%=MOD; 
	}
	cout<<res;
}

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

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

int main()
{
    int n, r;
    cin >> n >> r;
    int ans = r;
    if (n < 10) {
        ans += 100 * (10 - n);
    }
    cout << ans << endl;
    return 0;
}


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

int		main(void)
{
	vector<int> a(3);
	for (int i = 0; i < 3; i++)
		cin >> a.at(i);
	sort(a.begin(), a.end());
	cout << (a.at(1) - a.at(0)) + (a.at(2) - a.at(1)) << endl;
}

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

int main() {
  string a,b,c;
  cin >> a >> b >>c ;
  if(a.back() == b.front() && b.back() == c.front()) cout <<"YES" << endl;
  else cout << "NO" << endl;
}

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

int main()
{
    int n, k;
    string abc;

    cin >> n;
    cin >> k;
    cin >> abc;

    if(abc[k-1] == 'A') {
        abc[k-1] = 'a';
    }else if(abc[k-1] == 'B') {
        abc[k-1] = 'b';
    }else {
        abc[k-1] = 'c';
    }

    cout << abc << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

template <class T>
ostream &operator<<(ostream &os, const set<T> &st) {
	for (const auto &e : st) os << e << " ";
	return os;
}

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

template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
	for (const auto &e : mp) os << e << " ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T = lint>
struct Edge {
	int to;
	T cost;
	int tank;
	Edge() {}
	Edge(int to, T cost, int tank = 0) : to(to), cost(cost), tank(tank) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M, L;
	cin >> N >> M >> L;

	vector<vector<Edge<int>>> edges(N);
	for (int i = 0; i < M; i++) {
		int u, v, len;
		cin >> u >> v >> len;
		u--, v--;
		edges[u].emplace_back(v, len);
		edges[v].emplace_back(u, len);
	}

	auto bfs = [&](int st) {
		vector<pair<int, int>> dp(N, { INF, 0 });
		dp[st] = { 0, -L };
		queue<pair<int, pair<int, int>>> que;
		que.emplace(st, dp[st]);
		while (!que.empty()) {
			auto now = que.front();
			que.pop();
			for (const auto &e : edges[now.first]) {
				if (e.cost > L) continue;

				auto tmp = now;
				if (e.cost > -now.second.second) {
					tmp.second.first++;
					tmp.second.second = -L + e.cost;
				}
				else tmp.second.second += e.cost;

				if (tmp.second < dp[e.to]) {
					dp[e.to] = tmp.second;
					que.emplace(e.to, tmp.second);
				}

			}
		}
		return dp;
	};

	vector<vector<pair<int, int>>> memo(N);
	for (int i = 0; i < N; i++) memo[i] = bfs(i);

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int s, t;
		cin >> s >> t;
		s--, t--;
		auto tmp = memo[s][t].first;
		if(tmp != INF) cout << tmp << "\n";
		else cout << -1 << "\n";
	}
	
	return 0;
}

Measured memory_bytes: 2944
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define ll long long
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll,ll>
#define vl vector<long long>
#define se set <long long int>
#define pi pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define all(v) v.begin(), v.end()
#define in(x) cin>>x
#define o(x) cout<<x
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.14159265359
using namespace std;


ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

//const string k = "enterstringtobechecked";



int main()
{
    SYNC
    //clock_t tStart = clock();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n; in(n);
    ll temp=1000;
    while(n>temp)
    {
        temp+=1000;
    }
    o(temp-n)<<endl;







    //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);   
}


Measured memory_bytes: 3668
#include<stdio.h>

void trace(int A[],int N){
  int i;
 
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}
main(){
  int n,i,j,k;
  int A[100];
 
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
 
  trace(A,n);
 for(i=1;i<n;i++){
    k=A[i];
    j=i-1;
    while(j>=0&&A[j]>k){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=k;
    trace(A,n);
  }
 
  return 0;
 
}

Measured memory_bytes: 604
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
typedef long long ll;
typedef double D;

ll n,a[20];
D dp[21][200001];
const D INF = 1e12;

int main(){
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i];

  for(int i=0;i<=n;i++){
    for(int j=0;j<=a[n-1]*2;j++)dp[i][j] = INF;
  }
  dp[0][1] = 0;

  for(int i=0;i<n;i++){
    for(int j=1;j<=a[n-1]*2;j++){
      for(int k=j;k<=a[n-1]*2;k+=j){
	dp[i+1][k] = min(dp[i+1][k],max(dp[i][j],abs((D)(k-a[i])/a[i])));
      }
    }
  }

  D ans = INF;
  for(int i=0;i<=a[n-1]*2;i++)ans = min(ans,dp[n][i]);
  cout << setprecision(10) << fixed << ans << endl;
}
	

Measured memory_bytes: 33948
import std.stdio, std.string, std.ascii;
 
void main() {
    string s = readln.chomp;
    writeln( (s.length >= 6 && s.count!(isDigit) >= 1 && s.count!(isUpper) >= 1 && s.count!(isLower) >= 1) ?  "VALID" : "INVALID" );
}

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

int main(){

    int k;
    string s;
    cin >> k >> s;

    int size;
    size = s.size();
    vector<char> c;

    if (size <= k){
        cout << s << endl;
    }
    else{
        for (int i=0; i<k; i++){
            c.push_back(s.at(i));
        }
        for (int i=k; i<k+3; i++){
            c.push_back('.');
        }
        for (int i=0; i<c.size(); i++){
            cout << c.at(i);
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define lint long long
using namespace std;



lint keisan(lint n){
  return n*(n-1)/2;
}

int main(){
  lint N;
  cin >> N;
  
  vector<lint> ball(N,0);
  vector<lint> cnt(N,0);
  vector<lint> out(N,0);
  
  for(lint i=0; i<N; i++){
    cin >> ball[i];
    ball[i]--;
    cnt[ball[i]]++;
  }

  lint total = 0;
  
  for(lint i=0; i<N; i++){
    total += keisan(cnt[i]);
  }
  
  for(lint i=0; i<N; i++){
    out[i] = total - keisan(cnt[ball[i]]) + keisan(cnt[ball[i]]-1);
  }
  
  
  for(lint i=0; i<N; i++){
    cout << out[i] << endl;
  }
  // cout << "total=" << total << endl; 
}
    
    
  
  
  
  
  
    


Measured memory_bytes: 7296
N = int(input())

d = {'AC':0,'WA':0,'TLE':0,'RE':0}

for i in range(N):
  wrk = input()
  d[wrk] = d[wrk]+1

print('AC x ',d['AC'])
print('WA x ',d['WA'])
print('TLE x ',d['TLE'])
print('RE x ',d['RE'])

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

int N, M;
vector<vector<int>> bar;
vector<int> counters;
vector<int> cur;

void forward(int index) {
  while (counters[ bar[index][cur[index]] ] == -1) 
    ++ cur[index];
}

int main()
{
  cin >> N >> M;
  bar = vector<vector<int>> (N, vector<int>(M, 0));
  for (int i = 0; i < N; ++ i) {
    for (int j = 0; j < M; ++ j) {
      cin >> bar[i][j];
      -- bar[i][j];
    }
  }

  counters = vector<int> (M, 0);
  cur = vector<int> (N, 0);
  
  int ans = 100000;
  for (int round = 0; round < M; ++ round) {
    for (int i = 0; i < N; ++ i) {
      counters[ bar[i][cur[i]] ] ++;
    }
    
    int maxv = -1, maxi = -1;
    for (int i = 0; i < M; ++ i) {
      if (counters[i] != -1 && counters[i] > maxv) {
        maxi = i;
        maxv = counters[i];   
      }
    }
    ans = min(ans, maxv);
    
    counters[maxi] = -1;
    for (int i = 0; i < M; ++ i) counters[i] == -1 ? NULL : (counters[i] = 0);
    
    for (int i = 0; i < N; ++ i) forward(i);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 768
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (1<<18)
#define INIT 9223372036854775807
#define INIT2 2147483647
long long a[(2 * N)];
long long laz[(2 * N)];
int l[(2 * N)];
int r[(2 * N)];

long long f1(long long x, long long y) {
	if (x != INIT)return x;
	return y;
}
long long f2(long long x, long long y) {
	if (x != INIT)return x;
	return y;
}
long long f3(long long x, long long y) {
	return min(x, y);
}


void init(void) {
	f(i, (2 * N)) {
		a[i] = INIT2;
		laz[i] = INIT;
	}
	l[1] = 0;
	r[1] = N;
	for (int i = 1; i < N; i++) {
		l[(2 * i)] = l[i];
		r[(2 * i)] = (l[i] + r[i]) / 2;
		l[(2 * i) + 1] = (l[i] + r[i]) / 2;
		r[(2 * i) + 1] = r[i];
	}
	return;
}



long long change(int ll, int rr, int k, long long x) {
	long long vl, vr;
	if ((rr <= l[k]) || (r[k] <= ll))return f2(laz[k], a[k]);
	if (laz[k] != INIT) {
		a[k] = f2(laz[k], a[k]);
		if (k < N) {
			laz[(2 * k)] = f1(laz[k], laz[(2 * k)]);
			laz[(2 * k) + 1] = f1(laz[k], laz[(2 * k) + 1]);
		}
		laz[k] = INIT;
	}
	if ((ll <= l[k]) && (r[k] <= rr)) {
		laz[k] = f1(x, laz[k]);
		return f2(laz[k], a[k]);
	}
	else {
		int mm = (l[k] + r[k]) / 2;
		if ((l[k] < rr) && (ll < mm)) {
			vl = change(ll, rr, 2 * k, x);
		}
		else vl = f2(laz[(2 * k)], a[(2 * k)]);

		if ((mm < rr) && (ll < r[k])) {
			vr = change(ll, rr, (2 * k) + 1, x);
		}
		else vr = f2(laz[(2 * k) + 1], a[(2 * k + 1)]);

		a[k] = f3(vl, vr);
		return f2(laz[k], a[k]);
	}
}


long long search(int ll, int rr, int k) {
	if (laz[k] != INIT) {
		a[k] = f2(laz[k], a[k]);
		if (k < N) {
			laz[(2 * k)] = f1(laz[k], laz[(2 * k)]);
			laz[(2 * k) + 1] = f1(laz[k], laz[(2 * k) + 1]);
		}
		laz[k] = INIT;
	}
	long long vl, vr;
	if (rr <= l[k] || r[k] <= ll)return INIT2;
	else if (ll <= l[k] && r[k] <= rr) return f2(laz[k], a[k]);
	else {
		vl = search(ll, rr, 2 * k);
		vr = search(ll, rr, (2 * k) + 1);
		a[k] = f3(f2(laz[(2 * k)], a[(2 * k)]), f2(laz[(2 * k) + 1], a[(2 * k) + 1]));
		return f3(vl, vr);
	}
}


int main(void) {
	int q;
	int c, x, y;
	long long k;
	init();
	scanf("%d %d", &c, &q);
	f(qq, q) {
		scanf("%d", &c);
		if (c == 0) {
			scanf("%d %d %lld", &x, &y, &k);
			change(x, y + 1, 1, k);
		}
		else if (c == 1) {
			scanf("%d %d", &x, &y);
			k = search(x, y + 1, 1);
			printf("%lld\n", k);
		}
	}
	return 0;
}


Measured memory_bytes: 15000
n=int(input())
A=list(map(int, input().split()))
col=[0]*8
def transcol(x):
  if 1<=x and x<=399:
    return 0
  elif 400<=x and x<=799:
    return 1
  elif 800<=x and x<=1199:
    return 2
  elif 1200<=x and x<=1599:
    return 3
  elif 1600<=x and x<=1999:
    return 4
  elif 2000<=x and x<=2399:
    return 5
  elif 2400<=x and x<=2799:
    return 6
  elif 2800<=x and x<=3199:
    return 7
free=0
for a in A:
  if a>=3200:
    free+=1
  else:
    tmp=transcol(a)
    if col[tmp]==0:
      col[tmp]=1

minans=sum(col)
maxans=minans+free
if minans==0:
  minans=1
print(minans, maxans)

Measured memory_bytes: 3064
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    character(10):: s
    integer(int32):: y,m,d


    read'(a)', s
    read(s(1:4),*) y
    read(s(6:7),*) m
    read(s(9:10),*)d

    if (y < 2019) then
        print'(a)', 'Heisei'
        stop
    else if (y > 2019) then
        print'(a)', 'TBD'
        stop
    end if

    IF ( m < 4) then
        print'(a)', 'Heisei'
        stop
    else if (m > 4) then
        print'(a)', 'TBD'
        stop
    end if

    if (d <= 30) then
        print*, 'Heisei'
    else
        print*, 'TBD'
    end if
end program main

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

template <typename T>
T gcd(T a, T b) {
    if (a > b) {
        T buf = a;
        a = b;
        b = buf;
    }
    return a == 0 ? b : gcd(a, b%a);
}

int main() {
    int n, k;
    cin >> n >> k;
    bool bigger = false;
    int g = 0;
    for (int i=0, ai; i<n; i++) {
        cin >> ai;
        if (ai >= k) bigger = true;
        g = gcd(g, ai);
    }
    cout << (bigger && (k % g == 0) ? "POSSIBLE" : "IMPOSSIBLE") << '\n';
    return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, h, w, k);
  vector<string> c(h);
  rep(i, h) cin >> c[i];
  int ans = 0;
  rep(hs, 1 << h) rep(ws, 1 << w) {
    int black = 0;
    rep(i, h) rep(j, w) {
      bool red = ((hs >> i) & 1) || ((ws >> j) & 1);
      if (c[i][j] == '#' && !red) ++black;
    }
    if (black == k) ++ans;
  }
  out(ans);
}


Measured memory_bytes: 3624
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		B(sc);
		sc.close();
	}
	
	public static void A(Scanner sc) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println((a+b+1)/2);
	}
	
	public static void B(Scanner sc) {
		//一方の文字を辞書順にソート　他方を逆辞書順にソート
		String s = sc.next();
		String t = sc.next();
		Character[] sch = new Character[s.length()];
		Character[] tch = new Character[t.length()];
		for(int i=0;i<s.length();i++) {
			sch[i] = s.charAt(i);
		}
		for(int i=0;i<t.length();i++) {
			tch[i] = t.charAt(i);
		}
		Arrays.sort(sch);
		Arrays.sort(tch,Collections.reverseOrder());
		s = makeString(sch);
		t = makeString(tch);
		if(s.compareTo(t)<0) System.out.println("Yes");
		else System.out.println("No");
	}
	
	public static String makeString(Character[] c) {
		StringBuilder s = new StringBuilder();
		for(int i=0;i<c.length;i++) {
			s.append(c[i]);
		}
		return new String(s);
	}
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

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


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

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

    int len = (int)S.length();
    int cnt = 0, p = 0;
    bool ans = true;

    if( S[0] == 'A' ){
        for( int i = 2; i < len-1; ++i )
            if( S[i] == 'C' ){
                ++cnt;
                p = i;
            }

        if( cnt == 1 ){
            for( int i = 1; i < len; ++i )
                if( i != p && 'A' <= S[i] && S[i] <= 'Z' )
                    ans = false;
        } else ans = false;
    } else ans = false;

    if( ans ) cout << "AC" << endl;
    else cout << "WA" << endl;

    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn solve_(aa: Vec<isize>) -> Vec<isize> {
    let nnn = aa.len();
    let mut heap = std::collections::BinaryHeap::new();
    let mut acc = 0;
    let mut ans = Vec::new();
    for &a in aa.iter().take(nnn / 3) {
        heap.push(a);
        acc += a;
    }

    ans.push(acc);

    for &a in aa.iter().skip(nnn / 3).take(nnn / 3) {
        heap.push(a);
        let b = heap.pop().unwrap();
        acc += a - b;
        ans.push(acc);
    }

    ans
}

fn solve(aa: Vec<isize>) -> isize {
    let front = solve_(aa.iter().map(|a| -a).collect());
    let front: Vec<isize> = front.iter().map(|a| -a).collect();
    let back: Vec<isize> = solve_(aa.iter().cloned().rev().collect());
    let back = back.iter().rev().collect::<Vec<_>>();

    front
        .iter()
        .zip(back.iter())
        .map(|(&a, &b)| a - b)
        .max()
        .unwrap()
}

fn main() {
    read_line!();
    let aa = parse_vec!(isize);
    println!("{}", solve(aa));
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![3, 1, 4, 1, 5, 9]), 1);
    assert_eq!(solve(vec![1, 2, 3]), -1);
    assert_eq!(solve(vec![8, 2, 2, 7, 4, 6, 5, 3, 8,]), 5);
}


Measured memory_bytes: 18524
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <typeinfo>
#include <stdlib.h>


using namespace std;


int gcd(int a, int b){
  int l, s, tmp;
  if (a >= b){
    l = a;
    s = b;
  }else{
    l = b;
    s = a;
  }

  // あまりが0になるまで割り続け，0になった時の割る数が最大公約数
  while(1){
    tmp = s;
    s = l%s;
    if(s == 0){
      break;
    }
    l = tmp;
  }
  return tmp;
}

int main(int argc, char* argv[]){
  int x,y,ret;
  cin >> x >> y;

  ret = gcd(x,y);
  
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 3088
n, m = map(int, input().split())
listAC = [0] * n
listWAAC = [0] * n
listWA = [0] * n
for i in range(m):
    p, s = map(str, input().split())
    p = int(p) - 1
    if listAC[p] == 1:
        continue
    if s == 'AC':
        listAC[p] += 1
        listWAAC[p] += listWA[p]
        continue
    listWA[p] += 1

print(sum(listAC), sum(listWAAC))


Measured memory_bytes: 11100
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
int main()
{
    fastIO;
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll dp[n+1],x;
    dp[0]=0;
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        dp[i]=inf;
    }
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            x=i-j;
            if(x>=1)
            {
                dp[i]=min(dp[i],dp[i-j]+abs(a[i-1]-a[i-j-1]));
            }
        }
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
int main(){
    int n,a[105]={0},ans=0,sum=0,m,minn=11111111;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
       cin>>a[i];
       minn=min(minn,a[i]);
	   sum+=a[i];
	}
    ans=(m-sum)/minn+n;
	cout<<ans; 
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    return 0;
}


Measured memory_bytes: 256
# 解説AC
import math

N = int(input())
MOD = int(10 ** 9 + 7)

ans = (10 ** N) % MOD - (9 ** N) % MOD -(9 ** N) % MOD + (8 ** N) % MOD
while ans < 0: ans += MOD

print(ans % MOD)

Measured memory_bytes: 10640
#include <cmath>
#include <stdio.h>
using ll = long long;
using llu = long long unsigned;

int main(void) {
    int a, b, m;
    float h;
    scanf("%d %d %f %d", &a, &b, &h, &m);

    h *= 30;
    h += m*0.5;
    m *= 6;

    float angle = fabs(h-m);
    //printf("angle:%f\n", angle);
    long double c = sqrt(a*a + b*b - 2*a*b*cos(angle*M_PI/180));
    printf("%.20Lf\n", c);

    return 0;
}


Measured memory_bytes: 2596
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			
			if(c==0){
				if(a==1 && b==1){
					System.out.println("Open");
				}else{
					System.out.println("Close");
				}
			}else{
				System.out.println("Open");
			}
		}
	
	}	
}

Measured memory_bytes: 17156
#include<stdio.h>
#include<stdlib.h>
#define N 1000

typedef struct card{
	int data;
	struct card *next;
}card;


typedef struct queue{
	card *front;
	card *rear;
}queue;

card* makecard(int x){
	card *new=malloc(sizeof(card));
	new->data=x;
	new->next=NULL;
	return new;
}


int main(){
	int n,q,i,com,x,y;
	queue Q[N];
	card *new;
	
	scanf("%d %d",&n,&q);
	
	for(i=0;i<n;i++){
		Q[i].front=NULL;
		Q[i].rear=NULL;
	}
	
	for(i=0;i<q;i++){
		scanf("%d",&com);
		
		if(com==0){/*enqueue*/
			scanf("%d %d",&x,&y);
			new=makecard(y);
			
			if(Q[x].front==NULL){
				Q[x].front=new;
				Q[x].rear=new;
			}
			else {
				Q[x].rear->next=new;
				Q[x].rear=new;
			}
		}
		
		if(com==1){/*front*/
			scanf("%d",&x);
			if(Q[x].front!=NULL)printf("%d\n",Q[x].front->data);
		}
		
		if(com==2){/*dequeue*/
			scanf("%d",&x);
			if(Q[x].front!=NULL){
				if(Q[x].front==Q[x].rear){
					Q[x].front=NULL;
					Q[x].rear=NULL;
				}
				else Q[x].front=Q[x].front->next;
			}
		}
	}
	
	return 0;
	
}


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

int main (void){
  long long int x = 0,y = 0,z = 0,a = 0,b = 0;
  cin >> x;

  for(int i = 1;i < 200;i++){
    a = pow(i,5);
    for(int k = 0;k <= i;k++){
      b = pow(k,5);
      if(a - b == x){
        a = i;
        b = k;
        cout << a << " " << b << endl;
        return 0;
      }
      if(a + b == x){
        a = i;
        b = -k;
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;

}

Measured memory_bytes: 4044
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

A, B, C = mi()

ans = 0

#もし解毒剤入りが毒入り-1あったら全部食べられる
if A+B >= C-1:
  print(B+C)
  exit()

#足りなかったら
#Bの数だけ、BとCを食べ続けて解毒状態を保てる → B*2
#残ったCよりBのが多いので、毒入りクッキーをBの数だけ食べて解毒し、最後に1枚食べてお腹を壊したまま終わればいい
print((B*2) + A + 1)




Measured memory_bytes: 38512
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val s = sc.nextLine
  val nums = Array.fill(4)(0)
  nums(0) = s.substring(0, 1).toInt
  nums(1) = s.substring(1, 2).toInt
  nums(2) = s.substring(2, 3).toInt
  nums(3) = s.substring(3, 4).toInt

  // パターンをビット列で列挙するはず
  var ans = ""
  for (i <- 0 to 7) {
    var sum = nums(0)
    var str = nums(0).toString
    for (j <- 0 to 2) {
      if ((i & (1 << j)) > 0) {
        sum += nums(j + 1)
        str = str + "+" + nums(j + 1).toString
      } else {
        sum -= nums(j + 1)
        str = str + "-" + nums(j + 1).toString
      }
    }
    if (sum == 7) {
      ans = str + "=7"
    }
  }
  println(ans)
}


Measured memory_bytes: 25640
#include<cstdio>
int main(){
	int n,a;
	int count1=0,count2=0,count4=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a);
		if(a%2==0&&a%4!=0) count2++;
		else if(a%4==0) count4++;
		else count1++;
	}
	if(count2>0&&count4>=count1) printf("Yes");
	else if(count2==0&&count4>=count1-1) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
typedef long long ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;
 
using namespace std;

int main() {

	int n;
	cin >> n;

	int p[n];
	rep(i, n)
		cin >> p[i];

	int diff = p[1] - p[0];
	int minN = p[0];

	for (int i = 2; i < n; i++) {

		minN = min(minN, p[i - 1]);
		diff = max(diff, p[i] - minN);
	}

	cout << diff << endl;
}



Measured memory_bytes: 3868
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

pub fn upper_bound<T: Ord>(xs: &[T], y: &T) -> usize {
    let mut l = 0;
    let mut r = xs.len() + 1;

    while r - l > 1 {
        let m = l + (r - l) / 2;
        if &xs[m - 1] <= y {
            l = m;
        } else {
            r = m;
        }
    }

    l
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();
    let M = scan.word::<usize>();
    let K = scan.word::<usize>();
    let A = scan.list::<usize>(N);
    let B = scan.list::<usize>(M);

    let mut bb = B.clone();
    bb.insert(0, 0);
    for i in 0..M {
        bb[i + 1] += bb[i];
    }

    let mut at = 0;
    let mut max_n = 0;
    for ai in 0..=N {
        if at > K {
            break;
        }

        let bi = upper_bound(&bb, &K.saturating_sub(at));
        max_n = max_n.max(ai + bi.saturating_sub(1));

        if ai < N {
            at += A[ai];
        }
    }

    println!("{}", max_n);
}


Measured memory_bytes: 13308
#include<cstdio>
typedef double db;
int main()
{
	int n,m,d;scanf("%d%d%d",&n,&m,&d);
	db p;
	if(!d) p=1.0/n;else p=2.0*(n-d)/n/n;
	printf("%.10lf\n",1.0*p*(m-1));
	return 0;
}

Measured memory_bytes: 128
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-')
		jp = getchar();
	if (jp == '-')
		fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9')
		out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
void print(int x)
{
	if (x >= 10)
		print(x / 10);
	putchar('0' + x % 10);
}
void write(int x, char c)
{
	if (x < 0)
		putchar('-'), x = -x;
	print(x);
	putchar(c);
}
const int P = 998244353;
int add(int a, int b)
{
	return a + b >= P ? a + b - P : a + b;
}
void inc(int &a, int b)
{
	a = add(a, b);
}
int mul(int a, int b)
{
	return 1LL * a * b % P;
}
const int N = 300 + 10;
int n, m = 0, K, a[N], dp[N][N][N];
char buf[N];
int main()
{
	scanf("%s", buf + 1), n = strlen(buf + 1), K = min(n, read());
	int cnt = 0;
	for (int i = 1; i <= n; ++i)
		if (buf[i] == '0')
			a[++m] = cnt, cnt = 0;
		else
			++cnt;
	if (cnt)
		a[++m] = cnt;
	dp[m + 1][0][0] = 1;
	for (int i = m; i >= 1; --i)
	{
		for (int j = 0; j <= n; ++j)
			for (int k = n; k >= 0; --k)
				dp[i][j][k] = add(dp[i][j][k + 1], dp[i + 1][j][k]);
		for (int p = 1; p <= a[i]; ++p)
			for (int j = 0; j + p <= n; ++j)
				for (int k = 0; k + p <= n; ++k)
					inc(dp[i][j + p][k + p], dp[i + 1][j][k]);
	}
	int ans = 0;
	for (int j = 0; j <= K; ++j)
		inc(ans, dp[1][j][0]);
	write(ans, '\n');
	return 0;
}


Measured memory_bytes: 113356
import java.util.Scanner;


public class Main {
	static long A,B;
	static int K;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
			 A = sc.nextLong();
			 B = sc.nextLong();
			 K = sc.nextInt();
		sc.close();

		for(int i = 0 ; i < K/2 ; i++){
			if(A%2 != 0){
				A -= 1;
				B += A/2;
				A = A/2;
			}
			else{
				B += A/2;
				A = A/2;
			}

			//System.out.println(A + " " + B);
			if(B%2 != 0){
				B -= 1;
				A += B/2;
				B = B/2;
			}
			else{
				A += B/2;
				B = B/2;
			}
			//System.out.println(A + " " + B);
		}

		if(K%2 != 0){
			if(A%2 != 0){
				A -= 1;
				B += A/2;
				A = A/2;
			}
			else{
				B += A/2;
				A = A/2;
			}
			//System.out.println(A + " " + B);
		}
		System.out.println(A + " " + B);
	}
}

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

int main() {
    string s;
    cin >> s;
    int ans=0;
    for(int i=0;i<3;i++){
        if (s[i]=='1'){
            ans+=1;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

var ans = 0

func main() {
	var n int
	fmt.Scan(&n)
	f(0, n, 0, false, false, false)
	fmt.Println(ans)
}

func f(v, n, c int, a1, a2, a3 bool) {
	if v > n {
		return
	}
	if a1 && a2 && a3 {
		ans++
	}
	if c == 9 {
		return
	}
	f(v*10+3, n, c+1, true, a2, a3)
	f(v*10+5, n, c+1, a1, true, a3)
	f(v*10+7, n, c+1, a1, a2, true)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long idx=0;
    long a, b;
    cin >> a >> b;
    if(a >= b)
    {
        for(size_t i=0;i<a; i++)
        {
            cout << b;
        }
        cout << endl;
    }
    else
    {
        for(size_t i=0;i<b; i++)
        {
            cout << a;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
while True:
    A = []
    n = int(input())
    if n == 0:
        break
    for i in range(n):
        A.append(list(map(int,input().split())))
    result = A[:]
    result_T = list(map(list,zip(*A)))
    for line in result:
        line.append(sum(line))
        
    for line in result_T:
        line.append(sum(line))

    result_T = list(map(list,zip(*result_T)))
    result.append(result_T[-1]+[sum(result_T[-1])])
    
    for i in range(len(result)):
        for j in range(len(result[i])):
            print(str(result[i][j]).rjust(5),end="")
        print()
    


Measured memory_bytes: 5616
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define inf 100000000
#define mod 1000000007
#define ld long double
#define point complex<double>
#define pi  acos(-1)
#define IO                    \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
using namespace std;

string s;
	int convert(string s)
	{
		int res=0;
		for(int i=s.size()-1;i>=0;i--)
		{
			res+=pow(26,(s.size()-1)-i)*(s[i]-'a');
		}
		return res;
	}
ll dp[200001][3] ;
	ll solve(int cur ,int last)
	{
		
		if(cur>=s.size())
		{
			return 0;
		}
		if(dp[cur][last]!=-1)return dp[cur][last];
		string llast="";
		if(last==2)
		{
			llast=s[cur-2]+s[cur-1];
		}
		else if(last==1)
		{
			llast=s[cur-1];
		}
		string s1="",s2="";
		
			s1=s[cur];
	    if(cur+1<s.size())
		{
			s2=s[cur]+s[cur+1];
		}
		ll res=0;
		if(llast!=s1)
		res=solve(cur+1,1)+1;
		if(llast!=s2&&cur+2<s.size())
		res=max(res,solve(cur+2,2)+1);
		
		return dp[cur][last]=res;
	}

	int main(){
	cin>>s;
	memset(dp,-1,sizeof(dp));
	cout<<max(solve(1,1),solve(2,2))+1;
    return 0;
}


Measured memory_bytes: 59396
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 
const ll INF=1000000000000000000;

signed main(){
	ll n; cin>>n;
	vl v(n);
	rep(i,0,n){
		ll a; cin>>a;
		if(a==0){
			cout<<0<<endl;
			return 0;
		}
		v[i]=a;
	}
	ll k=1;
	rep(i,0,n){
		if(INF/v[i]<k){
			cout<<-1<<endl;
			return 0;
		}
		k*=v[i];
	}
	cout<<k<<endl;
	
	return 0;
}

Measured memory_bytes: 4032