akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	string s;
	cin >> s;
	bool f = true;
	f &= (s[0] == 'A');
	ll c = 0;
	REP(i, s.length()) if (s[i] >= 'a' && s[i] <= 'z') ++c;
	f &= (c == s.length() - 2);
	if (f) FOR(i, 2, s.length()-1) if (s[i] == 'C') {
		cout << "AC" << endl;
		return 0;
	}
	cout << "WA" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#define inf 0x3f3f3f3f

using namespace std;

char str[11];

int main() {
	while (scanf("%s", str) != EOF) {
		int len = strlen(str);
		long long ans = 0;
		for (int s = 0; s < pow(2, len-1); s++) {
			long long now = 0;
			int flag = s;
			for (int i = 0; i < len; i++) {
				now = now * 10 + str[i] - '0';
				if(flag & 1){
					ans += now;
					now = 0;
				}
				flag >>= 1;
			}
			ans += now;
			//printf("s %d, ans %lld\n",s, ans);
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

ll A,B,C,K;

ll solve(){
    if(K <= A) return K;
    if(K <= A + B) return A;
    if(K <= A + B + C) return A-(K-A-B);
}

int main() {
    cin >> A >> B >> C >> K;
    cout << solve() << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int n,m,x,y;
		cin>>n>>m>>x>>y;
		if(n==0) break;
		vi a(n);
		for(int i=0;i<x;i++){
			int t;
			cin>>t;
			a[t]=1;
		}
		for(int i=0;i<y;i++){
			int t;
			cin>>t;
			a[t]=2;
		}
		vvd dp(m+1,vd(n+1));
		dp[0][0]=1;
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				for(int k=1;k<=6;k++){
					int x=j+k;
					if(x>n) x=2*n-x;
					if(a[x]==2) x=0;
					if(a[x]==1){
						if(i+2<=m) dp[i+2][x]+=dp[i][j]/6;
					}
					else dp[i+1][x]+=dp[i][j]/6;
				}
			}
			dp[i+1][n]+=dp[i][n];
		}
		cout<<syosu(9)<<dp[m][n]<<endl;
	}
}


Measured memory_bytes: 3324
# coding: utf-8
import math

num_N, num_A, num_B = map(int, input().split())
l_val = list(map(int, input().split()))

l_val.sort(reverse=True)

num_cen = l_val[num_A - 1]

count_all = 0
for i in l_val:
    if num_cen == i:
        count_all += 1

count_front = 0
for i in l_val[0:num_A - 1]:
    if i == num_cen:
        count_front += 1

count_back = count_all - count_front - 1

ans = 0

if l_val[0] == num_cen:
    if count_back <= num_B - num_A:
        for i in range(num_A, num_A + count_back + 1):
            ans += math.factorial(count_all) // (math.factorial(count_all - i) * math.factorial(i))
    else:
        for i in range(num_A, num_B + 1):
            ans += math.factorial(count_all) // (math.factorial(count_all - i) * math.factorial(i))
else:
    ans = math.factorial(count_all) // (math.factorial(count_all - (count_front + 1)) * math.factorial(count_front + 1))

