akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

void printVec(std::vector<int> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}

int main() {
  int n;
  cin >> n;
  ll div = 1000000007;

  ll data = 1;
  for (int i = 1; i <= n; i++) {
    data = data * i;
    data = data % div;
  }
  cout << data << endl;
	return 0;
}

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

using namespace std;

int main(void) {
    string s;
    cin >> s;
    
    bool flg = true;
    for(int i = 0; i < s.size(); i++) {
        if(i % 2 == 0) {
            if(s[i] == 'L') {
                flg = false;
                break;
            }
        } else {
            if(s[i] == 'R') {
                flg = false;
                break;
            }
        }
    }
    cout << (flg ? "Yes" : "No") << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main(void)
{
    int d, n, tot = 0;
    cin >> n >> d;
    for (int i = 0; i < n; i++)
    {
        double x, y;
        cin >> x >> y;
        double dis = sqrt(x * x * 1.0 + y * y * 1.0);
        if (dis <= d)
            tot++;
    }
    cout << tot << endl;
    return 0;
}

Measured memory_bytes: 3852
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();

        int N = cin.nextInt();
        int W = cin.nextInt();

        long[] w = new long[N];
        long[] v = new long[N];

        for (int i = 0; i < N; i++)
        {
            w[i] = cin.nextLong();
            v[i] = cin.nextLong();
        }

        long[] DP = new long[100001];

        for (int i = 0; i <= 100000; i++)
        {
            DP[i] = 10000000000;
        }

        DP[0] = 0;

        for (int i = 0; i < N; i++)
        {
            for (int j = 100000; j >= 0; j--)
            {
                if (j + v[i] <= 100000 && DP[j] + w[i] <= W)
                {
                    DP[j + v[i]] = Math.Min(DP[j + v[i]], DP[j] + w[i]);
                }
            }
        }

        long ans = 0;
        for (int i = 0; i <= 100000; i++)
        {
            if (DP[i] != 10000000000)
            {
                ans = Math.Max(ans, i);
            }
        }

        Console.WriteLine(ans);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}



Measured memory_bytes: 11616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long D = sc.nextLong();
		long E = lcm(C,D);

		long x = 0;
		long y = 0;
		long z = 0;

		if (A%C == 0){
			x = B/C - A/C + 1;
		} else {
			x = B/C - A/C;
		}

		if (A%D == 0){
			y = B/D - A/D + 1;
		} else {
			y = B/D - A/D;
		}

		if (A%E == 0){
			z = B/E - A/E + 1;
		} else {
			z = B/E - A/E;
		}

		System.out.println(B - A + 1 - (x + y - z));
	}

	public static long gcd(long a , long b) {
		if (b==0) {
			return a;
		}
		return gcd(b,a%b);
	}

	private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }
}

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

using namespace std;

int main(){
	long long int n; cin >> n;
	long long int res = 0;
	for(int i=1; i<=n; i++){
		if(i % 3 == 0){
			
		}else if(i % 5 == 0){
			
		}else{
			res += i;
		}
	}
	
	cout << res << "\n";
	return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <math.h>
#define mod 1000000007
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, m, t;
  scanf("%lld%lld", &n, &k);
  t = sqrt(n);
  m = t * 2;
  if(t * (t + 1) > n) m--;
  ll dp[k][m], cnt[m], sum;
  for(i = 1; i <= t; ++i) {
    cnt[i - 1] = 1;
    cnt[m - i] = n / i - n / (i + 1);
  }
  for(i = 0; i < m; ++i) dp[0][i] = 1;
  for(i = 1; i < k; ++i) {
    sum = dp[i - 1][0];
    dp[i][m - 1] = sum;
    for(j = 1; j < m; ++j) {
      sum += dp[i - 1][j] * cnt[j];
      sum %= mod;
      dp[i][m - 1 - j] = sum;
    }
  }
  sum = 0;
  for(i = 0; i < m; ++i) sum += dp[k - 1][i] * cnt[i], sum %= mod;
  printf("%lld", sum);
  return 0;
}

Measured memory_bytes: 50048
S,T,D,*w=$<.read.split.map &:to_i
v=[0]
D.times{|i|v[i+1]=v[i]+w[i]}
m=v.min;z=-v[-1]
if i=(0..D).find{|i|S+v[i]<=T}
	p i
elsif z<=0
	p -1
else
	x=z>0?(S+m-T+z-1)/z:0
	p (0..D).find{|i|S-z*x+v[i]<=T}+x*D
end

Measured memory_bytes: 14244
import numpy as np

a, b, c, d = map( int, input().split() )
#print( a, b, c, d )

for i in range( 200 ):
    c = c - b
    if c <= 0:
        print( "Yes" )
        exit()

    a = a - d
    if a <= 0:
        print( "No" )
        exit()


