akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll K,N;
    cin>>K>>N;
    v A(N);
    rep(i,0,N)cin>>A[i];
    ll maxdiff = 0;
    rep(i,0,N-1){
        maxdiff = max(maxdiff,A[i+1]-A[i]);
    }
    maxdiff = max(maxdiff,K-(A[N-1]-A[0]));
    cout<<K-maxdiff;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++){
  cin >> d.at(i);
  }
  
  sort(d.begin(), d.end());
  int step = 1, temp = d.at(0);
  for(int i = 0; i < N; i++){
    if(temp == d.at(i))	continue;
    else{
    step++;
    temp = d.at(i);
    }
  }
  cout << step << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>

using namespace std;

int v[2001][2001];
int n,k;
int getsize(int x1,int y1,int x2,int y2){
    return v[x2][y2] - v[x2][y1] - v[x1][y2] + v[x1][y1];
}
int main()
{
    scanf("%d%d",&n,&k);
    int a,b;
    char c;
    for(int i = 1;i <= n;i ++){
        scanf("%d%d %c",&a,&b,&c);
        a %= 2 * k,b %= 2 * k;
        if(c == 'W')
            b += k;
        v[a % (2 * k) + 1][b % (2 * k) + 1] ++;
    }
    for(int i = 1;i <= 2 * k;i ++)
        for(int j = 1;j <= 2 * k;j ++)
            v[i][j] = v[i][j] + (v[i - 1][j] + v[i][j - 1] - v[i - 1][j - 1]);
    int ans = 0,sum;
    for(int i = 1;i <= k;i++)
        for(int j = 1;j <= k;j++){
            sum = getsize(0,0,i,j);
            sum += getsize(i,j,k + i,k + j) + getsize(k + i,k + j,2 * k,2 * k) + getsize(k + i,0,2 * k,j) + getsize(0,k + j,i,2 * k);
            ans = max(ans,max(sum,n - sum));
    }
    printf("%d\n",ans);
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    int ans = 0;
    int kuti = 1;
    for(;kuti<b;ans++)
    {
        kuti--;
        kuti += a;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1'000'000'009;

int main()
{
	int N; cin >> N;
	cout << (N + 1) % 2 << endl;
}


Measured memory_bytes: 3616
N = int(input())
H = list(map(int, input().split()))
flag = True
maxim = 0

for n in range(N):
  if maxim < H[n]:
    maxim = H[n]
  if H[n] < maxim -1:
      flag = False
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int h,w,n;
  cin >> h >> w >> n;
  int a=max(h,w),ans=0;
  rep(i,n+5){
    if (i*a>=n){
      ans=i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
arr = list(map(int,input().split()))
buf = [0 for i in range(61)]

count = [[0,0] for i in range(61)]

for a in arr:
    txt = str(bin(a))[2:].zfill(61)

    for i in range(len(txt)):
        if txt[i] == "0":
            buf[i] += count[i][1]
            count[i][0] += 1
        else:
            buf[i] += count[i][0]
            count[i][1] += 1

m = 10**9 +7

buf.reverse()
ans = 0

for i in range(len(buf)):
    num = buf[i]
    if i == 0:
        base = 1
    else:
        base = base*2
    b = base%m
    b = (b*num)%m

    ans += b
    ans = ans%m

# print(buf)
print(ans)





Measured memory_bytes: 123056
import java.util.*;

public class Main {
	static int[] a;
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>();
		for(int i = 0; i < n; i++) {
			if(hm.containsKey(a[i]) && hm.get(a[i]) == 1) {
				hm.put(a[i], 0);
			} else {
				hm.put(a[i], 1);
			}
		}
		int cout = 0;
		for(int key : hm.keySet()) {
			if(hm.get(key) == 1) {
				cout++;
			}
		}
		System.out.println(cout);
	}
}

Measured memory_bytes: 54144
W, H, x, y = map(int, input().split())
a = float(W * H / 2)
flag = 0
if x == 0 or y == 0 or x == W or y == H:
    falg = 0
else:
    if x == W / 2 and y == H / 2:
        flag = 1
    else:
        flag = 0
print(a, flag)

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

using namespace std;

int main(){
  int n;
  cin >> n;
  string S;
  vector<char> s;
  cin >> S;
  for(int i=0;i<S.size();i++){
    s.push_back(S[i]);
  }

  for(int i=0;i<S.size();i++){
    int tmp=0;
    tmp=int(s.at(i))+n;
    if(tmp>90){
      tmp=tmp-26;
    }
    cout << char(tmp);
  }
  cout << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	
	ll tmp = k * ll(n / k + 1);
	ll ans = min(abs(n - tmp), n % k);
	dunk(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long



int main(){
    
    FAST_IO
    int n;
    cin>>n;
    cout<<(1000-(n%1000))%1000<<"\n";
    return 0;
}

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

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

int main()
{
	int a,b;
	a=read(),b=read();
	if (a+b==15) puts("+");
	else if (a*b==15) puts("*");
	else puts("x");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
int m,f,r;
while(1){
scanf("%d %d %d",&m,&f,&r);
if(m==-1&&f==-1&&r==-1)break;
else if(m==-1||f==-1) printf("F\n");
else if((m+f)>=80) printf("A\n");
else if(65<=(m+f)&&(m+f)<80) printf("B\n");
else if(50<=(m+f)&&(m+f)<65) printf("C\n");
else if(30<=(m+f)&&(m+f)<50) {if(r>=50) printf("C\n"); else printf("D\n");}
else printf("F\n");
}
return 0;
}

Measured memory_bytes: 584
n = int(input())
a = list(map(int,input().split()))
a.sort()
v = a[0]
count = 1
result = 0
for i in range(1,n):
    if v == a[i]:
        count += 1
    else:
        if v == count:
            v = a[i]
            count = 1
        else:
            if count > v:
                result += count -v
                v = a[i]
                count = 1
            else:
                result += count
                v = a[i]
                count = 1
if v != count:
    if count > v:
        result += count -v
    else:
        result += count
print(result)

Measured memory_bytes: 63856
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()


double a, t;
double temp(double x){
    return t-x*6/1000;
}


int main(){
    int n;
    cin>>n>>t>>a;
    vector<double> h(n);
    rep(i,n) cin>>h[i];
    int ans=0;
    double c;
    if(temp(h[0])-a>0) c=temp(h[0])-a;
    else c=a-temp(h[0]);
    rep(i,n-1){
        double che=temp(h[i+1])-a;
        if(che<0) che*=-1;
        if(che<c){
            ans=i+1;
            c=che;
        }
    }
    cout<<ans+1<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    char a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    if(a==f&&b==e&&c==d)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
x = int(input())

i = 0
while True:
    a = i
    b = (np.abs(a**5 - x))**(1/5)
    #print(b)
    if (a**5-x) < 0 :
        b = -b
    if a**5 - int(b)**5 == x:
        print(a,int(b))
        break
    
    a = -i
    b = (np.abs(a**5 - x))**(1/5)
    if (a**5-x) < 0 :
        b = -b
    if a**5 - int(b)**5 == x:
        print(a,int(b))
        break
    i += 1

Measured memory_bytes: 27112
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;

int dp[405][405][41];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, ma, mb;
	cin >> n >> ma >> mb;
	vector<int> a(n), b(n), c(n);
	rep(i,405)rep(j,405)rep(k,41) dp[i][j][k] = INF;
	dp[0][0][0] = 0;
	rep(i,n){
		cin >> a[i] >> b[i] >> c[i];
		rep(j,400)rep(k,400){
			if(j+a[i] >= 401) continue;
			if(k+b[i] >= 401) continue;
			chmin(dp[j][k][i+1], dp[j][k][i]);
			chmin(dp[j+a[i]][k+b[i]][i+1], dp[j][k][i] + c[i]);
		}
	}
	int ans = INF;
	for(int i = 1; i <= 400; i++){
		int ca = i;
		int cb = i * mb;
		if(cb%ma != 0) continue;
		cb /= ma;
		if(cb > 400) continue;
		chmin(ans, dp[ca][cb][n]);
	}
	if(ans == INF) ans = -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 26496
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < (int) (b); i++)
#define REP(i, n)    for (int i = 0; i < (int) (n); i++)
#define REP1(i, n)   for (int i = 1; i <= (int) (n); i++)
#define all(x)       (x).begin(), (x).end()
#define SZ(x)        ((int) (x).size())
using ll = long long;

int main() {
  int n;
  cin >> n;
  map <ll, ll> mp;
  ll ans = 0;
  REP(i, n) {
	ll a;
	cin >> a;
	mp[a]++;
	ans += a;
  }
  int q;
  cin >> q;
  REP(i, q) {
	ll b, c;
	cin >> b >> c;
	ll cnt = mp[b];
	ans   += cnt * (c - b);
	mp[c] += cnt;
	mp[b]  = 0;
	cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 9328
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);

int main() {
    int N, K;
    cin >> N >> K;
    int h[N];
    rep(i, N) cin >> h[i];
    int dp[N+K+100];
    rep(i, N+K+100) dp[i] = INF;
    dp[0] = 0;
    rep(i, N){
        for(int j = 1; j <= K; j++){
            if (i+j < N) dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j])); 
        }
    }
    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
using namespace std;
const int MAX = 100;
int main() {
	int N, s, sum = 0, min = MAX; // minは10の倍数でない最小の数を入れる
	cin >> N;
	for (int i = 0;i < N;i ++) {
		cin >> s;
		sum += s;
		if (s % 10 && s < min) min = s;
	}
	if (sum % 10) cout << sum;
	else if (min % 10) cout << sum - min;
	else cout << 0;
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val p = (1..n).map { sc.nextInt()-1 }

  val array = p.toIntArray()

  var count = 0
  for (i in 0 until n-1) {
    val a1 = array[i]

    if (a1 == i) {
      val a2 = array[i+1]
      array[i] = a2
      array[i+1] = a1
      count++
    }
  }
  val last1 = array[n-1]
  if (last1 == n-1) {
    count++
  }

  println(count)

}

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

using namespace std;

int main() {

	int n;
	cin >> n ;

	int total = 0;
	int saidai = 0;
	int l = 0;
	for (int i = 0; i < n; i++) {
		cin >> l;
		total += l;
		if (l > saidai) { saidai = l; }
	}
	
	if (total - saidai > saidai) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  int abMax = 0;
  int value = 0;
  int idx = -1;
  for(int i=0;i<n;i++) {
    if(abs(a[i]) > abMax) {
      abMax = abs(a[i]);
      value = a[i];
      idx = i;
    }
  }
  if(idx == -1) {
    cout << 0 << endl;
    return 0;
  }
  vector<P> ans;
  for(int i=0;i<n;i++) {
    if(a[i] == value) continue;
    else {
      P p;
      p.first = i+1; p.second = idx+1;
      ans.emplace_back(p);
      a[i] += value;
    }
  }
  if(value < 0) {
    for(int i=n-2;i>=0;i--) {
      if(a[i] <= a[i+1]) continue;
      else {
        ans.emplace_back(make_pair(i+1, i+2));
        a[i] += a[i+1];
      }
    }
  }
  else {
    for(int i=0;i<n-1;i++) {
      if(a[i] <= a[i+1]) continue;
      else {
        ans.emplace_back(make_pair(i+2, i+1));
        a[i+1] += a[i];
      }
    }
  }
  cout << ans.size() << endl;
  for(int i=0;i<ans.size();i++) {
    cout << ans[i].second << " " << ans[i].first << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from itertools import permutations

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

d = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    A, B, C = map(int, input().split())
    d[A][B] = C
    d[B][A] = C
g = csgraph_from_dense(d)
g = floyd_warshall(g)

result = 1000000000
for p in permutations(r):
    t = 0
    for i in range(R - 1):
        t += g[p[i]][p[i + 1]]
    result = min(result, t)
print(int(result))


Measured memory_bytes: 19144
using System;

namespace b122A {
    class Program {
        static void Main(string[] args) {
            var input = Console.ReadLine();
            switch (input) {
                case "A":
                    Console.WriteLine("T");
                    return;
                case "T":
                    Console.WriteLine("A");
                    return;
                case "G":
                    Console.WriteLine("C");
                    return;
                case "C":
                    Console.WriteLine("G");
                    return;
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define INF 10000000
using namespace std;
int main()
{
  int n, m;
  while(cin >> n >> m, n | m) {
    vector<int> A(n + 1, 0);
    vector<int> B(n + 1, 0);
    int x, k, p;
    for(int i = 0; i < m; i++) {
      cin >> x >> k;
      for(int j = 0; j < k; j++) {
	cin >> p;
	p--;
	if(k == 1) A[p] += x;
	B[p] += x;
      }
    }
    int max_p = -1;
    int min_p = INF;
    for(int i = 0; i < n; i++) {
      if(B[i] > max_p && A[i] < min_p && min_p != INF){
	max_p = max(max_p, B[i]);
	continue;
      }
      max_p = max(max_p, B[i]);
      min_p = min(min_p, A[i]);
    }
    int ans = max_p - min_p + 1;
    cout << ans << endl;
  }
  return 0;
}




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

int main() {
    int H, W;  cin >> H >> W;
    vector<vector<char>> grid(H, vector<char>(W));
    for (int i = 0; i < H; ++i) for (int j = 0; j < W; ++j) cin >> grid[i][j];

    vector<int> gyou(H), retsu(W);
    // 行
    for (int i = 0; i < H; ++i) {
        bool flg = true;
        for (int j = 0; j < W; ++j) {
            if (grid[i][j] == '#') flg = false;
        }
        if (!flg) gyou[i] = 1;
        else gyou[i] = 0;
    }
    // 列
    for (int j = 0; j < W; ++j) {
        bool flg = true;
        for (int i = 0; i < H; ++i) {
            if (grid[i][j] == '#') flg = false;
        }
        if (!flg) retsu[j] = 1;
        else retsu[j] = 0;
    }

    for (int i = 0; i < H; ++i) {
        if (gyou[i] == 0) continue;
        for (int j = 0; j < W; ++j) {
            if (retsu[j] == 0) continue;
            cout << grid[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int N; 

int dfs(string s){
  if (stol(s)>N) return 0;
  int result = 0;
  if (
    find(s.begin(), s.end(), '3') != s.end() &&
    find(s.begin(), s.end(), '5') != s.end() &&
    find(s.begin(), s.end(), '7') != s.end()
  ) result++;
  result += dfs(s+"3"); result += dfs(s+"5"); result += dfs(s+"7");
  return result;
}

int main() {
  cin >> N;
  cout << dfs("0") << endl;
  return 0;
}

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

int n,dp[31];

int rec(int n){
    if(dp[n] != 0) return dp[n];
    return dp[n] = rec(n-1) + rec(n-2) + rec(n-3);
}

int main(){
    while(cin >> n,n){
        fill(dp,dp+31,0);
        dp[0] = 1; dp[1] = 1; dp[2] = 2;
        cout << rec(n)/3650 + 1<< endl;
    }
}

Measured memory_bytes: 1160
N,M=map(int,input().split())
drink=[tuple(map(int,input().split())) for i in range(N)]
drink.sort(key=lambda x:(x[0],-x[1]))
ans=0
tmp=0
for i in range(N):
    if tmp+drink[i][1]<=M:
        tmp+=drink[i][1]
        ans+=drink[i][0]*drink[i][1]
    else:
        #M<tmp+drink[i][1]
        #tmp+x=M
        ans+=drink[i][0]*(M-tmp)
        break
print(ans)



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

int main()
{
    int a,b,c,i,k;
    k=0;
    cin>>a>>b>>c;
    for(i=a;i<=b*a;i=i+a)
    {
        if((i%b)==(c%b))
        {
            k=1;
        }
    }
    if(k==1)
    {
        cout<<"YES";
    }
    else
        cout<<"NO";
    return 0;



}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<array>
#include<deque>
#include<queue>
#include<map>
#include<cmath>
#include<stdio.h>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::array;
using std::queue;
using std::deque;
using std::priority_queue;
using std::multimap;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;
using std::sin;
using std::cos;
using std::tan;
using std::log;
using std::floor;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;
#define MOD 1000000007;
#define PI 3.141592653589793;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int N;
string si[51];
int ti[51];
string X;
bool f = false;
int ans=0;
int main(void){
  cin.tie(0);
	std::ios::sync_with_stdio(false);

	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> si[i];
		cin >> ti[i];
	}
	cin >> X;

	for(int i = 0;i < N; i++){
		if(f) ans += ti[i];
		if(X == si[i]) f = true;
	}
	cout << ans;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

    if(a == 5 && b == 7 && c == 5) {
      System.out.println("YES");
    } else if(a == 5 && b == 5 && c == 7) {
      System.out.println("YES");
    } else if(a == 7 && b == 5 && c == 5) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 21844
//we_love_golf
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		sc.nextLine();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int max_k_multi = (b / k) * k;
		
		if(a<=max_k_multi) {
			System.out.println("OK");
		} else {
			System.out.println("NG");
		}
	}
}


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

int main() {
  int p, w, g, y, n;
  string s;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == "P") {
      p++;
    }
    else if (s == "W") {
      w++;
    }
    else if (s == "G") {
      g++;
    }
    else if (s == "Y") {
      y++;
    }
  }

  if (p && w && g && y) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

flg = True
for x, y in [(a, b), (a, c), (a, d), (a, e), (b, c), (b, d), (b, e), (c, d), (c, e), (d, e)]:
    if y -x <= k:
        continue
    else:
        flg = False
        break
if flg:
    print("Yay!")
else:
    print(":(")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

pll LR[200005];
pll PQ[100005];

int R[505][505];

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

	REP(i, M)
	{
		int l, r;
		cin >> l >> r;
		l--; r--;
		R[l][r]++;
	}
	REP(i, N)
	{
		for (int k = i - 1; k >= 0; --k)
		{
			R[k][i] += R[k + 1][i];
		}
		for (int k = i + 1; k < N; ++k)
		{
			R[i][k] += R[i][k - 1];
		}
	}
	REP(i, Q)
	{
		int p, q;
		//cin >> PQ[i].first >> PQ[i].second;
		cin >> p >> q;
		p--; q--;
		cout << R[p][q] << endl;
	}

	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) \
  SORT(var);       \
  REVERSE(var)
#define OPTIMIZE_STDIO         \
  ios::sync_with_stdio(false); \
  cin.tie(0);                  \
  cout.precision(10);          \
  cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
  ll x;
  mint() : x(0) {
  }
  mint(ll x) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint& r) {
    if ((x += r.x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint& operator-=(const mint& r) {
    if ((x -= r.x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint& operator*=(const mint& r) {
    if ((x *= r.x) > MOD) {
      x %= MOD;
    }
    return *this;
  }
  mint& operator++() {
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint operator++(int) {
    mint ret = x;
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return ret;
  }
  mint& operator--() {
    if ((--x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint operator--(int) {
    mint ret = x;
    if ((--x) < 0) {
      x += MOD;
    }
    return ret;
  }
  mint operator+(const mint& r) {
    mint ret;
    return ret = x + r.x;
  }
  mint operator-(const mint& r) {
    mint ret;
    return ret = x - r.x;
  }
  mint operator*(const mint& r) {
    mint ret;
    return ret = x * r.x;
  }
  mint operator-() {
    return mint() - *this;
  }
  bool operator<(const mint& a) {
    return x < a.x;
  }
  bool operator>(const mint& a) {
    return x > a.x;
  }
  bool operator<=(const mint& a) {
    return x <= a.x;
  }
  bool operator>=(const mint& a) {
    return x >= a.x;
  }
  bool operator==(const mint& a) {
    return x == a.x;
  }
  bool operator!=(const mint& a) {
    return x != a.x;
  }
};
ostream& operator<<(ostream& os, const mint& r) {
  os << r.x;
  return os;
}
ostream& operator>>(ostream& os, const mint& r) {
  os >> r.x;
  return os;
}

ll modpow(ll a, ll n) {
  ll res = 1;
  while(n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  mint ans = 0;
  REP(i, 60) {
    ll x = 0;
    REP(j, n) if (a[j] >> i & 1) x++;
    mint now = x * (n - x);
    REP(j, i) now *= 2;
    ans += now;
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


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


void solve(std::string S){
  int ans = 0;
  if (S == "SUN") 
    ans = 7;
  else if (S == "MON")
    ans = 6;
  else if (S == "TUE")
    ans = 5;
  else if (S == "WED")
    ans = 4;
  else if (S == "THU")
    ans = 3;
  else if (S == "FRI")
    ans = 2;
  else if (S == "SAT")
    ans = 1;

  std::cout << ans << std::endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

long long calc_combination(const long long &N, const long long &R) {
  if (R > N) return 0;
  long long  ans = 1;
  for (long long i=0; i<R; i++) ans *= N-i;
  for (long long i=0; i<R; i++) ans /= R-i;
  return ans;
}

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

  vector<long long> A(N);
  unordered_map<long long, long long> M;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    M[A[i]]++;
  }
  
  long long all_count = 0;
  for (auto a = M.begin(); a != M.end(); a++) {
    all_count += calc_combination(a->second, 2);
  }
  
  for (long long k = 0; k < N; k++) {
    long long k_count = M[A[k]]-1;
    cout << all_count - k_count << endl;
  }
  
  return 0;
}

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

int main()
{
	int H, W, N;
	cin >> H >> W >> N;
	vector<pair<int, int>> xys;
	for (int i = 0; i < N; i++) {
		int X, Y;
		cin >> X >> Y; --X, --Y;
		if (X > 0) xys.emplace_back(X, Y);
	}
	sort(xys.begin(), xys.end());
	int res = H;
	set<int> st;
	int ma = 1;
	for (int i = 1, j = 0; i < H; i++) {
		bool flag = true, end = false;
		set<int> tmp;
		while (j < N && xys[j].first == i) {
			int y = xys[j].second;
			if (y == ma) {
				flag = false;
			}
			else if (y < ma) {
				if (!st.count(y)) {
					res = i;
					end = true;
					break;
				}
				else {
					tmp.insert(y);
				}
			}
			++j;
		}
		if (end) break;
		st.swap(tmp);
		ma += flag;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <map>
#include <queue>

using namespace std;
const int N = 3;
const int N2 = 9;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
const char dir[4] = {'u','l','d','r'};


typedef struct Puzzle {
	int M[N2]; //状态 
	int space; //空格位置 
	string path; //记录空格的移动路径 
	
	bool operator<(const Puzzle & p) const {
		for (int i=0;i<N2;i++) {
			if (M[i] == p.M[i]) continue;
			return M[i] > p.M[i]; //为了让后面生成的状态靠前 
		}
		return false;
	}
	
} Puzzle;

bool isTarget(Puzzle & p) {
	for (int i=0;i<N2-1;i++) {
		if (p.M[i] != i+1) return false;
	}
	return true;
}

string bfs(Puzzle p) { //广度优先搜索 
	queue<Puzzle> Q;
	map<Puzzle,bool> V;
	Puzzle u,v;
	p.path = "";
	Q.push(p);
	V[p] = true;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		if (isTarget(u)) {
			return u.path;
		}
		int sx = u.space / N;
		int sy = u.space % N;
		//搜索四个方向 
		for (int r=0;r<4;r++) {
			int tx = sx + dx[r];
			int ty = sy + dy[r];
			if (tx < 0 || ty < 0 || tx >= N || ty >= N) continue; //不存在的情况
			int tspace = tx * N + ty; //新的空格位置
			v = u;//拷贝一份
			v.space = tspace; //改变数据
			swap(v.M[u.space],v.M[v.space]);
			//检查新生成的状态是否已经存在 
			if (!V[v]) {
				V[v] = true;
				v.path += dir[r];
				Q.push(v);
			}
		}
	}
	return "unsolvable";
}

int main() {
	Puzzle in;
	for (int i=0;i<N2;i++) {
		cin >> in.M[i];
		if (in.M[i] == 0) {
			in.space = i;
		}
	}
	string ans = bfs(in);
	cout << ans.size() << endl; 
 	return 0;
}


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

int main()
{
	int H,W;
	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int i = 0; i < W; i++)cout << "#";//一番上の横のプログラム
		cout << "\n";

		for (int i = 1; i < H - 1; i++) {	//真ん中のプログラム
			cout << "#";
			for (int j = 1; j < W - 1; j++)cout << ".";
			cout << "#";
			cout << "\n";
		}

		if (H > 1) {						//一番下のプログラム
			for (int i = 0; i < W; i++)cout << "#";
			cout << "\n";
		}
		cout << "\n";
		
	}
}


Measured memory_bytes: 3080
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt, wa_cnt_ls = 0, [ 0 for i in range(N) ]
for i in range(M):
    p, s = input().split(' ')
    idx = int(p) - 1
    if not idx in ac_set:
        if s == 'AC':
            ac_set.add(idx)
            wa_cnt += wa_cnt_ls[idx]
        else:
            wa_cnt_ls[idx] += 1
print(len(ac_set), wa_cnt)

Measured memory_bytes: 18060
#include<bits/stdc++.h>
using namespace std;
int main(){
    char a,b;
    cin >> a >> b;
    if(a=='H' && b=='H') cout << 'H' << endl;
    if(a=='H' && b=='D') cout << 'D' << endl;
    if(a=='D' && b=='H') cout << 'D' << endl;
    if(a=='D' && b=='D') cout << 'H' << endl;
    return 0;
}




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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
#define add(a, b) ((a % MOD) + (b % MOD)) % MOD;
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int h, w, k;
ll dp[111][11];
const ll MOD = 1000000000 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  if (stream2 == NULL) return 0;
#endif
  cin >> h >> w >> k;
  dp[0][0] = 1;
  k--;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < (1<<(w - 1)); j++) {
      bool pre = 0;
      bool ok = 1;
      if (w == 1) {
        dp[i + 1][0] += dp[i][0];
        continue;
      }
      for (int k = 0; k < w - 1; k++) {
        if (pre && j&(1<<k)) {
          ok = 0;
          break;
        }
        pre = j&(1<<k);
      }
      if (!ok) continue;
      //cout << bitset<7>(j) << endl;
      for (int k = 0; k < w; k++) {
        if (j&(1<<k)) {
          dp[i + 1][k + 1] = add(dp[i + 1][k + 1], dp[i][k]);
        } else if (k != 0 && j&(1<<(k - 1))) {
          dp[i + 1][k - 1] = add(dp[i + 1][k - 1], dp[i][k]);
        } else {
          dp[i + 1][k] = add(dp[i + 1][k], dp[i][k]);
        }
      }
    }
  }
  // for (int i = 0; i <= h; i++) {
  //   for (int j = 0; j < w; j++) {
  //     cout << "(" << i << "," << j << ") " << dp[i][j] << endl;
  //   }
  // }
  cout << dp[h][k] << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  fclose(stream2);
#endif
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <algorithm>
#include <functional>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;
static const int INF = 1e9;
int cnt = 0;

void merge(vector<int>& A, int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> L(n1 + 1);
	vector<int> R(n2 + 1);
	for (int i = 0; i < n1; ++i)
	{
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; ++i)
	{
		R[i] = A[mid + i];
	}
	L[n1] = INF;
	R[n2] = INF;
	int i = 0;
	int j = 0;
	for (int k = left; k < right; ++k)
	{
		++cnt;
		if (L[i] <= R[j])
		{
			A[k] = L[i];
			++i;
		}
		else
		{
			A[k] = R[j];
			++j;
		}
	}
}

void mergeSort(vector<int>& A, int left, int right)
{
	if (left + 1 < right)
	{
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

void solve()
{
	int n;
	cin >> n;
	vector<int> A(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> A[i];
	}
	mergeSort(A, 0, n);
	for (int i = 0; i < n - 1; ++i)
	{
		cout << A[i] << " ";
	}
	cout << A[n - 1] << endl;
	cout << cnt << endl;
}

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

Measured memory_bytes: 5064
//BISMILLAH
#include <bits/stdc++.h>
using namespace std;
map <int,int> mm;
map <int,int> tt;
int main(){
    
    int i,j,n,val1 = -1,val2 = -1,mx = -1,mx2 = -1,tal1 = -1,tal2 = -1,mx3 = -1,mx4 = -1,p;
    
    cin >> n;
    
    int a[n];
    for(i = 0;i<n;i++) {
        cin >> a[i];
        if(i%2 == 0){
            mm[a[i]]++;
            if(mm[a[i]] >= mx){
                mx = mm[a[i]];
                val1 = a[i];
            }
        }else{
            tt[a[i]]++;
            if(tt[a[i]] >= mx2){
                mx2 = tt[a[i]];
                val2 = a[i];
            }
        }
    }
       p = n/2;
       if(val1 != val2){
           cout << (p - mx) + (p - mx2) << endl;
       }else{
           mm.clear();
           tt.clear();
           for(i = 0;i<n;i++) {
        if(i%2 == 0){
            mm[a[i]]++;
            if(a[i] != val1 && mm[a[i]] >= mx3){
                mx3 = mm[a[i]];
                tal1 = a[i];
            }
        }else{
            tt[a[i]]++;
            if(a[i] != val2 && tt[a[i]] >= mx4){
                mx4 = tt[a[i]];
                tal2 = a[i];
            }
        }
    }    
             if(mx3 != -1 && mx4 != -1){
                 cout << min({(p - mx) + (p - mx4),(p - mx3) + (p - mx2),(p - mx3) + (p - mx4)}) << endl;
             }else if(mx3 != -1 && mx4 == -1){
                 cout << (p - mx3) + (p - mx2) << endl;
             }else if(mx3 == -1 && mx4 != -1){
                 cout << (p - mx) + (p - mx4) << endl;
             }else cout << p << endl;
       }
    return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 10000 + 3;

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

  vector<vector<int>> e(n);
  for(int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    --a; --b;
    e[a].push_back(b);
    e[b].push_back(a);
  }

  vector<int> c(n, 0);
  for(int i = 0; i < n; ++i) scanf("%d", &c[i]);
  sort(c.begin(), c.end());

  vector<int> deg(n, 0);
  queue<int> q;
  for(int i = 0; i < n; ++i) {
    deg[i] = e[i].size();
    if(deg[i] == 1) q.push(i);
  }

  ll sum = 0;
  vector<int> ans(n, 0);
  for(int i = 0; i < n; ++i) {
    int qf = q.front(); q.pop();
    ans[qf] = c[i];
    if(i + 1 < n) sum += c[i];
    for(int x: e[qf]) {
      --deg[x];
      if(deg[x] == 1) q.push(x);
    }
  }

  printf("%lld\n", sum);
  for(int i = 0; i < n; ++i) {
    if(i > 0) printf(" ");
    printf("%d", ans[i]);
  }
  printf("\n");
  return 0;
}


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

int main(void) {
	int X, Y;
	cin >> X >> Y;

	bool f_ans = false;
	for (int kame = 0; kame <= Y / 4; ++kame) {	// 亀の数の最大は Y/4
		int turu = X - kame;
		int sum = 2 * turu + 4 * kame;
		if (sum == Y) {
			f_ans = true;
			break;
		}
	}

	cout << (f_ans ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 3628
t=list(input())
n=len(t)
for i in range(n):
  if t[i]=='D':
    continue
  elif t[i]=='P':
    if i<n-1:
      if t[i+1]=='D':
        continue
      elif t[i+1]=='?':
        t[i+1]='D'
  else:
    if 0<i:
      if t[i-1]=='P':
        t[i]='D'
    if i<n-1 and t[i]=='?':
      if t[i+1]=='P':
        t[i]='D'
      elif t[i+1]=='?':
        t[i]='P'
      else:
        t[i]='P'
    else:
      t[i]='D'
print(''.join(t))

Measured memory_bytes: 10880
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

struct union_find {
    vector<int> parent;
    vector<int> size;
    vector<long long> weight_sum;
    int components = 0;

    union_find(int n = -1) {
        if (n >= 0)
            init(n);
    }

    void init(int n) {
        parent.resize(n + 1);
        size.assign(n + 1, 1);
        components = n;

        for (int i = 0; i <= n; i++)
            parent[i] = i;
    }

    int find(int x) {
        return x == parent[x] ? x : parent[x] = find(parent[x]);
    }

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);

        if (x == y)
            return false;

        if (size[x] < size[y])
            swap(x, y);

        parent[y] = x;
        size[x] += size[y];
        weight_sum[x] += weight_sum[y];
        components--;
        return true;
    }
};


struct edge {
    int A, B, Y;
    bool heaviest_ok = false;
    bool keep = false;

    bool operator<(const edge &other) const {
        return Y < other.Y;
    }
};

struct adj_edge {
    int node, weight, index;
    bool keep = false;
};

int N, M;
vector<int> X;
vector<edge> edges;
vector<vector<adj_edge>> adj;

void dfs(int node, int maximum) {
    for (adj_edge &e : adj[node])
        if (e.weight <= maximum && !e.keep) {
            e.keep = true;
            edges[e.index].keep = true;
            dfs(e.node, maximum);
        }
}

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

    cin >> N >> M;
    X.resize(N);

    for (int &x : X)
        cin >> x;

    edges.resize(M);

    for (edge &e : edges) {
        cin >> e.A >> e.B >> e.Y;
        e.A--; e.B--;
    }

    sort(edges.begin(), edges.end());
    union_find UF(N);
    UF.weight_sum = vector<long long>(X.begin(), X.end());

    for (edge &e : edges) {
        UF.unite(e.A, e.B);
        e.heaviest_ok = e.Y <= UF.weight_sum[UF.find(e.A)];
    }

    reverse(edges.begin(), edges.end());
    adj.assign(N, {});

    for (int i = 0; i < (int) edges.size(); i++) {
        edge &e = edges[i];
        adj[e.A].push_back({e.B, e.Y, i});
        adj[e.B].push_back({e.A, e.Y, i});
    }

    int remove = 0;

    for (edge &e : edges) {
        if (!e.keep && e.heaviest_ok)
            dfs(e.A, e.Y);

        if (!e.keep)
            remove++;
    }

    cout << remove << '\n';
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n); for(long long i = 0;i < (n);i++)
typedef long long ll;
typedef vector<long long> vl;
const ll mod = 1000000007;

int main(){
	ll n; cin >> n;
	if(n%2 == 0)cout << n/2 << endl;
	else cout << n/2 + 1 << 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;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define mem(a,b) memset(a,b,sizeof(a))
#define shutdown ios::sync_with_stdio(false)
#define MAX 10e18+1000
#define INF 0x3f3f3f3f
#define FOR(x,k) for(int x=1;x<=k;x++)

const int mm=1000100;
int math[mm];

int main() {
    shutdown;
    int n,k;
    cin>>n>>k;
    int temp=1;
    int sum=1;
    while(n>0&&temp<k){
        sum*=2;
        temp=sum;
        n--;
    }
    for(int i=1;i<=n;i++)
        sum+=k;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef long long ll;

const int MAX_SIZE = 10000;

struct edge{
	int to;
	int cost;
	int enemy;
};

class Situation{
public:
	int cost;
	int node;
	int money;

	Situation(int cost_,int node_,int money_){
		cost=cost_;
		node=node_;
		money=money_;
	}
	Situation();

	bool operator<(const Situation &s)const{
		return s.cost < this->cost;
	}
};

int V;

const int MAX_V = 101;

vector<edge> G[MAX_V][MAX_V];
//  éêÉ écèàzÅ½Çè­Å¬RXg
int d[MAX_V][MAX_V];
const int INF = 100000000;

//int prevv[MAX_V];
int L;
int N;
int M;

void dijkstra(int s){
	priority_queue<Situation> que;
	for(int i = 0; i < MAX_V; i++)
		fill(d[i],d[i]+MAX_V,INF);
	d[s][L] = 0;
	que.push(Situation(0,s,L));
	while(!que.empty()){
		Situation p = que.top();
		que.pop();
		int node = p.node;
		int money=p.money;
		if(d[node][money] < p.cost)
			continue;
		for(int i = 0; i < G[node][money].size(); i++){
			edge e = G[node][money][i];
			// ¨àðgÁÄìµÄàç¤ê
			if(money-e.cost>=0){
				if(d[e.to][money-e.cost] > d[node][money]){
					d[e.to][money-e.cost] = d[node][money];
					que.push(Situation(d[e.to][money-e.cost],e.to,money-e.cost));
				}
			}
			// ìÈµÌê
			if(d[e.to][money]>d[node][money]+e.enemy){
				d[e.to][money]=d[node][money]+e.enemy;
				que.push(Situation(d[e.to][money],e.to,money));
			}
		}
	}
}

int main(){

	while(cin>>N>>M>>L&&!(N==0&&M==0&&L==0)){
		for(int i = 0; i < MAX_V; i++)
			for(int j = 0; j < MAX_V; j++)
				G[i][j].clear();
		int from,to,cost,enemy;
		for(int i = 0; i < M; i++){
			cin>>from>>to>>cost>>enemy;
			from--;
			to--;
			edge e;
			e.cost=cost;
			e.to=to;
			e.enemy=enemy;
			
			for(int i = 0; i < MAX_V; i++)
				G[from][i].push_back(e);
			e.to=from;
			for(int i = 0; i < MAX_V; i++)
				G[to][i].push_back(e);
		}
		dijkstra(0);
		int minCost=INF;
		for(int i = 0; i < MAX_V; i++)
			minCost=min(minCost,d[N-1][i]);
		cout<<minCost<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define MN 100000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
pair<int,int> s[MN+5],S[MN+5];
int n,pos;long long ans1=0,ans2=0;
int Calc(pair<int,int> s,int&p)
{
    int P=p;
    if(p>=s.first&&p<=s.second) return 0;
    else if(p>s.second) return p=s.second,P-s.second;
    else return p=s.first,s.first-P;
}
bool cmp(pair<int,int> a,pair<int,int> b){return a.second<b.second;}
int main()
{
    n=read();
    for(int i=1;i<=n;++i) s[i].first=read(),s[i].second=read(),S[i]=s[i];
    sort(s+1,s+n+1,greater<pair<int,int> >());
    sort(S+1,S+n+1,cmp);
    for(int i=1;i<=n;++i)
    {
        if(i>1&&S[i].second>=s[i-1].first) break;
        ans1+=Calc(S[i],pos);
        if(S[i].second>=s[i].first) break;
        ans1+=Calc(s[i],pos);
    }
    ans1+=max(pos,-pos);pos=0;
    for(int i=1;i<=n;++i)
    {
        if(i>1&&s[i].first<=S[i-1].second) break;
        ans2+=Calc(s[i],pos);
        if(S[i].second>=s[i].first) break;
        ans2+=Calc(S[i],pos);
    }
    ans2+=max(pos,-pos);
    cout<<max(ans1,ans2);
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

ll n, t[1000], a[1000];
ll ta, aa;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i] >> a[i];
	}

	ta = t[0], aa = a[0];
	for (int i = 1; i < n; i++) {
		ll b1 = ta, b2 = ta, c1 = aa, c2 = aa;

		if (ta%t[i] != 0)b1 = (ta / t[i] + 1) * t[i];
		c1 = b1 / t[i] * a[i];

		if (aa%a[i] != 0)c2 = (aa / a[i] + 1) * a[i];
		b2 = c2 / a[i] * t[i]; 

		ta = (b1 + c1 > b2 + c2)?b1:b2;
		aa = (b1 + c1 > b2 + c2)?c1:c2;

		/*ll x = ta / t[i] + ((ta%t[i]) ? 1 : 0);
		ll y = aa / a[i] + ((aa%a[i]) ? 1 : 0);
		ta = max(x, y)*t[i];
		aa = max(x, y)*a[i];*/
	}

	cout << ta + aa << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	long long n;
	cin >> n;
	
	char ab[26];
	iota(ab, ab + 26, 'a');
	int len{1};
	long long z{}, l{26};
	while (z + l < n) {
		z += l;
		len++;
		l *= 26;
	}
	
	long long k = n - z - 1;
//	cout << k << " " << len << endl;
	char ans[len];
	for (int i = len - 1; i >= 0; i--) {
		ans[i] = ab[k%26];
		k /= 26;
	}
	for (int i = 0; i < len; i++) cout << ans[i];
}

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

constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  int n;
  cin >> n;
  cout << n * n * 3 << endl;
}

int main(int argc, char *argv[]){

  /* Regular */
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }
  
  // /* AOJ */
  // solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const ll INF = 1E+18;


int main(){
    int n;
    cin >> n;
    vector<ll> a(3*n);
    rep(i, 3*n) cin >> a[i];
    vector<ll> sum1(n+1);
    vector<ll> sum2(n+1);
    priority_queue<ll> q1;
    priority_queue<ll> q2;
    
    rep(i, n) {
        sum1[0] += a[i];
        q1.push(-a[i]);
        sum2[n] += a[i+2*n];
        q2.push(a[i+2*n]);
    }
    rep(i, n) {
        ll now = -q1.top();
        if (a[i+n]>now) {
            q1.pop();
            q1.push(-a[i+n]);
            sum1[i+1] = sum1[i] - now + a[i+n];
        }
        else sum1[i+1] = sum1[i];
    }
    rrep(i, n) {
        ll now = q2.top();
        if (a[i+n]<now) {
            q2.pop();
            q2.push(a[i+n]);
            sum2[i] = sum2[i+1] - now + a[i+n];
        }
        else sum2[i] = sum2[i+1];
    }
    ll ans = -INF;

    rep(i, n+1) {
        ll res = sum1[i] - sum2[i];
        chmax(ans, res); 
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8976