print((sum(l_val[0:num_A])) / num_A)
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, q;
  cin >> n;
  vi s(n);
  rep(i, n) cin >> s[i];
  cin >> q;
  int ans = 0;
  rep(i, q) {
    int a;
    cin >> a;
    int l = 0, r = n;
    while(l + 1 < r) {
      int x = (l + r) / 2;
      if(s[x] <= a)
        l = x;
      else
        r = x;
    }
    if(s[l] == a) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3108
#include<stdio.h>
int main(){
int a,b,c[4][13]={0},d,e,f,g;
char z;
scanf("%d",&a);
for(b=0;b<a;b++){
scanf("%s %d",&z,&e);
if(z=='S')
d=0;
if(z=='H')
d=1;
if(z=='C')
d=2;
if(z=='D')
d=3;
c[d][e-1]=1;
}
for(b=0;b<4;b++){
if(b==0)
z='S';
if(b==1)
z='H';
if(b==2)
z='C';
if(b==3)
z='D';
for(f=0;f<13;f++){
if(c[b][f]!=1)
printf("%c %d\n",z,f+1);
}
}
return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int64_t inf=1e11;
int main() {
  int64_t a,b,q,x,i,s1,s2,t1,t2,ans;
  cin>>a>>b>>q;
  vector<int64_t> s(a),t(b);
  for(i=0;i<a;i++) cin>>s.at(i);
  for(i=0;i<b;i++) cin>>t.at(i);
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  for(i=0;i<q;i++){
    cin>>x;
    auto it=upper_bound(s.begin(),s.end(),x);
    if(it==s.end()) s2=inf;
    else s2=*it;
    if(it==s.begin()) s1=-inf;
    else s1=*prev(it,1);
    it=upper_bound(t.begin(),t.end(),x);
    if(it==t.end()) t2=inf;
    else t2=*it;
    if(it==t.begin()) t1=-inf;
    else t1=*prev(it,1);
    ans=min(x-min(s1,t1),max(s2,t2)-x);
    ans=min(ans,x-s1+t2-s1);
    ans=min(ans,x-t1+s2-t1);
    ans=min(ans,s2-x+s2-t1);
    ans=min(ans,t2-x+t2-s1);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 4820
#include<iostream>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
int main() {
	//input
	int n, a;
	double ans=0.0;
	cin >> n;
	a = n%2;
	//compute
	//cout << a<<endl;
	if (a == 1) {
		ans = (n+1)/(2);
		ans /= n;
		//ans = (n + 1) / (2 * n);
	//	cout << ans<<endl;
	}
	else if(a==0){
		ans = 0.5 ;
	}
	//output
	printf("%.10f", ans);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <set>
using namespace std;
typedef long long ll;

const int ms = 200005;
int a[ms];
int main()
{
    int n, k, q;
    cin >> n >> k >> q;
    for (int i = 0; i < n; ++i)
    {
        a[i] = -q;
    }
    int x;
    for (int i = 0; i < q; ++i)
    {
        scanf("%d", &x);
        a[x-1]++;
    }
    for (int i = 0; i < n; ++i)
    {
        if (a[i] + k <= 0)
        {
            printf("No\n");
        }
        else
        {
            printf("Yes\n");
        }
    }
    return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
  
        static void Main(string[] args)
        {
            int[] xy = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int X1 = xy[0];
            int Y1 = xy[1];
            int X2 = xy[2];
            int Y2 = xy[3];
            int X3 = 0;
            int X4 = 0;
            int Y3 = 0;
            int Y4 = 0;
            X3 = X2 - (Y2 - Y1);
            Y3 = Y2 + (X2 - X1);
            X4 = X3 - (X2 - X1);
            Y4 = Y3 - (Y2 - Y1);
            Console.WriteLine(X3 + " " + Y3 + " " + X4 + " " + Y4);
        }
    }
}

Measured memory_bytes: 13268
use rand::Rng;
fn main() {
    let start=std::time::Instant::now();
    proconio::input! {
        d: usize,
        c: [i64;26],
        s: [[i64;26];d],
    }
    let mut t=vec![0;d];
    let mut last=[0;26];
    for (i,t) in t.iter_mut().enumerate() {
        let mut m=std::i64::MIN;
        let mut k=0;
        for j in 0..26 {
            let p=last[j];
            let mut v=0;
            v+=s[i][j];
            last[j]=i+1;
            for (&c,&last) in c.iter().zip(last.iter()) {
                v-=c*(i+1-last)as i64;
            }
            if m<v {
                m=v;
                k=j;
            }
            last[j]=p;
        }
        last[k]=i+1;
        *t=k;
    }
    let mut v=f(&c,&s,&t);
    let mut rng = rand::thread_rng();
    while start.elapsed().as_secs_f64()<1.98 {
        let r: usize=rng.gen_range(0, d*26);
        let i=r/26;
        let q=r%26;
        let p=t[i];
        t[i]=q;
        let w=f(&c,&s,&t);
        if w>v {
            v=w;
        }
        else {
            t[i]=p;
        }
    }
    for t in t {
        println!("{}",t+1);
    }
}
fn f(c: &Vec<i64>, s: &Vec<Vec<i64>>, t: &Vec<usize>) -> i64 {
    let mut last=[0;26];
    let mut v=0;
    for (i,&t) in t.into_iter().enumerate() {
        v+=s[i][t];
        last[t]=i+1;
        for (&c,&last) in c.iter().zip(last.iter()) {
            v-=c*(i+1-last)as i64;
        }
    }
    v
}

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

int main() {
	int n, d; cin >> n >> d;
	int x[11][11];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}

	int count = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int ll = 0;
			for (int k = 0; k < d; k++) {
				ll += pow(x[i][k] - x[j][k], 2);
			}
			double l = pow(ll, 0.5);
			if (l-int(l) == 0) count++;
		}
	}

	cout << count << endl;
}

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

long long n,a[100005],a1[100005],r1,r2,s;

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

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

    for(int i=1;i<=n;i++)
    {
        if(i%2==1)
        {
            if(s+a[i]<=0)
            {
                r1+=1-(s+a[i]);
                a[i]+=1-(s+a[i]);
                s=1;
            }
            else
                s+=a[i];
        }
        else
        {
            if(s+a[i]>=0)
            {
                r1+=1+(s+a[i]);
                a[i]-=1+(s+a[i]);
                s=-1;
            }
            else
                s+=a[i];
        }
    }
    s=0;
    for(int i=1;i<=n;i++)
    {
        if(i%2==0)
        {
            if(s+a1[i]<=0)
            {
                r2+=1-(s+a1[i]);
                a1[i]+=1-(s+a1[i]);
                s=1;
            }
            else
                s+=a1[i];
        }
        else
        {
            if(s+a1[i]>=0)
            {
                r2+=1+(s+a1[i]);
                a1[i]-=1+(s+a1[i]);
                s=-1;
            }
            else
                s+=a1[i];
        }
    }
    cout<<min(r1,r2);

    return 0;
}


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

