akhauriyash/Code-Regression huggingface dataset:
// inputに入力データ全体が入る
function Main(input) {
  input = input.split(" ");
  var maisu = parseInt(input[0]);
  var sum = parseInt(input[1]);
  var returnFlag = false;
  
  var senCount = 0;
  var gosenCount = 0;
  var manCount = 0;
  
  //合計金額から考えられる最大枚数
  var maxSenCount = parseInt(sum / 1000);
  if(maxSenCount > 2000){
     maxSenCount = 2000;
     }
  var maxGosenCount = parseInt(sum / 5000);
  if(maxGosenCount > 2000){
     maxGosenCount = 2000;
     }
  var maxManCount = parseInt(sum / 10000);
  
  if(maxManCount == maisu && maxManCount * 10000 == sum){
    manCount = maxManCount;
    returnFlag = true;
  }
  if(maxGosenCount == maisu && maxGosenCount * 5000 == sum){
    gosenCount = maxGosenCount;
    returnFlag = true;
  }
  if(maxSenCount == maisu && maxSenCount * 1000 == sum){
    senCount = maxSenCount;
    returnFlag = true;
  }
  
  if(!returnFlag){
  for(var i = 0; i <= maxManCount; i++){
    var tmpSum1 = 10000 * i;
    if(tmpSum1 > sum){
    	break;
    }
    for(var j = 0; j <= maxGosenCount - i; j++){
      var tmpSum2 = 10000 * i + 5000 * j;
   	  if(tmpSum2 > sum){
    	break;
      }
      for(var k = 0; k <= maxSenCount - i - j; k++){
        var tmpSum3 = 10000 * i + 5000 * j + 1000 * k;
        if(10000 * i + 5000 * j + 1000 * (maxSenCount - i - j) < sum){
           break;
           }
        if(tmpSum3 > sum){
           break;
           }
        if(tmpSum3 == sum && (i + j + k) == maisu){
           senCount = k;
           gosenCount = j;
           manCount = i;
           }
      }
    }
  }
}
  if(senCount == 0 && gosenCount == 0 && manCount == 0){
     console.log("-1 -1 -1");
  }else{
     console.log(manCount + " " + gosenCount + " " + senCount);
  }
  
  
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int r, g, b, n;
	cin >> r >> g >> b >> n;

	int ans = 0;
	for (int i = 0; i <= n; ++i)
		for (int j = 0; j <= n; ++j)
			if (i*r+j*g <= n && (n-i*r-j*g) % b == 0)
				++ans;

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  int x,y;
  cin>>x>>y;
  if((y-2*x>=0)&&(4*x-y)>=0 && (y-2*x)%2==0 && (4*x-y)%2==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#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 loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
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(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int a, b, c, d; cin >> a >> b >> c >> d;
  Yes((abs(c-a)<=d) or ((abs(b-a)<=d) and (abs(c-b)<=d)));


    return 0;
}


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

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


int main(){
  int n,x;
  int a[100100];
  int kyori[100100];
  
  cin >> n >> x;
  for(int i = 0;i < n;i++){
    cin >> a[i];
    kyori[i] = abs(x-a[i]);
  }
  if(n >= 2){
    int k;
    for(int i = 1;i < n;i++){
      k = gcd(kyori[0],kyori[i]);
      kyori[0] = k;
    }
    cout << k << endl;
  }
  else{
    cout << kyori[0] << endl;
  }
}

Measured memory_bytes: 1024
n=int(input())
ans=float("inf")
for i in range(1,n):
  a=0
  for j in range(len(str(i))):
    a+=int(str(i)[j])
  for j in range(len(str(n-i))):
    a+=int(str(n-i)[j])
  ans=min(ans,a)
print(ans)

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    int N;
    cin>>N;
    vector<int> b(N-1);
    rep(i,N-1) cin>>b[i];
    ll ans=b[0];
    for(int i=1;i<N-1;i++){
        ans+=min(b[i-1],b[i]);
    }
    ans+=b[N-2];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        try (Scanner sc = new Scanner(System.in)) {
            while (true) {
                int n = sc.nextInt();
                if (n == 0) {
                    break;
                }
                int[] scores = new int[n];
                for (int i = 0; i < scores.length; i++) {
                    scores[i] = sc.nextInt();
                }
                int sum = 0;
                double average = 0, variance = 0, sumf = 0;
                // … 平均値averageと，分散varianceを計算しよう …
                for (int i = 0; i < scores.length; i++) {
                    sum += scores[i];
                }
                average = (double) sum / (double) scores.length;
                for (int i = 0; i < scores.length; i++) {
                    sumf += ((double) scores[i] - average) * ((double) scores[i] - average);
                }
                variance = sumf / (double) scores.length;
                System.out.println(Math.sqrt(variance));
            }
        }
    }
}


