akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#define N 4000001
#define y1 ysfhfauhsud
#define MAX 400001
using namespace std;
int total1,ans;
int head[N],next[N],edge[N],x1[N],y1[N],x[N],y[N],fmax[N],p1[N],p2[N];
int n,m,k;
void swap(int &x,int &y)
{
	int t=x;x=y;y=t;
}
void insert(int x,int y)
{
	total1++;
	next[total1]=head[x];
	head[x]=total1;
	edge[total1]=y;
}
void qsort1(int l,int r)
{
	int i=l,j=r;
	int mid=x1[(i+j)/2];
	while (i<=j)
	{
		while (x1[i]<mid) i++;
		while (x1[j]>mid) j--;
		if (i<=j)
		{
			swap(x1[i],x1[j]);
			i++;j--;
		}
	}
	if (i<r) qsort1(i,r);
	if (l<j) qsort1(l,j);
}
void qsort2(int l,int r)
{
	int i=l,j=r;
	int mid=y[(i+j)/2];
	while (i<=j)
	{
		while (y[i]<mid) i++;
		while (y[j]>mid) j--;
		if (i<=j)
		{
			swap(y[i],y[j]);
			swap(x[i],x[j]);
			i++;j--;
		}
	}
	if (i<r) qsort2(i,r);
	if (l<j) qsort2(l,j);
}
int max(int x,int y)
{
	if (x<y) return y;
	return x;
}
void maketree(int ma,int l,int r)
{
	if (l==r)
	{
		fmax[ma]=p2[l];
		return;
	}
	int mid=(l+r)/2;
	maketree(ma*2,l,mid);
	maketree(ma*2+1,mid+1,r);
	fmax[ma]=max(fmax[ma*2],fmax[ma*2+1]);
}
int find_ans(int ma,int l,int r,int l1,int r1)
{
	if (l1>r1) return 0;
	if (l==l1&&r==r1) return fmax[ma];
	int mid=(l+r)/2;
	if (r1<=mid) return find_ans(ma*2,l,mid,l1,r1);
	if (mid<l1) return find_ans(ma*2+1,mid+1,r,l1,r1);
	int s=find_ans(ma*2,l,mid,l1,mid);
	s=max(s,find_ans(ma*2+1,mid+1,r,mid+1,r1));
	return s;
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for (int i=1;i<=k;i++)
	{
		scanf("%d%d",&x[i],&y[i]);
		//p[y[i]]++;
	}
	for (int i=1;i<=k;i++)
		x1[i]=x[i];
	qsort1(1,k);
	qsort2(1,k);
	memset(p1,0,sizeof(p1));
	memset(p2,0,sizeof(p2));
	for (int i=k;i>=1;i--)
	{
		p2[y[i]]++;
		p1[x[i]]++;
		insert(x[i],i);
	}
	maketree(1,1,MAX);
	ans=0;
	for (int i=1;i<=k;i++)
	{
		if (i!=k&&x1[i]==x1[i-1]) continue;
		int last=1;
		for (int j=head[x1[i]];j;j=next[j])
		{
			int ys1=edge[j];
			ans=max(ans,p2[y[ys1]]+p1[x1[i]]-1);
			ans=max(ans,p1[x1[i]]+find_ans(1,1,MAX,last,y[ys1]-1));
			last=y[ys1]+1;
		}
		ans=max(ans,p1[x1[i]]+find_ans(1,1,MAX,last,MAX));
	}
	printf("%d\n",ans);
}

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

int main(int argc, char const *argv[]) {
    int a, b;
    cin >> a >> b;

    if (a >= 13) cout << b << endl;
    else if (6 <= a && a <= 12) cout << b/2 << endl;
    else cout << 0 << endl;
    return 0;
}


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

using namespace std;

#define intt long long 
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

int n;

