akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

//#include<bits/stdc++.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define _USE_MATH_DEFINES
#define ll long long
#define ins Not Needed Thing
#define ull unsigned long long
#define ld long double
#define Accepted 0
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define SORRY FUL Accepted 
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
#define Toktama Kazakhstan 

using namespace std;

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 3e5 + 123;                                          
const int PRI = 555557;
const int pri = 997;

int tests = 1;
int n, a[N], l, r;
ll sum, res[N], ans = -INF;
multiset < int > s1, s2;

inline void Solve () {
	//easy
	cin >> n;
	for (int i = 1; i <= n * 3; i ++)
		cin >> a[i];	

	for (int i = 1; i <= n; i ++) {
		s1.insert(a[i]);
		sum += a[i];
		res[n + n + 1] += a[i + n + n];
		s2.insert(a[i + n + n]);
	}

	for (int i = n; i >= 1; i --) {
		res[i + n] = res[n + i + 1] - *s2.rbegin() + a[i + n];
		if (res[i + n] >= res[n + i + 1]) {
			res[i + n] = res[n + i + 1];
			continue;
		}
		int it = *s2.rbegin();
		s2.erase(s2.find(it));
		s2.insert(a[i + n]);
	}

	for (int i = 1; i <= n; i ++) {
	//	cout << sum << ' ' << res[i + n] << '\n';
	//	cout << sum - res[i + n] << '\n';
		ans = max(ans, sum - res[i + n]);
		if (a[i + n] > *s1.begin()) {
			sum -= *s1.begin();	
			sum += a[i + n];
			s1.erase(s1.begin());
			s1.insert(a[i + n]);
		}
	}
	ans = max(ans, sum - res[n + n + 1]);
	

	cout << ans;
}

int main () {
	SpeedForce;
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);	
	// cin >> tests;
	while(tests --) {
		Solve ();
		// Ee Zadrot
	}

	return Accepted; 
}

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

int main(int argc, char *argv[])
{
    int N, H;
    std::cin >> N >> H;

    std::vector<int> a(N), b(N);

    int a_max = -1;
    for (int i = 0; i < N; i++) {
        std::cin >> a[i] >> b[i];
    }

    for (int i = 0; i < N; i++) {
        if (a[i] > a_max) {
            a_max = a[i];
        }
    }

    std::sort(b.begin(), b.end(), std::greater<int>());

    int count = 0;
    bool flag = true;

    for (int i = 0; i < N; i++) {
        if (b[i] < a_max) {
            break;
        }
        H -= b[i];
        count++;
        if (H <= 0) {
            flag = false;
            break;
        }
    }

    if (flag) {
        count += H/a_max + (H%a_max != 0);
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    long mod = 998244353;
    int n = 1;
    int[] dat;
    int default_value = 0;
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        // int t = sc.nextInt();
        int t= 1;
        while(t-->0){
            out.println(main.solve());
        }
        out.flush();
    }
    long solve() throws Exception{
        int H = sc.nextInt(), W = sc.nextInt(), M = sc.nextInt();
        int[] col = new int[W];
        while(n<W) n*=2;
        dat = new int[2*n-1];
        List<Integer>[] rows = new List[H];
        for(int i=0; i<H; i++) rows[i] = new LinkedList<>();
        for(int i=0; i<M; i++){
            int r = sc.nextInt()-1, c = sc.nextInt()-1;
            rows[r].add(c);
            col[c]++;
        }
        for(int j=0; j<W;j++){
            update(j, col[j]);
        }
        int ans = 1;
        for(int i=0; i<H; i++){
            for(int c:rows[i]){
                update(c, -1);
            }
            int maxi = rangeMax(0,0,n-1,0,n-1);
            ans = Math.max(ans, maxi+rows[i].size());
            for(int c:rows[i]){
                update(c, 1);
            }
        }


        return ans;
    }
    void update(int k, int delta_val){
        k += n-1;
        dat[k] += delta_val;
        while(k>0){
            k = (k-1)/2;
            dat[k] = Math.max(dat[k*2+1], dat[k*2+2]);
        }
    }
    int rangeMax(int k, int qstart, int qend, int nstart, int nend){
        if(qstart>nend || qend < nstart) return default_value;
        if(qstart <= nstart && nend <= qend) return dat[k];
        int mid = (nstart+nend)/2;
        int left = rangeMax(k*2+1, qstart, qend, nstart,mid);
        int right = rangeMax(k*2+2, qstart, qend, mid+1, nend);
        return Math.max(left, right);
    }

    int paIn(String s){return Integer.parseInt(s);}
}

