akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		b-=a;
		int s,g;
		s=b/1000;b%=1000;
		g=b/500;b%=500;
		printf("%d %d %d\n",b/100,g,s);
	}
}

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric> // accumulate
#include <queue>
#include <string>
#include <cmath> // sqrt
#include <map>
using namespace std;
typedef long long ll;

const ll INF = (1LL << 62);
ll dp[110][100010];

int main() {
    int N, W;
    cin >> N >> W;
    for (int i = 0; i <= N; i++) {
        for (int value = 0; value <= 100000; value++) {
            dp[i][value] = INF;
        }
    }
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        ll w, v;
        cin >> w >> v;
        for (int value = 0; value <= 100000; value++) {
            dp[i+1][value] = min(dp[i+1][value], dp[i][value]);
            if (value + v > 100000) continue;
            dp[i+1][value + v] = min(dp[i+1][value + v], dp[i][value] + w);
        }

    }

    int ans = 0;
    for (int value = 100000; value >= 0; value--){
        if (dp[N][value] <= W) {
            cout << value << endl;
            return 0;
        }
    }
}

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

#define maxn 500010
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define rd read()
#define inf 1e10
#define ll long long
int ans;
int read() {
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
	return x*f;
}
int main() {
	int n=rd,m=rd;
	while(n)
	{
		n/=m;ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
div = 10**9+7


# ある自然数未満までのエラトステネスの篩をつくる
def mark(s, x):
    for i in range(x + x, len(s), x):
        s[i] = False


def eratosthenes(n):
    s = [True] * n
    for x in range(2, int(n ** 0.5) + 1):
        if s[x]: mark(s, x)
    return [i for i in range(0, n) if s[i] and i > 1]


primes = eratosthenes(1000)
num_pow = [1] * (N+1)

for n in range(1, N+1):
    for p in primes:
        if p > n:
            break
        while True:
            if n % p == 0:
                n /= p
                num_pow[p] += 1
            else:
                break

ans = 1
for z in num_pow:
    ans *= z

print(ans % div)




Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    double ans = 0;
    rep(i, n) Rep(j, i + 1, n)
    {
        double d = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
        ans += 2 * sqrt(d);
    }
    ans /= n;
    printf("%.8lf\n", ans);
}

Measured memory_bytes: 256
// abc134d: Preparing Boxes
#include <stdio.h>

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

  int m=0;
  for(int i=n;i>0;i--){
    int c=0;for(int j=i;j<=n;j+=i) c^=b[j];// 排他的論理和で剰余処理
    if(a[i]^c){
      b[i]=1;
      m++;
    }
  }

  printf("%d\n",m);
  for(int i=1;i<=n;i++)
    if(b[i]) printf("%d%c",i,--m?' ':'\n');

  return 0;
}

Measured memory_bytes: 2432
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int k, x;
  cin >> k >> x;

  for (int i = x-k+1; i < k+x; i++) cout << i << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def main():
    r = input().split()
    a = int(r[0])
    b = int(r[1])
    dd = set(make_divisors(a)) & set(make_divisors(b))
    dd = sorted(list(dd))
    res = 0
    #print(dd)
    for i in dd:
        if i == 1:
            res += 1
            continue
        else:
            flag = True
            for j in dd:
                if j == 1:
                    continue
                if j < i and i % j == 0:
                    flag = False
                    break
            if flag:
                res += 1
    print(res)

main()

Measured memory_bytes: 40432
package main

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

func mapf(f interface{}, list interface{}) interface{} {
        fv, listv := reflect.ValueOf(f), reflect.ValueOf(list)

        if fv.Kind() != reflect.Func || listv.Kind() != reflect.Slice {
                return nil
        }

        len := listv.Len()
        ret := reflect.MakeSlice(reflect.SliceOf(fv.Type().Out(0)), len, listv.Cap())

        for i := 0; i < len; i++ {
                v := fv.Call([]reflect.Value{listv.Index(i)})
                ret.Index(i).Set(v[0])
        }

        return ret.Interface()
}

func main() {
        var n, m int
        fmt.Scan(&n, &m)

        scanner := bufio.NewScanner(os.Stdin)

        A := make([][]int, n)
        for i := range A {
                scanner.Scan()
                A[i], _ = mapf(strconv.Atoi, strings.Split(scanner.Text(), " ")).([]int)
        }

        B := make([]int, m)
        for i := range B {
                scanner.Scan()
                B[i], _ = strconv.Atoi(scanner.Text())
        }

        for i := range A {
                n := 0
                for j := range B {
                        n += A[i][j] * B[j]
                }
                fmt.Println(n)
        }
}



