akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _ << ' ' <<
#define _squ(x)  ((x) * (x))
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define line_debug(var)  do{std::cout << "l" << __LINE__ << " " << #var << " : "; view(var);}while(0)
#define _max(v)  *max_element(v.begin(), v.end())
#define _min(v)  *min_element(v.begin(), v.end())
#define _sort(var)  std::sort(var.begin(), var.end());
#define _rsort(var)  std::sort(var.begin(), var.end(), std::greater<>());
using namespace std;
using ll = long long;
int gcd(int m, int n){return !n ? m : gcd(n, m%n);}
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;
template<typename T> void view(const T e){ std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){ for(const auto& e : v) std::cout << e << " "; std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T>>& vv){ for(const auto& v : vv){ view(v); } }

int souwa ( int inp ) {
  if(inp<=0) return 0;
  size_t wa = 0;
  for(int i=0; i<inp; ++i){
    wa += i;
  }
  return wa;
}

int main(){
  int i, j;
//  int N;
//  cin >> N;
//  V<int> v(N);
//  for(i=0; i<v.size(); i++) cin >> v[i];
  string S;
  cin >> S;
  vector<int> num(S.length()+1, 0);
  int counter = 1;
  for(int i=0; i<num.size(); ++i){
    bool is_larger = (S[i]=='<'? true : false);
    if(is_larger){
      num[i+1] = counter;
      counter++;
    }else{
      counter = 1;
    }
  }
//  debug(num);
  counter = 1;
  for(int i=num.size()-1; i>0; --i){
    bool is_larger = (S[i-1]=='<'? true : false);
    if(!is_larger){
      if(num[i-1] <= counter) num[i-1] = counter;
      counter++;
    }else{
      counter = 1;
    }
  }

//  debug(num);
  unsigned long long sums = 0;
  for(const auto& e : num) sums += e;
  cout << sums << endl;

//  0<3>2>1>0<1<2>0<1<2<3<4<5>2>1>0<1

  return 0;
}


Measured memory_bytes: 2820
n = int(input())
X = [int(x) for x in input().split()]
Y = [int(y) for y in input().split()]

d1 = 0
d2 = 0
d3 = 0
Di = []

for i in range(n) :
    d1 += abs(X[i] - Y[i])
print(f"{d1:.6f}")

for i in range(n) :
    d2 += abs(X[i] - Y[i]) ** 2
print(f"{(d2)**(1/2):.6f}")

for i in range(n) :
    d3 += abs(X[i] - Y[i]) ** 3
print(f"{(d3)**(1/3):.6f}")
    
for i in range(n) :
    Di.append(abs(X[i] - Y[i]))
print(f"{max(Di):.6f}")


Measured memory_bytes: 5660
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000



int main(){
	
	int N;
	cin>>N;
	
	vector<int> L(N);
	for(int i=0;i<N;i++)cin>>L[i];
	
	sort(L.begin(),L.end());
	
	int ans = 0;
	
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			for(int k=j+1;k<N;k++){
				if(L[i]==L[j]||L[j]==L[k])continue;
				if(L[i]+L[j]>L[k])ans++;
			}
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3632
#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>
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 all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

typedef vector< vector< pii > > Graph;

signed main() {
    int x, y; cin >> x >> y;
    int dist[4][4];
    rep(i,0,4) rep(j,0,4) {
        if(i == j) dist[i][j] = 0;
        dist[i][j] = INF;
    }
    dist[0][1] = 1;
    dist[1][0] = 1;
    dist[2][3] = 1;
    dist[3][2] = 1;

    rep(i,0,4) rep(j,0,4) {
        if(i == j) continue;
        int nx = dx[i] * x;
        int ny = dy[j] * y;
        if(abs(nx) != abs(x)) continue;
        if(abs(ny) != abs(y)) continue;
        if(nx < ny) dist[i][j] = ny - nx;
        else if(nx == ny) dist[i][j] = 0;
        else if(abs(nx) == abs(ny)) dist[i][j] = 1;
    }

    rep(k,0,4) rep(i,0,4) rep(j,0,4) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }
    cout << dist[0][2] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

using plint = pair<double, double>;

int N;
double L;

deque<plint> deq;
double Qsum = 0;
double Vnow = 0;

void trim()
{
    while (Vnow > L)
    {
        double nuku = min(Vnow - L, deq.front().second);
        deq.front().second -= nuku;
        Vnow -= nuku;
        Qsum -= nuku * deq.front().first;
        if (deq.front().second < 1E-5) deq.pop_front();
    }
}

void add(double tadd, double vadd)
{
    if (deq.back().first < tadd) // 追加するほうが高温の場合、先頭から余剰分を抜いていく
    {
        deq.push_back(plint(tadd, vadd));
        Qsum += tadd * vadd;
        Vnow += vadd;
        trim();
    }
    else // 低温の場合、うしろとくっつけていく
    {
        if (deq.back().second + vadd >= L)
        {
            Qsum = deq.back().first * (L - vadd) + tadd * vadd;
            Vnow = L;
            deq.clear();
            deq.push_back(plint(Qsum / L, L));
        }
        else
        {
            double Qaddnew = deq.back().first * deq.back().second + tadd * vadd;
            double vaddnew = deq.back().second + vadd;
            Qsum -= deq.back().first * deq.back().second;
            Vnow -= deq.back().second;
            deq.pop_back();
            add(Qaddnew / vaddnew, vaddnew);
        }
    }
}

void print()
{
    cout << setprecision(12) << Qsum / L << endl;
}
int main()
{
    cin >> N >> L;
    REP(_, N)
    {
        double t, v;
        cin >> t >> v;
        if (_ == 0)
        {
            deq.push_back(plint(t, v));
            Qsum = t * v;
            Vnow = v;
            print();
        }
        else
        {
            add(t, v);
            print();
        }
    }
}


Measured memory_bytes: 46624
<?php
list($q) = ints();
$n = pow(10, 5);
$isPrime = isPrimeArr($n);
$cusum[1] = 0;
for ($i = 1; $i <= $n; $i++) {
    if ($i % 2 === 0) {
        $cusum[$i + 1] = $cusum[$i];
        continue;
    }
    if ($isPrime[$i] && $isPrime[intdiv($i + 1, 2)]) {
        $cusum[$i + 1] = $cusum[$i] + 1;
    } else {
        $cusum[$i + 1] = $cusum[$i];
    }
}
for ($i = 0; $i < $q; $i++) {
    list($l, $r) = ints();
    $ans[] = $cusum[$r + 1] - $cusum[$l];
}
echo implode(PHP_EOL, $ans);

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}

function isPrimeArr($max)
{
    $arr = array_fill(0, $max + 1, true);
    $arr[0]  = $arr[1] = false;
    $rmax = (int) floor(sqrt($max));
    for ($i = 2; $i <= $rmax; $i++) {
        for ($j = 2 * $i; $j <= $max; $j += $i) {
            $arr[$j] = false;
        }
    }
    return $arr;
}


Measured memory_bytes: 19440
n = int(input())
a = list(map(int, input().split()))
count = 0
wa = 0
ans = 10 ** 18
#+-+-...
for i in range(n):
    wa += a[i]
    if i % 2 == 0 and wa <= 0:
        count += abs(wa) + 1
        wa = 1
    elif i % 2 == 1 and wa >= 0:
        count += abs(wa) + 1
        wa = -1
ans = min(ans, count)

#-+-+...
count = 0
wa = 0
for i in range(n):
    wa += a[i]
    if i % 2 == 0 and wa >= 0:
        count += abs(wa) + 1
        wa = -1
    elif i % 2 == 1 and wa <= 0:
        count += abs(wa) + 1
        wa = +1
ans = min(ans, count)

print(ans)

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

int main(){
  int a, x = 1;
  while(1){
    cin >> a;
    if ( a == 0 ){
      break;
    }else if ( a != 0 ){
      cout << "Case " << x << ": " << a << endl;
    }
    x = x + 1;
  }
  return 0;
}


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

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

    pair<pair<int, int>, int> a[n];
    pair<pair<int, int>, int> b[n];

    for (int i = 0; i < n; i++) {
        int a_, b_;
        cin >> a_ >> b_;

        a[i] = {{a_ + b_, a_}, i};
        b[i] = {{a_ + b_, b_}, i};
    }

    sort(a, a + n, [](pair<pair<int, int>, int> a, pair<pair<int, int>, int> b){ return a.first.first == b.first.first ? (a.first.second > b.first.second) : (a.first.first > b.first.first); });
    sort(b, b + n, [](pair<pair<int, int>, int> a, pair<pair<int, int>, int> b){ return a.first.first == b.first.first ? (a.first.second > b.first.second) : (a.first.first > b.first.first); });

    int idx_a = 0;
    int idx_b = 0;

    long total_a = 0;
    long total_b = 0;

    bool use[n] = {};
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            while (use[a[idx_a].second]) {
                idx_a++;
            }
            use[a[idx_a].second] = true;
            total_a += a[idx_a].first.second;
            idx_a++;
        } else {
            while (use[b[idx_b].second]) {
                idx_b++;
            }
            use[b[idx_b].second] = true;
            total_b += b[idx_b].first.second;
            idx_b++;
        }
    }

    cout << total_a - total_b << endl;

    return 0;
}