Measured memory_bytes: 88076
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    double N;
    int K;
    cin >> N >> K;

    double ans = 0;
    FOR(i, 1, N + 1)
    {
        int point = i;
        double prob = 1 / N;
        while (point < K)
        {
            point *= 2;
            prob /= 2.0;
        }
        ans += prob;
    }

    cout << setprecision(12) << ans;
}

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

int main()
{
    /* Input */
    int N, X, Y;
    std::cin >> N >> X >> Y;

    /* Solve */

    // 最短距離をインデックスに持つ配列
    // 最短距離を算出するごとに対応するインデックスをカウントアップ
    std::vector<int> map(N+1, 0);
    int min_dist = 0;
    for (int i = 1; i < N; i++)
    {
        for (int j = i+1; j <= N; j++)
        {
            min_dist = std::min(j-i, std::abs(X-i) + std::abs(Y-j) + 1);
            map[min_dist]++;
        }
    }

    for (int i = 1; i < N; i++)
        std::cout << map[i] << std::endl;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(100009);
  for(int i=0;i<N;i++)cin >> A[i];
  vector<int> q(100000),w(99998);
  for(int i=0;i<100000;i++)q[i]=0;
  for(int i=0;i<N;i++){q[A[i]]++;}
  for(int i=0;i<99998;i++){w[i]=0; w[i]+=q[i]+q[i+1]+q[i+2];}
  sort(w.begin(),w.end());
  cout << w[99997] << endl;
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << min(a+b, min(b+c, c+a)) << endl;
}






Measured memory_bytes: 256
N, M = map(int,input().split())
H = list(map(int,input().split()))
L = [1] * N

for i in range(M):
  A, B = map(int, input().split())
  if H[A - 1] > H[B - 1]:
    L[B - 1] = 0
  elif H[A - 1] < H[B - 1]:
    L[A - 1] = 0
  else:
    L[A - 1] = 0
    L[B - 1] = 0
  
print(L.count(1))

Measured memory_bytes: 20116
package main

import (
	"fmt"
)

func reverse(s string) string {
	ans := ""
	for i, _ := range s {
		ans += string(s[len(s)-i-1])
	}
	return string(ans)
}

func main() {
	var w string
	fmt.Scan(&w)

	length := len(w)
	var half int
	if length%2 == 0 {
		half = length / 2
	} else {
		half = (length / 2) + 1
	}
	h1 := w[:(length / 2)]
	h2 := w[half:]
	rh2 := reverse(h2)
	var count int
	for i := 0; i < len(h1); i++ {
		if h1[i] != rh2[i] {
			count++
		}
	}
	fmt.Println(count)
}


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

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18

int main()
{
    int X; cin >> X;
    if (X < 5) {
        cout << 0 << endl;
        return 0;
    }
    int happy = 0;
    int num500 = (X / 500);
    happy += num500 * 1000;
    X -= num500 * 500;

    int num5 = (X / 5);
    happy += num5 * 5;
    cout << happy << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef pair<int,int> P;
typedef long long ll;

int main(){
	int k,n;
	ll h[100000];

	cin >> n >> k;
	for(int i=0;i<n;i++) cin >> h[i];
	sort(h,h+n);

	ll min = 10e9;

	for (int i = 0; i < n-k+1; i++){
		if(min >  h[i+k-1]- h[i])
			min = h[i + k - 1] - h[i];
	}

		cout << min << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<utility>
#include<cstdio>
#include<cstring>
#include<new>
#include<float.h>
#include<ctype.h>
#include<cfloat>
#include<cmath>
#include<cctype>
#include<sstream>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define sz size()
#define em empty()
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int a,b;
	cin>>a>>b;
	cout<<a+b/2;
	return 0;
}


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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long
#define ld long double

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, p;
    cin >> n >> p;
    vector<ll> my_pow(n + 1);
    my_pow[0] = 1;
    for (int i = 1; i <= n; i++) my_pow[i] = (my_pow[i - 1] * 10) % p;
    string s;
    cin >> s;
    if (p == 2 || p == 5) {
        ll ans = 0;
        for (int i = 0; i < n; i++) {
            if ((s[i] - '0') % p == 0) ans += (i + 1);
        }
        cout << ans;
        return 0;
    }
    vector<int> cnt(p);
    cnt[0]++;
    int cur = 0;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        cur *= 10;
        cur += s[i] - '0';
        cur %= p;
        ans += cnt[(cur * my_pow[n - i - 1]) % p];
        cnt[(cur * my_pow[n - i - 1]) % p]++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 5180
#include <stdio.h>
using namespace std;

int main(){
    int h1,m1,h2,m2,k;
    scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
    int a = 60*(h2-h1) + (m2-m1);
    if(a <= k){
        printf("0\n");
    }else{
        printf("%d\n", a - k);
    }
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);


  double h,a;cin>>h>>a;
  cout<<ceil(h/a)<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(int i=0;i<n;i++)
#define FOR1(i,n) for(int i=1;i<=n;i++)
#define FORl(i,l,n) for(int i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll mod = 1e9 + 7;

ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}


