akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;                                                            
#define pb push_back                                                            
#define mp make_pair                                                                                                                                
#define sqr(a) ((a) * (a))                                                      
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   
#define co() cout.precision(10);                                                
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n"; 
#define test int t;cin>>t;while(t--)
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif

typedef long long li;
typedef long double ld;

const li mod = 1000000007;
int main() 
{
    io();
    li n,k;
    cin>>n>>k;
    li c=0,i,a[n];
    F cin>>a[i];
    sort(a,a+n);
    fo(i,0,k)
    c+=a[i];
    cout<<c;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}



int main2() {
  ll N = nextLong();
  ll X = nextLong();
  ll M = nextLong();

  ll a = X;

  vector<ll> step(M+10, -1);
  vector<ll> sums(M+10);

  step[a] = 0;
  sums[a] = a;

  ll age = 1;
  ll y;
  ll cycle_len, cycle_sum;
  for (; ; age++) {
    ll na = (a * a) % M;
    if (step[na] != -1) {
      cycle_len = (step[a] + 1) - step[na];
      cycle_sum = (sums[a] + na) - sums[na];
      y = na;
      break;
    } else {
      step[na] = age;
      sums[na] = sums[a] + na;
    }
    a = na;
  }

  // cout << cycle_len << " " << cycle_sum << endl;
  // cout << step[y] << " " << sums[y] << endl;

  if (age >= N) {
    ll ans = 0;
    a = X;
    REP(_, N) {
      ans += a;
      a = (a * a) % M;
    }
    cout << ans << endl;
    return 0;
  }

  ll ans = 0;
  ans += sums[y] - y;
  N -= step[y];

  ll C = N / cycle_len;
  N -= C * cycle_len;
  ans += C * cycle_sum;
  {
    a = y;
    REP(_, N) {
      ans += a;
      a = (a * a) % M;
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;
//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

int n;
vvi ans;

int main(){
    cin >> n;
    int k = sqrt((double)n * 2);

    if (n == 1) {
        cout << "Yes" << endl;
        cout << 2 << endl;
        cout << "1 1" << endl;
        cout << "1 1" << endl;
    }else if (k * (k+1) == 2 * n){
        cout << "Yes" << endl;
        cout << k+1 << endl;

        ans.resize(k+1);
        int elm = 1;

        REP(i,k+1){
            int st = ans[i].size();
            FOR(j, st+1, k+1){
                ans[i].pb(elm);
                ans[j].pb(elm);
                elm++;
            }
            cout << k << " ";
            for (auto v: ans[i]) cout << v << " ";
            cout << endl;
        }

    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 2304
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N = int(input())
A = [int(i) for i in input().split()]

s = sum(A)
sa = [A[0]]
for i in range(1, N) :
    sa.append(sa[-1] + A[i])

ret = float('inf')
for i in range(N) :
    ret = min(ret, abs(sa[i] - (s - sa[i])))
    
print(ret)

Measured memory_bytes: 92240
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,a[200010],m=987654321,ans;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",a+i);
        if(a[i]<=m)
        {
            ans++;
            m=a[i];
        }
    }
    printf("%d",ans);
}

Measured memory_bytes: 1024
k,n = list(map(int, input().split()))

a_vector = list(map(int, input().split()))

tonari_dif = 0
for i in range(1,n):
    tonari_dif = max(tonari_dif, a_vector[i] - a_vector[i-1])
#    print(tonari_dif)

true_tonari_dif = max(tonari_dif, a_vector[0]+(k-a_vector[-1]))

print(k-true_tonari_dif)
 

Measured memory_bytes: 77388
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

template<class Monoid> struct SegmentTree {
private:
    using Func = std::function<Monoid(Monoid, Monoid)>;
    Func F;
    Monoid UNITY;
    int n;
    std::vector<Monoid> node;
public:
    SegmentTree() {}

    //m=size, f=[](M a,M b){return ;}
    // size : m
    SegmentTree(int m, const Func f, const Monoid &unity) {
        build(m, f, unity);
    }

    SegmentTree(const std::vector<Monoid>& v, const Func f, const Monoid &unity) {
        build(v, f, unity);
    }

    void build(int m, const Func f, const Monoid &unity) {
        F = f;
        UNITY = unity;
        n = 1; while (n < m) n <<= 1;
        node.resize(n * 2 - 1, UNITY);
    }

    void build(const std::vector<Monoid>& v, const Func f, const Monoid &unity) {
        F = f;
        UNITY = unity;
        int sz = v.size();
        n = 1; while (n < sz) n <<= 1;
        node.resize(n * 2 - 1, UNITY);
        REP(i, sz) node[i + n - 1] = v[i];
        for (int i = n - 2; i >= 0; i--) node[i] = F(node[2 * i + 1], node[2 * i + 2]);
    }

    void update(int x, Monoid val) {
        if (x >= n || x < 0) return;
        x += n - 1;
        node[x] = val;
        while (x > 0) {
            x = (x - 1) >> 1;
            node[x] = F(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    // [a,b)
    Monoid get(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return UNITY;
        if (a <= l && r <= b) return node[k];
        Monoid vl = get(a, b, 2 * k + 1, l, (r - l) / 2 + l);
        Monoid vr = get(a, b, 2 * k + 2, (r - l) / 2 + l, r);
        return F(vl, vr);
    }

    Monoid operator[](int x)const {
        return node[n + x - 1];
    }

    int size() {
        return n;
    }

    void print() {
        REP(i, n) {
            std::cout << i << "\t: " << node[n + i - 1] << std::endl;
        }
    }
};

int main() {
    int n; cin >> n;
    vector<int> h(n), a(n);
    REP(i, n) cin >> h[i];
    REP(i, n) cin >> a[i];
    SegmentTree<ll> seg(n+1, [](ll a, ll b) {return max(a, b); },0);
    REP(i, n) {
        seg.update(h[i], seg.get(0, h[i]) + a[i]);
        //seg.print();
    }
    cout << seg.get(0, n + 1) << endl;
    return 0;
}

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

int main(){
  string S;
  int N;
  cin >> N;
  cin >> S;
  
  for(int i=0;i<S.length();i++){
    if('Z'>= S[i] + N){
      S[i] = S[i] + N;
    }else{
      S[i] = (S[i] + N) - 26;
    }
  }
  
  cout << S;
  return 0;
}


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

int b;
int l, r;

void check(int p, int q) {
    if (q - (p / 2) >= 1) {
        if ((r - l + 1) < p) {
            l = q - (p / 2);
            r = q + (p / 2);
        }
    } else {
        if ((r - l + 1) < 2 * q) {
            l = (p / 2) - q + 1;
            r = q + (p / 2);
        }
    }
}

void solve() {
    for (int i = 1; i * i <= b; i++) {
        if (b % i) continue;
        int j = b / i;
        if (i % 2) {
            check(i, j);
        }
        if (j % 2) {
            check(j, i);
        }
    }
    cout << l << ' ' << r - l + 1 << endl;
}

int main() {
    while (1) {
        cin >> b;
        if (b == 0) return 0;
        l = 1;
        r = 0;
        solve();
    }
}


Measured memory_bytes: 3084
/*
    author: blue_matrix
*/
#include <bits/stdc++.h>
using namespace std;

#define n_l '\n'
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl
#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll> h(n);
    for(ll i=0;i<n;i++)
    {
        cin>>h[i];
    }

    map<ll,ll> m1,m2;
    for(ll i=0;i<n;i++)
    {
        m1[-h[i]+i]++;
        m2[h[i]+i]++;
    }
    ll sum=0;
    for(auto it=m1.begin();it!=m1.end();it++)
    {
        // if(m2[it->first]!=0)
        // {
            sum+=(it->second)*(m2[it->first]);
        // }
    }
    // dbg(m1);
    // dbg(m2);
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 39112
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    char[] s = sc.next().toCharArray();
    int r = 0;
    int l = 0;         
    for(int i=0;i<n;i++){
      if(r==0&&s[i]==')')l++;
      if(s[i]=='(')r++;
      if(r>0&&s[i]==')')r--;
    }
    for(int i=0;i<l;i++)System.out.print("(");
    System.out.print(String.valueOf(s));
    for(int i=0;i<r;i++)System.out.print(")");
    System.out.println("");
  }
}


Measured memory_bytes: 23124
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken().to!int; }
long readLong() { return readToken().to!long; }
real readReal() { return readToken().to!real; }

void chmin(T)(ref T t, in T f) { if (t > f) t = f; }
void chmax(T)(ref T t, in T f) { if (t < f) t = f; }

int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); }


int N, H, W;

void main() {
  try {
    for (; ; ) {
      N = readInt();
      H = readInt();
      W = readInt();
      const ans = (N + 1 - H) * (N + 1 - W);
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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

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


struct UnionFind {
  vector<int> data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x); y = find(y); 
    if (x == y) return false;
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }
  
  bool same(int x, int y) {
    x = find(x); y = find(y); 
    return (x == y);
  }

  int find(int k) {
    if (data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  // 要素 k が属する集合の要素の数を求める
  int size(int k) {
    return -data[find(k)];
  }
};

ll calc(ll n) {
  return n * (n-1) / 2;
}


int N, M;
int a[110000];
int b[110000];
ll res[110000];

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

  Rep (i, M) {
    cin >> a[i] >> b[i];
  }

  UnionFind uni = UnionFind(N+1);

  ll tmp = calc(N);

  rep (k, M) {
    res[M-k] = tmp; 

    if (!uni.same(a[M-k], b[M-k])) {
      tmp -= uni.size(a[M-k]) * uni.size(b[M-k]);
    }

    uni.unite(a[M-k], b[M-k]);
  }

  Rep(i, M) {
    cout << res[i] << "\n";
  }
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int my_sum(int n){
  int sum = 0;
  while(n>0){
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main(){
  int N;
  cin >> N;
  int x = my_sum(N);
  if(N%x == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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>;

const ll mod = 1e9;

int main(){
    ll w,h,x,y;
    cin >> w >> h >> x >> y;
    double ans = w / 2.0 * h;
    if (w / 2.0 == x && h / 2.0 == y) cout << ans << ' ' << 1 << endl;
    else cout << ans << ' ' << 0 << endl;
    return 0;
}

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

int main() {
	int h,w,k; cin >> h >> w >> k;
	vector<vector<char>> c(h,vector<char>(w));
	rep(i,h){
		string s; cin >>s;
		rep(j,s.size()) {
			c[i][j]=s[j];
		}
	}
	int ans=0;
	rep(bh,1<<h) {
		rep(bw,1<<w) {

			auto v=c;
			rep(i,h) {
				if(bh&(1<<i)) {
					rep(j,w) {
						v[i][j]='x';
					}
				}
			}

			rep(i,w) {
				if(bw&(1<<i)) {
					rep(j,h) {
						v[j][i]='x';
					}
				}
			}

			int cut = 0;
			rep(i,h)rep(j,w) {
				if(v[i][j]=='#') cut++;
			}
			if(cut==k) ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3576
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )
# from itertools import accumulate
# from collections import deque

import random


def main():
    n_finger,n_required = map(int, input().split())
    n_finger = n_finger-1
    # 1 + n_finger * n_hub_prepare = n_required
    n_hub_prepare = ( n_required - 1 ) // n_finger
    
    if 1 + n_finger * n_hub_prepare < n_required :
        n_hub_prepare += 1

    print(n_hub_prepare)
    
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 66796
#include <bits/stdc++.h>
#define endl '\n'

//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);

int n, m;
string s[MAXN];

void read()
{
	cin >> n >> m;
	for(int i = 0; i < n; i++)
		cin >> s[i];
}

string s2[MAXN];

void solve()
{
	map<char, int> cnt;
	map<vector<char>, int> cnt_hs;
	for(int i = 0; i < n; i++)
	{
		vector<char> tmp;
		for(int j = 0; j < m; j++)
			tmp.push_back(s[i][j]);

		sort(tmp.begin(), tmp.end());
		cnt_hs[tmp]++;
	}

	int cnt_odd = 0;
	for(auto it: cnt_hs)
		cnt_odd += (it.second % 2);

	if(cnt_odd != n % 2) 
	{
		cout << "NO" << endl;
		exit(0);
	}
	else
	{
		for(auto it: cnt_hs)
			if(it.second % 2 == 1)
			{
				for(auto c: it.first)
					cnt[c]++;

				int cnt_odd2 = 0;
				for(auto it: cnt)
					cnt_odd2 += it.second % 2;

				if(cnt_odd2 != m % 2) 
				{
					cout << "NO" << endl;
					exit(0);
				}
			}			
	}	

	for(int i = 0; i < m; i++)
		s2[i].resize(n);

	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			s2[j][i] = s[i][j];

	for(int i = 0; i < m; i++) s[i] = s2[i];
	swap(n, m);

	cnt_hs.clear();
	cnt.clear();
	for(int i = 0; i < n; i++)
	{
		vector<char> tmp;
		for(int j = 0; j < m; j++)
			tmp.push_back(s[i][j]);

		sort(tmp.begin(), tmp.end());
		cnt_hs[tmp]++;
	}

	cnt_odd = 0;
	for(auto it: cnt_hs)
		cnt_odd += (it.second % 2);

	if(cnt_odd != n % 2) 
	{
		cout << "NO" << endl;
		exit(0);
	}
	else
	{
		for(auto it: cnt_hs)
			if(it.second % 2 == 1)
			{
				for(auto c: it.first)
					cnt[c]++;

				int cnt_odd2 = 0;
				for(auto it: cnt)
					cnt_odd2 += it.second % 2;

				if(cnt_odd2 != m % 2) 
				{
					cout << "NO" << endl;
					exit(0);
				}
			}			
	}

	vector<int> perm;
	for(int i = 0; i < m; i++)
		perm.push_back(i);

	if(n < 9)
	{
		do
		{
			if(clock() >= 1.5 * CLOCKS_PER_SEC) break;

			cnt_hs.clear();
			for(int i = 0; i < n; i++)
			{
				vector<char> tmp;
				for(int j = 0; j < m; j++)
					tmp.push_back(s[i][perm[j]]);

				vector<char> tmp2 = tmp;
				reverse(tmp2.begin(), tmp2.end());
				cnt_hs[tmp2]--;
				cnt_hs[tmp]++;
			}

			bool ok = 1;
			for(auto it: cnt_hs)
				if(it.second != 0)
					ok = 0;

			if(ok)
			{
				cout << "YES" << endl;
				return;
			}
		}
		while(next_permutation(perm.begin(), perm.end()));

		cout << "NO" << endl;
	}
	else cout << "YES" << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 16640
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int x;
	REP(i, 5) {
		cin >> x;
		if(x == 0) {
			cout << i + 1 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3620
#include <string>
#include <iostream>
using namespace std;
const int mod = 1000000007;
string s; int n, pw[100009], ca[100009], cb[100009], cc[100009], cq[100009];
int solve(string x) {
	int ret = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] != x[1]) continue;
		int ma = ca[i], mb = cc[n] - cc[i + 1];
		if (x[0] == '?') ma = cq[i];
		if (x[2] == '?') mb = cq[n] - cq[i + 1];
		ret = (ret + 1LL * ma * mb) % mod;
	}
	return ret;
}
int pw2(int n) {
	return n < 0 ? 0 : pw[n];
}
int main() {
	cin >> s; n = s.size();
	pw[0] = 1;
	for (int i = 0; i < n; ++i) {
		pw[i + 1] = 3LL * pw[i] % mod;
		ca[i + 1] = ca[i] + (s[i] == 'A');
		cb[i + 1] = cb[i] + (s[i] == 'B');
		cc[i + 1] = cc[i] + (s[i] == 'C');
		cq[i + 1] = cq[i] + (s[i] == '?');
	}
	int qc = cq[n];
	int ret = 0;
	ret = (ret + 1LL * solve("ABC") * pw2(qc)) % mod;
	ret = (ret + 1LL * solve("AB?") * pw2(qc - 1)) % mod;
	ret = (ret + 1LL * solve("A?C") * pw2(qc - 1)) % mod;
	ret = (ret + 1LL * solve("?BC") * pw2(qc - 1)) % mod;
	ret = (ret + 1LL * solve("A??") * pw2(qc - 2)) % mod;
	ret = (ret + 1LL * solve("?B?") * pw2(qc - 2)) % mod;
	ret = (ret + 1LL * solve("??C") * pw2(qc - 2)) % mod;
	ret = (ret + 1LL * solve("???") * pw2(qc - 3)) % mod;
	cout << ret << '\n';
	return 0;
}

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

int main(){
    int a,b;
    bool ok=true;
    cin >> a >> b;
    string s;
    cin >> s;
    for(int i=0;i<a+b+1;i++){
        if(0<=i&&i<a){
            if(isdigit(s[i])){}
            else ok=false;
        }
        if(a<=i&&i<a+1){
            if(s[i]=='-'){}
            else ok=false;
        }
        if(a+1<=i&&i<a+b+1){
            if(isdigit(s[i])){}
            else ok=false;
        }
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

const int MOD = 1000000007;

long long modPow(long long a, long long p){
    if(p == 0) return 1;
    auto res = modPow(a, p/2);
    res = (res*res)%MOD;
    if(p%2) res = (res*a)%MOD;
    return res;
}

long long calcInv(long long a){
    return modPow(a, MOD-2);
}

int main(){
    int N;
    while(cin >> N){
        vector<int> A(N);
        for(auto& t : A) cin >> t;
        vector<int> p(1000001, 0);
        for(auto t : A){
            int val = t;
            for(int i=2;i*i<=val;i++){
                if(val%i) continue;
                int cnt = 0;
                while(val%i == 0){
                    val /= i;
                    ++cnt;
                }
                p[i] = max(p[i], cnt);
            }
            if(val > 1) p[val] = max(p[val], 1);
        }
        long long M = 1;
        for(int i=2;i<=1000000;i++) M = (M * modPow(i, p[i])) % MOD;
        long long res = 0;
        for(auto& t : A) res = (res + M * calcInv(t)) % MOD;
        cout << res << endl;
    }
}

Measured memory_bytes: 4352
N = int(input())
K = list(map(int, input().split()))
if K[0] != 0:
	K[0] -= 1
y_f = 1
	
for i in range(1, N):
	if K[i - 1] == K[i]:
		pass
	elif K[i - 1] > K[i] - 1:
		print("No")
		y_f = 0
		break
	else:
		if K[i] != 0:
			K[i] -= 1
if y_f == 1:
	print("Yes")

Measured memory_bytes: 63984
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	string s; cin>>s;
	rep(i,s.size()-8) cout<<s[i]; cout<<endl;
	return 0;
}


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

int n;
vector<int> a(20);


bool solve(int i, int m){
  if (m==0) return 1;
  if (i>n) return 0;
  bool res= solve(i+1, m) || solve(i+1,m-a[i]);
  return res;
}

int main(){
  int q;

  
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  cin>>q;
  vector<int> m(q);
  for(int i=0;i<q;i++) cin>>m[i];
  for(int i=0;i<q;i++){
    if(solve(0,m[i])) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }

}



Measured memory_bytes: 3108
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws Exception{

        // 自分の得意な言語で
        // Let's チャレンジ！！
		int s = 0;
		int i = 0;
		String tN;
		ArrayList<String> array = new ArrayList<String>();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
        	String line = br.readLine();
        	//文字列に先頭又は最後に空白文字がくっ付いている場合、それらを全て取り除きます。
        	line = line.trim();
        	//半角スペースを区切り文字として扱う
        	String[] readLineArray = line.split("[\\s+]");
        	//変数に配列を代入
        	int a = Integer.parseInt(readLineArray[0]);
        	int b = Integer.parseInt(readLineArray[1]);
        	if(a == 0 && b == 0){
        		break;
        	}else if(a > b){
        		s = a;
        		a = b;
        		b = s;

        	}
        	tN = (a+" "+b);
            array.add(tN);

        	i++;
        }
        int N = i;

        for(i = 0;i<N;i++){
        	System.out.println(array.get(i));
        }

    }
}

Measured memory_bytes: 25368
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  s << p.first << " " << p.second << "\n"; return s;
}

// cout vector<pair>
template<typename T1, typename T2> ostream& operator<<(ostream& s, const vector<pair<T1, T2> >& vp) {
  int len = vp.size(); s << "\n";
  for (int i = 0; i < len; ++i) { s << vp[i]; }
    s << "\n"; return s;
}

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

vvi g;
int n, m;
vector<bool> checked;
vector<int> color;


bool bip() {
  checked.assign(n, false);
  color.assign(n, -1);
  deque<int> stk;
  stk.push_back(0);
  checked[0] = true;
  color[0] = 0;
  while (!stk.empty()) {
    int u = stk.front();
    stk.pop_front();
    for (int v : g[u]) {
      if (checked[v]) {
        if (color[u] == color[v]) {
          return false;
        }
        continue;
      }
      checked[v] = true;
      color[v] = 1 - color[u];
      stk.push_back(v);
    }
  }
  return true;
}

int main() {
  scanf("%d %d", &n, &m);
  g.resize(n);
  rep (i, m) {
    int a, b;
    scanf("%d %d", &a, &b);
    a -= 1; b -= 1;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  bool flg = bip();
  ll ans;
  if (flg) {
    ll cnt = 0;
    rep (i, n) {
      cnt += color[i];
    }
    ans = cnt * (n - cnt) - m;
  } else {
    ans = (ll)n * (n-1) / 2 - m;
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main(void)
{
    int n, m;
    cin >> n >> m;
    int likedFood[m];
    rep(i, m) likedFood[i] = 0;

    rep(i, n) {
        int k;
        cin >> k;
        rep(i, k) {
            int a; cin >> a;
            a--;
            likedFood[a]++;
        }
    }

    int ans = 0;
    rep(i, m) if(likedFood[i] == n) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

#include <map>
using std::map;

#include <string>
using std::string;

map<string, int> memo;

int main (void) {
int n;

scanf("%lld", &n);
for (int i = 0; i < n; i++) {
string s;
cin >> s;

memo[s] += 1;
}


int maxv = 0;
for (const auto& x : memo) {
int v = x.second;
if (v > maxv) maxv = v;
}
for (auto it = memo.begin(); it != memo.end(); it++) {
if (it->second == maxv) {
cout << it->first << endl;
}
}

return 0;
}

Measured memory_bytes: 25216
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

bool solve() {
    auto s = readln.split.map!(to!int);
    auto W = s[0];
    auto H = s[1];
    if (W == 0) return false;

    auto A = H.iota.map!(_ => readln.split.map!(to!int).array).array;
    auto C = readln.split.map!(to!int).array;

    const int[] dr = [-1, 0, 1, 0]; // U, R, D, L
    const int[] dc = [0, 1, 0, -1];


    auto D = new int[][][](H, W, 4);
    foreach (i; 0..H) foreach (j; 0..W) D[i][j][] = 1 << 29;

    auto pq = new BinaryHeap!(Array!(Tuple!(int, int, int, int)), "a[3] > b[3]");
    pq.insert(tuple(0, 0, 1, 0));

    while (!pq.empty) {
        auto r = pq.front[0];
        auto c = pq.front[1];
        auto dir = pq.front[2];
        auto dist = pq.front[3];
        pq.removeFront;
        if (D[r][c][dir] <= dist) continue;
        D[r][c][dir] = dist;

        foreach (i; 0..4) {
            auto nr = r + dr[(dir+i)%4];
            auto nc = c + dc[(dir+i)%4];
            auto ndir = (dir+i)%4;
            auto ndist = i == A[r][c] ? dist : dist + C[i];
            if (nr < 0 || nr >= H || nc < 0 || nc >= W) continue;
            if (D[nr][nc][ndir] <= ndist) continue;
            pq.insert(tuple(nr, nc, ndir, ndist));
        }
    }

    D[H-1][W-1].reduce!min.writeln;

    return true;
}

void main() {
    while (solve()) {}
}



Measured memory_bytes: 3888
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int H, W, D;
	cin >> H >> W >> D;
	vector<vector<int>> A(H, vector<int>(W));
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++){
			cin >> A[i][j];
			A[i][j]--;
		}
	}
	int N = H * W;
	vector<int> y(N), x(N);
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++){
			y[A[i][j]] = i;
			x[A[i][j]] = j;
		}
	}
	vector<int> S(N, 0);
	for (int i = D; i < N; i++){
		S[i] = S[i - D] + abs(y[i] - y[i - D]) + abs(x[i] - x[i - D]);
	}
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++){
		int L, R;
		cin >> L >> R;
		L--;
		R--;
		cout << S[R] - S[L] << endl;
	}
}

Measured memory_bytes: 4556
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
const int MAX_N=10000;
int n,a;
set<int> st;

int main(){
	cin >> n;
	
	REP(i,0,n){
		cin >> a;
		if(st.count(a)) st.erase(a);
		else st.insert(a);
	}
	
	cout << st.size() << endl;
	return 0;
}


Measured memory_bytes: 4864
import copy
N,K=map(int,input().split())
V=list(map(int,input().split()))

ANS=0
#print(V[:0])
for i in range(min(N,K)+1):
    for j in range(min(N,K)-i+1):
        A=V[:i]
        B=V[N-j:]
        C=A+B
        #print(C,i,j)
        C.sort()
        for k in range(min(K-i-j,len(C))):
            if C[k]<0:
                C[k]=0
        #print(C)
        if ANS<sum(C):
            ANS=sum(C)
print(ANS)

Measured memory_bytes: 41072
#include <stdio.h>

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

int main()
{
    int n,a[100],i,j;
    scanf("%d",&n);
    for(i = 0;i < n;i++)scanf("%d",&a[i]);

    int sum = 0,ave[3],ans[3] = {0};
    for (i = 0; i < n; i++)
    {
        sum += a[i];
    }
    ave[0] = (sum + (n / 2)) / n;
    ave[1] = ave[0]--;
    ave[2] = ave[0]--;
    for (i = 0; i < n; i++)
    {
       for (j = 0; j < 3; j++)
       {
           ans[j]  += (a[i] - ave[j]) * (a[i] - ave[j]);
       }
    }

    printf("%d",min(ans[0],min(ans[1],ans[2])));
}

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

int main(){
  int n,c=0;
  while(true){
  cin>>n;
  if(n==0){
    break;
  }
  int dp[n+1];
  for(int i=0;i<n+1;i++){
    if(i==0){
      dp[i]=1;
    }
    if(i==1){
      dp[i]=1;
    }
    if(i==2){
      dp[i]=2;
    }
  }
  
  for(int i=3;i<n+1;i++){
      dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
  }
  cout<<dp[n]/3650+1<<endl;
  }
}

Measured memory_bytes: 1160
h,w=map(int,input().split())
s=[input() for _ in range(h)]
from collections import deque
ans=0
dd=[(1,0),(-1,0),(0,1),(0,-1)]
for i in range(h):
  for j in range(w):
    if  s[i][j]=="#":
          continue
    
    g=[[0]*w for _ in range(h)]
    v=[[0]*w for _ in range(h)]
    g[i][j]=1
    q=deque([(j,i)])
    while q:
      x,y=q.popleft()
      for dx,dy in dd:
        nx=x+dx
        ny=y+dy
        if not 0<=nx<w:
          continue
        if not 0<=ny<h:
          continue
        if g[ny][nx]:
          continue
        if s[ny][nx]=="#":
          continue
        g[ny][nx]=1
        v[ny][nx]=v[y][x]+1
        q.append((nx,ny))
    for ii in v:
      ans=max(ans,max(ii))

print(ans)        


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

int main(void) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if ((abs(a - b) <= d && abs(c - b) <= d) || abs(c - a) <= d)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
/*~~~~~~~~~~~~~~~~~ K++ code ~~~~~~~~~~~~~~~~~~~
in(a, b, c)
out(10*max(a, b, c) + a + b + c - max(a, b, c))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

;;;
;
int main(){
  ;;;
    int a, b, c;
    cin >> a >> b >> c;
    ;
    cout << (10*max(max(a, b), c) + a + b + c - max(max(a, b), c)) << endl;;
    ;
}

Measured memory_bytes: 888
class UnionFind
  attr_accessor :parent, :rank
  
  def initialize(n)
    @parent = []
    @rank = []
    n.times do |i|
      @parent[i] = i
      @rank[i] = 0
    end
  end

  def find(x)
    if @parent[x] == x
      return x
    else
      return @parent[x] = find(@parent[x])
    end
  end

  def unite(x,y)
    x,y = find(x),find(y)
    return if x==y

    x,y = y,x if @rank[x] < @rank[y]
    @rank[x] += 1 if @rank[x] == @rank[y]
    @parent[y] = x
  end
end

n,m = gets.split.map(&:to_i)
tree = UnionFind.new(n+1)

m.times do
  x,y,z = gets.split.map(&:to_i)
  tree.unite(x,y)
end

parents = []
1.upto(n) do |i|
  parents << tree.find(i)
end
p parents.uniq.length

Measured memory_bytes: 11380
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
   int a,i;
   vector<int> s;
   for(i=0;i<5;i++){
      cin>>a;
      s.push_back(a);
   }
   sort(s.rbegin(),s.rend());
   
   printf("%d",s[0]);
   for(i=1;i<5;i++){
      printf(" %d",s[i]);
   }
   printf("\n");
   return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll mod=1e9+7;

#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define rc(x)  return cout<<x<<"\n",0
#define sz(s)  (int) s.size()

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

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

ll pow(ll a, ll b)
{
	ll res=1;
	while(b)
	{
		if(b%2) res=(res*a)%mod;
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}

int ugabuga()
{

	ll n,k;
	cin>>n>>k;
	ll dp[k+3];
	for(int i=0;i<=k;i++) dp[i]=0;

	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		ll x,val;
		cin>>x>>val;
		for(int j=k-x;j>=0;j--)
		{
			dp[j+x]=max(dp[j+x],dp[j]+val);
			ans=max(dp[j+x],ans);
		} 
	}

	cout<<ans;

	return 0;
}


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

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

}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
    int A, B, C;
    scanf("%ld %ld %ld", &A, &B, &C);
    int ans, dummy;
    dummy = B / A;
    if (dummy < C)
    {
        ans = dummy;
    }
    else
    {
        ans = C;
    }
    printf("%ld", ans);
    return 0;
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  ll k, a, b;
  cin >> k >> a >> b;
  if (k <= a) {
    cout << k + 1 << endl;
    return 0;
  }
  ll n = k - a - 1;
  ll m = n/2;
  ll num = (m+1)*b-m*a;
  if (n%2 == 1) num++;
  if (a > b) num = 0;
  cout << max(num, k+1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp
void bit_full_search(int n)
{

    //2^n回ループ
    for (int bit = 0; bit < (1<<n); ++bit) {
        cout << "{";
        for (int i = 0; i < n; ++i) {
            //if (bit & (1<<i)) {
            if(bit >> i&1){
                cout << " " << i << " ";
            }
        }
        cout << "}" << endl;
    }
    
}



int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll h, w, k; cin >> h >> w >> k;
    vector<vector<string>> vec(h, vector<string>(w));
    rep(i, h){
        string s; cin >> s;
        rep(j, w){
            vec[i][j] = s[j];
        }
    }

    

    ll ans = 0;
    vector<vector<string>> tmp(h, vector<string>(w));
    for (int bit = 0; bit < (1<<h); ++bit) {
        
        
        vector<ll> gyo;
        
        //cout << "{";
        for (int i = 0; i < h; ++i) {
            if (bit & (1<<i)) {
                //cout << " " << i << " ";
                gyo.push_back(i);
            }
        }
        //cout << "}" << endl;

        for (int bit2 = 0; bit2 < (1<<w); ++bit2) {
            vector<ll> retsu;
            tmp = vec;
            //cout << "[";
            for (int i = 0; i < w; ++i) {
                if (bit2 & (1<<i)) {
                    //cout << " " << i << " ";
                    retsu.push_back(i);
                }
            }
            //cout << "]" << endl;

            //ここ
            
            rep(i, gyo.size()){
                rep(j, w){
                    tmp[gyo[i]][j] = "r";
                }
                //cout << gyo[i] << " ";
            }

            rep(i, retsu.size()){
                rep(j, h){
                    tmp[j][retsu[i]] = "r";
                }
                //cout << retsu[i] << " ";
            }
            

            ll count = 0;
            rep(i, h){
                rep(j, w){
                    //cout << tmp[i][j] << " ";
                    if(tmp[i][j] == "#"){
                        count++;
                    }
                }
            }
            //cout << "count = " << count << endl;
            if(count == k){
                ans++;
            }

        }

        



    }

    cout << ans << endl;

}

Measured memory_bytes: 3588
#include <stdio.h>
int main(void){
    
    int a, b;
    
    scanf("%d %d", &a, &b);
    if(a < b) printf("a < b\n");
    if(a > b) printf("a > b\n");
    if(a == b) printf("a == b\n");
    
    return 0;
}

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

int main()
{
    long long i,l,r,d,mul,cnt=0;
    cin>> l >> r >> d;

    for(i=l/d;i*d<=r;i++){
        mul = d*i;
        if(mul>=l && mul<=r){
            cnt++;
        }
    }

    cout<< cnt <<endl;
    return 0;
}


Measured memory_bytes: 3640
def ball(card, number, state):
    for a in range(3):
        for b in range(3):
            if(card[a][b] == number):
                state[a][b] = 1

def check(state):
    for m in range(3):
        if(min(state[m]) == 1):
            return True
    for m in range(3):
        if(state[0][m] == 1 and state[1][m] == 1 and state[2][m] == 1):
            return True
    if(state[0][0] == 1 and state[1][1] == 1 and state[2][2] == 1):
        return True
    if(state[2][0] == 1 and state[1][1] == 1 and state[2][0] == 1):
        return True
    return False

                
state = [[0 for i in range(3)] for j in range(3)]
card = [list(map(int, input().split())) for i in range(3)]
N = int(input())
for n in range(N):
    ball(card, int(input()), state)
if(check(state)):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
#include <stdio.h>
#include <math.h>
 int main()
{
       long x, p= 100, count = 0;
       scanf("%zu",&x);
       while(p<x)
       {
           count = count +1;
           p = p + (p*0.01);
           
       }
       printf("%zu",count);
       
       
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define fre(i,t,n)  for(int i =(t);i<=(n);++i)
#define fer(i,n,t)  for(int i =(n);i>=(t);--i)
#define mp make_pair
#define pb push_back
typedef long long ll;
void smain();
int main(){
    ios::sync_with_stdio(false);
    smain();
    return 0;
}
const int maxn = 300+3;
char str[maxn][maxn];
void smain(){
    int n;
    cin>>n;
    fre(i,0,n-1)
        cin>>str[i];
    int cnt=0;
    fre(k,0,n-1)
    {
        bool flag=true;
        //cout<<k<<":"<<endl;
        fre(i,0,n-1)
        {
            fre(j,0,n-1)
            {
                //cout<<"("<<i<<","<<(j)%n<<") ("<<(j+k)%n<<","<<(i-k+n)%n<<");";
                if(str[i][(j+k)%n]!=str[(j)%n][(i+k+n)%n])    flag=false;
            }
            //cout<<endl;
        }
        if(flag)    cnt++;
    }
    cout<<cnt*n<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,sum1=0,sum2=0;
	cin>>a>>b>>c;
	sum1=b-a;
	sum2=c-b;
	if(sum1==sum2)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 3564
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

int main() {
    int k, s;
    cin >> k >> s;

    LL res = 0;

    rep(x, k + 1) {
        rep(y, k + 1) {
            int z = s - x - y;
            if (z >= 0 && z <= k) res++;
        }
    }

    cout << res << endl;
    return 0;
}


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

string s;
bool foo[1000];

int main() {
    cin >> s;
    for (int i = 0; i < s.size(); i++) foo[s[i]] = 1;
    if (foo['N'] == foo['S'] && foo['W'] == foo['E']) cout << "Yes";
    else cout << "No";
}

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

#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

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

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



int main(){
    int N;
    string S;
    cin >>N >> S ;
    if(N%2 == 1)cout << "No" << endl;
    else {
        rep(i,N/2){
            if(S[i] != S[(N/2)+i]){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }






}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define I 100007

using namespace std;

long long b[I][4], n, x, k;

struct aa{
long long x, y, z;
} a[I];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> a[i].x >> a[i].y >> a[i].z;
    }
    b[1][1] = a[1].x; b[1][2] = a[1].y; b[1][3] = a[1].z;
    for(int i = 2; i <= n; i ++){
        b[i][1] = max(b[i - 1][2] + a[i].x, b[i - 1][3] + a[i].x);
        b[i][2] = max(b[i - 1][1] + a[i].y, b[i - 1][3] + a[i].y);
        b[i][3] = max(b[i - 1][2] + a[i].z, b[i - 1][1] + a[i].z);
    }
    cout << max(b[n][1], max(b[n][2], b[n][3])) << endl;
    return 0;
}


Measured memory_bytes: 5760