Measured memory_bytes: 2668
def check_even(a_list):
    flag = True
    for i, a in enumerate(a_list):
        if a%2 == 1:
            flag = False
            break
        a_list[i] = a//2
    return a_list, flag


def main():
    n = int(input())
    a_list = [int(a) for a in input().split()]

    cnt = 0
    while True:
        a_list, flag = check_even(a_list)
        if not flag:
            break
        cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

void solve(long long N, vector<long long> W){
  long long ans = 10000000;
  long long mi, ma, x;
  for (int i = 0; i < 101; i++) {
    mi = 0;
    ma = 0;
    for (int j = 0; j < N; j++) {
      if (j <= i) {
        mi += W[j];
      } else {
        ma += W[j];
      }
    }
    x = ma - mi;
    ans = min(ans, x < 0 ? -x : x);
  }
  std::cout << ans << std::endl;

}

int main(){
  long long N;
  scanf("%lld",&N);
  vector<long long> W(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&W[i]);
  }
  solve(N, W);
  return 0;
}


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

int main() {

  int N,a,b,c,A;
  
  cin>>N;
  
  a=N/100;
  
  b=(N - N/100 * 100) / 10;
    
  c= N - N/10 * 10;
  
  A=a + b + c;
  
  cout<<A<< endl;
  
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int MAX_N = 50;
vector<int> Preorder(MAX_N), Inorder(MAX_N);
vector<int> ans;
int n, pos = 0;
void Solve(int left, int right)
{
    if(left >= right) return;
    int node = Preorder[pos];
    pos++;
    for(int i = left; i < right; i++)
    {
        if(Inorder[i] == node)
        {
            Solve(left, i);
            Solve(i + 1, right);
        }
    }
    ans.push_back(node);
}
int main()
{
    cin >> n;
    for(int i = 0; i < n; i++) cin >> Preorder[i];
    for(int i = 0; i < n; i++) cin >> Inorder[i];
    Solve(0, n);
    for(int i = 0; i < ans.size(); i++)
    {
        if(i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}




Measured memory_bytes: 3160
// #define FNAME "template"

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

typedef long long inte;
const int maxk = 1000005;

#ifndef NDEBUG
#    define dprint(x) (cerr << (#x) << " = "<< (x) << endl)
#else
#    define dprint(x) (NULL)
#endif

template<typename T>
inline void readFig(T& x)
{
#   ifdef FTREAD
        static int c = 0;
        int op = 1;
        x = 0;
        while (!isdigit(c)) {
            if (c == '-')
                op = -1;
            c = getchar();
        }
        while (isdigit(c)) {
            x *= 10;
            x += c - '0';
            c = getchar();
        }
        x *= op;
#   else
        cin >> x;
#   endif
}

int dis[maxk];
bool vis[maxk] = {0};
int K;
void SP()
{
    deque<pair<int, int> > q;
    q.push_back(make_pair(1, 1));
    while (!q.empty()) {
        int u = q.front().first, d = q.front().second;
        q.pop_front();
        if (vis[u])
            continue;
        dis[u] = d;
        vis[u] = true;
        if (u == 0)
            break;
        q.push_back(make_pair((u + 1) % K, d + 1));
        q.push_front(make_pair(u * 10 % K, d));
    }
}

inline void solve()
{
    readFig(K);
    SP();
    cout << dis[0] << endl;
}

signed main()
{
#   ifdef FNAME
        freopen(FNAME".in", "r", stdin);
        freopen(FNAME".out", "w", stdout);
#   endif
#   ifndef FTREAD
    	ios::sync_with_stdio(false);
    	cin.tie(0);
#   endif

#   ifdef MULTEST
        int T;
        readFig(T);
        while (T--)
            solve();
#   else
        solve();
#   endif

#   ifdef FNAME
        fclose(stdin);
        fclose(stdout);
#   endif
    	return 0;
}



Measured memory_bytes: 4504
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using LL = long long;
const long double EPS = 1e-5;
 
int main(void) {
    LL _n, _s;
    cin >> _n >> _s;
    const LL n = _n, s = _s;
    
    if(n == s) {cout << n+1 << endl; return 0;}
    
    auto f = [](LL n, LL b) -> LL {
        LL ret = 0;
        while(n >= b) {
            ret += n%b;
            n /= b;
        }
        ret += n;
        return ret;
    };
    
    for(LL b = 2; b <= sqrt(n)+EPS; ++b) {
        if(f(n, b) == s) {cout << b << endl; return 0;}
    }
    
    for(LL p = sqrt(n+EPS); p >= 1; --p) {
        LL q = s - p;
        if(q < 0 || n-q <= 0) continue;
        if((n-q) % p == 0) {
            LL b = (n-q)/p;
            if(q < b && p < b) {cout << (n-q)/p << endl; return 0;}
        }
    }
    
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    char s[3];
    scanf("%s", s);
    if (s[0] == s[1]) {
        if (s[0] == s[2]) {
            printf("No\n");
        } else {
          printf("Yes\n");
        }
    } else {
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

ll n;
ll x;
vector<ll> patys;
vector<ll> sizes;

void setup(){
  n = in();
  x = in();
  patys.resize(n+1);
  sizes.resize(n+1);
  patys[0] = 1;
  sizes[0] = 1;
  rep(i,n){
    patys[i+1] = patys[i] * 2 + 1;
    sizes[i+1] = sizes[i] * 2 + 3;
  }
}

ll func(int level,ll rem){
  if(level==0 and rem)return 1;
  ll res = 0;
  if(rem<=1)return 0;
  --rem;
  if(rem<=sizes[level-1]){
    return func(level-1,rem);
  }
  res += patys[level-1];
  rem -= sizes[level-1];
  if(rem){
    --rem;
    ++res;
    res += func(level-1,rem);
  }
  return res;
}

int main(){
  setup();

  cout << func(n,x) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int n, m;
int a[maxn];
ll tag[maxn], s;
inline void add(int l,int r,int v) { tag[l] += v, tag[r + 1] -= v; }
inline void add(int l,int r) {
	if(r < l) r += m;
	s += r - l, ++ l;
	add(l + 1, r, 1);
	add(r + 1, r + 1, l - r);
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	rep(i, 1, n) {
		cin >> a[i];
	}
	rep(i, 2, n) {
		add(a[i - 1], a[i]);
	}
	rep(i, 1, m + m) {
		tag[i] += tag[i - 1];
	}
	rep(i, 1, m + m) {
		tag[i] += tag[i - 1];
	}
	ll ans = 1e18;
	rep(i, 1, m) {
		ans = std::min(ans, s - tag[i] - tag[i + m]);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 2176
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()

if n%10 == 3:
    print('bon')
elif n%10 in [2,4,5,7,9]:
    print('hon')
else:
    print('pon')

Measured memory_bytes: 9064
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}




int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    vector<ll>a;
    vector<ll>b;
    vector<ll>c;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        a.push_back(x);
    }
    c.push_back(0);
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        b.push_back(x);
    }
    for(int i=0;i<n-1;i++){
        ll x;
        cin>>x;
        c.push_back(x);
    }
    ll res=0;
    ll last=-1;
    for(int i=0;i<n;i++){
        if(last==-1){last=a[i];}
        ll cur=a[i];
        res+=b[a[i]-1];
        if(cur==last+1)res+=c[a[i]-1];
        last=cur;
    }
    cout<<res<<endl;
    return 0;
    }


Measured memory_bytes: 256
a, b = map(int, input().split())
if a * b <= 0:
    print("Zero")
elif a > 0 and b > 0:
    print("Positive")
else:
    if (abs(a - b) + 1) % 2 == 0 :
        print("Positive")
    else:
        print("Negative")


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

int ab(int num){
	if(num<0)num*=-1;
	return num;
}

int dis(int Ax,int Ay,int Bx,int By){
	return ab(Ax-Bx)+ab(Ay-By);
}

int sum(int Ax,int Ay,int Bx,int By,int Cx,int Cy,int Dx,int Dy){
	return dis(Ax,Ay,Bx,By)+dis(Cx,Cy,Dx,Dy);
}

int X(int num,int W){
	num%=W;
	if(num==0)num=W;
	return num;
}

int Y(int num,int W){
	num=(num-1)/W;
	return num+1;
}

int cal(int A,int B,int C,int D,int W){
	return sum(X(A,W),Y(A,W),X(B,W),Y(B,W),X(C,W),Y(C,W),X(D,W),Y(D,W));
}

int main(){
	int n;
	int a,b,c,d;
	cin>>n;
	cin>>a>>b;
	cin>>c>>d;
	
	int tmp=cal(a,b,c,d,1);
	
	
	for(int i=1;i<=n;i++){
		//cout<<i<<" "<<cal(a,b,c,d,i)<<endl;
		tmp=min(tmp,cal(a,b,c,d,i));
	}
	
	cout<<tmp<<endl;
	
	return 0;
}


Measured memory_bytes: 1160
def main():
    n, k = map(int, input().split())
    count = 0
    lc = list()
    res = 0
    for i in range(1, n+1):
        while i < k:
            i = i * 2
            count += 1
            if i >= k:
                lc.append(count)
                count = 0
    diff = n - len(lc)
    for i in range(len(lc)):
        res += 1/n * (1/2 ** lc[i])
    res += diff/n
    print(res)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
k=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(k[int(input())-1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;

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

	int t = 1;
	// cin >> t;

	while (t--) {
                int n;
                cin >> n;
                vector<int> v(n);
                for (auto &x : v) cin >> x;
                int maxx = v[0];
                int ans = 0;
                for (int i = 0; i < n; i++) {
                        if (v[i] < maxx) {
                                ans += maxx - v[i];
                        } else maxx = v[i];
                } 
                cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4776
#include <stdio.h>
#include <math.h>


int main(){

    int a,b;
    scanf("%d%d",&a,&b);
    
    int d = a/b;
    int r = a%b;
    double f = (double)a/(double)b;

    printf("%d %d %lf\n",d,r,f);
    return 0;
}



Measured memory_bytes: 2748
#include <bits/stdc++.h>
#pragma GCC diagnostic error "-Wconversion"
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
ll digits(ll x){
  ll length = 0;
  while (x > 0){
    x /= 10;
    length++;
  }
  return length;
  if (x == 0) return 0;
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);

  string s, t; cin >> s >> t;

  //ll ans = 0;
  string ans;

  ans = t + s;

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

Measured memory_bytes: 256
n, m, x, y = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))

mx = max(xs)
my = min(ys)

for i in range(x+1, y+1):
    if i <= mx or my < i:
        continue
    else:
        print("No War")
        exit()
print("War")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long

string INF = "-";

int match[9] = {2,5,5,4,5,6,3,7,6};
string dp[10010]; //マッチi本で作れる最大数

string chmax(string s,string t){
  if(s == INF) return t;
  if(s.size() < t.size()) return t;
  if(s.size() == s.size() && s < t) return t;
  return s;
}

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

  int n,m; cin >> n >> m;
  vector<int> a(m);
  for(int i = 0; i < m; i++){
    cin >> a[i];
  }

  fill(dp,dp+10010,INF);
  dp[0] = "";
  for(int i = 0; i <= n; i++){
    if(dp[i] == INF) continue;
    for(auto x : a){
      dp[i+match[x-1]] = chmax(dp[i+match[x-1]],dp[i]+to_string(x));
    }
  }
  cout << dp[n] << endl;

  return 0;
}


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

int main() {

    int N;
    cin>>N;
    vector<string> S(N);
    int cnt_a=0,cnt_b=0,cnt_ab=0,cnt=0;
    for(int i=0;i<N;i++){
        cin>>S.at(i);
        for(int j=0;j<S.at(i).size()-1;j++){
            if(S.at(i).at(j)=='A'&&S.at(i).at(j+1)=='B'){
                cnt++;
            }
        }
            if(S.at(i).at(0)=='B'&&S.at(i).at(S.at(i).size()-1)=='A'){
                cnt_ab++;
            }
            if(S.at(i).at(0)!='B'&&S.at(i).at(S.at(i).size()-1)=='A'){
                cnt_a++;
            }
        if(S.at(i).at(0)=='B'&&S.at(i).at(S.at(i).size()-1)!='A'){
            cnt_b++;
        }
        }
    int ans=cnt;
    if(cnt_ab>=1){
        ans=ans+cnt_ab-1;
        if(cnt_a>=1){
            ans++;
            cnt_a--;
        }
        if(cnt_b>=1){
            ans++;
            cnt_b--;
        }
        }
    ans=ans+min(cnt_a,cnt_b);
    cout<<ans<<endl;
}

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

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

	vector<pair<long, long>> ab(N);
	vector<pair<long, long>> cd(M);
	int a, b;
	for(int i=0; i<N; i++){
		cin >> a >> b;
		ab[i] = make_pair(a, b);
	}
	for(int i=0; i<M; i++){
		cin >> a >> b;
		cd[i] = make_pair(a, b);
	}

	long res, man, tmp;
	for(int i=0; i<N; i++){
		man = 99999999999L;
		for(int j=0; j<M; j++){
			tmp = abs(ab[i].first - cd[j].first) + abs(ab[i].second - cd[j].second);
			if(tmp < man){
				man = tmp;
				res = j + 1;
			}
		}
		cout << res << endl;
	}	
}


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



int main()
{
  vector<int> A;
  int N;
  int sw = 0;

  cin >> N;
  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    A.push_back(a);
  }

  for (int i = 0; i < N; i++)
  {
    int mini = i;
    for (int j = i; j < N; j++)
    {
      if (A[j] < A[mini])
      {
        mini = j;
      }
    }
    if (i != mini) sw++;
    int tmp = A[mini];
    A[mini] = A[i];
    A[i] = tmp;
  }

  for (int i = 0; i < N; i++)
  {
    cout << A[i];
    if (i != N-1) cout << ' ';
  }
  cout << endl;
  cout << sw << endl;
}

Measured memory_bytes: 1216
from enum import IntEnum


class Sides(IntEnum):
    Left = 1
    Right = 2
    Bottom = 3
    Top = 4


original_width, original_height, n = (int(x) for x in input().split())

left, right, bottom, top = 0, original_width, 0, original_height

for i in range(n):
    x, y, a = (int(x) for x in input().split())
    if a == Sides.Left:
        left = max(left, x)
    elif a == Sides.Right:
        right = min(right, x)
    elif a == Sides.Bottom:
        bottom = max(bottom, y)
    elif a == Sides.Top:
        top = min(top, y)

width = right - left
height = top - bottom
area = width * height
print(area if width > 0 and height > 0 else 0)


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

string dp[55][55];

string tonum(string s) {
  if(s[0] == '0') return (s.size() == 1 ? "0" : "");
  string res = "";
  rep(i, s.size()) {
    if(isdigit(s[i])) res += s[i];
    else if(s[i] == '?') res += '9';
    else return "";
  }
  return res;
}

void ch(string &s, string t) {
  if(s.size() < t.size() || s.size() == t.size() && s < t) s = t;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;

  reps(len, 1, s.size()+1) {
    rep(i, s.size()+1-len) {
      int j = i + len;

      dp[i][j] = tonum(s.substr(i, len));

      if(len < 6) continue;

      if(s[i] != 'L' && s[i] != 'R' && s[i] != '?') continue;
      if(s[i+1] != '(' && s[i+1] != '?') continue;
      if(s[j-1] != ')' && s[j-1] != '?') continue;

      //cout<<"!!!!!!!!!!!!!!!"<<s[i]<<" "<<i<<" "<<j<<endl;

      reps(k, i+3, j-2) { //X(Y!...)/X(...!.)
	if(s[k] != ',' && s[k] != '?') continue;
	//string l = tonum(s.substr(i+2, k));
	//string r = tonum(s.substr(k+1, j-1));
	//if(l == "" || r == "") continue;
	if(dp[i+2][k] == "") continue;
	if(dp[k+1][j-1] == "") continue;

	if(s[i] == 'L' || s[i] == '?') ch(dp[i][j], dp[i+2][k]);
	if(s[i] == 'R' || s[i] == '?') ch(dp[i][j], dp[k+1][j-1]);
      }
    }
    /*
    cout << "-----------" << len << "--------" << endl;
    rep(i, s.size()+1)
      reps(j, i+1, s.size()+1)
      cout << i << " " << j << " "<< dp[i][j] << endl;
    */
  }

  cout << (dp[0][s.size()] == "" ? "invalid" : dp[0][s.size()]) << endl;

  return 0;
}

Measured memory_bytes: 3348
#include<bits/stdc++.h>
using namespace std;
double w,h,x,y;
int main(){
    scanf("%lf %lf %lf %lf",&w,&h,&x,&y);
    printf("%f ",w*h/2);
    if(x*2==w && y*2==h) printf("1");
    else printf("0");
    return 0;
}


Measured memory_bytes: 256
S = list(input())
s = len(S)
K = int(input())
A = []
j = 1

for i in range(0,s-1,1):
  if S[i] == S[i+1]:
    j += 1
  else:
    A.append(j)
    j = 1
A.append(j)

a = len(A)

b = 0
for i in range(0,a,1):
  b += A[i]//2
  
x = b*K

if a == 1:
  x = (s*K)//2
elif S[s-1] == S[0] and A[a-1] % 2 == 1 and A[0] % 2 == 1:
  x += K-1

print(x)

Measured memory_bytes: 3064
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    ll a, b, k; cin >> a >> b >> k;

    if(k >= a + b){
        cout << 0 << " " << 0 << endl;
        return 0;
    }

    else{
        if(k <= a){
            cout << a - k << " " << b << endl;
            return 0;
        }
        else if(a < k && k < a + b){
            cout << 0 << " " << b - (k - a) << endl;
            return 0;
        }
    }

return 0;
}

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

using namespace std;
// (setq-default c-basic-offset 2)

void mark(vector<vector<bool>>& board, vector<vector<int>>& a, int bi) {
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      if (a[i][j] == bi) {
        board[i][j] = true;
        return;
      }
    }
  }
}