int main(){
    ll n;
	cin >> n;
	map<ll,ll> my;
	for(ll i = 1; i*i <= n; i++){
		for(ll j = 1; j*j <= n; j++){
			for(ll k = 1; k *k <= n; k++){
				ll val = i*i + j*j + k*k + i*j + j*k + k*i;
				my[val]++;
			}
		}
	}
	for(ll i = 1; i <= n; i++){
		cout << my[i] << endl;
	}
}

Measured memory_bytes: 6028
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    ll A[N];
    REP(i, N) cin >> A[i];

    ll total = 0;
    REP(i, N) total += A[i];

    ll F[N];
    ll t = total;
    for (int i = 0; i < N - 2; i += 2) {
        t -= 2 * A[i];
    }
    F[N - 1] = t;
    for (int i = N - 2; i >= 0; --i) {
        F[i] = 2 * A[i] - F[i + 1];
    }
    cout << F[0];
    REP(i, N - 1) cout << " " << F[i + 1];
    cout << endl;
    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n;
    long long m=0,a=0,r=0,c=0,h=0;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        switch(s[0]){
            case 'M':
            m++;
            break;
            case 'A':
            a++;
            break;
            case 'R':
            r++;
            break;
            case 'C':
            c++;
            break;
            case 'H':
            h++;
            break;
        }
    }
    cout<<m*a*(r+c+h)+m*r*(c+h)+(m+a+r)*c*h+a*r*(c+h)<<endl;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	vector<vector<bool>>g(n,vector<bool>(n,false));
	for(int i=0;i<m;++i){
		int a,b; cin>>a>>b; --a,--b;
		g.at(a).at(b)=true;
		g.at(b).at(a)=true;
	}
	int ans=0;
	for(int i=0;i<n;++i){
		for(int j=i;j<n;++j){
			if(!g.at(i).at(j))continue;
			g.at(i).at(j)=false;
			g.at(j).at(i)=false;
			vector<bool>usd(n,false); usd.front()=true;
			queue<int>q; q.push(0);
			while(q.size()){
				int cur=q.front(); q.pop();
				for(int k=0;k<n;++k){
					if(!g.at(cur).at(k)||usd.at(k))continue;
					usd.at(k)=true;
					q.push(k);
				}
			}
			if(count(usd.begin(),usd.end(),false))++ans;
			g.at(i).at(j)=true;
			g.at(j).at(i)=true;
		}
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3596
horses = [4, 1, 4, 1, 2, 1, 2, 1]

readlines.each do |passengers|
  ps = passengers.chomp.split.map(&:to_i)
  hs = horses.dup
  ans = horses.dup
  max = 0
  (0..7).each do |i|
    temp = ps.map.with_index{ |p, j| (p < hs[j] ? p : hs[j])}.inject(&:+)
    if max < temp
      max = temp
      ans = hs.dup
    elsif max == temp
      ans = hs.dup if hs.join.to_i < ans.join.to_i
    end
    hs.rotate!
  end

  puts ans.join(' ')
end

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

int main(){
      int A,B,C,X,check=0;

      cin >> A >> B >> C >> X;

      for(int i = 0;i <= A;i++){
            for(int j = 0;j <= B;j++){
                  for(int k = 0;k <= C;k++){
                        if(500*i + 100 * j + 50 * k == X)check++;
                  }
            }
      }
      cout << check << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int n;
    cin>>n;
    if(n%1000==0){
        cout << 0 << endl;
        return 0;
    }
    cout << 1000-(n%1000) << endl;
    return 0;
}

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

using namespace std;

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

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    string S;
    cin>>S;
    string A=S.substr(5,2),B=S.substr(8,2);
    int a=stoi(A),b=stoi(B);
    if(a<=4){
        cout<<"Heisei"<<endl;
    }else if(5<=a){
        cout<<"TBD"<<endl;
    }
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int[][] AB = new int[N][2];
        for (int i = 0; i < N; i++) {
            AB[i][0] = sc.nextInt();
            AB[i][1] = sc.nextInt();
        }

        Arrays.sort(AB, (a, b) -> a[0] - b[0]);

        int max = 0;
        int[][] dp = new int[N+1][T];

        for (int i = 0; i < N; i++) {
            int a = AB[i][0];
            int b = AB[i][1];
            for (int j = T - 1; j >= 0; j--) {
                dp[i+1][j] = dp[i][j];
                if (j >= a) {
                    dp[i+1][j] = Math.max(dp[i+1][j], dp[i][j-a] + b);
                }
            }
            max = Math.max(max, dp[i][T-1] + b);
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 69632
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int r;
	cin >> r;
	cout << 3 * r*r << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);
ll nCr(ll n, ll m) {
    if (m > n) return 0;
    ll ans = 1;
    for(ll i = 1; i <= m; i++) {
        ans *= (n+1-i);
        ans /= i;
    }
    return ans;
}
ll sub(string n, int k) {
    int len = n.size();
    ll ans = nCr(len-1, k) * pow(9, k);
    // cout << "step 1 " << ans << endl;
    ans += (n[0] - '1') * nCr(len-1, k-1) * pow(9, k-1);
    k--;
    if (k > 0) {
        for(int i = 1; i < n.size(); i++) {
            if (n[i] != '0') {
                ans += sub(n.substr(i), k);
                break;
            }
        }
    } else {
        ans += 1;
    }
    return ans;
}

int main() {
    string n;
    int k = 0;
    cin >> n >> k;
    cout << sub(n, k) << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

S = list(input())
N = len(S)

for i in range(1, N):
    if S[i - 1] == S[i]:
        print (i, i + 1)
        exit()

for i in range(2, N):
    if S[i - 2] == S[i]:
        print (i - 1, i + 1)
        exit()

print (-1, -1)

Measured memory_bytes: 3956
#include<iostream>
#include<string>
#include<set>
using namespace std;
int main(){
  int n;
  set<string>st;
  cin>>n;
  for(int i=0;i<n;i++){
    string str;
    cin>>str;
    st.insert(str);
  }
  cout<<st.size()<<endl;
  return(0);
}

Measured memory_bytes: 19124
#include<stdio.h>
#include<ctype.h>
int main(void)
{
  char a[10],b[10],c[10];
  scanf("%s",a);
  scanf("%s",b);
  scanf("%s",c);
  a[0]=toupper(a[0]);
  b[0]=toupper(b[0]);
  c[0]=toupper(c[0]);
  printf("%c%c%c\n",a[0],b[0],c[0]);
  return 0;
}

Measured memory_bytes: 128
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        s: chars,
    }

    if s[2] == s[3] && s[4] == s[5] {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	int a;
	int b;
	int sub;
}GROUP;

int cmp( const void *p, const void *q ) {
    return ((GROUP*)q)->sub - ((GROUP*)p)->sub;
}

int main(void){
	
	int i, n, ans = 0;
	long diff = 0;
	
	scanf("%d", &n);
	
	GROUP group[n];
	
	for (i = 0; i < n; i++){
		scanf("%d", &group[i].a);
	}
	for (i = 0; i < n; i++){
		scanf("%d", &group[i].b);
	}
	
	for (i = 0; i < n; i++){	
		if(group[i].a - group[i].b < 0){
			ans++;
			diff += group[i].b - group[i].a;
			group[i].sub = 0;
		}else{
			group[i].sub = group[i].a - group[i].b;
		}
	}
	
	if(diff == 0){
		printf("0");
		return 0;
	}
	
	qsort(group, n, sizeof(GROUP), cmp);
	
	for (i = 0; i < n; i++){
		if(group[i].sub >= diff){
			ans++;
			diff == 0;
			printf("%d", ans);
			return 0;
		}else{
			ans++;
			diff -= group[i].sub;
		}
	}
	
	printf("-1");
	
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int x,y; cin>>x>>y;
	cout<<(x%y?x:-1)<<"\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.Stream;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] nums = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    System.out.println(nums[0] < nums[1] ? 0 : 10);
  }
}

