akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	public static void main(String[] args) {
		int n =sc.nextInt();
		int x =sc.nextInt();
		int y =sc.nextInt();
		int ans[]=new int[n+1];
		int max=0;
		int k1;
		int k2;
		for(int i=1;i!=n;i++) {
		for(int j=i+1;j<n+1;j++) {
			k1=j-i;
			k2=Math.abs(x-i)+1+Math.abs(y-j);
			if(k1>k2) {
				max=k2;
			}else if(k1<k2) {
				max=k1;
			}else if(k1==k2){
				max=k1;
			}
			ans[max]++;
			
		//p(ans);
		}
		}
		for(int i=1;i!=n;i++) {
			p(ans[i]);
		}
		
		
			
		
		
		
		
	}
}


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

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 1073741824
#define LINF 4611686018000000000
#define MOD 1000000007

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    if (s * t >= d) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


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

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  int k = __builtin_popcount(a ^ b);
  if (k % 2 == 0) {
    cout << "NO" << "\n";
    return 0;
  }
  cout << "YES" << "\n";
  vector<vector<int>> to_one(n + 1);
  to_one[0] = {0};
  to_one[1] = {0, 1};
  for (int i = 2; i <= n; ++i) {
    for (auto x : to_one[i - 1]) {
      to_one[i].push_back(x << 1);
    }
    reverse(to_one[i - 1].begin(), to_one[i - 1].end());
    for (auto x : to_one[i - 1]) {
      to_one[i].push_back(x << 1 | 1);
    }
    reverse(to_one[i - 1].begin(), to_one[i - 1].end());
  }
  vector<vector<int>> to_all(k + 1);
  to_all[1] = {0, 1};
  for (int i = 3; i <= k; i += 2) {
    for (auto x : to_all[i - 2]) {
      to_all[i].push_back(x);
    }
    for (auto x : to_one[i - 2]) {
      to_all[i].push_back(x ^ ((1 << (i - 1)) - 1));
    }
    for (auto x : to_one[i - 1]) {
      to_all[i].push_back(x ^ ((1 << i) - 2));
    }
  }
  vector<int> ans;
  for (auto x : to_all[k]) {
    for (auto y : to_one[n - k]) {
      ans.push_back(y << k | x);
    }
    reverse(to_one[n - k].begin(), to_one[n - k].end());
  }
  vector<int> to_bit(n);
  int ptr = 0;
  for (int i = 0; i < n; ++i) {
    if ((a ^ b) >> i & 1) {
      to_bit[ptr++] = i;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (!((a ^ b) >> i & 1)) {
      to_bit[ptr++] = i;
    }
  }
  for (int i = 0; i < 1 << n; ++i) {
    int real_ans = 0;
    for (int j = 0; j < n; ++j) {
      if (ans[i] >> j & 1) {
        real_ans |= 1 << to_bit[j];
      }
    }
    ans[i] = real_ans;
  }
  for (int i = 0; i < 1 << n; ++i) {
    if (i) {
      cout << " ";
    }
    cout << (ans[i] ^ a);
  }
  cout << "\n";
  return 0;
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int func(long long N) {
    // cout << fixed << setprecision(8);

    int ans;
    ans = pow(N, 3);
    cout << ans << endl;

    return 0;
}

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

    long long N;
    scanf("%lld", &N);

    func(N);

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;
int n;
vector<long long> a;
vector<long long> b;
long long res = 0;

int main() {
	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	long long c = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] != 0)
			c += a[i];
		else {
			b.push_back(c);
			c = 0;
		}
	}
	if (c > 0)
		b.push_back(c);
	for (int i = 0; i < b.size(); i++) {
		res += b[i] / 2;
	}

	cout << res << endl;
	//cin >> n;
	return 0;
}

Measured memory_bytes: 2168
///not today

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

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair< int, pair<int, int> >
#define plpll pair< ll, pair<ll, ll> >

using namespace std;

