akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef struct node
{
    LL x,y;
    LL val;
}point;
point num[100006];
LL maxa[100006];
LL maxb[100006];
int main(void)
{
   LL n,c;
   scanf("%lld %lld",&n,&c);
   for(int i = 1;i <= n;i++)
   scanf("%lld %lld",&num[i].x,&num[i].val),num[i].y = c - num[i].x;
   num[0].x = 0;
   num[n+1].x = 0;
   num[0].y = 0;
   num[n+1].y = 0;
   for(int i = 0;i < 100006;i++)
    maxa[i] = 0,maxb[i] = 0;
   maxa[0] = 0,maxb[0] = 0;
   LL maxx = 0;
   for(int i = 1;i <= n;i++)
   {
       maxa[i] = num[i].val - abs(num[i].x - num[i-1].x) + maxa[i-1];
       maxx = max(maxx,maxa[i]);
   }
   for(int i = n;i >= 1;i--)
   {
       maxb[i] = num[i].val - abs(num[i].y - num[i+1].y) + maxb[i+1];

       maxx = max(maxx,maxb[i]);
   }
   LL maxq = 0;
   for(int i = n - 1;i >= 1;i--)
   {
      maxq = max(maxq,maxb[i+1]);
      maxx = max(maxa[i] + maxq - num[i].x,maxx);
      //printf("%lld\n",maxa[i] + maxq - num[i].x);
   }
   maxq = 0;
   for(int i = 2;i <= n;i++)
   {
       maxq = max(maxq,maxa[i-1]);
       maxx = max(maxb[i] + maxq - num[i].y,maxx);
   }
   printf("%lld\n",maxx);
   return 0;
}


Measured memory_bytes: 4096
// Code by ajcxsu
// Geometry template

#include<bits/stdc++.h>
#define EPS (1e-9)
using namespace std;

struct Point {
    double x,y;
    Point(double x=0,double y=0):x(x), y(y) {}

    Point operator +(Point p) { return Point(x+p.x,y+p.y); }
    Point operator -(Point p) { return Point(x-p.x,y-p.y); } // 加减
    Point operator *(double a) { return Point(x*a,y*a); }
    Point operator /(double a) { return Point(x/a,y/a); } // 数乘

    double norm() { return x*x+y*y; } // 范数
    double abs() { return sqrt(norm()); } // 大小

    bool operator < (const Point &p) { return x!=p.x?x<p.x:y<p.y; }
    bool operator == (const Point &p) { return fabs(p.x-x) < EPS && fabs(p.y-y) < EPS; }
} ;
typedef Point Vector;

double dot(const Point &a, const Point &b) {
    return a.x*b.x+a.y*b.y;
} // 内积
double cross(const Point &a, const Point &b) {
    return a.x*b.y-a.y*b.x;
} // 外积
bool equals(double a, double b) { return fabs(a-b)<EPS; } // 误差相等

struct Line {
    Point p1,p2;
} ;
typedef Line Seg;

/* 1 正交 2 平行 0 其他 */
int PO(Vector a, Vector b) {
    if(equals(dot(a,b), 0)) return 1;
    else if(equals(cross(a,b), 0)) return 2;
    else return 0;
}
int PO(Line a, Line b) { // 正交、平行判定
    return PO(a.p2-a.p1, b.p2-b.p1);
}

istream& operator >>(istream &in, Vector &a) {
    in>>a.x>>a.y;
    return in;
}
istream& operator >>(istream &in, Line &a) {
    in>>a.p1>>a.p2;
    return in;
}

int main() {
    ios::sync_with_stdio(false);
    int q;
    cin>>q;
    while(q--) {
        Seg a,b;
        cin>>a>>b;
        cout<<PO(a,b)<<endl;
    }
    return 0;
}



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

//#define cin fin
//#define cout fout
#define ld long double 
#define pb push_back
#define F first
#define S second 
#define ll long long

using namespace std;

const int N = 2e5 + 1e3 , SQ = 440 ; 

