akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}

int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
struct edge { int to, cost; };
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
/*--------Library Zone!--------*/

class dijkstra {
public:
	int V;
	dijkstra(int x) {
		V = x;
	}
	int far[100005];
	vector<edge>G[100005];
	void solve(int st) {
		fill(far, far + V, moder);
		far[st] = 0;
		prique(P)que;
		que.push({ 0,st });
		while (que.size()) {
			P p = que.top(); que.pop();
			int v = p.second;
			if (far[v] < p.first)continue;
			rep(i, G[v].size()) {
				edge e = G[v][i];
				if (far[e.to] > far[v] + e.cost) {
					far[e.to] = far[v] + e.cost;
					que.push({ far[e.to],e.to });
				}
			}
		}
	}
};
signed main() {
	int n, m, s;
	cin >> n >> m >> s;
	static dijkstra dijk(n);
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		dijk.G[a].push_back({ b,c });
	}
	dijk.solve(s);
	rep(i, n) {
		if (dijk.far[i] != moder)cout << dijk.far[i] << endl;
		else cout << "INF" << endl;
	}
	endre;
}



Measured memory_bytes: 19496
#include <stdio.h>

int main()
{
    char N[4];
    
    scanf("%s", N);
    
    if(((N[0] == N[1]) && (N[1] == N[2])) || ((N[1] == N[2]) && (N[2] == N[3])))
        puts("Yes");
    else
        puts("No");
        
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

vector<int> G[100001];
vector<int> color(100001, -1);
void init(int idx, int c){
  if(color[idx] >= 0) return;
  color[idx] = c;
  for(int to: G[idx])
	init(to, c);
}

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

  for(int i=0;i<M;++i){
	int a, b; cin >> a >> b;
	G[a].push_back(b);
	G[b].push_back(a);
  }
  for(int i=0;i<N;++i){
	init(i, i);
  }

  int Q; cin >> Q;
  for(int q=0;q<Q;++q){
	int a, b; cin >> a >> b;
	cout << (color[a]==color[b]? "yes": "no") << endl;
  }

  return 0;
}