Measured memory_bytes: 2688
#include <stdio.h>
#include <string.h>
 
int main(void)
{
  char w[101];
  int len,i,ma = 0,mb = 0,mc = 0,md = 0,me = 0,mf = 0,mg = 0,mh = 0,mi = 0,mj = 0,mk = 0,ml = 0,mm = 0,mn = 0,mo = 0,mp = 0,mq = 0,mr = 0,ms = 0,mt = 0,mu = 0,mv = 0,mw = 0,mx = 0,my = 0,mz = 0;
  scanf("%s",w);
  len = strlen(w);
  if(len < 101) {
    for (i = 0; w[i] != 0; i++) {
      if (w[i] == 'a') ma++;
      if (w[i] == 'b') mb++;
      if (w[i] == 'c') mc++;
      if (w[i] == 'd') md++;
      if (w[i] == 'e') me++;
      if (w[i] == 'f') mf++;
      if (w[i] == 'g') mg++;
      if (w[i] == 'h') mh++;
      if (w[i] == 'i') mi++;
      if (w[i] == 'j') mj++;
      if (w[i] == 'k') mk++;
      if (w[i] == 'l') ml++;
      if (w[i] == 'm') mm++;
      if (w[i] == 'n') mn++;
      if (w[i] == 'o') mo++;
      if (w[i] == 'p') mp++;
      if (w[i] == 'q') mq++;
      if (w[i] == 'r') mr++;
      if (w[i] == 's') ms++;
      if (w[i] == 't') mt++;
      if (w[i] == 'u') mu++;
      if (w[i] == 'v') mv++;
      if (w[i] == 'w') mw++;
      if (w[i] == 'x') mx++;
      if (w[i] == 'y') my++;
      if (w[i] == 'z') mz++;
    }
    if (ma % 2 == 0 && mb % 2 == 0 && mc % 2 == 0 && md % 2 == 0 && me % 2 == 0 && mf % 2 == 0 && mg % 2 == 0 && mh % 2 == 0 && mi % 2 == 0 && mj % 2 == 0 && mk % 2 == 0 && ml % 2 == 0 && mm % 2 == 0 && mn % 2 == 0 && mo % 2 == 0 && mp % 2 == 0 && mq % 2 == 0 && mr % 2 == 0 && ms % 2 == 0 && mt % 2 == 0 && mu % 2 == 0 && mv % 2 == 0 && mw % 2 == 0 && mx % 2 == 0 && my % 2 == 0 && mz % 2 == 0) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(){
        int n;
        cin >> n;
        int *a = new int[n];
        int max1 = 0, max2 = 0;
        for(int i=0;i<n;i++){
                cin >> a[i];

                if(max1 < a[i]){
                        max2 = max1;
                        max1 = a[i];
                }else if(max2 < a[i]){
                        max2 = a[i];
                }
        }

        for(int i=0;i<n;i++){
                if(a[i] == max1){
                        cout << max2 << endl;
                }else {
                        cout << max1 << endl;
                }
        }
}

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

using namespace std;

int main(){
    int N, Y;
    cin >> N >> Y;
    
    vector<int> res{-1,-1,-1};
    bool flag = false;
    for(int i=0; i<=N; i++){
        if(res.at(0) != -1)break;
        int s = i*10000;
        if(s > Y)continue;
        for(int j=0; i+j<=N; j++){
            int sum = s+j*5000;
            if(sum > Y)continue;
            int k = (Y-sum)/1000;
            if(i+j+k == N){
                res = vector<int>{i,j,k};
                break;
            } 
        }
    }

    for(int i : res)cout << i << " ";
    // cout << endl;
    // printf("10000*%d + 5000*%d + 1000*%d = %d\n",
    // res.at(0), res.at(1), res.at(2), 10000*res.at(0)+5000*res.at(1)+1000*res.at(2));
}

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    if(a >= k) {
        a -= k;
    } else {
        k -= a;
        a = 0;
        if(b >= k) {
            b -= k;
        } else {
            b = 0;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

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


int main() {
  
  int N;
  cin>>N;
  
  
  vector<int> A(N);
  vector<int> B(N);
for (int i = 0; i < N; i++) {
  cin >> A.at(i);
}
  
  for (int i = 0; i < N; i++) {
  cin >> B.at(i);
}
  
  vector<int> C(N);
for (int i = 0; i < N-1; i++) {
  cin >> C.at(i);
}
  
  int sw=0;
  int sw1;
  int sw2=-1;
  
  for (int i = 0; i < N; i++) {
    sw1=A.at(i);
    if(sw1==sw2+1){
      sw=sw+B.at(A.at(i)-1)+C.at(A.at(i-1)-1);
    }else{
      sw=sw+B.at(A.at(i)-1);
    }
    sw2=sw1;
  
}
  
  cout<<sw<<endl;
  
}


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

int k;
long long int a[10];

int main () {

	for (int i = 0; i < 3; i ++) cin >> a[i];
	cin >> k;
	sort(a, a + 3);
	for (int i = 0; i <k; i ++) {
		a[2] *= 2;
	}
	long long int zbr = a[0];
	zbr += a[1];
	zbr += a[2];
	cout << zbr;

	return 0;
}

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

unordered_map<ll, ll> minvmap;
ll minv(ll a, ll m) {
  auto k = a; auto p = minvmap[a]; if (p != 0) return p;
  ll b = m, u = 1, v = 0;
  while (b) { ll t = a/b; swap(a -= t*b, b); swap(u -= t*v, v); }
  p = (u%m+m)%m; minvmap[k] = p; return p;
}
struct mint {
    ll x;
    mint():x(0){}
    mint(ll x):x((x%mod+mod)%mod){}
    mint& fix() { x = (x%mod+mod)%mod; return *this;}
    mint operator-() const { return mint(0) - *this;}
    mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
    mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
    mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
    mint& operator/=(const mint& a){ (x*=minv(a.x, mod))%=mod; return *this; }
    mint operator+(const mint& a)const{ return mint(*this) += a;}
    mint operator-(const mint& a)const{ return mint(*this) -= a;}
    mint operator*(const mint& a)const{ return mint(*this) *= a;}
    mint operator/(const mint& a)const{ return mint(*this) /= a;}
    bool operator<(const mint& a)const{ return x < a.x;}
    bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}

vector<int> graph[100005];

vector<bool> used(100005);

mint ans;
int k;

void dfs(int p) {
  used[p] = true;
  int cnt = 0;
  for(auto e: graph[p]) {
    if (!used[e]) {
      cnt++;
    }
  }
  int now = k;
  if (p != 1) {
    now--;
  }
  for(int i=1; i<=cnt; i++) {
    ans *= (now-i);
  }
  for(auto e: graph[p]) {
    if (!used[e]) dfs(e);
  }
}

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

  int n; cin >> n >> k;

  rep(i, n-1) {
    int a, b; cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  ans = k;
  dfs(1);
  cout << ans << endl;
}

Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>

using namespace std;
            
int main(){

    int x,y;
    
    while(cin >> x >> y){
        int goukei = x + y;
        int count  = 1;
        while(goukei > 9){
            goukei /= 10;
            count++; 
        }
        cout << count << endl;
    }
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	int N; cin >> N;
	string S; cin >> S;
	int ans = 0;
	int tmp = 0;
	rep(i, 0, S.size()) {
		if (S[i] == 'I')tmp++;
		else tmp--;
		chmax(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

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

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

    int n;
    cin>>n;
    int a[n];
    for (int i=0; i<n; i++) cin>>a[i];
    int cnt = 0;
    for (int i=0; i<n; i++){
        for (int j=i+1; j<n; j++){
            for (int k=j+1; k<n; k++){
                if (a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k]){
                    bool ok = 1;
                    ok &= (a[i]+a[j]>a[k]);
                    ok &= (a[j]+a[k]>a[i]);
                    ok &= (a[i]+a[k]>a[j]);
                    cnt += ok;
                }
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3604
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:String,
    }
    println!("{}",
             if a=="111" {"999" }
             else if a=="119" {"991" }
             else if a=="191" {"919" }
             else if a=="199" {"911" }
             else if a=="911" {"199" }
             else if a=="919" {"191" }
             else if a=="991" {"119" }
             else {"111" }
    )
}

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

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

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main()
{
    int A, B;
    cin >> A >> B;

    int a = A - 1;

    cout << ((B == 1) ? (0) : ((B - 1 - 1) / a + 1)) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 105
#define MAX 105
#define BLACK 2
#define GRAY 1
#define WHITE 0
#define NIL -1

int head, tail;
int Q[N];
int color[N];
int discover[N];
int adj[N][N];
int n;

void enqueue(int);
int dequeue();
void bfs(int);

int main()
{

    //int n;
    int u, k, v;
    int i, j;
    int num;
    int uid;

    scanf("%d", &n);

    for (i = 1; i <= n; i++)
    {
        scanf("%d%d", &uid, &k);
        for (j = 0; j < k; j++)
        {
            scanf("%d", &num);
            adj[uid][num] = 1;
        }
    }
    /*
 for(i=1;i<=n;i++){
   printf("%d  ",i);
    for(j=1;j<=n;j++){
    printf("%d ",adj[i][j]);
  }
    printf("\n");
 }
 printf("\n");
 printf("\n");
 */
    bfs(1);

    for (i = 1; i <= n; i++)
    {
        printf("%d %d\n", i, discover[i]);
    }

    return 0;
}

void enqueue(int num)
{

    Q[tail] = num;
    if (tail + 1 == MAX)
        tail = 0;
    else
        tail++;
}

int dequeue(void)
{
    int x;
    x = Q[head];
    if (head + 1 == MAX)
        head = 0;
    else
        head++;
    return x;
}

void bfs(int node)
{

    int i;
    int uid;

    for (i = 1; i <= n; i++)
    {
        color[i] = WHITE;
        discover[i] = NIL;
    }

    color[node] = GRAY;
    discover[node] = 0;

    enqueue(node);

    while ((tail - head - 1) >= 0)
    {

        uid = dequeue();

        for (i = 1; i <= n; i++)
        {
            if (adj[uid][i] == 1 && color[i] == WHITE)
            {
                color[i] = GRAY;
                discover[i] = discover[uid] + 1;
                enqueue(i);
            }
        }
        color[uid] = BLACK;
    }
}



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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const int N = 100010;

inline int in() {int x; scanf("%d",&x); return x;}
inline ll lin() {ll x; scanf("%lld",&x); return x;}

int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};

int row, col;

char str[55][55];

bool Valid(int i, int j){
    if(i < 0 || j < 0) return 0;
    if(i >= row || j >= col) return 0;
    return 1;
}

int main(){
    row = in(), col = in();
    for(int i = 0; i < row; i++){
        scanf("%s", str[i]);
    }
    for(int i = 0; i < row; i++){
        for(int j = 0; j < col; j++){
            if(str[i][j] == '#'){

                int ok = 0;
                for(int k = 0; k < 4; k++){
                    int xx = i + fx[k];
                    int yy = j + fy[k];
                    if(Valid(xx, yy) && str[xx][yy] == '#'){
                        ok = 1;
                    }
                }

                if(!ok){
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
# 077a

def atc_077a(input_value: str) -> str:
    C1 = input_value[0]
    C2 = input_value[1]

    if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:
        return "YES"
    else:
        return "NO"


C1 = input()
C2 = input()
print(atc_077a([C1, C2]))


Measured memory_bytes: 9004
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  multiset<int>a,b;
  rep(i,1<<n){int t;cin>>t;a.insert(t);}
  multiset<int>slime;
  bool flag=1;
  auto la=(a.lower_bound(1e9+7));
  la--;
  slime.insert(*la);
  b.insert(*la);
  //cout<<(la==a.end())<<endl;


//  cout<<a.size()<<endl;
//  a.erase(7);
//  for(auto t:a)cout<<t<<endl;


  rep(i,n)
  {
    multiset<int>dslime;
    for(auto tp:slime)
    {
      auto t=a.lower_bound(tp);
      if(t==a.begin()){flag=0;break;}
      t--;
      dslime.insert(*t);
      a.erase(t);
    //  b.insert(*t);

      //if(b.count(*t)==a.count(*t))a.erase(*t);
    }
  //  for(auto t:b)cout<<t<<" ";cout<<endl;

    if(!flag)break;
    slime.insert(all(dslime));
  }
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;



  return 0;

}


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

int main(){
	int n;
	cin>>n;
	vector<vector<int>> vec(n+1,vector<int>(3));
	for(int i=1;i<=n;i++){
		cin>>vec[i][0]>>vec[i][1]>>vec[i][2];
	}
	vector<vector<int>> dp(n+1,vector<int>(3,0));
	for(int i=1;i<=n;i++){
		for(int j=0;j<3;j++){
			dp[i][j]=vec[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
		}
	}
	int ans=max({dp[n][0],dp[n][1],dp[n][2]});
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int a[200000];
int s[200000],s2[200000];

signed main(){
	int n;scanf("%d",&n);
	rep(i,n){
		scanf("%d",&a[i]);
	}
	s[0]=abs(a[0]);
	for(int i=1;i<n;i++)s[i]=s[i-1]+abs(a[i]-a[i-1]);
	s2[n-1]=abs(a[n-1]);
	for(int i=n-2;i>=0;i--)s2[i]=s2[i+1]+abs(a[i]-a[i+1]);
	rep(i,n){
		if(i==0){
			cout<<s2[1]+abs(a[1])<<endl;
		}
		else if(i==n-1){
			cout<<s[n-2]+abs(a[n-2])<<endl;
		}
		else{
			cout<<s[i-1]+abs(a[i+1]-a[i-1])+s2[i+1]<<endl;
		}
	}
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> cnts(3, 0);
    ll ans = 0;
    rep(i, N){
        string s;
        cin >> s;
        if(s[0] == 'B' && s[s.size() - 1] == 'A'){
            cnts[2] ++;
        }
        else if(s[0] == 'B'){
            cnts[0] ++;
        }
        else if(s[s.size() - 1] == 'A'){
            cnts[1] ++;
        }

        for(int j = 0; j < s.size() - 1; j ++){
            if(s.substr(j, 2) == "AB"){
                ans ++;
            }
        }
    }
    ans += min(cnts[0], cnts[1]);
    if(cnts[0] + cnts[1] == 0 && cnts[2] >= 1) {
        ans += cnts[2] - 1;
    }else{
        ans += cnts[2];
    }
    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
fn readvec() -> Vec<i64> {
    let reader = std::io::stdin();
    let mut line = String::new();
    let _l = reader.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();
    let mut num = Vec::<i64>::new();
    for i in 0 .. vec.len() {
        let n: i64 = vec[i].parse().unwrap();
        num.push(n);
    }
    return num;
}

fn main() {
    loop {
        let a = readvec();
        if a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0 {
            break;
        }
        let b = a[1] * a[2] - a[0];
        if b <= 0 {
            println!("0");
        } else {
            println!("{}", (b + a[3] - 1) / a[3]);
        }
    }
}



Measured memory_bytes: 1060
A,B=map(int, input().split())
S=input()
length=A+B+1

ans=False
cnt=0
for i in range(length):
  if S[i]=="-":
    cnt+=1
  if i == A and S[i] == "-":
    ans=True
print('Yes' if ans==True and cnt==1 else 'No')


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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    map<int, int> ac;
    map<int, int> wa;
    for(int i = 0; i < m; i++) {
        int p;
        string s;
        cin >> p >> s;
        if (s == "AC") {
            if (ac.find(p) == ac.end()) ac.insert(make_pair(p, 1));
        } else if (s == "WA") {
            if (wa.find(p) == wa.end()) { 
                if (ac.find(p) == ac.end()) wa.insert(make_pair(p, 1));
            } else if (ac.find(p) == ac.end()) wa.at(p)++;
        }
    }
    int ans_ac = 0;
    int ans_wa = 0;
    for (auto itr = ac.begin(); itr != ac.end(); itr++) {
        ans_ac++;
        if (wa.find(itr->first) != wa.end()) ans_wa += wa.at(itr->first);
    }
    cout << ans_ac << " " << ans_wa << endl;
    return 0;
}

Measured memory_bytes: 4992
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"

inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    N=I()
    H=LI()
    prev=-100
    tmp=0
    out=0
    for h in H:
        out=max(out,tmp)
        if h>prev:
            tmp=0
        else:
            tmp+=1
        # print(tmp)
        prev=h
    out=max(out,tmp)
    print(out)

if __name__ == "__main__":
    main()

Measured memory_bytes: 23900
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int N;
    string s, t;
    cin >> N >> s >> t;

    int ans = 2*N;
    for(int i = 0; i < N; i++){
        int cnt = 0;
        for(int j = 0; j < N; j++){
            if(N < i+j) break;
            if( s[i+j] == t[j] ) cnt++;
        }

        ans = min(ans, 2*N-cnt);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
mod = 10**9+7
 
def comb(n,m,p=10**9+7):
    if n < m : return 0
    if n < 0 or m < 0:return 0
    m = min(m, n-m)
    top = bot = 1
    for i in range(m):
        top = top*(n-i) % p
        bot = bot*(i+1) % p
    bot = pow(bot, p-2, p)
    return top*bot % p
 
n,a,b = map(int, input().split())
ans = pow(2, n, mod)-1 - comb(n,a) - comb(n, b)
ans %= mod
print(ans)


Measured memory_bytes: 38728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
struct dice{
    int u, d, f, b, l, r;
    void init(int up,int down,int front, int back, int left, int right){
        u = up, d = down, f = front, b = back, l = left, r = right;
    }
    void goup(){    int tmp = u; u = b, b = d, d = f, f = tmp; }
    void godown(){  int tmp = u; u = f, f = d, d = b, b = tmp; }
    void goleft(){  int tmp = u; u = r, r = d, d = l, l = tmp; }
    void goright(){ int tmp = u; u = l, l = d, d = r, r = tmp; }

    void rotateleft() {  int tmp = f; f = r, r = b, b = l, l = tmp; }
    void rotateright() { int tmp = f; f = l, l = b, b = r, r = tmp; }

    void reversefb() { swap(f, b), swap(u, d); }
    void reverselr() { swap(l, r), swap(u, d); }
};

bool check(dice& d1, dice& d2){
    if (d1.u != d2.u) return false;

    bool ret = false;
    rep(i,4){
        if (d1.f == d2.f and d1.b == d2.b and d1.l == d2.l and d1.r == d2.r and d1.d == d2.d) ret = true;
        d1.rotateleft();
    }
    return ret;
}

bool checkall(dice& dic1, dice& dic2){
    bool ret = false;
    ret |= check(dic1, dic2);

    dic1.goleft();
    ret |= check(dic1, dic2);

    dic1.goleft();
    ret |= check(dic1, dic2);

    dic1.goleft();
    ret |= check(dic1, dic2);

    dic1.goup();
    ret |= check(dic1, dic2);

    dic1.reversefb();
    ret |= check(dic1, dic2);

    return ret;
}
int main() {
    init();
    int u, b, r, l, f, d;

    ll N;
    cin >> N;
    vc<dice> D(N);
    rep(i,N){
        cin >> u >> b >> r >> l >> f >> d;
        D[i].init(u, d, f, b, l, r);
    }

    bool issame = false;
    rep(i,N-1)repe(j,i+1,N){
        issame |= checkall(D[i], D[j]);
    }
    cout << (!issame ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3240
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		sc.close();

		long m = 1000000007;
		PrintWriter pw = new PrintWriter(System.out);
		long a = n - k + 1;
		long b = k;
		long val1 = a;
		long val2 = 1;
		long ans = val1;
		pw.println(ans);

		for (int i = 2; i <= k; i++) {
			val1 = val1 * (a - i + 1) % m;
			val1 = val1 * modinv(i, m) % m;
			val2 = val2 * (b - i + 1) % m;
			val2 = val2 * modinv(i - 1, m) % m;
			if (val2 == 0) val2 = 1;
			ans = val1 * val2 % m;
			pw.println(ans);
		}
		pw.flush();
	}

	static long modinv(long a, long m) {
		long b = m;
		long u = 1;
		long v = 0;
		long tmp = 0;

		while (b > 0) {
			long t = a / b;
			a -= t * b;
			tmp = a;
			a = b;
			b = tmp;

			u -= t * v;
			tmp = u;
			u = v;
			v = tmp;
		}

		u %= m;
		if (u < 0) u += m;
		return u;
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;

int main(){
    int y, m, d;
    string s;
    cin >> s;
    sscanf(s.c_str(), "%d/%d/%d", &y, &m, &d);
    if(y < 2019) cout << "Heisei";
    else if(y == 2019 && m < 4) cout << "Heisei";
    else if(y == 2019 && m == 4 && d <= 30) cout << "Heisei";
    else cout << "TBD";
    return 0;
}

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

using namespace std;

int main(){
    int n, m; cin >> n >> m;
    vector<int> nodes(n);
    for(int i=0; i<n; ++i) nodes[i]=i;
    vector<vector<bool>> edges(n, vector<bool>(n));
    for(int i=0; i<m; ++i){
        int a, b; cin >> a >> b;
        --a; --b;
        edges[a][b]=edges[b][a]=true;
    }
    int ans=0;
    do{
        ++ans;
        for(int i=1; i<n; ++i){
            if(!edges[nodes[i-1]][nodes[i]]){
                --ans;
                break;
            }
        }
    } while(next_permutation(nodes.begin()+1, nodes.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int A[][] = new int[N][2];
		for(int i = 0; i < N; i++) {
			A[i][0] = sc.nextInt();
			A[i][1] = sc.nextInt();
		}
		Arrays.sort(A, Comparator.comparingInt(o -> o[0]));
		
		PriorityQueue<Integer> pq = new PriorityQueue<Integer>(Collections.reverseOrder());
		int c = 0;
		int ans = 0;
		for(int i = 1; i <= M; i++) {
			while(c < N && A[c][0] == i) {
				pq.add(A[c][1]);
				c++;
			}
			if(pq.size() > 0) {
				ans += pq.poll();
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 95300
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define INF 1<<25
 
typedef long long ll;

int dy[8]={1,1,1,0,0,-1,-1,-1};
int dx[8]={-1,0,1,-1,1,-1,0,1};
struct S{
	int a,b,c;
};
bool asc(const S& left,const S& right){
	return left.c > right.c;
}
int t[200001];
int main(){
	int N,T;
	cin>>N>>T;
	rep(i,N)cin>>t[i];
	ll ans=0;
	rep(i,N-1){
		ans+=min(T,(t[i+1]-t[i]));
	}
	ans+=T;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
ll f[1000010], invf[1000010];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
    int s; cin>>s;
    fac(2*s);
    ll ans=0;
    for(int i=1; i<=s/3; i++){
        (ans+=comb(s-3*i+i-1, i-1))%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);

int solve(int N, int K) {
	vector<int>P(N);
	rep(i, N)P[i] = i;
	int ans = 0;
	do {
		int flag = 1;
		rep(i, N)if (abs(P[i] - i) == K) { flag = 0; break; }
		ans += flag;
		ans %= 924844033;

	} while (next_permutation(ALL(P)));
	return ans;
}

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

	
	int N, K;
	cin >> N >> K;
	vector<int>num(26, 0);
	rep(i, N) {
		string P;
		cin >> P;
		num[P[0] - 'A']++;
	}

	int ans = 0;
	while (1) {
		sort(ALL(num), greater<int>());
		if (num[K - 1] == 0)break;
		ans++;
		rep(i, K)num[i]--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;
typedef pair<ll,ll> P;

ll N,A,B;
int main(){
  cin>>N>>A>>B;
  ll AB=A+B;
  ll ans =(N/AB)*A;
  ll md = N%AB;

  if(md-A>0){
    print((ans+A))
  }
  else print((ans+md));

}


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

int main(){
  int w,a,b;
  cin >> w >> a >> b;
  if(b+w<a)cout << a-(b+w) << endl;
  else if(a+w<b)cout << b-(a+w) << endl;
  else cout << 0 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[15];
int n;
int ans;
void dfs(int x, int pro)
{
    if(x>n)
    {
        if(pro%2==0)ans++;    
        return;
    }
    for(int i=-1; i<=1; i++)
    {
        dfs(x+1, pro*(a[x]+i));
    }
    return;
}
int main()
{
    int  i, j;
    cin>>n;
    for(i=1; i<=n; i++)scanf("%d", &a[i]);
    dfs(1, 1);
    cout<<ans<<endl;
}


Measured memory_bytes: 764
s=input()
n=len(s)
for i in range(n-1):
  if s[i]==s[i+1]:
    print(i+1,i+2)
    exit()
for i in range(n-2):
  if s[i]==s[i+2]:
    print(i+1,i+3)
    exit()
print(-1,-1)

Measured memory_bytes: 70404
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

		Scanner scan = new Scanner(System.in);

		String s, t;
		s = scan.next();
		t = scan.next();

		int trueCount = 0;

		char[] s_char = s.toCharArray();
		char[] t_char = t.toCharArray();

		for (int i = 0; i < s_char.length; i++) {
			if (s_char[i] == t_char[i]) {
				trueCount++;

			}
		}

		System.out.println(trueCount);
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。ｓ
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param a 基数
	 * @param n 乗数
	 * @param primeNumMod 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myModPow(long a, long n, long primeNumMod) {

		long ans = 1;

		//乗数が0の場合→1
		if (n == 0)
			return 1;

		if (primeNumMod == 0) {
			//modを使わないとき

			while (n > 0) {

				if (n % 2 == 0) {
					//累乗が偶数の時

					a *= a;
					n = n / 2;
				} else {
					//累乗が奇数の時
					ans *= a;
					n--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			while (n > 0) {

				if (n % 2 == 0) {
					//累乗が偶数の時

					a *= myMod(a, primeNumMod);
					n = n / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(a, primeNumMod);
					n--;

				}
			}

			return myMod(ans, primeNumMod);

		}

	}

}


Measured memory_bytes: 23252
h,w=map(int,input().split())
used=[[0]*w for _ in range(h)]

grid=[]

for i in range(h):
    for j in range(w):
        if used[i][j]==0:
            grid.append([(i,j)])
            used[i][j]=1
            if used[h-i-1][j]==0:
                grid[-1].append((h-i-1,j))
                used[h-i-1][j]=1
            if used[h-i-1][w-j-1]==0:
                grid[-1].append((h-i-1,w-j-1))
                used[h-i-1][w-j-1]=1
            if used[i][w-j-1]==0:
                grid[-1].append((i,w-j-1))
                used[i][w-j-1]=1

num=[len(x) for x in grid]
num=sorted(num, reverse=True)
from collections import defaultdict

d=defaultdict(int)
for i in range(h):
    S=list(input())
    for s in S:
        d[s]+=1

for i in range(len(num)):
    for x in range(26):
        if d[chr(97+x)]>=num[i]:
            d[chr(97+x)]-=num[i]
            break

for x in range(26):
    if d[chr(97+x)]>=1:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 74840
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7, N = 2 * 1e5 + 10;
	ll n;
  	ll a[N], q[N];
	ll sum = 0;
int main(){
    q[0] = 0;
    a[0] = 0;
  	cin >> n;//输入n
  	for(int i = 1; i <= n; i ++){
     	cin >> a[i] ;//输入所有的数
      	a[i] %= mod;//然后先mod,原数组;
      	q[i] = (q[i - 1] +a[i]) % mod;//前缀和数组
      	sum = (sum + (a[i] * q[i - 1] % mod)) % mod ;
        
    }
  cout << sum;
  return 0;
}

Measured memory_bytes: 6280
N, K = map(int, input().split())
S = input()

ans = ""
for i in range(N):
    if i == K-1 and S[i] == "A":
        ans += "a"
    elif i == K-1 and S[i]  == "B":
        ans += "b"
    elif i == K-1 and S[i]  == "C":
        ans += "c"
    else:
        ans += S[i]
print(ans)

Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<cassert>
#include<string>
#include<cmath>
#include<climits>
#include<cfloat>
#include<algorithm>
#include<vector>
using namespace std;
#define MAX 500000

typedef pair<int, int> P;

int N;
P A[MAX];

bool compare_y(P a, P b){
  return a.second < b.second;
}

int closest_pair(P *a, int n){
  if ( n <= 1 ) return INT_MAX;
  int m = n / 2;
  int x = a[m].first;
  int d = min(closest_pair(a, m), closest_pair(a + m, n - m));
  inplace_merge(a, a + m, a + n, compare_y);
  
  vector<P> b;
  for ( int i = 0; i < n; i++ ){
    if ( fabs(a[i].first - x) >= d ) continue;
    for ( int j = 0; j < b.size(); j++ ){
      int dx = a[i].first - b[b.size() - j - 1].first;
      int dy = a[i].second - b[b.size() - j -1 ].second;
      if ( dy >= d ) break;
      d = min(d, dx*dx + dy*dy);
    }
    b.push_back(a[i]);
  }
  return d;
}

main(){
  cin >> N;
  assert (2 <= N && N <= 500000);
  for  ( int i = 0; i < N; i++ ){
    scanf("%d %d", &A[i].first, &A[i].second);
  }

  sort(A, A + N );
  //printf("%.10lf\n", closest_pair(A, N));
  printf("%d\n", closest_pair(A, N));
}

Measured memory_bytes: 10752
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>

using namespace std;

#define gettime printf("\nTime : %0.3lf\n",clock()*1.0/CLOCKS_PER_SEC);
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repp(i,a,b) for(int i=a;i>=b;i--)
#define Set(x,a) memset(x,a,sizeof(x));

#define vs vector<string>
#define vi vector<int>
#define ll long long
#define ff first
#define ss second

struct comp {
       bool operator() (int a,int b) {
            return a>b;
       }
};

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //std::ios::sync_with_stdio(false);
    int n;
    int a[10005];
    int b[10005];
    ll needA = 0, needB = 0;
    bool valid = true;
    scanf("%d", &n);
    rep (i,1,n) scanf("%d", &a[i]);
    rep (i,1,n) scanf("%d", &b[i]);
    rep (i,1,n) {
        if (a[i] < b[i]) needA += (b[i] - a[i]) / 2;
        else needB += a[i] - b[i];
        if (b[i] > a[i] && (b[i] - a[i]) % 2 != 0) {
            needA++;
            needB++;
        }
    }
    if (valid && needA >= needB) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 384