bool check(vector<vector<bool>>& board) {
  for (int i = 0; i < 3; ++i) {
    bool ok = true;
    for (int j = 0; j < 3; ++j) {
      if (board[i][j] == false) {
        ok = false;
      }
    }
    if (ok) return true;
  }

  for (int i = 0; i < 3; ++i) {
    bool ok = true;
    for (int j = 0; j < 3; ++j) {
      if (board[j][i] == false) {
        ok = false;
      }
    }
    if (ok) return true;
  }

  bool ok = true;
  for (int i = 0; i < 3; ++i) {
    if (board[i][i] == false) {
      ok = false;
    }
  }
  if (ok) return true;

  ok = true;
  for (int i = 0; i < 3; ++i) {
    if (board[2 - i][i] == false) {
      ok = false;
    }
  }
  if (ok) return true;

  return false;
}

int main() {
  vector<vector<int>> a(3, vector<int>(3));
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> a[i][j];
    }
  }
  int n;
  cin >> n;
  vector<int> b(n);
  for (int& bi : b) {
    cin >> bi;
  }

  vector<vector<bool>> board(3, vector<bool>(3, false));
  for (int bi : b) {
    mark(board, a, bi);
  }

  if (check(board)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	string o, e;

	cin>>o>>e;

	rep(i, e.size()){
		cout<<o[i]<<e[i];
	}
	if((int)o.size()!=(int)e.size()) cout<<o[(int)o.size()-1]<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){
	int N;
	scanf("%d",&N);
	int S[N];
	for(int i = 0; i < N; i++)scanf("%d",&S[i]);

	int M;
	scanf("%d",&M);

	int Q[M];
	for(int i = 0; i < M; i++)scanf("%d",&Q[i]);
	sort(Q,Q+M);

	int left = 0,right,m,count = 0;

	for(int i = 0; i < M; i++){
		right = N-1;
		m = (left+right)/2;

		while(left <= right){
			if(S[m] == Q[i]){
				count++;
				left= m+1;
				break;
			}else if(S[m] > Q[i]){
				right = m-1;
			}else{ //S[m] < Q[i]
				left = m+1;
			}
			m = (left+right)/2;
		}
	}
	printf("%d\n",count);
}