int main() {

	FAST;

	int a, b, c;
	cin >> a >> b >> c;
	for (int i = 1; i <= b; i ++) {
		if ((a * i) % b == c) {
			cout << "YES\n";
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
import math
cnt = 0
for i in range(int(input())):
    x = int(input())
    flg = False # なんらかの数で割り切れるかどうか
    if x == 1:
        continue
    if x == 2:
        cnt += 1
        continue
    for k in range(2, math.floor(math.sqrt(x))+1):
        if not(x % k):
            flg = True
            break
    if not flg:
        cnt += 1
print(cnt)


Measured memory_bytes: 5680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  string n;
  cin >> n;
  ll sum = 0;
  ll len = n.size();
  for (int i = 0; i < len; i++) {
    sum += (int)(n[i] - '0');
  }
  int nInt = stoi(n);
  if (nInt % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main(void){
	int d;
	long s;
	while(cin >> d){
		s = 0;
		for(int i = 1; i * d + d <= 600; i++){
			s +=  (d * i) * (d * i) * d;
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
n = int(input())
s = input()
leftW = 0
leftE = 0
allW = s.count("W")
allE = s.count("E")
cost = 0
mincost = n
for si in s:
  if si == "W":
    rightW = allW - leftW - 1
    rightE = allE - leftE
    cost = leftW + rightE
    leftW += 1
  else:
    rightW = allW - leftW
    rightE = allE - leftE - 1
    cost = leftW + rightE
    leftE += 1
  mincost = min(mincost, cost)
print(mincost)


Measured memory_bytes: 3780
/* 
    Author : Jeff Ahn
    Sat 13 Jun 2020 12:57:43 AM PDT 
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const map<T,T> &vec){ os<< "{"; for (auto p : vec) os << "(" << p.first << "," << p.second << "), "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_map<T,T>&vec){ os<< "{"; for (auto p : vec) os << "(" << p.first << "," << p.second << "), "; os << "}"; return os; }

template <typename T> struct Modular {
  /* to abbreviate the word "Modular" */
  using M = Modular; 

  /* Infers type from template. The struct/class T must have 
     "modulus" defined as member.*/
  using Type = typename decay<decltype(T::modulus)>::type; 

  /* Mod is now an alias to the "modulus" (eg 1e9+7) */

  constexpr static Type Mod() { return  T::modulus; }
  /* v is the value of the Mint. 0 <= v < Mod */
  Type v;
  Modular(long long a = 0) : v((a %= Mod()) < 0 ? a + Mod() : a) {}
  M operator-() const { return M() -= *this; }
  M& operator+=(M r) { if ((v += r.v) >= Mod()) v -= Mod(); return *this; }
  M& operator-=(M r) { if ((v += Mod() - r.v) >= Mod()) v -= Mod(); return *this; }
  M& operator*=(M r) { v = (uint64_t)v * r.v % Mod(); return *this; }
  M& operator/=(M r) { return *this *= mdpow(r, Mod() - 2); }
  friend M operator+(M l, M r) { return l += r; }
  friend M operator-(M l, M r) { return l -= r; }
  friend M operator*(M l, M r) { return l *= r; }
  friend M operator/(M l, M r) { return l /= r; }
  friend bool operator==(M l, M r) { return l.v == r.v; }
  friend M mdpow(M b, unsigned exp) {
    Modular res(1);
    while(exp) {
      if (exp & 1) {
        res *= b;
        if ((res.v += Mod()) >= Mod()) res.v -= Mod();
      }
      b *= b;
      exp >>= 1;
    }
    return res;
  }
};

struct VarMod { static unsigned modulus; };
unsigned VarMod::modulus;
unsigned& md = VarMod::modulus;
using Mint = Modular<VarMod>;

const int mxn = 1e5 + 10;
Mint dp[mxn];

signed main() {
  fastio;
  md = 1e9+7;
  unsigned n, k;
  cin >> n >> k;
  Mint res(0);
  for (int i = k; i >= 1; i--) {
    Mint b(k / i);
    b = mdpow(b, n);
    dp[i] = b;
    for (int j = 2*i; j <= k; j += i) {
      dp[i] -= dp[j];
    }
    res += (dp[i] * Mint(i));
  }
  cout << res.v << endl;
  
}


Measured memory_bytes: 4012
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
int main() {
	long long n, m;
	std::cin >> n >> m;
	if (m >= n * 2) {
		std::cout << n + (m - n * 2) / 4 << std::endl;
	}
	else {
		std::cout << m / 2 << std::endl;
	}
	return 0;
}

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

const ll MOD = 1000000000000000000;

int main() {
	//入力
	int a,b,c,d;
	cin >> a >> b >> c >> d;

	//処理
	ll ans = (ll)a * c;
    if (ans < ((ll)a * d)) ans= (ll)a * d;
	if (ans < ((ll)b * c)) ans = (ll)b * c;
	if (ans < ((ll)b * d)) ans = (ll)b * d;

	//出力
	std::cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3632
n,k,q = map(int,input().split()) #N人、Kpoint、Q回答
a = [] # 順番
for _ in range(q):
    a.append(int(input()))

# 最初に回数分引く
point = [k-q] * n

for win in a:
    point[win-1] += 1

#print(point)


for i in point:
    if i <= 0:
        print("No")
    elif i >= 1:
        print("Yes")



Measured memory_bytes: 10452
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

const int MN = 100010;
int a[MN];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
        int l, r; cin >> l >> r;
        a[l]++; a[r + 1]--;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
        a[i] += a[i - 1];
        ans += (a[i] == m);
	}
	cout << ans << endl;
	return 0;
}


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

long long n, m, q;
vector<long long> A, B, C, D;
long long ans = 0;

void dfs(vector<long long> v) {
  if (v.size() == n) {
    long long now = 0;
    rep(i, q) if (v[B[i]-1] - v[A[i]-1] == C[i]) now += D[i];
    ans = max(ans, now);
    return;
  }

  v.push_back(v.back());
  while (v.back() <= m) {
    dfs(v);
    v.back()++;
  }
}

void solve(long long N, long long M, long long Q, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c, std::vector<long long> d){
  n = N, m = M, q = Q;
  A = a; B = b, C = c, D = d;

  dfs(vector<long long>(1, 1));
  cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> a(Q);
    std::vector<long long> b(Q);
    std::vector<long long> c(Q);
    std::vector<long long> d(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
        scanf("%lld",&d[i]);
    }
    solve(N, M, Q, std::move(a), std::move(b), std::move(c), std::move(d));
    return 0;
}


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

#define ll long long
#define ar array

bool chk(string s) {
	for(int i=0; i<(int)s.size()-1-i; ++i)
		if(s[i]^s[(int)s.size()-1-i])
			return 0;
	return 1;
}

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

	string s;
	cin >> s;
	int n=s.size();
	cout << (chk(s)&&chk(s.substr(0, (n-1)/2))&&chk(s.substr((n+1)/2))?"Yes":"No");
}

Measured memory_bytes: 256
n = int(input())
num_list = []
max_num = 0
second_max_num = 0

for i in range(n):
    get_num = int(input())
    if get_num > max_num:
        second_max_num = max_num
        max_num = get_num
    elif get_num > second_max_num:
        second_max_num = get_num
        
    num_list.append(get_num)

for i in num_list:
    if i == max_num:
        print(second_max_num)
    else:
        print(max_num)
    

Measured memory_bytes: 12524
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
	while (1) {
		int m, f, r;
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1) return 0;

		if (m == -1 || f == -1) {
			cout << "F" << endl;
		}
		else if (m + f >= 80) {
			cout << "A" << endl;
		}
		else if (m + f >= 65) {
			cout << "B" << endl;
		}
		else if (m + f >= 50) {
			cout << "C" << endl;
		}
		else if (m + f >= 30) {
			if (r >= 50) {
				cout << "C" << endl;
			}
			else {
				cout << "D" << endl;
			}
		}
		else {
			cout << "F" << endl;
		}
	}

	return 0;
}



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

const int MOD = 1e9 + 7;

int ADD(int x, int y) {
  int res = x + y;
  if (res >= MOD) res -= MOD;
  if (res < 0) res += MOD;
  return res;
}

int MUL(int x, int y) {
  return 1ll * x * y % MOD;
}

int N, C;
int A[405], B[405];
int dp[2][405];

void Calc() {
  dp[N & 1][C] = 1;

  for (int i = N - 1; i >= 0; i--) {
    memset(dp[i & 1], 0, sizeof(dp[i & 1]));
    for (int j = A[i]; j <= B[i]; j++) {
      int nxt_sum = 0;
      for (int pw = C; pw >= 0; pw--) {
        nxt_sum = MUL(nxt_sum, j);
        nxt_sum = ADD(nxt_sum, dp[(i + 1) & 1][pw]);
        dp[i & 1][pw] = ADD(dp[i & 1][pw], nxt_sum);
      }
    }
  }
}

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

  cin >> N >> C;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }

  Calc();
  
  cout << dp[0][0] << "\n";
  return 0;
}


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