int32_t main(){
      int x;
      cin >>x;
      cout <<x* x* 3;
      return false;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	double x1,y1,x2,y2,x3,y3,x4,y4;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
		if(x1 == x2 && x3 == x4){
			cout<<"YES"<<endl;
		}else if(y1 == y2 && y3 == y4){
			cout<<"YES"<<endl;
		}else{
			double m = (y2-y1)/(x2-x1);
			double n = (y4-y3)/(x4-x3);
			if(m==n){
				cout<<"YES"<<endl;
			}else if(m != n){
				cout<<"NO"<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1228
#include <iostream>

void printArray(int array[], int array_size) {
	std::cout << array[0];
	for (int i = 1; i < array_size; i++) {
		std::cout << " " << array[i];
	}
	std::cout << "\n";
}

int main()
{
	int a, b, c;
	std::cin >> a;
	std::cin >> b;
	std::cin >> c;
	int array[] = { a, b, c };

	if (array[0] > array[2])
		std::swap(array[0], array[2]);
	if (array[1] > array[2])
		std::swap(array[1], array[2]);
	if (array[0] > array[1])
		std::swap(array[0], array[1]);

	printArray(array, sizeof(array) / sizeof(int));
    return 0;
}




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

int main() 
{ 
    ll n, m, sum = 0;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        ll num;
        cin >> num;
        sum += num;
    }
    if(sum > n) {
        cout << -1 << "\n";
    } else {
        cout << n - sum << "\n";
    }
    return 0; 
} 

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

int N, ans = 0;
ll A[200000];
bool B[200000] = {false};

int main() {
    scanf("%d", &N);
    REP(i, N) scanf("%d", A+i);
    sort(A, A+N);
    for(int i=N-1; i>=0; i--) {
        int p = 0;
        while(A[i] >= 1LL<<p) p++; 
        ll x = (1LL<<p) - A[i];
        int j = lower_bound(A, A+N, x) - A;
        if(B[i]) continue;
        while(j < i && A[j] == x) {
            if(!B[j]) {
                B[i] = true;
                B[j] = true;
                A[j]--;
                ans++;
                break;
            }
            j++;
        }
    }
    printf("%d", ans);
	return 0;
}

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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    while (a >= b) {
        b *= 2;
        k--;
    }
    while (b >= c) {
        c *= 2;
        k--;
    }

    if (k >= 0)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;

    return 0;
}

Measured memory_bytes: 3600
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def cmb(n, r):
    p = 1
    c = 1
    for i in range(r):
        p *= (n - i)
        c *= (i + 1)
    return p // c


def main():
    N = I()
    A = LI()
    a = Counter(A)
    c = 0
    org = {}
    one = {}
    org_tital = 0
    for k, v in a.items():
        org[k] = cmb(v, 2)
        one[k] = cmb(v-1, 2)
        org_tital += org[k]

    # print(org, one, org_tital)

    for i in range(N):
        diff = org[A[i]] - one[A[i]]
        print(org_tital - diff)
    # print()


if __name__ == '__main__':
    main()


Measured memory_bytes: 108364
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Beginner
 */

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

/* constant */

const int MAX_N = 100;

const int INF = 1 << 30;
const long long LINF = 1LL << 60;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

/* subroutines */

/* main */

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

  printf("%d\n", r + ((n < 10) ? (10 - n) * 100 : 0));
  return 0;
}


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

vector<int> take_primes(int n) {
  vector<bool> is_prime(n+1, true);
  vector<int> primes;
  is_prime[0] = is_prime[1] = false;
  for(int i=2;i<=n;i++) {
    if(is_prime[i]) {
      primes.push_back(i);
      for(int j= i*2;j<=n;j+=i) {
	is_prime[j] = false;
      }
    }
  }
  return primes;
}

vector<ll> solve(int n) {
  vector<int> primes = take_primes(55555);
  vector<ll> res;
  for(auto p: primes) {
    if(p % 5 == 1) {
      res.push_back(p);
    }
    if((int) res.size() == n) {
      break;
    }
  }
  return res;
}

int main() {

  int n;
  cin >> n;
  auto res = solve(n);
  int len = res.size();
  for(int i=0;i<len;i++) {
    cout << res[i];
    if(i != len-1) 
      cout << " "; 
  }
}

Measured memory_bytes: 3620
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();
		String s = sc.next();
		if (s.matches("[0-9]{" + a + "}-[0-9]{" + b + "}")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21716
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define pb(x) push_back(x)
#define int long long

vector<int> A(3);

signed main(void){
	cin >> A[0] >> A[1] >> A[2];
	SORT(A);
	cout << abs(A[0]-A[1]) + abs(A[1]-A[2]) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i, n) ans += a[i]-1;
    cout << ans << endl;
}

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