Measured memory_bytes: 3736
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <utility>
using namespace std;


int main() {
    int n;
    cin>>n;
    
    vector<int>w(n);
    for(int i=0;i<n;i++){
        cin>>w.at(i);
    }
    
    vector<int>dif(n);
    for(int j=0;j<n;j++){
        int s1=0,s2=0;
        for(int i=0;i<j;i++){
            s1+=w.at(i);
        }
        for(int i=j;i<n;i++){
            s2+=w.at(i);
        }
        dif.at(j)=abs(s1-s2);
    }
    

    cout<<*min_element(dif.begin(), dif.end())<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n;
    int s;
    int sum = 0;
    int min = 100;
    int i;
    
    scanf("%d", &n);
    
    for( i = 0; i < n; ++i){
        scanf("%d", &s);
        sum += s;
        if( min > s && s%10 != 0){
            min = s;
        }
    }
    
    if( sum%10 == 0 && min < 100){
        sum -= min;
    }
    if( sum%10 == 0 && min == 100){
        sum = 0;
    }
    
    printf("%d\n", sum);
    return 0;
    
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


using namespace std;

#define int         long long
#define ld          double
#define vi          vector <int>
#define vp          vector <pair<int,int>>
#define vvi         vector <vector <int>>
#define pb          push_back
#define mp          make_pair
#define pi          pair<int,int>
#define all(a)      a.begin(),a.end()
#define sz(a)       a.size()
#define sl(a)       a.length()
#define rev(a)      sort(all(a),greater<int>())
#define ff          first
#define ss          second
#define minel(a)	*min_element(all(a))
#define maxel(a)	*max_element(all(a))
#define Mod         1000000007
#define deb(x)      cout << x << endl;
#define o(x)        for(auto a:x)cout << a <<" ";cout << endl;
#define o2(x,n,m)   for(int i =0;i<n;i++){for(int j=0;j<m;j++)cout << x[i][j] << " ";cout << endl; } 
#define i(x,n)      for(int i=0;i<n;i++)cin >> x[i];
#define i2(x,n,m)   for(int i =0;i<n;i++){for(int j=0;j<m;j++)cin >> x[i][j]; }
int inf = 1e18;




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

    int n,k;cin >> n >> k;
    vi a(n);i(a,n); 

    vector <bool> dp(k+1);
    
    for(int i=0;i<=k;i++)dp[i] = false;

    for(int i=0;i<=k;i++) 
    {
        for(int j=0;j<n;j++)
        {
            if(a[j]>i)continue;
            dp[i] = dp[i] or !dp[i-a[j]];
        }
    }

    if(dp[k])cout << "First" <<endl;
    else cout << "Second" <<endl;
    
}



