akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <deque>
#include <iostream>
#include <vector>

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

int H, N;
int A[10001], B[10001];

// int dp[10001][10001];
//VII dp(10001, VI(10001, 0));

int dp[10001];

int main() {
    REP(i, 10002) {
        dp[i] = 1000000000;
    }
    cin >> H >> N;
    REP(i, N) {
        cin >> A[i] >> B[i];
    }
    REP(h, H + 1) {
        int min = 1000000000;
        REP(i, N) {
            int tmp = (h <= A[i]) ? B[i] : (dp[h - A[i]] + B[i]);
            if (tmp < min) {
                min = tmp;
            }
        }
        dp[h] = min;
    }
    cout << dp[H] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
// #pragma GCC optimize("O2")
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef multiset <ll> mms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define deb(x) cout << #x << " " << x << endl;
#define ff first
#define ss second
#define pb(v) push_back(v)
#define lb(v) lower_bound(v)
#define ub(v) upper_bound(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b) {
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s) {
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v) {
	forl(i,v.size()) cout<<v[i]<<" ";
	cout<<"\n";
}
void pa(ll *v, ll size) {
	forl(i,size) cout<<v[i]<<" ";
	cout<<"\n";
}
void removeDups(mv &v) {
	sort(all(v));
	mv::iterator it = unique(v.begin(), v.end());
	v.resize(distance(v.begin(), it));
}
inline ld kthRoot(ld n, ll k) {
	return pow(k, (1.0 / k) * (log(n) / log(k)));
}
ll power(ll x, ll y, ll p) {
	ll res=1;
	x=x%p;
	while(y>0) {
		if(y&1) res = (res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x, ll mod) {
	if(x>=mod) x%=mod;
}

ll mod = 1e9 + 7;

ll arr[5003], crr[5003], tmparr[5003], n, k;
bool vis[5003];

ll getAns(ll pos) {
	forl(i,n + 1) vis[i] = 0;
	ll cur = 0, donee = 0, ret = LLONG_MIN;
	while(!vis[arr[pos]] && donee < k) {
		cur += crr[pos];
		tmparr[donee++] = crr[pos];
		ret = max(ret, cur);
		pos = arr[pos];
		vis[pos] = 1;
	}
	ll k1 = k;
	k1 -= donee;
	if(k1 == 0) return ret;
	cur += ((k1 - 1) / donee) * cur;
	ret = max(ret, cur);
	k1 -= ((k1 - 1) / donee) * donee;
	for(ll i=0;i<min(k1, donee);i++) {
		cur += tmparr[i];
		ret = max(ret, cur);
	}
	return ret;
}

void thisIsMain() {
	cin>>n>>k;
	ll ans = LLONG_MIN;
	forl(i,n) cin>>arr[i + 1];
	forl(i,n) {
		cin>>crr[i + 1];
		ans = max(ans, crr[i + 1]);
	}
	forl(i,n) ans = max(ans, getAns(i + 1));
	cout<<ans<<"\n";
}

int main(void)
{
	fastio
	ll t = 1;
	// cin>>t;
	while(t--) thisIsMain();
	return 0;
}

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

using namespace std;

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

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

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

int main(int argc, char **argv) {
	ll n;
	cin >> n;
	cout << ((n+110)/111*111) << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    S.insert(S.begin() + 4, ' ');
    cout << S << endl;

    return 0;
}


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

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


int main() {
    ll H,W;
    cin >> H >> W;

    ll SizeH = H*2;
    vector<vector<char>> C(SizeH,vector<char>(W));

    ll index=0;
    rep(i,H){
        rep(j,W){
            cin >> C[index][j];
        }
        index++;
        rep(j,W){
            C[index][j] = C[index-1][j];
        }
        index++;
    }

    rep(i,SizeH){
        rep(j,W){
            cout << C[i][j];
        }
        cout << endl;
    }
}



Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
//
struct poi{
  int X;int Y;int Z;
  bool operator<(const poi&R)const{
    return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
  }
};
//
//
int main(){
  int N;
  cin>>N;
  if(N%10==0){
    cout<<10<<endl;
  }else{
    int ans=0;
    while(N){
      ans+=N%10;
      N/=10;
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip> 
typedef long long ll;
const int mod = 1e9 + 7;
using namespace std;
ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll n;
    while (cin >> n)
    {
        ll ans = 0;
        ans += (n / 500) * 1000;
        ans += (n % 500) / 5 * 5;
        cout << ans << '\n';
    }
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int member_count = sc.nextInt();

		int boss [] = new int[member_count];
		int assistant [] = new int[member_count];

		for (int i = 0; i < member_count; i++) {
			assistant[i] = 0;
		}

		for (int i = 1; i < member_count; i++) {
			boss[i] = sc.nextInt();
			assistant[boss[i] - 1]++;
		}

		for (int i = 0; i < member_count; i++) {
			System.out.println(assistant[i]);
		}

	return;

	}
}


Measured memory_bytes: 57528
#include <iostream>
#include <bits/stdc++.h>
#include <cstdlib>

using namespace std;

int main(int argc, char const* argv[])
{
  long long a, b, k;

  scanf("%lld  %lld  %lld", &a, &b, &k);

  if (a > k) {
    a -= k;
    printf("%lld %lld\n", a, b);
  } else {
    k -= a;
    printf("%lld %lld\n", 0, b - k > 0 ? b - k : 0);
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){

	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c) != EOF){
        bool check[20] = {0};
        check[a] = check[b] = check[c] = 1;
        int cnt = 0;
        for(int i = 1; i <= 10; i++){
            if(check[i] == 0 && a+b+i <= 20){
                cnt++;
            }
        }
        if(cnt >= 4) cout << "YES" << endl;
        else cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

string is_match(string& s, string& t) {
    int n = s.size();
    int m = t.size();

    rep(i, n-m+1) {
        string u = s.substr(n-m-i, m);

        bool f = true;

        rep(j, m) {
            if (u[j] != t[j] && u[j] != '?') f = false;
        }

        if (f) {
            string res = s;
            rep(j, m) {
                res[n-m-i+j] = t[j];
            }
            return res;
        }
    }

    return "@";
}

int main() {
    string s, t;
    cin >> s >> t;

    string rest = is_match(s, t);
    if (rest == "@") {
        cout << "UNRESTORABLE" << endl;
    }
    else {
        rep(i, rest.size()) {
            cout << (rest[i] == '?' ? 'a' : rest[i]);
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i, a, n) for (int i = a; i < n; i++)
using namespace std;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int a,b,c,d; cin>>a>>b>>c>>d;
    while(a>0 && c>0) {
        c-=b;
        a-=d;
    }
    if(c<1) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXS 200000

int h,w,n,ans;
int x[MAXS+3],y[MAXS+3];
int vis[MAXS+3];

int main() {
	scanf("%d %d %d",&h,&w,&n);
	ans=h;
	memset(vis,0x3f,sizeof(vis));
	for(int i=1;i<=n;i++) {
		scanf("%d %d",&x[i],&y[i]);
		if(x[i]>=y[i])
			vis[x[i]-y[i]]=min(vis[x[i]-y[i]],x[i]);
	}
	for(int i=1;i<=n;i++)
		if(x[i]>y[i])
			if(vis[x[i]-y[i]-1]>x[i])
				ans=min(ans,x[i]-1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
int main()
{
	int A,B;
	1<=A<=13;
	1<=B<=13;
	scanf("%d %d",&A,&B);
	if(A!=1 && B!=1)
	{
	if(A>B)
		printf("Alice");
		else if(A<B)
			printf("Bob");
			else
				printf("Draw");
	}
	else if(A==1 && B!=1)
		printf("Alice");
		else if(B==1 && A!=1)
			printf("Bob");
			else
				printf("Draw");


}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000007

int main(){

    int n;
    cin >> n;
    string s;
    cin >> s;
    int count = 0,ans = 0;

    REP(n){

        if(s[i] == 'I'){
            count++;
        }else{
            count--;
        }
        ans = max(ans,count);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
fun Int.bit(i:Int) = 1 shl i and this>0
fun <T> readList(del:String = " ",f:String.()->T) = readLine()!!.split(del).map {f(it)}

fun main() {
	val (n,m,x) = readList {toInt()}
	val a = Array(n) {readList {toInt()}.run {get(0) to drop(1)}}

	(1 until (1 shl n)).map {flag->
		var cost = 0
		val list = IntArray(m) {0}
		for((c,l) in (0 until n).asSequence().filter(flag::bit).map {a[it]}) {
			cost += c
			for(i in list.indices)
				list[i] += l[i]
		}
		if(list.all {x<=it}) cost else Int.MAX_VALUE
	}.min()!!.let {println(if(it==Int.MAX_VALUE) -1 else it)}
}


Measured memory_bytes: 42308
#include <cstdio>
int N, T, A, X;
int main()
{
    scanf("%d%d%d", &N, &T, &A);
    int res = 0;
    int cc = 1 << 30;
    for (int i = 1; i <= N; i++)
    {
        scanf("%d", &X);
        int d = (T * 1000 - X * 6) - A * 1000;
        if (d < 0)
            d = -d;
        if (cc > d)
            cc = d, res = i;
    }
    printf("%d\n", res);
}

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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    long long S = 0LL, s = 0LL;
    long long min = 1000000000000000000LL;

    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
        S += A.at(i);
    }
    for(int i = 0; i < N - 1; i++) {
        s += A.at(i);
        min = (min < llabs(2 * s - S)) ? min : llabs(2 * s - S);
    }
    cout << min << endl;

    return 0;
}

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

using namespace std;

long long dp[102][100002];
int w[102], v[102];
int n, W;

long long solve(int i, int rw) {
	if(i == n) return 0;
	if(dp[i][rw] != -1) return dp[i][rw];

	dp[i][rw] = solve(i+1, rw); // leave it
	if(rw >= w[i]) // take it
		dp[i][rw] = max(dp[i][rw], v[i] + solve(i+1, rw-w[i]));

	return dp[i][rw];
}

int main() {
	scanf("%d %d", &n, &W);

	for(int i=0; i<n; i++)
		scanf("%d %d", &w[i], &v[i]);

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

	printf("%lld\n", solve(0, W));

	return 0;
}

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

int main() {
	string s, t;
	cin >> s >> t;
	sort(all(s));
	sort(all(t)); reverse(all(t));
	string ans = (s < t) ? "Yes" : "No";
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

int main() {
    int h, w;   cin >> h >> w;
    int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
    int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

    string *s = new string[h];
    for (int i = 0; i < h; i++)
        cin >> s[i];

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int tmp = 0;
            for (int k = 0; k < 8; k++) {
                int nx = i + dx[k], ny = j + dy[k];
                if (nx < 0 || h <= nx || ny < 0 || w <= ny)
                    continue;
                if (s[nx][ny] == '#')
                    tmp++;
            }
            if (s[i][j] != '#')
                s[i][j] = '0' + tmp;
        }
    }

    for (int i = 0; i < h; i++)
        cout << s[i] << endl;

    return 0;
}

Measured memory_bytes: 888
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(), v.end()

using namespace std;
using ll = int64_t;

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

  string s;
  cin >> s;
  int n = s.size();
  int k;
  cin >> k;

  for (int i = 0; i < n; i++) {
    if (s[i] != 'a') {
      int distance = 'z' - s[i] + 1;
      if (distance <= k) {
        k -= distance;
        s[i] = 'a';
      }
    }
  }

  k %= 26;

  s[n - 1] += k;

  cout << s << endl;

  //cerr << s << endl;
  //cerr << k << endl;

  return 0;
}


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

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

    map<string, int> map;
    string s;
    for(int i = 0; i < n; i++){
        cin >> s;
        auto itr = map.find(s);
        if(itr == map.end()){
            map.insert(make_pair(s, 1));
        }else{
            map[s]++;
        }
    }

    /*for(auto i = map.begin(); i != map.end() ; ++i ) {
        cout << i->first << " " << i->second << "\n";
    }*/
    vector<string> ans;
    int min = -1;
    for(auto i = map.begin(); i != map.end() ; ++i){
        if(i->second == min){
            ans.push_back(i->first);
        }else if(i->second > min){
            min = i->second;
            ans.erase(ans.begin(), ans.end());
            ans.push_back(i->first);
        }
    }

    sort(ans.begin(), ans.end());
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 26868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    string s;
    cin >> s;
    int n = s.size();
    bool flag = false;
    for (int i = 1; i < n; i++) {
        if (s[i] != s[i - 1]) flag = true;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(1, [4, 1, 5]), 5)

    def test_2(self):
        self.assertEqual(think(9, [7, 9, 3, 2, 3, 8, 4, 6]), 0)

    def test_3(self):
        self.assertEqual(think(0, [1000000000, 1000000000, 1000000000]), 3000000000)


def solve():
    k, h = read()
    result = think(k, h)
    write(result)


def read():
    n, k = read_int(2)
    return k, read_int(n)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(k, h):
    if k >= len(h):
        return 0
    h.sort(key=lambda x: -x)
    h[0:k] = [0] * k
    return sum(h)


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 112784
#include <bits/stdc++.h>
using namespace std;
int main ()
{
  int N,A;
  cin >> N;
  for (int i=0; i < N ; i++)
  {
    string Col;
    cin >> Col;
    if ( Col == "Y" )
    {A++;}
  }
  if ( A == 0 ){
  cout << "Three" << endl;
  }
  else
  {
  cout << "Four" << endl;
  }
}

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

int main(){
	int n,t;
	while(1){
		string a;
		cin >> n;
		if(n==-1){
			return 0;
		}
		if(n==0){
			a += '0';
		}
		for(t=0;n!=0;t++){
			a += '0' + n%4;
			n=n/4;
		}
		reverse(a.begin(), a.end());
		cout << a << endl;

	}
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define DEBUG(a) cerr<<#a<<"="<<a<<endl
#define DEBUG_ARRAY(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define DEBUG(a) 
#define DEBUG_ARRAY(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> P;
typedef pair<ll,P> PP;
typedef vector<ll> vll;

const ll INF=(1LL<<50);


void solve(long long K, long long A, long long B){
    if(A+2<B){
        if(K>A){
            ll tmp=(K+1-A)/2;
            cout<<tmp*(B-A)+K-tmp*2+1<<endl;
        }else{
            cout<<1+K<<endl;
        }
    }else{
        cout<<1+K<<endl;
    }
}

int main(){
    long long K;
    scanf("%lld",&K);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(K, A, B);
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {  
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int Z = 0;
		int ONE = 0;
		String S = I.next();
		for (int i = 0; i < S.length(); i++) {
			if (S.charAt(i)=='0') Z++;
			else ONE++;
		}
		O.pln(Math.min(ONE, Z)*2);
	}
	public static ArrayList<String> perms(int N, int upper){
		if (N==1) {
			ArrayList<String> ret = new ArrayList<String>();
			for (int i = 1; i<=upper; i++) ret.add(Integer.toString(i)+" ");
			return ret;
		}
		ArrayList<String> prev = perms(N-1,upper);
		ArrayList<String> ret = new ArrayList<String>();
		for (int i = 0; i < prev.size(); i++) {
			boolean[] vis = new boolean[upper+1];
			String cur = prev.get(i);
			String[] parts = cur.split(" ");
			for (int j = 0; j < parts.length; j++) {
				vis[Integer.parseInt(parts[j])]=true;
			}
			for (int j = 1; j <= upper; j++) {
				if (!vis[j]) {
					String curans = cur;
					curans+=Integer.toString(j)+" ";
					ret.add(curans);
				}
			}
		}
		return ret;
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 28356
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, a, b) for(int i = (a); i >= (b); --i)
#define debug(x) cerr << #x << ' ' << x << endl;
using namespace std;

typedef long long ll;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;
const double EPS=1e-8;
inline int sign(double a){return a<-EPS?-1:a>EPS;}
inline int cmp(double a,double b){return sign(a-b);}
//点
struct P{
    double x,y;
    P(){}
    P(double _x,double _y):x(_x),y(_y){}
    P operator + (P p){return P(x+p.x,y+p.y);}
    P operator - (P p){return P(x-p.x,y-p.y);}
    P operator * (double k){return P(x*k,y*k);}
    P operator / (double k){return P(x/k,y/k);}
    double dot(P p){return x*p.x+y*p.y;}
    double det(P p){return x*p.y-y*p.x;}
    double distTo(P p){return (*this-p).abs();}
    double alpha(){return atan2(y,x);}
    void read(){scanf("%lf%lf", &x, &y);}
    void write(){printf("%.10lf %.10lf\n", x, y);}
    double abs(){return sqrt(abs2());}
    double abs2(){return x*x+y*y;}
    P rot90(){return P(-y,x);}
    P unit(){return *this/abs();}
    int quad(){return sign(y)==1||(sign(y)==0&&sign(x)>=0);}
    P rot(double an){return P(x*cos(an)-y*sin(an),x*sin(an)+y*cos(an));}
    bool operator < (P p)const{int c=cmp(x,p.x);if(c)return c==-1;return cmp(y,p.y)==-1;}
    bool operator == (P o)const{return cmp(x,o.x)==0&&cmp(y,o.y)==0;}
};

int main(int argc, char const *argv[])
{
    P p0, p1, p2, p3;
    int q;
    scanf("%d", &q);
    while (q--) {
        p0.read(); p1.read(); p2.read(); p3.read();
        P s1, s2;
        s1 = p1 - p0; s2 = p3 - p2;
        if(fabs(s1.det(s2)) < EPS) printf("2\n");
        else if(fabs(s1.dot(s2)) < EPS)   printf("1\n");
        else printf("0\n");   
    }
    return 0;
}


Measured memory_bytes: 3240
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using pii=pair<int,int>;
vector<pii> result;

void solveEven(int n){
  for(int i=1;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      if(i+j!=n+1){
	result.push_back(make_pair(i,j));
      }
    }
  }
  cout<<result.size()<<endl;
  for(auto i:result)
    cout<<i.first<<" "<<i.second<<endl;
}

void solveOdd(int n){
  for(int i=1;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      if(i+j!=n){
	result.push_back(make_pair(i,j));
      }
    }
  }
  cout<<result.size()<<endl;
  for(auto i:result)
    cout<<i.first<<" "<<i.second<<endl;
}

int main(){ _;
  int n;cin>>n;

  if(n%2==0){
    solveEven(n);
  }
  else{
    solveOdd(n);
  }
}


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

int dp[100005][3];

int main() {
  int N;
  cin >> N;
  int a, b, c;
  vector<vector<int>> D(N);
  for (int i = 0; i < N; i++) {
    cin >> a >> b >> c;
    D[i].push_back(a); D[i].push_back(b); D[i].push_back(c);
  }
  dp[0][0] = D[0][0]; dp[0][1] = D[0][1]; dp[0][2] = D[0][2];
  for (int i = 1; i < N; i++) {
    dp[i][0] = D[i][0] + max(dp[i-1][1], dp[i-1][2]);
    dp[i][1] = D[i][1] + max(dp[i-1][0], dp[i-1][2]);
    dp[i][2] = D[i][2] + max(dp[i-1][0], dp[i-1][1]);
  }
  cout << max({dp[N-1][0], dp[N-1][1], dp[N-1][2]}) << endl;
}

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

int main(){
	int n,cA=0,cUn=0,j=1;
	string s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s=="A"){
			cA++;
		}
		else if(s=="Un"){
			cUn++;
		}
		if(cA<cUn) j=0;
	}
	if(cA==cUn&&j!=0) j=1;
	else j=0;
	if(j==1) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 3140
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*  ________       __      ________  _    __       __       ________               *
* |  ______|     /  \    |  ____  || |  / /      /  \     |  ____  |              *
* | |______     / /\ \   | |____| || |_/ /      / /\ \    | |____| |              *
* |______  |   / /__\ \  |  __  __||  __ \     / /__\ \   |  __  __|              *
*  ______| |  / ______ \ | |  \ \  | |  \ \   / ______ \  | |  \ \                *
* |________| /_/      \_\|_|   \_\ |_|   \_\ /_/      \_\ |_|   \_\               *
*                                                                                 *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int A,B,C;

    cin >> A >> B >> C;

    if((A == B && A != C && B != C) || (A == C && A!= B && C != B) || (B == C && A != B && A != C))
    {
        cout << "Yes" << endl;
    }

    if(A == B && B == C && C == A)
    {
        cout << "No" << endl;
    }

    if(A != B && B != C && C != A)
    {
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdio>
using namespace std;

static const int INF=100000;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N,L;
    cin >> N >> L;
    int ans=0;
    vector<int> t(N);
    if(L>=0){
        for(int i=2;i<=N;i++){
            ans+=L+i-1;
        }
    }else if(abs(N)<=abs(L)&&L<0){
        for(int i=1;i<N;i++){
            ans+=L+i-1;
        }
    }else{
        for(int i=1;i<=N;i++){
            ans+=L+i-1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <math.h>

using namespace std;
#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("aa_input.txt", "r", stdin);
    int t=1;
    //cin>>t;
    while (t--)
    {
        int s, w;
        cin>>s>>w;
        if(s<=w) cout<<"unsafe"<<endl;
        else cout<<"safe"<<endl;
    }
    
    return 0;
}
/*

riaadmorshed@gmail.com

*/

Measured memory_bytes: 3648
//0007 Debt Hell
// éÉZñÅ¢éFlÍàÉ¢ÁÄÅàÆÒ©ç10~ØèÄµÜÁ½
//»ÌÆÒÍT²ÆÉqª5%t«A»ÌÛ1000¢ÍØèã°éÆ¢¤
//nTÔãÌÔÏzðßæ@È¨An<=100Æ·é

#include<iostream>
using namespace std;

int main(void)
{
	int debt;
	int n;
	int i;

	cin >> n;
	debt = 100000;	//ÅÍ10~
	for(i = 0; i < n; i++)
	{
		//T²ÆÉ1.05{
		debt += debt/20;
		//1000~¢Ì[ª é©
		int fraction = debt%1000;
		if(fraction)
			debt = debt-fraction + 1000;
	}
	cout << debt << endl;

	return 0;
}

Measured memory_bytes: 0
n, k = map(int, input().split())
mod = 10 ** 9 + 7

ans = 0
c = 0   #combination
l = 0
h = 0
for i in range(1, n+2): #O(n)
    l += i - 1
    h += n + 1 - i
    c = (h - l + 1) % mod
    if i >= k:
        ans = (ans + c) % mod
    else:
        pass
print(ans)   

Measured memory_bytes: 9176
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <math.h>
#include <string>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>

using namespace std;

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

template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

const int maxn = 1000100;
int n;
ll s, res;
ll a[maxn];
map<ll, ll> b;
void solve() {
	scanf("%d", &n);
	for(int i = 0, x; i < n; ++ i){
		scanf("%d", &x);
		s += x;
		a[i] = x;
		b[s] ++;
	}
	s = 0;
	for(int i = 0; i < n; ++ i){
		s = s + a[i]; 
		res += b[s];
		if(s == 0) res ++;
		b[s] --;
	}
	cout << res - n;
}

int main() {
	int t = 1;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 14336
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

vector< vector<int> > g;
int n, m;

vector<bool> visited;
vector<int> matching;

bool augment(int left) {
  if (left < 0)
    return true;
  if (visited[left])
    return false;
  visited[left] = true;
  REP(i, g[left].size()) {
    int right = g[left][i];
    if (augment(matching[right])) {
      matching[right] = left;
      return true;
    }
  }
  return false;
}
int match() {
  matching.assign(m, -1);
  int matches = 0;
  REP(left, n) {
    visited.assign(n, false);
    if (augment(left))
      matches++;
  }
  return matches;
}

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

int main(){
  int r[500];
  int b[500];
  while((n = getInt()) + (m = getInt())){
    g = vector<vector<int> >(n);
    visited = vector<bool>(n);
    matching = vector<int>(m);

    REP(i,n)
      b[i] = getInt();

    REP(i,m)
      r[i] = getInt();

    REP(i,n) REP(j,m) if(gcd(b[i], r[j]) != 1){
      g[i].push_back(j);
    }

    print(match());
  }
  return 0;
}

Measured memory_bytes: 1900
#include<iostream>
#include<cstdio>
#define rep(i,n)for(int i=0;i<n;i++)

using namespace std;

int main()
{
    int a,b,x,y;
    scanf("%d%d%d%d",&a,&b,&x,&y);
    printf("%lf %d\n",double(a)*double(b)/2,x+x==a && y+y==b);

    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}

import Data.Array.ST
import Data.Array.Unboxed
import Data.Array.Base (unsafeRead, unsafeWrite)
import Control.Monad

shive :: Int -> UArray Int Bool
shive n = runSTUArray $ do
  arr <- newArray (0,n) True
  mapM_ (setFalse arr) $ [0,1] ++ [4 , 6 .. n]
  mapM_ (loop arr) [3, 5 .. truncate $ sqrt $ fromIntegral n]
  return arr
    where
      loop arr k = do
        v <- unsafeRead arr k
        when v $ mapM_ (setFalse arr) [k * k, k * (k + 2) .. n]
      setFalse arr k = unsafeWrite arr k False


primeList :: Int -> [Int]
primeList n = [p | (p, bool) <- assocs $ shive n, bool]

main = do
  n' <- getContents
  let n = map read $ lines n'
  putStr $ unlines $ map show $ map (length . primeList) n

Measured memory_bytes: 5444
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <iomanip>

using namespace std;
// for loop
#define F(i, L, R) for(int i = L; i < R; i++)
#define FE(i, L, R) for(int i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(int i = L; i > R; i--)
#define FRE(i, L, R) for(int i = L; i >= R; i--)

// data types
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

int main() {
    int n;
    cin >> n;
    vi data(100);
    F(i, 0, n){
        int l;
        cin >> l;
        data[n-i-1] = l;
    }
    printAF(data, n);
}



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

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

int main(){
	int N, K;
	cin >> N >> K;
	int d[110];
	int snuke[110]={0};
	rep(i,K){
		cin >> d[i];
		rep(j,d[i]){
			int A;
			cin >> A;
			snuke[A]++;
		}
	}
	int ans=0;
	for(int i=1; i<=N; i++){
		if(snuke[i]==0) ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3636
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
P = []
C = []
for i in range(N):
    a, b = MAP()
    P.append([a, b])
for j in range(M):
    c, d = MAP()
    C.append([c, d])

def calculate_manhattan_distance(x1, y1, x2, y2):
    return abs(x1 - x2) + abs(y1 - y2)

for i in range(N):
    min_d = INF
    for j in range(M):
        tmp_d = calculate_manhattan_distance(P[i][0], P[i][1], C[j][0], C[j][1])
        if tmp_d < min_d:
            min_d = tmp_d
            ans_c_id = j + 1
    print(ans_c_id)


Measured memory_bytes: 9996
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def main():
    N = int(readline())
    abc = map(int, read().split())
    x, y, z = 0, 0, 0
    for a, b, c in zip(abc, abc, abc):
        x, y, z = max(y, z) + a, max(x, z) + b, max(x, y) + c

    print(max(x, y, z))


if __name__ == '__main__':
    main()


Measured memory_bytes: 25444
a, b, c, k = map(int, input().split())

m = 0
if k >= a:
    m += a
    k -= a
else:
    m = k
    k = 0

if k > 0:
    if k >= b:
        k -= b
    else:
        m = k
        k = 0

if k > 0:
    if k >= c:
        m -= c
    else:
        m -= k

print(m)

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

int main() {
    int A, B;
    cin >> A >> B;
    int ans = 0;
    int tmp = 1;
    if (B == 1) {
        cout << 0 << endl;
        return 0;
    }
    while (true) {
        tmp -= 1;
        tmp += A;
        ans += 1;
        if (tmp >= B) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
#define fs first
#define sc second
#define mp make_pair
#define L(x) (1<<x)
#define next Next
using namespace std;
const int inf=1e9+10;
const ll llinf=1e16+10;
const int maxn=1e5+10;
const int maxm=1e3+10;
const int mod=1e9+7;
int n;
int c[maxn];
int main()
{
    //freopen("in.txt","r",stdin);
    while(~scanf("%d",&n))
    {
        cls(c,0);
        for(int i=1;i<=n;i++)
        {
            int x;
            scanf("%d",&x);
            c[x+2]++;
            c[x+1]++;
            c[x]++;
        }
        int ans=0;
        for(int i=0;i<maxn;i++)
            ans=max(ans,c[i]);
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    int N;
    cin >> N;
    map<ll, int>cnt;
    vector<ll>A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        cnt[A[i]]++;
    }
    ll a = 0, b = 0;
    for(int i = 0; i < A.size(); i++){
        if(a < b)swap(a, b);
        if(cnt[A[i]] >= 2 && b < A[i]){
            cnt[A[i]] -= 2;
            b = A[i];
        }
        if(cnt[A[i]] >= 2 && a < A[i]){
            cnt[A[i]] -= 2;
            a = A[i];
        }
    }
    cout << a * b << endl;

    return 0;
}

Measured memory_bytes: 7296
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    String t = sc.next();
    String tmp = s;
    tmp += s;

    if (tmp.contains(t)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}

Measured memory_bytes: 39296
n,m=gets.split.map(&:to_i)
l=[0]*(n+1)
m.times do
  a,b=gets.split.map(&:to_i)
  l[a]+=1
  l[b]+=1
end
l.each do |k|
  if k.odd?
    puts "NO"
    exit
  end
end
puts "YES"

Measured memory_bytes: 15156
import java.util.*;

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

    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long k = sc.nextLong();
    long ans = 0;

    if(k < a){
      ans = k;
    } else if(k <= a + b){
      ans = a;
    } else {
      ans = 2 * a + b - k;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 35768
import heapq

X, Y, A, B, C = map(int,input().split())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
R = list(map(int,input().split()))
P.sort(reverse=True)
Q.sort(reverse=True)
red = P[:X]
green = Q[:Y]
ALL = red + green
R = list(map(lambda x: x*(-1), R))
ALL = list(map(lambda x: x*(-1), ALL))

heapq.heapify(R)
heapq.heapify(ALL)

ans = 0
loop = len(ALL)

for _ in range(loop):
    if len(R) == 0:
        ans += heapq.heappop(ALL)*(-1)
    elif len(ALL) == 0:
        ans += heapq.heappop(R)*(-1)
    elif R[0]*(-1) < ALL[0]*(-1):
        ans += heapq.heappop(ALL)*(-1)
    else:
        ans += heapq.heappop(R)*(-1)

print(ans)

Measured memory_bytes: 27040
l = input().split()
N = int(l[0])
A = int(l[1])
B = int(l[2])
C = int(l[3])
D = int(l[4])
l = input().split()
S = l[0]

# print(N, A, B, C, D, S)

def blocked(path):
    return '##' in path

def cleared(path):
    return '...' in path

def find_path(A, B, C, D, S):
    s_path = S[A:C]
    f_path = S[B:D]
    if blocked(s_path) or blocked(f_path):
        return False
    return True

def solve(A, B, C, D, S):
    if not find_path(A, B, C, D, S):
        return False
    begin = B - 2
    end = D - 2 if S[D - 2] == '#' else C
    return cleared(S[begin:end])

ret = True
if C < D:
    ret = find_path(A, B, C, D, S)
else:
    ret = solve(A, B, C, D, S)

if ret:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 41328
using System;
using System.Collections.Generic;
class Program
    {
        static void Main(string[] args)
        {   
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]), b = int.Parse(s[1]), t = int.Parse(s[2]);
            Console.WriteLine(t/a * b);
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 11092
n, m = map(int, input().split())
A = [[] for i in range(n)]
for i in range(n):
    A[i] = list(map(int, input().split()))
B = [[0]*1 for i in range(m)]
for i in range(m):
    B[i] = int(input())
for row in range(n):
    c = 0
    for col in range(m):
        c += A[row][col] * B[col]
    print("%d" %(c))


Measured memory_bytes: 6024
import numpy as np

n = int(input())
s = [int(i=='#') for i in input()]

blacks = 0
whites = np.sum(np.array(s)==0)
ans = [blacks+whites]

for x in s:
  if x==1:
    blacks += 1
  else:
    whites -= 1

  ans.append(blacks + whites)

print(np.min(ans))


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

using namespace std;

namespace {

    struct E {
        int from, to, w;
        E(int from, int to, int w) : from(from), to(to), w(w) {}
        bool operator<(const E& e) const {
            if (from == e.from) {
                return to < e.to;
            }
            return from < e.from;
        }
    };

    int N;
    vector<E> P;
    bool input() {
        cin >> N;
        if (N == 0) return false;
        P.clear();
        for (int i = 0; i < N; i++) {
            int x, y, w; cin >> x >> y >> w;
            P.push_back(E(x, y, w));
        }
        return true;
    }

    const int INF = 1<<28;
    void solve() {
        sort(P.begin(), P.end());
        static int dp[2][367][367];
        memset(dp, 0, sizeof(dp));
        int ans = 0;
        for (int i = 0; i < N; i++) {
            const E& e = P[i];
            for (int j = 0; j <= 366; j++) for (int k = 0; k <= 366; k++) {
                dp[(i + 1) & 1][j][k] = dp[i & 1][j][k];
            }
            for (int j = 0; j <= 366; j++) {
                dp[(i + 1) & 1][j][e.to + 1] = max(dp[i & 1][j][e.to + 1], dp[i & 1][j][e.from] + e.w);
                int c = dp[(i + 1) & 1][j][e.to + 1];
                for (int k = e.to + 1; k <= 366; k++) {
                    c = max(c, dp[(i + 1) & 1][j][k]);
                    dp[(i + 1) & 1][j][k] = c;
                }
            }
            for (int j = 0; j <= 366; j++) {
                dp[(i + 1) & 1][e.to + 1][j] = max(dp[i & 1][e.to + 1][j], dp[i & 1][e.from][j] + e.w);
                int c = dp[(i + 1) & 1][j][e.to + 1];
                for (int k = e.to + 1; k <= 366; k++) {
                    c = max(c, dp[(i + 1) & 1][k][j]);
                    dp[(i + 1) & 1][k][j] = c;
                }
            }
        }
        cout << dp[(N + 1) & 1][366][366] << endl;
    }
}

int main() {
    while (input()) solve();
    return 0;
}

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

int main() {
    long n, x, m;
    cin >> n >> x >> m;
    long res = 0;
    long i, j = x, k = x, l, c = 0;
    while (true) {
        j = j * j % m;
        k = k * k % m;
        k = k * k % m;
        if (j == k) {
            l = x;
            while(l != j) {
                c++;
                j = j * j % m;
                l = l * l % m;
            }
            break;
        }
    }
    j = x;
    if (n <= c) {
        for (i = 0; i < n; i++) {
            res += j;
            j = j * j % m;
        }
        cout << res << endl;
        return 0;
    }
    for (i = 0; i < c; i++) {
        res += j;
        j = j * j % m;
    }
    n -= c;
    long r = 0, rc = 0;
    k = j;
    do {
        r += k;
        k = k * k % m;
        rc++;
    }while(k != j);
    res += r * (n / rc);
    for (i = 0; i < (n % rc); i++) {
        res += j;
        j = j * j % m;
    }
    cout << res << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <stdlib.h>
#include <cstdint>
using namespace std;

int main()
{
	int x;
	int ans = 1;

	cin >> x;

	if( x == 1 ) {
		cout << ans << endl;
		return 0;
	}

	for( int b = 2; b <= x / b; b++ ) {
		int acc = b * b;
		while( acc * b <= x ) {
			acc *= b;
		}
		if( acc > ans ) {
			ans = acc;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define ll long long int

using namespace std;

ll ans[101][100001];
pair<ll, ll> arr[101];

int main(){
    ll n, w;
    cin >> n >> w;
    for(int i=1;i<=n;i++) cin >> arr[i].first >> arr[i].second;
    sort(arr, arr+n);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=w;j++){
            if(j-arr[i].first<0) ans[i][j] = ans[i-1][j];
            else{
                ans[i][j] = max(ans[i-1][j], arr[i].second + ans[i-1][j-arr[i].first]);
            }
        }
    }
    cout << ans[n][w] << endl; 
    return 0;
}

Measured memory_bytes: 81200