ll gcd(ll number1, ll number2)
{
  ll m = number1;
  ll n = number2;

  if (number2 > number1)
  {
    m = number2;
    n = number1;
  }

  if (m % n == 0)
    return n;
  else
    return gcd(n, m % n);
}

ll lcm(ll number1, ll number2)
{
  return number1 * number2 / gcd(number1, number2);
}

int main()
{
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  A--;
  ll CC = B / C - A / C;
  ll DD = B / D - A / D;
  ll CD = lcm(C, D);
  ll CDCD = B / CD - A / CD;

  cout << (B - A) - (CC + DD) + (CDCD) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(ll &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
ll a[4],n,res=6e18;
ll solve(ll n, int S){
	assert((S>>2&1)&&(S>>3&1));
	ll qaq=0;
	/*if(S>>3&1)res+=n/8*a[3],n%=8;
	if(S>>2&1)res+=n/4*a[2],n%=4;
	if(S>>1&1)res+=n/2*a[1],n%=2;
	if(S>>0&1)res+=n/1*a[0],n%=1;*/
	qaq+=n/8*a[3],n%=8;qaq+=n/4*a[2],n%=4;
	return qaq;
}
int main() {
	rep(i,0,3)read(a[i]);rep(i,1,3)a[i]=min(a[i],a[i-1]*2);
	read(n);
	n*=4;
	cout<<solve(n,15);
	return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
typedef long long ll;

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int n = getInt();
  const int l = getInt();

  const int mx = l + n - 1;
  const int mn = l + 1 - 1;

  const ll sum = l * n + n * (n - 1) / 2;
  if(mx * mn <= 0){
    printf("%lld\n", sum);
  }else{
    const ll a = sum - mn;
    const ll b = sum - mx;
    if(std::abs(sum - a) <= std::abs(sum - b)) printf("%lld\n", a);
    else printf("%lld\n", b);
  }
  return 0;
}

Measured memory_bytes: 128
use proconio::{fastout, input};

use rand::prelude::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::time::SystemTime;

struct Input {
    d: usize,
    c: Vec<i64>,
    s: Vec<[i64; 26 + 1]>,
}

fn calc_score(input: &Input, t: &Vec<usize>) -> i64 {
    let mut res = 0;
    let mut last: [usize; 26 + 1] = [0; 26 + 1];
    for day in 1..=input.d {
        let now_contest = t[day];
        res += input.s[day][now_contest];
        last[now_contest] = day;
        for contest in 1..=26 {
            res -= input.c[contest] * (day - last[contest]) as i64;
        }
    }
    res
}

fn get_time(time: SystemTime) -> f64 {
    time.elapsed().unwrap().as_secs_f64()
}

#[fastout]
fn main() {
    let time = SystemTime::now();
    let mut rand = rand_pcg::Pcg64Mcg::new(890482);

    // input
    input! {
        d: usize,
        _c: [i64; 26],
        _s: [[i64; 26]; d],
    }

    let mut c = vec![0];
    c.extend(_c.iter());

    let mut s = vec![[0; 26 + 1]; d + 1];
    for day in 1..=d {
        for contest in 1..=26 {
            s[day][contest] = _s[day - 1][contest - 1]
        }
    }

    let input = Input { d, c, s };

    let mut t = vec![1; d + 1];

    // process
    let mut score = calc_score(&input, &t);
    while get_time(time) < 1.95 {
        for _ in 1..=1000 {
            if rand.gen_bool(0.5) {
                let day = rand.gen_range(1, d + 1);
                let contest = rand.gen_range(1, 26 + 1);

                let tmp = t[day];
                t[day] = contest;
                let next_score = calc_score(&input, &t);
                if next_score > score {
                    score = next_score;
                } else {
                    t[day] = tmp;
                }
            } else {
                let day1 = rand.gen_range(1, d);
                let day2 = rand.gen_range(day1 + 1, min(d + 1, day1 + 16));

                let tmp = t[day1];
                t[day1] = t[day2];
                t[day2] = tmp;

                let next_score = calc_score(&input, &t);
                if next_score > score {
                    score = next_score;
                // println!("{} {}", score, get_time(time));
                } else {
                    t[day2] = t[day1];
                    t[day1] = tmp;
                }
            }
        }
    }

    for i in 1..=d {
        println!("{}", t[i]);
    }
}


Measured memory_bytes: 2352
require "prime"
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
A=get_i
#N=10**6
#A=(1..N).to_a
num=A.tally
flag=true
seen=array(10**6+1,false)
2.upto(10**6) do|x|
  cnt=0
  k=x
  next if seen[k]
  while k<=10**6 and cnt<=1
      cnt+=num[k] unless num[k].nil?
      seen[k]=true
      k+=x
  end 
  if cnt>1
      flag=false
      break
  end
end
if flag
    puts "pairwise coprime"
else
    if A.inject(0){|res,x| res=res.gcd(x)}==1
        puts "setwise coprime"
    else
        puts "not coprime"
    end
end

Measured memory_bytes: 126004
#include <iostream>
#include <algorithm>

const int MAX = 200005;
int64_t A[MAX];
int main()
{
    std::ios_base::sync_with_stdio(0);
    int n;
    std::cin >> n;
    int64_t s = 0, ss = 0;
    for (int i=0;i<n;++i) { std::cin >> A[i]; s+=A[i]; }
    int64_t l = 0;
    int64_t r = s;
    int64_t result = 0;
    for (int i=0;i<n;++i) {
        if (ss*2 <= s && s <= (ss+A[i])*2)
        {
            l = ss;
            r = ss+A[i];
            result = std::min(s-2*l, 2*r-s);
        }
        ss += A[i];
    }
    std::cout << result;
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner (System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		int distA = Math.abs(a-x);
		int distB = Math.abs(b-x);

		System.out.println(distA < distB ? "A" : "B");
	}
}


Measured memory_bytes: 35620
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

signed main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("error.txt", "w", stderr);
// #endif
	crap;

	int n;
	cin>>n;

	map<int,int> mp;

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

	int total = 0;
	for(auto x: mp){
		total += x.second * (x.second - 1)/2;
	}

	for(int i=0; i<n; i++){
		int val = mp[vec[i]];
		cout << total - val + 1 << endl;

	}

	return 0;
}






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



int main() {
   int n;
   cin >> n;
   vector<int> a(n);
   for (int i=0; i<n; i++) {
      cin >> a[i];
   }
   for (int i=0; i<n; i++) {
      if (a[i] % 2 == 0) {
         if ((a[i] % 3 != 0) && (a[i] % 5 != 0)) {
            cout << "DENIED" << endl;
            return 0;
         }
      }
   }
   cout << "APPROVED" << endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define int long long int
#define modulo 1000000007
using namespace std;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int cnt=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(x>=k)cnt++;
    }
    cout<<cnt;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==5&&b==5&&c==7||a==5&&b==7&&c==5||a==7&&b==5&&c==5){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
}

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


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

  int ans=0;
  for(int i=1;i<=n;++i){
    if(i%2==0)continue;
    if(a[i]%2!=0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}

		for (int i = n-1; i >= 0; i--) {
			if (i != 0) {
				System.out.print(a[i] + " ");
			} else {
				System.out.println(a[i]);
			}
		}

	}

}