Measured memory_bytes: 3664
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

N,M = map(int,input().split())
S = input()
T = input()

LCM = lcm(N,M)
GCD = gcd(N,M)

for i in range(0,LCM,LCM//GCD):
    if S[i*N//LCM] != T[i*M//LCM]:
        print(-1)
        exit()
print(LCM)



Measured memory_bytes: 5944
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

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

    if(X==3 || X==5 || X==7) cout << "YES" << endl;
    else cout << "NO" << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int MAX = 1e5+5;
int A, B, Q; ll s[MAX], t[MAX], x;
int main() {
  scanf("%d %d %d", &A, &B, &Q);
  for(int i = 1; i <= A; ++i) scanf("%ld", &s[i]);
  for(int i = 1; i <= B; ++i) scanf("%ld", &t[i]);
  s[0] = t[0] = -INF, s[A+1] = t[B+1] = INF;
  for(int i = 1; i <= Q; ++i) {
    scanf("%ld", &x);
    auto sitr = lower_bound(s+1, s+A+1, x);
    ll sv[2] = {*(sitr-1), *sitr};
    auto titr = lower_bound(t+1, t+B+1, x);
    ll tv[2] = {*(titr-1), *titr};
    ll ans = INF;
    for(int j = 0; j < 2; ++j) {
      for(int k = 0; k < 2; ++k) {
        ans = min(ans, abs(sv[j]-x)+abs(sv[j]-tv[k]));
        ans = min(ans, abs(tv[k]-x)+abs(tv[k]-sv[j]));
      }
    }
    printf("%ld\n", ans);
  }
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

lli happyValue(string s){
    lli size = s.size();
    lli cnt = 0;
    rep(i, size-1) if(s[i] == s[i+1]) cnt++;
    return cnt;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n, k; string s;
    cin >> n >> k >> s;

    // 第1引数:全員が同じ方向を向いていた場合
    // 第2引数:操作を加えて向きを揃えた場合
    cout << min(n-1, happyValue(s)+(2*k)) << endl;
}

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

int main()
{
    int n;
    cin >> n;
    queue<long int> qu;
    for(long int i = 1; i < 10; i++)
        qu.push(i);

    long ans;
    while(n--)
    {
        ans = qu.front();
        qu.pop();
        if(ans%10 != 0)
            qu.push(ans*10+ans%10-1);
        qu.push(ans*10+ans%10);
        if(ans%10 != 9)
            qu.push(ans*10+ans%10+1);
    }
    cout << ans;
}


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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

void MAIN() {
  int n, m, a, b;
  cin >> n >> m >> a >> b;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << ((i <= b) ^ (j <= a));
    }
    cout << '\n';
  }
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main{
    public static void main(final String args[]) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        int A = scan.nextInt();
        int B = scan.nextInt();
        int Kc = K;
        while(true){
            if(Kc <= B){
                if(Kc >= A){
                    System.out.println("OK");
                    break;
                }
            }else if(Kc > B){
                System.out.println("NG");
                break;
            }
            Kc = Kc + K;
            
        }

    }
}

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

constexpr long long INF = 100000000007;

int N;
long long dp[100005][3];
int triple[100005][3];

int main()
{
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> triple[i][0] >> triple[i][1] >> triple[i][2];
    }

    for (int k = 0; k < 3; ++k) {
        dp[0][k] = 0;
    }

    for (int i = 1; i <= N; ++i) {
        for (int k = 0; k < 3; ++k) {
            dp[i][k] = -INF;
            for (int kp = 0; kp < 3; ++kp) {
                if (k != kp)
                    dp[i][k] = max(dp[i][k], dp[i - 1][kp] + triple[i][k]);
            }
        }
    }

    long long ans = -INF;
    for (int k = 0; k < 3; ++k)
        ans = max(ans, dp[N][k]);
    cout << ans << endl;
}

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