using namespace std;

typedef long long llint;
const llint MOD = 998244353;

template <typename T>
T modpow(T m, T n, const T &p) {
  if (n == 0) return 1;
  T ret = modpow(m * m % p, n / 2, p);
  if (n % 2) ret *= m;
  return ret % p;
}

int main() {
  llint n, m, k;
  cin >> n >> m >> k;
  vector<llint> mul(n, 0), div(n, 0);
  mul[0] = div[0] = 1;
  for (llint i = 0; i <= k; i++) {
    mul[i + 1] = mul[i] * (n - 1 - i);
    div[i + 1] = div[i] * (i + 1);
    mul[i + 1] %= MOD;
    div[i + 1] %= MOD;
  }
  llint ans = 0;
  for (llint i = 0; i <= k; i++) {
    llint v = m * mul[i] % MOD * modpow(div[i], MOD - 2, MOD) % MOD;
    v *= modpow(m - 1, n - 1 - i, MOD), v %= MOD;
    ans += v, ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}

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

int main(){
   string S;
   cin >> S;
   int N = S.length();
   long long ans = 0;
   
   for(int bit = 0; bit < (1 << N - 1); bit++){
       string now = "";
       now += S[0];
       for(int i = 0; i < N - 1; i++){
           if(bit & (1 << i))now += "+";
           now += S[i + 1];
       }
       
       long long sum = 0;
       int pos = 0;
       while(now.find("+", pos) != string::npos){
           int next = now.find("+", pos);
           sum += stoll(now.substr(pos, next - pos));
           pos = next + 1;
       }
       sum += stoll(now.substr(pos));
       ans += sum;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
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)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($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, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        A: i64,
        B: i64,
    }
    if A+B < 10{
        println!("{}", A+B);
    }else{
        println!("error");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

    int n;
    cin >> n;
    vector<int> a;
    for(int i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            a.push_back(i);
            a.push_back(n / i);
        }
    }
    int ans = 0;
    rep(i, a.size()) {
        a[i]--;
        if(!a[i]) continue;
        if(n / a[i] == n % a[i]) ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.lang.Integer.max

fun main(args:Array<String>):Unit {
    val (n, p) = readLine()!!.trim().split(' ').map(String::toInt)
    val have = IntArray(n + 1){0}
    val need = IntArray(n + 1){0}
    for (i in n downTo 1){
        val (x, y) = readLine()!!.trim().split(' ').map(String::toInt)
        have[i] = x
        need[i] = y
    }
    need[0] = Int.MAX_VALUE
    val memo = Array(n + 1){IntArray(p + 1){-1}}
    mdp(n, p, have, need, memo)
    println(mdp(n, p, have, need, memo))
}
fun mdp(dayRest:Int, power:Int, have:IntArray, need:IntArray, memo:Array<IntArray>):Int {
    if (dayRest <= 0) return 0
    if (memo[dayRest][power] < 0){
        var current = have[dayRest]
        var powerRest = power
        var maxDay = 0
        for (presentDay in 0 .. dayRest){
            if (maxDay < mdp(dayRest - presentDay - 1, powerRest, have, need, memo) + presentDay)
                maxDay = mdp(dayRest - presentDay - 1, powerRest, have, need, memo) + presentDay
            if (need[dayRest - presentDay] <= current){
                current = have[dayRest - presentDay - 1]
            }else if (need[dayRest - presentDay] <= current + powerRest){
                powerRest -= need[dayRest - presentDay] - current
                current = max(0, have[dayRest - presentDay - 1] - need[dayRest - presentDay] + current)
            }else{
                break
            }
        }
        memo[dayRest][power] = maxDay
    }
    return memo[dayRest][power]
}


Measured memory_bytes: 459532
#include <iostream>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
using namespace std;
void k_cut(vector<int> &card,int k){
  int n = card.size();
  vector<int> tmp(card.size(),0);
  for(int i = 0;i < n-k;i++){

    tmp[i] = card[k+i];
  }
  for(int i =n-k;i < n;i++){
    tmp[i] = card[i-(n-k)];

  }

  card = vector<int>(tmp);
}
void rihul(vector<int> &card){
  int n = card.size();
  vector<int> tmp(n,0);
  for(int i =0;i < n;i++){
    if(i%2 == 0)tmp[i] = card[i/2];
    else{
      tmp[i] = card[i/2+n/2];
    }

  }
  card = vector<int>(tmp);
}
int main(){
  int n;
  cin >> n;
  vector<int> card(n*2,0);
  for(int i = 0;i < 2*n;i++){
    card[i] = i+1;
  }
  int m;
  cin >> m;
  for(int i = 0;i < m;i++){
    int k;
    cin >> k;
    if(k == 0){
      rihul(card);
    }else{
      k_cut(card,k);
    }
  }
  for(int i = 0;i < 2*n;i++){
    cout << card[i] << endl;
  }
}
vector<string> split(string str,string delim){
  vector<string> items;
  size_t dlm_idx;
  if(str.npos == (dlm_idx = str.find_first_of(delim))){
    items.push_back(str.substr(0,dlm_idx));
  }
  while(str.npos != (dlm_idx = str.find_first_of(delim))){
    if(str.npos == str.find_first_not_of(delim)){
      break;
    }
    items.push_back(str.substr(0,dlm_idx));
    dlm_idx++;
    str = str.erase(0,dlm_idx);
    if(str.npos == str.find_first_of(delim) && "" != str){
      items.push_back(str);
      break;
    }
  }
  return items;
}

Measured memory_bytes: 1224
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    lld n, k;
    scanf("%lld %lld", &n, &k);
    lld ans = 0;
    rep(i, (int)k+1, (int)n+1){
        ans += n/((lld)i) * ((lld)i - k);
        if(n%((lld)i) >= k){
            ans += (n%((lld)i)) - k + 1;
        }
    }
    if(k==0){
        ans -= n;
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  	
  	long long a,b,c,d,e,f;
  	cin >> a >> b;
  	c=a+b, d=a-b, e=a*b;
  	if (c>d){
      f=c;
    }
  	else {
      f=d;
    }
  	if (f>e){
      cout << f;
    }
  	else {
      cout << e;
    }
}

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

int main(){
    int N,Q;
    int K;
    cin>>N>>K>>Q;

    int a;
    int c[N]={0};

    for(int i=0;i<Q;i++){
        cin>>a;
        c[a-1]++;
    }


    for(int i=0;i<N;i++){

        if(K-(Q-c[i])<=0){
            cout<<"No"<<endl;

        }else{
            cout<<"Yes"<<endl;
        }

    }
 
    

}

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

using namespace std;

char arr[5][5][4];
char puzzle[36][4];
bool used[36];
const int dx[] = {0,1,0,-1};
const int dy[] = {1,0,-1,0};

bool check(char a, char b){
  int d = -32;
  return (a + d == b || b + d == a || a == '0' || b == '0');
}

int rec(int y, int x){
  if(y == 4 && x == 1){
    return 1;
  }
  int res = 0;
  for(int i = 0 ; i < 36 ; i++){
    if(used[i]) continue;
    int cnt = 0;
    for(int j = 0 ; j < 4 ; j++){
      arr[y][x][j] = puzzle[i][j];
    }
    for(int j = 0 ; j < 4 ; j++){
      int nx = x + dx[j];
      int ny = y + dy[j];

      if(check(arr[ny][nx][(j+2)%4], arr[y][x][j])){
        cnt++;
      }
    }
    if(cnt == 4){
      int ii = i/4*4;
      for(int j = ii ; j < ii+4 ; j++){
        used[j] = true;
      }
      int a = 0, b = 0;
      if(x == 3) a++;
      if(x > 2) b++;
      res += rec(y + a, x + 1 - 3*b);
      for(int j = ii ; j < ii+4 ; j++){
        used[j] = false;
      }
    }
    for(int j = 0 ; j < 4 ; j++){
      arr[y][x][j] = '0';
    }
  }
  return res;
}

int main(){
  int Tc;
  string str;

  cin >> Tc;
  while(Tc--){
    memset(used, false, sizeof(used));
    fill(arr[0][0], arr[5][5], '0');
    for(int i = 0 ; i < 9 ; i++){
      cin >> str;
      for(int j = 0 ; j < 4 ; j++){
        puzzle[i*4][j] = str[j];
      }
      for(int j = 1 ; j < 4 ; j++){
        for(int k = j ; k < j+4 ; k++){
          puzzle[i*4+j][k-j] = str[k%4];
        }
      }
    }    
    cout << rec(1, 1) << endl;
  }

  return 0;
}

Measured memory_bytes: 1204
# coding: utf-8
# Your code here!

a, b, c, d = map(int , input().split())

# print(a)
# print(b)
# print(c)
# print(d)

# 会話できるなら Yes を, できないなら No を出力せよ。

if abs(c - a) <= d:
    print('Yes')
elif abs(b - a) <= d and abs(c - b) <= d:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
    int h,w,i,j;
    while(1){
        scanf("%d%d",&h,&w);
        if(h==0&&w==0) break;
        for(i=0; i<h; i++){
            for(j=0; j<w; j++){
                putchar('#');
            }
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <cmath>

using namespace std;


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

	return gcd(b, a%b);
}

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

	int *A = new int[N+1];

	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	A[N] = 0;

	// これ最大公約数まんまでは？
	int index = 0;
	int read = 0;
	while (N != 1) {
		index = 0;
		read = 0;
		while (read < N) {
			A[index] = gcd(A[read], A[read + 1]);
			read += 2;
			index++;
		}
		A[index + 1] = 0;
		N = (N + 1) / 2;
	}


	cout << A[0];



	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

//ll mod = 1000000007;
ll mod = 998244353;

signed main()
{
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int diffx=tx-sx;
    int diffy=ty-sy;
    rep(i,diffx){
        cout << "R";
    }
    rep(i,diffy){
        cout << "U";
    }
        rep(i,diffx){
        cout << "L";
    }
        rep(i,diffy){
        cout << "D";
    }
    cout << "D";
    rep(i,diffx+1){
        cout << "R";
    }
    rep(i, diffy+1)
    {
        cout << "U";
    }
    cout << "LU";
    rep(i, diffx+1)
    {
        cout << "L";
    }
    rep(i, diffy+1)
    {
        cout << "D";
    }
    cout << "R" << endl;

    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <math.h>
using namespace std;
typedef long long int ll;

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}

int main(){
	while(1){
		ll n,m; cin >> n >> m;
		if(n==0&&m==0)break;
		vector<ll>a(m);
		for(int i=0;i<m;i++){
			cin >> a[i];
		}
		double ans=0;
		ll sum=(1+n)*n/2;
		ll cnt=n;
		for(int i=1;i<(1<<m);i++){
			int bit_count=0;
			ll lc=1;
			for(int j=0;j<m;j++){
				if(i&(1<<j)){
					bit_count++;
					lc=LCM(lc,a[j]);
				}
			}
			if(bit_count%2==1){
				sum-=(n/lc+1)*(n/lc)/2*lc;
				cnt-=n/lc;
			}
			else{
				sum+=(n/lc+1)*(n/lc)/2*lc;
				cnt+=n/lc;
			}
		}
		if(cnt==0){
			cout << 0 << endl;
		}
		else{
			ans=(double)sum/cnt;
			printf("%.8f\n",ans );
		}
	}
}


Measured memory_bytes: 3204
ss = input()

n = len(ss)
arrs = [ss[0]]

for i in range(1, n):
    if len(arrs[-1]) == 2:
        if arrs[-1].endswith(ss[i]):
            arrs.append('*')
        else:
            arrs.append(ss[i])

    else:
        if arrs[-1] == ss[i]:
            arrs.append(ss[i: i + 2])
        else:
            arrs.append(ss[i])

c = arrs.count('*')

if arrs[-1] == arrs[-2]:
    ans = len(arrs) - 1

else:
    ans = len(arrs)
print(ans - c)
    

Measured memory_bytes: 14864
let rec read f n =
  if n <= 0 then []
  else
    let x = f () in
    x :: read f (n - 1)

let () =
  let n = read_int () in
  let ls = read read_int n in
  let tbl = Array.make_matrix 101 10001 false in
  let rec loop i xs =
    let rec iloop j v =
      if j > 10000 then () else begin
          if tbl.(i).(j) then begin
              tbl.(i+1).(j) <- true;
              tbl.(i+1).(j+v) <- true
            end else ();
          iloop (j+1) v
        end
    in
    match xs with
      [] -> ()
    | h :: l -> begin
        iloop 0 h;
        loop (i+1) l
      end
  in
  let rec find i =
    if i = 0 then 0 else
      if tbl.(n).(i) then
        if i mod 10 = 0 then find (i-1) else i
      else
        find (i-1)
  in
  tbl.(0).(0) <- true;
  loop 0 ls;
  find 10000 |> string_of_int |> print_endline


Measured memory_bytes: 8576
n,m = map(int, raw_input().split())
s,c = [map(int, raw_input().split()) for _ in range(m)], 1
s.sort()
cur = s[0]
for u,v in s[1:]:
	if cur[1] <= u:
		cur,c = [u,v], c + 1 
	else: cur = [max(u, cur[0]),min(v, cur[1])]
print c

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

int main()
{
    int N, M;
    cin >> N >> M;
    int A;
    int sum = 0;
    for (int i = 0; i < M; i++) {
        cin >> A;
        sum += A;
    }

    if (N - sum < 0) cout << -1 << endl;
    else cout << N - sum << endl;
    return 0;
}

Measured memory_bytes: 3624
N = gets.to_i
num1 = 0
ans = false

9.times do
    num1 += 1
    num2 = 0

    9.times do
        num2 += 1
        if N == num1 * num2
            ans = true
        end
    end
end

if ans
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 1788
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);

        int n = Integer.parseInt(stdin.nextLine());
        List<Point> points = new ArrayList<>();
        for (int i = 0; i < n; i++) points.add(new Point(Integer.parseInt(stdin.nextLine()), true));
        for (int i = 0; i < n; i++) points.add(new Point(Integer.parseInt(stdin.nextLine()), false));
        Collections.sort(points, Comparator.comparing(point -> point.x));

        long ans = 1;
        long mod = 1_000_000_000 + 7;
        Deque<Point> pcs = new ArrayDeque<>();
        Deque<Point> powers = new ArrayDeque<>();
        for (Point point : points) {
            if (point.pc) {
                if (powers.isEmpty()) {
                    pcs.addLast(point);
                } else {
                    ans = (ans * powers.size()) % mod;
                    powers.pollLast();

                }
            } else {
                if (pcs.isEmpty()) {
                    powers.addLast(point);
                } else {
                    ans = (ans * pcs.size()) % mod;
                    pcs.pollLast();
                }
            }
        }

        System.out.println(ans);
    }

    private static class Point {
        private int x;
        private boolean pc;

        public Point(int x, boolean pc) {
            super();
            this.x = x;
            this.pc = pc;
        }
    }
}


Measured memory_bytes: 160512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	char a,b;
	cin>>a>>b;
	if(a=='H'){
		if(b=='H'){
			cout<<'H'<<endl;
		}
		else{
			cout<<'D'<<endl;
		}
	}
	else if(a=='D'){
		if(b=='H'){
			cout<<'D'<<endl;
		}
		else{
			cout<<'H'<<endl;
		}
	}
}