int32_t main()
{
	ios::sync_with_stdio(0) ; cin.tie(0) ; 
	ll n , k ; 
	cin >> n >> k ; 
	ll ans = 1900 * k + (n-k) * 100 ; 
	for(int i = 0 ; i < k ; i ++ ) 
		ans *= 2 ; 
	cout << ans << endl ; 
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int n;
  cin >> n;
  int ans = 0;
  FOR(i, 1, n + 1)
  {
    if (0 < i && i < 10)
    {
      ans++;
    }
    if (99 < i && i < 1000)
    {
      ans++;
    }
    if (9999 < i && i < 100000)
    {
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main() {
    string s;
    cin >> s;
    set<char> st;
    for (int i = 0; i < s.size(); i++) {
        st.insert(s[i]);
    }

    for (char i = 'a'; i <= 'z'; i++) {
        if (st.find(i) == st.end()) {
            cout << i << endl;
            return 0;
        }
    }

    cout << "None" << endl;

    return 0;
}


Measured memory_bytes: 512
def main
  while (n = gets.to_i) != 0
    array = Array.new(n + 1)
    array[0] = Array.new(n + 1, 0)
    n.times do |i|
      array[i + 1] = [0] + gets.chomp.split(//).map{|c|(c == ".") ? 1:0}
    end
    max = 0
    for x in 1..n
      for y in 1..n
        array[x][y] = [array[x - 1][y - 1], array[x - 1][y], array[x][y - 1]].min + 1 if array[x][y] == 1
        max = (max > array[x][y]) ? max : array[x][y]
      end
    end
    puts max
  end
end
main

Measured memory_bytes: 27216
#include <stdio.h>

int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if (a + b + c >= 22)
    {
        printf("%s", "bust\n");
    }
    else
    {
        printf("%s", "win\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    int a , b , d;
    char c;
    scanf("%d %c %d",&a,&c,&b);
    if(c=='-')
    {
        d = a - b;
    }
    else if(c=='+')
    {
        d = a + b;
    }
    printf("%d\n",d);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------


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

  int k; cin >> k;
  vector<int> a = {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};

  cout << a[k-1] << endl;



  return 0;
}


Measured memory_bytes: 256
# include <stdio.h>

int main(){
    int g1[7] = {1, 3, 5, 7, 8, 10, 12};
    int g2[4] = {4, 6, 9, 11};
    int g3 = 2;
    int x, y;
    int a= 0, b = 0, c =0;
    scanf("%d %d", &x, &y);
    
    for (int i = 0; i < 7; ++i){
        if (x == g1[i])
            a = 1;
        if (y == g1[i])
            b = 1;
    }
    if (a == 1 && b == 1){
        printf("Yes\n");
        c = 1;
    }
    
    a = 0, b = 0;
        
    for(int i =0; i < 5; ++i){
        if (x == g2[i])
            a = 1;
        if (y == g2[i])
            b = 1;
    }
    if (a == 1 && b == 1){
        printf("Yes\n");
        c = 1;
    }
    if (x == 2 && y == 2)
        printf("Yes\n");

    if (c == 0)
        printf("No\n");
        
        
    
    return 0;
}

Measured memory_bytes: 128
def insertionSort(A, N):
    for i in range(N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        t = str(A[0])
        for i in range(1,N):
            t = t + " " + str(A[i])
        print(t)


             
n = int(input())
a = [int(i) for i in input().split()]

insertionSort(a,n)

Measured memory_bytes: 5604
#include <stdio.h>
int main(void) {
	int mt[10];
	int i, j, buf;

	for (i = 0; i < 10; i++){
		scanf("%d", &mt[i]);
	}

	for (i = 0; i < 9; i++){
		for (j = i+1; j < 10; j++){
			if (mt[j] >= mt[i]){
				buf = mt[i];
				mt[i] = mt[j];
				mt[j] = buf;
			}

		}	
	}

	for (i = 0; i < 3; i++){
		printf("%d\n", mt[i]);
	}
	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(abs(a-c) <= d || (abs(a-b) <= d && abs(c-b) <= d)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

vector<int> G[SIZE];
vector<int> ans(SIZE), a(SIZE);
vector<int> L;
void dfs(int k = 0, int p = -1){
    int flag = -1;
    int itr = lower_bound(L.begin(), L.end(), a[k]) - L.begin();
    vector<int>::iterator it = lower_bound(L.begin(), L.end(), a[k]);
    if (it == L.end()){
        L.push_back(a[k]);
    }
    else {
        flag = *it;
        *it = a[k];
    }
    ans[k] = L.size();
    for (auto &&i : G[k]){
        if (i == p)continue;
        dfs(i, k);
    }
    if (flag == -1)L.pop_back();
    else L[itr] = flag;
}
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int n; cin >> n;
    rep(i,n)cin >> a[i];
    rep(i,n-1){
        int u, v; cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs();
    rep(i,n)
        cout << ans[i] << endl;
}

Measured memory_bytes: 29968
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
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 pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    h = I()
    w = I()
    n = I()
    t = max(h,w)


    return (n+t-1) // t


print(main())





Measured memory_bytes: 5464
#include <iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(void){
    // Here your code !
    double x,a,b;
    cin>>x>>a>>b;
    if(abs(a-x)>abs(b-x)) cout<<"B"<<endl;
    else if(abs(b-x)>abs(a-x)) cout<<"A"<<endl;
    return 0;
}


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

const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

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

  std::cout << fixed << setprecision(1);

  int n;
  int id = 0;
  while (cin >> n,n) {
    double x[55], y[55];
    double area = 0;
    REP(i, n){
      cin >> x[i] >> y[i];
    }
    REP(i, n){
      area += (x[i] - x[(i + 1) % n]) * (y[i] + y[(i + 1) % n]);
    }
    std::cout << ++id << ' ' << abs(area)/2 << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3240
#include<stdio.h>
#define H 250

int h;

void print(int A[]){
  int i;

  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,A[i]);
    
    if(i != 1)  printf("parent key = %d, ",A[i/2]);

    if(i*2<=h) printf("left key = %d, ",A[i*2]);
    if(i*2+1<=h) printf("right key = %d, ",A[i*2+1]);

    printf("\n");
  }
}

int main(){

  int i,j;
  int A[H];

  scanf("%d",&h);

  for(i=1;i<=h;i++) scanf("%d",&A[i]);

  print(A);

  return 0;
}



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

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



fn main() {
    let s: Vec<char> = read::<String>().chars().collect();

    if s[0] == '7' || s[1] == '7' || s[2] == '7' {
        println!("Yes");
    }else{
        println!("No");
    }


}


Measured memory_bytes: 2080
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t,m,x,y,q;
int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      cin>>n;
      ll a[n],x=1,ans=0;
      for(int i=0;i<n;i++){
      	cin>>a[i];
      	if(a[i]==x)x++;
      	else ans++;
      }
      if(ans==n)cout<<-1<<endl;
      else cout<<ans;
}

Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 1e9;

int main() {
    ll N;
    cin >> N;
    set<ll> ans;
    auto check = [](ll base, ll temp) {
        while (base % temp == 0 && base > 1) base /= temp;
        return base % temp;
    };
    if (N == 2) {
        cout << 1 << endl;
        return 0;
    }
    {
        ll base = N - 1;
        for (ll i = 1; i * i <= base; i++) {
            if (base % i != 0) continue;
            if (i != 1 && check(N, i) == 1) ans.insert(i);
            if (check(N, base / i) == 1) ans.insert(base / i);
        }
    }
    for (ll i = 1; i * i <= N; i++) {
        if (N % i != 0) continue;
        if (i != 1 && check(N, i) == 1) ans.insert(i);
        if (check(N, N / i) == 1) ans.insert(N / i);
    }
    cout << ans.size() << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() { 
    ll N, X1=0, X2=0, X;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> X;
        X1 += X;
        X2 += X*X;
    }
    ll P = round(X1/(double)N);
    cout << X2 - 2*P*X1 +N*P*P << endl;
}

Measured memory_bytes: 256
time = []
time_up = []
time_amari = []
for _ in range(5):
    t = int(input())
    if t%10!=0:
        t_up = (t//10+1)*10
        t_amari = t_up-t
    else:
        t_up = t
        t_amari = -1
    time.append(t)
    time_up.append(t_up)
    time_amari.append(t_amari)
s = sum(time_up)
pos = time_amari.index(max(time_amari))
print(s-time_up[pos]+time[pos])

Measured memory_bytes: 3064
N,D=map(int,input().split())
X=[list(map(int,input().split())) for i in range(N)]
count=0
for i in range(N):
    for j in range(i+1,N):
        count+=(sum((y-z)**2 for y,z in zip(X[i],X[j]))**.5).is_integer()
print(count)

Measured memory_bytes: 3060
import sys


def main():
    n, m, x, y = map(int, input().split())
    xs = list(map(int, input().split()))
    ys = list(map(int, input().split()))

    xs.sort()
    ys.sort()
    a = xs[-1]
    b = ys[0]

    if a <= b:
        for i in range(b-a+1):
            z = a + i
            if a < z and z <= b and x < z and z <= y:
                print("No War")
                sys.exit(0)
        print("War")
    else:
        print("War")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
class MainClass
{
	public static void Main (string[] args)
	{
		var line = Console.ReadLine ().Split(' ');
		var h = int.Parse (line[0]);
		var w = int.Parse (line[1]);
		var strlist = new List<string> ();
		var top = "";
		for(var i = 0;i<w+2;i++){
			top += "#";
		}
		strlist.Add (top);
		for(var i = 0;i < h; i++){
			strlist.Add ("#"+Console.ReadLine ()+"#");
		}
		strlist.Add (top);
		strlist.ForEach(x => Console.WriteLine (x));
	}
}

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

int main()
{
    string O, E;
    cin >> O >> E;

    for (int i = 0; i < O.size(); i++) {
        cout << O[i];
        if (E[i] != NULL) {
            cout << E[i];
        }
    }
    cout << endl;
}


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

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

    int N;
    cin >> N;
    string S;
    cin >> S;
    int maxv = 0;
    for (int i = 0; i < N; i++) {
        char ch = S[i];
        for (int j = i + 1; j < N; j++) {
            if (S[j] != ch) continue;
            if (i + maxv > j || j + maxv > N) continue;
            if (i > 0 && S[i - 1] == S[j - 1]) continue;
            int k = 0;
            while (j + k < N && i + k < j && S[j + k] == S[i + k]) k++;
            maxv = max(maxv, k);
        }
    }
    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
l = input()
arr = []
for i in range(N):
    arr.append(l[i])

c = 0
left = 0
right = N-1

T = False
for i in arr:
    if i == 'R':
        T = True
if T == False:
    print(c)
else:
    T = False
    for i in arr:
        if i == 'W':
            T = True
    if T == False:
        print(c)
    else:
        while True:
            while True:
                if arr[left] == 'R':
                    left += 1
                else:
                    break
            while True:
                if arr[right] == 'W':
                    right -= 1
                else:
                    break
            arr[left] = 'R'
            arr[right] = 'W'
            if left >= right:
                break
            else:
                c += 1
        print(c)


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

int gcd(int m,int n){
    if(m>n)return gcd(n,m);
    if(m==0){
        return n;
    }else{
        return gcd(n%m,m);
    }
}

int main(){
    int N,x[100001];
    cin>>N>>x[0];
    for(int i=1;i<=N;i++){
        cin>>x[i];
    }
    sort(x,x+N+1);
    int ans=x[1]-x[0];
    for(int i=1;i<N;i++){
        int d=x[i+1]-x[i];
        if(d==0)continue;
        ans=gcd(ans,d);
    }
    cout<<ans<<endl;
}


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

using namespace std;

#define int long long

int a, b, n;

int get(int x) {
  int fx = (a * x) / b;
  int fy = a * (x / b);
  return fx - fy;
}

signed main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> a >> b >> n;
  int nearest = n / b * b - 1;
  nearest = min(n, nearest);
  cout << max(get(nearest), get(n)) << '\n';

  return 0;
}

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

using namespace std;

vector<int> h(100010);

int main()
{
  int N, K; cin >> N >> K;
  for (int i = 0; i < N; ++i) {
    cin >> h[i];
  }

  sort(h.begin(), h.begin() + N);

  int ans = 1e9;
  for (int i = 0; i <= N - K; ++i) {
    ans = min(ans, h[i+K-1] - h[i]);
  }

  cout << ans << endl;
}

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

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a);
  vector<int> q(b);
  vector<int> r(c);
  for(int i = 0; i < a; i++) cin >> p.at(i);
  for(int i = 0; i < b; i++) cin >> q.at(i);
  for(int i = 0; i < c; i++) cin >> r.at(i);
  
  sort(p.begin(), p.end(), greater<int>());
  sort(q.begin(), q.end(), greater<int>());
  sort(r.begin(), r.end(), greater<int>());
  
  long long ans = 0;
  int np = x - 1;
  int nq = y - 1;
  int nr = 0;
  bool ok = true;
  while(ok){
    ok = false;
    if(nr >= c) break;
    long long s;
    long long t;
    if(np == -1) s = 10000000000;
    if(np >= 0) s = p.at(np);
    if(nq == -1) t = 10000000000;
    if(nq >= 0) t = q.at(nq);
    long long l = r.at(nr);
    if(s < t){
      if(s < l){
        ans += l;
        nr++;
        np--;
        ok = true;
      }
    }
    else{
      if(t < l){
        ans += l;
        nr++;
        nq--;
        ok = true;
      }
    }
  }
  
  for(int i = 0; i < np + 1; i++){
    long long j = p.at(i);
    ans += j;
  }
  for(int i = 0; i < nq + 1; i++){
    long long j = q.at(i);
    ans += j;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1408
# Fast IO (be careful about bytestring)

# import os,io
# input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline


H,W,M = map(int,input().split())
targetList = []
rowCount = [0] * H
columnCount = [0] * W
for _ in range(M):
    p,q = map(int,input().split())
    targetList.append((p-1,q-1))
    rowCount[p-1] += 1
    columnCount[q-1] += 1
rowCountLabelled = []
columnCountLabelled = []
for i in range(H):
    rowCountLabelled.append((rowCount[i],i))
for i in range(W):
    columnCountLabelled.append((columnCount[i],i))
rowCountLabelled.sort(reverse = True)
columnCountLabelled.sort(reverse = True)
targetList.sort()
maxi = rowCountLabelled[0][0] + columnCountLabelled[0][0]
isMaxAchievable = False
for elem1 in rowCountLabelled:
    if elem1[0] != rowCountLabelled[0][0]:
        break
    for elem2 in columnCountLabelled:
        if elem2[0] != columnCountLabelled[0][0]:
            break
        target = (elem1[1],elem2[1])
        l = 0
        r = len(targetList) - 1
        while l < r:
            m = (l + r) // 2
            if target == targetList[m]:
                l = m
                r = m
                break
            elif target < targetList[m]:
                r = m-1
            elif target > targetList[m]:
                l = m + 1
        if (l >= len(targetList) or target != targetList[l]) and target != targetList[r]:
            isMaxAchievable = True
            break
    if isMaxAchievable:
        break
if isMaxAchievable:
    print(maxi)
else:
    print(maxi - 1)


Measured memory_bytes: 157836
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    int x;
    cin>>x;
    if(x==7||x==5||x==3){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

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

int main(){
	int n;
	cin >> n;
	int t[n + 1],x[n + 1],y[n + 1];
	t[0] = 0;
	x[0] = 0;
	y[0] = 0;
	for(int i = 1; i <= n; i++) cin >> t[i] >> x[i] >> y[i];
	REP(i,n){
		if(abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) > t[i + 1] - t[i] || (abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])) % 2 != (t[i + 1] - t[i]) % 2){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i=0; i<n; i++){
    cin>> s[i];
    sort(s[i].begin(),s[i].end());
  }
  sort(s.begin(),s.end());
  long count=1;
  long sum=0;
  for(int i=0; i<n-1; i++){
    	if(s[i]==s[i+1]) count++;
    else {sum+=count*(count-1)/2; count=1;}
    }
  sum+=count*(count-1)/2;
  cout << sum << endl;
}

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

from collections import deque

graph = [deque([]) for _ in range(n+1)]

for _ in range(n):
    u, k, *v = [int(x) for x in input().split()]

    v.sort()
    for i in v:
        graph[u].append(i)
    
arrive = [-1 for i in range(n+1)]
finish = [-1 for i in range(n+1)]

times = 0

def dfs(v):
    global times
    times += 1
    arrive[v] = times
    stack = [v]
    
    while stack:
        v = stack[-1]
        if graph[v]:
            w = graph[v].popleft()
            if arrive[w] == -1:
                times += 1
                arrive[w] = times
                stack.append(w)
        else:
            times += 1
            finish[v] = times
            stack.pop()
    return

for i in range(n):
    if arrive[i+1] == -1:
        dfs(i+1)

for j in range(n):
    tmp = [j+1, arrive[j+1], finish[j+1]]
    print(*tmp)



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

int main() {
	string str;
	cin >> str;
	int t = 1;
	char s = str[0];
	for(char c:str){
		if(c!=s){
			s = c;
			t++;
		}
	}
	cout<<t-1<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
using namespace std;
int n;
int arr[2][3];
int a=0,b=1;
int main(){
    scanf("%d",&n);
    while (n--){
        scanf("%d%d%d",&arr[b][0],&arr[b][1],&arr[b][2]);
        arr[b][0]+=max(arr[a][1],arr[a][2]);
        arr[b][1]+=max(arr[a][0],arr[a][2]);
        arr[b][2]+=max(arr[a][0],arr[a][1]);
        swap(a,b);
    }
    printf("%d\n",max(arr[a][0],max(arr[a][1],arr[a][2])));
}


Measured memory_bytes: 128
//////////////////////////////////////////////////////////
//______________________________________________________//
//    ____           __                                 //
//    /   )          / |                                //
//---/__ /-----__---/__|----__----__----__------__--_/_-//
//  /    )   /___) /   |  /   ' /   ' /___)   /   ) /   //
//_/____/___(___ _/____|_(___ _(___ _(___ ___/___/_(_ __//
//                                          /           //
//                                         /            //
//////////////////////////////////////////////////////////
#include <iostream>
#include <math.h>
#include <stack>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <iterator>
#include <cctype>
#include <cstdio>
#include <cstring>
#define rep(counter, limit) for (int counter = 0; counter < limit; counter++)
typedef long long ll; using namespace std;const int INF=1001001001;
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
int main() {

  string s;
  cin>>s;
  if(s[0]=='7' || (s[1]=='7' || s[2]=='7')){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
const int inf=100000;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;
int main() 
{
	int x,n;
	cin>>x>>n;
	vector<int> p(n);
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
	}
	//答え
	int ans=inf;
	//直前の最小値
	int pre=inf;
	bool flag=true;
	for(int i=0;i<=101;i++)
	{
		flag=true;
		for(int j=0;j<n;j++)
		{
			if(i==p[j]) flag=false;
		}
		if(flag)
		{
			if(pre==abs(x-i)&&ans==i)
			{
				ans=min(ans,i);
			}
			else if(pre>abs(x-i))
			{
				ans=i;
				pre=abs(x-i);
			}
			
		}
	}
	if(n==0) cout<<x<<endl;
	else cout<<ans<<endl;
	return 0;
}

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

#define int 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 rep1(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif


template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

#endif


void solve(){
    int N, K;
    cin >> N >> K;
    int ans = 0;
    while(N>0){
        N/=K;
        ans++;
    }
    cout << ans << endl;
    
}

signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define min(a,b) (a<b?a:b)
#define ll long long
//#define file
using namespace std;

int T,i,j,k,l;
map<ll,ll> hs;
map<ll,ll> :: iterator I;
ll n,A,B,C,D;

ll dg(ll t)
{
	if (!t) return 0;
	
	I=hs.find(t);
	if (I!=hs.end()) return hs[t];
	
	ll ans=9223372036854775807ll,s;
	if (t<=9223372036854775807ll/D) ans=min(ans,t*D);
	
	s=dg((t/2)),ans=min(ans,s+A+D*(t%2));
	if (t>2)
	s=dg(((t/2)+1)),ans=min(ans,s+A+D*(2-t%2));
	s=dg((t/3)),ans=min(ans,s+B+D*(t%3));
	if (t>3)
	s=dg(((t/3)+1)),ans=min(ans,s+B+D*(3-t%3));
	s=dg((t/5)),ans=min(ans,s+C+D*(t%5));
	if (t>5)
	s=dg(((t/5)+1)),ans=min(ans,s+C+D*(5-t%5));
	
	hs[t]=ans;
	return ans;
}

int main()
{
	#ifdef file
	freopen("a.in","r",stdin);
	#endif
	
	scanf("%d",&T);
	for (;T;--T)
	{
		scanf("%lld%lld%lld%lld%lld",&n,&A,&B,&C,&D);
		printf("%lld\n",dg(n));
		hs.clear();
	}
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}

Measured memory_bytes: 4960
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int high=0,low=0,n,number[8],kawa;
    string str;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>str;
        for(int j=0;j<8;j++)number[j]=str[j]-'0';
        for(int j=0;j<8;j++){
            for(int k=7;k>j;k--){
                if(number[k]>number[k-1]){
                    kawa=number[k-1];
                    number[k-1]=number[k];
                    number[k]=kawa;
                }
            }
            high+=number[j]*pow(10,7-j);
            low+=number[j]*pow(10,j);
        }
        cout<<high-low<<endl;
        high=0;low=0;
    }
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool bo[100];
#define ll long long 
int main()
{
	ll n;
	string s;
	cin>>n>>s;
	ll x=0,ma=0;
	for(ll i=0;i<n;i++)
	{
		if(s[i]=='I') x++;
		else x--;
		ma=max(ma,x);
	}
	cout<<ma<<endl;
}


Measured memory_bytes: 256
n=int(input())
box=list(map(int,input().split()))
count=0
for i in range(n):
    p=n-1
    while p!=i:
        if box[p]<box[p-1]:
            box[p],box[p-1]=box[p-1],box[p]
            count +=1
        p -=1
print(*box)
print(count)


Measured memory_bytes: 5608
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"


def solve():
    N = int(input())
    A = int(input())

    return N % 500 <= A


def main():
    print(Yes if solve() else No)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3916
module Card_set =
  Set.Make
    (struct
      type t = string * int
      let compare (s0,n0) (s1,n1) = match Pervasives.compare s0 s1 with
        | 0 -> Pervasives.compare n0 n1
        | _ ->
          match s0 with
          | "S" -> -1
          | "H" -> if s1 = "S" then 1 else -1
          | "C" -> if s1 = "D" then -1 else 1
          | _ -> 1
    end)

let () =
  let l = (List.concat (List.map
                          (fun x -> List.map
                              (fun n -> x,n)
                              [1;2;3;4;5;6;7;8;9;10;11;12;13])
                          ["S";"H";"C";"D"])) in
  let set = List.fold_left (fun acc x -> Card_set.add x acc) Card_set.empty l in
  let count = read_int () in
  let rec loop i s =
    if i >= count then s
    else
      let line = read_line () in
      let p = Scanf.sscanf line "%s %d" (fun m n -> m,n) in
      loop (i+1) (Card_set.remove p s)
  in
  Card_set.iter (fun (s,n) -> Printf.printf "%s %d\n" s n) (loop 0 set)

Measured memory_bytes: 2416
package main

import "fmt"

func main() {
	var n, r int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	for i := 0; i < len(a); i++ {
		c := 0
		for a[i]%2 == 0 {
			c++
			a[i] /= 2
		}
		r += c
	}
	fmt.Println(r)
}

Measured memory_bytes: 1280
count = int(input())
a = list(map(int, input().split()))

min_num = max_num = a[0]
total = 0
for i in a:
    if min_num > i : min_num = i
    if max_num < i : max_num = i 
    total += i

print("%d %d %d" %(min_num, max_num, total))


Measured memory_bytes: 6592
def after_explain():
    d, g = map(int, input().split())
    a = []
    b = []
    for i in range(d):
        p, c = map(int, input().split())
        a.append(p)
        b.append(c)

    mincnt = 999999999
    for i in range(1 << 2 * d):
        score = 0
        cnt = 0
        for j in range(d):
            if i & (1 << j):
                score += a[j]*(j+1)*100 + b[j]
                cnt += a[j]

        for j in range(d-1, -1, -1):
            if not(i & (1 << j)):
                if score > g:
                    break
                s = g - score
                if s % ((j+1)*100) == 0:
                    c = min(a[j], s // ((j + 1) * 100))
                    cnt += c
                    score += c * ((j + 1) * 100)
                else:
                    c = min(a[j], s // ((j + 1) * 100))
                    cnt += c + 1
                    score += (c+1) * ((j + 1) * 100)
                break
        if score < g:
            continue
        if cnt < mincnt:
            mincnt = cnt
    return mincnt

print(after_explain())

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

using namespace std;

typedef long long int ll;

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

    string s1,s2;
    cin >> s1 >> s2;

    int n = s1.length();
    int m = s2.length();

    ll ans = n+m;
    for(int i=0 ;i<=(n-m) ; i++)
    {
        ll cc = 0;
        for(int j=0 ; j<m ; j++)
        {
            if(s1[i+j] != s2[j])
                cc++;
        }
        ans = min(ans,cc);
    }

    cout << ans ;
    return 0;
}


Measured memory_bytes: 3656
#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>
using namespace std;

int main() {
    
    long long A,B,C;
    long long count = 0;
    
    cin >> A;
    cin >> B;
    cin >> C;
    
    if ( A%2 == 1 || B%2 == 1 || C%2 == 1 ) {
        cout << 0 << endl;
        return 0;
    }
    
    if ( A == B && B == C && C == A ) {
        cout << -1 << endl;
        return 0;
    }
    
    while( A%2 == 0 && B%2 == 0 && C%2 == 0 ) {
        
        long long a, b, c;
        a = A;
        b = B;
        c = C;
        
        A = ( b+c ) / 2;
        B = ( a+c ) / 2;
        C = ( b+a ) / 2;
        
        count++;
    }
    
    cout << count << endl;
    
    return 0;
}

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

template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");

private:
	using ll = long long;

	int v;

	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}

public:

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }

	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}

	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}

	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}

	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<int(1e9)+7>;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s; cin >> s;
	vector<num> dp(13);
	dp[0] ++;
	for (char c : s) {
		vector<num> ndp(13);
		for (int d = 0; d < 10; d++) {
			if (c == '?' || c == char(d + '0')) {
				for (int v = 0; v < 13; v++) {
					ndp[(10 * v + d) % 13] += dp[v];
				}
			}
		}
		dp = ndp;
	}
	cout << dp[5] << '\n';

	return 0;
}


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

