akhauriyash/Code-Regression huggingface dataset:
N, K = map(int, input().split())
_A = list(map(int, input().split()))
ans = 0

A = []
for a in _A:
    if a >= K:
        ans += 1
    else:
        A.append(a)

A.sort(reverse=True)
M = len(A)
isNess = [False] * M

accA = [0] * (M + 1)
for i in range(1, M + 1):
    accA[i] = accA[i - 1] + A[i - 1]

left = 0
for right in range(1, M):
    while accA[right] - accA[left] >= K:
        left += 1

    for i in range(right, M)[:: -1]:
        if (accA[right] - accA[left]) + A[i] >= K:
            isNess[i] = True
            for j in range(left, i):
                isNess[j] = True
            break

ans += sum(isNess)
print(N - ans)

Measured memory_bytes: 42604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    ll a,b,k;
    cin>>a>>b>>k;
    if(a>=k){
        cout<<a-k<<' '<<b<<endl;
    }else{
        cout<<0<<' '<<max(0LL,b-(k-a))<<endl;
    }
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
	if (ch =='A') return 1;
	else if (ch =='C') return 2;
	else if (ch =='G') return 3;
	else if (ch =='T') return 4;
	else return 0;
}

long long getKey(char str[]){
	long long sum=0, p = 1, i;
	for (i=0;i < strlen(str); i++){
		sum += p*(getChar(str[i]));
		p *=5;
	}
	return sum;
}

int h1(int key){return key % M;}
int h2(int key){return 1 + (key % (M-1));}

int find(char str[]){
	long long key,i,h;
	key=getKey(str);
	for(i=0;;i++){
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h],str)==0) return 1;
		else if ( strlen(H[h]) == 0) return 0;
	}
	return 0;
}

int insert(char str[]){
	long long key,i,h;
	key=getKey(str);
	for(i=0;;i++){
		h = (h1(key) + i * h2(key)) % M;

		if (strcmp(H[h],str)==0) return 100;
		else if ( strlen(H[h]) == 0) {
		  strcpy(H[h],str);
		  return 0;
	}
	}
	return 0;
}

int main(){
	int i,n,h;
	char str[L],com[9];
	for(i=0;i<M;i++) H[i][0]='\0';
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %s",com,str);
		if (com[0] == 'i'){
			insert(str);
		}else{
			if (find(str)){
				printf("yes\n");
			}else{
				printf("no\n");
			}
		}
	}
}

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



int main(){
    int n,x,y,A,B;
    cin>>n>>x>>y;
    A = x;
    if(x>y)
        A = y;
    if(x+y>n)
        B = (x+y)-n;
    else
        B = 0;
    cout<<A<<" "<<B;
    return 0;
}


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

struct group{
	int left,right;
};