Measured memory_bytes: 256
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 3*1e5 , limit = 1e17 , MOD=1e9+7;
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int32_t main(){
    boost;
    
    int a,b,n;
    cin>>a>>b>>n;
    int x = min( b-1 , n);
    
    int res = (a*x)/b  - (a)*(x/b);
    cout<<res<<endl;
     
}

Measured memory_bytes: 3616
// ABC 055 D
#include<bits/stdc++.h>
 
using namespace std;

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

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())

#define PB(a) push_back(a)

#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int n,m;
  cin >> n >> m;
  LL ans=0;
  vector <PII> a(n);
  REP(i,n){
    cin >> a[i].first >> a[i].second;
  }
  SORT(a);
  REP(i,n){
    if(a[i].second<m){
      m-=a[i].second;
      ans += (LL)a[i].second*a[i].first;
    }
    else{
      ans += (LL)m*a[i].first;
      break;
    }
  }
  
//  VI cd(n);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int,input().split()))
aa=[0]*9
for i in range(n):
    x = a[i]//400
    if x<8:
        aa[x] = 1
    else:
        aa[8] += 1
suma = sum(aa[0:8])
if suma==0:
    mina = 1
else:
    mina = suma
maxa = suma+aa[8]
print(mina,maxa)


Measured memory_bytes: 3060
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli l = 0ll, r = 0ll;
	cin >> l >> r;
	if (r - l > 3000)
		cout << "0" << endl;
	else
	{
		lli res = 2018;
		for (lli i = l; i < r; ++i)
			for (lli j = i + 1; j <= r; ++j)
				res = min(res, (1ll * i * j) % 2019);
		cout << res << endl;
	}
}