Measured memory_bytes: 28244
import itertools

N = int(input())
L = list(map(int, input().split()))

count = 0
for a in itertools.combinations(L, 3):
    if len(set(a)) != 3:
        continue
    a = sorted(a)
    if a[2] < a[0] + a[1]:
        count += 1
print(count)

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <cstdio>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;

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

struct edge{
	int to, cost;
};

int main(){
	while(1){
		int n;
		scanf("%d", &n);
		if(n==0) return 0;

		vector<vector<llong> > v(15, vector<llong>(15, INF));
		int m=0;
		REP(i, n){
			int f, t, c;
			scanf("%d %d %d", &f, &t, &c);
			m=max(m, f);
			m=max(m, t);
			v[f][t]=c;
			v[t][f]=c;
		}
		m++;
		REP(i, m) v[i][i]=0;

		REP(i, m){
			REP(j, m){
				REP(k, m){
					v[j][k]=min(v[j][k], v[j][i]+v[i][k]);
					
				}
			}
		}

		int ans=0;
		vector<llong> sum(15, 0);
		REP(i, m){
			REP(j, m){
				if(v[i][j]>=INF) continue;
				sum[i]+=v[i][j];
			}
			if(sum[ans]>sum[i]) ans=i;
		}

		printf("%d %ld\n", ans, sum[ans]);
	}
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    ll ans=k;
    rep(i,n-1){
        ans*=k-1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main() {
	vector<int> vec(3);
	rep(i, 3) {
		cin >> vec[i];
	}
	sort(vec.begin(), vec.end());

	int A = vec[2] - vec[0];
	cout << A << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n, r, s, p, k;
	char t[100002];
	int i, j;
	long long int ret;
	int index;
	char cur;
	char next;
	char past;
	int index_c;
	int index_n;
	int prc;
	int flag;

	int jdg[3][3];
	int point[3];

	scanf("%d %d", &n, &k);
	scanf("%d %d %d", &r, &s, &p);
	scanf("%s", t);

	ret = 0;

	for (i = 0; i < k; i++){
		flag = 0;
		past = '0';
		for (j = 0; j * k + i < n; j++){
			index = j * k + i;

			cur = t[index];
			if (cur == past && flag == 1){
				prc = 0;
				flag = 0;
			}
			else if (index + k >= n){
				// 次の手を気にしなくていい場合 -> 無条件で勝ち
				prc = 1;

			}
			else{
				// 次の手を気にする場合
				next = t[index + k];
				if (cur == next){ flag = 1; }
				prc = 1;
			}

			// 勝ったときの加算処理
			if (prc == 1){
				switch (cur){
				case 'r':
					ret += p;
					break;

				case 's':
					ret += r;
					break;

				case 'p':
					ret += s;
					break;

				default:
					// No Operation
					break;

				}
			}
//			printf("%d : %d ( ret = %lld )\n", index, prc, ret);
			past = cur;
		}
	}

	printf("%lld\n", ret);

	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
	ll N;
	string S;
	ll Q;
	cin >> N >> S >> Q;
	vector<ll> k(Q);
	REP(i, Q) cin >> k[i];
	
	REP(j, Q){
		ll D = 0;
		ll M = 0;
		ll DM = 0;
		ll res = 0;
		REP(i, N){
			if(S[i]=='D'){
				D++;
			}
			if(S[i]=='M'){
				M++;
				DM += D;
			}
			if(S[i]=='C'){
				res += DM;
			}
			if(i>=k[j]-1){
				if (S[i-k[j]+1]=='D'){
					D--;
					DM -= M;
				}
				if (S[i-k[j]+1]=='M'){
					M--;
				}
			}
		}
		cout << res << endl;
	}

    return 0;
}

Measured memory_bytes: 1412
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#include <iomanip>
#define rep(i,x) for(ll i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
using graph = vector<vector<ll>>;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}/*フィボナッチテンプレ
ll memo[50];
ll fibo(ll n) {
    if (memo[n] != 0)return memo[n];
    if (n <= 1)return memo[n] = n;
    else return memo[n] = fibo(n - 1) + fibo(n - 2);
}
*/
bool isp(ll n) {
    bool res = true;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            res = false;
            break;
        }
    }
    return res;
}