Measured memory_bytes: 26528
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main() {
	int a,p=0;
	cin >> a;
	vector<int> s(a);
	for (int i = 0; i < a; i++) {
		cin >> s[i];
		for (;;) {
			if (s[i] == 0||s[i]%2==1)break;
			if (s[i] % 2 == 0) s[i] /= 2,p++;
			
		}
	}
	cout << p << endl;
	return 0;

}

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

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

    bool F[N][5][2];
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            for (int k = 0; k < 2; k++)
            {
                cin >> F[i][j][k];
            }
        }
    }

    int P[N][11];
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 11; j++)
        {
            cin >> P[i][j];
        }
    }

    int ans = INT_MIN;
    for (int i = 1; i < (1 << 10); i++)
    {
        bitset<16> b(i);
        int count[N] = {};
        for (int j = 0; j < 10; j++)
        {
            if (b[j])
            {
                for (int k = 0; k < N; k++)
                {
                    if (F[k][j / 2][j % 2])
                    {
                        count[k]++;
                    }
                }
            }
        }

        int profit = 0;
        for (int j = 0; j < N; j++)
        {
            profit += P[j][count[j]];
        }
        ans = max(ans, profit);
    }
    cout << ans << endl;
}


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

int main(){
  int N;
  cin >> N;
  //　4ケタ整数の判別
  if(N % 1111 == 0){
  	cout << "Yes" << endl;
  }
  //  3ケタ整数の判別
  else if(N % 1000 % 111 == 0 || (N - N % 1110 % 10) % 1110 == 0){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import itertools
from collections import deque
from sys import stdin
input = stdin.readline


def main():
  H, W = list(map(int, input().split()))

  M = [input()[:-1] for _ in range(H)]

  def bfs(start):
    dist = [[float('inf')]*W for _ in range(H)]
    dist[start[0]][start[1]] = 0

    q = deque([start])
    max_ = 0

    while len(q):
      now_h, now_w = q.popleft()
      if M[now_h][now_w] == '#':
        return
      for next_h, next_w in ((now_h+1, now_w),
                             (now_h-1, now_w),
                             (now_h, now_w-1),
                             (now_h, now_w+1)):

        if not(0 <= next_h < H) or not(0 <= next_w < W) or \
           (dist[next_h][next_w] != float('inf')) or \
           M[next_h][next_w] == '#':
          continue

        # temp = dist[now_h][now_w] + 1
        # dist[next_h][next_w] = temp
        # if max_ < temp:
        #   max_ = temp
        dist[next_h][next_w] = dist[now_h][now_w] + 1
        max_ = max(max_, dist[next_h][next_w])
        q.append((next_h, next_w))
    return max_

  max_ = 0
  for h in range(H):
    for w in range(W):
      if M[h][w] == '.':
        max_ = max(bfs((h, w)), max_)

  print(max_)


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 68864
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define x real()
#define y imag()
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int n;
	cin >> n;
	cout << n * n << "\n";
}



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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  char c;
  cin >> c;

  if (c <= 'Z') {
    cout << 'A' << endl;
  } else {
    cout << 'a' << endl;
  }
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(void){
    int x, fh, ov, fy, hap;
    scanf("%d",&x);
    fh = x / 500; ov = x % 500; fy = ov / 5;
    hap = fh * 1000 + fy * 5;
    printf("%d",hap);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <climits>
#include <functional>
#include <algorithm>

#define REP(i , begin , end) for( int i = begin; i < end ; ++i )
#define LOOP(n) for(int i = 0; i < n ; ++i)
#define FOREACH(v , fn) std::foreach(v.begin(), v.end(), fn)
#define FINDIF(v, fn) std::find_if( v.begin() , v.end() , fn)

using namespace std;

using ll = long long;
using ull = unsigned long long;
template<class T>
using Graph = vector<vector<T>>;

int main(){
  int H, N;
  cin >> H >> N;
  int sum = 0;
  LOOP(N){
    int a;
    cin >> a;
    sum += a;
  }
  cout << (sum >= H ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const ll INF=1LL<<60;
const ll mod=1E9+7;



int main(){
  int l,r,d,ans=0;
  cin >> l >> r >> d;
  for(int i=l;i<=r;i++){
    if(i%d==0)ans++;
  }
  cout << ans;
}


Measured memory_bytes: 3592
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(S: str, T: str):
    print(T+S)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string S,s;
int n,a,b;

int main(){
	cin >> S;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> s >> a >> b;
		if(s == "print"){
			string t = S.substr(a,b-a+1);
			cout << t << endl;
		}else if(s=="reverse"){
			reverse(S.begin()+a,S.begin()+b+1);
		}else{
			string u;
			cin >> u;
			S.replace(a,b-a+1,u);
		}
	}
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    long n,ans=0;
    string s;
    cin >> n >> s;
    int r[4001]={},g[4001]={},b[4001]={};
    rep(i,n){
        if(s[i]=='R') r[i+1] = r[i] + 1;
        else r[i+1] = r[i];
        if(s[i]=='G') g[i+1] = g[i] + 1;
        else g[i+1] = g[i];
        if(s[i]=='B') b[i+1] = b[i] + 1;
        else b[i+1] = b[i];
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int a = 'R'+'B'+'G';
            if(s[i]==s[j]) continue;
            char d = a-s[i]-s[j];
            int cur = 0;
            if(d=='R') cur = r[n]-r[j];
            if(d=='G') cur = g[n]-g[j];
            if(d=='B') cur = b[n]-b[j];
            if(s[2*j-i]==d) cur--;
            ans += cur;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3668
N = int(input())
song = ["a"] * N
time = [0] * N
for i in range(N):
	s, t = input().split()
	song[i] = s
	time[i] = int(t)
X = input()

idx = 0
for i in range(N):
	if X == song[i]:
		idx = i
		break

ans = 0
for i in range(idx+1, N):
	ans += time[i]

print(ans)

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

using namespace std;

string s;

int main(){
	std::ios::sync_with_stdio(false);
    cin.tie(0);
	cin >> s;
	int ans = 0;
	for(int i=s.size()-2;i>=0;i--){
		if((i+1)%2!=0) continue;
		int mid = i/2+1, f = 1;
		for(int k=0;mid<=i;mid++,k++){
			if(s[k]!=s[mid]){
				f = 0;
				break;
			}
		}
		if(f){
			ans = i+1;
			break;
		}
	}
	cout << ans << "\n";

	return 0;
} 


Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        p: [f64; n],
    }

    let mut dp = vec![vec![0f64; n / 2 + 2]; n + 1];
    dp[0][0] = 1.0;
    for i in 0..n {
        for j in 0..n / 2 + 2 {
            dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
            let nj = std::cmp::min(j + 1, n / 2 + 1);
            dp[i + 1][nj] += dp[i][j] * p[i];
        }
    }
    println!("{}", dp[n][n / 2 + 1]);
}


Measured memory_bytes: 41212
#import sys
#input = sys.stdin.readline
Q = 10**9+7
def main():
    S = input()
    N = len(S)
    dp = [[0]*13 for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        s = S[N-1-i]
        r = pow(10, i, 13)                
        if s == '?':
            for k in range(10):
                t = k*r%13
                for j in range(13):
                    dp[i+1][(j+t)%13] = (dp[i+1][(j+t)%13] + dp[i][j])%Q
            continue
        t = int(s)*r%13
        for j in range(13):
            dp[i+1][(j+t)%13] = dp[i][j]
    print(dp[N][5])
if __name__ == '__main__':
    main()


Measured memory_bytes: 62008
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf')]*n
dp[0] = 0
for i in range(n):
    for j in range(1, k+1):
        if i+j < n:
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]))
print(dp[n-1])

Measured memory_bytes: 55264
#include<stdio.h>
int e[100002],f[100002][2];
//大きい順
void merge(int i,int j,int *s){
  if(i!=j){
    merge(i,(i+j)/2,s);
    merge((i+j)/2+1,j,s);
    int a=i,b=(i+j)/2+1;
    int d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        e[d]=s[b];
        b++;
      }
      else if(j<b){
        e[d]=s[a];
        a++;
      }
      else if(s[a]>s[b]){
        e[d]=s[a];
        a++;
      }
      else{
        e[d]=s[b];
        b++;
      }
    }
    for(d=i;d<=j;d++)
      s[d]=e[d];
  }
}