Measured memory_bytes: 3688
#include <iostream>
using namespace std;
int a[100005];
int main(int argc, char** argv) {
	int n,mn=1e9,mx=0,cnt=0;
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
		if(a[i]==mn)
			++cnt;
		if(a[i]<mn)
		{
			mn=a[i];
			cnt=1;
		}
		if(a[i]>mx)
			mx=a[i];
	}
	if(mx==mn)
	{
		if(a[1]==n-1)
			puts("Yes");
		else if(a[1]<=n/2)
			puts("Yes");
		else puts("No");
		return 0;
	}
	if(mx-mn>=2)
		puts("No");
	else if((n-cnt)/2+cnt<mx||cnt+1>mx)
		puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define zmrl(x) (int)((x).size())
#define ahen(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
const int mod = 998244353;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n,k; cin>>n>>k;
    vector<pii> seg;
    for (int i=1; i<=k; i++) {
        int a,b; cin>>a>>b;
        seg.pb({a, b});
    }
    sort(ahen(seg));
    int dp[200200]; dp[n] = 1;
    for (int i=n-1; i>=1; i--) {
        dp[i] = 0;
        for (auto &cur : seg) {
            if (i+cur.fi > n) break;
            dp[i] = (((dp[i]+dp[i+cur.fi])%mod - (i+cur.se >= n ? 0 : dp[i+cur.se+1]))%mod+mod)%mod;
        }
        dp[i] = (dp[i] + dp[i+1]) % mod;
    }
    cout << ((dp[1]-dp[2])%mod+mod)%mod << '\n';
    return 0;
}

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