Measured memory_bytes: 26932
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

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

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

bool solve(int n)
{
    string s=to_string(n);

    n=s.length();
    int l=0;
    int r=n-1;
    while (l<r)
    {
        if (s[l]!=s[r])
        {
            return false;
        }
        l++;
        r--;
    }
    return true;
}
int main()
{
    start();
    int a, b;
    cin>>a>>b;
    int c=0;
    for (int i=a;i<=b;i++)
    {
        if (solve(i))
        {
            c++;
        }
    }
    cout<<c;
    return 0;
}

Measured memory_bytes: 3788
package main

import (
  "fmt"
)
var H, W int

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

var grid []string
var ret [51][51]int

func main() {
  fmt.Scanf("%d %d", &H, &W)
  for i := 0; i < H; i++ {
    var temp string
    fmt.Scanf("%s", &temp)
    grid = append(grid, temp)
  }

  for i := 0; i < H; i++ {
    for j := 0; j < W; j++ {
      for k := 0; k < 8; k++ {
        if grid[i][j] != '#' {
          continue
        }

        nx, ny := i + dx[k], j + dy[k]
        if nx < 0 || ny < 0 || nx >= H || ny >= W {
          continue
        }
        ret[nx][ny] += 1
      }
    }
  }

  for i := 0; i < H; i++ {
    for j := 0; j < W; j++ {
      if grid[i][j] == '#' {
        fmt.Print("#")
      } else {
        fmt.Print(ret[i][j])
      }
    }
    fmt.Println()
  }

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int L,R,D;
    cin>>L>>R>>D;
    int count=0;
    for(int k=L;k<=R;k++){
        if(k%D==0)count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, A, B, C);
  print(C, A, B);
}


Measured memory_bytes: 256
a, b = map(int, input().split())

from fractions import gcd
from collections import Counter
# def gcd(x, y):
#     if x < y: x, y = y, x
#     while y != 0:
#         x, y = y, x % y
#     return x

gcd_ab = gcd(a, b)
if gcd_ab == 1:
    print(1)
    exit()

def get_divisor(n):
    divisor = Counter()
    while n % 2 == 0:
        divisor[2] += 1
        n //= 2
        
    i = 3
    while i*i <= n:
        while n % i == 0:
            divisor[i] += 1
            n //= i
        i += 2
    if n > 1:
        divisor[n] += 1
    return divisor

divisor = get_divisor(gcd_ab)
print(len(divisor)+1)




Measured memory_bytes: 5104
N =int(input())
A = []
for i in range(N):
    a,b = map(int, input().split())
    A.append([a,b])
A.sort(key=lambda x:x[1])
tmp = 0
for t,up in A:
    if tmp + t > up:
        print('No')
        break
    tmp += t
else:
    print('Yes')

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

const int nm = 1e5;
int n, m[3], q[nm][2], x, y;
string s;
char ans[100000];

int main() {
	cin >> n;
	for (int i = 0; i < 3; i++)
		cin >> m[i];
	for (int i = 0; i < n; i++) {
		cin >> s;
		q[i][0] = s[0] - 'A';
		q[i][1] = s[1] - 'A';
	}
	for (int i = 0; i < n; i++) {
		x = q[i][0], y = q[i][1];
		if (!m[x] && !m[y]) {
			cout << "No" << endl;
			return 0;
		} else if (m[x] == 1 && m[y] == 1 && i + 1 < n) {
			if (q[i + 1][0] == y || q[i + 1][1] == y)
				swap(x, y);
		} else if (m[y] < m[x])
			swap(x, y);
		ans[i] = 'A' + x;
		m[x]++;m[y]--;

	}
	cout << "Yes" << endl;
	for (int i = 0; i < n; i++)
		cout << ans[i] << endl;
}


Measured memory_bytes: 4520
PI = Math::PI

# k = gets.to_s.to_i
a, b, h, m = gets.to_s.split.map{|e|e.to_f}
#m = Array.new(n){ gets.to_s.split.map{|e|e.to_i} }
# s = gets.to_s.chomp

r_k = h * 30 + 30 * (m / 60.0)
# p (m / 60.0)
r_s = m * 6
r = (r_k - r_s).abs

r = [360, 360 -r].min
# p r
cosmos = Math.cos(PI*r/180.0)
ans = a ** 2 + b ** 2 - 2 * a * b * cosmos
puts (ans ** (0.5))

Measured memory_bytes: 14884
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]


n = I()
s = 1
if n < 27:
    print(chr(96 + n))

else:
    while 26 ** s < n:
        n -= 26 ** s
        s += 1
    ans = ''
    n -= 1
    for i in range(s):

        k = n // 26**(s-i-1)
        ans = ans + chr(97 + k)
        n = n - k * 26**(s-i-1)



    print(ans)



