akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
static const int mod = 1e9 + 7;
using ll = long long;
vector<vector<ll>> comb(int n, int r) {
    vector<vector<ll>> v(n + 1,vector<ll>(n + 1, 0));
    for (int i = 0; i < v.size(); i++) {
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for (int j = 1; j < v.size(); j++) {
        for (int k = 1; k < j; k++) {
            v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]) % mod;
        }
    }
    return v;
}
int main() {
    ll N, K;
    cin >> N >> K;
    auto c = comb(2000, 2000);
    for (int i = 1; i <= K; i++)
        cout << (c[K-1][i-1] * c[N-K+1][i]) % mod << endl;
}

Measured memory_bytes: 31616
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

S = rs()

ans = 0
cnt = 0
for c in S:
	if c == 'R':
		cnt += 1
	else:
		cnt = 0
	ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 67988
//write for s26

#include<bits/stdc++.h>
using namespace std;
int main() {
	int h1,m1,h2,m2,k,t1,t2;
	cin>>h1>>m1>>h2>>m2>>k;
	t1=h1*60+m1;t2=h2*60+m2;
	if(t2-k==0) {
		cout<<0<<endl;
		return 0;
	}
	int ram=t2-k;
	cout<<abs(ram-t1)<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int sum[110][26];

signed main()
{
    int N; cin>>N;
    string s; cin>>s;

    REP(i,N){
        sum[i+1][s[i]-'a']++;
    }
    REP(i,N){
        REP(j,26) sum[i+1][j]+=sum[i][j];
    }

    int ans=0;
    for(int i=1;i<=N-1;i++){
        int cnt=0;
        REP(j,26){
            if(sum[i][j]>0 and sum[N][j]-sum[i][j]>0){
                cnt++;
            }
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
using namespace std;
const int N = 510;
int n, m;
char s[N][N], a[N][N], b[N][N];
int main() {
	scanf("%d%d",&n,&m);
	rep(i,1,n) scanf("%s",s[i] + 1);
	rep(i,1,n) rep(j,1,m) a[i][j] = b[i][j] = '.';
	rep(i,1,n) a[i][1] = b[i][m] = '#';
	rep(i,1,n) if (i & 1) {
		rep(j,1,m - 1) a[i][j] = '#';
	} else {
		rep(j,2,m - 1) b[i][j] = '#';
	}
	rep(i,1,n) rep(j,1,m) if (s[i][j] == '#') a[i][j] = b[i][j] = '#';
	rep(i,1,n) printf("%s\n",a[i] + 1);
	printf("\n");
	rep(i,1,n) printf("%s\n",b[i] + 1);
	return 0;
}

Measured memory_bytes: 1536
N,W = map(int,input().split())
c = [tuple(map(int,input().split())) for i in range(N)]
DP = [[0 for i in range(W+1)] for i in range(N+1)]

for i in range(N):
    for w in range(W+1):
        if w-c[i][0] < 0:
            DP[i+1][w] = DP[i][w]
        else:
            DP[i+1][w] = max(DP[i][w-c[i][0]]+c[i][1],DP[i][w])
print(DP[N][W])

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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main() {
    string s_dash;
    string t;

    cin >> s_dash >> t;

    string min = s_dash;
    
    for (auto& i : min) {
            i = 'z'+1;
    }

    string max = min;

    if (s_dash.size() < t.size()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    for (int i = 0; i < (int)(s_dash.size() - t.size() + 1); i++) {
        bool flg = true;
        for (int j = 0; j < (int)t.size(); j++) {
            if (s_dash[i + j] != '?' && s_dash[i + j] != t[j]) {
                flg = false;
                break;
            }
        }

        if (flg) {
            string tmp = s_dash;
            tmp.replace(tmp.begin() + i, tmp.begin() + i + t.size(), t);
            for (auto& j : tmp) {
                if (j == '?') {
                    j = 'a';
                }
            }

            if (tmp < min) {
                min = tmp;
            }
        }
    }

    if (min == max) {
        cout << "UNRESTORABLE" << endl;
    } else {
        cout << min << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}


macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"2 2
2 1 2
1 2
0 1"# => r#"1"#,
r#"2 3
2 1 2
1 1
1 2
0 0 1"# => r#"0"#,
r#"5 2
3 1 2 5
2 2 3
1 0"# => r#"0"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: i64,
        b: i64,
    }

    let x = a + b;
    let y = a - b;
    let z = a * b;

    std::cmp::max(std::cmp::max(x, y), z).to_string()
}

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

int main() {
    int x;
    cin>>x;
    if(x >=400 && x<600)    cout<<8<<endl;
    else if(x >=600 && x<800)    cout<<7<<endl;
    else if(x >=800 && x<1000)    cout<<6<<endl;
    else if(x >=1000 && x<1200)    cout<<5<<endl;
    else if(x >=1200 && x<1400)    cout<<4<<endl;
    else if(x >=1400 && x<1600)    cout<<3<<endl;
    else if(x >=1600 && x<1800)    cout<<2<<endl;
    else if(x >=1800 && x<2000)    cout<<1<<endl;
    return 0;
}

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

int main(){
  int H,W;

  char list[101][101];
  vector<int> anslist_i;
  vector<int> anslist_j;


  cin >>H>>W;

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >>list[i][j];
    }
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(list[i][j] == '#'){
        anslist_i.push_back(i);
        break;
      }
    }
  }

  for(int i = 0; i < W; i++){
    for(int j = 0; j < H; j++){
      if(list[j][i] == '#'){
        anslist_j.push_back(i);
        break;
      }
    }
  }


  for(int i = 0; i < (int)anslist_i.size();i++){
    for(int j = 0;j < (int)anslist_j.size();j++){
      cout <<list[anslist_i[i]][anslist_j[j]];
    }
    cout <<'\n';
  }


  cout <<endl;
  return 0;
}


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

int main()
{
  int64_t N,A,B ;
  cin>>N>>A>>B ;
  
  if((B-A)%2==0) cout<<(B-A)/2<<endl ;
  else{
    if(A<=N-B) cout<<A+(B-A-1)/2<<endl ;
    else cout<<N-B+1+(B-A-1)/2<<endl ;
  }
  
  return 0 ;
}


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

const int MAX = 100005;

int main() {
  // input
  int N;
  int A[MAX];
  int counting[MAX] {0};
  cin >> N;
  int maxv {0};
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (maxv < A[i]) maxv = A[i];
    counting[A[i]]++;
  }

  int ans {0};
  int tmp_ans {0};

  for (int i = 1; i < MAX-1; i++) {
    tmp_ans = counting[i-1] + counting[i] + counting[i+1];
    if (tmp_ans > ans) ans = tmp_ans;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3932
#include <iostream>
using namespace std;
int main() {
    int n;
    std::cin >> n;
    int d[n];
    for(int i=0; i<n; i++) std::cin >> d[i];
    
    int ans = 0;
  
    for (int i=0; i<n; i++) {
    	for (int j=i+1; j<n; j++) {
            ans = ans + d[i]*d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int A, B, C, D; std::cin >> A >> B >> C >> D;
  std::cout << std::min(A,B) + std::min(C,D) << std::endl;

  return 0;
}


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

int main(){
	int n;
	cin >> n;
	for(int i=1;i<=100;i++){
		int temp=i*1000;
		if(temp>=n){
			cout << temp-n << endl;
			return 0;
		}
	}
	return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main()
{

    lint a, b;
    cin >> a >> b;

    lint ans, tmp;

    for (int i = 1; i < 1001; i++)
    {
        if((i*8-(i*8)%100)==a*100&&(i*10-(i*10)%100)==b*100){
            cout << i << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";

    return 0;
}

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


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

    cout<< ((x<1200) ? "ABC" : "ARC") <<endl;

    return 0;
}

Measured memory_bytes: 256
require 'pp'

n, m = gets.chomp!.split(" ").map(&:to_i)

if n >= 3 && m >= 3
    # 4隅は4隣接なので表
    # 4隅以外の周辺は6隣接なので表
    # それ以外は9隣接なので裏
    sum = (n*m) - ((n * m) - ((n - 2) * (m - 2)))
elsif n == 2 || m == 2
    # 隣接はすべて偶数なので0
    sum = 0
else # 行列どちらか，あるいは両方が1
    # 両端は2，それ以外は3
    if n == 1 && m == 1
        sum = 1
    else
        sum = [n, m].max - 2
    end
end

puts sum


Measured memory_bytes: 2044
# -*- coding: utf-8 -*-
import math
N, A, B = map(int, input().split())
V = list(map(int, input().split()))
V.sort(reverse=True)
maxavg = sum(V[:A])/A
print(maxavg)
min = V[A-1]
ltAnum = 0
minnum = 0
for i in range(N):
    if V[i] > min:
        ltAnum = ltAnum + 1
    elif V[i] == min:
        minnum = minnum + 1
    else:
        break
#print(ltAnum)
#print(minnum)

import math
def nCr(n,r):
    f = math.factorial
    return f(n)//f(r)//f(n-r)

c_min = 0
import itertools
if ltAnum > 0:
    c_min = nCr(minnum, A-ltAnum)
if ltAnum == 0:
    for j in range(A, B+1):
        if minnum < j:
            break
        else:
            c_min = c_min + nCr(minnum, j)
print(c_min)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int a,b;
    cin>>a>>b;
    if(a>12){
        cout<<b<<endl;
    }
    else if(a>5){
        cout<<b/2<<endl;
    }
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int main()
{
	cin>>s1>>s2;
	bool flag=false;
	for(int i=0;i<s1.size();i++)
	{
		if(s1==s2)
		{
			flag=true;
			break;
		}
		char c=s1[s1.size()-1];
		s1.erase(s1.size()-1,1);
		s1=c+s1;
	}
	if(flag)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,a,b) for(ll i=(a);i<(b);i++)
#define frr(i,a,b) for(ll i=(a-1);i>=(b);i--)
#define vi vector<int>
#define de deque<int>
#define del deque<ll>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define mpp map<ll,ll>
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define ln(a) a.length()
#define sz(a) a.size()
#define endl "\n"
int M=1000000007;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

int n,k;cin>>n>>k;
int a[n];f(i,0,n)cin>>a[i];
bool dp[k+1];
memset(dp,false,sizeof dp);
f(i,1,k+1)
{
    f(j,0,n)
    {
        if(i>=a[j] && dp[i-a[j]]==false)
        {
            dp[i]=true;
        }
    }
}
if(dp[k]==true){cout<<"First"<<endl;}
else{cout<<"Second"<<endl;}
}



Measured memory_bytes: 384
def binomial_coefficients(n: int, A: list) -> tuple:
    max_A = max(A)
    max_r, max_a = 0, 0
    for a in A:
        if a == max_A:
            continue
        r = min(a, max_A - a)
        if max_r < r:
            max_r = r
            max_a = a

    return max_A, max_a


if __name__ == "__main__":
    n = int(input())
    A = list(map(int, input().split()))
    ai, aj = binomial_coefficients(n, A)
    print(ai, aj)


Measured memory_bytes: 14060
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)     for(lint i=n-1;i>=0;--i)
#define REPR1(i,n)    for(lint i=n;i>0;--i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
bool is_prime(int n)
{
	REPI(i, 2, sqrt(n) + 1)if (n % i == 0)return false;
	return true;
}
int main()
{
	int n = in();
	int cnt = 0;
	REP(i, n)if (is_prime(in()))cnt++;
	cout << cnt << endl;
}


Measured memory_bytes: 3012
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	

	int a,b,c;
	cin >> a>>b>>c;
	string s = "NO";
	if (a + b + c == 17 && a * b * c == 175) {
		s = "YES";
	}
	
	cout << s<< endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}
int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;

    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }

    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}


void solve(std::string s){
    replace(s.begin(),s.end(),',',' ');
    cout << s << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod 1000000007
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
int x[100000],y[100000];
signed main(){
	int n,m,ans=0,ans2=0;
	cin>>n>>m;
	f(i,n){
		cin>>x[i];
	}
	f(i,m){
		cin>>y[i];
	}
	int a=n-1,b=n-1;
	for(int i=1;i<n;i++){
		b-=2;
		ans+=a*(x[i]-x[i-1]);
		ans%=mod;
		a+=b;
	}
	a=m-1,b=m-1;
	for(int i=1;i<m;i++){
		b-=2;
		ans2+=a*(y[i]-y[i-1]);
		ans2%=mod;
		a+=b;
	}
	cout<<ans*ans2%mod<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

//--global--//

int n;
static const int maxN = 16;
int d[maxN];
int dp[1 << maxN][maxN];
int a[maxN][maxN+1];

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

// s =　今までに通った集合, v = 今の頂点
int solve(int s, int v, int *d2){
    //cout << "通った:" << bitset<8>(s) << ", " << v  << " ";
    // v を通ったからdを更新する

    int d3[maxN];
    rep(i, n){
        d3[i] = d2[i];
    }
    if(v == -1){
        v = 0;
    }
    else{
        rep(i, n){
            d3[i] = min(d3[i], a[i][v+1]);
        }
    }
    //
    if(dp[s][v] != -1){
        //cout << "you have traveld already" << endl;
        return dp[s][v];
    }

    if(s == (1 << n)-1){
        //cout << "finish" << endl;
        return dp[s][v] = 0; 
    }
    //cout << endl;

    int res = INTINF;
    rep(u, n){
        if(!(s >> u & 1)){
            //cout << "通る:" << bitset<8>(s) << ", " << v  << ", " << d3[u] << endl;
            res = min(res, solve(s | 1 << u, u, d3) + d3[u]);
            //cout << "res" << res << endl;
        }
    }
    return dp[s][v] = res;
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//
    
    while(1){
        cin >> n;
        if(n == 0)break;
        memset(dp, -1, sizeof(dp));

        rep(i, n){
            rep(j, n+1){
                //if(j)cout << " ";
                cin >> a[i][j];
                //cout << a[i][j];
            }
            d[i] = a[i][0];
            //cout << endl;
        }
        int res = solve(0, -1, d);
        cout << res << endl;
    }
    return 0;
}



Measured memory_bytes: 7192
N,M=map(int,input().split())

Wish=[]
for i in range(M):
  Wish.append(list(map(int,input().split())))
sorted_wish=sorted(Wish,key=lambda x:x[1])

bridge=0
count=0
for wish in sorted_wish:
  left=wish[0]
  right=wish[1]
  if left>=bridge and right>bridge:
    count+=1
    bridge=right
print(count)

Measured memory_bytes: 29832
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;

//おまじない



int main() {

	char c[20];
	cin >> c;
	c[5] = ' ';
	c[13] = ' ';

	cout << c << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<((a+b>=c)?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    ll a;
    ld b;
    cin >> a >> b;
    ll res = a*b;
    printf("%ld\n", res);
    // cout << (ll)a*b << "\n";
    return 0;
}

Measured memory_bytes: 3816
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>

using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;

int main(){

    int n; cin >> n;
    string ans="No";
    rep(i,10)rep(j,10){
        if(i*j==n) ans="Yes";
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59



int main(){
  ll i,j;
  ll n,l;
  cin>>n>>l;
  ll M=Mod;
  ll m;
  ll ans=0;
  for(i=1;i<=n;i++){
    ans+=l+i-1;
  }
  if(l>0) ans-=l;
  else if(l+n-1<0) ans-=l+n-1;
  cout<<ans<<endl;
  return 0;  
}

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

using ll = long long;

int main() {
	int N, K;
	scanf ("%d %d", &N, &K);
	vector < int > P (N);
	for (int & x : P) scanf ("%d", &x);
	ll maxSum = 0LL, sum = 0LL;
	for (int i = 0; i < K; i++) {
		sum += P[i];
	}
	maxSum = sum;
	for (int i = K; i < N; i++) {
		sum -= P[i - K];
		sum += P[i];
		maxSum = max (maxSum, sum);
	}
	double answer = (double) (maxSum + K) / 2.0;
	printf ("%.9lf\n", answer);
	return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a != c) {
        cout << "Yes" << endl;
    } else if (b == c && b != a) {
        cout << "Yes" << endl;
    } else if (c == a && c != b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

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

    for(int i=0;i<N;i++){
        if(p.at(i)!=i+1) count++;
    }
    if(count<=2){
        cout<<"YES"<<endl;
        return 0;
    }
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#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;

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  rep(i,N) cin>>A[i];

  int ans=0;
  for(int i=0;i<N;i++){
    if(A[i]>=K) ans++;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 640
// Created by ahmed_drawy on 11/09/19.
///dp educational contest atcoder
#include <bits/stdc++.h>
#include <string.h>
#pragma clang diagnostic push
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
using namespace std;
#define lp(i,start , end)       for(int i = start ; i<end ; ++i)
#define lllp(i,start , end)       for(ll i = start ; i<end ; ++i)
#define inN(arr ,  n) for(int i = 0 ; i< n ; ++i)  cin>>arr[i];
#define Rlp(i,start , end)      for(int i = start ; i>end ; --i)
#define all(v)                   ((v).begin(),(v).end())
#define sz(v)                  (int)((v).size())
#define clr(v,d)                memset(v , d , sizeof(v))
#define inf 0x3f3f3f3f
//#define dbg (v)    for(auto it : v)cout<<it<<' ';
typedef long long               ll;
typedef vector<int>             vi;
typedef vector  <ll>            vll;
typedef vector<vector<int> >    adj;
typedef pair<int ,int>          pii;
const double EPS =1e-7;
const int OO = 1e6;
#define endl '\n'
#define cint(c) (int)c -'0';
#define itc(c) (char)c +'A';
bool sortpair( const pair<int , int> & x, const pair<int , int> & y){
    return  x.first != y.first ? x.first < y.first : x.second > y.second ;
}
int dcomp(double x , double y){
    return fabs(x-y) <= EPS? 0: x>y?1:-1;
}

void smile() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
//    freopen("/home/tw3/Desktop/Desktop/training/in.txt", "r", stdin);
//    freopen("/home/tw3/Desktop/Desktop/training/out.txt" , "w" , stdout);
#endif
}
#define fastin smile()

int n , m;
const int N = 3000 +3;
ll dp[N][N];
string s, t;
ll lcs(int i , int j ){
    if(i == n || j ==m )
        return 0 ;
    ll &ret = dp[i][j];
    if(~ret)
        return ret;
    ret = 0;
    if(s[i] == t[j])
        ret =1 +  lcs(i+1 , j+1);
    else {
        ret = max(ret, lcs(i + 1, j));
        ret = max(ret, lcs(i, j + 1));
    }
    return ret;
}
void build(int i , int j){
    if(i == n || j ==m )
        return  ;
    if(s[i] == t[j]) {
        lcs(i + 1, j + 1);
        cout << s[i];
        build(i+1, j+1);
        return ;
    }
    if(lcs(i+1 , j) > lcs(i , j+1))
        build(i+1, j);
    else build(i, j+1);
    return ;

}
int main() {
    fastin;
    cin >> s >> t;
    n = sz(s), m = sz(t);
    clr(dp , -1);
//    lcs(0,0);
    build(0,0);


}

Measured memory_bytes: 71040
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.Queue;
class Main {
    public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String[] t = scan.nextLine().split("\\s");
		int num = Integer.parseInt(t[0]);
		int Dectime = Integer.parseInt(t[1]);
		
		Queue<Process> queue = new ArrayDeque<Process>();
		for(int i = 0; i < num; i++){
			String[] str = scan.nextLine().split("\\s");
			
			Process pro = new Process(str[0], Integer.parseInt(str[1]));
			queue.offer(pro);
		}
		
		int result = 0;
		
		while(queue.size() > 0){
			Process pro = queue.poll();
				
			result += Dectime;
			
			if((pro.time = pro.time - Dectime) > 0){
				queue.offer(pro);
			}else{
				result += pro.time;
				System.out.println(pro.name + " " + result);
			}
			
		}
	}
}

class Process{
	String name = null;
	int time = 0;
	
	Process(String n, int t){
		this.name = n;
		this.time = t;
	}
}

Measured memory_bytes: 104732
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
int even_string(string s,int n)
{
	n/=2;
	rep(i,n)
	{
		if(s[i]!=s[i+n])
		{
			return 0;
		}
	}
	return 1;
}
int main()
{
	string S;
	cin>>S;
	int tail=S.size()-2;
	int ans=0;
	while(tail>0)
	{
		if(even_string(S,tail))
		{
			ans=tail;
			break;
		}
		tail-=2;
	}
	cout<<ans<<endl;
}

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

int main(){
  int n,x,t;
  cin >> n >> x >> t;
  if(n%x==0)cout << n/x*t << endl;
  else cout << (n/x+1)*t << endl;
  return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
    int n,h[500];
    long long res=1;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&h[i]);
    sort(h, h+n);
    for(int i=n-1;i>=0;i--){
        if(i>=n-4) res+=h[i];
        else if(h[i]>(n-i-1)/4) res+=h[i]-(n-i-1)/4;
    }
    printf("%lld\n",res);
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 1e9 + 7;

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

	ll n;
	cin >> n;

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

	if(t[n-1] != a[0]){
		cout << 0 << endl;
		return 0;
	}

	ll ans = 1;
	for(int i = 1; i < n-1; i++){
		if(t[i] > t[i-1]){
			if(t[i] > a[i]){
				cout << 0 << endl;
				return 0;
			}
		}else if(a[i] > a[i+1]){
			if(a[i] > t[i]){
				cout << 0 << endl;
				return 0;
			}
		}else{
			// cout << min(t[i], a[i]) << endl;
			ans *= min(t[i], a[i]);
			ans %= MOD;
		}
	}

	cout << ans << endl;	
}

Measured memory_bytes: 1792
<?php
fscanf(STDIN, "%d %d", $count, $start_x);

$results = [];
$start = (-1 * ($count - 1));
$total_count = ($count - 1) + $count + $start;
for ($i = $start; $i < $total_count; $i++) {
    $results[] = $start_x + $i;
}
//rsort($results);

echo implode(' ', $results) . "\n";


Measured memory_bytes: 4728
n=int(input())
arr=[int(input()) for _ in range(n)]
lmax=[0]*n
rmax=[0]*n
tmp=arr[0]
for i in range(1,n):
  lmax[i]=tmp
  tmp=max(tmp,arr[i])
tmp=arr[-1]
for i in range(n-2,-1,-1):
  rmax[i]=tmp
  tmp=max(tmp,arr[i])
for i in range(n):
  print(max(lmax[i],rmax[i]))

Measured memory_bytes: 15656
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

const int N = 510;
int dp[N][N], a[N][N];

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, m, q;
  cin >> n >> m >> q;
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    a[l][r]++;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      dp[i][j] = a[i][j] + dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
    }
  }
  
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    cout << dp[r][r] - dp[r][l - 1] - dp[l - 1][r] + dp[l - 1][l - 1] << "\n";
  }
}



Measured memory_bytes: 4992
#include<stdio.h>
#include<string.h>
#define LENGTH 100005

typedef struct pp{
  char na[10];
  int time;
}X;

X A[LENGTH];
int top,end,num;

void enqueue(X a){
  A[end] = a;
  end = (end +1 )% LENGTH;
}

X dequeue(){
  X a= A[top];
  top = (top + 1) % LENGTH;
  return a;
}

int min(int a, int b){
  return a < b? a:b;
}

int main(){
  int elaps =0,ci;
  int i,q;
  X ui;
  scanf("%d %d",&num,&q);

  for(i=1;i<=num;i++){
    scanf("%s",&A[i].na);
    scanf("%d",&A[i].time);
  }

  top = 1;
  end = num +1;

  while(top != end){
    ui = dequeue();
    ci = min(q, ui.time);
    ui.time -= ci;
    elaps += ci;
    if(ui.time>0) enqueue(ui);
    else{
      printf("%s %d\n",ui.na,elaps);
    }
  }
  return 0;
}



Measured memory_bytes: 3288
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n, k; cin>>n>>k;
    vector<int> v;
    for(int i=1; i*i<=n; i++){
        v.emplace_back(i);
        v.emplace_back(n / i);
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    vector<int> num;
    num.emplace_back(1);
    for(int i=0; i+1<v.size(); i++){
        num.emplace_back(v[i+1] - v[i]);
    }

    int m = num.size();
    vector<vector<ll>> dp(k+1, vector<ll>(m+1, 0));
    dp[0][0] = 1;

    for(int i=0; i<k; i++){
        vector<ll> sumdp(m+1, 0);
        for(int j=0; j<m; j++){
            sumdp[j+1] = sumdp[j] + dp[i][j];
            sumdp[j+1] %= MOD;
        }

        for(int j=0; j<m; j++){
            dp[i+1][j] = sumdp[m-j] * num[j];
            dp[i+1][j] %= MOD;
        }
    }

    ll ans = 0;
    for(int i=0; i<m; i++){
        ans += dp[k][i];
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 51452
#include<bits/stdc++.h>
#define LL long long
#define mod 1000000007
#define maxn 100010
using namespace std; 

int a[maxn];

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	bool ok = true;
	bool ye = true;
	for(int i = 1; i < n; ++i){
		if(a[i - 1] - a[i] > 1){
			ok = false;
		}
		if(a[i - 1] - a[i] == 1){
			if(ye){
				ye = false;
			}
			else{
				ok = false;
			}
		}
		if(a[i - 1] < a[i]){
			ye = true;
		}
	}
	if(ok){
		puts("Yes");
	}
	else{
		puts("No");
	}
	return 0;
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int n,y;
  cin >> n >> y;
  int a=-1,b=-1,c=-1;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      if(i+j<=n&&1000*i+5000*j+10000*(n-i-j)==y){
        a=i;
        b=j;
        c=n-i-j;
      }
    }
  }
  cout << c << " " << b << " " << a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Nmax 100005
#include <cmath>
#define INF 0x3f3f3f3f

using namespace std;

ifstream f("1.in");
ofstream g("1.out");

int n, dp[Nmax], h[Nmax];

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> h[i];
        dp[i]=INF;
    }
    dp[1]=0;
    for (int i = 1; i <= n; i++)
    {
        dp[i+1]=min(dp[i+1], dp[i]+abs(h[i]-h[i+1]));
        dp[i+2]=min(dp[i+2], dp[i]+abs(h[i]-h[i+2]));
    }
    cout << dp[n];
}