int main(void){
    string a,b;
    cin>>a>>b;
    if(a==b) cout<<"EQUAL"<<endl;
    else if(a.size()!=b.size()){
        cout<<(a.size()>b.size() ? "GREATER" : "LESS")<<endl;
    }else{
        cout<<(a>b ? "GREATER" : "LESS")<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fast()    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll K[1000][100005];
ll knapsack(ll wt[],ll val[],ll w,ll n)
{
	if(n==0 || w==0)
	return 0;
	if(K[n][w]!=-1)
	return K[n][w];
	
	if(wt[n-1]<=w)
	return K[n][w]=max(val[n-1]+knapsack(wt,val,w-wt[n-1],n-1),
	knapsack(wt,val,w,n-1));
	else
	return K[n][w]=knapsack(wt,val,w,n-1);
 
} 

 
 int main()
 {
 	ll n,w;
 	cin>>n>>w;
 	ll wt[n],val[n];
 	memset(K,-1,sizeof(K));
 	for(int i=0;i<n;i++)
 	cin>>wt[i]>>val[i];
 	
 	cout<<knapsack(wt,val,w,n);
 	
	 }

Measured memory_bytes: 781568
import time
n = int(input())
t = [[i for i in map(int, input().split())] for _ in range(n)]

now = [0, 0, 0]
flag = True

for target in t:
    t_t, t_x, t_y = target
    n_t, n_x, n_y = now

    distance = abs(t_x-n_x) + abs(t_y - n_y)
    require_time = t_t - n_t

    if distance <= require_time and (distance-require_time) % 2 == 0:
        now = target
        continue
    else:
        flag = False
        break

if(flag):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 21136
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstring>
#include <cmath>
#include <cstdio>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()

using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<29;

int main(){
	ll n;
	while(cin >> n, n){
		string ans;
		while(n != 0){
			if(n < 0){
				if(n%10){
					ans += '0'+(10+n%10);
					n -= 10;
				}else{
					ans += '0';
				}
			}else{
				ans += '0'+n%10;
			}
			n /= -10;
		}
		cout << string(rev(ans)) << endl;
	}

    return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    int n;cin>>n;
    map<string, int>m;
    rep(i,n){
        string tmp;
        cin>>tmp;
        m[tmp]++;
    }
    co(m.size());
}

Measured memory_bytes: 19260
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long A = scanner.nextLong();
        long B = scanner.nextLong();
        long C = scanner.nextLong();
        long K = scanner.nextLong();
        scanner.close();

        if (A >= K) {
            System.out.println(K);
        } else if (A + B >= K) {
            System.out.println(A);
        } else {
            System.out.println(A - (K - B - A));
        }

    }
}