//大きい順
void sort(int i,int j,int s[][2]){
  if(i!=j){
    sort(i,(i+j)/2,s);
    sort((i+j)/2+1,j,s);
    int a=i,b=(i+j)/2+1;
    int d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        f[d][0]=s[b][0];
        f[d][1]=s[b][1];
        b++;
      }
      else if(j<b){
        f[d][0]=s[a][0];
        f[d][1]=s[a][1];
        a++;
      }
      else if(s[a][1]>s[b][1]){
        f[d][0]=s[a][0];
        f[d][1]=s[a][1];
        a++;
      }
      else{
        f[d][0]=s[b][0];
        f[d][1]=s[b][1];
        b++;
      }
    }
    for(d=i;d<=j;d++){
      s[d][0]=f[d][0];
      s[d][1]=f[d][1];
    }
  }
}

int main(){
  int n,m,i;
  scanf("%d%d",&n,&m);
  int a[n+1],b[m+1][2];
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  merge(0,n-1,a);
  for(i=0;i<m;i++)
    scanf("%d%d",&b[i][0],&b[i][1]);
  sort(0,m-1,b);
  int bcount=0,anum=0,bnum=0;
  long long sum=0;
  for(i=0;i<n;i++){
    long long num;
    if(a[anum]<b[bnum][1] && bnum<m){
      num=b[bnum][1];
      sum+=num;
      bcount++;
    }
    else{
      num=a[anum];
      sum+=num;
      anum++;
    }
    if(bcount==b[bnum][0]){
      bnum++;
      bcount=0;
    }
  }
  printf("%lld\n",sum);
  return 0;
}