int main(){
  int n,h[200],m[200];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>h[i]>>m[i];
  }
  int k;
  cin>>k;
  int NK = n+k;
  for(int i=n;i<NK;i++){
    cin>>h[i]>>m[i];
  }
  vector<int> N(n+k);
  for(int i=0;i<NK;i++){
    N[i]=h[i]*60+m[i];
  }
  sort(N.begin(),N.end());
  int H,M;
  for(int i=0;i<NK;i++){
    H=N[i]/60;
    M=N[i]%60;
    if(N[i+1]==N[i]){
      continue;
    }
    if(i==NK-2 && N[i+2]==N[i+1]){
      if(M<10){
        cout<<H<<":"<<0<<M<<endl;
      }
      else{
        cout<<H<<":"<<M<<endl;
      }
      break;
    }
    if(i==NK-1){
      if(M<10){
        cout<<H<<":"<<0<<M<<endl;
      }
      else{
        cout<<H<<":"<<M<<endl;
      }
      break;
    }
    if(M<10){
      cout<<H<<":"<<0<<M<<" ";
    }
    else{
      cout<<H<<":"<<M<<" ";
    }
  }
}


Measured memory_bytes: 3176
package main

import (
	"fmt"
	"math"
)

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func main() {
	var n, d, ans int
	fmt.Scan(&n, &d)
	x := make([][]int, n)
	for i := range x {
		x[i] = make([]int, d)
	}
	for i := 0; i < n; i++ {
		for j := 0; j < d; j++ {
			fmt.Scan(&x[i][j])
		}
	}
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			dist := 0
			for k := 0; k < d; k++ {
				dist += abs(x[i][k]-x[j][k]) * abs(x[i][k]-x[j][k])
			}
			if int(math.Ceil(math.Sqrt(float64(dist)))) == int(math.Sqrt(float64(dist))) {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.*;
public class Main{
	public static void cross_cl(Circle c, Line l){
		if(l.x1 == l.x2){
			double ans1 = (double)c.y - Math.sqrt(Math.pow((double)c.r,2)-Math.pow((double)(l.x1-c.x),2));
			double ans2 = (double)c.y + Math.sqrt(Math.pow((double)c.r,2)-Math.pow((double)(l.x1-c.x),2));
			System.out.printf("%.8f %.8f %.8f %.8f\n",(double)l.x1,ans1,(double)l.x1,ans2);
		}
		else if(l.y1 == l.y2){
			double ans1 = (double)c.x - Math.sqrt(Math.pow((double)c.r,2)-Math.pow((double)(l.y1-c.y),2));
			double ans2 = (double)c.x + Math.sqrt(Math.pow((double)c.r,2)-Math.pow((double)(l.y1-c.y),2));
			System.out.printf("%.8f %.8f %.8f %.8f\n",ans1,(double)l.y1,ans2,(double)l.y1);
		}
		else{
			double a = (double)(l.y2 - l.y1) / (l.x2 - l.x1);
			double ans1 = 1.0 + Math.pow(a,2);
			double ans2 = (double)c.x + a * a * l.x1 + a * c.y - a * l.y1;
			double ans3 = (double)(c.x * c.x) + Math.pow(a* l.x1 + (double)(c.y - l.y1),2) - (double)(c.r * c.r);
			double ansx1 = (ans2 - Math.sqrt(Math.pow(ans2,2)- ans1 * ans3))/ans1;
			double ansx2 = (ans2 + Math.sqrt(Math.pow(ans2,2)- ans1 * ans3))/ans1;
			double ansy1 = (ansx1 - (double)l.x1) * a + (double)l.y1;
			double ansy2 = (ansx2 - (double)l.x1) * a + (double)l.y1;
			System.out.printf("%.8f %.8f %.8f %.8f\n",ansx1,ansy1,ansx2,ansy2);
		}
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Circle c = new Circle(sc.nextLong(),sc.nextLong(),sc.nextLong());
		int q = sc.nextInt();
		for(int i = 0 ; i < q ; i++){
			Line l = new Line(sc.nextLong(),sc.nextLong(),sc.nextLong(),sc.nextLong());
			cross_cl(c,l);
		}
	}
}
class Circle{
	long x;
	long y;
	long r;
	Circle(long x, long y, long r){
		this.x = x;
		this.y = y;
		this.r = r;
	}
}
class Line{
	long x1;
	long y1;
	long x2;
	long y2;
	Line(long x1, long y1, long x2, long y2){
		this.x1 = x1;
		this.y1 = y1;
		this.x2 = x2;
		this.y2 = y2;
	}
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

  rep(i, s.size()) {
    char c = s[i];
    int index = c - 'A';
    s[i] = 'A' + ((index + n) % 26);
  }
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define ld          double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        200005
#define LOG         20
#define mod         1000000007
using namespace std;
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s1,s2;
    cin>>s1>>s2;
    cout<<s2<<s1;
}

Measured memory_bytes: 256
import sys

n, k = map(int, sys.stdin.readline().strip().split())
a = map(int, sys.stdin.readline().strip().split())

def main(n, k, a):
    nega = []
    posi = []
    zeros = 0

    for ai in a:
        if ai < 0:
            nega.append(ai)
        elif ai > 0:
            posi.append(ai)
        else:
            zeros += 1

    posi.sort()
    nega.sort(reverse=True)

    ng = - (10 ** 18)-1
    ok = 10 ** 18 + 1

    while ok - ng > 1:
        mid = (ok + ng) // 2
        cnt = 0

        if mid >= 0:
            cnt += zeros * (zeros - 1) // 2 + zeros * (n - zeros)

        if mid > 0:
            cnt += len(nega) * len(posi)
            for a in (posi, nega):
                l = 0
                r = len(a)-1
                while l < r:
                    while l < r and a[l] * a[r] > mid:
                        r -= 1
                    cnt += r - l
                    l += 1
        else:
            r = len(nega) - 1
            for l in range(len(posi)):
                while r >= 0 and posi[l] * nega[r] <= mid:
                    r -= 1
                cnt += len(nega) - r - 1

        if cnt >= k:
            ok = mid
        else:
            ng = mid
    print(ok)


main(n, k, a)

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

int main() {
  string a,b;
  cin>>a>>b;
  
  for(int i=0;i<b.size();i++){
    cout<<a.at(i)<<b.at(i);
  }
  if(a.size()==b.size()){
    cout<<endl;
  }
  if(a.size()!=b.size()){
    cout<<a.at(a.size()-1)<<endl;
  } 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ms(a,b) memset(a,b,sizeof(a))
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int maxn=1e6+10;
const int mod=1e9+7;
const int maxm=1e3+10;
using namespace std;
string s;
int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    map<string,int>mp;
    for(int i=0;i<n;i++)
    {
    	cin>>s;
    	sort(s.begin(),s.end());
        mp[s]++;
    }
    ll ans=0;
    for(auto i:mp)
    {
        ll res=i.second;
        ans+=(res*(res-1)/2);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int main() {
    string str;
    cin >> str;    

    vector<int> vec;
    char cur='R';
    int cnt=0;
    for(int i=0; i<str.size(); i++) {
        if(cur==str[i]) {
            // cout << str << endl;
            cnt++;
        } else {
            vec.push_back(cnt);
            cnt = 1;
            cur = str[i];
        }
        if(str[i]=='L') {
            if(str[i-1]!='R') str[i]='0';
        } else {
            if(str[i+1]!='L') str[i]='0';
        }
    }
    vec.push_back(cnt);
    // for(int i=0; i<vec.size(); i++) {
    //     cout << vec[i];
    // }
    // cout << endl;
    // cout << str << endl;
    
    cnt=0;
    for(int i=0; i<str.size(); i++) {
        if(str[i]=='0') {
            cout << str[i];
        } else if(str[i]=='R') {
            if((vec[cnt]+vec[cnt+1])%2==0) {
                cout << (vec[cnt]+vec[cnt+1])/2;
            } else {
                if(vec[cnt]%2) {
                    cout << (vec[cnt]+vec[cnt+1]+1)/2;
                } else {
                    cout << (vec[cnt]+vec[cnt+1])/2;
                }
            }
            cnt++;
        } else {
            if((vec[cnt]+vec[cnt-1])%2==0) {
                cout << (vec[cnt]+vec[cnt-1])/2;
            } else {
                if(vec[cnt]%2) {
                    cout << (vec[cnt]+vec[cnt-1]+1)/2;
                } else {
                    cout << (vec[cnt]+vec[cnt-1])/2;
                }
            }
            cnt++;
        }
        cout << " ";
    }
    cout << endl;


    return 0;
    
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  cout << ((A+B+C)>21 ? "bust" : "win") << '\n';
  return 0;
}

Measured memory_bytes: 3588
a,b = map(int, input().split())

if a ==1:
    if b == 1:
        print(1)
        exit()
    else:
        print(b-2)
        exit()

elif a==2:
    print(0)
    exit()

else:
    if b ==1:
        print(a-2)
        exit()
    elif b==2:
        print(0)
        exit()
    else:
        print((a-2)*(b-2))
        exit()

Measured memory_bytes: 9180
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	string s;
	cin >> s;
	int pre = -1;
	for (int i = 0; i < 4; ++i) {
		int c = ctoi(s[i]);
		if (c == pre) {
			PRI("Bad");
			return 0;
		}
		else {
			pre = c;
		}
	}
	PRI("Good");
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     is(a)               to_string(a)
#define     ci(a,c)             a-c
#define     debug(i)            cout<<"point :"<<i<<'\n';
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'


void solve(){
    int n,m;cin>>n>>m;
    cout<<(n>m?"No\n":"Yes\n");
}

signed main() { 
    IO();

    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define int long long
 
void solve()
{
   int n;  cin>>n;
   int cnt=0;
   int a[n][2];
   for(int i=0;i<n;i++)cin>>a[i][0]>>a[i][1];
   for(int i=2;i<n;i++)
   {
       if(a[i-2][0]==a[i-2][1]&&a[i-1][0]==a[i-1][1]&&a[i][0]==a[i][1])
       {
           cout<<"Yes"<<endl;
           return ;
       }
   }
    cout<<"No"<<endl;
    return ;
}


 
 
 signed main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    
    
    
    int T; 
    T=1;
    //cin>>T;
    while(T--)
    {
          solve();
    }
    
    
        return 0;
	
}

Measured memory_bytes: 3616
def getval():
    n = int(input())
    h = [list(map(int,input().split())) for i in range(n)]
    return n,h

def main(n,h):
    dp = [[h[0][0],h[0][1],h[0][2]]]
    for i in range(1,n):
        cur = h[i]
        prev = dp[-1]
        temp = []
        temp.append(max(prev[1],prev[2])+cur[0])
        temp.append(max(prev[0],prev[2])+cur[1])
        temp.append(max(prev[0],prev[1])+cur[2])
        dp.append(temp)
    print(max(dp[-1]))
    
if __name__=="__main__":
    n,h = getval()
    main(n,h)


Measured memory_bytes: 96984
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int q;
    cin >> q;
    for(int loop = 0; loop < q; ++loop){
        string s, t;
        cin >> s >> t;
        int n1 = s.length(), n2 = t.length();
        vector<vector<int>> dp(n1 + 2, vector<int>(n2 + 2, 0));
        for(int i = 0; i <= n1; ++i){
            for(int j = 0; j <= n2; ++j){
                chmax(dp[i][j + 1], dp[i][j]);
                chmax(dp[i + 1][j], dp[i][j]);
                if(i < n1 && j < n2 && s[i] == t[j]){
                    chmax(dp[i + 1][j + 1], dp[i][j] + 1);
                }
            }
        }
        cout << dp[n1][n2] << '\n';
    }
}


Measured memory_bytes: 6908
function main(input) {
    const args = input.split('\n');
    const N = parseInt(args[0], 10);
    const L = args[1].split(' ').map(Number).sort(A)
  
    if(B(L,N)) console.log("Yes")
    else console.log("No")
}

var A = (a,b)=>{
  if( a > b ) return -1;
        if( a < b ) return 1;
        return 0;
}

var B = (l,n)=>{
	var M = l[0]
    var m = 0
    for(var i=1;i<n;i++){
    	m += l[i]
    }
  if(M>=m) return false
  else return true
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

int
main(void){
	int n; cin >> n;
	vector<int> vec(n);
	for(int i = 0; i < n; i++) cin >> vec[i];
	
	vec[0]--;
	for(int i = 1; i < n; i++){
		if(vec[i] > vec[i - 1]) vec[i]--;
	}
	
	for(int i = 1; i < n; i++){
		if(vec[i] < vec[i - 1]){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
	
}


Measured memory_bytes: 640
/**
*    author:  yuya1234
*    created: 10.07.2020 16:58:58
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  int n;
  cin>>n;

  vector<pair<int,int>> pairs(n);
  int tmp1,tmp2;
  REP(i,n)
  {
    cin>>tmp1>>tmp2;
    pairs[i]=make_pair(tmp2,tmp1);
  }

  SORT(pairs);

  ll sum=0;
  string ans="Yes";
  REP(i,n)
  {
    sum+=pairs[i].second;
    if(sum>pairs[i].first)ans="No";
  }

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

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

int k;

int main() {

	FAST;

	cin >> k;
	if (k % 7 == 0) {
		k /= 7;
	}
	if (__gcd(10, k) != 1) {
		cout << -1 << '\n';
		return 0;
	}
	// specific case
	if (k == 1) {
		cout << 1 << '\n';
		return 0;
	}
	int x = 0;
	for (int i = 1; i <= k; i ++) {
		x = (x * 10 + 1) % k;
		if (x == 0) {
			cout << i << '\n';
			return 0;
		}
	}
	return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int tim(string s){
  int h=(s[0]-'0')*10+(s[1]-'0');
  int m=(s[3]-'0')*10+(s[4]-'0');
  int ss=(s[6]-'0')*10+(s[7]-'0');
  return 3600*h+60*m+ss;
}

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) return 0;
    vector<int> count(86402,0);
    for(int i=0;i<n;i++){
      string s,t;
      cin >> s >> t;
      count[tim(s)]++;
      count[tim(t)]--;
    }
    int ma=count[0];
    for(int i=1;i<86402;i++){
      count[i]+=count[i-1];
      ma=max(ma,count[i]);
    }
    cout << ma << endl;
  }
  return 0;
}



Measured memory_bytes: 3568
import sys
n=int(input())
a=input().split()
b=[]
for i in range(n):
    b.append(a[i])
for i in range(n):
    sys.stdout.write("{0}".format(a[n-1-i]))
    if i==n-1:
        sys.stdout.write("\n")
    else:
        sys.stdout.write(" ")

Measured memory_bytes: 5616
// テ・ツ淞コテヲツ慊ャテ」ツδ?」ツδウテ」ツδ療」ツδャテ」ツδシテ」ツδ?

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

vector<pii> to[810];
int N;
int p[810], d[810], deg[810], rec[810];

void calc(int p, int par=-1) {
    for(auto x : to[p]) {
        if(x.first == par) continue;
        if(deg[x.first] == 1) continue;
        calc(x.first, p);
        chmax(rec[p], rec[x.first] + x.second);
    }
}

signed main() {
    while(cin >> N, N) {
        rep(i,0,810) to[i].clear();
        memset(deg, 0, sizeof(deg));

        int sum = 0;
        rep(i,0,N-1) cin >> p[i], p[i]--;
        rep(i,0,N-1) cin >> d[i], sum += d[i];
        rep(i,0,N-1) {
            to[p[i]].push_back(make_pair(i+1 , d[i]));
            to[i+1 ].push_back(make_pair(p[i], d[i]));
            deg[i+1]++; deg[p[i]]++;
        }

        int res = 0;
        rep(i,0,N) {
            for(auto x : to[i]) if(deg[i] != 1 && deg[x.first] != 1) res += x.second;
        }

        int ma = 0;
        rep(i,0,N) {
            memset(rec,0,sizeof(rec));
            if(deg[i] == 1) continue;
            calc(i);
            chmax(ma, rec[i]);
        }

        // printf("sum = %lld, res = %lld, ma = %lld\n", sum, res, ma);
        cout << sum + res - ma << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]


def func(x):
    attack = 0
    for h in H:
        hp = h - B * x
        if hp <= 0:
            continue
        attack += -(-hp // (A - B))
        # B*Xで足りない分対象に選んでAで補填するが、対象に選ぶということは
        # 選んだ数n分Bがなくなるということ。hp=h-B*(x-n)
        # 対象nの分(A-B)増加と言い換えられ、対象回数はhp//(A-B)の繰り上げで求まる。
    if attack > x:
        return 0
    else:
        return 1


l, r = -1, 10 ** 9
while (r - l > 1):
    mid = (l + r) // 2
    if func(mid):
        r = mid
    else:
        l = mid


print(r)

Measured memory_bytes: 7072
from bisect import bisect
S=input()
T=input()
c=[[] for _ in range(26)]
for i,s in enumerate(S):
    j=ord(s)-ord("a")
    c[j].append(i)
for t in set(T):
    if not c[ord(t)-ord("a")]:
        print(-1)
        exit()
rnd=0
k=-1
for t in T:
    ti=ord(t)-ord("a")
    i=bisect(c[ti],k)
    if i==len(c[ti]):
        k=c[ti][0]
        rnd+=1
    else:
        k=c[ti][i]
        
print(rnd*len(S)+k+1)


Measured memory_bytes: 54128
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    println(problem118a(a, b))
}

fun problem118a(a: Int, b: Int): Int {
    return if (b % a == 0) a + b else b - a
}

Measured memory_bytes: 31272
import java.util.Scanner;

class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt(); 
        int b = scanner.nextInt();
        
        int d = a / b;
        int r = a % b;
        double f = (double)a / b;
        
        System.out.println(Integer.toString(d) + " " + Integer.toString(r) + " " + String.format("%.8f", f));
    }
}


Measured memory_bytes: 26496
#include <stdio.h>
int main(void)
{
    int i,N[7],a,b,c,t;
    char S[102];
     
    for(i=1;i<7;i++)scanf("%d",&N[i]);
    scanf("%s",S);
     
    for(a=1,b=2,c=3,i=0;S[i];i++){
        switch(S[i]){
        case 'N':t=a,a=b,b=7-t;break;
        case 'E':t=c,c=a,a=7-t;break;
        case 'S':t=b,b=a,a=7-t;break;
        case 'W':t=a,a=c,c=7-t;break;
        }
    }
    printf("%d\n",N[a]);
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll l[52],r[52];
int main() {
	ll n,k,ans=INF;
	cin>>n>>k;
	for(ll i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		l[i]=x;r[i]=y;
	}
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			for(ll m=0;m<n;m++){
				for(ll o=0;o<n;o++){
					ll sum=0;
					ll ux=l[i],dx=l[j],uy=r[m],dy=r[o];
					if(ux<dx){
						swap(ux,dx);
					}
					if(uy<dy){
						swap(uy,dy);
					}
					for(ll p=0;p<n;p++){
						ll nowx=l[p],nowy=r[p];
						if(nowx>=dx&&nowx<=ux&&nowy<=uy&&nowy>=dy){
							sum++;
						}
					}
					if(sum>=k){
						ll sq=(ux-dx)*(uy-dy);
						ans=min(ans,sq);
					}
				}
			}
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

int main(void) {
  ll H, W, D;
  cin >> H >> W >> D;
  vector< vector<ll> > A(H + 1, vector<ll>(W + 1));
  vector<ll> Y(H * W + 1), X(H * W + 1);
  REP(i, 1, H + 1) REP(j, 1, W + 1) {
    cin >> A[i][j];
    Y[A[i][j]] = i;
    X[A[i][j]] = j;
  }
  ll Q;
  cin >> Q;
  vector<ll> L(Q), R(Q);
  REP(i, 0, Q) cin >> L[i] >> R[i];

  vector<ll> dp(H * W + 1);
  REP(i, 1, H * W + 1) {
    if(i <= D) dp[i] = 0;
    else dp[i] = dp[i - D] + (abs(Y[i - D] - Y[i]) + abs(X[i - D] - X[i]));
  }

  REP(i, 0, Q) cout << dp[R[i]] - dp[L[i]] << endl;
}


Measured memory_bytes: 5504
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<string>
#include<queue>
#include<set>
#include<stack>
#include<map>

using namespace std;

int med(int a,int b,int c){
    int A[3]={a,b,c};
    sort(A,A+3);
    return A[1];
}

int main(){
    int N;
    int A[200000];
    cin>>N;
    for(int i=1;i<=2*N-1;i++){
        cin>>A[i];
    }
    int low=1;
    int high=2*N;
    int B[200000];
    while(high-low>1){
        int mid=(low+high)/2;
        for(int i=1;i<=2*N-1;i++){
            if(A[i]>=mid){
                B[i]=1;
            }else{
                B[i]=0;
            }
        }
        //中心から最も近い連続したpartを探す．
        int left=N-1;
        int right=N+1;
        int ret=-1;
        while(left>0){
            if(B[left]==B[left+1]){
                ret=B[left];
                break;
            }
            if(B[right]==B[right-1]){
                ret=B[right];
                break;
            }
            left--; right++;
        }
        if(ret==-1){
            if(N%2==0){
                ret=(1-B[N]);
            }else{
                ret=B[N];
            }
        }
        if(ret==0){
            high=mid;
        }else{
            low=mid;
        }
    }
    cout<<low<<endl;
    return 0;
}


Measured memory_bytes: 1920
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int min = 2;
    for(int i=1;i<N;i++){
      min = Math.min(min*2, min+K);
    }
    System.out.println(min);
  }
}


Measured memory_bytes: 23764
#include <vector>
#include <iostream>
#include <string>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main(){
    int i;
    int n;
    cin >> n;
    vector<int> h(200);
    rep(i, n) cin >> h[i];

    int count = 1;
    for (int i = 1; i < (n); i++){
        bool flg = true;
        for (int j=0; j<i; j++){
            if (h[j] > h[i]){
                flg = false;
            }
        }
        if (flg==true){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    int n;
    cin >> n;
 
    int array[n];
    for(int i=0; i < n; i++){
        cin >> array[i];
    }
    
    int ans = 0;
    for(int i=0; i < n; i++){
        if((i+1) != array[i]){
            ++ans;
        }
    }
    // cout << ans << endl;
    if(ans <= 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

func init() {
	nextReader = newScanner()
}

func main() {
	A := make([][]int, 3, 3)
	for i := 0; i < 3; i++ {
		A[i] = make([]int, 3, 3)
	}
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			A[i][j] = nextInt()
		}
	}
	N := nextInt()
	hits := make([]int, 3, 3)
	for k := 0; k < N; k++ {
		b := nextInt()
		for i := 0; i < 3; i++ {
			for j := 0; j < 3; j++ {
				if A[i][j] == b {
					hits = append(hits, 3*i+(j+1))
				}
			}
		}
	}
	for i := 1; i <= 3; i++ {
		if contains(hits, i) && contains(hits, i+3) && contains(hits, i+6) {
			fmt.Println("Yes")
			return
		} else if contains(hits, 3*i-2) && contains(hits, 3*i-1) && contains(hits, 3*i) {
			fmt.Println("Yes")
			return
		}
	}
	if contains(hits, 1) && contains(hits, 5) && contains(hits, 9) {
		fmt.Println("Yes")
		return
	}
	if contains(hits, 3) && contains(hits, 5) && contains(hits, 7) {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")

}


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

#define limit (int)(2e5 + 5)
// #define mod (int)(1e9 + 7)
#define pb push_back
#define fi first
#define se second

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;

int main() {

	lli n,c;
	cin >> n;
	c = n;
	lli l = 0;

	int binary[20];

	while(c > 0)
	{
		c--;
		binary[l] = (c)%26;
		l++;
		c /= 26;
	}

	char ch;
	for (int i = l-1; i >= 0; --i)
	{
		ch = 'a' + binary[i];
		cout << ch;
	}
	return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {

  int n = in;
  auto a = in.Array(n);
  auto mini = *min_element(all(a));
  auto maxi = *max_element(all(a));
  cout << (maxi - mini) << endl;



}


Measured memory_bytes: 256
def WarshallFloyd(M):
    N = len(M)
    M = [m[:] for m in M]
    for k in range(N):
        for j in range(N):
            for i in range(N):
                M[i][j] = min(M[i][j], M[i][k] + M[k][j])
    return M

N, *A = map(int, open(0).read().split())
A = list(map(list, zip(*[iter(A)] * N)))

B = WarshallFloyd(A)

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        if A[i][j] > B[i][j]:
            print(-1)
            quit()

        if A[i][j] == B[i][j] and all(B[i][j] != B[i][k] + B[k][j] for k in range(N) if k != i and k != j):
            ans += B[i][j]

print(ans)

Measured memory_bytes: 89940
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int[] st = new int[6];
			for(int i = 0;i < n;i++){
				double t = scan.nextDouble();
				if(t >= 185){
					st[5]++;
				}else if(t >= 180){
					st[4]++;
				}else if(t >= 175){
					st[3]++;
				}else if(t >= 170){
					st[2]++;
				}else if(t >= 165){
					st[1]++;
				}else{
					st[0]++;
				}
			}
			for(int i = 0;i < 6;i++){
				System.out.print(i+1 + ":");
				for(int j = 0;j < st[i];j++){
					System.out.print("*");
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 20224
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let ans = if (a*b)%2 == 0 { "Even" } else { "Odd" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
A, B, C, D = gets.split.map(&:to_i)

lcm = C.lcm(D)
sum = B - A + 1

b1 = B / C
b2 = (A - 1) / C
b_c = b1 - b2

d1 = B / D
d2 = (A - 1) / D
d_c = d1 - d2

lcm1 = B / lcm
lcm2 = (A - 1) / lcm
lcm_c = lcm1 - lcm2

ans = sum - b_c - d_c + lcm_c
puts ans


Measured memory_bytes: 1788