Measured memory_bytes: 35784
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int a[100010];

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n;scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	int mi=a[1],ma=a[1];
	for (int i=2;i<=n;i++)
	{
		mi=min(mi,a[i]);ma=max(ma,a[i]);
	}
	if (mi+1<ma) {puts("No");return 0;}
	if (mi==ma)
	{
		if (mi<=n/2||mi==n-1) puts("Yes"); else puts("No");
		return 0;
	}
	int s=0;
	for (int i=1;i<=n;i++) if (a[i]==mi) s++;
	if (s+1<=ma&&ma<=s+(n-s)/2) puts("Yes"); else puts("No");
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {
    int a,b;
    cin>>a>>b;
    int u[4]={a,a-1,b,b-1};
    sort(u,u+4);
    cout<<u[3]+u[2]<<endl;



    return 0;
}


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

int main(){
    string s,t,s2,tt,ss;
    cin >> s >> t;
    int ls,lt;
    ls=s.size();
    lt=t.size();
    ll ans=lt;
    ll k;

    rep(i,ls+1-lt){
        k=0;
        s2=s.substr(i,lt);
        rep(j,lt){
            ss=s2[j];
            tt=t[j];
            if(ss==tt){
                ++k;
            }
        }
        ans=min(ans,lt-k);
    }

    cout << ans << endl;
    

    return 0;
}

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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