Measured memory_bytes: 2560
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int N=100100;
int i,j,k,n,m,En,ch,ff;
int a[N],h[N];
struct edge { int s,n;} E[N];
void R(int &x) {
	x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void E_add(int x,int y) {
	E[++En].s=y;E[En].n=h[x];h[x]=En;
}
int dfs(int x) {
	vector<int> A;
	for (int k=h[x];k;k=E[k].n) A.push_back(dfs(E[k].s));
	sort(A.begin(),A.end());
	int ma=0;
	for (int i=0;i<A.size();i++) ma=max(ma,A[i]+(int) A.size()-i);
	return ma;
}
int main() {
	R(n);
	for (i=2;i<=n;i++) {
		R(a[i]);
		E_add(a[i],i);
	}
	printf("%d\n",dfs(1));
}

Measured memory_bytes: 9600
//abc159_a.cpp
//Sat Apr 18 22:42:09 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

int main(){
	int n,m;
	cin >> n >> m;

	cout << n*(n-1)/2+m*(m-1)/2 << endl;
//	printf("%.4f\n",ans);
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n, -1);
    bool ok = true;
    rep(i,m) {
        int s, c;
        cin >> s >> c;
        if (a.at(s-1) == -1 ) {
            a.at(s-1) = c;
        }
        else ok = a.at(s-1) == c;
    }

    if (n!=1 && a.at(0) == 0) ok = false;
    if(!ok) {
        cout << -1 << endl;
        return 0;
    }
    if (n==1 && a.at(0) == -1) {
        cout << 0 << endl;
        return 0;
    }
    rep(i,n) {
        if(a.at(i) == -1) {
            a.at(i) = i == 0 ? 1:0;
        }
        cout << a.at(i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3604
parseInt(x) = parse(Int,x)

function g(b)
  l = length(b)
  tmp = 0
  for i = 1:l
    tmp += b[i]
  end
  return(tmp)
end

function f(N,i,b,a)
  c = 0
  g(b[i:i:N]) % 2 == a ? c = 0 : c = 1
  return(c)
end

function main()
  N = parseInt(readline())
  a = map(parseInt,split(readline()))
  b = zeros(Int,N)
  for i = N:-1:1
    b[i] = f(N,i,b,a[i])
  end
  println(sum(b))
  for i in 1:N
    if b[i] == 1
      i < N ? print(i," ") : print(i)
    end
  end
end

main()

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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++){
    cin >> d[i];
  }
  
  int ans = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < i; j++){
      ans += d[i]*d[j];
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define  REP(i, s, e) for (register int i = (s), end_##i = (e); i <= end_##i; i++)
#define DREP(i, s, e) for (register int i = (s), end_##i = (e); i >= end_##i; i--)
#define DEBUG fprintf(stderr, "Passing [%s] in Line %d\n", __FUNCTION__, __LINE__)

#define chkmax(a, b) (a < (b) ? a = (b) : a)
#define chkmin(a, b) (a > (b) ? a = (b) : a)

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>

using namespace std;

template <typename T> T read()
{
	T ans(0), flag(1);
	char c(getchar());
	while (!isdigit(c))
	{
		if (c == '-') flag = -1;
		c = getchar();
	}
	while (isdigit(c))
	{
		ans = ans * 10 + c - 48;
		c = getchar();
	}
	return ans * flag;
}

void file(string s)
{
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

int m, n, k;

int main()
{
#ifdef CraZYali
	file("A");
#endif
	cin >> n;
	REP(i, 1, 9)
		REP(j, 1, 9) if (i * j == n)
		{
			cout << "Yes\n";
			return 0;
		}
	cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            int a, p;
            ReadInt(out a, out p);
            int ans = (a * 3 + p) / 2;
            Console.WriteLine(ans);
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    ll k,a,b;
    cin >> k >> a >> b;
    ll ans = k+1,tmp = 0;

    if(k<a || b-a <= 2){
        ans = k+1;
    }else{
        if((k-(a-1))%2 == 0){
            tmp = a + (b-a)*((k-(a-1))/2);
        }else{
            tmp = a + (b-a)*((k-(a-1))/2) + 1;
        }
        ans = max(ans,tmp);
    }

    cout << ans << endl;





    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	int a[101]={0};
	while(cin>>n){
		a[n]++;
	}
	int m=0;
	for(int i=1; i<101; i++)
		m=max(m, a[i]);
	for(int i=1; i<101; i++){
		if(a[i]==m)
			cout<<i<<endl;
	}
	return 0;
}


Measured memory_bytes: 3080
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;

class Program
{
	static void Main(string[] args)
	{
		long N = long.Parse(Console.ReadLine());
		long ans = 0;
		for(long l = 1;l < N; l++)
		{
			ans += l;
		}

		Console.WriteLine(ans);
	}
}

//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
//Boolean ok = false;

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();

//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

Measured memory_bytes: 11092
from bisect import bisect_left

n, q = [int(x) for x in input().split()]
s = input()

index_list = []
i = 0
while i < n - 1:
    if s[i] == "A" and s[i + 1] == "C":
        index_list.append(i + 1)
        i += 2
    else:
        i += 1

for _ in range(q):
    l, r = [int(x) for x in input().split()]
    print(bisect_left(index_list, r) - bisect_left(index_list, l))

Measured memory_bytes: 5772
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){
    int a, b;
    
    cin>>a>>b;
    
    int sum=0;
    for(int i=1; i<=b-a-1; i++){
        sum+=i;
    }
    
    cout<<sum-a<<endl;
}


Measured memory_bytes: 256
n=gets.to_i
v=gets.chomp.split.map(&:to_i)
v1=[]
v2=[]

h1 = Hash.new(0)
h2 = Hash.new(0)
v.each_with_index do |w, i|
    if i%2==0
        v1 << w
        h1[w] += 1
    else
        v2 << w
        h2[w] += 1
    end
end

hh1 = h1.to_a.sort {|a,b| a[1] <=> b[1]}.reverse
hh2 = h2.to_a.sort {|a,b| a[1] <=> b[1]}.reverse

#p hh1
#p hh2
ans =0
if hh1[0][1] == hh2[0][1] && hh2[0][1] == n/2
    if hh1[0][0] == hh2[0][0]
        puts n/2
    else
        puts 0
    end
elsif hh1[0][1] == hh2[0][1] && hh1[0][0] == hh2[0][0]
    ans += n/2 - hh1[0][1] 
    if hh1[1][1] > hh2[1][1]
        ans += n/2 - hh1[1][1] 
    else
        ans += n/2 - hh2[1][1]
    end
    puts ans
elsif hh1[0][1] == hh2[0][1]
    ans += n - hh1[0][1] - hh2[0][1]
    puts ans
else
    ans += n - hh1[0][1] - hh2[0][1]
    puts ans
end


Measured memory_bytes: 22084
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int n, x[3100], y[3100];
bool ex[5100][5100];

bool isex(int x, int y) {
    if (x < 0 || x > 5000 || y < 0 || y > 5000) return false;
    return ex[x][y];
}

int main() {
    while (cin >> n) {
        if (n == 0) break;
        memset(ex, 0, sizeof(ex));
        for (int i = 0; i < n; ++i) {
            cin >> x[i] >> y[i];
            ex[x[i]][y[i]] = true;
        }
        int res = 0;
        for (int i = 0; i < n; ++i) {
            for (int j = i+1; j < n; ++j) {
                int dx = x[j] - x[i], dy = y[j] - y[i];
                
                int dx1 = dy, dy1 = -dx;
                if (isex(x[i]+dx1, y[i]+dy1) && isex(x[j]+dx1, y[j]+dy1)) chmax(res, dx*dx+dy*dy);
                if (isex(x[i]-dx1, y[i]-dy1) && isex(x[j]-dx1, y[j]-dy1)) chmax(res, dx*dx+dy*dy);
            }
        }
        
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 26592
# -*- coding: utf-8 -*-

from random import *
import copy

def command(hougaku, label):
    temp = {}
    temp = copy.deepcopy(label)
    if(hougaku == 'E'):
        label[1] = temp[4]
        label[3] = temp[1]
        label[4] = temp[6]
        label[6] = temp[3]
    elif(hougaku == 'W'):
        label[1] = temp[3]
        label[3] = temp[6]
        label[4] = temp[1]
        label[6] = temp[4]
    elif(hougaku == 'N'):
        label[1] = temp[2]
        label[2] = temp[6]
        label[5] = temp[1]
        label[6] = temp[5]
    elif(hougaku == 'S'):
        label[1] = temp[5]
        label[2] = temp[1]
        label[5] = temp[6]
        label[6] = temp[2]

if __name__=="__main__":
    label1 = {}
    label2 = {}
    n1 = map(int, raw_input().split())
    n2 = map(int, raw_input().split())
    for i in range(6):
        label1[i+1] = n1[i]
        label2[i+1] = n2[i]
    #print label1
    #print label2
    count = 0
    flag = 0
    while True:
        if(label1 == label2):
            flag = 1
            break
        x = random()
        if(x < 0.25):
            command('E', label1)
        elif(x < 0.50):
            command('W', label1)
        elif(x < 0.75):
            command('N', label1)
        else:
            command('S', label1)
        count += 1
        #print label1
        if(count > 1000):
            break
    if(flag == 1):
        print 'Yes'
    else:
        print 'No'

Measured memory_bytes: 5488