akhauriyash/Code-Regression huggingface dataset:
const Main = input => {
    input = input.split("\n");
    const xn = input[0].split(" ").map(value => parseInt(value, 10));

    const x = xn[0];
    const n = xn[1];

    let near;
    if(n === 0) {
        //nが0のときはx自身を答えにする
        near = x;
    } else {
        const p = input[1].split(" ").map(value => parseInt(value, 10));

        //pに存在する整数を除いた1~100までのリスト
        const list = [];
        for(let i = 0; i <= 101; i++) {
            if(p.includes(i)) continue;
            list.push(i);
        }

        near = 0;
        list.forEach(value => {
            if(Math.abs(value - x) < Math.abs(near - x)) {
                near = value;
            }
        })
    }

    console.log(near);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29596
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <iomanip>
#include <cassert>
#include <numeric>
using namespace std;
 
#define ff first
#define ss second
#define pb push_back 
 
using LL = long long int;
using VL = vector<LL>;
using VI = vector<int>;
using VVL = vector<VL>;
using PLL = pair<LL,LL>;
using PII = pair<int ,int>;
 
#ifdef DEBUG
void _print()
{
  cout << endl;
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
  cout << first_elem << " ";
  _print(args...);
}
#else
void _print()
{
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
}
#endif
 
 
// NOTE: Please dont implement _print() as function in your program. It is reserved
// for debug purpose.

int main()
{
    ios::sync_with_stdio(false);
    LL t = 1;
    while (t--) {
        LL n;
        cin >> n;
        
        
        LL num = n;
        _print(num);
        string ans = "";
        for (int i = 1; i <= 64 && num; i++) {
            LL dig = num % 26;
            _print(dig);
            ans += ('a' + (dig + 25) % 26);
            num /= 26;
            if (dig == 0 && num) {
                num--;
            }
        }

        reverse(ans.begin(), ans.end());
        cout << ans << endl;

        


    }
    return 0;
    
}


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

int main(void){
  int h,w,n;
  cin >> h >> w >> n;
  int ma = max(h,w);
  int mi = min(h,w);
  int count = 0;
  int ans = 0;
  for(int i = 1; i <= mi; i++){
    count += ma;
    if(count >= n){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    N, X = map(int, input().split())
    l = list(map(int, input().split()))
    p = 0
    record = [0]
    for i in range(N):
        p += l[i]
        if p > X:
            break
        record.append(p)
    print(len(record))
main()  

Measured memory_bytes: 9152
import java.io.*;
class Main {
 public static void main(String[] args) throws IOException{
     BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
     String s = new String(br.readLine());
     String[] arg = s.split(" ");
     int width = Integer.parseInt(arg[0]) - 1;
     int length = Integer.parseInt(arg[1]) - 1;
     System.out.println(width*length);

 }
}

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

int main(){
    int k;
    string str;
    cin >> k >> str;
    if(str.size() <= k){
        cout << str << endl;
    } else {
        cout << str.substr(0, k) << "...\n";
    }
    return 0;
}

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

#define mp make_pair
#define fst first
#define snd second

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef pair<i64,int> pli;
typedef pair<int,i64> pil;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

const int MAX_N = 1000;
int n,m;
i64 xyz[3][MAX_N];
i64 a[MAX_N];

int main()
{
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> xyz[0][i] >> xyz[1][i] >> xyz[2][i];
  }

  i64 res = 0;
  for (int p = 0; p < 8; p++) {
    fill_n(a,n,0);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 3; j++) {
        if (p & (1 << j)) a[i] -= xyz[j][i];
        else a[i] += xyz[j][i];
      }
    }
    sort(a,a+n);
    reverse(a,a+n);
    res = max(res, accumulate(a,a+m,INT64_C(0)));
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define N 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int x, y, z;
    cin >> x >> y >> z;
    swap(x,y);
    swap(x,z);
    cout << x << " " << y << " " << z << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
int main() {
    std::string s;
    std::getline(std::cin, s);
    char c;
    for (char c:s) {
        if (islower(c)) std::cout << char(toupper(c));
        else if (isupper(c)) std::cout << char(tolower(c));
        else std::cout << c;
    }
    std::cout << std::endl;
}


Measured memory_bytes: 3200
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=5e5+5;
int n,t,opt,tree[maxn<<2],pos,x,y;
char s[maxn],ch;
void build(int node,int l,int r){
    if(l==r){
        tree[node]=1<<(s[l]-'a');
        return ;
    }
    int mid=(l+r)>>1;
    build(node<<1,l,mid);
    build(node<<1|1,mid+1,r);
    tree[node]=tree[node<<1]|tree[node<<1|1];
}
void change(int node,int l,int r,int pos){
    if(l==r&&l==pos){
        tree[node]=1<<(ch-'a');
        return ;
    }
    int mid=(l+r)>>1;
    if(mid>=pos)    change(node<<1,l,mid,pos);
    else            change(node<<1|1,mid+1,r,pos);
    tree[node]=tree[node<<1]|tree[node<<1|1];
}
int query(int node,int L,int R,int l,int r){
    if(L<=l&&R>=r){
        return tree[node];
    }
    int mid=(l+r)/2,ans=0;
    if(mid>=L) ans=ans|query(node<<1,L,R,l,mid);
    if(mid<R)  ans=ans|query(node<<1|1,L,R,mid+1,r);
    return ans;
}
int main(){
    scanf("%d %s %d",&n,s+1,&t);
    build(1,1,n);
    while(t--){
        scanf("%d",&opt);
        if(opt==1){
            scanf("%d %c",&pos,&ch);
            if(s[pos]!=ch){
                change(1,1,n,pos);
                s[pos]=ch;//改变
            }
        }else{
            scanf("%d %d",&x,&y);
            printf("%d\n",__builtin_popcount(query(1,x,y,1,n)));
        }
    }
    return 0;
}



Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  long long A,B;
  cin >> A >> B;
  if((A+B)%2==1){cout << "IMPOSSIBLE" << endl;}
  else{cout << (A+B)/2 << endl;}
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"
 
using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
 
//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
	
 
 
int main() {
	int r, g, b;
	cin >> r >> g >> b;
	cout << ((100 * r + 10 * g + b) % 4 == 0 ? "YES" : "NO") << endl;
 
	return 0;
}

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

int N;

int main() {
  cin >> N;
  long long sum=0;
  for(int i=1;i<=N;i++){
    if(i%3==0){
      continue;
    }else if(i%5==0){
      continue;
    }else{
      sum+=i;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3220
#include<stdio.h>
int main(void){
    int i,j,H,W;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0)break;
        for(i=1;i<=H;i++){
            for(j=1;j<=W;j++){
                if((((i%2)==0)&&((j%2)==0))||(((i%2)==1)&&((j%2)==1))){
                    putchar('#');
            }
            else{
                putchar('.');
            }
        }
        printf("\n");
        }
        printf("\n");
    }
}


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

int dp[100005],m,n,sizea;

int sizenum(int a){
    sizea=0;
    int b=a;
    while(b>0){
        b/=10;
        sizea++;
    }
    return sizea;
    
}

int power(int a,int b){
    if(b>=1) return a*power(a,b-1);
    if(b==0) return 1;
    
    
}
bool pld(int y){
    for(int i=1;i<=sizenum(y)/2;i++){
        if((y/power(10,i-1))%10!=(y/power(10,sizenum(y)-i))%10) return false;
    }
    return true;
    
}


int main(){
    cin >> m >> n;
    for(int i=1;i<=100000;i++){
        if(pld(i)==true) dp[i]++;
        dp[i]+=dp[i-1];
    }
    cout<<dp[n]-dp[m-1];
    
}

Measured memory_bytes: 640
N, K = map(int,input().split())
A = [int(i) for i in input().split()]
cnt = 0
B = A*2
cnt1 = 0
for i in range(N-1):
  for j in range(i+1,N):
    if A[i] > A[j]:
      cnt += 1
for i in range(N):
  for j in range(N, 2*N):
    if B[i] > B[j]:
      cnt1 += 1
print((cnt*K+cnt1*K*(K-1)//2)%(10**9+7))

Measured memory_bytes: 41836
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	int n,k;cin>>n>>k;
	int j;
	rep(i,n){
		int a;cin>>a;
		if(a==1) j=i;
	}
	int ans;
	if(j<k-1||n-k<j) cout<<((n-k)+(k-2))/(k-1)+1<<endl;
	else cout<<((n-1)+(k-2))/(k-1)<<endl;
}


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

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

		for (int i = 0; i < N; i++) {
			v[i] = sc.nextInt();
		}
		Arrays.sort(v);
		double cal = v[0];
		for (int i = 1; i < N ; i++) {
			cal += v[i];
			cal /= 2;
		}
		System.out.println(cal);
	}
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	string S, T;
	char a[26], b[26];
	
	rep(i, 26)
	{
		a[i] = '-';
		b[i] = '-';
	}

	cin >> S >> T;

	rep(i, S.size())
	{
		if (a[S[i] - 'a'] == '-'  && b[T[i] - 'a'] == '-')
		{
			a[S[i] - 'a'] = T[i];
			b[T[i] - 'a'] = S[i];
		}	
		else
		{
			if (a[S[i] - 'a'] != T[i] || b[T[i] - 'a'] != S[i])
			{
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
//#include <queue>

using namespace std;
#define n_max 10000
#define INF 10001000

#define rep(i, a, n) for(int i = a; i < n; i++)
#define rep2(i, a, n) for(int i = a; i <= n; i++)
#define rrep(i, a, n) for(int i = a; i > n; i--)
#define rrep2(i, a, n) for(int i = a; i >= n; i--)
#define lrep(i, a, n) for(long int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

int main()
{
    long int ans = 0;
    int N;

    cin >> N;

    map<string, long int> A;

    for(int i = 0; i < N; i ++) {
        string tmp;
        cin >> tmp;
        sort(tmp.begin(), tmp.end());
        A.insert(make_pair(tmp, 0));
        A.at(tmp)++;
    }

    for(auto i = A.begin(); i != A.end(); i++) {
        ans += i->second * (i->second-1) / 2;
        //cout << "key -> " << i->first << ", value -> " << i->second << endl; 
    }
    cout << ans << endl; 

    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <fstream>
#include <set>
using namespace std;

int main()
{
    //ifstream cin("input.txt");

    int N, S;
    cin >> N >> S;
    S /= 1000;
    int x, y, z, tempS, tempN;
    for (x = 0; x <= S / 10; ++x)
    {
        tempN = N - x;
        tempS = S - 10 * x;
        if ((tempS - tempN) % 4 != 0)
            continue;
        y = (tempS - tempN) / 4;
        z = tempN - y;
        if (y >= 0 && z >= 0)
        {
            cout << x << ' ' << y << ' ' << z;
            return 0;
        }
    }
    cout << "-1 -1 -1";
}


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

int main() {
    ll n;
    cin >> n;
    ll ans = 1001001001001001001;
    for (ll a = 1; a * a <= n; ++a) {
        if (n % a == 0) {
            ll b = n / a;
            ans = min(ans, a + b - 2);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
import sys
 
stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
 
n,m = na()
ba = []
for i in range(n):
    ba.append(ns())
bb = []
for i in range(m):
    bb.append(ns())
 
for i in range(n-m+1):
    for j in range(n-m+1):
        ok = True
        for k in range(m):
            if ba[i+k][j:j+m] != bb[k]:
                ok = False
                break
        if ok:
            print("Yes")
            sys.exit(0)
print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>

using namespace std;



int main() {
	int n ,k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	sort(h.begin(), h.end());
	int ans = 1000000000;
	for (int i = 0; i <= n - k;i++) {
		if (ans > h[i + k - 1] - h[i]) {
			ans = h[i + k - 1] - h[i];
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    for(int i=n-1;i>=0;i--){
        if(i!=0)cout<<a[i]<<" ";
        else cout<<a[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

 

int main() {
	int a, b; cin >> a >> b;
	string s;
	if (a < 0 && b>0)s = "Zero";
	else if (a > 0)s = "Positive";
	else {
		if ((b - a + 1) % 2 == 0)s = "Positive";
		else s = "Negative";
	}
	print(s);




	return 0;
}

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

int main(){
    int n,m;
    cin>>n;
    vector<int>d(n);
    for(int i=0; i<n; i++) cin>>d[i];
    cin>>m;
    vector<int> t(m);
    for(int i=0; i<m; i++) cin>>t[i];
    map <int,int> mpd,mpt;
    for(int i=0; i<n; i++) mpd[d[i]]++;
    for(int i=0; i<m; i++) mpt[t[i]]++;
    for(int i=0; i<m; i++) {
        if(mpt[t[i]] > mpd[t[i]]) {
            cout<<"NO"<<"\n";
            return 0;
        }
    }
    cout<<"YES"<<"\n";
}

Measured memory_bytes: 20608
s=input()

ans=0
g=0
for h in s:
    if g>0:
        #pを出せるなら出す
        g-=1
        if h=='g':
            ans+=1
    else:
        #pが出せないならg
        g+=1
        if h=='p':
            ans-=1

print(ans)

Measured memory_bytes: 3316
<?php
// https://atcoder.jp/contests/abc044/tasks/abc044_b
// どの英小文字も、w中に偶数回出現すればYesを出力する

// AtCoderではmb_substr_countは使えない
// count_string($array, $string)で$arrayに含まれる$stringの数をカウントする
function count_string($array, $string)
{
  return count(array_keys($array, $string));
}

// fgets(STDIN)で標準入力
// trimで改行を削除
// str_splitで配列化(array_keysは文字列には使えないため)
$w = str_split(trim(fgets(STDIN)));

// 予めアルファベットを定義しておく,str_splitで配列化
$ALPHABETS = str_split("abcdefghijknmlopqrstuvwxyz");

// 出力を定義
$ans = "Yes";


// 入力された文字列に登場したアルファベットの数が奇数であれば,$ansに"No"を代入する
foreach($ALPHABETS as $alphabet){
  if (count_string($w, $alphabet)%2 == 1){
    $ans = "No";
  }
}

// 答えを出力する
echo $ans."\n";

Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
const int MAX = 3000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
//invの要素にはiの逆元が格納されている
//前処理
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;//i!(mod MOD)を計算
        inv[i] = MOD - inv[MOD%i]* (MOD / i) % MOD;//iの逆元を計算
        finv[i] = finv[i - 1] * inv[i] % MOD;//i!(mod MOD)の逆元を計算
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;//nCk = n!/(k!*(n-k)!)を計算
}
long long mod_pow(long long x, long long y){
    if(y == 0) return 1;
    long long res = 1;
    while(y != 0){
        if(y & 1) res = res*x%MOD;
        x = x * x % MOD;
        y >>= 1;
    }
    return res;
}
int main(){
    COMinit();
    long long K;
    cin >> K;
    string S;
    cin >> S;
    long long siz = S.size();
    long long res = 0;
    for(int i = 0; i < siz; i++){
        res = res + COM(siz + K, i) * mod_pow(25, siz + K - i) % MOD;
        res %= MOD;
    }
    long long ans = (mod_pow(26, K + siz) - res + MOD) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 75504
//BISMILLAH
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i;
    int n;
    cin >> n;
    int a[n],b[n];
    int fl = 0;
    for(i = 0;i<n;i++){
        cin >> a[i] >> b[i];
        if(i>=2){
            if(a[i] == b[i] && a[i-1] == b[i-1] && a[i-2] == b[i-2]) fl = 1;
        }
    }
    if(fl) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<int, int>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
ll MOD = 1000000007;

template <typename T>
class BIT {
private:
  vector<T> bit;
  int neutral = 0;
  // 更新クエリ, 区間クエリ
  function<T(T,T)> f = [](const T l, const T r) -> T { return max(l, r); },
                   g = [](const T l, const T r) -> T { return max(l, r); };
public:
  BIT(int n_ = 1e5) { init(n_); }
  void init(int n_ = 1e5) { bit.assign(n_+1, neutral); }
  void update(int i, T w) {
    for(int x = i+1; x < bit.size(); x += x&-x) bit[x] = f(bit[x], w);
  }
  // [0,i]
  T query(int i) {
    T ret = neutral;
    for(int x = i+1; x > 0; x -= x & -x) ret = g(ret, bit[x]);
    return ret;
  }
};

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

  while(1) {
    ll n;
    cin >> n;
    if(!n) break;

    vector<ll> dp(n+1);
    dp[0] = 1;
    REP(i, n+1) {
      if(i>=1) dp[i] += dp[i-1];
      if(i>=2) dp[i] += dp[i-2];
      if(i>=3) dp[i] += dp[i-3];
    }
    ll day = ceil(dp[n], 10LL);
    ll year = ceil(day, 365LL);
    cout << year << endl;
  }

  return 0;
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
ll C;
ll n,x[MAXN],v[MAXN];
ll a[MAXN];
ll save1[MAXN],save2[MAXN];
int main()
{
	scanf("%lld",&n);
	scanf("%lld",&C);
	for(ll i=1;i<=n;i++)
		scanf("%lld%lld",&x[i],&v[i]);
	x[n+1]=C;
	for(ll i=1;i<=n;i++)
		a[i]=v[i]-(x[i]-x[i-1]);
	ll now=0;
	for(ll i=1;i<=n;i++)
	{
		now+=a[i];
		save1[i]=max(save1[i-1],now);
	}
	for(ll i=n;i>=1;i--)
		a[i]=v[i]-(x[i+1]-x[i]);
	now=0;
	for(ll i=n;i>=1;i--)
	{
		now+=a[i];
		save2[i]=max(save2[i+1],now);
	}
	ll ans=0;
	for(ll i=1;i<=n;i++)
		a[i]=v[i]-2*(x[i]-x[i-1]);
	now=0;
	for(ll i=0;i<=n;i++)
	{
		now+=a[i];
		ans=max(ans,now+save2[i+1]);
	}
	for(ll i=1;i<=n;i++)
		a[i]=v[i]-2*(x[i+1]-x[i]);
	now=0;
	//printf("%lld\n",save1[3]);
	for(ll i=n+1;i>=1;i--)
	{
		now+=a[i];
		ans=max(ans,now+save1[i-1]);
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
	int n, k;
	string s;
	cin >> n >> k;
	cin >> s;
	
	s.at(k-1) = tolower(s.at(k-1));
	cout << s << endl;
}

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

using namespace std;

typedef long long ll;

constexpr ll MOD = 1e9 + 7;
constexpr ll MAX = 3e6;

ll fac[MAX];
ll inv[MAX];
ll finv[MAX];

ll modpow(ll a, ll n){
  if (n <= 0) return 1;
  ll ret = (n & 1) ? a % MOD : 1;
  n >>= 1;
  return ret * modpow(a * a % MOD, n) % MOD; 
}

void CombInit(){
  fac[0] = fac[1] = 1;
  inv[0] = inv[1] = 1;
  finv[0] = finv[1] = 1;
  for(ll i=2; i<MAX; i++){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}

ll Comb(ll n, ll k){
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main(){
  CombInit();

  ll K;
  string S;
  cin >> K >> S;

  ll SLength = S.size();
  ll ret = 0;
  for(ll i=SLength-1; i<SLength+K; i++){
    ll nRight = SLength + K - (i + 1);
    ll nLeft  = K - nRight;
    ll temp = modpow(25, nLeft) * modpow(26, nRight) % MOD;
    temp = temp * Comb(SLength+K-nRight-1, SLength-1) % MOD;
    ret = (ret + temp) % MOD;
  }

  cout << ret << endl;
}

Measured memory_bytes: 75568
#include <iostream>
#include <algorithm>
#define N 200006
using namespace std;
int main() {
	int n,mi,ans;
	int a[N];
	cin>>n;
	mi=a[0];ans=a[1]-mi;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i==0) mi=a[i];
		else if(i==1){
			ans=a[i]-mi;
		}
		if(a[i]-mi>ans) ans=a[i]-mi;
		if(a[i]<mi) mi=a[i];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3888
#include<bits/stdc++.h>
typedef long long ll;
#define X first
#define Y second
typedef double dbl;
#define forn(i,n,k) for(int i=0;i<n;i=i+k)
#define forpn(p,n,k) for(int i=p;i<n;i+=k)

using namespace std;
long long gcd(int a,int b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
int main()
{
    int n,m;
    cin>>n>>m;
    int h[n][2];
    for(int i=0;i<n;i++)
    {
        cin>>h[i][0];
        h[i][1]=1;
    }
    // vector<int> path(n);
    
    for(int i=0;i<m;i++)
    {
        int p,q;
        cin>>p>>q;
        if(h[p-1][0]>h[q-1][0]){
            h[q-1][1]=0;
        }
        else if(h[q-1][0]>h[p-1][0]){
            h[p-1][1]=0;
        }
        else {
            h[p-1][1]=0;
            h[q-1][1]=0;
        }
    
        
    }
    int count=0;
    for(int i=0;i<n;i++)
    {
        if(h[i][1]==1) count++;
    }
    cout<<count;
    
    return 0;
}


Measured memory_bytes: 4420
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, a, b, c, d, tmp, m, h, w, x[ohara], y[ohara], sum, k, q;

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

  cin >> n;
  ld ans = 0.0;
  vector<ll> p(n);
  rep(i, n) { cin >> x[i] >> y[i]; }
  rep(i, n) p[i] = i;
  ld waru = 0.0;
  do {
    waru++;
    ld cnt = 0.0;
    rep(i, n - 1) {
      cnt += (ld)sqrt((x[p[i]] - x[p[i + 1]]) * (x[p[i]] - x[p[i + 1]]) +
                      (y[p[i]] - y[p[i + 1]]) * (y[p[i]] - y[p[i + 1]]));
    }
    ans += cnt;
  } while (next_permutation(all(p)));
  doublecout(ans / waru);
  return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

char s[15],k;

int main()
{
    cin.getline(s, 15);
    if((s[0]=='Y')&&(s[1]=='A')&&(s[2]=='K')&&(s[3]=='I')) cout<<"Yes"<<endl;
    else cout<<"No"<<endl; 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    string A;cin >> A;
    ll n = A.size();
    ll res = 1+(n*(n-1))/2;
    vector<ll> cnt(30,0);
    rep(i,n){
        cnt[A[i]-'a']++;
    }
    rep(i,30){
        if(cnt[i]>=2)res -=(cnt[i]*(cnt[i]-1))/2;
    }
    cout << res << endl;
    return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  int count = 0, ans = 0;
  while (count < n) {
    ans++;
    count += max(h, w);
  }
  cout << ans << endl;
}


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

using namespace std;

int main()
{

	int x, y;
	int xi, yi;
	cin >> x >> y;

	if (x == 2)
		xi = 33;
	else if (x == 4 || x == 6 || x == 9 || x == 11)
	{
		xi = 22;
	}
	else
		xi = 11;
	if (y == 2)
		yi = 33;
	else if (y == 4 || y == 6 || y == 9 || y == 11)
	{
		yi = 22;
	}
	else
		yi = 11;

	if (xi == yi)
		cout << "Yes";
	else
		cout << "No";
	return 0;
};

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

using namespace std;

int top, S[1000];

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

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

int main() {
  int a, b;
  top = 0;
  string s;

  while (cin >> s) {
    if (s == "+") {
        b = pop();
        a = pop();
        push(a + b);
    } else if (s == "-") {
        b = pop();
        a = pop();
        push(a - b);
    } else if (s == "*")  {
        b = pop();
        a = pop();
        push(a * b);
    } else {
        push(atoi(s.c_str()));
    }
  }

  cout << pop() << endl;

  return 0;
}

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

int main() {
  int n = 0, a, b;
  cin >> a >> b;
  if(b == 1) cout << 0 << endl;
  else if(a >= b) cout << 1 << endl;
  else{
    while(b > 0){
    if(n == 0) b -= a;
    else b -= a - 1;
    n++;
    }
  cout << n << endl;
  }
}

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

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

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

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let t: String = read(&mut stdin_lock, &mut buf, b'\n');
    let mut sv: Vec<char> = s.chars().collect();
    let mut tv: Vec<char> = t.chars().collect();
    sv.sort();
    tv.sort_by(|a, b| b.cmp(a));
    let ans = if sv < tv { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
	int A,B,C;
	cin >> A >> B >> C;
	if(A==B){
		cout << C << endl;
	}else if(A==C){
		cout << B << endl;
	}else{
		cout << A << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
signed main(){
  Int k,a,b;
  cin>>k>>a>>b;
  if(b<=a||k+1<=a){
    cout<<k+1<<endl;
    return 0;
  }
  Int res=k+1;
  Int x=(k+1-a)/2,y=(k+1-a)%2;
  chmax(res,a+x*(b-a)+y);
  cout<<res<<endl;
  return 0;
}


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

AB = []
for _ in range(1, N):
    a, b = map(int, input().split())
    AB.append((a, b))
    
if N == 1:
    print(K)
else:
    # 無効グラフなので双方向にする
    graph = {}
    for a,b in AB:
        if not a in graph:
            graph[a] = {}
        if not b in graph:
            graph[b] = {}
        graph[a][b] = 1
        graph[b][a] = 1


    #print(graph)

    collors = [None] * (N+1)
    from collections import deque
    q = deque([(K, 1)]) 
    while q:
        col_num, v = q.popleft()
        if collors[v] == None:
            collors[v] = col_num

            if col_num == K:
                rest_col = K-1
            else:
                rest_col = K-2

            for v in graph[v]:
                if collors[v] == None:
                    q.appendleft((rest_col, v))
                    rest_col -= 1
    #print(collors)  

    MOD = 10**9+7

    ans = 1
    for i in collors[1:]:
        ans = ans * i % MOD
    print(ans)
    

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

int main(){
  int a;
  string b;
  cin >> a >> b;
  int len = b.size();
  if(len==1){
    a *= 10;
  }else if(len==2){
    a *= 100;
  }else{
    a *= 1000;
  }
  int num = a + stoi(b);
  for(int i = 1; i <= 1000; i++){
    if(i*i==num){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double lb; 

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)


int main() {
    vector<ll> x(5);
    rep(i,5){
        cin >> x[i];
    }
    rep(i,5){
        if(x[i] == 0){
            cout << i+1 << endl;
            return 0;
        }
    }

}



Measured memory_bytes: 3624
let () = Scanf.scanf "%d" @@ fun n ->
  let aa = Array.init n @@ fun _ -> Scanf.scanf " %f" Fun.id in
  let () = Array.sort compare aa in
  let ans = ref aa.(0) in
  for i = 1 to n - 1 do
    ans := (!ans +. aa.(i)) /. 2.0
  done;
  Printf.printf "%f\n" !ans
  

Measured memory_bytes: 3940
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
#define INF 0x3f3f3f3f
/**
*超时有可能是输入的问题
*注意边界
*仔细读题
*没思路试试逆向思维
**加油，奥利给！！！ 
**/
ll f[10000];
int main()
{
	int m,n,i,j,t,k,s=0;
	cin>>n;
	f[0]=2;
	for(i=1;i<=n;i++)
	f[i]=f[i-1]*2+2;
	cout<<f[n]; 
 } 

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

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)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        String ans = N == M ? "Yes" : "No";
        System.out.println(ans);
    }
}


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

int MOD=1000000007;
struct edge {
    int to, cost;
};

int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}

auto factor(int n){
  map<int,int>res;
  for(int i=2;i*i<=n;i++){
      for(; n%i==0;n/=i) res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
////////////////////////////////////////////////////////////
signed main() {
  int n;
  cin>>n;
  vector<string>s(n);
  rep(i,n)cin>>s[i];
  sort(s.begin(),s.end());
  vector<char>m={'M','A','R','C','H'};
  vector<int>a(5);
  rep(i,5)if(s[0][0]==m[i])a[i]++;
  rep(i,n-1){
    rep(j,5)if(s[i+1][0]==m[j]&&s[i]!=s[i+1])a[j]++;
  }
  int ans=0;
  rep(i,3){
    for(int j=i+1;j<4;j++){
      for(int k=j+1;k<5;k++){
        ans+=a[i]*a[j]*a[k];
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6344
#include<bits/stdc++.h>
using namespace std;
const int N = 1e2+5;
void seek(){
    printf("Impossible");
    exit(0);
}
int n, A[N], T[N], mx;
set<int> st;
int main(){
    scanf("%d", &n);
    for(int i=0;i<n;i++) { scanf("%d", &A[i]); mx = max(mx, A[i]); }
    for(int i=0;i<n;i++) T[A[i]]++;
    if(T[mx]<2) seek();
    for(int i=0;i<n;i++) if(A[i]<((mx+1)>>1)) seek();
    if(T[(mx+1)>>1]>1+(mx&1)) seek();
    for(int i=0;i<n;i++) st.insert(A[i]);
    if((int)st.size()<((mx+2)>>1)) seek();
    printf("Possible");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
      public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int d = x * y;
		int u = (x * 2 + y * 2);
		System.out.println(d + " " + u);
	}
}



Measured memory_bytes: 26176
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
using namespace std;

const double PI=acos(-1);

int main(){
    long h, w;
    cin >> h >> w;

    if(w == 1 || h == 1) cout << 1 << endl;
    else{
        long a = w/2+w%2, b = w%2 == 0 ? a*2 : a*2-1, c = b*(h/2), d = h%2*a;
        cout << c+d << endl;    
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rrep(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll a; long double b; cin >> a >> b;
  cout << ll(a*b);

  return 0;
}

Measured memory_bytes: 3744
#include <iostream>

 

 

 

using namespace std;

 

 

 

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


Measured memory_bytes: 3116
#include <cstdio>
#include <iostream>

int k, a, b;

long long solve()
{
  if (b - a <= 1) {
    return 1 + k;
  }
  if (a - 1 <= k) {
    int rounds = (k - (a - 1)) / 2;
    return 1 + k - 2 * rounds + 1LL * (b - a) * rounds;
  }
  return 1 + k;
}

int main()
{
  scanf("%d%d%d", &k, &a, &b);
  std::cout << solve() << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
const int N=2e5+5;
const long long inf=1e18;
pair< pair<int,int> , int > a[N];
int n,x[N],y[N],l[N],r[N];
map<int,long long> f[2][N];
long long dis(pair<int,int> i,pair<int,int> j){
	return abs(x[i.fi]-x[j.fi])+abs(y[i.se]-y[j.se]);
}
long long dfs(int mn,int mx,int l,int r,int k){
	if(f[k][l].count(r)) return f[k][l][r];
	int L=::l[l-1],R=::r[r+1];long long ans=inf;
	if(l>1 && (a[l-1].fi.se==mn-1 || a[l-1].fi.se==mx+1))
		ans=min(ans,dfs(min(a[L].fi.se,mn),max(a[L].fi.se,mx),L,r,0)+dis(a[L].fi,k==0?a[l].fi:a[r].fi));
	if(r<n && (a[r+1].fi.se==mn-1 || a[r+1].fi.se==mx+1))
		ans=min(ans,dfs(min(a[R].fi.se,mn),max(a[R].fi.se,mx),l,R,1)+dis(a[R].fi,k==0?a[l].fi:a[r].fi));
	f[k][l][r]=(ans==inf?l-r:ans);
	return f[k][l][r];
}
long long ans[N];
signed main(){
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>x[i]>>y[i],a[i]=make_pair(make_pair(x[i],y[i]),i);
	sort(a+1,a+n+1);
	sort(x+1,x+n+1);
	sort(y+1,y+n+1);
	for(int i=1;i<=n;++i)
		a[i].fi.fi=lower_bound(x+1,x+n+1,a[i].fi.fi)-x,
		a[i].fi.se=lower_bound(y+1,y+n+1,a[i].fi.se)-y;
	l[1]=1;
	for(int i=2;i<=n;++i)
		if(abs(a[i-1].fi.se-a[i].fi.se)==1) l[i]=l[i-1];
		else l[i]=i;
	r[n]=n;
	for(int i=n-1;i>=1;--i)
		if(abs(a[i+1].fi.se-a[i].fi.se)==1) r[i]=r[i+1];
		else r[i]=i;
	//for(int i=1;i<=n;++i)cout<<a[i].fi.fi<<" "<<a[i].fi.se<<endl;
	for(int i=1;i<=n;++i)
		ans[a[i].se]=dfs(a[i].fi.se,a[i].fi.se,i,i,0);
	for(int i=1;i<=n;++i)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 87252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)
int main(){
   int n,m;
   cin >> n >> m;
   vector<vector<int>> edge(n);
   vector<int> p(n);
   vector<bool> visited(n,false);
   rep(i,n) p[i]=i+1; 
   rep(i,m){
      int x,y;
      cin >> x >> y;
      x--;y--;
      edge[x].push_back(y);
      edge[y].push_back(x);
   }
   bool can = true;
   ll ans=0;
   do{
      for (int i=0;i < n-1;i++){
         for (auto q:edge[p[i]-1]){
            if (q != p[i+1]-1) {
               can =false;
            }
            else {
               can=true;
               break;
            }
         }
         if (!can) break; 
      }
      if (can) ans++;
      //rep(i,n){
      //   cout << p[i] << " ";
      //}
      //if (can) printf(" o\n");
      //else printf("  x\n");

   }while(next_permutation(p.begin()+1,p.end()));

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



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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

signed main() {
    vector<vector<int>> A(3, vector<int>(3));
    rep(i, 3) {
        rep(j, 3) {
            cin >> A.at(i).at(j);
        }
    }
    int N;
    cin >> N;
    vector<int> b;
    int count = 0;
    rep(k, N) {
        int b;
        cin >> b;
        rep(i, 3) {
            rep(j, 3) {
                if (A.at(i).at(j) == b) {
                    A.at(i).at(j) = 101;
                }
            }
        }
    }

    rep(i, 3) {
        if (A[i][0] == A[i][1] && A[i][0] == A[i][2]) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    rep(i, 3) {
        if (A[0][i] == A[1][i] && A[0][i] == A[2][i]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (A[0][0] == A[1][1] && A[0][0] == A[2][2]) {
        cout << "Yes" << endl;
        return 0;
    }

    if (A[0][2] == A[1][1] && A[0][2] == A[2][0]) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;

}


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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> happy(n, vector<int>(3,0));
  rep(i,0,n) rep(j,0,3) cin >> happy[i][j];
  vector<vector<int>> dp(n+2, vector<int>(3,0));
  rep(i,0,n) rep(j,0,3) rep(k,0,3) {
    if (j == k) continue;
    dp[i+1][k] = max(dp[i+1][k], dp[i][j] + happy[i][k]);
  }
  int ans = max(dp[n][0], max(dp[n][1], dp[n][2]));
  cout << ans << endl;
  return 0;
}


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

inline int read()
{
	char c=getchar();
	int x=0,f=1;
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
	return x*f;
}

const int INF=1e9+5;

int main()
{
	int n,i,maxv,minv,x;
	n=read();
	maxv=-INF,minv=INF;
	for (i=1;i<=n;i++) x=read(),maxv=max(x,maxv),minv=min(x,minv);
	printf("%d\n",maxv-minv);
	return 0;
}

Measured memory_bytes: 256
/*


                 """Bismillahir Rahmanur Rahim"""

*/
#include<bits/stdc++.h>
using namespace std;
#define pi 2*acos(0.0)
#define ll long long int
#define pb push_back
#define pf push_front
const ll sz = 1000001;
#define ek(x) __builtin_popcount(x)
#define ses '\n'
#define stm istringstream
#define sob(x) x.begin(),x.end()
#define ghora ios_base::sync_with_stdio(0);cin.tie(0);
#define gcd __gcd
ll lcm(ll x,ll y){return (x*y)/gcd(x,y);}
#define tin ll T;cin>>T; for(ll o=1;o<=T;o++)
#define tout cout<<"Case "<<o<<": ";
string s,t;
ll l1,l2;
ll dp[3010][3010];
ll lcs(ll i,ll j)
{
    if(i==l1 || j==l2)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    ll ans;
    if(s[i]==t[j])
        ans=1+lcs(i+1,j+1);
    else 
    {
        ll v1=lcs(i+1,j);
        ll v2=lcs(i,j+1);
        ans=max(v1,v2);
    }
    return dp[i][j]=ans;
}
string ans;
void slcs(ll i,ll j)
{
    if(i==l1 || j==l2)
       {
          cout<<ans<<ses;
          return;
       }
    if(s[i]==t[j])
        {ans+=s[i];slcs(i+1,j+1);}
    else 
    {
        if(dp[i+1][j]>dp[i][j+1])
            slcs(i+1,j);
        else slcs(i,j+1);
    }
   
}
int main()
{
   
   cin>>s>>t;
   memset(dp,-1,sizeof(dp));
   l1=s.size();
   l2=t.size();
   ll x=lcs(0,0);
    //   cout<<x<<ses;
     slcs(0,0);
   //cout<<"o"<<ses;
    return 0;
}
/*   --------------------
    |      ~SOHAN~       |
    |   ~Chandler68~     |
     --------------------
    || VALAR MORGULIS||==|| ALL MEN MUST DIE ||
    \\ Power Is Power//
    || I Can Do This All day ||
    // We are on a Break \\ // How you doin'? \\
    || Say My Name || ~~ || I Am The Who Knocks ||
    // I Am Ted Mosby Architect \\
    || It Is Legen --wait for it -- dary ,Legendary ||
    \\ Penny - Penny - Penny // -- Bazinga

*/



Measured memory_bytes: 71424
#include <iostream>

using namespace std;

int main()
{
	long int n;
	cin>>n;
	long int a[n], l;
	cin>>l;
	for(long int i=0; i<n; i++)
		cin>>a[i];

	long int sum=0;
	long int ind=-1;
	for(long int i=1; i<n; i++)
	{
		if(sum<=a[i]+a[i-1])
		{
			sum = a[i]+a[i-1];
			ind=i;
		}
	}
	if(sum>=l)
	{
		cout<<"Possible"<<endl;
		for(long int i=1; i<ind; i++)
			cout<<i<<endl;
		for(long int i=n-1; i>ind; i--)
			cout<<i<<endl;
		cout<<ind<<endl;
	}
	else
		cout<<"Impossible";
}

Measured memory_bytes: 4380