int main() {
  ll N;
  cin >> N;
  if(N == 1)cout << "Hello World" << endl;
  else{
    ll a,b;
    cin >> a >> b;
    cout << a + b << endl;
  }
}

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

#define ios  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll n;

int main() {
    ios;

    ll n,k;
    cin>>n>>k;
    ll arr[n+1][2]={0};
    for(ll i=1;i<=n;i++)
    {
        cin>>arr[i][0]>>arr[i][1];
    }
      ll dp[n+1][k+1]={0};
      for(ll i=0;i<=n;i++)
      {
          for(ll j=0;j<=k;j++)
          {
              if(i==0||j==0)
                dp[i][j]=0;
            else  if(arr[i][0]>j)
                dp[i][j]=dp[i-1][j];
              else
               dp[i][j]=max(arr[i][1]+dp[i-1][j-arr[i][0]],dp[i-1][j]);

          }

          }
      cout<<dp[n][k];
     return 0;
}


Measured memory_bytes: 79232
import java.util.*;

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

        for (int i = 0; i < n; i++) {
          list[i] = sc.next();
        }
        Arrays.sort(list);
        String answer = "";
        for(int i = 0; i < n; i++) {
          answer +=list[i];
        }      
       
            System.out.println(answer);
    }
}


Measured memory_bytes: 23380
#include<iostream>
#include<string>
using namespace std;
int main (){
    int a, b;
    string op;
    for (int i=0; ;i++){
        
        cin >> a >> op >> b;
        if (op == "+"){
            cout << a + b << endl;
        }
        else if (op == "+"){
            cout << a + b << endl;
        }
        else if (op == "-"){
            cout << a - b << endl;
        }
        else if (op == "*"){
            cout << a * b << endl;
        }
        else if (op == "/"){
            cout << a / b << endl;
        }
        else if (op == "?"){
            break;
        }
        
    }
    return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>
int main()
{
    int a, b,i;
    scanf("%d %d", &a, &b);
    char ch[a];
    for(i=0;i<=a;i++){
        scanf("%c", &ch[i]);
        if(i==b)
            ch[i]= ch[i]+32;

        printf("%c", ch[i]);
    }
    printf("\n");
    return 0;

}


Measured memory_bytes: 128
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    int n, q;
    ll t;
    cin >> n >> t >> q;

    ll d, a;
    vector<pair<ll,int>> x;
    vector<pair<ll,int>> v[2]; // 0-right, 1-left
    for(int i = 0; i < n; i++){
        cin >> d >> a;
        a--;
        v[a].push_back({d,i});
        x.push_back({d,a});
    }

    sort(v[0].begin(), v[0].end());
    sort(v[1].begin(), v[1].end());

    priority_queue<pair<ll,pii>, vector<pair<ll,pii>>, greater<pair<ll,pii>>> pq;
    for(pair<ll,int> p : v[0]){
        auto it = lower_bound(v[1].begin(), v[1].end(), p);
        if(it == v[1].end())    continue;
        pq.push({(*it).first-p.first, {p.second, (*it).second}});
    }

    set<ll> fixed;
    while(!pq.empty()){
        auto p = pq.top();  pq.pop();
        int l = p.second.first, r = p.second.second;
        ll dist = p.first;
        if(dist/2 > t)  break;
        auto itl = fixed.lower_bound(x[l].first), itr = fixed.lower_bound(x[r].first-dist/2);
        bool lb = itl == fixed.end() || *itl > x[l].first+dist/2;
        bool rb = itr == fixed.end() || *itr > x[r].first;
        if(lb && rb){
            fixed.insert(dist/2+x[l].first);
        }
    }

    int ask;
    for(int i = 0; i < q; i++){
        cin >> ask;
        ask--;
        if(x[ask].second == 0){
            auto it = fixed.lower_bound(x[ask].first);
            if(it == fixed.end() || *it > x[ask].first+t){
                cout << x[ask].first+t << endl;
            }else{
                cout << *it << endl;
            }
        }else{
            auto it = fixed.lower_bound(x[ask].first);
            if(it != fixed.begin()) it--;
            if(fixed.empty() || *it > x[ask].first || *it < x[ask].first-t){
                cout << x[ask].first-t << endl;
            }else{
                cout << *it << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 8024
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
A = sorted(A, reverse=True)
d = defaultdict(int)
for i in range(N):
  d[A[i]] += 1
d = sorted(d.items(), key=lambda x:x[1], reverse=True)
d = sorted(d, key=lambda x:x[0], reverse=True)
a = []
for key, val in d:
  if 2 <= val <= 3:
    a.append(key)
  elif val >= 4:
    a.append(key)
    a.append(key)
  if len(a) >= 2:
    print(a[0]*a[1])
    exit()
if len(a) < 2:
  print(0)

Measured memory_bytes: 21540
/* B - ... (Triple Dots) */

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

int main(){
  int K;
  string S;
  cin >> K >> S;
  if(S.size() <= K){
    cout << S << endl;
  }else{
    for(int i = 0; i < K; i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}


Measured memory_bytes: 3620
import java.util.*;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String args[]) {

        int n = sc.nextInt();

        List<Integer> ryokan = new ArrayList<>();

        int c = 0;
        for (int i=0; i < n; i++) {
            ryokan.add(sc.nextInt());
            if (check(i, ryokan))
                c++;
        }

        System.out.println(c);

    }

    private static boolean check(int i, List<Integer> ryokan) {
        for (int j=0; j < i; j++) {
            if (ryokan.get(j) > ryokan.get(i))
                return false;
        }
        return true;
    }

}


Measured memory_bytes: 22996
#include<cstdio>
#include<algorithm>
typedef long long LL;
const int N=1e6+2,md=998244353;
int n,k,fac[N],iv[N],ans;
inline void upd(int&a){a+=a>>31&md;}
inline int C(int n,int m){return(n>=m)?(LL)fac[n]*iv[m]%md*iv[n-m]%md:0;}
inline int calc(int R,int B){
	int r=C(R+B,R);
	if(R-B<n)upd(r-=C(R+B,2*R-n+1));
	return r;
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=*fac=1;i<N;++i)fac[i]=(LL)fac[i-1]*i%md;
	iv[N-1]=741754199;
	for(int i=N-2;~i;--i)iv[i]=(i+1LL)*iv[i+1]%md;
	for(int R=std::max(k+1>>1,n);R<=k;++R)upd(ans+=calc(R,R==k-R?R-1:k-R)-md);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
int n,tim,mn=1001;
int c[1001],t[1001];
int main(){
  	cin>>n>>tim;
  	for(int i=1;i<=n;i++){
    	cin>>c[i]>>t[i];
    	if(c[i]<mn&&t[i]<=tim)
    		mn=c[i];
	}
	if(mn==1001)
		cout<<"TLE"<<endl;
	else 
		cout<<mn<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T>
T pow_ (T x, T n, T M){
    uint64_t u = 1, xx = x;
    while (n > 0){
        if (n&1) u = u * xx % M;
        xx = xx * xx % M;
        n >>= 1;
    }
    return static_cast<T>(u);
};

int main() {
    int n, p;
    cin >> n >> p;
    string s;
    cin >> s;
    if(p <= 10){
        vector<int> m(p), m2(p);
        ll ans = 0;
        for (int i = 0; i < s.size(); ++i) {
            fill(m2.begin(),m2.end(), 0);
            m2[(s[i]-'0')%p]++;
            for (int j = 0; j < p; ++j) {
                m2[(j*10+(s[i]-'0'))%p] += m[j];
            }
            ans += m2[0];
            m = m2;
        }
        cout << ans << "\n";
    }else {
        map<int, int> m;
        int val = 0;
        vector<int> vs(n+1);
        ll aaa = 1;
        for (int i = n-1; i >= 0; --i) {
            val = (val + (s[i]-'0')*aaa)%p;
            aaa = (aaa*10)%p;
            m[val]++;
            vs[i] = val;
        }
        ll ans = 0;
        for (int i = n-1; i >= 0; --i) {
            ans += m[vs[i+1]];
            m[vs[i]]--;
        }
        cout << ans << "\n";
    }


    return 0;
}

Measured memory_bytes: 1668
D="A23456789TJQK",S="SCHD",b[5][13],F,d,u,s,B,f,i;main(N){for(;~scanf("%d",&N);){for(i=i&&!puts("");i<61;i++)scanf("%d",b[i/13]+i%13);for(;N--;){char*t,c[]="00000000000000",h[5]={f=B=0};for(i=5;i--;i>3?u=s:0,f|=s-u)scanf("%as",&t),c[d=strchr(D,*t)-D]++,B+=b[s=strchr(S,t[1])-S][d];for(c[i=13]=*c;i--;t=strstr(c,"11111"))h[c[i]-48]++;printf("%d\n",b[4][f?t?3:h[4]?6:h[3]?h[2]?5:2:h[2]?h[2]-1:9:t-c-9?t?7:4:8]*B);}}}

Measured memory_bytes: 4496
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair

using std::sort;
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::pair;
using std::reverse;
typedef long long ll;


#define pb push_back
#define mp std::make_pair
#define all(x) (x).begin(),(x).end()

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



Measured memory_bytes: 256
a,b,c,x = 4.times.map {gets.to_i}
count = 0
(0..a).each do |i|
    (0..b).each do |j|
        (0..c).each do |k|
             count += 1 if i*500 + j*100 + k*50 == x
        end
    end
end

puts count

Measured memory_bytes: 1788
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc=new FastScanner();
		int n = sc.nextInt();
		long maxxi_y1 = Integer.MIN_VALUE;
		long minxi_y1 = Integer.MAX_VALUE;
		long maxxi_plus_y1 = Integer.MIN_VALUE;
		long minxi_plus_y1 = Integer.MAX_VALUE;
		long x[][] = new long[n][2];
		for(int i =0;i<n;i++) {
			x[i][0] = sc.nextLong();
			x[i][1] = sc.nextLong();
			maxxi_y1 = Math.max(maxxi_y1, x[i][0]-x[i][1]);
			maxxi_plus_y1 = Math.max(maxxi_plus_y1, x[i][0]+x[i][1]);
			minxi_plus_y1 = Math.min(minxi_plus_y1, x[i][0]+x[i][1]);
			minxi_y1 = Math.min(minxi_y1, x[i][0]-x[i][1]);
		}
		long ans =0;
		
			ans  = Math.max( (maxxi_plus_y1-minxi_plus_y1), (maxxi_y1 - minxi_y1) );
			System.out.println(ans);
		
	}
	
	
	static final Random random = new Random();
	
	static void sort(int[] a) {
		int n = a.length;
		for(int i =0; i<n; i++) {
			int val = random.nextInt(n);
			int cur = a[i];
			a[i] = a[val];
			a[val] = cur;
		}
		Arrays.sort(a);
	}
	
	static void sortl(long[] a) {
		int n = a.length;
		for(int i =0; i<n; i++) {
			int val = random.nextInt(n);
			long cur = a[i];
			a[i] = a[val];
			a[val] = cur;
		}
		Arrays.sort(a);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (st == null  || !st.hasMoreTokens()) {
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		String nextLine() { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
		} 
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
	}

}


Measured memory_bytes: 62184
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<climits>
using namespace std;
int main(){
  int n[3];

  cin >> n[0] >> n[1] >> n[2];

  int cnt = 0;

  while(true){
    if(n[0] == n[1] && n[1] == n[2]){
      break;
    }
    sort(n, n+3);
    if(n[0] + 2 <= n[2]){
      n[0] += 2;
    }else{
      n[0]++;
      n[1]++;
    }
    cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = (a < 10 && b < 10) ? a*b : -1;
        System.out.println(ans);
    }

}


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

const long long mod =1e+7 ;
const int N = 1e5+5;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define fr(i,l,m) for(int i=l;i<m;i++)
# define vii vector<int>
#define vpr vector<pair<ll,ll> >
ll pwr(ll x,ll y);
bool isprime(int n) ;
////
////
////

int dp[N],ans=0;
vii adj[N];
bool visited[N];

int dfs(int p)
{
   // visited[p]=1;
    int len=0;
    fr(i,0,adj[p].size())
    {
        //cout<<"p adj "<<p<<' '<<i<<endl;

            /*if(dp[adj[p][i]]!=-1)
            {
                len=max(len,dp[adj[p][i]]);
            }
            else{*/
          if(dp[adj[p][i]]!=-1)
          {
              int ln=dp[adj[p][i]];
          //cout<<"ln : "<<ln+1<<endl;
          len=max(ln+1,len);
          }
          else{
          int ln=dfs(adj[p][i]);
          dp[adj[p][i]]=ln;
          //cout<<"ln : "<<ln+1<<endl;
          len=max(ln+1,len);
          }
            //}


    }
    //dp[p]=len;
   // cout<<"len "<<len<<endl;
    return len;
}




int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);
int n,m,x,y;
cin>>n>>m;
fr(i,0,m)
{
    cin>>x>>y;
    adj[x].pb(y);
}

fr(i,0,N)dp[i]=-1;

fr(i,1,n+1)
{
   // memset(visited,0,sizeof(visited));
   if(dp[i]!=-1){
    ans=max(ans,dp[i]);
   }
   else{
    int df=dfs(i);
    dp[i]=df;
  //cout<<"i:"<<i<<' '<<ans<<' '<<df<<endl;
    ans=max(ans,df);
   }
}
cout<<ans<<endl;
return 0;
}
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*(ans%mod))%mod;
    x=(x*x)%mod;
    y=y/2;

    }
    return ans%mod;
}