Measured memory_bytes: 9976
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define int long long
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=998244353;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int X[110];
int Y[110];
int H[110];
int n;
bool chec(int x,int y,int h)
{
    for(int i=1;i<=n;i++)
    {
        if(H[i]!=max(h-abs(x-X[i])-abs(y-Y[i]),0*1ll))
            return false;
    }
    return true;
}
int32_t main()
{

    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>X[i]>>Y[i]>>H[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(H[i]!=0)
        {
            swap(X[1],X[i]);
            swap(Y[1],Y[i]);
            swap(H[1],H[i]);
            break;
        }
    }
    for(int x=0;x<=100;x++)
    {
        for(int y=0;y<=100;y++)
        {
            if(chec(x,y,H[1]+abs(x-X[1])+abs(y-Y[1])))
            {
                cout<<x<<" "<<y<<" "<<H[1]+abs(x-X[1])+abs(y-Y[1])<<endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=1e5+10;

int a[maxn],b[maxn],A,B,m;
int mina=inf,minb=inf;

int main(){
	cin>>A>>B>>m;
	for(int i=0;i<A;i++){
		cin>>a[i];
		mina=min(mina,a[i]);
	}
	for(int i=0;i<B;i++){
		cin>>b[i];
		minb=min(minb,b[i]);
	}
	int ans=mina+minb;
	for(int i=0;i<m;i++){
		int x,y,c;
		cin>>x>>y>>c;
		x--; y--;
		ans=min(ans,a[x]+b[y]-c);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
// {{{ include
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
// }}}

using namespace std;

typedef long long ll;
inline int in(){int x;scanf("%d",&x);return x;}

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

int panel[16][16];
int backup[16][16];
int vis[16][16];
int h, w;

void dump(){
  return;
  puts(":::::::::");
  for (int y = 1; y <= h; y++){
    for (int x = 1; x <= w; x++){
      printf("%2d", panel[y][x]);
    }
    puts("");
  }
  puts(":::::::::");
}

void fill_panel(int x, int y, int a, int b){
  if (vis[y][x]++) return;
  int& p = panel[y][x];
  if (p != a) return;
  p = b;
  for (int d = 0; d < 4; d++){
    fill_panel(x + dx[d], y + dy[d], a, b);
  }
}

int count_panel(int x, int y, int a)
{
  if (vis[y][x]++) return 0;
  int p = panel[y][x];
  if (p != a) return 0;
  int res = 1;
  for (int d = 0; d < 4; d++){
    res += count_panel(x + dx[d], y + dy[d], a);
  }
  return res;
}

int simulate(int manip[5]){
  int r;
  for (int i = 0; i < 5; i++){
    memset(vis, 0, sizeof(vis));
    fill_panel(1, 1, panel[1][1], manip[i]);
  }
  memset(vis, 0, sizeof(vis));
  return count_panel(1, 1, panel[1][1]);
}

int main()
{
  int c;
  while (h = in(), w = in(), c = in()){
    memset(panel, 0, sizeof(panel));
    for (int y = 1; y <= h; y++){
      for (int x = 1; x <= w; x++){
        panel[y][x] = in();
      }
    }
    memcpy(backup, panel, sizeof(backup));
    int maxi = 0;
    int manip[5];
    manip[4] = c;
    for (int i = 1; i <= 6; i++){
      manip[0] = i;
      for (int j = 1; j <= 6; j++){
        manip[1] = j;
        for (int k = 1; k <= 6; k++){
          manip[2] = k;
          for (int l = 1; l <= 6; l++){
            manip[3] = l;
            memcpy(panel, backup, sizeof(panel));
            int r = simulate(manip);
            maxi = max(maxi, r);
          }
        }
      }
    }
    printf("%d\n", maxi);
  }
  return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,cnt1=0,x;
   double ans,cnt=0;
    cin>>n;
    while(n--)
    {  cin>>x;
       cnt+=(1/double (x));

    }
    cout<<1/cnt<<endl;


       //cout<<<<endl;
   /* vector<ll>vec;
    vector<ll>::iterator it;
     for(int i=0;i<n;i++)
     {
        cin>>x;
        vec.push_back(x);

     }
       for(it=vec.begin();it!=vec.end();it++){
               cnt+=*it;}
                for(int i=0;i<n;i++){
                cnt1+=vec[i]*vec[i+1];}
             cout.precision(5);
          cout<<double(cnt1)/cnt<<endl;*/

return 0;}



Measured memory_bytes: 384
n=int(input())
t=list(str(input()))
s=[]
for i in range(n):
    s.append(int(t[i]))
g=[[0 for i in range(10)] for j in range(10)]
r=[0 for j in range(n+1)]
l=[0 for j in range(n+1)]
for i in range(n):
    if r[i]&(2**s[i])==0:
        r[i+1]=r[i]+2**s[i]
    else:
        r[i+1]=r[i]
    if l[n-i]&(2**s[n-i-1])==0:
        l[n-i-1]=l[n-i]+2**s[n-i-1]
    else:
        l[n-i-1]=l[n-i]
ans=[[[0 for i in range(10)] for j in range(10)] for k in range(10)]
for i in range(n):
    for j in range(10):
        for k in range(10):
            if r[i]&(2**j) and l[i+1]&(2**k):
                ans[j][s[i]][k]+=1
kai=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            if ans[i][j][k]>0:
                kai+=1
print(kai)

Measured memory_bytes: 44908
#include <stdio.h>

int main() {

	int a, b, c, d;
	
	scanf("%d", &a);
    b = a % 100 % 10;
    c = (a / 10) % 10;
  	d = a / 100;
    printf("%d", b + c + d);
	
	return (0);

}

Measured memory_bytes: 1688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), d = sc.nextInt();
		int x=sc.nextInt();//,k=sc.nextInt();
		long sum=0,count=0,flag=0,max=-999999,min=99999;
		long[] array=new long[n];
		//String[] array = new String[n];
		//String s=sc.next();//,t=sc.next();
		for(int i=0;i<n;i++) {
			array[i]=sc.nextLong();
		}
		for(int i=0;i<n;i++) {
			int j=0;
			while(count<d) {
				count=j*array[i]+1;
				if(count>d)break;
				sum++;
				j++;
			}
			count=0;
		}

		System.out.println(sum+x);
	}
	public static int sample(int n) {
		return n;
	}

}


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

using namespace std;

const int N = 233;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> dp(N);
  for (int i = 0; i < n; i++) {
    int cur;
    scanf("%d", &cur);
    vector<int> ndp(N, n);
    for (int x = 0; x < N; x++) {
      for (int y = 0; y < N; y++) {
        if (x != y) {
          ndp[y] = min(ndp[y], dp[x] + (y != cur));
        }
      }
    }
    dp = ndp;
  }
  int ans = *min_element(dp.begin(), dp.end());
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = sorted([int(x) for x in input().split()])
freq = Counter(a)
A = max(a)
good = [True]*(A+1)
ans = 0
for x in freq:
	for k in range(2*x,A+1,x):
		good[k] = False
	if good[x] and freq[x]==1:
		ans += 1
print(ans)

Measured memory_bytes: 134872
package main

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

func main() {
	// sc.Split(bufio.ScanWords)
	S := readLine()
	s, ir, il := len(S), 0, -1
	A := make([]int, s)
	for i, c := range S {
		if c == 'R' {
			if il != -1 {
				A[il-1] = (il-ir)/2 + (i-il)/2 + (il-ir)%2
				A[il] = (il-ir)/2 + (i-il)/2 + (i-il)%2
				ir = i
				il = -1
			}
		} else if il == -1 {
			il = i
		}
	}
	A[il-1] = (il-ir)/2 + (s-il)/2 + (il-ir)%2
	A[il] = (il-ir)/2 + (s-il)/2 + (s-il)%2
	for i, a := range A {
		if i == s-1 {
			fmt.Printf("%d\n", a)
		} else {
			fmt.Printf("%d ", a)
		}
	}
}

var sc = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin, 1000)

func nextInt() int {
	i, _ := strconv.ParseInt(nextLine(), 10, 64)
	return int(i)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
const int MOD = 1e9+7;
const int INF = 1e9+15;
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);}
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct Edge{int to,weight;};
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 dp[110][101010]; 
int w[110],v[110];

signed main(){
  int n,W;
  cin>>n>>W;
  rep(i,n) cin>>w[i]>>v[i];
  rep(i,110)rep(j,101010) dp[i][j]=INF;
  
  dp[0][0]=0;
  rep(i,n+1)rep(j,101010){
    if(j>=v[i]) chmin(dp[i+1][j],dp[i][j-v[i]]+w[i]);
    chmin(dp[i+1][j],dp[i][j]);
  }

  int ans=0;
  rep(j,101010) if(dp[n][j]<=W) ans=j;
  cout<<ans<<endl;
  // rep(i,n+1){
  //   rep(j,101010) if(dp[i][j]<INF) cout<<dp[i][j]<<"/"<<j<<" ";
  //   cout<<endl;
  // }
  return 0;
}


Measured memory_bytes: 87040
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

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

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

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

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

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

int main()
{
    ll a;
    cin >> a;
    string b;
    cin >> b;
    ll tmp = 0;
    ll cnt = 1;
    for (ll i = 0; i < b.size(); i++)
    {
        if (b[b.size() - i - 1] == '.')
        {
            continue;
        }
        tmp += cnt * (ll)(b[b.size() - i - 1] - '0');
        cnt *= 10;
    }
    ll sum = a * tmp;
    cout << sum / 100 << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X;
  cin >> X;
  int A = 0;
  int B = 0;
  A = X/500;
  B = (X - A * 500) / 5;
  cout << A * 1000 + B * 5 << endl;
}


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


#define mod 1000000007
#define ull unsigned long long int
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return true; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

ll ncr(int n, int k)  
{  
	if(k>n)return 0;
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
#define  deb(x)       cout << '>' << #x << ':' << x << endl;


void  solve()
{
	int a,b;
	cin>>a>>b;
	int c=0;
	while(a>0)
	{
		a-=b;
		c++;
	}
	cout<<c<<endl;

}


int main()
{
 
    FastIO;
    ll t=1;
   	//bcin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")



int main() {
	string s;
	cin >> s;
	vector<ll> dp[2];
	dp[0].resize(s.size() + 1, 0);
	dp[1].resize(s.size() + 1, 0);
	dp[1][s.size()] = 1000000000000000000LL;
	for(int i =s.size()-1; i >= 0; --i){
		dp[0][i] = min(dp[0][i + 1] + s[i] - '0', dp[1][i + 1] + 1 + s[i] - '0');
		dp[1][i] = min(dp[0][i + 1] + 10 - (s[i] - '0'), dp[1][i + 1] + 9 - (s[i] - '0'));
	}
	PRI(min(dp[0][0], dp[1][0] + 1));
	return 0;
}




Measured memory_bytes: 20088
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b) * h / 2;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN             PIC X(10).
01 K              PIC 9(3).
01 X              PIC 9(6).

PROCEDURE DIVISION.
  ACCEPT LN.
  UNSTRING LN DELIMITED BY SPACE INTO K X.
  IF X <= 500 * K
      DISPLAY "Yes"
  ELSE
      DISPLAY "No"
  END-IF.
  STOP RUN.


Measured memory_bytes: 636
n, m = map(int, input().split())

jouken_1 = []
jouken_2 = []
jouken_3 = []

if m == 0:
    if n == 1:
        print(0)
        exit()
    elif n == 2:
        print(10)
        exit()
    else:
        print(100)
        exit()

for _ in range(m):
    array = tuple(map(int, input().split()))
    if array[0] == 1:
        jouken_1.append(array)
    elif array[0] == 2:
        jouken_2.append(array)
    elif array[0] == 3:
        jouken_3.append(array)

a = set(jouken_1)
b = set(jouken_2)
c = set(jouken_3)
a = list(a)
b = list(b)
c = list(c)
flag = False

if len(a) > 1:
    print(-1)
    exit()
elif len(a) == 1:
    a = a[0][1]
else:
    flag = True
    a = 0

if len(b) > 1:
    print(-1)
    exit()
elif len(b) == 1:
    b = b[0][1]
else:
    b = 0

if len(c) > 1:
    print(-1)
    exit()
elif len(c) == 1:
    c = c[0][1]
else:
    c = 0

if n == 1:
    if b > 0 or c > 0:
        print(-1)
        exit()
    for i in range(10):
        if i == a:
            print(a)
            exit()
    print(-1)
elif n == 2:
    if c > 0:
        print(-1)
        exit()
    if a == 0 and flag is True:
        a = 1
    for i in range(10, 100):
        if str(i)[0] == str(a) and str(i)[1] == str(b):
            print(i)
            exit()
    print(-1)
elif n == 3:
    if a == 0 and flag is True:
        a = 1
    for i in range(100, 1000):
        if str(i)[0] == str(a) and str(i)[1] == str(b) and str(i)[2] == str(c):
            print(i)
            exit()
    print(-1)

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
// static const ll MAX = 1000000;
static const ll INFTY = 1e12;

struct edge {
    ll to;
    char cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

#include <iostream>
using namespace std;

const int MAX = 10000;
const int MOD = 1000000007;

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


int main(void){

  int N, i;
  cin >> N >> i;

  cout << N-i+1 << endl;


}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


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

#define pb push_back
#define ll long long
#define ff first
#define ss second
#define pii pair<int,int> 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

int main(){
    fastio
    int n,l;
    cin>>n>>l;
    int ans=0;
    int min1=1e9;
        int x=0;
        for(int i=1;i<=n;i++){
           ans += (l+i-1);
           if(abs(l+i-1)<min1){
               min1 = abs(l+i-1);
               x = l+i-1;
           }
        }
        ans -= x;
    cout<<ans<<endl;
}

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

using namespace std;
ifstream fin("f.in");
ofstream fout("f.out");

#define hello cout << "hello" << endl
#define dbg(var) cout << #var << " --> " << var << endl
#define mset(a, b)  memset(a, b, sizeof(a))
#define vi vector<int>
#define vii vector<pair<int, int> >
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define boost ios_base::sync_with_stdio(false)

const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-6;
const int N = 1e5 + 10;

ll x[N], y[N];
int main(){
	boost;
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; ++i)
		cin >> x[i];
	for(int i = 0; i < m; ++i)
		cin >> y[i];
	ll sum1 = 0;
	ll sum2 = 0;
	for(int i = 1; i <= n; ++i){
		sum1 = ((sum1 % mod) + ((i - 1) * x[i - 1] - (n - i) * x[i - 1]) % mod) % mod;
		// sum1 = ((sum1 % mod) + ((i - 1) * x[i - 1]) % mod) % mod;
		// sum1 = ((sum1 % mod) + (-((n - i) * x[i - 1]) % mod)) % mod;
	}
	for(int i = 1; i <= m; ++i){
		sum2 = ((sum2 % mod) + ((i - 1) * y[i - 1] - (m - i) * y[i - 1]) % mod) % mod;
		// sum2= ((sum2 % mod) + ((i - 1) * y[i - 1]) % mod) % mod;
		// sum2 = ((sum2 % mod) + (-((m - i) * y[i - 1]) % mod)) % mod;
	}
	ll ans = (sum1 * sum2) % mod;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int n;
int a[50001];
int S[50001];


int main(){

while(cin >> n && n > 0){


  int max = -100000;
  for (int i = 0; i < n; ++i)
  {
    cin >> a[i];
    if( a[i] > max) max = a[i];
  }

  S[0] = 0;
  for (int i = 0; i < n ; ++i)
  {
    S[i + 1] = S[i] + a[i];
    
  }


  for (int i = 0; i < n + 1; ++i)
  {
    for (int k = 0; k < i ; ++k)
    {
      if(S[i] - S[k] > max) max = S[i] - S[k];
    }
  }

  cout << max << endl;

  }
}

Measured memory_bytes: 1192
import sys
from heapq import heappush,heappop
input = sys.stdin.readline

n,m = map(int,input().split())
ab = []
for i in range(n):
    a,b = map(int,input().split())
    if a <= m:
        ab.append((a,b))
ab.sort(reverse=1)

stock = []
ans = 0
for i in range(1,m+1):
    while ab and ab[-1][0] <= i:
        a,b = ab.pop(-1)
        heappush(stock,-b)
    if stock:
        ans += -heappop(stock)

print(ans)

Measured memory_bytes: 17232
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int max(const void* x,const void* y);
int main(){
	for(;;){
		int hand[5];
		if(scanf("%d,%d,%d,%d,%d",&hand[0],&hand[1],&hand[2],&hand[3],&hand[4]) == EOF){break;}
		qsort(hand,5,sizeof(int),max);
		int f = 0;
		for(int i=0; i<5; i++){
			if(hand[i] == hand[i+1] && hand[i+1] == hand[i+2] && hand[i+2] == hand[i+3]){f = 1;i+=3;}
			else if(hand[i] == hand[i+1] && hand[i+1] == hand[i+2]){f += 2;i+=2;}
			else if(hand[i] == hand[i+1]){f += 3;i+=1;}
		}
		if(hand[0]+1 == hand[1] && hand[1]+1 == hand[2] && hand[2]+1 == hand[3] && hand[3]+1 == hand[4]){f = 10;}
		if(hand[0] == 1 && hand[1] == 10 && hand[2] == 11 && hand[3] == 12 && hand[4] == 13){f = 10;}
		if(f == 1){cout <<"four card"<<endl;}
		else if(f == 2){cout <<"three card"<<endl;}
		else if(f == 3){cout <<"one pair"<<endl;}
		else if(f == 6){cout <<"two pair"<<endl;}
		else if(f == 5){cout <<"full house"<<endl;}
		else if(f == 10){cout <<"straight"<<endl;}
		else if(f == 0){cout <<"null"<<endl;}
	}
	return 0;
}
int max(const void* x,const void* y){
	return *(int*)x - *(int*)y;
}

Measured memory_bytes: 0
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
c=[[0 for i in range(w)] for j in range(h)]
k=0 #color
for i in range(h):
    if i%2==0:
        j=0
        while j<w:
            if a[k]>0:
                c[i][j]=k+1
                a[k]-=1
                j+=1
            else:
                k+=1
    else:
        j=w-1
        while j>=0:
            if a[k]>0:
                c[i][j]=k+1
                a[k]-=1
                j-=1
            else:
                k+=1
for i in range(h):
    print(*c[i])

Measured memory_bytes: 3920
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		String[] a = new String[n];
		for (int i = 0; i < n; i++) {
			a[i] = Long.toBinaryString(sc.nextLong());
		}
		sc.close();

		int[] cnt1 = new int[40];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < a[i].length(); j++) {
				if (a[i].charAt(j) == '1') {
					cnt1[a[i].length() - 1 - j]++;
				}
			}
		}

		long[][] val = new long[40][2];
		char[] bit0 = new char[40];
		long base = 1;
		for (int i = 0; i < 40; i++) {
			if (cnt1[i] < n - cnt1[i]) {
				bit0[i] = '1';
			} else {
				bit0[i] = '0';
			}
			val[i][0] = base * cnt1[i];
			val[i][1] = base * (n - cnt1[i]);
			base *= 2;
		}

		char[] k2 = Long.toBinaryString(k).toCharArray();
		char[] bitk = new char[40];
		Arrays.fill(bitk, '0');
		for (int i = 0; i < k2.length; i++) {
			bitk[k2.length - 1 - i] = k2[i];
		}

		long ans = 0;
		char[] bit = new char[40];
		System.arraycopy(bit0, 0, bit, 0, bit.length);

		for (int i = bit.length - 1; i >= 0; i--) {
			if (bit[i] < bitk[i]) {
				ans = Math.max(ans, calc(val, bit));
				break;
			} else if (bit[i] > bitk[i]) {
				bit[i] = '0';

			} else if (bit[i] == '1' && bitk[i] == '1') {
				bit[i] = '0';
				ans = Math.max(ans, calc(val, bit));
				bit[i] = '1';
			}
		}
		ans = Math.max(ans, calc(val, bit));
		System.out.println(ans);
	}

	static long calc(long[][] val, char[] bit) {
		long ret = 0;
		for (int i = 0; i < bit.length; i++) {
			ret += val[i][bit[i] - '0'];
		}
		return ret;
	}
}


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