int main(){
    long long N; 
    cin >> N;
    long long ans = 1;
    for(long long i = 0; i < 1000000; i++) {
        if(i*i <= N) {
            ans = i*i;
        }
    }
    cout << ans << endl;
}




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

int main() {
	int ans[] = {111, 222, 333, 444, 555, 666, 777, 888, 999};
	int n;
	cin >> n;
	for (auto e : ans) {
		if (e >= n) {
			cout << e << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    from sys import stdin
    input = stdin.readline

    N = 1000

    def lcs(X, Y):
        c = [[0]*(N+1) for _ in range(N+1)]
        maxl = 0
        X = ' ' + X # 1オリジンにする
        Y = ' ' + Y
        pre_row = c[0]
        for i, x in enumerate(X):
            if i == 0:
                continue
            row = c[i]
            for j, y in enumerate(Y):
                if j == 0:
                    continue
                if x == y:
                    value = pre_row[j-1] + 1
                    row[j] = value
                    if maxl < value: # maxlの更新はこの時しか起こらない
                        maxl = value
                else:
                    pre_row_j = pre_row[j]
                    row_j_1 = row[j-1]
                    value = row_j_1
                    if pre_row_j > row_j_1:
                        value = pre_row_j # max関数だと、とても遅い
                    row[j] = value
            pre_row = row # 今の列が次の列にとって一つ前の列になる

        return maxl

    n = int(input())
    for _ in range(n):
        s1 = input()[:-1]
        s2 = input()[:-1]
        print(lcs(s1, s2))


Measured memory_bytes: 30940
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll X, ll Y) {
  for (int res = 1;; ++res) {
    X = X * 2;
    if (X > Y) {
      cout << res << endl;
      return;
    }
  }
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll X;
	ll Y;
	scanf("%lld", &X);
	scanf("%lld", &Y);
	solve(X, Y);
	return 0;
}


Measured memory_bytes: 764
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pradyumn
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.println(a * b - (a + b - 1));
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = pread();
            }
            int res = 0;
            do {
                if (c == ',') {
                    c = pread();
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = pread();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 19668
N = int(input())
X = [0]*N
Y = [0]*N
for i in range(N):
    X[i],Y[i] = map(int, input().split())

d = 0
import math
for i in range(N):
    for j in range(N):
        d += ((X[i]-X[j])**2+(Y[i]-Y[j])**2)**0.5

ans = d/N
print(ans)



Measured memory_bytes: 38640
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

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

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

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

const unsigned long long INF = 1LL << 60;

////////////////////////////////////////////////////////////

int main() {
    int a, b;
    cin >> a >> b;
    if (a == b) {
        cout << "a == b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a < b" << endl;
    }
}



Measured memory_bytes: 3104
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def dd(b, n, k):
	if k==0:
		return n
	if b <= k:
		return 0
	ret = 0
	na = n // b
	ret += na * (b-k)
	
	nb = n % b
	ret += max(nb - k + 1, 0)
	#pa((b,ret))
	return ret

def main():
	#a = int(input())
	n, k = tin()
	#s = input()
	ret = 0
	for b in range(1, n+1):
		ret += dd(b,n, k)
	print(ret)
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 67360