b = b - 1
c = c - 1
A = []

for i in range(a):
    for j in range(i+1, a):
        A.append(min(abs(i - b) + 1 + abs(j - c), abs(j - i)))
import collections
C = collections.Counter(A)

for i in range(1, a):
    print(C[i])

Measured memory_bytes: 114700
#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()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    ans += 1 * min(a, k);
    k = max(k - a, 0LL);
    ans += 0 * min(b, k);
    k = max(k - b, 0LL);
    ans += -1 * min(c, k);
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};

class RollingHash{
  public:
  const ull mod = (1ull << 61)-1;
  const ull MASK31 = (1ull << 31)-1;
  vector<ull> pows;
  vector<ull> hash;
  const ull base = 1162261467;
  string s;
  RollingHash(string t) : pows(t.size()+1,1),hash(t.size()+1,0),s(t){
    REP(i,s.size())pows[i+1] = calcmod(mul(pows[i],base));
    REP(i,s.size())hash[i+1] = calcmod(mul(hash[i],base)+s[i]);
  }
  ull gethash(ll l,ll r){
    return calcmod(hash[r]+mod*4-mul(hash[l],pows[r-l]));
  }
  ull mul(ull n,ull r){
    ull nu = n >> 31,nd = n & MASK31;
    ull ru = r >> 31,rd = r & MASK31;
    return ((nu*ru) << 1) + nd * rd + (((nu*rd+nd*ru) >> 31) << 1) + (((nu*rd + nd*ru)&MASK31) << 31);
  }
  ull calcmod(ull n){
    ull u = n >> 61,d = n & mod;
    return (u+d >= mod) ? u+d-mod : u+d;
  }
};