//	LLONG_MAX 9.2*1e18	9223372036854775807LL = (2^63)-1
//	INT_MAX 2.1*1e9 2147483647 = (2^31)-1
//	O(1e8) 1.2sec

void Main()
{
	int N;
	cin>>N;

	vecll(L,N);
	vin(L);

	ull ans=0;
	rep(i,N){
		rep(j,i){
			rep(k,j){
				if(L[i]==L[j])continue;
				if(L[i]==L[k])continue;
				if(L[k]==L[j])continue;
				if(L[i]+L[j]+L[k]>2*max({L[i],L[j],L[k]}))ans++;
			}
		}
	}

	cout<<ans<<_n;
}


void Test();
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int n, m;
    cin >> n >> m;
    vector<double> a(n), b(n), c(m), d(m);

    rep(i, n)
    {
        cin >> a[i] >> b[i];
    }
    rep(i, m)
    {
        cin >> c[i] >> d[i];
    }
    int ans = 0;
    double dis, mini;
    rep(i, n)
    {
        ans = 0;
        mini = fabs(a[i] - c[0]) + fabs(b[i] - d[0]);
        rep(j, m)
        {
            dis = fabs(a[i] - c[j]) + fabs(b[i] - d[j]);
            // cout << dis << endl;
            if (dis < mini)
            {
                ans = j;
            }
            mini = min(dis, mini);
        }
        cout << ans + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxtl(),m=nxtl();
    vector <ll> v(n);
    generate(all(v),nxtl);
    sort(v.begin(),v.end());
    ll test=0;
    ll l=0,r=200000;
    while(l<=r)
    {
        ll x=(l+r)/2;
        stack <int> s;
        ll count=0;
        for(int i=n-1;i>=0;i--)
        {
            while(s.size()&&v[s.top()]+v[i]<x)
            {
                s.pop();
                count+=2*(s.size());
            }
            s.push(i);
        }
        while(s.size()>0)
        {
                s.pop();
                count+=2*(s.size());
        }
        for(int i=0;i<n;i++)
            if(2*v[i]>=x)
                count++;
        if(count>=m)
        {
            if(test<x)
                test=x;
            l=x+1;
        }
        else
            r=x-1;
    }
    ll x=test+1;
    ll count=0;
    stack <int> s;
    ll sum=0;
    ll stack_sum=0;
        for(int i=n-1;i>=0;i--)
        {
            while(s.size()&&v[s.top()]+v[i]<x)
            {
                int temp=s.top();
                s.pop();
                stack_sum-=v[temp];
                sum+=2*(stack_sum+v[temp]*s.size());
                count+=2*(s.size());
            }
            s.push(i);
            stack_sum+=v[i];
        }
        while(s.size()>0)
        {
                int temp=s.top();
                s.pop();
                stack_sum-=v[temp];
                sum+=2*(stack_sum+v[temp]*s.size());
                count+=2*(s.size());
        }
        for(int i=0;i<n;i++)
            if(2*v[i]>=x){
                count++;
                sum+=2*v[i];
            }
        sum+=(test*(m-count));
        cout<<sum<<endl;


    

    return 0;   
}


 
 


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

using namespace std;
int main()
{
    int h,m,s;
	cin>>s;
	h=s/3600;
	s-=h*3600;
	m=s/60;
	s-=m*60;
	cout<<h<<":"<<m<<":"<<s<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define rlp(i,a,b) for(int i=a;i>b;i--)
#define ft first
#define sd second
#define pii pair<int,int>
#define all(vect) vect.begin(),vect.end()
#define rall(vect) vect.rbegin(),rend() 
const int num = 200001;
typedef long long ll;
ll dp[num],h[num];
int main()
{
	int n;
	cin >> n;
	rep(i,1,n+1)
		cin >> h[i],dp[i]=INT_MAX;	
	dp[1]=0;
	dp[2]=abs(h[1]-h[2]);
	rep(i,3,n+1)
		dp[i]=min(dp[i],min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2])));
	cout << dp[n];


	return 0;
}

Measured memory_bytes: 1792