Measured memory_bytes: 27244
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main(){

    input!{
        s: chars,
    }

    let l = s.len();
    let mut flag: bool = true;
    for i in 0..l{
        // odd
        if i%2==0 {
            if s[i] == 'L'{
                flag = false;
                break;
            }
        } else {
            if s[i]=='R' {
                flag = false;
                break;
            }
        }

    }

    if flag == true{
        println!("Yes");
    } else {
        println!("No");
    }

}

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

int main(){
  int a;
  cin >> a;
  cout << a+a*a+a*a*a << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int n,k;
const int MAX=1e5+8;
int dp[MAX], arr[MAX];
int f(int i) {
	if (i == n-1) return 0;
	if(dp[i]!=-1) return dp[i];
	int a=1e9+5;
	for(int j=1;j<=k;j++) {
		if(j+i < n) a = min(a, abs(arr[j+i] - arr[i]) + f(i+j));
	}
	return dp[i] = a;
}
int main() {
	// your code goes here
	memset(dp, -1, sizeof(dp));
	cin >> n >> k;
	for(int i=0;i<n;i++) cin >> arr[i];
	cout << f(0);
	return 0;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
struct Monster
{
    short health;
    short strength;
};

int main(){
    Monster takahashi;
    Monster aoki;
    short A,B,C,D;
    cin >> A >> B >> C >> D;
    takahashi.health = A;
    takahashi.strength = B;
    aoki.health = C;
    aoki.strength = D;
    for(int i = 0;;i++){
        //Takahashi attacks
        aoki.health -= takahashi.strength;
        if(aoki.health <= 0){
            //aoki loses
            cout << "Yes" << endl;
            return 0;
        }
        //Aoki attacks
        takahashi.health -= aoki.strength;
        if(takahashi.health <= 0){
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;

int MOD=1000000007;


int main(){
    int a=0,b=0;
    string S;
    cin >> S;
    for(ll i=0; i<S.size(); i++){
        if(S[i]=='A') a++;
        if(S[i]=='B') b++;
    }
    if(a==0 || b==0) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    int h, w;
    cin >> h >> w;
    int cnt = 0;
    rep(i, h) rep(j, w) {
        char a;
        cin >> a;
        if (a == '#') cnt++;
    }
    if (cnt == h+w-1) cout << "Possible\n";
    else cout << "Impossible\n";
}

Measured memory_bytes: 256
use std::collections::BTreeSet;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };

    let mut ans = vec![];
    let mut cur: Vec<usize> = vec![0];
    for _ in 0..10 {
        let mut next = vec![];
        for &cur in cur.iter() {
            next.push(cur * 10 + 3);
            next.push(cur * 10 + 5);
            next.push(cur * 10 + 7);
        }
        ans.extend(next.clone());
        cur = next;
    }
    let n: usize = sc.read();
    let mut count = 0;
    for &ans in ans.iter() {
        let mut ans = ans;
        if n >= ans {
            let mut set = BTreeSet::new();
            while ans > 0 {
                set.insert(ans % 10);
                ans /= 10;
            }
            if set.len() >= 3 {
                count += 1;
            }
        }
    }
    println!("{}", count);
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 6396
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const int MOD = 1000000007;

long long mod(long long a) {
	a %= MOD;
	return a >= 0 ? a : a+MOD;
}

int main() {
	long long n, k;
	cin >> n >> k;
	vector<vector<int>> g(n);
	for (int i = 0; i < n-1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	long long ans = 1;
	struct State
	{
		long long v, parent, x;
	};
	queue<State> q;
	q.push({0, -1, k});
	while (!q.empty()) {
		State cur = q.front(); q.pop();
		ans = mod(ans * cur.x);
		int x = k - 2;
		if (cur.v == 0) x++;
		for (int nv : g[cur.v]) {
			if (nv == cur.parent) continue;
			q.push({nv, cur.v, x});
			x--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11488
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

int main() {
    int M, K;
    scanf("%d %d", &M, &K);
    if (M == 1) {
       if (K > 0) return !printf("-1\n");
       return !printf("0 0 1 1\n");
    }
    if (K >= (1 << M)) return !printf("-1\n");
    for (int i = 0; i < (1 << M); i++) {
        if (i == K) continue;
        printf("%d ", i);
    }
    printf("%d\n", K);
    for (int i = (1 << M) - 1; i >= 0; i--) {
        if (i == K) continue;
        printf("%d ", i);
    }
    printf("%d\n", K);
    return 0;
}


Measured memory_bytes: 1792
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST         ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll           long long
#define ld           long double
#define pb           push_back
#define mp           make_pair
#define pii          pair<int,int>
#define mii          map<int,int>
#define vi           vector<int>
#define vll          vector<long long>
#define all(a)       (a).begin(),(a).end()
#define clz(a)       __builtin_clz(a) // count leading zeroes
#define ctz(a)       __builtin_ctz(a) // count trailing zeroes
#define popc(a)      __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul          1000000007
#define rep(i,a,b)   for(int i=a;i<b;i++)
#define rfor(i,a,b)  for(int i=a; i>=b; i--)
#define SIZE         1000005
#define F            first
#define S            second
#define mod          998244353

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define endl         '\n'
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{ 
  int n; cin>>n;
  double a[n];
  rep(i,0,n) cin>>a[i];
  double dp[n+1][n+1];
  double ans = 0;
  dp[0][0]=1;
  rep(i,0,n+1)
  {
    rep(j,1,n+1)
    {
      if(i==0) dp[i][j-i] = dp[i][j-i-1]*(1-a[j-1]);
      else if(i==j) dp[i][j-i] = dp[i-1][j-i]*a[j-1];
      else{
        dp[i][j-i] = dp[i-1][j-i]*a[j-1] + dp[i][j-i-1]*(1-a[j-1]);
      }
      if(2*i>j and j==n) ans+=dp[i][j-i];
    }
  }
  cout<<fixed<<setprecision(15)<<ans;
} 
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define vv vector
#define ff first
#define ss second
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
typedef pair<ll,ll> pll;
typedef vv<ll> vll;
// #define dbg

int main(){
	fastio;
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int llint;
int main() {
	int n;
	cin >> n;
	vector<llint>a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int cnt = 1;
	int ans = 0;
	for (int i = 1;i < n;i++) {
		if (a[i - 1] == a[i]) {
			cnt++;
			if (i == n - 1) {
				if (cnt % 2 == 1) {
					ans++;
				}
			}
		}
		else {
			if (cnt % 2 == 1) {
				ans++;
			}
			if (i == n - 1) {
				ans++;
			}
			cnt = 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int n;
  cin >> n;
  vector<LL> value(1<<18), weight(1<<18);
  FOR(i,1,n+1) cin >> value[i] >> weight[i];
  vector<vector<pair<LL, LL>>> hanzen(1<<13); // weight, value
  hanzen[0].emplace_back(0,0);
  FOR(bits,1,1<<13) {
    for(pair<LL,LL> p:hanzen[bits/2]) {
      pair<LL,LL> added = make_pair(p.first+weight[bits], p.second+value[bits]);
      hanzen[bits].push_back(p);
      hanzen[bits].push_back(added);
    }
    vector<pair<LL,LL>> tmp(hanzen[bits].begin(),hanzen[bits].end());
    sort(tmp.begin(),tmp.end());
    hanzen[bits].clear();
    hanzen[bits].emplace_back(0,0);
    for(pair<LL,LL> p:tmp) {
      if(hanzen[bits].back().second < p.second) hanzen[bits].push_back(p);
    }
  }
  int q;
  cin >> q;
  while(q--) {
    LL v, l;
    cin >> v >> l;
    vector<pair<LL,LL>> comb;
    comb.emplace_back(0,0);
    while(v>=(1<<13)) {
      vector<pair<LL,LL>> tmp(comb.begin(), comb.end());
      for(pair<LL,LL> p:tmp) {
        pair<LL,LL> added = make_pair(p.first+weight[v], p.second+value[v]);
        comb.push_back(added);
      }
      v/=2;
    }
    LL answer = 0;
    for(pair<LL,LL> p: comb) {
      LL cw,cv;
      tie(cw,cv) = p;
      if(cw>l) continue;
      auto ite = lower_bound(hanzen[v].begin(),hanzen[v].end(), make_pair(l-cw+1,0ll));
      --ite;
      answer=max(answer, cv+ite->second);
    }
    cout << answer << endl;
  }

  return 0;
}


Measured memory_bytes: 607632
a, b, k = map(int, input().split())
num = []
if a > b:
    for i in range(1, b+1):
        if a%i == 0 and b%i == 0:
            num.append(i)

else:
    for i in range(1, a+1):
        if a%i == 0 and b%i == 0:
            num.append(i)
print(num[-k])


Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>
typedef struct{
    int time;
    int number;
    int ans;
    int q[10];
}Data;
Data d[50];
int M, T, P, R;
int m, t, p, j;
void init(void){
    for(int i=0; i<50; i++){
        d[i].time=0;
        d[i].number=i;
        d[i].ans=0;
        for(int j=0; j<10; j++){
            d[i].q[j]=0;
        }
    }
}
int compare(const void *a, const void *b){
    Data c = *(Data *)a;
    Data d = *(Data *)b;
    if(c.ans > d.ans) return -1;
    else if(d.ans > c.ans) return 1;
    else{
        if(c.time > d.time) return 1;
        else if(d.time > c.time) return -1;
        else{
            if(c.number > d.number) return -1;
            else return 1;
        }
    }
}
int main(void){
    while(1){
        init();
        scanf("%d%d%d%d",&M,&T,&P,&R);
        if(M==0 && T==0 && P==0 && R==0) break;
        for(int i=0; i<R; i++){
            scanf("%d%d%d%d",&m,&t,&p,&j);
            if(j==0){
                d[t-1].time+=(m+d[t-1].q[p-1]*20);
                d[t-1].ans++;
            }
            else{
                d[t-1].q[p-1]++;
            }
        }
        qsort(d,T,sizeof(Data),compare);
        for(int i=0; i<T-1; i++){
            printf("%d",d[i].number+1);
            if(d[i].time==d[i+1].time && d[i].ans==d[i+1].ans) printf("=");
            else printf(",");
        }
        printf("%d\n",d[T-1].number+1);
    }
    return 0;
}



Measured memory_bytes: 2032
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int N = 2e6 + 6;
int A[N];
int n;

void solve()
{
	int k , a, b;
	cin >> k >> a >> b;

	loop(i,a,b+1)
	{
		if(i%k == 0)
		{
			cout << "OK";
			return;
		}
	}

	cout << "NG";
}
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);

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

 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		int visit[7];
		memset(visit, 0, sizeof(visit));
		while (n--)
		{
			int t;
			scanf("%d", &t);
			++visit[t/10 >= 6 ? 6 : t/10];
		}
		for (int i = 0; i < 7; ++i)
			printf("%d\n", visit[i]);
	}

	return 0;
}

Measured memory_bytes: 876
#include<stdio.h>
#include<stdlib.h>
#define N 2000000
#define MAX 10000

int main(){
  int a[N];
  int n,i,c[MAX+1];
  
  scanf("%d",&n);

  int b[n];
  
  for(i=1;i<=n;i++) scanf("%d",&a[i]);

  for(i=0;i<=MAX;i++){
    c[i]=0;
  }

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

  for(i=1;i<MAX;i++){
    c[i]=c[i]+c[i-1];
  }

  for(i=n;i>0;i--){
    b[c[a[i]]]=a[i];
    c[a[i]]--;
  }
  
  for(i=1;i<n;i++) printf("%d ",b[i]);
  printf("%d\n",b[i]);
  
  return 0;
}



Measured memory_bytes: 17360
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
enu = enumerate

sys.setrecursionlimit(10**7)
S = input()

for i in range(6):
    if 'hi'*i == S:
        print('Yes')
        exit()
else:
    print('No')




Measured memory_bytes: 3444
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
bool match(char c1, char c2){
    if(c1=='?'||c2=='?'||c1==c2){
        return true;
    }else{
        return false;
    }
}

int solve(string a, string b, string c){
    int la = a.size();
    int lb = b.size();
    int lc = c.size();
    int ret = la+lb+lc;
    vector<bool> ab(5000,true);
    vector<bool> bc(5000,true);
    vector<bool> ac(5000,true);
    REP(i,la+1){
        int r = min(la-1,i+lb-1);
        bool f = true;
        for(int j=i;j<=r;j++){
            if(match(a[j],b[j-i])==false){
                f = false;
                break;
            }
        }
        ab[i]=f;
    }
    REP(i,lb+1){
        int r = min(lb-1,i+lc-1);
        bool f = true;
        for(int j=i;j<=r;j++){
            if(match(b[j],c[j-i])==false){
                f = false;
                break;
            }
        }
        bc[i]=f;
    }
    REP(i,la+lb+1){
        int r = min(la-1,i+lc-1);
        bool f = true;
        for(int j=i;j<=r;++j){
            if(match(a[j],c[j-i])==false){
                f =false;
                break;
            }
        }
        ac[i]=f;
    }
    REP(i,la+1){
        int t = max(i+lb,la);
        for(int j=i;j<=t;++j){
            if(ab[i]&&bc[j-i]&&ac[j]){
                int r = max({la, i+lb, j+lc});
                ret = min(ret,r);
            }
        }
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b,c;
    cin >> a >> b >> c;
    int ans = a.size() + b.size() + c.size();
    ans = min(ans,solve(a,b,c));
    ans = min(ans,solve(a,c,b));
    ans = min(ans,solve(b,a,c));
    ans = min(ans,solve(b,c,a));
    ans = min(ans,solve(c,b,a));
    ans = min(ans,solve(c,a,b));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(150000)


d = [2,5,5,4,5,6,3,7,6]

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

memo = [ "-" for _ in range(N + 1)]

def find(N):
    global memo
    if memo[N] != "-":
        return memo[N]

    mval = ""
    val = ""
    for a in A:
        if d[a - 1] < N:
            val = find(N - d[a - 1])
            if val == "":
                continue
            val = val + str(a)
        elif d[a - 1] == N:
            val = str(a)
        else:
            continue

        if len(mval) < len(val) or (len(mval) == len(val) and mval < val):
            mval = val
    memo[N] = mval
    return memo[N]

m = find(N)
print(m)


Measured memory_bytes: 30916
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        Set<String> set = new HashSet<>();
        set.add("AKIHABARA");
        set.add("KIHABARA");
        set.add("AKIHBARA");
        set.add("AKIHABRA");
        set.add("AKIHABAR");
        set.add("KIHBARA");
        set.add("KIHABRA");
        set.add("KIHABAR");
        set.add("AKIHBRA");
        set.add("AKIHBAR");
        set.add("AKIHABR");
        set.add("KIHBRA");
        set.add("KIHBAR");
        set.add("KIHABR");
        set.add("AKIHBR");
        set.add("KIHBR");
        if (set.contains(s)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }
}


Measured memory_bytes: 23892
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <queue>
#include <iomanip>
#include <algorithm>
using namespace std;
int n;
int main()
{
int tim = 0, curx = 0, cury = 0;
scanf("%d", &n);
while (n--) {
int t, x, y; scanf("%d %d %d", &t, &x, &y);
int nd = abs(curx - x) + abs(cury - y);
if (tim + nd > t || nd % 2 != (t - tim) % 2) {
printf("No\n"); return 0;

}
tim = t; curx = x; cury = y;
}
printf("Yes\n");
return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp90 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = st[0];
            int K = st[1];

            var h = new int[N];

            for (int i = 0; i < N; i++) {
                h[i] = int.Parse(Console.ReadLine());
            }

            Array.Sort(h);

            int ans = h[N - 1] - h[0];

            for (int i = 0; i + K - 1 < N; i++) {
                ans = Math.Min(ans, h[i + K - 1] - h[i]);

            }

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 17632
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int  num = scanner.nextInt();
		
		Koch(num);
		
		scanner.close();
	}
	
	public static void Koch(int num){
		
		if(num == 0){
			System.out.printf("%.8f %.8f\n", 0.0, 0.0);
		}else{
			KochCurve(0, num, 0, 0, 100, 0);
		}
		 System.out.printf("%.8f %.8f\n", 100.0, 0.0);
		
	}
	
	//コッホ
	public static void KochCurve(final int deep, final int n, double x1, double y1, double x2, double y2){
		double x_diff = x2 - x1;
		double y_diff = y2 - y1;
		
		double x3_1 = x1 + x_diff / 3;
		double y3_1 = y1 + y_diff / 3;
		double x3_2 = x1 + 2 * x_diff / 3;
		double y3_2 = y1 + 2 * y_diff / 3;
		double x3_f = Math.cos(Math.toRadians(Math.toDegrees(Math.atan2(y_diff, x_diff)) + 60)) * (Math.sqrt(x_diff * x_diff + y_diff * y_diff) / 3) + x3_1;
		double y3_f = Math.sin(Math.toRadians(Math.toDegrees(Math.atan2(y_diff, x_diff)) + 60)) * (Math.sqrt(x_diff * x_diff + y_diff * y_diff) / 3) + y3_1;
		
		if(deep == n - 1){
			System.out.printf("%.8f %.8f\n",   x1,   y1);
			System.out.printf("%.8f %.8f\n", x3_1, y3_1);
			System.out.printf("%.8f %.8f\n", x3_f, y3_f);
			System.out.printf("%.8f %.8f\n", x3_2, y3_2);
		}else{
			KochCurve(deep + 1, n, x1, y1, x3_1, y3_1);
			KochCurve(deep + 1, n, x3_1, y3_1, x3_f, y3_f);
			KochCurve(deep + 1, n, x3_f, y3_f, x3_2, y3_2);
			KochCurve(deep + 1, n, x3_2, y3_2, x2, y2);
		}
    }
}


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

struct Pos
{
  int x;
  int y;
};

int main()
{
  int h, w;
  int map[1100][1100];
  queue<Pos> positions;
  string buff;

  cin >> h >> w;
  for (int y = 0; y < h; ++y)
  {
    cin >> buff;
    for (int x = 0; x < w; ++x)
    {
      if (buff[x] == '.')
      {
        map[x][y] = -1;
      }
      else
      {
        map[x][y] = 0;
        positions.push({x, y});
      }
    }
  }

  const Pos moves[] = {
      {0, 1},
      {1, 0},
      {0, -1},
      {-1, 0},
  };

  int turn = 0;
  while (!positions.empty())
  {
    Pos pos = positions.front();
    positions.pop();

    for (int i = 0; i < 4; ++i)
    {
      Pos move = moves[i];
      Pos next = {pos.x + move.x, pos.y + move.y};
      if (next.x < 0 || w <= next.x || next.y < 0 || h <= next.y)
      {
        continue;
      }

      if (map[next.x][next.y] < 0)
      {
        int nextTurn = map[pos.x][pos.y] + 1;
        map[next.x][next.y] = nextTurn;
        if (turn < nextTurn)
        {
          turn = nextTurn;
        }
        positions.push(next);
      }
    }
  }
  cout << turn << endl;

  return 0;
}

Measured memory_bytes: 12688
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int N, K, ans;
int A[110];

int main(){
    scanf("%d %d", &N, &K);
    for (int i=1; i<=N; i++) scanf("%d", &A[i]);
    sort(A+1, A+N+1);
    for (int i=1; i<=N; i++){
        if (K >= A[i]){
            ans++;
            K -= A[i];
        }
        else break;
    }
    if (ans == N && K > 0) ans--;
    printf("%d\n", ans);
    return 0;
}


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

int main() {
    char s[19];
    cin >> s;
    char* c;
    c = s;
    for (int i=0; i<19; i++) {
        if (*c == ',')
            *c = ' ';
        c++;
    }
    cout << s << flush;

    return 0;
}

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

#define int long long


template <class Monoid> struct SegmentTree{
    using Func = function<Monoid(Monoid, Monoid)>;

    int size;
    vector<Monoid> seg;
    const Func merge;
    const Monoid def;

    SegmentTree(int n, Monoid d, const Func f): merge(f), def(d){
        for(size = 1; size <= n; size <<= 1);
        seg.assign(size*2, def);
    }

    Monoid& operator[] (int i) { return seg[i+size]; };
    void build(){ for(int i = size-1;i >= 0;i--) seg[i] = merge(seg[i*2], seg[i*2+1]); }

    void update(int i, Monoid val){
        seg[i += size] = val;
        while(i >>= 1) seg[i] = merge(seg[i*2], seg[i*2+1]);
    }

    void add(int i, Monoid val){ update(i, val+seg[i+size]); }

    Monoid get(int a, int b){
        Monoid l = def, r = def;
        for(a += size, b += size; a < b; a >>= 1, b >>= 1){
            if(a & 1) l = merge(l, seg[a++]);
            if(b & 1) r = merge(r, seg[--b]);
        }
        return merge(l, r);
    }
};

int n;
pair<char, int> p[4010];

int b[2010];
int w[2010];
int memo[2010][2010];

SegmentTree<int> seg(4010, 0, [](int a, int b){ return (a + b);});

int dp(int i, int j){
    if(i == n/2 && j == n/2){
        return 0;
    }

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

    int ans = LLONG_MAX;
    if(i < n/2){
        seg.update(b[i], 0);
        ans = min(ans, dp(i+1, j) + seg.get(0, b[i]));
        seg.update(b[i], 1);
    }

    if(j < n/2){
        seg.update(w[j], 0);
        ans = min(ans, dp(i, j+1) + seg.get(0, w[j]));
        seg.update(w[j], 1);
    }

    return memo[i][j] = ans;
}

signed main(){
    cin >> n;
    n *= 2;

    for(int i = 0;i < n;i++){
        cin >> p[i].first >> p[i].second;
        p[i].second--;

        if(p[i].first == 'B'){
            b[p[i].second] = i;
        }else{
            w[p[i].second] = i;
        }
    }

    for(int i = 0;i < n;i++){
        seg[i] = 1;
    }
    seg.build();

    memset(memo, -1, sizeof(memo));

    cout << dp(0, 0) << endl;

    return 0;
}

Measured memory_bytes: 33024
//Sinhaeng Hhjian
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
const int maxn=5e6+7;
#define mod 998244353;
typedef long long ll;
void fuck(){
	
}
int main(){
	ll a, b, c;
	cin>>a>>b>>c;
	if(a+b>=c)
		printf("%lld\n", b+c);
	else
		printf("%lld\n", 2*b+a+1);
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
#include <math.h>
#include <string>
#include <vector>

# include <map>

using namespace std;

typedef long long ll;

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

	ll max = a * c;
	if (a * d > max) {
		max = a * d;
	}
	if (b * c > max) {
		max = b * c;
	}
	if (b * d > max) {
		max = b * d;
	}
	cout << max;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,num,ii,b,I,R,B,C,i,p,q,r,P,Q;
  int pA[1100],qA[1100],rA[1100];
  vector<int> index;
  while(cin >> n && n){
    index.clear();
    for(int j=0;j<n;j++){
      cin >> i >> p >> q >> r;
      pA[j] = p; qA[j] = q; rA[j] = r; 
      index.push_back(i);
    }
    cin >> P >> Q >> R >> C;
    bool finf = false;
    for(int j=0;j<n;j++){
      if(pA[j]<=P && qA[j]<=Q && rA[j]<=R && pA[j]*4+qA[j]*9+rA[j]*4<=C){
	cout << index[j] << endl;
	finf = true;
      }
    }
    if(!finf)cout << "NA" << endl;
      
  }
  return 0;
}

Measured memory_bytes: 1240
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
char s[107];
long long b[107];
int main(){
    cin>>s+1;
    long long k;
    cin>>k;
    long long ans=0;
    long long pos=0;
    long long n=strlen(s+1);
    long long cnt=-1;
    for(long long i=1;i<=n+1;++i){
        if(s[i]!=s[i-1]){
            b[++cnt]=i-pos;
            pos=i;
        }
    }
    for(long long i=1;i<=cnt;++i)
        ans+=b[i]/2;
    if(k==1)
        cout<<ans;
    else{
        if(s[1]!=s[n]){
            ans*=k;
            cout<<ans;
        }
        else if(cnt==1){
            ans=b[1]*k/2;
            cout<<ans;
        }
        else if(cnt==2){
            ans*=k;
            cout<<ans;
        }
        else{
            long long tamp=ans-b[1]/2-b[cnt]/2;
            long long tot=tamp*k+(b[1]+b[cnt])/2*(k-1)+b[1]/2+b[cnt]/2;
            cout<<tot;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative

import Control.Monad
    (when)

type Problem = (Int, Int)

type Result = [String]

check :: Int -> Int -> Char

check x y
    | even y
        = if even x then '#' else '.'
        
    | otherwise
        = if even x then '.' else '#'

solve :: Problem -> Result

solve (h, w)
    = [[check x y | x <- [0..(w - 1)]] | y <- [0..(h - 1)]]

input :: IO Problem

input
    = do
        [h, w] <- map read.words <$> getLine
        return (h, w)

output :: Result -> IO ()

output xs
    = putStrLn $ concat [x ++ "\n" | x <- xs]
    
main :: IO ()

main
    = do
        xs <- input
        when (xs /= (0, 0)) $ do
            output $ solve xs
            main

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

int main(){
  int n,k,q;
  cin >> n >> k >> q;
  vector<int> a(q);
  for(int i=0;i<q;i++) cin >> a[i];
  vector<int> cnt(n,0);
  for(int i=0;i<q;i++){
    cnt[a[i]-1]++;
  }
  for(int i=0;i<n;i++){
    if(k+cnt[i]>q) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll arr[100];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,res=0;
    cin>>n;
    for(ll i=1;i<=25;i++)
    arr[i]=0;
    for(ll i=1;i<=n;i++){
        ll k=i;
        while(k/10!=0)
        k/=10;
        if(i%10!=0)
        arr[(k*10)+(i%10)]++;
    }
    for(ll i=1;i<100;i++)
    res+=arr[i]*arr[(i%10)*10+i/10];
    cout<<res;
} 


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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

string s;
int sz;
int yo(char ch)
{
    int tmp=sz-1;
    string magic=s;
   // cout<<ch<<" # # # "<<endl;
   int ret=0;
    while(tmp--)
    {
         string past=magic;
         //cout<<magic<<"#"<<endl;
         magic="";
         int len=past.size()-1;
         f(i,0,len-1)
         {
             if(past[i]==ch || past[i+1]==ch)
             {
                 magic+=ch;
             }
             else magic+=past[i];
         }
         ret++;
         int flag=0;
         f(i,0,len-1)
         {
            if(magic[i]!=ch)flag=1;
         }
         if(flag==0)return ret;
    }
    if(magic[0]!=ch)return inf;
    return ret;
}
 main()

{
    fast
    cin>>s;
    sz=s.size();
    set<char>chk;
    for(auto ch:s)chk.insert(ch);
    if(chk.size()==1)
    {
        cout<<"0"<<endl;
        return 0;
    }
    int ses=sz-1;
    for(char ch='a';ch<='z';ch++)
    {
         ses=min(ses,yo(ch));
    }
    cout<<ses<<endl;
    return 0;

}














Measured memory_bytes: 256
/*
 © 2020-08-22 12:40:23 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  string s; cin >> s;
  lli foo = 0;
  for(auto i : s) foo += i - '0';
  cout << (foo % 9 ? "No" : "Yes") << ENDL;
  return 0;
}


Measured memory_bytes: 3712