int main(){

  int n;
  string s;
  cin >> n >> s;
  int res = 0;
  RollingHash rh(s);
  vector<tuple<ull,int,int>> v;
  for(ll i = n/2;i > 0;i--){
    for(ll j = 0;i+j <= n;j++){
      v.push_back(make_tuple(rh.gethash(j,j+i),i,j));
    }
  }
  sort(ALL(v));
  v.push_back(make_tuple(rh.mod,0,0));
  int old = 0;
  REP(i,v.size()-1){
    if(get<0>(v[i]) != get<0>(v[i+1])){
      if((get<2>(v[old]) < get<1>(v[i])+get<2>(v[i])) && (get<2>(v[old]) >= get<2>(v[i]))){
        old = i+1;
        continue;
      }
      if((get<2>(v[i]) < get<1>(v[old])+get<2>(v[old])) && (get<2>(v[i]) >= get<2>(v[old]))){
        old = i+1;
        continue;
      }
      res = max(res,get<1>(v[i]));
      old = i+1;
    }
  }
  cout << res << endl;



  

  return 0;
}


Measured memory_bytes: 264664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n;
ll k,a[N],L,R;
int main(){
    scanf("%d%lld",&n,&k);
    for(int i=0;i<n;i++) scanf("%lld",&a[i]);
    sort(a,a+n);
    L=-1e18,R=1e18;
    while(L+1!=R){
        ll Mid=(L+R)/2;
        ll cnt=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]<0){//小于0则向下找
                int l=i,r=n;
                while(l+1!=r){
                    int mid=(l+r)/2;
                    if(a[i]*a[mid]<=Mid) r=mid;
                    else l=mid;
                }
                cnt+=n-r;
            }
            else{
                int l=i,r=n;
                while(l+1!=r){//大于0向上找
                    int mid=(l+r)/2;
                    if(a[i]*a[mid]<=Mid) l=mid;
                    else r=mid;
                }
                cnt+=l-i;
            }
        }
        if(cnt<k) L=Mid;
        else R=Mid;
    }
    printf("%lld",R);
    return 0;
}