Measured memory_bytes: 31592
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void)
{
    int N, K, count = 0, itr, _max = 0;
    double res = 0;
    scanf("%d%d", &N, &K);

    vector<int> P(N);

    for (int i = 0; i < N; i++){
        scanf("%d", &P[i]);
        count += P[i];
        if (i >= K) count -= P[i - K];
        if (_max < count){
            itr = i;
            _max = count;
        }
    }

    for (int i = 0; i < K; i++){
        res += (P[itr - i] + 1) / 2.0;
    }
    printf("%lf", res);
    return 0;
}



Measured memory_bytes: 1024
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int n;  cin >> n;
  double x, ans = 0.0;
  string u;
  rep0(i,n){
    cin >> x >> u;
    if(u == "BTC"){
      ans += (double)x*380000.0;
    }else{
      ans += x;
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define sc(x) scanf("%d", &x)
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ALL(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define ABS(x) ((x)>=0?(x):(-(x)))
#define fastio ios::sync_with_stdio(0),cin.tie(0)
template<class T>T gcd(T a, T b){return b?gcd(b, a%b):a;}

int main()
{
    int n;
    sc(n);
    int sum = 0, mx = 0;
    for(int i = 0; i < n; i++){
        int x;
        sc(x);
        sum += x;
        mx = max(mx, x);
    }
    if(sum-mx > mx)puts("Yes");
    else puts("No");
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int[] a = new int[3];
        
        for(int i = 0; i < 3; i++) a[i] = sc.nextInt();
        
        Arrays.sort(a);
        
        System.out.println(a[0]+a[1]);
    }
}


Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    long long int n;
    vector<pair<string,int>>a(1000);
    vector<pair<string,int>>b(1000);
    cin>>n;
    for(long long int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second;
        a[i].second*=-1;
        b[i].first=a[i].first;
        b[i].second=a[i].second;
    }
    sort(a.begin(),a.end(),greater<>());
    for(long long int i=0;i<n;i++){
        for(long long int j=0;j<n;j++){
            if(a[n-1-i].first==b[j].first&&a[n-1-i].second==b[j].second){
                cout<<j+1<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static readonly int[][] di=new int[][]{new int[]{-1,0},new int[]{1,0},new int[]{0,-1},new int[]{0,1}};
	static int[] s;
	static string[] st;
	static char[][] c1,c2;
	static void Main(){
		Sc sc=new Sc();
		s=sc.Ia;
		st=new string[s[0]];
		c1=new char[s[0]][];
		c2=new char[s[0]][];
		for(int i = 0;i<s[0];i++){
			st[i]=sc.S;
			if(i%2==0){
				c1[i]=(new string('#',s[1]-1)+".").ToCharArray();
				c2[i]=new string('.',s[1]).ToCharArray();
			}
			else{
				c1[i]=new string('.',s[1]).ToCharArray();
				c2[i]=("."+new string('#',s[1]-1)).ToCharArray();
			}
			c1[i][0]='#';
			c2[i][s[1]-1]='#';
			for(int j = 0;j<s[1];j++){
				if(st[i][j]=='#'){c1[i][j]='#';c2[i][j]='#';}
			}
		}
		for(int i = 0;i<s[0];i++){Console.WriteLine(String.Join("",c1[i]));}
		Console.WriteLine();
		for(int i = 0;i<s[0];i++){Console.WriteLine(String.Join("",c2[i]));}
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 19524
#include<stdio.h>
int main()
{
	char x[5];
	scanf("%s",x);
	if((x[0]==x[1]&&x[1]==x[2])||x[1]==x[2]&&x[2]==x[3])
		printf("Yes\n");
	else
		printf("No\n");

	
	return 0;
}

Measured memory_bytes: 128
A, B, C, X, Y = list(map(int, input().split()))

Ans = 0
if A > C * 2:
  Ans += C * (X * 2)
  Y -= X
  X = 0
if B > C * 2:
  Ans += C * (Y * 2)
  X -= Y
  Y = 0
X = max(0, X)
Y = max(0, Y)
if A + B > C * 2:
  t = min(X, Y)
  Ans += C * (t * 2)
  X -= t
  Y -= t
if X > 0:
  Ans += A * X
if Y > 0:
  Ans += B * Y

print(Ans)

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

int main()
{
  std::string S;
  std::cin >> S;
  bool YYMM, MMYY;
  if ((S[0] == '0' && S[1] != '0') || (S[0] == '1' && S[1] < '3')) MMYY = true;
  else MMYY = false;
  if ((S[2] == '0' && S[3] != '0') || (S[2] == '1' && S[3] < '3')) YYMM = true;
  else YYMM = false;
  // std::cout << YYMM <<" "<<MMYY<<std::endl;
  if (YYMM)
  {
    if (MMYY) std::cout << "AMBIGUOUS" << std::endl;
    else std::cout << "YYMM" << std::endl;
  }
  else
  {
    if (MMYY) std::cout << "MMYY" << std::endl;
    else std::cout << "NA" << std::endl;
  }
}


Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,m;
string s,c,ss,ans="~";
int main(){
	cin>>s>>c;
    n=s.size();
    m=c.size();
    for(int i=0;i<=n-m;i++){
        bool flag=0;
        for(int j=0,k=i;j<m;j++,k++){
            if(c[j]!=s[k]&&s[k]!='?'){
                flag=1;
                break;
            }
        }
        if(flag)continue;
        ss=s;
        for(int j=0;j<m;j++)ss[i+j]=c[j];
        for(int j=0;j<n;j++){
            if(ss[j]=='?')ss[j]='a';
        }
        ans=min(ans,ss);
    }
    if(ans=="~")puts("UNRESTORABLE");
    else cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String N = sc.next();
		char seven = '7';
		if(N.charAt(0) == seven
			|| N.charAt(1) == seven
			|| N.charAt(2) == seven) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 26928
year, month, day = map(int, input().split("/"))
if year < 2019:
    print("Heisei")
elif year > 2019:
    print("TBD")
elif month < 4:
    print("Heisei")
elif month > 4:
    print("TBD")
elif day <= 30:
    print("Heisei")
else:
    print("TBD")

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

using namespace std;
using ll = long long;

#define INF (1LL << 60)

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i,0,N) cin >> A[i];

    sort(ALL(A));
    bool f = true;
    REP(i,0,N-1) {
        if(A[i] == A[i+1]) {
            f = false;
            break;
        }
    }

    if(f) _PR("YES");
    else _PR("NO");

    return 0;
}

/*



*/

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j,k;
  int n,m,r;
  cin>>n>>m>>r;
  vi v(r);
  rep(i,r)cin>>v[i];
  sort(all(v));
  vector<vi> dp(n+1,vi(n+1,INF));
  rep(i,n+1)dp[i][i]=0;
  rep(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    dp[a][b]=c;
    dp[b][a]=c;
  }
  rep(k,n+1)rep(i,n+1)rep(j,n+1)dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
  ll ans=(ll)INF*INF;
  do{
    ll tmp=0;
    rep(i,r-1)tmp+=dp[v[i]][v[i+1]];
    ans=min(ans,tmp);
  }while(next_permutation(all(v)));
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>
#include <functional>

using namespace std;
using ll = long long;

#define all(x) (x).begin(),(x).end()
#define PRI(n) cout << n << " "<<endl;
#define PRI2(n, m) cout << n << " " << m << " "<<endl;

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

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;

struct edge;
struct UnionFind;

bool isPrime(ll x);

ll GCD(ll a, ll b);

ll LCM(ll a, ll b);

ll nCr(int n, int r);


struct UnionFind {
    vector<int> par;
    vector<int> rank;

    UnionFind(int N) {
        for (int i = 0; i < N; ++i) {
            par.push_back(i);
            rank.push_back(0);
        }
    }

    int find(int x) {
        if (par[x] == x)return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)return;
        if (rank[x] < rank[y])par[x] = y;
        else {
            par[y] = x;
            if (rank[x] == rank[y])rank[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

ll M, N;

int main() {
    ll H, W, x, y;
    cin >> H >> W >> x >> y;
    int ans = 0;
    if (x == 0 || y == 0)ans = 0;
    else if (x * 2 == H && y * 2 == W)ans = 1;
    printf("%10f %d", double(H) * double(W) / 2, ans);
    return 0;
}

struct edge {
    int to, cost;
    bool flag = false;
};

bool isPrime(ll x) {
    if (x == 0)return 0;
    if (x == 1)return 0;
    if (x == 2)return 1;
    if (x % 2 == 0)return 0;
    FOR(i, 3, x - 1) {
        if (x % i == 0)return 0;
    }
    return 1;
}

ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) for (int j = min(i, r); j < 1; --j)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = a + b;
    int tmp = a - b;
    ans = max(ans, tmp);
    tmp = a * b;
    ans = max(ans, tmp);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
using namespace std;
const int maxn = 55;
int x[maxn];
int n;
map<int,int> Q;
int main()
{
    cin>>n;
    int sum = 0;
    int max1 = -1e6-5;
    int min1 = 1e6+5;
    int now = 0;
    for(int i=1;i<=n;i++)
    {
        cin>>x[i];
        Q[x[i]]=i;
        max1 = max(max1,x[i]);
        min1 = min(min1,x[i]);
    }
    if(abs(min1)>abs(max1))now = 1;
    if(min1<=0&&max1>=0)
    {
        cout<<2*n-1<<endl;
        for(int i=1;i<=n;i++)
        {
            if(now)cout<<Q[min1]<<" "<<i<<endl;
            else cout<<Q[max1]<<" "<<i<<endl;
        }
    }
    else cout<<n-1<<endl;
    if(now)
    {
        for(int i=n;i>1;i--)
        {
            cout<<i<<" "<<i-1<<endl;
        }
    }
    else
    {
        for(int i=2;i<=n;i++)
        {
            cout<<i-1<<" "<<i<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import sys

t = 'eraser, erase, dreamer, dream'.split(', ')
def obtainable(s):
    for x in t:
        s = s.replace(x, '')
    return not s

s = sys.stdin.readline().rstrip()

def main():
    print("YES" if obtainable(s) else "NO")

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3188
n=int(input())
k=[]
for i in(range(n)):
  k.append(str(input()))
ac=k.count('AC')
wa=k.count('WA')
tle=k.count('TLE')
re=k.count('RE')
print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)

Measured memory_bytes: 16196
#!/usr/bin/env python3
import sys


def solve(c: "List[str]"):
    print(c[0][0] + c[1][1] + c[2][2])
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    c = [next(tokens) for _ in range(3)]  # type: "List[str]"
    solve(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
# AtCoder Beginner Contest 138 D - Ki　
import sys
sys.setrecursionlimit(10 ** 9)

N, Q = map(int, sys.stdin.readline().strip().split())

M = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = map(int, sys.stdin.readline().strip().split())
    M[a - 1].append(b - 1)
    M[b - 1].append(a - 1)

X = [0] * N
for _ in range(Q):
    p, x = map(int, sys.stdin.readline().strip().split())
    X[p - 1] += x


ans = [0] * N


def dfs(u, parent=None):

    ans[u] = ans[parent] + X[u]

    for v in M[u]:
        if v != parent:
            dfs(v, u)


dfs(0, 0)
print(' '.join([str(i) for i in ans]))


Measured memory_bytes: 275240
def slove():
    import sys
    input = sys.stdin.readline
    x, a, b = list(map(int, input().rstrip('\n').split()))
    if b - a <= 0:
        print("delicious")
    elif b - a <= x:
        print("safe")
    else:
        print("dangerous")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>

using namespace std;

int main(void) {

	int r, D, a;
	cin >> r >> D >> a;
	int i = a;

	for (int j = 1; j <= 10; j++) {
		int ans = r * i - D;

		i = ans;
		cout << ans << endl;
	}


	return 0;
}

Measured memory_bytes: 256
l  =[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(l[int(input())-1])

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

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

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

#define endl '\n'
#define re return

#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define repd(i,a,b) for (ll i = (a); i >= b; i--)
#define repdz(i,a) for (ll i = a; i >=0; i--)
#define trav(a, x) for (auto& a : x)

#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define llin(a) ll a; cin>>a;
#define llin2(a,b) ll a,b; cin >>a>>b;
#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c;
#define full(v) v.begin(),v.end()

void solve()
{
    int n;
    cin >> n;
    vi a(n),b(n),c(n);
    repz(i,n)
    {
        cin >> a[i] >> b[i] >> c[i];
    }

    int dp[3][n+7];
    dp[0][0]=a[0];
    dp[1][0]=b[0];
    dp[2][0]=c[0];

    rep(i,1,n)
    {
        dp[0][i]= a[i]+max(dp[1][i-1],dp[2][i-1]);
        dp[1][i]= b[i]+max(dp[0][i-1],dp[2][i-1]);
        dp[2][i]= c[i]+max(dp[0][i-1],dp[1][i-1]);
    }
    cout << max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
}
int main()
{
    ios_base::sync_with_stdio(false);
    //llin(t);
    //while (t--)
    //{
        solve();
    //}
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i,l,r) for(int i=l;i<=r;i++)
vector<int>adj[100001];
int vis[100001]={0};
int dp[100001];
int dfs(int i)
{  //cout<<i<<endl;
    vis[i]=1;
    if(adj[i].size()==0)
        return dp[i]=0;
            

    int c=INT_MIN;
    for(auto j : adj[i])
    {    

        if(!vis[j])
            {c=max(dfs(j),c);}
        else {
            c=max(c,dp[j]);
        }
    }
    
    return dp[i]=c+1;
}
signed main()
{  // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
    }
   memset(dp,-1,sizeof(dp));
  
  for(int i=1;i<=n;i++)
   dfs(i);

int ans=INT_MIN;
for(int i=1;i<=n;i++)
   ans=max(ans,dp[i]);
cout<<ans<<endl;

   


    return 0;
}

Measured memory_bytes: 9344
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    big = pow(10, 18)
    ret = 1
    if 0 in A:
        print(0)
        return
    for a in A:
        ret *= a
        if ret > big:
            print(-1)
            return
    print(ret)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Measured memory_bytes: 87216
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
   int n,m;
   cin >> n >> m;
   vector<int> oks(n + 1,true);
   for(int i = 0;i < m;i++){
         int a;
         cin >> a;
         oks[a] = false;
   }
   
   vector<long long int> dp(n + 1);
   dp[0] = 1;
   for(int i = 0;i < n;i++){
         for(int j = i + 1;j <= min(n,i + 2);j++){
               if(oks[j]){
                     dp[j] += dp[i];
                     dp[j] %= long(1e9 + 7);
               }
         }
   }
   cout << dp[n] << endl;
}


Measured memory_bytes: 4552
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;


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


int main() {
    int N;
    cin >> N;
    
    if ( N == 3 ) {
        cout << 2 << " " << 5 << " " << 63 << endl;
        return 0;
    }
    else if ( N == 4 ) {
        cout << 2 << " " << 5 << " " << 20 << " " << 63 << endl;
        return 0;
    }

    vector<int> ans(N);
    int a = 0;
    for ( int i = 3; i <= 30000; i += 3 ) {
        if ( N%2 && i == 30000 ) { break; } 
        ans[a] = i;
        a++;
        if ( ( a%4 == 3 || a%4 == 0 ) &&  ( N-a == 4 || N-a == 2 ) ) { break; }        
    }
    

    for ( int i = 2; i <= 30000; i += 2 ) {
        if ( i%3 == 0 ) { continue; }
        ans[a] = i;
        a++;
        if ( a == N ) { break; }
    }

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

    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

struct Edge{
public:
  int from,to,cost;
  Edge(){}
  Edge(int _from,int _to,int _cost){
    from = _from;
    to = _to;
    cost = _cost;
  }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;


const int EPS = 1e-9;
const int MOD = 1e9+7;



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin >> n){
    TSTART();
    ll ans = 1;
    REP(i,n){
      ans *= i + 1;
      ans %= MOD;
    }
    cout << ans << endl;
    TSTOP();
  }
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int c[3][3];
  rep(i,3)rep(j,3)cin>>c[i][j];
  int a1,a2,a3;
  rep(a1,101)rep(a2,101)rep(a3,101){
    int b1=c[0][0]-a1;
    int b2=c[0][1]-a1;
    int b3=c[0][2]-a1;
    if(a2+b1==c[1][0] && a2+b2==c[1][1] && a2+b3==c[1][2] &&
       a3+b1==c[2][0] && a3+b2==c[2][1] && a3+b3==c[2][2]){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;

}


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

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

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

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

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

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

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

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

int main(){
    while (1) {
        int w, h;
        cin >> w >> h;
        if (w==0 && h==0) break;
        vs wall(2*h-1);
        cin.ignore();
        rep(i, sz(wall)) getline(cin, wall[i]);
        vector<vi> dist(h, vi(w, INF));
        auto bfs = [&] () {
            dist[0][0] = 1;
            int d = 1;
            bool flug = true;
            while (flug) {
                flug = false;
                rep(y, h) rep(x, w) {
                    if (dist[y][x] != d) continue;
                    const vi dy = { -1, 0, 1, 0 }, dx = { 0, 1, 0, -1 };
                    rep(i, 4) {
                        int ny = y + dy[i], nx = x + dx[i];
                        if (ny<0 || ny>=h || nx<0 || nx>=w) continue;
                        if (wall[y+ny][x+nx]=='1') continue;
                        if (dist[ny][nx]!=INF) continue;
                        dist[ny][nx] = d + 1;
                        if (ny==h-1 && nx==w-1) return;
                        flug = true;
                    }
                }
                ++d;
            }
        };
        bfs();
        int ans = dist[h-1][w-1];
        if (ans==INF) ans = 0;
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3188
n = int(input())

hap = [[0] for i in range(n)]
for i in range(n):
  hap[i] = [int(i) for i in input().split()]
  
dp = [[0]*3 for i in range(n)]
for i in range(3):
  dp[0][i] = hap[0][i]
  
for i in range(1, n):
  for j in range(3):
    dp[i][j] = max(dp[i-1][(j+1)%3]+hap[i][j], dp[i-1][(j+2)%3]+hap[i][j])
print(max(dp[n-1]))
     


Measured memory_bytes: 44100
#include<stdio.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
int main(void)
{
  int N,total=0,ope=0;char stones[200001]={0};if(!scanf("%d %s",&N,stones))return-1;
  rep(i,N){if(stones[i]=='R')total++;} 
  ope=total;rep(i,total){if(stones[i]=='R')ope--;}
  return printf("%d\n",ope),0;
}

Measured memory_bytes: 1924
x, y, X, Y = map(int, input().split())
ans = ''
kyori_x = X - x
kyori_y = Y - y
ans += 'R' * kyori_x + 'U' * kyori_y
ans += 'L' * kyori_x + 'D' * kyori_y
ans += 'L' + 'U' * (kyori_y + 1) + 'R' * (kyori_x + 1) + 'D'
ans += 'R' + 'D' * (kyori_y + 1) + 'L' * (kyori_x + 1) + 'U'
print(ans)

Measured memory_bytes: 3060
N = int(input())
A = list(map(int,input().split()))

ans = 1
up = None
for a,b in zip(A,A[1:]):
    if a==b: continue
    if up is None:
        up = a<b
    elif up:
        if a>b:
            up = None
            ans += 1
    else:
        if a<b:
            up = None
            ans += 1
print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
using namespace std;
const int N=205;
int n,a[N],ans;
int main(){
	scanf("%d",&n); n*=2;
	rep (i,1,n) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for (int i=1;i<=n;i+=2) ans+=a[i];
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
n, k = gets.chomp.split.map(&:to_i)
book = Hash.new(0)
n.times do |_|
  a, b = gets.chomp.split.map(&:to_i)
  book[a] += b
end
arr = book.to_a.sort_by! {|key, val| key }
res = -1
arr.each do |key, val|
  break if k <= 0
  res = key
  k -= val
end
puts res

Measured memory_bytes: 11000
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n;
    string s;

    cin >> n >> s;

    int mi = 1000;
    int cnt = 0;

    REP(i, n)
    {
        if (s[i] == '(')
            cnt++;
        else
            cnt--;

        mi = min(mi, cnt);
    }

    if (mi < 0)
        cnt -= mi;

    REP(i, -mi)
    cout << "(";
    cout << s;
    REP(i, cnt)
    cout << ")";

    cout << endl;

    return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int a, b, c, d, n, x, y;
    string s, t;


    auto Yes = [&](bool t){
        cout << (t ? "Yes" : "No") << endl;
    };
    auto YES = [&](bool t){
        cout << (t ? "YES" : "NO") << endl;
    };
    auto tri = [&](bool t, string a, string b){
        cout << (t ? a : b) << endl;
    };

    cin >> s;
    for(int i = 0; i < 3; ++i){
        if(s[i] == '1')
            s[i] = '9';
        else if(s[i] == '9')
            s[i] = '1';
    }
    cout << s << endl;
}


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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }




signed main() {

	int A, B;
	cin >> A >> B;

	int ans = (B - 1+A-2) / (A - 1);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <iomanip>
#include <unordered_map>
#include <string>
#include <unordered_set>
using namespace std;
typedef long long ll;
const int N = 200010;
ll n, h[N];
int main() {
    cin >> n;
    for(ll i = 1; i <= n; i ++) {
        cin >> h[i];
    }
    unordered_map<ll, ll> cnts;
    ll res = 0;
    for(ll i = 1; i <= n; i ++) {
        res += cnts[i - h[i]];
        cnts[h[i] + i] ++;
    }
    cout << res << endl;
    return 0;
}

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

int main() {
    int n, k; cin >> n >> k;
    vector<int> p(n);
    rep (i, n) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    for(int i = 0; i < k; i++) {
        ans += p[i];
    }
    cout << ans << endl;;
}

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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n,k; cin>>n>>k;
    vi arr(n);
    FOR(i, 0, n) {
        cin>>arr[i]; arr[i]--;
    }
    ll res = 0; map<int, ll> cnt; cnt[0] = 1;
    ll prefs[n + 1]; prefs[0] = 0;
    FOR(i, 0, n) {
        prefs[i + 1] = (prefs[i] + arr[i])%k;
        if(i >= k - 1) {
            cnt[prefs[i - k + 1]]--;
        }
        if(cnt.count(prefs[i + 1])) {
            res += 1LL * cnt[prefs[i + 1]];
            cnt[prefs[i + 1]]++;
        } else {
            cnt.insert({prefs[i + 1], 1});
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 17964
N = int(input())
As = []
AsNum = []
for i in range(N):
	A = []
	AsNum.append(int(input()))
	for j in range(AsNum[i]):
		A.append(list(map(int, input().split())))
	As.append(A)

noContradiction = []
Ans = 0
for bit in range(2**N):
	honest = []
	for i in range(N):
		if bit >> i & 1 == 1:
			honest.append(1)
		else:
			honest.append(0)
	flag = True
	for i in range(N):
		if honest[i]:
			for saying in As[i]:
				if ((saying[1] == 1 and honest[saying[0] - 1] == 0)
					or (saying[1] == 0 and honest[saying[0] - 1] == 1)):
					flag = False
					break
		if not flag:
			break
	if flag:
		Ans = max(Ans, sum(honest))
print(Ans)

Measured memory_bytes: 3192
#!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile

INF = float("inf")


def read(
    *shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def readi(*shape):
    return read(*shape)


def readi1(*shape):
    return [i - 1 for i in readi(*shape)]


def readf(*shape):
    return read(*shape, f=float)


def reads(*shape):
    return read(*shape, f=str)


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[0]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def main():
    N = readi()
    S = reads()
    print("".join(chr((ord(c) + N + 13) % 26 + 65) for c in S))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

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

    int n=s.size();
    rep(i,n-1){
        if(s[i]==s[i+1]){
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }
    }

    rep(i,n-2){
        if(s[i]==s[i+1] || s[i+1]==s[i+2] || s[i]==s[i+2]){
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }

    cout<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 3736
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    if(n<=2){
        cout<<-1<<endl;
        return 0;
    }
    if(n==3){
        cout<<"aab"<<endl;
        cout<<"c.b"<<endl;
        cout<<"cdd"<<endl;
        return 0;
    }
    vector<int> vx(n),vy(n),hx(n),hy(n);
    if(n%2==0){
        rep(i,n)vx[i]=i;
        rep(i,n)vy[i]=(i/2)*2;
        rep(i,n)hx[i]=(i/2)*2;
        rep(i,n)hy[i]=i;
    }
    else {
        rep(i,n)vx[i]=i;
        vx[1]=n-1;
        rep(i,n)vy[i]=i;
        vy[n-1]=0;
        rep(i,n)hy[i]=i;
        hy[1]=n-1;
        rep(i,n)hx[i]=i;
        hx[n-1]=0;
    }
    vector<vector<int>> ans(n,vector<int>(n,0));
    while(1){
        random_shuffle(vx.begin(),vx.end());
        random_shuffle(hx.begin(),hx.end());
        bool ok = true;
        rep(i,n){
            if(ans[vx[i]][vy[i]]||ans[vx[i]][vy[i]+1]){
                ok=false;
                break;
            }
            ans[vx[i]][vy[i]]=i+1;
            ans[vx[i]][vy[i]+1]=i+1;
        }
        rep(i,n){
            if(ans[hx[i]][hy[i]]||ans[hx[i]+1][hy[i]]){
                ok=false;
                break;
            }
            ans[hx[i]][hy[i]]=n+i+1;
            ans[hx[i]+1][hy[i]]=n+i+1;
        }
        if(ok)break;
        rep(i,n){
           ans[vx[i]][vy[i]]=0;
            ans[vx[i]][vy[i]+1]=0; 
        }
        rep(i,n){
            ans[hx[i]][hy[i]]=0;
            ans[hx[i]+1][hy[i]]=0;
        }
    }
    vector<string> s(n);
    rep(i,n){
        rep(j,n){
            if(!ans[i][j])s[i]+='.';
            else if(i>0 && ans[i-1][j]==ans[i][j])s[i]+=s[i-1][j];
            else if(j>0 && ans[i][j-1]==ans[i][j])s[i]+=s[i][j-1];
            else s[i]+=char('a'+(i%5*5+j%5));
        }
    }
    rep(i,n)cout<<s[i]<<endl;
    return 0;
}

Measured memory_bytes: 6272