signed main(){
	int N,K; string S; cin>>N>>K>>S;
	int l=-1,r=-1;
	vector<group> G;

	for(int i=0;i<N;i++){
		if(S[i]=='0' and S[i+1]=='1'){
			i++; l=i;
			while(S[i]=='1' and i<N){
				i++;
			}
			i--;
			r=i; group tmp;
			tmp.left=l; tmp.right=r;
			G.push_back(tmp);
		}
	}
	int ans=0;
	if(K>G.size())ans=N;
	else{
		int M=G.size();

		ans=G[K-1].right+1;
		if(S[M-1]=='0')	ans=max(ans,N-G[M-K].left);
		else ans=max(ans,N-G[M-K-1].left);

		for(int i=0;i<M-K;i++){
			ans=max(ans,G[i+K].right-G[i].left+1);
		}
	}
	// for(int i=0;i<G.size();i++){
	// 	cout<<"G="<<G[i].left<<":"<<G[i].right<<endl;
	// }
	cout<<ans<<endl;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int H, W;
int A[88][88];
int B[88][88];
const int KMAX = 13000;
bool dp[88][88][KMAX + 90];
int C[88][88];
void input() {
  cin >> H >> W;
  rep(i, 1, H) {
    rep(j, 1, W) { cin >> A[i][j]; }
  }
  rep(i, 1, H) {
    rep(j, 1, W) { cin >> B[i][j]; }
  }
}
void solve() {
  rep(i, 1, H) {
    ;
    rep(j, 1, W) { C[i][j] = abs(A[i][j] - B[i][j]); }
  }

  // DP start
  dp[1][1][C[1][1]] = 1;
  // // 1を決めておく
  // rep(i, 1, H) {  // 下方向へ
  //   rep(k, 0, KMAX - 1) {
  //     ;
  //     dp[i][1][k] |= dp[i - 1][1][k + C[i][1]];
  //     if (k - C[i][1] >= 0) {
  //       dp[i][1][k] |= dp[i - 1][1][k - C[i][1]];
  //     }
  //   }
  // }
  // rep(j, 1, W) {
  //   rep(k, 0, KMAX - 1) {
  //     dp[1][j][k] |= dp[1][j - 1][k + C[1][j]];
  //     if (k - C[1][j] >= 0) {
  //       dp[1][j][k] |= dp[1][j - 1][k - C[1][j]];
  //     }
  //   }
  // }
  rep(i, 1, H) {
    ;
    rep(j, 1, W) {
      ;
      rep(k, 0, KMAX - 1) {
        ;
        dp[i][j][k] |= dp[i][j - 1][k + C[i][j]];
        dp[i][j][k] |= dp[i - 1][j][k + C[i][j]];
        //     if (k - C[i][j] >= 0) {
        dp[i][j][k] |= dp[i][j - 1][abs(k - C[i][j])];
        dp[i][j][k] |= dp[i - 1][j][abs(k - C[i][j])];
        //    }
      }
    }
  }
  // int ans = -1;
  rep(k, 0, KMAX) {
    if (dp[H][W][k]) {
      cout << k << endl;
      return;
    }
  }

  // rep(k, 0, 50) { printf("k=%lld .... dp[H][W][k] = %lld.\n", k,
  // dp[H][W][k]); }
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 91520
import sys
N,K,Q = map(int,input().split())
if K > Q:
    for i in range(N):
        print('Yes')
    sys.exit(0)
else:
  res = dict()
  for i in range(N+1):
      res[i] = 0
  for i in range(Q):
    answ = int(input())
    if answ not in res:
      res[answ] = 0
    res[answ] += 1
res2 = [answ[0] for answ in res.items() if answ[1] >= (Q-K+1)]
for i in res2:
    res[i] = -1
for i in range(1,N+1):
    if (res[i] == -1):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 15084
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0;i < N;i++){
    cin >> d.at(i);
  }
  long long ans = 0;
  for(int i = 0;i < N;i++){
    for(int j = i + 1;j < N;j++){
      ans += d.at(i) * d.at(j);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3564
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){

    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

bool IsPrime(ll num){
    if(num < 2) return false;
    else if(num == 2) return true;
    else if(num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for(ll i = 3; i <= sqrtNum; i += 2){
        if(num%i==0){
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

signed main(){
  int n; cin>>n;
  string s; cin>>s;
  int cnt = 0;
  reps(i,n-1){
    if(s[i]==s[i-1]) cnt++;
  }
  cout << n-cnt << endl;


  return 0;
}


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

int main(){
    vector<int> digit[10];
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    digit[a%10].push_back(a);
    digit[b%10].push_back(b);
    digit[c%10].push_back(c);
    digit[d%10].push_back(d);
    digit[e%10].push_back(e);

    int ans = 0;
    int count = 0;
    for(int i=0;i<digit[0].size();i++){
        ans += digit[0][i];
        count++;
    }
    if(count<5){
        for(int i=9;i>=1;i--){
            for(int j=0;j<digit[i].size();j++){
                if(count==4){
                    ans += digit[i][j];
                    count++;
                    break;
                }else{
                    ans += (digit[i][j]/10 + 1)*10;
                    count++;
                }
            }
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import itertools

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N,M,Q = map(int, input().split())
L = []

for i in range(1,M+1,1):
    L.append(i)

A = []
B = []
C = []
D = []
for _ in range(Q):
    a,b,c,d = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)
    D.append(d)

List = list(itertools.combinations_with_replacement(L, N))
ans = 0
for l in List:
    temp = 0
    for q in range(Q):
        if (l[B[q]-1]-l[A[q]-1])==C[q]:
            temp = temp + D[q]
    ans = max(ans, temp)
print(ans)
            

Measured memory_bytes: 21568
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
char s[5][10]={"dream","dreamer","erase","eraser"};
char ss[101010];
bool ok[101010];
int main()
{
	int l;
	scanf("%s",ss+1);
	l=strlen(ss+1);
	memset(ok,0,sizeof(ok));
	ok[0]=true;
	for(int i=1;i<=l;i++)
	{
		if(i>=5&&(strncmp(s[0],ss+i-4,5)==0||strncmp(s[2],ss+i-4,5)==0))
			ok[i]|=ok[i-5];
		if(i>=6&&strncmp(s[3],ss+i-5,6)==0)
			ok[i]|=ok[i-6];
		if(i>=7&&strncmp(s[1],ss+i-6,7)==0)
			ok[i]|=ok[i-7];
	}
	if(ok[l])
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

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

string s1, s2;
int dp[3001][3001];

int recur(int p1, int p2) {
	if(p1 >= s1.size() or p2 >= s2.size())
		return dp[p1][p2] = 0;

	int &ret = dp[p1][p2];
	
	if(ret != -1)
		return ret;

	ret = max(recur(p1+1, p2+1) + (s1[p1] == s2[p2]), max(recur(p1+1, p2), recur(p1, p2+1)));
	return ret;
}


void dfs(int p1, int p2) {
	//cerr << p1 << ", " << p2 << " : ";
	if(p1 >= s1.size() or p2 >= s2.size()) {
		cout << endl;
		return;
	}

	//cerr << (s1[p1] == s2[p2]) << " " << dp[p1][p2] << " -> " << dp[p1+1][p2+1] << " :: ";

	if(s1[p1] == s2[p2] and dp[p1][p2] == dp[p1+1][p2+1]+1) {
		cout << s1[p1];
		//cerr << "+1+1\n";
		dfs(p1+1, p2+1);
	}
	else if(dp[p1+1][p2] > dp[p1][p2+1]) {
		//cerr << "+1+0\n";
		dfs(p1+1, p2);
	}
	else {
		//cerr << "+0+1\n";
		dfs(p1, p2+1);
	}
}

int main() {
	cin >> s1 >> s2;
	memset(dp, -1, sizeof dp);
	recur(0, 0);
	dfs(0, 0);
	return 0;
}

Measured memory_bytes: 35968
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	vector<int>M(N);
	int cnt = 0;
	rep(i, N) {
		while (A[i] % 2 == 0) {
			cnt++;
			A[i] /= 2;
		}
		M[i] = cnt;
		cnt = 0;
	}
	sort(M);
	cout << M[0] << endl;
	
}

Measured memory_bytes: 256
#include <stdio.h>
int main ( )
{
int a,b,perimeter,area;
    scanf("%d %d", &a,&b);
if (a>=1 && b<=100)
    {
    area=a*b;
    perimeter=2*(a+b);

    printf("%d %d\n",area,perimeter);
    }

return 0;
}







Measured memory_bytes: 2680
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using M = map<string,ll>;




int main(){
    ll N;
    cin >> N;
    vector<double> X(N,0);
    vector<double> Y(N,0);
    for(int i=0;i<N;i++){
        cin>>X[i]>>Y[i]
    ;}
    double Sum=0;
    for(int i=0;i<N-1;i++){
     for(int j=i+1;j<N;j++){
         Sum+=sqrt(pow(X[j]-X[i],2)+pow(Y[j]-Y[i],2))
     ;}
    ;}
    cout << fixed << setprecision(10);
    cout<<Sum*2/N<<endl;

return 0;


}  



Measured memory_bytes: 256
from sys import stdin
D, G = [int(_) for _ in stdin.readline().rstrip().split()]
P, C = [], []
for _ in range(D):
    p, c = stdin.readline().rstrip().split()
    P.append(int(p))
    C.append(int(c))
res = 1<<29
for bit in range(1<<D):
    s, num = 0, 0
    for i in range(D):
        if ((bit >> i) & 1):
            s += C[i] + P[i] * 100 * (i+1)
            num += P[i]
    if s >= G:
        res = min(res, num)
    else:
        for i in range(D-1, -1, -1):
            if ((bit >> i) & 1):
                continue
            for j in range(P[i]):
                if s >= G:
                    break
                s += 100 * (i+1)
                num += 1
        res = min(res, num)
print(res)

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

#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 

using namespace std;                    

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

const int N = (int)1e5 + 123, mod = (int)1e9 + 7;

int n, m, q, ans[N];
vector< int > v[2];

int main(){    

	cin >> n >> m;
	if(m == 1){
		int x;
		cin >> x;
		if(x == 1)
			cout << x << endl << 1 << endl << 1;
        else
        	cout << x << endl << 2 << endl << x - 1 << " " << 1;
		return 0;
	}
	for(int i = 0; i < m; i++){
		int x;
		cin >> x;
		v[x&1].pb(x);
	}                             
	sort(v[0].begin(),v[0].end());
	sort(v[1].begin(),v[1].end());
	
	if(v[1].size() > 2){
		cout << "Impossible" ;
		return 0;
	}                          
	
	if(!v[1].empty())
       	cout << (ans[q++] = v[1][0]) << " ";
	for(int i = 0; i < v[0].size(); i++)
		cout << (ans[q++] = v[0][i]) << " ";
	for(int i = 1; i < v[1].size(); i++)
		cout << (ans[q++] = v[1][i]) << " ";
	cout << endl; 
	ans[0]--;
	ans[q - 1]++;
	if(ans[0] == 0){
		cout << q - 1 << endl;
		for(int i = 1; i < q; i++)
			cout << ans[i] << " ";
	}else{
		cout << q << endl;
		for(int i = 0; i < q; i++)
			cout << ans[i] << " ";
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<cstdlib>
using namespace std;
#define MAXN 200005
#define INF 0x3f3f3f3f
#define LL long long
vector<int>G[MAXN];
int siz[MAXN],n,cnt;
void dfs(int u,int p)
{
	siz[u]=1;
	for(int i=0;i<G[u].size();i++)
	{
		int v=G[u][i];
		if(v==p) continue;
		dfs(v,u);
		if(siz[v]==2) siz[v]=-1;
		else siz[u]+=siz[v];//删点
	}
	return ;
}
void dfs2(int u,int p)
{
	++cnt;
	int num=0;//统计叶子个数 
	for(int i=0;i<G[u].size();i++)
	{
		int v=G[u][i];
		if(v==p) continue;
		if(siz[v]==1) num++;
		if(siz[v]!=-1)
			dfs2(v,u); 
	}
	if(num>=2)
	{
		printf("First\n");
		exit(0);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n-1;i++)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1,0);
	dfs2(1,0);
	if(cnt==1) printf("First\n");//只剩下一个节点 先手必胜 
	else printf("Second\n");//不存在那样的节点 先手必败 
    return 0;
}


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


int main() {
  string a, b, c;
  cin >> a >> b >> c;
  cout << a[0] << b[0] << c[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    string s;

    cin>>s;

    if(s[2]==s[3]&&s[4]==s[5]){
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
N = int(input())
s_ = [input() for _ in range(N)]

center = 0
s_aend = []
s_bstart = []
s_bsae = []
s_else = []
center = 0

for s in s_:
  if s.startswith("B") and s.endswith("A"):
    s_bsae.append(s)
  elif s.startswith("B"):
    s_bstart.append(s)
  elif s.endswith("A"):
    s_aend.append(s)
  else:
    center += s.count("AB")

s_max = ""
if len(s_bsae) > 0:
  s_max = ''.join(s_bsae)

if len(s_bstart) > 0 and len(s_bsae) > 0:
  center += 1
  b_len = len(s_bstart)-1
else:
  b_len = len(s_bstart)
  
if len(s_aend) > 0 and len(s_bsae) > 0:
  center += 1
  a_len = len(s_aend)-1
else:
  a_len = len(s_aend)

a_center = 0
b_center = 0

for s in s_bstart:
  a_center += s.count("AB")
for s in s_aend:
  b_center += s.count("AB")

#print(s_max.count("AB"))
#print(center)
#print(min(a_len,b_len))
#print(a_center)
#print(b_center)
print(s_max.count("AB") + center + min(a_len,b_len)+a_center+b_center)






Measured memory_bytes: 3828
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  vector<int> a(2);
  cin>>a[0]>>a[1];
  sort(a.begin(),a.end());
  cout<<(a[1]!=a[0]?2*a[1]-1:a[1]+a[0]);
  
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cassert>
#include<algorithm>
#include<cmath>
#include<cstdio> 

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
 
#define EPS (1e-6)
#define equals(a,b) (fabs((a)-(b))<EPS)
 
using namespace std;
 
typedef long long ll;
 
struct Edge {
  int s,t;
  ll c,d;
};
 
int V,E;
 
bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }
 
int par[10010];
int find(int x) {
  if( x == par[x] ) return x;
  return par[x] = find(par[x]);
}
void unit(int x,int y) {
  x = find(x), y = find(y);
  if( x != y ) par[x] = y;
}
 
double x;
bool cmp(Edge a, Edge b) {
  double v1 = a.d - a.c * x;
  double v2 = b.d - b.c * x;
  return LT(v2,v1);
}

void compute(vector<Edge> &vec) {
  double L = 0, R = 2.0 * 1e20;
  double sum_c = 0, sum_d = 0;
  rep(i,E) {
    sum_c += vec[i].c;
    sum_d += vec[i].d;
  }
  rep(_,120) {
    double M = ( L + R ) * 0.5;
    x = M;
    sort(vec.begin(),vec.end(),cmp);
    double c=0,d=0;
    rep(i,V) par[i] = i;
    rep(i,E) {
      int s = vec[i].s, t = vec[i].t;
      if( find(s)!=find(t) ) {
	unit(s,t);
	c += vec[i].c;
	d += vec[i].d;
      }
    }
    c = sum_c - c;
    d = sum_d - d;
    if( equals(c,0) && equals(d,0) ) {
      puts("0");
      return;
    }
    double v = d / c;
    if( LTE(v,M) ) R = M;
    else L = M;
  }
  
  printf("%.10f\n",L);
}
 
int main() {
  cin >> V >> E;
  vector<Edge> vec(E);
  rep(i,E) {
    int a,b,c,d;
    cin >> a >> b >> c >>d;
    vec[i] = (Edge){a,b,c,d};
  }
  compute(vec);
  return 0;
}

Measured memory_bytes: 3352
package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d", &N)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
	}
	bunsi := 1.0
	for _, a := range A {
		bunsi *= float64(a)
	}
	B := make([]float64, N)
	for i := 0; i < N; i++ {
		B[i] = 1
	}
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if i == j {
				continue
			}
			B[j] *= float64(A[i])
		}
	}
	bunbo := 0.0
	for i := 0; i < N; i++ {
		bunbo += B[i]
	}
	fmt.Println(bunsi / bunbo)
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const intll INF = 100000000000000000;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s ;
  string t = "YAKI" ;
  
  if(s.size() < 4){
    cout << "No" <<endl;
    return 0 ;
  }
  rep(i,4){
    if(s.at(i) != t.at(i)){
      cout << "No" << endl  ;
      return 0 ;
    }
  }
  
  cout <<"Yes" <<endl ;
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int a[4];
string s;
main()
{
  cin>>s;
  for(int i=0;i<4;i++)a[i]=s[i]-'0';
  for(int i=0;i<2;i++)for(int j=0;j<2;j++)for(int k=0;k<2;k++)
  {
    int now=a[0];
    now+=i?-a[1]:a[1];
    now+=j?-a[2]:a[2];
    now+=k?-a[3]:a[3];
    if(now==7)
    {
      cout<<a[0]<<(i?'-':'+')<<a[1]<<(j?'-':'+')<<a[2]<<(k?'-':'+')<<a[3]<<"=7"<<endl;
      return 0;
    }
  }
}


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

using namespace std;

int n,i,j;

int main(){
	scanf("%d", &n);
	
	for(i = 1; i <= 3500; i++){
		for(j = 1; j <= 3500; j++){
			long long tmp = 1LL * n * i * j;
			long long tmp1 = 4LL * i * j - 1LL * n * i - 1LL * n * j;
			if(tmp1 != 0 && tmp % tmp1 == 0 && (tmp / tmp1) >= 1 && (tmp / tmp1) <= 3500)
			return 0 * printf("%d %d %d\n", i, j, tmp / tmp1);
		}
	}
}


Measured memory_bytes: 256
import math
N,M=(int(x) for x in input().split())
a=[0]*(N)
b=[0]*(N)
c=0
v=0
for i in range(N):
    A,B=(int(x) for x in input().split())
    a[i]=A
    b[i]=B
#print(a,b)
v = max(a)
#ソート開始
b.sort(reverse=True)
#ソート終了
#print(i,b[i],v,M,N)
i=0
for i in b:
    if i>=v:
        c+=1
        M-=i
    else:break
    if M <= 0:
        break
if M>0:
    c+=math.ceil(M/v)
print(c)


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

int main(){
    int A,B;
    cin >> A >> B;
    cout << (B % A == 0 ? A + B : B - A) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
const int N=3e5+24,D=1<<19;
struct point{int x,y;}a[N],b[N],c[N],d[N];
struct segment{
	int l,r,h;
}up[N+N],dn[N+N];
int n,w,h,m,ans,k0,k1,st[N],top,k,l,left[N],right[N],tmp[N];
bool Cmpl(const segment&a,const segment&b){return a.l<b.l;}
bool Cmp(const point&a,const point&b){
	if((a.y>=m)==(b.y>=m))
	  return a.x==b.x?a.y<b.y:a.x<b.x;
	return a.y>=m;
}
struct segment_tree{
	int mx[D+D];
	inline void Init(){for(int i=0;i<(D+D);i++)mx[i]=0;}
	inline int Max(int l,int r){
		int res=0;
		for(l+=D,r+=D+2;l^r^1;l>>=1,r>>=1){
		  if(~l&1)res=std::max(res,mx[l^1]);
		  if( r&1)res=std::max(res,mx[r^1]);
		}return res;
	}
	inline void Insert(int k,int a){
		for(k+=D+1,mx[k]=std::max(mx[k],a),k>>=1;k;k>>=1)
		  mx[k]=std::max(mx[k<<1],mx[k<<1|1]);
	}
}t;
void Solve(int w,int h,point*a){
	m=h/2;
	for(int i=1;i<=n;i++)tmp[i]=a[i].x;
	tmp[n+1]=w;
	std::sort(tmp+1,tmp+2+n);
	k=0;
	for(int i=1;i<=n+1;i++)if(tmp[i]!=tmp[i-1])tmp[++k]=tmp[i];
	for(int i=1;i<=n;i++)a[i].x=std::lower_bound(tmp,tmp+1+k,a[i].x)-tmp;
	std::sort(a+1,a+1+n,Cmp);
	k0=k1=0;
	for(int i=0;i<=n;i++){
	  if(i==n||a[i+1].y<m){l=i;break;}
	}
	for(int i=2;i<=l;i++)
	  up[++k0]=(segment){a[i-1].x,a[i].x,h-m};
	for(int i=l+2;i<=n;i++)
	  dn[++k1]=(segment){a[i-1].x,a[i].x,m};
	if(l){
	  up[++k0]=(segment){0,a[1].x,h-m};
	  up[++k0]=(segment){a[l].x,k,h-m};
	}
	else up[++k0]=(segment){0,k,h-m};
	if(n-l){
	  dn[++k1]=(segment){0,a[l+1].x,m};
	  dn[++k1]=(segment){a[n].x,k,m};
	}
	else dn[++k1]=(segment){0,k,m};
	top=0;
	for(int i=1;i<=l;i++){
	  for(;top&&a[st[top]].y>=a[i].y;--top);
	  left[i]=!top?0:a[st[top]].x;
	  st[++top]=i;
	}
	top=0;
	for(int i=l;i;i--){
	  for(;top&&a[st[top]].y>=a[i].y;--top);
	  right[i]=!top?k:a[st[top]].x;
	  st[++top]=i;
	}
	top=0;
	for(int i=l+1;i<=n;i++){
	  for(;top&&a[st[top]].y<=a[i].y;--top);
	  left[i]=!top?0:a[st[top]].x;
	  st[++top]=i;
	}
	top=0;
	for(int i=n;i>l;i--){
	  for(;top&&a[st[top]].y<=a[i].y;--top);
	  right[i]=!top?k:a[st[top]].x;
	  st[++top]=i;
	}
	for(int i=1;i<=n;i++){
	  if(i<=l){
		if(i==1||a[i].x>a[i-1].x)
		  up[++k0]=(segment){left[i],right[i],a[i].y-m};
	  }
	  else{
		if(i==n||a[i].x<a[i+1].x)
		  dn[++k1]=(segment){left[i],right[i],m-a[i].y};
	  }
	}
	std::sort(up+1,up+1+k0,Cmpl);
	std::sort(dn+1,dn+1+k1,Cmpl);
	t.Init();
	for(int i=1,j=1;i<=k0;i++){
	  for(;j<=k1&&dn[j].l<=up[i].l;j++)
		t.Insert(dn[j].r,tmp[dn[j].r]+dn[j].h);
	  ans=std::max(ans,t.Max(up[i].l,up[i].r)-tmp[up[i].l]+up[i].h);
	}
	t.Init();
	for(int i=k0,j=k1;i;i--){
	  for(;j&&dn[j].l>=up[i].l;j--)
		t.Insert(dn[j].r,tmp[dn[j].r]-tmp[dn[j].l]+dn[j].h);
	  ans=std::max(ans,t.Max(up[i].l,up[i].r)+up[i].h);
	}
}
int main(){
    scanf("%d%d%d",&w,&h,&n);
	for(int i=1;i<=n;i++){
	  scanf("%d%d",&a[i].x,&a[i].y);
	  b[i].y=a[i].x,b[i].x=a[i].y;
	  c[i].x=a[i].x,c[i].y=h-a[i].y;
	  d[i].x=b[i].x,d[i].y=w-b[i].y;
	}
	Solve(w,h,a);
	Solve(h,w,b);
	Solve(w,h,c);
	Solve(h,w,d);
	printf("%d\n",ans<<1);
	return 0;
}

Measured memory_bytes: 29184
#include<stdio.h>
main()
{
  int n,x,t;
  scanf("%d%d%d",&n,&x,&t);
  if(n%x==0){
    n=(n/x)*t;
    printf("%d\n",n);
  }
  else{
    n= ((n/x)+1)*t;
    printf("%d\n",n);
    }
  }


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

Measured memory_bytes: 600
#include<stdio.h>
#include<string.h>
int main()
{
	char a[102],b[102];
	scanf("%s%s",a,b);
	if(strlen(a)>strlen(b))
	{
		printf("GREATER\n");
		return 0;
	}
	if(strlen(a)<strlen(b))
	{
		printf("LESS\n");
		return 0;
	}
	int i;
	i=0;
	while(a[i]==b[i] && i<strlen(a))
	  i++;
	if(i<strlen(a))
	{
		if(a[i]>b[i])
		{
			printf("GREATER\n");
			return 0;
		}
		else
		{
			printf("LESS\n");
			return 0;
		}
	}
	else
	{
		printf("EQUAL\n");
		return 0;
	}
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  while(true)
  {
   int H = sc.nextInt();
   int W = sc.nextInt();
   if(H == 0 && W == 0)
    break;
   for(int i = 0 ; i < H ; i++)
   {
    int x = 1;
    if(i % 2 == 0)
     x--;
    for(int j = 0 ; j < W ; j++)
    { 
     if(j % 2 == x)
      System.out.print("#");
     else
      System.out.print(".");
    }
    System.out.println();
   }
   System.out.println();
  }
 }
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << abs(a - b) + abs(b - c) + abs(c - a) - max({abs(a - b), abs(b - c), abs(c - a)}) << "\n";
    return 0;
}


Measured memory_bytes: 256
n,x = map(int,input().split())
ans = 0
i = n
while i >= 0:
    c = 2**(i+1) - 3
    num_p = 2**i - 1
    
    if 2*c + 3 == x:
        ans += 2*num_p + 1
        break
    elif c + 2 == x:
        ans += num_p + 1
        break
    elif 1 == x:
        break
    
    elif 2 + c <= x:
        x -= 2 + c
        ans += num_p + 1
    else:
        x -= 1
    
    i -= 1

print(ans)

Measured memory_bytes: 9144
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
using namespace std;


vector<bool> makeIsPrime(int n){
    vector<bool> prime(n + 1, true);
    if(n >= 0)prime[0] = false;
    if(n >= 1)prime[1] = false;
    for(int i = 2; i * i <= n; i++){
        if(!prime[i])continue;
        for(int j = i * i; j <= n; j += i){
            prime[j] = false;
        }
    }
    return prime;
}

int main(){
    int n;
    vector<bool> prime = makeIsPrime(300000);
    vector<int> primeCnt(300000, 0);
    for(int i = 0; i < 300000; i++){
        if(i == 0)primeCnt[i] = 0;
        else primeCnt[i] = primeCnt[i - 1] + (prime[i] ? 1 : 0);
    }

    while(cin >> n){
        if(n == 0)return 0;

        cout << primeCnt[2 * n] - primeCnt[n] << endl;
    }
}


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

int main()
{
	int N, W;
	cin >> N >> W;
	vector<long long> dp(W+1); // dp[w] = max value with weight w
	for (int i = 0; i < N; ++i)
	{
		long long w, v;
		cin >> w >> v;
		for (int j = W - w; j >= 1; --j)
		{
			if (dp[j] == 0)
				continue;
			dp[j + w] = max(dp[j + w], dp[j] + v);
		}
		dp[w] = max(dp[w], v);
	}
	cout << *max_element(dp.begin(), dp.end()) << '\n';
}


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

int main() {
  int n;cin>>n;
  int an[100100];rep(i,100100) an[i]=0;
  int a;
  rep(i,n) {
    cin>>a;
    an[a] ++;
  }
  int uni=0, dup=0;
  rep(i,100100) {
    if (an[i] > 0) {
      uni++;
      if (an[i]>1) dup += an[i]-1;
    }
  }
  uni -= dup%2;
  cout << uni;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

void solve(long long N, long long A, long long B, std::vector<long long> X) {
  ll n = 0;
  ll ans = 0;
  while (n < N - 1) {
    if ((X[n + 1] - X[n]) * A > B) {
      ans += B;
    } else {
      ans += (X[n + 1] - X[n]) * A;
    }
    n++;
  }
  print(ans);
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  std::vector<long long> X(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &X[i]);
  }
  solve(N, A, B, std::move(X));
  return 0;
}


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

int main() {
	ios_base::sync_with_stdio( false );

	array<int, 5> a;
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

	int result = INT_MAX;
	do {
		int x = 0;

		for( int i = 0; i < a.size(); ++i ) {
			x += a[i];
			if( i < a.size()-1 && a[i] % 10 > 0 ) {
				x += 10 - a[i] % 10;
			}
		}

		if( x < result ) {
			result = x;
		}
	}
	while( next_permutation( a.begin(), a.end() ) );

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
d = 0

b_sum = sum(b)
for i in range(n-1):
    if a[i]+1 == a[i+1]:
        d = c[a[i]-1] + d

print(b_sum + d)

Measured memory_bytes: 38496
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int M=2e6;
const int MOD=1000003;
#define fix(num) (int((num%MOD+MOD)%MOD))

struct MNUM{
	int num;
	MNUM(){}
	MNUM(int _num):num(_num){}
	MNUM operator +(const MNUM B)const{return fix(1ll*num+B.num);}
	MNUM operator -(const MNUM B)const{return fix(1ll*num-B.num);}
	MNUM operator *(const MNUM B)const{return fix(1ll*num*B.num);}
	MNUM operator +=(const MNUM B){return *this=(*this)+B;}
	MNUM operator -=(const MNUM B){return *this=(*this)-B;}
	MNUM operator *=(const MNUM B){return *this=(*this)*B;}
}Cfac[MOD+3],Cinv[MOD+3];

int q,n,x,d;

MNUM QPow(MNUM und,int cur){
	MNUM resu(1);
	while(cur){
		if(cur&1) resu*=und;
		und*=und;
		cur>>=1;
	}
	return resu;
}
void Init(){
	Cfac[0]=1;for(int i=1;i<MOD;i++) Cfac[i]=Cfac[i-1]*i;
	Cinv[MOD-1]=QPow(Cfac[MOD-1],MOD-2);for(int i=MOD-2;i>=0;i--) Cinv[i]=Cinv[i+1]*(i+1);
}
int main(){
	Init();
	scanf("%d",&q);
	while(q--){
		scanf("%d%d%d",&x,&d,&n);
		if(d==0){
			printf("%d\n",QPow(x,n).num);
			continue;
		}
		MNUM tmp=QPow(d,MOD-2)*x;
		long long l=tmp.num,r=tmp.num+n-1;
		if(r>=MOD) printf("0\n");
		else{
			MNUM ans=Cfac[r]*(l? Cinv[l-1]:0)*QPow(d,r-l+1);
			printf("%d\n",ans.num);
		}
	}
	return 0;
}

Measured memory_bytes: 8576
import numpy as np

def main():
    SpotNum = int(input())
    SpotCoordinate = [int(i) for i in input().split()]
    
    SpotCoordinate.insert(0, 0)
    SpotCoordinate.append(0)
    
    DiffSpotCoordinate = abs(np.diff(SpotCoordinate))
#    print(DiffSpotCoordinate)
    
#    SumTable = [0 for i in range(100000)]
##    print(SumTable)
#    
#    Diff = abs(SpotCoordinate[0] - SpotCoordinate[2] )
#    result = Diff + sum(DiffSpotCoordinate[2:])
#    print(result)
#    
#    for i in range(1,SpotNum):
#        if(SumTable == []):
#            SumTable[i-1] = sum(DiffSpotCoordinate[:i])
##            print(SumTable[i-1])
#        else:
#            SumTable[i-1] = SumTable[i-2] + sum(DiffSpotCoordinate[i-1:i])
##            print(SumTable[i-1])
#            
#        Diff = abs(SpotCoordinate[i] - SpotCoordinate[i+2] )
##        print(Diff)
#        
#        result = Diff + SumTable[i-1] + sum(DiffSpotCoordinate[i+2:])
##        print(RmSpotCoodinate)
##        print(sum(abs(np.diff(RmSpotCoordinate))))
#        print(result)
    
    SumDiffSpotCoordinate = sum(DiffSpotCoordinate)
    for i in range(1,SpotNum+1):
        result = SumDiffSpotCoordinate - DiffSpotCoordinate[i-1] - DiffSpotCoordinate[i] + abs(SpotCoordinate[i-1] - SpotCoordinate[i+1])
        print(result)
        
if __name__=="__main__":
    main()

Measured memory_bytes: 22928
import unittest
import functools


class TestE(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([2, 3, 4]), 13)

    def test_2(self):
        self.assertEqual(think([12, 12, 12, 12, 12]), 5)

    def test_3(self):
        self.assertEqual(think([1000000, 999999, 999998]), 996989508)

    def test_4(self):
        self.assertEqual(gcd(3, 2), 1)


def solve():
    a = read()
    result = think(a)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a):
    mode = 10 ** 9 + 7

    lcm_of_all_a = 1
    for e in a:
        lcm_of_all_a = lcm(lcm_of_all_a, e)

    lcm_of_all_a %= mode
    result = 0
    for e in a:
        result += lcm_of_all_a * inverse(e, mode) % mode
        result %= mode
    return result


def write(result):
    print(result)


def lcm(a, b):
    return a // gcd(a, b) * b 


def gcd(a, b):
    if a < b:
        return gcd(b, a)

    while True:
        if a % b == 0:
            return b
        a, b = b, a % b


def inverse(x, mode):
    return pow(x, mode - 2, mode)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 54248
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    let H = parseInt(arg[0].split(" ")[1]);

    let AB = arg.slice(1, N + 1).map(n=>n.split(" ").map(l=>parseInt(l)));
    
    AB.sort((a,b)=>b[0] - a[0]);
    
    let throwSum = 0;
    const strongest = AB[0][0];
    
    for(let i=0; i<N; i++) {
        if(AB[i][1] > strongest) {
            throwSum += AB[i][1];
        }
    }
    
    let cnt = 0;
    
    // while(H > throwSum) {
    //     H -= AB[0][0];
    //     cnt++;
    // }
    
    // console.log("cnt" + cnt);

    cnt += Math.ceil(((H - throwSum) / strongest));
    cnt = Math.max(0, cnt);
    
    H -= cnt * strongest;

    if(H <= 0) {
        console.log(cnt);
        return;
    } 

    AB.sort((a,b)=>b[1] - a[1]);
    
    for(let i=0; i<N; i++) {
        H -= AB[i][1];
        cnt++;
        
        if(H <= 0) break;
    }
    
    console.log(cnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 51904
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,count=0;
  cin>> n;
  int a[n];
  bool b=true;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  while(b){
    b=false;
    for(int i=n-1;i>0;i--){
      if(a[i]<a[i-1]){
        swap(a[i],a[i-1]);
        b=true;
        count++;
      }
    }
  }
  for(int i=0;i<n;i++){
    cout <<a[i];
    if(i!=n-1)cout<<' ';
  }
  cout<<endl<<count<<endl;
  return 0;
}
      


Measured memory_bytes: 3084
#!/usr/bin/env python3
#ABC125 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def gcd(n,m):
    if m == 0:
        return n
    else:
        return gcd(m,n%m)

n = I()
a = LI()
l,r = [0]*n,[0]*n
l[0] = a[0]
r[-1] = a[-1]
for i in range(1,n):
    l[i] = gcd(l[i-1],a[i])
for i in range(n-1)[::-1]:
    r[i] = gcd(r[i+1],a[i])
ans = 0
l = [0] + l + [0]
r = [0] + r + [0]
for i in range(1,n+1):
    ans = max(ans,gcd(l[i-1],r[i+1]))
print(ans)


Measured memory_bytes: 62444
N,*hs=$<.read.split.map(&:to_i)

hs << 10**9+1

ret = 0
count = 0
t = 0
hs.each do |h|
  if t < h
    ret = count if ret < count
    count = 0
  else
    count += 1
  end
  t = h
end

p ret


Measured memory_bytes: 9340
import sys

readline = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)


def main():
    N, Q = map(int, readline().split())
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, readline().split())
        G[a - 1].append(b - 1)
        G[b - 1].append(a - 1)
    X = [0] * N
    for i in range(Q):
        p, x = map(int, readline().split())
        X[p - 1] += x

    C = [0] * N

    def dfs(v, p):
        C[v] = C[p] + X[v]
        for nv in G[v]:
            if nv != p:
                dfs(nv, v)

    dfs(0, -1)

    print(*C)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 274424
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main() {
    int n;
    scanf("%d", &n);
    int t = 0, x = 0, y = 0;
    rep(i, n) {
        int next_t, next_x, next_y;
        scanf("%d%d%d", &next_t, &next_x, &next_y);
        int distance = abs(x - next_x) + abs(y - next_y);
        int timeleft = next_t - t;

        // 次の地点にたどり着けない
        if(distance > timeleft) {
            printf("No\n");
            return 0;
        }

        // 次の地点を越えれるけど偶奇が一致しないので、行って帰っての時間消費ができない
        if((timeleft % 2) != (distance % 2)) {
            printf("No\n");
            return 0;
        }

        t = next_t, x = next_x, y = next_y;
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 3720
s = int(input())

if s == 1 or s == 2 or s == 4:
    print(4)
    quit()

for i in range(1000000):
    if s % 2 == 0:
        s /= 2
    elif s % 2 == 1:
        s = 3 * s + 1

    if s == 4:
        print(i+5)
        break


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define mod 1000000007
#define MOD(x) ((x)%mod)
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)
using namespace std;
int n;
long long a[3005];
long long dp[3005][3005];
bool done[3005][3005];
void dfs(int s,int l,int r)
{
	done[l][r]=1;
	if(l==r)
	{
		if(s==1) dp[l][r]=a[l];
		else dp[l][r]=-a[l];
		return;
	}
	int t=!s;
	if(!done[l][r-1]) dfs(t,l,r-1);
	if(!done[l+1][r]) dfs(t,l+1,r);
	if(s==1) dp[l][r]=max(a[l]+dp[l+1][r],a[r]+dp[l][r-1]);
	else dp[l][r]=min(-a[l]+dp[l+1][r],-a[r]+dp[l][r-1]);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	dfs(1,1,n);
	printf("%lld",dp[1][n]);
	return 0;
}



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

#define make_it_fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define imn INT_MIN
#define imx INT_MAX

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}

template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}

void _print() {cerr << "]\n";}

template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...) 20
#endif

ll power(ll a,ll b,ll m=1e9+7)
{
    a%=m;
    if(b==1)
    return a;
    if(b==0)
    return 1LL;
    ll ret=power(a,b/2);
    ret=(ret*ret)%m;
    if(b&1)
    ret=(ret*a)%m;
    return ret;
}

ll lcm(ll a,ll b)
{
    return (a*b)/(__gcd(a,b));
}

void solve()
{
    string s;
    cin>>s;
    if(s.back()=='s')
    cout<<s<<"es";
    else
    cout<<s<<"s";
}

int main()
{
    make_it_fast;
    int TEST_CASES=1;
    // cin>>TEST_CASES;
    while(TEST_CASES--)
    {
        solve();
    }
    return 0;
}


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

int main(){
    int n,m,count=0;
    double total=0;

    cin >> n;
    cin >> m;

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

    for(int i=0;i<n;i++){
        if(a[i]>=(total/(4*m))){
            count++;
        }
    }
    
    if(count>=m){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
    //データ取り込み
		Scanner sc = new Scanner(System.in);
		//String S = sc.next();
    //int B = sc.nextInt();
    //System.out.println();
		String S1 = sc.next();
		String S2 = sc.next();
		String S3 = sc.next();
		System.out.println(""+S1.charAt(0)+S2.charAt(1)+S3.charAt(2));
	}
}


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

int main(){
	int n,m;
	cin >> n >> m;
	
	vector<int> from1, toN;
	for(int i=0; i<m; i++){
		int a,b;
		cin >> a >> b;
		if(a==1) from1.push_back(b);
		if(b==n) toN.push_back(a);
	}
	sort(from1.begin(), from1.end());
	sort(toN.begin(), toN.end());
	
	bool isfound=false;
	int i=0, j=0;
	while(i<(int)from1.size() && j<(int)toN.size()){
		if(from1[i]==toN[j]){
			isfound = true;
			break;
		}else if(from1[i]<toN[j]){
			i++;
		}else if(from1[i]>toN[j]){
			j++;
		}
	}
	
	if(isfound){
		cout << "POSSIBLE" << endl;
	}else{
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

main(){
  int x,sum=0,i,n,a,b;
  char s[110];
  int stack[110];
  int stack_top=0;
  
  while( scanf("%s",s) != EOF ){
    if( s[0] == '+' ){
      --stack_top;
      a = stack[stack_top];
      --stack_top;
      b = stack[stack_top];
      sum = a + b;
      stack[stack_top] = sum;
      stack_top++;
    }
    else if ( s[0] == '-' ){
      n =  stack[--stack_top];
      sum = stack[--stack_top] - n;
      stack[stack_top] = sum;
      stack_top++;
    } 
    else if ( s[0] == '*' ){
      --stack_top;
      a = stack[stack_top];
      --stack_top;
      b = stack[stack_top];
      sum = a * b;
      stack[stack_top] = sum;
      stack_top++;
    } 
    else {
      x = atoi(s);
      stack[stack_top] = x;
      stack_top++;
    }
  }
  for( i=0 ; i<stack_top ; i++) printf("%d\n",stack[i]);
  return 0;
}

Measured memory_bytes: 548
#include<stdio.h>
int main()
{
  int A,B,C;
  scanf("%d%d",&A,&B);
  C=A*B;
  if(A<=9 && B<=9)  {
    printf("%d\n",C);}
  
  else { printf("-1\n");
       }
  return 0;
}


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

int n, a[100009], b[100009], G[100009], ans[100009];
vector<int>x[100009], y[100009]; bool used[100009]; vector<int>V;

vector<int>solve(vector<int>Z) {
	vector<int>J; J.push_back(0);
	for (int i = 0; i < Z.size(); i++) Z[i] -= 2;
	for (int i = 0; i < Z.size(); i++) {
		int B = J.size();
		for (int j = 0; j < Z[i]; j++) J.push_back(B + j + 1);
		J.push_back(B);
	}
	J.push_back(n - 1);
	return J;
}

int main() {
	cin >> n;
	for (int i = 1; i <= n - 1; i++) {
		cin >> a[i] >> b[i];
		G[a[i]]++; G[b[i]]++;
		y[a[i]].push_back(b[i]);
		y[b[i]].push_back(a[i]);
	}
	int t = 0, eg = 0;
	for (int i = 1; i <= n - 1; i++) {
		if (G[a[i]] >= 2 && G[b[i]] >= 2) {
			x[a[i]].push_back(b[i]);
			x[b[i]].push_back(a[i]);
			eg++;
		}
	}
	int ver = 0;
	for (int i = 1; i <= n; i++) {
		if (x[i].size() >= 1) ver++;
		if (y[i].size() >= 2) t = i;
	}
	if (!(ver == eg + 1 || ver == 0)) {
		cout << "-1" << endl;
		return 0;
	}
	int s = 0;
	for (int i = 1; i <= n; i++) {
		if (x[i].size() >= 3) {
			cout << "-1" << endl;
			return 0;
		}
		if (x[i].size() == 1) s = i;
	}
	if (s == 0) s = t;
	used[s] = true; V.push_back(y[s].size());

	while (true) {
		bool flag = false;
		for (int i = 0; i < x[s].size(); i++) {
			if (used[x[s][i]] == false) {
				used[x[s][i]] = true;
				s = x[s][i]; flag = true;
				break;
			}
		}
		if (flag == true) V.push_back(y[s].size());
		else break;
	}
	vector<int>F1 = solve(V); reverse(V.begin(), V.end());
	vector<int>F2 = solve(V);
	vector<int>F = min(F1, F2);
	for (int i = 0; i < F.size(); i++) { if (i)cout << " "; cout << F[i] + 1; }cout << endl;
	return 0;
}

Measured memory_bytes: 14964