int main(){
	int n, m;
	cin >> n >> m;
	int arr[n]{};
	while(m--){
		int a, b;
		cin >> a >> b;
		arr[--a]++;
		arr[--b]++;
	}
	for(int i = 0; i < n; i++) cout << arr[i] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define INF 10000000000000009
#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

signed main(){
    int N;
    int a[114514],b[114514],c[114514];
    cin >> N;
    REP(i,N){cin >> a[i] >> b[i] >> c[i];}
    int dpa[114514],dpb[114514],dpc[114514];
    dpa[0]=a[0];
    dpb[0]=b[0];
    dpc[0]=c[0];
    
    for(int i=1;i<N;i++){
        dpa[i]=a[i]+max(dpb[i-1],dpc[i-1]);
        dpb[i]=b[i]+max(dpa[i-1],dpc[i-1]);
        dpc[i]=c[i]+max(dpa[i-1],dpb[i-1]);
    }
    cout << max(dpa[N-1],max(dpb[N-1],dpc[N-1])) << endl;
    
    return 0;
}   


Measured memory_bytes: 5504
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int dp[100005][3];
int a[105],n;
int func(int i,int j){
    //cout<<i<<" "<<j<<endl;
    if(i==0){
        return 0;
    }

    if(dp[i][j]!=-1)
        return dp[i][j];

    int ans=0;
    for(int k=0;k<n;k++){
        if(a[k]<=i){
            if(j==1 and func(i-a[k],2)==0)
                ans=1;
            if(j==2 and func(i-a[k],1)==0)
                ans=1;
        }
    }

    // cout<<i<<" "<<j<<" "<<ans<<endl;
    return dp[i][j]=ans;

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

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

    memset(dp,-1,sizeof dp);
    if(func(k,1))
        cout<<"First";
    else
        cout<<"Second";
}

Measured memory_bytes: 6144
# coding: utf-8
# hello worldと表示する
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    n=I()
    lis=LI2()
    lis.sort()
    ans=0
    if n%2==0:
        x=n//2
        for i in range(x-1):
            ans+=2*(lis[n-i-1]-lis[i])
        ans+=lis[n-x]-lis[x-1]
        print(ans)
    else:
        if n==1:
            print(0)
            sys.exit()
        x=n//2
        ans1=0  
        ans2=0
        for i in range(x):
            ans1+=2*lis[n-i-1]
            ans2-=2*lis[i]
        for i in range(x-1):
            ans1-=2*lis[i]
            ans2+=2*lis[n-i-1]
        ans1-=lis[x]+lis[x-1]
        ans2+=lis[x]+lis[x+1]
        #print(ans1,ans2)
        print(max(ans1,ans2))
if __name__=="__main__":
    main()


Measured memory_bytes: 78484
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define MOD 1000000007
#define ALL(a) (a).begin(),(a).end()
#define ms(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10) 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge{ int from, to, cost; };

int n, l, t, b;
int masu[105];//0-start, 1-goal, 2-lose, 3-back
double dp[110][110]; //iターン目にjマスにいるときの期待値
const double ex = 1.0 / 6;

int main()
{
	while (cin >> n >> t >> l >> b, n)
	{
		ms(masu, -1);
		masu[0] = 0;
		masu[n] = 1;
		int a;
		REP(i, l)
		{
			cin >> a;
			masu[a] = 2;
		}
		REP(i, b)
		{
			cin >> a;
			masu[a] = 3;
		}
		ms(dp, 0);
		dp[0][0] = 1;

		REP(i, t)
		{
			REP(j, n)
			{
				FOR(k, 1, 7)
				{
					double exp = dp[i][j] * ex;
					int tmp = j + k;
					if (tmp > n) tmp = n - (tmp - n);
					if (masu[tmp] == 2) dp[i + 2][tmp] += exp;
					else if (masu[tmp] == 3) dp[i + 1][0] += exp;
					else dp[i + 1][tmp] += exp;
				}
			}
		}
		double sum = 0;
		REP(i, t + 1)
		{
			sum += dp[i][n];
		}
		cout << D10 << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1328
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
const int N = 2005;
const int MOD = 924844033;

int f[N];

int n, k;
int path_match[2 * N][N][2];

bool vis[N][2];
int path_len;
void DFS(int v, int side = 0)
{
    if(vis[v][side])
        return;

    path_len++;
    vis[v][side] = true;

    if(v + k <= n)
        DFS(v + k, side ^ 1);
    if(v - k >= 1)
        DFS(v - k, side ^ 1);
}

int dp[N], new_dp[N];

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

    cin >> n >> k;

    f[0] = 1;
    for(int i = 1; i <= n; i++)
        f[i] = (1LL * f[i - 1] * i) % MOD;

    path_match[0][0][0] = 1;
    for(int i = 1; i <= 2 * n; i++)
    {
        for(int j = 0; j <= i; j++)
        {
            path_match[i][j][0] = (path_match[i - 1][j][0] + path_match[i - 1][j][1]) % MOD;
            path_match[i][j][1] = path_match[i - 1][j - 1][0];
        }
    }

    dp[0] = 1;
    for(int i = 1; i <= n; i++)
    {
        if(!vis[i][0])
        {
            path_len = -1;
            DFS(i);
            for(int j = 0; j <= n; j++)
                new_dp[j] = 0;

            for(int j = 1; j <= (path_len + 1) / 2; j++)
                for(int k = n - j; k >= 0; k--)
                {
                    int x = (path_match[path_len][j][0] + path_match[path_len][j][1]) % MOD;
                    x = (1LL * dp[k] * x) % MOD;
                    new_dp[k + j] = (new_dp[k + j] + x) % MOD;
                }
            for(int j = 0; j <= n; j++)
                dp[j] = (dp[j] + new_dp[j]) % MOD;
        }
    }


    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        int x = (1LL * dp[i] * f[n - i]) % MOD;
        if(!(i & 1))
            x = MOD - x;

        ans = (ans + x) % MOD;
    }

    ans = (0LL + MOD + f[n] - ans) % MOD;
    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int
typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  string s;
  cin >> s;
  int res = 0;
  for (int i = 0; i < 4; i++)
  {
    if(s[i] == '+') res++;
    if(s[i] == '-') res--;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }

void solve(std::string s, std::string t){
    ll M = s.length(), N = t.length();
    vector<vll> dp(M+1, vll(N+1, 0));
    REP(i, M){
        REP(j, N){
            if(s[i] == t[j]) dp[i+1][j+1] = dp[i][j] +1 ; 
            else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
        }
    }

    ll i = M, j = N;
    string ans;
    while(i > 0 && j > 0){
        if(dp[i][j] == dp[i-1][j-1] + 1 && s[i-1]==t[j-1]) {
            ans.push_back(s[i-1]);
            i--; j--;
        }
        else if(dp[i][j] == dp[i-1][j]){
            i--;
        }
        else if(dp[i][j] == dp[i][j-1]){
            j--;
        }
    }
    //cout<<dp[M][N]<<endl;
    reverse(ALL(ans));
    cout<<ans<<endl;
}

int main(){
    std::string s;
    std::cin >> s;
    std::string t;
    std::cin >> t;
    solve(s, t);
    return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
typedef long long ll;
//
int main(){
    int n;
    cin >> n;
    for(int i = 1;;i++){
        if(i * (i + 1) / 2 >= n){
            cout << i;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main()
{
  long long k, n;

  cin >> k >> n;

  vector < long long > a(n);

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

  long long ans = k - a[n-1] + a[0];
  int max = k - a[n-1] + a[0];

  for(int i= 1; i < n; i++){
    ans += a[i] - a[i-1];
    if(max < a[i] - a[i-1]) max = a[i] - a[i-1];
    
  }

  ans -= max;
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

ll s,t;
ll p,q,m;
ll y;

int main(){
  cin>>s>>t;
  cin>>p>>q>>m;
  cin>>y;

  ll ans=y^s^t;
  cout<<ans<<endl;

  return 0;
}



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

int main(int argc, const char * argv[]) {
    
    int n;
    cin>>n;
    
    stack<int> st[n];
    
    int q;
    cin>>q;
    
    for(int i=0;i!=q;++i){
        int query;
        cin>>query;
        
        int t;
        cin>>t;
        
        switch (query) {
            case 0:
                int x;
                cin>>x;
                st[t].push(x);
                break;
            case 1:
                if(st[t].empty()) break;
                
                cout<<st[t].top()<<endl;
                break;
            case 2:
                if(st[t].empty()) break;
                
                st[t].pop();
                break;
        }
    }
    return 0;
}



Measured memory_bytes: 4296
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;

int main(){

    ll A, B, C; cin >> A >> B >> C;

    ll t_C = C - 1;

    ll ans = 0;



    if(A + B < C){
        ans = A + 2 * B + 1;
    }else if(A + B >= C){
        ans = C + B;
    }


    cout << ans << endl;

}

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

int main() {
  int a,b;
  cin >> a >> b;
  if(a==1||b==1) cout << 1 << endl;
  else if(a%2==0||b%2==0) cout << (long)a *(long) b / 2 << endl;
  else cout << (long)a *(long) b / 2 + 1 << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

# factorials
_nfact = 2 * (10 ** 5) + 10
facts = [0] * _nfact
facts[0] = 1
for i in range(1, _nfact):
    facts[i] = (facts[i - 1] * i) % MOD

def binomial(m, n):
    return DIV(facts[m], facts[n] * facts[m - n])

def main():
    N, A, B, C = LI()
    D = DIV(100, 100 - C)
    ans = 0
    ap, bp, abp = [1], [1], [POW(A + B, N)]
    for _ in range(0, N + 1):
        ap.append(ap[-1] * A % MOD)
        bp.append(bp[-1] * B % MOD)
        abp.append(abp[-1] * (A + B) % MOD)
    for m in range(N, 2 * N):
        x = binomial(m - 1, N - 1) * DIV(
            ap[N] * bp[m - N] + ap[m - N] * bp[N],
            abp[m - N]) % MOD
        y = (m * D) % MOD
        ans = (ans + (x * y) % MOD) % MOD
    return ans

print(main())

Measured memory_bytes: 22956
#include <bits/stdc++.h>
#define repl(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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() {
    ll n,t;
    cin >> n >> t;
    vector<ll> a(n,0);
    rep(i,n)cin >> a[i];
    ll res = 0;
    rep(i,n-1){
        if(a[i] + t >= a[i+1])res += a[i+1] - a[i];
        else res += t;
    }
    cout << res+t << endl;
    return 0;
}

Measured memory_bytes: 1792
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N; cin>>N;
    
    ll fac[N + 1] = {0};
    
    for(ll i=2;i<N;++i)
    {
        for(ll j=i;j<=N;j += i)
        {
            fac[j]++;
        }
    }
    
    ll ans = 0;
    for(ll i=1;i<N;++i)
    {
        ll req = N - i;
        //all possible factors of req
        ans += (fac[req] + 1);
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 11432
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	string s;
	cin >> s;
	int l,w=0;
	l = s.length();
	REP(i,l){
		if(s[i]=='o'){
			w++;
		}
	}
	if(w + (15-l) >= 8){
		println("YES");
	}else{
		println("NO");
	}
	return 0;
}


Measured memory_bytes: 256
arr = list(map(int, input().split()))
count_5 = 0
count_7 = 0
for i in arr:
    if i == 5:
        count_5 += 1
    if i == 7:
        count_7 += 1
if count_5 == 2 and count_7 == 1:
    print("YES")
else:
    print("NO")


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

// #define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (stderr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 1e9, MOD = INF + 7 /* INF - 1755647 */;

/////////////////////////////////////////////////////////////////////

const int N = 3e5 + 20;

int32_t main() {

    sync;

    int n; cin >> n;
    int ans = 0, mx = 0;
    while(n--) {
        int x; cin >> x;
        if (x >= mx) ans++;
        mx = max(x, mx);
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L.at(i);
    }

    sort(L.begin(), L.end());
    int ans;
    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            ans += lower_bound(L.begin() + j + 1, L.end(), L.at(i) + L.at(j)) - upper_bound(L.begin() + j + 1, L.end(), abs(L.at(i) - L.at(j)));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
"""
1度の操作で最大+2できる
隣り合う箇所はN-1
LないしRが連続している箇所をグループとして見ると、求める数は
  N-1-隣り合うグループが異なっている場所の個数
= N-1-(グループの個数-1)
"""
import sys
sys.setrecursionlimit(10**6)
n, k = map(int, input().split())
s = input()

score = 0
for i in range(n-1):
    if s[i] == s[i+1]: score += 1

ans = min(score+2*k, n-1)
print(ans)

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

int main(){
	
	for(int a,b;;){
		cin>>a>>b;
		if(a==0 && b==0)break;
		if(a>b)cout<<b<<" "<<a<<endl;
		else cout<<a<<" "<<b<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1160
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e12;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

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

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

int main(){
    ll N; cin >> N;
    vl a(N, 0); REP(i, N) cin >> a[i];
    vvl dp(N+1, vl(2, 0));
    dp[2][0] = a[0] + a[1];
    dp[2][1] = - (a[0] + a[1]);
    FOR(i, 2, N){
        dp[i+1][0] = max(dp[i][0]+a[i], dp[i][1]+a[i]);
        ll t0 = dp[i][0] - a[i-1] + (-a[i-1]-a[i]);
        ll t1 = dp[i][1] + a[i-1] + ( a[i-1]-a[i]) ;
        dp[i+1][1] = max(t0, t1);
    }
    cout << max(dp[N][0], dp[N][1]) << endl;
    return 0;
}


Measured memory_bytes: 6528