Measured memory_bytes: 1024
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
int check(int num ){
    
    int num1 = pow(num , 0.2);
    
    int ans = num1;
    
    num1 = pow(num1,5);
    
    if(num1 == num){
        return ans;
    }
    
    return 0;
}
int32_t main(){
    int n,m;
    cin>>n>>m;
    int data[n+1];
    for(int i =0 ; i < n ; i++ )
    cin>>data[i+1];
    
    int val[n+1];
    // vector<int>v[n+1];
    for(int i  = 1 ; i <= n ; i++ ){
        val[i] = -1e9;
    }
    for(int i =0 ; i < m ; i++ ){
        int x,y;
        cin>>x>>y;
        
        val[x] = max({val[x] , data[y]});
    
        val[y] = max({data[x],val[y]});
    }
    int ans =0 ;
    int mark[n+1];
    for(int i=1;i<=n;i++)mark[i]=1;
    for(int i =1;i<=n ;i ++ ){
        if(data[i]>val[i])ans++;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 6012
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(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
S=get.uniq!
puts yn_judge(S.size==4,"Four","Three")

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> ans(N);
    ll sum = 0;
    rep(i, N){cin >> A.at(i); sum += A.at(i);}
    sum /= 2;
    ll cnt = 1;
    while (true){
        if (cnt < N){sum -= A[cnt]; cnt += 2;}else{break;}
    }
    ans[0] = sum * 2;
    rep(i, N-1){ans.at(i+1) = (A.at(i) - (ans.at(i) / 2)) * 2;}
    rep(i, N){cout << ans.at(i) << " ";}
}

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


Measured memory_bytes: 2944
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x){
  S[++top]=x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a, b;
  top = 0;
  char s[100];

  while(scanf("%s", s)!=EOF){
    if(s[0]=='+'){
      b=pop();
      a=pop();
      push(a+b);
    }else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }else if(s[0]=='*'){
      b=pop();
      a=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }

  printf("%d\n", pop());
  return 0;
}


Measured memory_bytes: 2704
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long answer = 1;
        for (int i = 1; i <= N; i++) {
            answer = answer * i % 1000000007;
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define int ll

int a,b,c;

signed main(){
  cin>>a>>b>>c;

  if(a+b>=c){
    cout<<b+c<<endl;
  }
  else{
    cout<<a+2*b+1<<endl;
  }
}

Measured memory_bytes: 256
N = int(input())
ax = list(map(int,input().split()))
 

boxin = []
bx = [0 for _ in range(N+1)]
for cnt in range(N, 0, -1):
    a = ax[cnt-1]
    i = 2
    memo_cnt = 0
    while 1:
        test_val = i * cnt
        if test_val > N:
            break
        if bx[test_val]:
            memo_cnt += 1
        i += 1
    if a != memo_cnt % 2:
        boxin.append(cnt)
        bx[cnt] = 1

 
box = len(boxin)
print(box)
if box != 0:
    boxin.reverse()
    print(' '.join(map(str, boxin)))
    
    

Measured memory_bytes: 19888
def run(s):
    n = 1000001
    a = [0, s]
    for i in range(2, n):
        pre = a[i-1]
        if pre % 2 == 0:
            a.append(pre // 2)
        else:
            a.append(3*pre + 1)
    ret_dic = {}
    ret = None
    for i in range(1, n):
        ai = a[i]
        if ai in ret_dic:
            ret = i
            break
        else:
            ret_dic[ai] = 1
    return ret


def main():
    s = int(input())
    print(run(s))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10900
#include <stdio.h>  
#include <string.h>
#define M 500000
#define NIL -1

typedef struct node_tbl
{
	int key,p,l,r;
} node;

node T[M+1];
int root=NIL;
int size=0;

void insert(int k){
	int y=NIL;
	int x=root;
	int z=size++;

	T[z].key=k;
	T[z].l=NIL;
	T[z].r=NIL;

	while (x!=NIL)
	{
		y=x;
		if (T[z].key<T[x].key) x=T[x].l;
		else                   x=T[x].r;
	}

	T[z].p=y;
	if (y==NIL) root=z;
	else{
		if (T[z].key<T[y].key)
			T[y].l=z;
		else
			T[y].r=z;
	}
}

int find(int u){
    int id,x=0;
    scanf("%d",&id);
    while(1){
        if(T[x].key==0){
            return NIL;
        }
        else if(T[x].key==id){
            return x;
        }
        else if(id<T[x].key) x=T[x].l;
        else if(id>T[x].key) x=T[x].r;   
    }
}

int Min(int x){
    while(T[x].l!=NIL) x=T[x].l;
    return x;
}

int Successor(int x){
    int y;
    if(T[x].r!=NIL) return Min(T[x].r);
    
    y=T[x].p;
    while(y!=NIL && x==T[y].r){
        x=y;
        y=T[y].p;
    }
    return y;
}


void delete(){
    int x,y,z;
    z=find(root);
    //printf("|%d|",z);
    
    if(T[z].l==NIL || T[z].r==NIL) y=z;
    else y=Successor(z);
    
    if(T[y].l!=NIL) x=T[y].l;
    else            x=T[y].r;
    
    if(x!=NIL)      T[x].p=T[y].p;
    
    if(T[y].p==NIL) root=x;
    else if(y==T[T[y].p].l) T[T[y].p].l=x;
    else if(y==T[T[y].p].r) T[T[y].p].r=x;

    if(y!=z) T[z].key=T[y].key;
    
}


void inorder(int u){
	if (u==NIL) return;
	inorder(T[u].l);
	printf(" %d", T[u].key);
	inorder(T[u].r);
}

void preorder(int u){
	if (u==NIL) return;
	printf(" %d", T[u].key);
	preorder(T[u].l);
	preorder(T[u].r);
}

int main(){
	char o[8];
	int n,x,i;
	scanf("%d", &n);
	
	for (i=0;i<n;i++){
		scanf("%s",o);
		if(!strcmp("insert",o)){
			scanf("%d",&x);
			insert(x);
        }
        else if(!strcmp("find",o)){
            if(find(root)==NIL) printf("no\n");
            else                printf("yes\n");
            
        }
        else if(!strcmp("print",o)){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
        else if(!strcmp("delete",o)) delete();
	}
	return 0;
}


Measured memory_bytes: 7948
from sys import stdin

for line in stdin:
    H, W = map(int, line.rstrip().split(' '))
    if 0 == H == W:
        break

    for i in range(H):
        for j in range(W):
            print('#' if (i+j)%2==0 else '.', end='')
        print()

    print()

Measured memory_bytes: 8896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stdio.h>
#include <math.h>
#include <string>
using namespace std;

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> problemNumber;
	vector<string> result;
	int problemTmp;
	string resultTmp;
	for (int  i = 0; i < M; i++)
	{
		cin >> problemTmp >> resultTmp;
		problemNumber.push_back(problemTmp - 1);
		result.push_back(resultTmp);
	}
	// 0: AC, 1: WAの数
	vector<vector<int>> finalResult(N, vector<int>(2, 0));
	for (int i = 0; i < M; i++) {

		if (result.at(i) == "AC") {
			// ACは一回だけカウント
			if (finalResult.at(problemNumber[i]).at(0) == 0) {
				finalResult.at(problemNumber[i]).at(0) = 1;
			}
		}
		else {
			// WA
			if (finalResult.at(problemNumber[i]).at(0) >= 1) {
				continue;
			}
			finalResult.at(problemNumber[i]).at(1) = finalResult.at(problemNumber[i]).at(1) + 1;
		}
	}
	long long AC = 0;
	long long WA = 0;
	for (int i = 0; i < N; i++) {
		if (finalResult.at(i).at(0) == 1) {
			++AC;
			WA = WA + finalResult.at(i).at(1);
		}
	}

	cout << AC << " " << WA << endl;
}

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

int main() {
	int H,W;
	while(true){
		cin>>H>>W;
		if(H==0&&W==0){
			break;
		}
		for(int i=0;i<H;i++){
			if((i+1)%2!=0){
				for(int a=0;a<W;a++){
					if((a+1)%2!=0){
					cout<<"#";
					}
					else{
						cout<<".";
					}
					}
				cout<<"\n";
			}
			else{
				for(int a=0;a<W;a++){
					if((a+1)%2!=0){
						cout<<".";
					}
					else{
						cout<<"#";
					}
					}
				cout<<"\n";
			}
		}
		cout<<"\n";
	}
	return 0;
}


Measured memory_bytes: 1120
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int k,s;
  cin >> k >> s;
  int z;
  int count=0;
  for(int x=0;x <= k; x++){
    for(int y=0;y <= k;y++){
      z = s - x - y;
      if(z >= 0 && z <= k )count++;
    }
  }
  cout << count <<endl;    
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static long x;

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int k=sc.nextInt();
		int s=sc.nextInt();
		int count=0;
		for(int x=0;x<=k;x++) {
			for(int y=0;y<=k;y++) {
				int z=s-x-y;
				if(z>=0 && z<=k) count++;
				
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll num = 1;
    for (ll i = round(sqrt(N)); i > 0; i--) {
        if (N % i == 0) {
            num = i;
            break;
        }
    }
    // cout << round(sqrt(N)) << endl;
    // cout << num << endl;
    cout << num + N/num - 2 << endl;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);       
		int n = sc.nextInt();
        int b = sc.nextInt();
        if(n>12){System.out.println(b);}
		else{if(n>5){System.out.println(b/2);}
            else{System.out.println(0);}}
  }
}


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

#define ll long long
#define vll vector<ll>
#define vvll vector<vll>
#define rep(i, n) for(i = 0; i < n; i++)

int main(){
    ll H, N;
    vll As(1010);
    vll Bs(1010);
    
    ll i, j;
    vll dp;

    cin >> H >> N;
    rep (i, N) {
        cin >> As[i] >> Bs[i];
    }

    dp.assign(H + 1, 1001001001);
    dp[0] = 0;
    rep (i, H) {
        rep (j, N) {
            dp[min(H, i + As[j])] = min(dp[min(H, i + As[j])], dp[i] + Bs[j]);
        }
    }

    cout << dp[H];

    return 0;
}

Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
  int n, t, x, j;
  string s;
  vector<int> v, u;
  while (cin >> n, n) {
    for (int i = 0; i < n; ++i) {
      cin >> s;
      v.push_back(s.size());
    }
    t = 0;
    u = {5, 7, 5, 7, 7, 0};
    for (int i = 0; i < n; ++i) {
      j = i;
      t = 0;
      x = 5;
      while (x >= 0 && t < 5) {
	x -= v[j];
	if (!x) {
	  ++t;
	  x = u[t];
	} else if (x < 0) break;
	++j;
      }
      if (t == 5) {
	cout << i+1 << endl;
	break;
      }
    }
    v.erase(v.begin(), v.end());
  }
  return 0;
}

Measured memory_bytes: 3112