bool isprime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;
long long N, u, v;

vector<long long> tree[100005];
long long memo_a[100005];
long long memo_t[100005];

int main(){
	cin >> N >> u >> v;
	u--;v--;
	rep(i, N-1) {
		long long a, b;
		cin >> a >> b;
		a--;b--;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}


	// point, (pa, dis)
	queue<pair<long long, pair<long long,long long> > >Q;
	Q.push(make_pair(v, make_pair(-1, 0)));
	while(!Q.empty()) {
		long long cur = Q.front().first;
		long long pa = Q.front().second.first;
		long long dis = Q.front().second.second;
		memo_a[cur] = dis;
		Q.pop();
		//cout << cur << endl;
		for(auto next: tree[cur]) {
			if(next != pa) {
				Q.push(make_pair(next, make_pair(cur, dis + 1)));
			}
		}
	}

	long long ans = 0;
	Q.push(make_pair(u, make_pair(-1, 0)));
	while(!Q.empty()) {
		long long cur = Q.front().first;
		long long pa = Q.front().second.first;
		long long dis = Q.front().second.second;
		memo_t[cur] = dis;
		Q.pop();
		//cout << cur << endl;
		for(auto next: tree[cur]) {
			if(next != pa) {
				Q.push(make_pair(next, make_pair(cur, dis + 1)));
			}
		}
	}

	rep(i, N) {
		if(memo_a[i] > memo_t[i]) {
			ans = max(ans, memo_a[i]);
		}
	}

	cout << ans -1 << endl;
}


Measured memory_bytes: 11752