Measured memory_bytes: 1792
def main():
    n = [int(i) for i in input().split()]
    mi = []
    ma = []
    for i in range(n[1]):
        j = [int(i) for i in input().split()]
        mi.append(j[0])
        ma.append(j[1])
    ans = min(ma)-max(mi)+1
    if ans < 0:
        ans = 0
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 57176
#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 maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (ll)4e18;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, m;
	cin >> n >> m;
	n *= 2;
	if (n >= m) {
		ll ans = m / 2;
		cout << ans << endl;
	}
	else {
		ll ans = n / 2;
		m -= n;
		ans += m / 4;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import itertools
from collections import Counter
n=int(input())
a0=[input()[0] for i in range(n)]
a =[i for i in a0 if i in ["M","A","R","C","H"]]
c = dict(Counter(a))

if len(set(a))<=2:
  print(0)
else:
  x=0
  for i1, i2, i3 in itertools.combinations(set(a), 3):
    x+=c[i1]*c[i2]*c[i3]
  print(x)
    
  

Measured memory_bytes: 5108
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;


     signed main(){
         

int n;
cin>>n;
int a[n],b[n];
for(int i=0;i<n;i++)cin>>a[i]>>b[i];
sort(a,a+n);sort(b,b+n);
if(n%2){
     cout<<b[n/2]-a[n/2]+1<<endl;
}else{
cout<<(b[n/2-1]+b[n/2]-a[n/2-1]-a[n/2]+1)<<endl;

}









 }

 


 






    





      

        


Measured memory_bytes: 6756
a,b = map(int,input().split())
#初期tapsは0から
taps = 0
#現在の穴数（最初のコンセントの穴があるので１）
A = 1

#A(現在の穴の数)がb(ほしい穴数)より小さい間繰り返す
while A < b:
    #タップの数を一つづつ足していく
    taps += 1
    #タップにタップを接続するとひとつ穴を使ってa個の穴を拡張できるのでa-1を足す
    A += a-1

print(str(taps))


Measured memory_bytes: 2940