akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define X first
#define Y second
#define F 1145141919
using namespace std;
vector<pair<int,int> > v[160];
int dp[80][160][12],n,m,k;
int Jump(int a,int b,int c,int d){
	if(v[a][b].X==-1||v[c][d].X==-1)return 0;
	int ret=abs(v[a][b].X-v[c][d].X);
	ret*=v[a][b].Y+v[c][d].Y;
	return ret;
}
int main(){
	pair<int,int> p;
	p.X=-1,p.Y=-1;
	v[0].push_back(p);
	while(cin>>n>>m&&n){
	for(int i=1;i<=n;i++){
		cin>>k;v[i].clear();
		while(k--){
			cin>>p.X>>p.Y;
			v[i].push_back(p);
		}
	}
	v[n+1].clear();p.X=-1,p.Y=-1;v[n+1].push_back(p);
	for(int i=0;i<80;i++)for(int j=0;j<160;j++)for(int k=0;k<12;k++)dp[i][j][k]=F;
	for(int i=0;i<=m;i++)dp[i][0][0]=0;
	for(int i=0;i<=m;i++){
		for(int f=0;f<=n;f++){
			for(int g=0;g<v[f].size();g++){
				for(int k=0;k<v[f+1].size();k++)dp[i][f+1][k]=min(dp[i][f+1][k],dp[i][f][g]+Jump(f,g,f+1,k));
				if(f!=n&&i!=m)for(int k=0;k<v[f+2].size();k++)dp[i+1][f+2][k]=min(dp[i+1][f+2][k],dp[i][f][g]+Jump(f,g,f+2,k));
			}
		}
	}
	int ans=F;
	for(int i=0;i<=m;i++)ans=min(ans,dp[i][n+1][0]);
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define RB rbegin()
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define MD 1000000007
#define PPF pop_front()
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;u.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C
V<LL>v;
V<LL>w,ab,bc;
set<LL>uo;
map<LL,LL>u,uc;
map<LL,LL>ww,cc;
LL ar[120005];
LL br[500005];
LL cr[500][500];
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c,str;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
    while(tt--)
    {
//        UOSMOY;
        cin>>n;
        k=0;
        while(n)
        {
//            n-=26;
            l=n%26;
            if(l==0)
            {
                l=26;
            }
            ch=char(l+'a'-1);
            a+=ch;
n--;
            n/=26;
            k++;
        }
        reverse(a.B,a.E);
        cout<<a<<endl;
    }
    return 0;
    //IN
    //AL
}


Measured memory_bytes: 3592
import sys
from collections import deque

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
  n, m = nm()
  ver = [tuple(nm()) for _ in range(n)]
  hor = [tuple(nm()) for _ in range(m)]
  xli = [0]*(2*n+m+1)
  yli = [0]*(n+2*m+1)
  for i, (a, b, c) in enumerate(ver):
    xli[i*2] = a
    xli[i*2+1] = b
    yli[i] = c
  for i, (a, b, c) in enumerate(hor):
    xli[2*n + i] = a
    yli[n + 2*i] = b
    yli[n + 2*i + 1] = c
  xli = sorted(set(xli))
  yli = sorted(set(yli))
  xdic = {x:i for i, x in enumerate(xli)}
  ydic = {x:i for i, x in enumerate(yli)}
  H = len(yli)*2 + 1
  W = len(xli)*2 + 1
  G = [[0]*W for _ in range(H)]
  for a, b, c in ver:
    a = xdic[a]; b = xdic[b]
    c = ydic[c]
    if a > b:
      a, b = b, a
    for i in range(2*a+1, 2*b+2):
      G[2*c+1][i] = 1
  for a, b, c in hor:
    a = xdic[a]
    b = ydic[b]; c = ydic[c]
    if b > c:
      b, c = c, b
    for i in range(2*b+1, 2*c+2):
      G[i][2*a+1] = 1
  # print(xli)
  # print(yli)
  # prn(G)
  q = deque()
  sx = xdic[0]*2+1; sy = ydic[0]*2+1
  G[sy-1][sx-1] = 2
  q.append((sy-1, sx-1))
  ans = 0
  while q:
    y, x = q.popleft()
    for ny, nx in ((y+2, x), (y-2, x), (y, x+2), (y, x-2)):
      if 0 <= ny < H and 0 <= nx < W and G[ny][nx] == 0 and G[(ny+y)//2][(nx+x)//2] != 1:
        G[ny][nx] = 2
        q.append((ny, nx))

  for ny in range(H):
    for nx in range(W):
      if G[ny][nx] > 1:
        if ny == 0 or ny == H-1 or nx == 0 or nx == W-1:
          print('INF')
          return
        if ny % 2 == nx % 2 == 0:
          ans += (yli[ny//2] - yli[ny//2-1]) * (xli[nx//2] - xli[nx//2-1])
  print(ans)
  return

solve()


Measured memory_bytes: 431652
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int> a(M);
  vector<int> b(M);
  vector<int> c(N);
  for(int i=0;i<M;i++)
    cin>>a.at(i)>>b.at(i);
  for(int i=0;i<M;i++){
    c.at(a.at(i)-1)++;
    c.at(b.at(i)-1)++;
  }
  for(int i=0;i<N;i++)
    cout<<c.at(i)<<endl;
}

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

int main(int argc, char const *argv[])
{
    int r;
    int g;
    int b;
    cin>>r>>g>>b;
    int s=r*100+g*10+b;
    
    if (s%4==0) {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define m 1000000007
using namespace std;
int main()
{
    /*string s;
    cin>>s;
    int n=s.size();
    if(s[n-1]=='s')
        s.append("es");
    else
        s.append("s");
    cout<<s<<endl;*/
        int n;bool c=false;
        cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];

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

        if(a[i]==b[i] && a[i+1]==b[i+1] && a[i+2]==b[i+2])
            c=true;
    }
    if(c)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;

}


Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int top,s[1000];
int pop(){
	top--;
	return s[top+1];
}
int push(int a){
	s[++top]=a;
}
int main(){
	int b,a;
	top=0;
	char c[3];
	while(cin>>c){
		if(c[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}
		else if(c[0]=='-'){
			a=pop();
			b=pop();
			push(b-a);
		}
		else if(c[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}
		else{
			push(atoi(c));
		}
	}
	cout<<pop()<<endl;
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
 
using namespace std;
 
const int maxn = 2e5 + 10;
int dat[maxn], N;
 
int main() {
  cin >> N;
  for(int i = 0; i < N; ++i) cin >> dat[i];
  long long res = 0;
  for(int i = 1; i < N; ++i) {
    if(dat[i] < dat[i - 1]) res += dat[i - 1] - dat[i], dat[i] = dat[i - 1];
  }
  printf("%lld\n", res);
  return 0;
}

Measured memory_bytes: 4548
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    cout << (n-2) * 180 << endl;
    return 0; 
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
   for (int i = 0; i < 3; i++) {
     char a;
     char b;
     a = S.at(i);
     b = S.at(i+1);{
       if( a == b){
         cout << "Bad" << endl;
         break;}
       else if (i == 2)
              cout <<  "Good" <<endl;
     }
   }
}


Measured memory_bytes: 3624
import sys
#import numpy as np
import math
from fractions import Fraction
import itertools

#input=sys.stdin.readline
s=input()
n=len(s)
ans1=ans2=-1
for i in range(n-2):
    if s[i]==s[i+2]:
        ans1=i
        ans2=i+2
        break
else:
    for i in range(n-1):
        if s[i]==s[i+1]:
            ans1=i
            ans2=i+1
            break
    else:
        print(-1,-1)
        exit()

print(ans1+1,ans2+1)

Measured memory_bytes: 5340
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main(){
  string str;
  int alp[26]={};
  while(getline(cin,str)){
    for(int i=0,l=str.size();i<l;i++){
      if(str[i]>='a'&&str[i]<='z') alp[str[i]-'a']++;
      else  if(str[i]>='A'&&str[i]<='Z') alp[str[i]-'A']++;
    }
  }
  for(int i=0;i<26;i++){
    printf("%c : %d\n",i+'a',alp[i]);
  }
}


Measured memory_bytes: 3292
N = int(input().strip())
P = list(map(int, input().strip().split()))

counter = 0
for i in range(1, N - 1):
  a = P[i - 1]
  b = P[i]
  c = P[i + 1]
  #print(a, b, c)

  if a < b < c or c < b < a:
    counter += 1

print(counter)

Measured memory_bytes: 3060
#include <stdio.h>
int main() {
  int i;
  double N, count;
  count = 0;
  scanf("%lf", &N);
  for (i = 1; i < N + 1; ++i) {
    if (i % 2 != 0) {
      ++count;
    }
  }
  double ans = count / N;
  printf("%f", ans);
  return 0;
}

Measured memory_bytes: 128
def main():
    n, *a = map(int, open(0).read().split())
    b = [i for i in a if i <= 0]
    *ab, = map(abs, a)
    c = sum(ab)
    if len(b) % 2 == 0:
        print(c)
    else:
        print(c - 2 * min(ab))


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {

	string s;
	cin >> s;

	if (
		(s[0] == s[1] && s[2] == s[3] && s[0]!=s[2])
		|| (s[0] == s[2] && s[1] == s[3] && s[0]!=s[1])
		|| (s[0] == s[3] && s[1] == s[2] && s[0]!=s[1])
		) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
info=array(n,1)
n.times do|i|
  a=gets.to_i
  info[i]=array(a,1) unless a.zero?
  a.times do|j|
    info[i][j]=get_i
    info[i][j][0]-=1
  end
end
ans=0
(2**n).times do|i|
  hu=array(n,1,-1)
  cnt=0
  flag=true
  n.times do|j|
    unless (i&(2**j)).zero?
      if hu[j]==-1
        hu[j]=1
      elsif hu[j]==0
        flag=false
        break
      end
      cnt+=1
      next if info[j]==nil
      info[j].each do|arr|
        if hu[arr[0]]==-1
          hu[arr[0]]=arr[1]
        elsif hu[arr[0]]!=arr[1]
          flag=false
          break
        end
      end
    else
      if hu[j]==-1
        hu[j]=0
      elsif hu[j]==1
        flag=false
        break
      end
    end
    unless flag
      break
    end
  end
  if flag
    ans=(ans>cnt) ? ans : cnt
  end
end
puts ans

Measured memory_bytes: 2300
/*╔═══╗──╔╗╔╗───────────────────╔╗────────╔═══╦═══╗
  ║║─║╠╗╠╗╔╣╚═╦══╦═╗╔╦╗╔═╗╔══╦══╣╚═╦╦══╦══╣║─║║║─╚╝
  ║╔═╗║╚╝║╚╣║║║╚╝║║─╔╦╗║║║║╚╝║╚╝║╚╝║║║═╬══║╔═╗║╚╩═║
  ╚╝─╚╩══╩═╩╝╚╩══╩╝─╚╩╝╚╝╚╩══╩══╩══╩╩══╩══╩╝─╚╩═══╝*/

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

#define f(i,k,n) for(i=k;i<n;i++)
#define fd(i,k,n) for(i=k;i>n;i--)
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(c) c.begin(),c.end()
#define sz(c) (int)c.size()
#define lb lower_bound
#define ub upper_bound
#define gi greater<int>
#define rev reverse
#define ff first
#define ss second
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define imp cout << "IMPOSSIBLE" << endl;
#define nl cout << endl
#define hello cout << "hello" << endl;
#define sp(x) fixed << setprecision(x)
#define re return

void dbg_out(){cerr << endl;}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

const double pi = 3.14159265359;
const ll mod = 1000000007;
const ll modc = 998244353;

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

ll mod_inv(ll n, ll p){
    return power(n,p-2, p);
}

bool inline isPrime(ll n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
template<typename... T>
void W(T&&... args)
{
	((cout << sp(9) <<  args << " "), ...);
	nl;
}
template<typename... T>
void R(T&&... args)
{
	((cin >> args), ...);
}
ll ston(string s) 
{
	ll a = 0;
	reverse(s.begin(),s.end());
	ll pow = 1;
	for(int i=0;i<s.size();i++)
	{
		a += pow*(s[i]-'0');
		pow*=10;
	}
	return a;
}
template <class T>
string to_binary(T n) 
{
	string binaryNum;
	int i = 0;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
		i++;
	}
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
template<class T>
bool perfectSq(T n)
{
	if(sqrt(n) == floor(sqrt(n)))
		return true;
	else
		false;
}
template<class T>
void wv(T &v)
{
	for(auto x : v)
		cout << x << " " ;
	nl;
}
template<class T>
void rv(T &v)
{
	for(int i=0;i<sz(v);i++)
		cin >> v[i];
}
void solve()
{
	int i,j;ll sum = 0,prod = 1;ll maxl = LONG_MIN,minl = LONG_MAX;int maxi = INT_MIN,mini = INT_MAX;
	int x,n;
	R(x,n);
	vi p(n);
	rv(p);
	map<int,int>hash;
	for(auto x : p)
		hash[x] = 1;
	int diff = 1000;
	int snum = 1000;
	for(i=0;i<=101;i++)
	{
		if(hash[i] == 0)
		{
			if(abs(x-i) < diff)
			{
				diff = abs(x-i);
				snum = i;
			}
		}
	}
	W(snum);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3652
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define inf 1000000000000000000
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}


//edge cases when n=1,m=1.wrong variable in loop.if<->while;merge resize;LLONG_MAX
signed main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //#endif
    speed
    //global var
    string str;cin>>str;
    int ans=0;
    for(auto it:str){
        ans+=(it-'0');
        ans%=9;
    }
    if(ans==0){cout<<"Yes\n";}
    else{cout<<"No\n";}
}
//try thinking from a different angle after spending some time


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1000000000+7;

void trace(long long a, long long b, bool isMinus) {
  if (isMinus) swap(a,b);
  cout << a << " " << b << endl;
}

int factorization(long long x, vector<pair<long long, long long>> & v) {
  if (v.size() != 0) return 0;
  v.push_back(make_pair(1,1));
  long long i=2;
  while (sqrt(x) >= i) {
    if (x % i != 0) {
      i++;
      continue;
    }
    v.push_back(make_pair(i,0));
    while (x % i == 0) {
      v.back().second++;
      x = x/i;
    }
  }
  return 0;
}

pair<long long, long long> check(long long x, long long y) {
  long long b=0;
  long long a=b+y;
  long long z=x/y;
  auto culc = [](auto a, auto b) {return pow(a,4) + pow(a,3)*b + pow(a,2)*pow(b,2) + a*pow(b,3) + pow(b,4);};
  while (culc(a,b) <= z) {
    if (culc(a,b) == z) {
      return make_pair(a,b);
    }
    b++;
    a=b+y;
  }
  b=-1;
  a=b+y;
  while (culc(a,b) <= z) {
    if (culc(a,b) == z) {
      return make_pair(a,b);
    }
    b--;
    a=b+y;
  }
  return make_pair(0,0);
}

long long multi(vector<long long> v) {

}

int main1() {
  long long a,b,x;
  bool isMinus = x < 0;
  x = abs(x);
  if (x==0) {
    cout << 0 << " " << 0 << endl;
    return 0;
  }
  vector<pair<long long, long long>> f;
  factorization(x,f);

  vector<long long> F;
  for (auto e:f) {
    for (int i=0; i<e.second; i++) {
      F.push_back(e.first);
    }
  }





}

int main() {
  long long a,b,x;
  cin >> x;
  bool isMinus = x < 0;
  x = abs(x);
  if (x==0) {
    cout << 0 << " " << 0 << endl;
    return 0;
  }

  vector<long long> dp;
  dp.push_back(0);
  a = 0;
  while (true) {
    a++;
    dp.push_back(pow(a,5));
    b = -a;
    for (;b<=0; b++) {
      if (dp.at(a) + dp.at(-b) == x) {
        trace(a,b,isMinus);
        return 0;
      }
    }
    b = 1;
    for (;b<a; b++) {
      if (dp.at(a) - dp.at(b) == x) {
        trace(a,b,isMinus);
        return 0;
      }
    }
  }

}

Measured memory_bytes: 3988
function f()
    n = parse(Int, readline())
    l = map(x->parse(Int, x), split(chomp(readline()), " "))
    l_max = findmax(l)[1]
    l[findmax(l)[2]] = 0
    l_sum = sum(l)
    if l_max < l_sum
        print("Yes")
    else
        print("No")
    end
end
f()

Measured memory_bytes: 173020
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

ll Count(string S) {
  int N = S.size();
  
  // init
  ll cnt = 1;
  ll total = 0;

  // iter
  for (int i = 1; i < N; ++i) {
    if (S[i] == S[i - 1]) {
      ++cnt;
    } else {
      total += cnt / 2;
      cnt = 1;
    }
  }

  // terminate
  total += cnt / 2;

  return total;
}

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

  if (K <= 10) {
    string T;
    for (int i = 0; i < K; ++i) {
      T += S;
    }
    cout << Count(T) << endl;
  } else {
    string T;
    for (int i = 0; i < 10; ++i) {
      T += S;
    }
    ll cnt10 = Count(T);
    T += S;
    ll cnt11 = Count(T);
    T += S;
    ll cnt12 = Count(T);
    ll ans;
    ans = cnt10;
    ans += (K - 10) / 2 * (cnt12 - cnt10);
    if ((K - 10) % 2 != 0) ans += cnt11 - cnt10;
    cout << ans << endl;
  }
  
  return 0;
}


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

signed main(){
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  int ans=0;
  for(int i=0;i<n;i++)if(v[i]&1&&~i&1)ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <memory.h>


using namespace std;

typedef long long ll;

const int N = 2 * 100000 + 20;

int n , x , a[N];

ll res = 0;
int main(){
	//freopen("input.txt","r",stdin);
	scanf("%d%d",&n,&x);
	for (int i = 0; i < n; ++i){
		scanf("%d",&a[i]);
		if(a[i] > x){
			res += a[i] - x;
			a[i] = x;
		}
	}
	for (int i = 1 ; i < n; ++i){
		ll total = a[i-1] + a[i];
		if(total > x){
			res += total - x;
			a[i] -= total - x;
		}
	}
	printf("%lld\n",res );
	return 0;
}

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

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
int main(){
  int n;cin>>n;
  int count[1010];
  for(int i=0;i<=n;i++)count[i]=0;
  for(int i=2;i<=n;i++){
    int t=i;
  	for(int j=2;j<=t;j++){
      while(t%j==0){
      	t/=j;
        count[j]++;
      }
    }
  }
  ll ans=1;
  for(int i=2;i<=n;i++){
  	ans = (ans*max(1, 1+count[i]))%ll(1e9+7);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();

            int d = b - a;
            int sum = 0;
            for (int i = 0; i < d; i++) {
                sum += i;
            }

            out.println(sum - a);
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



Measured memory_bytes: 21588
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
*H, = map(int, input().split())

left = 0
ans = 0
while left < N-1:
    tmp = 0
    for right in range(left+1, N):
        if H[left] >= H[right]:
            tmp += 1
            left = right
        else:
            left = right
            break
    ans = max(tmp, ans)


print(ans)

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

int	main() {
	int N;
	cin >>N;
	vector<int> A(N, 0);
	vector<int> B(N, 0);
	vector<int> C(N, 0);
	for (int i=0; i<N; i++)
		cin >>A.at(i);
	for (int i=0; i<N; i++)
		cin >>B.at(i);
	for (int i=0; i<N; i++)
		cin >>C.at(i);
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());
	long S=0;
	long ia=0;
	long ic=0;
	for (int i=0; i<N; i++) {
		while(true) {
			if (ia==N)
				break;
			if (A.at(ia)<B.at(i))
				ia++;
			else
				break;
		}
		while(true) {
			if (ic==N)
				break;
			if (C.at(ic)<=B.at(i))
				ic++;
			else
				break;
		}
		S +=ia*(N-ic);
	}
	cout <<S <<endl;
	return 0;
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vll a(N);
    rep(i,N) cin>>a[i];
    ll sum=0;
    rep(i,N) sum^=a[i];
    rep(i,N){
        if (i>0) cout<<" ";
        cout<<(sum^a[i]);
    }cout<<endl;
    return 0;
}


Measured memory_bytes: 4744
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N, K;
  cin >> N >> K;
  int X;
  int sum = 0;
  rep(i, N) {
    cin >> X;
    sum += min(X, K - X);
  }
  cout << sum * 2 << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 1000000001;

int main(){
  int a[3];
  rep(i,3) cin >> a[i];
  sort(a, a+3);
  if(a[0] == a[1]) cout << a[2] <<endl;
  else cout << a[0] <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    string S;
    ll K;   
    cin >> S >> K;
    for (int i = 0; i < min((long long)S.size(), K); i++) {
		if (S[i] >= '2') { cout << S[i] << endl; return 0; }
	}
	cout << '1' << endl;
	return 0;
}

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

using namespace std;

long long K;

long long N = 50;

int main(){
    cin >> K;
    long long val = (K + N - 1) / N + (N - 1);
    long long N1 = val * N - N * (N - 1) - K;
    cout << N << endl;
    for(int i = 1;i <= N1;i++){
        printf("%lld%c", val + N1 - N - 1, i == N ? '\n' : ' ');
    }
    for(int i = N1 + 1;i <= N;i++){
        printf("%lld%c", val + N1, i == N ? '\n' : ' ');
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

int main()
{
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    char input[10];
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf(" %s", input);
        if (!strcmp(input, "AC")) {
            ac++;
        }
        else if (!strcmp(input, "WA")) {
            wa++;
        }
        else if (!strcmp(input, "TLE")) {
            tle++;
        }
        else if (!strcmp(input, "RE")) {
            re++;
        }
    }
    //printf("%s\n", input);
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
}

Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std;
string rep[] = {"" , "Male", "Female"};
signed main(){
	int n; cin >> n;
	int l = 0 , r = n - 1;
	string v;
	int s1 , sn;
	cout << 0 << "\n";
	fflush(stdout);
	cin >> v;
	if(v == "Vacant") exit(0);
	for(int i = 1 ; i <= 2 ; ++i)
		if(v == rep[i]) s1 = i;
	cout << n - 1 << "\n";
	fflush(stdout);
	cin >> v;
	if(v == "Vacant") exit(0);
	for(int i = 1 ; i <= 2 ; ++i)
		if(v == rep[i]) sn = i;
	while(l < r)
	{
		int mid = l + r >> 1;
		cout << mid << "\n";
		fflush(stdout);
		cin >> v;
		if(v == "Vacant") exit(0);
		for(int i = 1 ; i <= 2 ; ++i)
		if(v == rep[i])
		{
			if((n - mid) % 2 == (sn - i + 2) % 2 || (mid - 1) % 2 != (i - s1 + 2) % 2)
				l = mid + 1;
			else r = mid;
		}
	}
}

Measured memory_bytes: 852
pictures = ['S','H','C','D']
card_li = []
for i in range(4):
    for j in range(1,14):
        card_li.append(pictures[i] + ' ' + str(j))
n = int(input())
for i in range(n): del card_li[card_li.index(input())]
for i in card_li:
    print(i)

Measured memory_bytes: 7736
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def main():
    N,X = (int(i) for i in input().split())
    x=list(map(int,input().split()))

    gcd_l = []
    #gcd_l.append(abs(X-x[0]))

    for i in range(0,N):
        gcd_l.append(abs(X-x[i]))
    if N==1:
        ans = gcd_l[0]
    else:
        a = [gcd_l[0],gcd_l[1]]
        ans = gcd(max(a),min(a))
        for n in range(2,len(gcd_l)):
            a = [ans,gcd_l[n]]
            ans = gcd(max(a),min(a))
    print(ans)

main()

Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;

const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int main(){
	int n, m;
	
	cin >> n >> m;
	
	n--;
	m--;
	
	cout << n*m << endl;
	
	return 0;
}

Measured memory_bytes: 256
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define F first
#define S second


int main()
{

#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//ios_base& scientific (ios_base& str);


    ll a;
    double b;
    cin >> a;
    cin >> b;
    long long b_new = round(b * 100);
    ll out = (a * b_new) / 100;
    cout << out << "\n";
    return 0;
}

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

  int n;
  cin>>n;

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

  int m;
  cin>>m;

  vector <int> b(m);
  for(int i=0;i<m;i++) cin>>b[i];

  cout<<(a<b)<<endl;

  return 0;

}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int N=0;
    int L,R;
    int d;
    cin>>L>>R>>d;
    for(int i=L;i<=R;i++){
        if(i%d==0){
            N++;
        }
    }
    cout<<N<<endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(void) {
  int N,T,C_i[101],T_i[100],ans=100,i;
  T_i[100]=1001;
  scanf("%d %d",&N,&T);
  for(i=0;i<N;i++)scanf("%d %d",&C_i[i],&T_i[i]);
  for(i=0;i<N;i++)if(T_i[i] <= T && C_i[i] < C_i[ans])ans=i;
  if(ans == 100) {
    printf("TLE\n");
  } else {
    printf("%d\n",C_i[ans]);
  }
  return 0;
}


Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (_, k) = i.read2::<usize, usize>();
    let k = k - 1;
    let mut s = String::new();
    for (idx, c) in i.read_line().chars().enumerate() {
        if idx == k {
            for c in c.to_lowercase() {
                s.push(c);
            }
        } else {
            s.push(c);
        }
    }
    writeln!(o, "{}", s).unwrap();
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


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

int main(){
    int n,m,l;
    long long a[100][100], b[100][100], c[100][100] = {};
    cin >> n >> m >> l;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++){
            cin >> b[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            c[i][j] = 0;
            for(int k = 0; k < m; k++){
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            if(j) cout << " ";
            cout << c[i][j];
        }
        cout << endl;
    }
    return 0;
}


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

using namespace std;

int main(){
    string s;
    char temp;
    cin >> s;
    for(int i = 4; i > 0; i--){
        for(int j = 0; j < i - 1; j++){
            if(s[j] > s[j + 1]) temp = s[j], s[j] = s[j + 1], s[j + 1] = temp;
        }
    }
    if(s[0] == s[1] && s[2] == s[3] && s[0] != s[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
data = sys.stdin.read()
data = data.lower()
ans = {
       'a':0,
       'b':0,
       'c':0,
       'd':0,
       'e':0,
       'f':0,
       'g':0,
       'h':0,
       'i':0,
       'j':0,
       'k':0,
       'l':0,
       'm':0,
       'n':0,
       'o':0,
       'p':0,
       'q':0,
       'r':0,
       's':0,
       't':0,
       'u':0,
       'v':0,
       'w':0,
       'x':0,
       'y':0,
       'z':0,
       }

for i in data:
    if i in ans:
        ans[i] += 1

for i in ans:
    print(i, ':', ans[i])


Measured memory_bytes: 5576
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

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

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK) 
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}

ll COMBI(ll N, ll R){
    if(R==1) return N;
    ll bunbo=1;
    ll bunsi=1;
    for(ll i=0; i<=R-1; i++){
        bunsi = bunsi * (N-i) % MOD;
        bunbo = bunbo * (i+1) % MOD;
    }
    return (bunsi*modinv(bunbo, MOD))%MOD;
}

int main(){
    ll n,A,B; cin>>n>>A>>B;
    ll whole= (modpow(2, n, MOD) -1)%MOD;
    //wholeからnCaとnCbをひけばいい
    ll ans=(whole-COMBI(n,A)%MOD-COMBI(n,B)%MOD)%MOD;
    if(ans<0) ans+=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

st = sorted(p)
x = list(itertools.permutations(st, n))

num1 = x.index(tuple(p))
num2 = x.index(tuple(q))
print(abs(num1 - num2))


Measured memory_bytes: 8052
using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading;

namespace Sweet
{
    class Program
    {
        static void Main(string[] args)
        {
            Int32 a,b;

            for(;;){
                string str = Console.ReadLine();

                b = str.IndexOf(" ");
                a = int.Parse(str.Substring(0, b));
                b = int.Parse(str.Substring(b));
                if (a == 0 && b == 0)
                    return;

                //Console.WriteLine("you entered {0} 0x{0:x4}.", num);
                //string ans = string.Format("{0}", num * num * num);
                Console.WriteLine("{0}", Sweep(a, b));
                /*Console.WriteLine("Hello World");*/
                //Console.ReadLine();
            }
        }
        private static int MaxSweep(int a, int b,int c)
        {
            if (a + c <= b)
                return a;
            else
            if (b + c <= a)
                return b;
            else
            {
                c = (a < b)?b-a:a-b;
                if (a <= b)
                    return b - c;
                else
                    return a - c;
            }
        }
        private static int Sweep(int a, int b)
        {
            int i,j,k,s,res=0;

            for (res = 0, i = MaxSweep(b, a, 3); 2 < i; i--)
                for (j = MaxSweep(i-1, b - i - 1, 2), s = b - i; 1 < j; j--)
                    for (k = MaxSweep(j-1, b - i - j, 1); s <= j + k && 0 < k; k--)
                    {
                        //Console.Write("{0}, {1}, {2} ", i, j, k);
                        if (s == j + k)
                        {
                            //Console.Write("{0}, {1}, {2} ", i, j, k);
                            res++;
                        }
                    }
            return res;
        }
    }
}

Measured memory_bytes: 9668
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define __builtin_ctz __builtin_ctzll
#define __builtin_clz __builtin_clzll
#define __builtin_popcount __builtin_popcountll
using namespace std;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',') { cerr<<*sdbg++; } cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third;
  bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  for (T& v : vec) { ResizeVec(v, sz); }
}
typedef Triple<int, int, int> TIII;
template<class A, class B, class C>
ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class T> ostream& operator<<(ostream& out, set<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class L, class R> ostream& operator<<(ostream& out, map<L, R> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }


int32_t main() {

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  cin.tie(0);
  //double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;
  

  int a, b, c;
  cin>>a>>b>>c;
  cout<<b + min(a + b + 1, c)<<endl;
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  return 0;
}


Measured memory_bytes: 256
//io
#include <iostream>
#include <cstdio>

//data structure
#include <vector>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>

//algorithm
#include <algorithm>
#include <cmath>
#include <cstdlib>

#include <cassert>
using namespace std;
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 100;
int d[maxn][maxn];

int dp(int a, int b)
{
  if (a > b)
    swap(a, b);
  int &ret = d[a][b];
  if (ret == -1)
    {
      set<int> s;
      for (int i = 1; 2*i <= b; ++i)
	{
	  if (a >= 2*i)
	    s.insert(dp(a-2*i, b+i));
	  s.insert(dp(a+i, b-2*i));
	}
      for (int i = 0; true; ++i)
	if (s.count(i) == 0)
	  {
	    ret = i;
	    break;
	  }
    }
  return ret;
}
int main()
{

  // brute force
  /* 
  memset(d, -1, sizeof(d));
  for (int i = 0; i <= 20; ++i)
    {
      for (int j = 0; j <= i; ++j)
	{
	  printf("%d ", dp(j, i));
	  // printf("dp(%d, %d) = %d\n", j, i, dp(j, i));
	}
      puts("");
    }
  */
  ll x, y;
  scanf("%lld %lld", &x, &y);
  if (abs(x-y) <= 1)
    puts("Brown");
  else
    puts("Alice");
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
bool is_prime(long long N)
{
  if (N == 1)
    return false;
  for (long long i = 2; i * i <= N; ++i)
  {
    if (N % i == 0)
      return false;
  }
  return true;
}

int main()
{
  cout << fixed << setprecision(10);
  int Q;
  cin >> Q;
  vector<int> vec(100010);
  int n = 0;
  rep(i,100010)
  {
      if(is_prime(i)&&is_prime((i+1)/2)&&i%2==1)
      {
        n ++;
        vec[i] = n;
      }
      else
      {
        vec[i] = n;
      }
  }
  rep(i,Q)
  {
    int l,r;
    cin >> l >> r;
    l--;
    cout << vec[r] - vec[l] << endl;
  }
  return 0;
}


Measured memory_bytes: 3764
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

int main() {
    std::string str;
    std::cin >> str;

    if (str == "Sunny") {
        std::cout << "Cloudy" << std::endl;
    } else if (str == "Cloudy") {
        std::cout << "Rainy" << std::endl;
    } else {
        std::cout << "Sunny" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
    public class Main{
        public static void main(String[] args){
            Scanner sc=new Scanner(System.in);
            int N=sc.nextInt();
            int A[];
            A=new int[N];
            for(int i=0;i<N;i++) A[i]=sc.nextInt();
            Arrays.sort(A);
            boolean ans=true;
            for(int i=0;i<N-1;i++) if(A[i]==A[i+1]) ans=false;
            System.out.println(ans?"YES":"NO");
        }
    }

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

struct Node {
    long key;
    Node *parent, *left, *right;
};

struct Node *root, *NIL;

void preParse(struct Node *id) {
    if (id == NIL) {
        return;
    }
    cout << " " << id->key;
    preParse(id->left);
    preParse(id->right);
}

void inParse(struct Node *id) {
    if (id == NIL) {
        return;
    }
    inParse(id->left);
    cout << " " << id->key;
    inParse(id->right);
}

 Node * find(long k) {
    Node *x = root;

    while (x != NIL) {
        if (x->key == k) {
            return x;
        }
        else {
            if(k < x->key) {
                x = x->left;
            }
            else {
                x = x->right;
            }
        }
    }
    return x;
}

void insert(long k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        }
        else {
            x = x->right;
        }
    }

    z->parent = y;
    if (y == NIL) {
        root = z;
    }
    else {
        if (z->key < y->key) {
            y->left = z;
        }
        else {
            y->right = z;
        }
    }
}

int main() {
    long m;
    cin >> m;

    char com[10];

    for (long i = 0; i < m; i++) {
        cin >> com;
        if (com[0] == 'p') {
            inParse(root);
            cout << endl;
            preParse(root);
            cout << endl;
        }
        else if (com[0] == 'f') {
            long key;
            cin >> key;
            Node *t = find(key);
            if (t != NIL) {
                cout << "yes" << endl;
            }
            else {
                cout << "no" << endl;
            }
        }
        else if (com[0] == 'i'){
            long key;
            cin >> key;
            insert(key);
        }
    }

    return 0;
}



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

int main(void){
    // Your code here!
    int N;
    cin>>N;
    map<string,ll> dic;
    rep(0,i,N){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        ++dic[s];
    }
    ll ans=0,n;
    for(auto iter=dic.begin();iter!=dic.end();++iter){
        n=iter->second;
        ans+=n*(n-1)/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 11136
n = int(input())
def function(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    
    if n != 1:
        a.append(n)
    
    return a

a = function(n)
print("{0}:" . format(n), end=" ")
for i in range(len(a) - 1):
    print(a[i], end=" ")
print(a[len(a) - 1])


Measured memory_bytes: 5600
A=int(input())
B=int(input())
C=int(input())
X=int(input())

x=[(i,j,k)for i in range(A+1) for j in range(B+1) for k in range(C+1)]
count=0
for i,j,k in x:
    if 500*i+100*j+50*k==X:
        count+=1
        
print(count)
    

Measured memory_bytes: 13592
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    if(b+c-a < 0) cout << 0 << endl;
    else cout << b+c-a << endl;
}

Measured memory_bytes: 256
S = list(input())
N = len(S)
ans = [1]*N
for i in range(N-1):
    if S[i] == 'R' and S[i+1] == 'L':
        S[i] = "T"
        S[i+1] = "T"

csr = 0
cnt = 0
while csr < N:
    if S[csr] == 'R':
        cnt += 1
        ans[csr] = 0
        csr += 1
    elif S[csr] == 'T':
        ans[csr] += cnt // 2
        ans[csr+1] += cnt - cnt // 2
        cnt = 0
        csr += 2
    else:
        csr += 1

csr = N-1
cnt = 0

while csr > 0:
    if S[csr] == 'L':
        cnt += 1
        ans[csr] = 0
        csr -= 1
    elif S[csr] == 'T':
        ans[csr] += cnt // 2
        ans[csr-1] += cnt - cnt // 2
        cnt = 0
        csr -= 2
    else:
        csr -= 1

print(' '.join(map(str, ans)))

Measured memory_bytes: 11180