akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <tuple>
#include <algorithm>
using namespace std;

constexpr int kN = int(5E5 + 10);

struct BIT {
	int val[kN];
	void init() {memset(val, 0, sizeof(val));}
	void add(int pos, int x) {
		//printf("add(%d, %d)\n", pos, x);
		while (pos < kN) {
			val[pos] += x;
			pos += pos & -pos;
		}
		//printf("return\n");
		return ;
	}
	int ask(int pos) {
		//printf("ask(%d)\n", pos);
		int ans = 0;
		while (pos) {
			ans += val[pos];
			pos ^= pos & -pos;
		}
		//printf("return\n");
		return ans;
	}
};

BIT bit;
int c[kN], ans[kN], lst[kN];
tuple<int, int, int> p[kN];

int main() {
	int n, q, l, r, pos = 0, x = 0;
	scanf("%d%d", &n, &q);
	for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
	for (int i = 1; i <= q; i++) {
		scanf("%d%d", &l, &r);
		p[i] = {r, l, i};
	}
	sort(p + 1, p + 1 + q);
	bit.init();
	for (int i = 1; i <= q; i++) {
		while (pos < get<0>(p[i])) {
			++pos;
			x++;
			bit.add(pos + 1, -1);
			if (lst[c[pos]] > 0) {
				x--;
				bit.add(lst[c[pos]] + 1, 1);
			}
			lst[c[pos]] = pos;
		}
		ans[get<2>(p[i])] = bit.ask(get<1>(p[i])) + x;
	}
	for (int i = 1; i <= q; i++) printf("%d\n", ans[i]);
}


Measured memory_bytes: 17264
#include <iostream>
#include <algorithm>
#include <cstring>
#define INF 500050
using namespace std;
int a[INF];
int main()
{
	string s;
	cin >> s;
	for(int i=0; i<s.length(); i++)  {
		if(i%2) {
			if(s[i]=='R') 
			{
				cout<<"No"<<endl;
				return 0;
			}
		}else{
			if(s[i]=='L')
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<cmath>
#include<cctype>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<sstream>
#define X first
#define Y second
using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

const int N=1000010,mod=1e9+7,INF=0x3f3f3f3f;
const double eps=1e-6;

double n;

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

	cin>>n;
	
	printf("%.12f\n",n/3*(n/3)*(n/3));


















	return 0;
}











Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <math.h>
 
using namespace std;
 
int main(){
 
  	int H, W;
  
  	while(true){
		cin >> H >> W;
 		if(H==0 && W==0)
          break;
      
      for(int j=0; j<H; j++){
          for(int i=0; i<W; i++){
            if(j==0 || j==H-1 || i==0 || i==W-1)
              cout << "#";

         	else
               cout << ".";
           }
        	cout << endl;
       }
      cout << endl;
    }
  
  return 0;
}


Measured memory_bytes: 3088
x,y = map(int,input().split())
mod = 10**9+7
def comb(N,x):
    numerator = 1
    for i in range(N-x+1,N+1):
        numerator = numerator * i % mod
    denominator = 1
    for j in range(1,x+1):
        denominator = denominator * j % mod
    d = pow(denominator,mod-2,mod)
    return numerator * d % mod

if (x+y) % 3 == 0:
    a = (2*y-x) //3
    b = (2*x-y) //3

    if a >= 0 and b >= 0:
        print(comb(a+b,a))
        exit()
print(0)

Measured memory_bytes: 63248
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    
    string ans="YES";
    sort(a,a+n);

    for(int i=1;i<n;i++){
        if(a[i-1]==a[i]){
            ans="NO";
            break;
        }
    }

    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
map <ll,ll>a;
int main() {
	ll n;
	cin>>n;
	a[-1]++;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		auto now=a.lower_bound(x);
		now--;
		ll sea=now->first;
		if(sea==-1){
			a[x]++;
		}
		else {
			a[sea]--;
			a[x]++;
			if(a[sea]==0){
				a.erase(sea);
			}
		}
	}
	ll ans=0;
    for(auto itr = a.begin(); itr != a.end(); ++itr) {
         ans+= itr->second ;    // 値を表示
    }	
    cout << ans-1;
	// your code goes here
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

const int MAX = 2e5+10;
const int MOD = 1e9+7;

ll fac[MAX<<2];  // fac[n] = n!
ll finv[MAX<<2]; // (fac[n] * finv[n]) % MOD = 1
ll inv[MAX<<2];  // (n * inv[n]) % MOD = 1

void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR (i, 2, MAX<<2) {
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i) % MOD;
        finv[i] = finv[i-1]*inv[i] % MOD;
    }
}

ll nCk (int n, int k) {
    if (n < k || k < 0 || n < 0) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

ll pow_(ll n, ll k) {
    ll res = 1;
    while (k) {
        if (k&1) res = (res * n) % MOD;
        n = n * n % MOD;
        k >>= 1;
    }
    return res;
}

int N;
int C[MAX];

int solve() {
    init();
    sort(C, C+N);

    ll ans = 0, sm = 1;
    REP (k, N) {
        ans = (ans + C[N-k-1] * pow_(2, 2*N-k-1) % MOD * sm) % MOD;
        sm = (2 * sm + pow_(2, k)) % MOD;
    }
    return ans;
}

int main() {
    cin >> N;
    REP (i, N) cin >> C[i];
    cout << solve() << endl;
}

Measured memory_bytes: 19840
// in the name of Allah
// Ya Ali!
#include <bits/stdc++.h>
using namespace std;

typedef long long ll ;
typedef long double ld ;

const ll maxn = 2e5 + 10 ;
const ll INF = 1e18 ;

#define f first
#define s second

ll n , a[maxn] , h[maxn] , maxx[4*maxn] , dp[maxn] , idx[maxn] ;
vector<pair<pair<ll,ll> , ll > > vv ;

void up(ll x , ll y , ll va , ll l=0 , ll r=n-1 , ll node=1)
{
  if(l > y || r < x)return ;
  else if(l >= x && r <= y){
    maxx[node] = va ;
    return ;
  }
  ll mid = (r+l)/2 ;
  up(x , y , va , l , mid , 2*node)  ;
  up(x , y , va , mid+1 , r , (2*node)+1) ;
  maxx[node] = max(maxx[2*node] , maxx[(2*node)+1]) ;
}

ll qu(ll x , ll y , ll l = 0 ,ll r = n-1 , ll node = 1)
{
  if(l > y || r < x)return 0 ;
  else if(l >= x && r <= y)return maxx[node] ;
  ll mid = (r+l)/2 ;
  return max(qu(x , y , l , mid , 2*node) , qu(x , y , mid+1 , r , (2*node)+1)) ;
}

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

 cin >> n ;
 for(int i = 1 ; i <= n ; i ++)cin >> h[i] ;
 for(int i = 1 ; i <= n ; i ++)cin >> a[i] ;
 for(ll i = 1; i <= n ; i ++){
    vv.push_back({{h[i] , a[i]} , i}) ;
 }
 sort(vv.begin() , vv.end()) ;

 for(int i = 0 ; i < n ; i ++){
    idx[vv[i].s] = i ;
 }

 ll ans = 0 ;
 for(int i = 1 ; i <= n ; i ++){
    ll ind = idx[i] ;
    dp[i] = qu(0 , ind)+a[i] ;
    up(ind,ind,dp[i]) ;
    ans = max(ans , dp[i]) ;
 }
 cout << ans ;
    return 0;
}


Measured memory_bytes: 18924
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    int a[110];
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        sort(a,a+n);
        int x=a[0],y=a[n-1];
        int s;
        for(int i=x;i<=y;i++)
        {
            int s1=0;
            for(int j=0;j<n;j++)
            {
                s1=s1+(a[j]-i)*(a[j]-i);
            }
            if(i==x)
            {
                s=s1;
            }
            if(s>s1)
            {
                s=s1;
            }
        }
        printf("%d\n",s);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n;
int v[3];
int dp[2][3];
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    cin>>n;

    for(int i=0;i<n;i++){
        cin>>v[0]>>v[1]>>v[2];

        dp[i%2][0] = v[0] + max(dp[(i+1)%2][1],dp[(i+1)%2][2]);
        dp[i%2][1] = v[1] + max(dp[(i+1)%2][0],dp[(i+1)%2][2]);
        dp[i%2][2] = v[2] + max(dp[(i+1)%2][0],dp[(i+1)%2][1]);
    }

    cout<<max(dp[(n+1)%2][0],max(dp[(n+1)%2][2],dp[(n+1)%2][1]));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int N;cin>>N;
    vector<double>a(N);
    ll sum=0;
    ll seki=1;
    rep(i,N){
        cin>>a.at(i);
        sum+=a.at(i);
        seki*=a.at(i);
    }
    double bunbo=0;
    rep(i,N){
        bunbo+=seki*1.0/a.at(i);
    }
    printf("%.14f\n",seki*1.0/bunbo);
}

Measured memory_bytes: 3816
import scala.io.StdIn.{readInt,readLine}

object Main extends App {
  val n = readInt
  val list = for(i <- 0 until n) yield readLine.split(" ").map(_.toInt)
  val sorted = list.sortWith( (x,y) => if( x(1) == y(1) ) x(0) < y(0) else x(1) > y(1) )
  println(sorted(0)(0) + " " + sorted(0)(1))
}

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

int main(){
    int N;
    cin >> N;
    int h[200];
    for (int i = 0; i < N; i++){
        cin >> h[i];
    }
    bool mesh[100][100];
    for (int i = 0; i < N; i++){
        for (int j = 0; j < 100; j++){
            if (h[i] > 0){
                mesh[i][j] = true;
                h[i]--;
            }
            else mesh[i][j] = false;
        }
    }
  /*  for (int i = 0; i < N; i++){
        for (int j = 0; j < 100; j++){
            cout << mesh[i][j] << " ";
        }
        cout << endl;
    }
    */
    int count = 0;
    for (int j = 0; j < 100; j++){
        bool flag = false;
        for (int i = 0; i < N; i++){
            if (flag == false && mesh[i][j] == true){
                count++;
                flag = true;
            }
            if (mesh[i][j] == false){
                flag = false;
            }
        }
    }
    cout << count << endl;
    return 0;

}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


struct SegmentTreeMIN{
  ll n;
  vll tree;

  SegmentTreeMIN(ll len){
    n=1;
    while(len>n)
      n*=2;

    tree.assign(2*n-1, LLINF);
  }

  void update(ll index, ll value){
    index += n-1;
    tree[index] = value;

    while(index>0){
      index=(index-1)/2;
      tree[index] = min(tree[index*2+1], tree[index*2+2]);
    }
  }


  //[a, b)
  ll query(ll a, ll b){
    return query(a,b,0,0,n);
  }

  ll query(ll a, ll b, ll index, ll l, ll r){
    if(b<=l || r<=a)
      return LLINF;

    if(a<=l && r<=b)
      return tree[index];

    ll value_l = query(a,b,2*index+1,l,(l+r)/2);
    ll value_r = query(a,b,2*index+2,(l+r)/2,r);
    return min(value_l, value_r);
  }
};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin>>n;
  vll l(n),r(n);
  REP(i,n)cin>>l[i]>>r[i];

  ll p=-LLINF,q=LLINF;
  REP(i,n){
    p=max(p,l[i]);
    q=min(q,r[i]);
  }

  ll ans=0;
  //p,qが同一グループ
  REP(i,n)ans=max(ans,r[i]-l[i]+1);
  ans+=max(0LL,q-p+1);

  //p,qが別グループ
  vpl t(n);
  REP(i,n){
    t[i].FI=max(r[i]-p+1,0LL);
    t[i].SE=-max(q-l[i]+1,0LL);
  }
  sort(ALL(t));

  SegmentTreeMIN seg(n);
  REP(i,n)seg.update(i,-t[i].SE);
  REP(i,n){
    if(i==0)
      continue;
    ll now=t[i].FI+seg.query(0,i);
    ans=max(ans,now);
  }


  cout<<ans<<endl;
}



Measured memory_bytes: 8488
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define f(k,n) for(auto i =k; i<n; i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie();
#define test ll t; cin>>t;

int main(){
    IOS
    int a, b ,i;
    cin>>a>>b;
    for(i = 10*b; i< (10*b + 10) ; i++){
        if(a == floor(0.08*i)) break;
    }
    if(i < (10*b + 10)) cout<<i<<endl;
    else{cout<<"-1"<<endl;}
    return 0 ;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.*;

public class Main {

    static long gcd(long a,long b) {
        long temp;
        while ((temp=a%b)!=0) {
            a=b;
            b=temp;
        }
        return b;
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        int T = in.nextInt();
        for (int i=0;i<T;i++) {
            long A = in.nextLong();
            long B = in.nextLong();
            long C = in.nextLong();
            long D = in.nextLong();
            if (A<B || D<B) {
                out.println("No");
                continue;
            }
            if (gcd(B, D)==1) {
                if (B-1<=C) out.println("Yes");
                else out.println("No");
                continue;
            } else {
                long GCD = gcd(B, D);
                if (A<C) {
                    A+=D*(C-A+D-1)/D;
                }
                long ok = (A-C)/GCD;
                if ((A-C)%GCD==0) ok--;
                long value = A-GCD*ok-B;
                if (value>=0) out.println("Yes");
                else out.println("No");
            }
        }

        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int a[26];

int main() {
  string s;
  while (getline(cin, s)) {
    for (auto& e : s) {
      if (isalpha(e)) {
        e = tolower(e);
        a[e - 'a']++;
      }
    }
  }
  for (int i = 0; i < 26; i++) {
    cout << (char)(i + 'a') << " : " << a[i] << "\n";
  }
}


Measured memory_bytes: 3204
// https://atcoder.jp/contests/agc023/tasks/agc023_a
// 10min ~ 15min

#include <stdio.h>
#include <vector>
#include <algorithm>

long long combination(int a, int b) {
    long long ret = 1;
    for (int i=0; i<b; i++) {
        ret *= a-i;
    }
    for (int i=0; i<b; i++) {
        ret /= b-i;
    }
    return ret;
}

int main(void) {
    int N;
    scanf("%d", &N);

    int Ai[N];
    for (int i=0; i<N; i++) {
        scanf("%d", &Ai[i]);
    }

    std::vector<long long> totals;
    totals.push_back(0);
    long long sum = 0;
    for (int i=0; i<N; i++) {
        sum += Ai[i];
        totals.push_back(sum);
    }
    // totals[i] is sum(Ai[0], Ai[1], ..., Ai[i])

    // qsortが面倒だったので、vector使ってsort
    std::sort(totals.begin(), totals.end());
    totals.push_back(-1);

    long long count = 0;
    int sameCount = 0;
    long long before = -1;
    for (int i=0; i<totals.size(); i++) {
        long long a = totals[i];
        if (before == a) {
            sameCount++;
        } else {
            // 先頭からの合計が同じ場所を2つ選んだ時、2つの間の合計は0
            count += combination(sameCount, 2);
            before = a;
            sameCount = 1;
        }
    }

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

    return 0;
}


Measured memory_bytes: 3316
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
         
            var input = Reads();
            var w = input[0];
            var h = input[1];
            if (h == 1 || w == 1)
                Console.WriteLine(1);
            else if (w * h % 2 == 0)
                Console.WriteLine(w * h / 2);
            else
                Console.WriteLine((w * h + 1) / 2); 


            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
#include<set>  
#include<map>  
#include<stack>  
#include<cmath>  
#include<cstdio>  
#include<queue>  
#include<vector>  
#include<cstring> 
#include<climits>  
#include<iostream> 
#include<algorithm> 
using namespace std; 
#define INF 1000000000000000
#define MAXN 3000
#define LL long long
int read(){ 
    int f=1,x=0; 
    char c=getchar(); 
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();} 
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();} 
    return f*x; 
}
int a[MAXN+5];
int main(){
	int n=read(),ans=0;
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++) ans+=a[i]-1;
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

int main(){
	ll K;
	cin >> K;
	ll total = 0;
//--------------------------------------------------------
	 for(int a = 1; a <= K; a++){
	 	for(int b = 1; b <= K; b++){
	 		for(int c = 1; c <= K; c++){
	 			total += gcd(a,gcd(b,c));
	 		}
	 	}
	 }
//-----------------------------------------------------
	cout << total << endl;
}

Measured memory_bytes: 3636
/**
*    created: 12.05.2020 00:51:21
**/
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

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

    int n; cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(),d.end());
    int m = n/2;
    cout << d[m]-d[m-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
As = list(map(int, input().split()))

As.sort()

accA = sum(As[:-1])
for i in reversed(range(N - 1)):
    if accA * 2 < As[i + 1]:
        print(N - 1 - i)
        break
    accA -= As[i]
else:
    print(N)


Measured memory_bytes: 14252
/*
g++ -std=c++11 -o2 -Wall ABC110A.cpp -o .\out\ABC110A.out
.\out\ABC110A.out
*/

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

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  ans = max(ans, a * 10 + b + c);
  ans = max(ans, b * 10 + a + c);
  ans = max(ans, c * 10 + a + b);
  cout << ans << "\n";
}


Measured memory_bytes: 256
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import cs_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,k = map(int,ipt().split())
    p = list(map(int,ipt().split()))
    p.sort()
    ans = 0
    for i in p[:k:]:
        ans += i
    print(ans)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 68728
#include <stdio.h>
#include <string.h>

int main(void){

  int N, L;
  int i, j;

  scanf("%d %d", &N, &L);

  char S[N][128];
  char temp[128];

  for(i = 0; i < N; i++){
    scanf("%s", S[i]);
  }

  for(i = 1; i < N; i++){
    for(j = 1; j < N; j++){
      if(strcmp(S[j - 1], S[j]) > 0){
	strcpy(temp, S[j - 1]);
	strcpy(S[j - 1], S[j]);
	strcpy(S[j], temp);
      }
    }
  }

  for(i = 0; i < N; i++){
    printf("%s", S[i]);
  }

  printf("\n");
      
  return 0;
}


Measured memory_bytes: 128
/**
*    author:  yuya1234
*    created: 10.07.2020 11:25:42
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  int n;
  cin>>n;

  int d[n];
  REP(i,n)cin>>d[i];

  int m;
  cin>>m;

  int t[m];
  REP(i,m)cin>>t[i];

  sort(d,d+n);
  sort(t,t+m);
  int idx=0;
  string ans;

  REP(i,m)
  {
    for(int j=idx;j<n;j++)
    {
      ans="NO";
      if(t[i]==d[j])
      {
        ans="YES";
        idx=j+1;
        break;
      }
    }
    if(ans=="NO")break;
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 5200
n,k = map(int,input().split())
p = [i-1 for i in list(map(int,input().split()))]
c = list(map(int,input().split()))
ans = -float("inf")
for i in range(n):
    now = i
    cnt = [0]
    for j in range(n):
        nxt = p[now]
        cnt.append(cnt[j]+c[nxt])
        now = nxt
        if now == i:
            break
    m = len(cnt)-1
    if k <= m:
        s = max(cnt[1:(k+1)])
    elif cnt[-1] < 0:
        s = max(cnt[1:])
    else:
        t = k//m
        s = (t-1)*cnt[-1]+max(cnt[1:])
        s = max(s, t*cnt[-1]+max(cnt[:(k-t*m+1)]))
    ans = max(ans,s)
print(ans)

Measured memory_bytes: 79868
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S, T, U; bool check = true;	vector<ll> v;



int main() {
	//Code Line
	cin >> S >> T;
	T.erase(T.size() - 1);
	if (S == T)cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

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



void solve()
{
    ll b,a;cin>>a>>b;
    ll g=gcd(a,b);
    set<int>s;
    ll t=g;
        for(int64_t i = 2; i * i <= g; i++) {
        while(t % i == 0) {
            s.insert(i);
             t /= i;
            }
        }
        if(t!=1)s.insert(t);
    cout<<s.size()+1<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoderMake.ABC163
{
    class ABC163B
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select((x) => int.Parse(x)).ToArray();
            var b = Console.ReadLine().Split().Select((x) => int.Parse(x));
            var n = a[0];
            var sum = b.Sum();
            if (n>=sum)
            {
                Console.WriteLine(n-sum);
            }
            else
            {
                Console.WriteLine(-1);
            }

        }
    }
}


Measured memory_bytes: 29076
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if(A == B) cout << C << endl;
    if(A == C) cout << B << endl;
    if(B == C) cout << A << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) (x).begin(), (x).end() 
const int inf = 1e9;
const long long INF=1e15;
#define endl '\n'
#define forn(i, n) for(int i=0;i<(n);++i)
#define pb push_back
#define eb emplace_back
#define fastio ios::sync_with_stdio(false);cin.tie(0); //cout.tie(0);

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

using _Tp = long long;
static _Tp const mod = 1e9+7;
class modular {
	public:
	_Tp value;
	modular() {}
	modular(_Tp b) {value = b%mod;}
	_Tp operator=(_Tp b) {value = b%mod; return b;}
	auto operator+(modular b) {return modular{(value+b.value)%mod};}
	auto operator+(_Tp b) {return modular{(value+b)%mod};}
	auto operator-(modular b) {return modular{(value-b.value+mod)%mod};}
	auto operator-(_Tp b) {return modular{(value-b+mod)%mod};}
	auto operator*(modular b) {return modular{value*b.value%mod};}
	auto operator*(_Tp b) {return modular{value*b%mod};}
	auto operator/(modular b) {return modular{value*pow(b.value, mod-2)%mod};}
	auto operator/(_Tp b) {return modular{value*pow(b, mod-2)%mod};}
	operator _Tp() {return value;}
	static _Tp pow(_Tp v, _Tp k) {
		if(k == 0) return 1;
		if(k == 1) return v%mod;
		if(k % 2 == 0) {
			auto ret = pow(v, k/2);
			return ret*ret%mod;
		}
		return v*pow(v,k-1)%mod;
	}
};
ll fact[200001];
ll zero[200001];
modular C(ll p, ll q) {
	modular one = fact[p], two = fact[q], three = fact[p-q];
	return one/two/three;
}
modular H(ll p, ll q) {
	return C(p+q-1, q);
}

int main() {
	fastio;
	fact[0] = 1;
	for(ll i=1;i<=200000;i++) fact[i] = fact[i-1] * i % mod;
	ll n, k;
	cin >> n >> k;
	zero[0] = 1;
	for(ll i=1;i<=min(k,n-1);i++) zero[i] = H(n-i, i) * C(n, i);
	modular ans = 0;
	for(ll i=0;i<=min(k,n-1);i++) ans = ans + zero[i];
	cout << ans;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B,C,D;
  string S;
  cin>>N>>A>>B>>C>>D>>S;
  for(int i=A-1;i<C;i++){
    if(S[i]=='#' && S[i+1]=='#'){
      puts("No");
      return 0;
    }
  }
  for(int i=B-1;i<D;i++){
    if(S[i]=='#' && S[i+1]=='#'){
      puts("No");
      return 0;
    }
  }
  if(C<D){
    puts("Yes");
    return 0;
  }
  for(int i=B-2;i<D-1;i++)
    if(S[i]=='.' && S[i+1]=='.' && S[i+2]=='.'){
      puts("Yes");
      return 0;
    }
  puts("No");
}

Measured memory_bytes: 3764
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

int main(){
    
    while(true){
        
        int n;
        cin>>n;
        if(n==0)break;
        
        map<char,char> M;
        
        REP(i,n){
            char a,b;
            cin>>a>>b;
            M[a]=b;
        }
        
        int s;
        cin>>s;
        string ans;
        
        REP(i,s){
            char t;
            cin>>t;
            if(M.find(t)!=M.end())ans+=M[t];
            else ans+=t;
        }
        
        cout<<ans<<endl;
        
    }
    
    return 0;
    
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int thp, tat, ahp, aat;
  cin >> thp >> tat >> ahp >> aat;

  for (;;) {
    ahp -= tat;
    if (ahp <= 0) {
      cout << "Yes";
      return 0;
    }
    thp -= aat;
    if (thp <= 0) {
      cout << "No";
      return 0;
    }
  }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
 int a,b,c,i,j,n,s;
int main()
{
   cin>>a>>b>>c>>n;
   for (i=0;i<=a;i++)
   for (j=0;j<=b;j++)
   if ((n-i*500-j*100>=0)&&(n-i*500-j*100<=c*50))
   ++s;
   cout<<s<<endl;
    return 0;
}

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

ri1 = [a,b]
ri2 = [c,d]
ma = -10**20

for i in range(2):
    for j in range(2):
        a = ri1[i]*ri2[j]
        if a > ma:
            ma = a
print(ma)

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define endl        "\n"
#define dint        long double

const int mod = 1e9+7;

inline int add(int a, int b) { int res = a + b; if(res >= mod) res -= mod;  return res; }
inline int sub(int a, int b) { int res = a - b; if(res < 0) res += mod; return res;}
inline int mul(int a, int b) { return (a * b)%mod; }



void solve() {
    dint a, b; cin >> a >> b;
    int ans = a*b;
    cout << ans << endl;
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);


    int T = 1;
    //cin >> T;

    while(T--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3808
#include <stdio.h>

int main(void) {
	int weight;
	int i;
	int didoutput;
	while(1) {
		if(scanf("%d",&weight)==-1)break;
		for(i=0,didoutput=0;i<=9;i++) {
			if(weight & (1<<i)) {
				if(didoutput)printf(" ");
				printf("%d",1<<i);
				didoutput=1;
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    String S = sc.next();

    sc.close();

    String[] s = S.split("");

    int d = 753;

    for (int i = 0; i <= s.length - 3; i++) {

      int v = Integer.valueOf(s[i] + s[i+1] + s[i+2]);

      int d1 = Math.abs(753 - v);
      
      d = Math.min(d, d1);

    }

    System.out.println(d);

  }

}

Measured memory_bytes: 23892
N, M = map(int, input().split())

P = []
Y = []

d = {}
ans = [0] * M
for i in range(1,N+1):
    d[i] = []

for i in range(M):
    p,y = map(int, input().split())
    d[p].append((i,y))

for k in d.keys():
    d[k] = sorted(d[k], key=lambda x: x[1])
    for i in range(len(d[k])):
        ans[d[k][i][0]] = '{}{}'.format(str(k).zfill(6),str(i+1).zfill(6))

for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 44468
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;


LL dp[401][401];
vector<LL> a;
vector<LL> s;


LL rec(int l,int r){
    if(~dp[l][r]) return dp[l][r];
    if(l+1==r) return 0;
    LL ret=LINF;
    for (int k = l+1; k < r; k++) {
        ret=min(rec(l,k)+rec(k,r)+s[r]-s[l],ret);
    }
    return dp[l][r]=ret;
}


int main(){
    int N;cin >> N;
    LL p=0;
    s.resize(N+1);
    for (int i = 0; i < N; i++) {
        LL A;
        cin >> A;
        a.pb(A);
        s[i+1]=s[i]+A;
    }
    memset(dp,-1,sizeof(dp));
    cout << rec(0,N) << endl;
    return 0;
}




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

using namespace std;
int main()
{
    int n, t, m, mo;
    cin >> n >> t >> mo;
    long long int sum=t;
    while(--n)
    {
        cin >> m;
        sum += min(m-mo, t);
        mo=m;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a, b, k;
    scanf("%lld %lld %lld", &a, &b, &k);
    if(k <= a){
        printf("%lld %lld\n", a-k, b);
        return 0;
    }
    else if(k <= (a+b)){
        printf("0 %lld\n", a+b-k);
        return 0;
    }
    else{
        printf("0 0\n");
        return 0;
    }
}

Measured memory_bytes: 256
<?php
    $num = intval(trim(fgets(STDIN)));
    $i = 1;
    
    while($array = trim(fgets(STDIN))){
        
        $Graph[$i] = array_map('intval',explode(" ",$array));
        
        array_shift($Graph[$i]);
        array_shift($Graph[$i]);

        $i++;
    }

    //前頂点を未訪問状態にする。
    $dist = array_fill(1,$num,-1);
    
    $queue = new SplQueue();
    
    //初期条件頂点0を初期ノードとする出発地点なので距離0
    $dist[1] = 0;
    
    $queue->enqueue(1);
 
    while(!$queue->isEmpty()){
        //キューの先頭要素を取り出す。
        $v = $queue->dequeue();
        
        //ここから頂点の探査を始める。
        foreach($Graph[$v] as $value){
            if($dist[$value] != -1)continue;//到達済みの頂点は探索しない
            
            //新たな白色頂点$valueについて距離情報を更新してキューに追加する。
            $dist[$value] = $dist[$v]+1;
            $queue->push($value);
        }
    }
    for($j=1;$j<=$num;$j++){
        if($dist[$j]==0 && $j!=1){
            echo $j." "."-1"."\n";
        }else{
            echo $j." ".$dist[$j]."\n";
        }
    }
?>


Measured memory_bytes: 9428
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n;
	ll a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	ll b[n+1],c[n];
	for(int i=1;i<=n;i++) cin>>b[i];
	for(int i=1;i<n;i++) cin>>c[i];
	ll ans = b[a[0]];
	
	for(int i=1;i<n;i++)
	{
	    ans += b[a[i]];
	    if( a[i-1] + 1 == a[i] ) ans += c[a[i-1]];
	}
	cout<<ans;
	return 0;
}


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

int main() {
    int n, k, l, ans = 0;
    vector<int> v;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> l;
        v.push_back(l);
    }
    sort(v.begin(),v.end(),greater<int>());
    for(unsigned i = 0;i<k;i++){
        ans+=v[i];
    }
    cout << ans << endl;
    return 0;
}

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

signed main(){
	string S; cin>>S;
	bool pro=true;
	set<string> dict={"dream","dreamer","erase","eraser"};
	while(S.size()!=0){
		string five=S.substr(0,5);
		string six=S.substr(0,6);
		string seven=S.substr(0,7);
		if(dict.count(seven)&&S.size()>=7){
			string latter=S.substr(5,5);
			if(latter=="erase")for(int i=0;i<5;i++)S.erase(S.begin());
			else for(int i=0;i<7;i++)S.erase(S.begin());
		}
		else if(dict.count(six)&&S.size()>=6){
			for(int i=0;i<6;i++)S.erase(S.begin());
		}
		else if(dict.count(five)&&S.size()>=5){
			for(int i=0;i<5;i++)S.erase(S.begin());
		}
		else {
			pro=false; break;
		}
	}
	cout<<((pro)? "YES":"NO")<<endl;
}


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


int gcd(int a,int b){
    
    if(a==0 || b==0)return 0;
    if(a<b){
        int sw;
        sw=a;
        a=b;
        b=sw;
    }
    
    int r;
    while((r=a%b)!=0){
        a=b;
        b=r;
    }
    return b;
}

int main(void){
   int n,X;
   int x[111111];
   cin>>n>>X;
   for(int i=0;i<=n;i++){
       if(i==n)x[i]=X;
       else cin>>x[i];
   }
   sort(x,x+n+1);
   int ke=x[1]-x[0];
   for(int i=2;i<=n;i++){
       //if(ke>x[i]-x[i-1]){
        int ke2=x[i]-x[i-1];
        ke=gcd(ke,ke2);
       //}
   }
   cout<<ke<<endl;
       
   
}


Measured memory_bytes: 640
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if x[mid] >= n:
        rr = mid
    else:
        ll = mid+1


n = onem()
a = []
b = []
for i in range(n):
    x,c = m()
    a.append([x-c-1,x+c-1])
    b.append([x-c-1,x+c-1])

a.sort(key = lambda x:(x[1]))
b.sort()
aa = []

for i in range(n):
    if not aa:
        aa.append(a[0])
        bbb = a[0][1]
    else:
        if bbb <= a[i][0]:
            aa.append(a[i])
            bbb = a[i][1]
        else:
            continue

print(len(aa))   

    














Measured memory_bytes: 38264
#include <iostream>
#include <algorithm>
#include <vector>

int main ()
{
	int a, b, c;
	std::cin >> a >> b >> c;
	std::vector<int> v{ a,b,c };
	std::sort (begin (v), end (v));
	std::cout << v[0] << " ";
	std::cout << v[1] << " ";
	std::cout << v[2] << std::endl;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

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

    string s;
    cin >> s;
    int len = s.size();
    cout << s[0] << len - 2 << s[len - 1] << endl;
    return 0;
}

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

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

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


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


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

	while (true) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			break;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			break;
		}
	}
}

Measured memory_bytes: 3676
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents[i]: 要素iの親要素の番号
        # 要素iが根の場合、parents[i] = -(そのグループの要素数)
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    # 要素xが属するグループの要素数を返す
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    # 全ての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    # グループの数を返す
    def group_count(self):
        return len(self.roots())
    # 辞書{根の要素: [そのグループに含まれる要素のリスト], ...}を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    # print()での表示用
    # all_group_members()をprintする
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = MAP()
tree = UnionFind(N)
AB = [LIST() for _ in range(M)]

ans = [N*(N-1)//2]
tmp = N*(N-1)//2
for A, B in AB[::-1]:
	A, B = A-1, B-1
	if tree.find(A) != tree.find(B):
		tmp -= tree.size(A)*tree.size(B)
	ans.append(tmp)
	tree.union(A, B)

print(*ans[::-1][1:], sep="\n")


Measured memory_bytes: 123352
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll N, A[5];
    cin >> N;
    rep(i, 0, 5) cin >> A[i];
    ll max_v = (N % A[0] == 0) ? N / A[0] : N / A[0] + 1;
    rep(i, 1, 5) {
        ll tmp = (N % A[i] == 0) ? N / A[i] : N / A[i] + 1;
        chmax(max_v, tmp);
    }

    cout << 4ll + max_v << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, d;
    cin >> n >> m >> d;
    if(d == 0) {
        cout << fixed << setprecision(12) << (m - 1.0)/(n + 0.0) << endl;
    } else {
        cout << fixed << setprecision(12) << ((n - d) * 2 * (m - 1))/(n * n + 0.0) << endl;
    }

    return 0;
}
// 1 3

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

int n;
typedef pair<long long, long long> P;
vector<P> v, w;
int ans;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i){
		int a, b;
		cin >> a >> b;
		v.push_back(P(a, b));
	}
	for(int i=0; i<n; ++i){
		int a, b;
		cin >> a >> b;
		w.push_back(P(a, b));
	}
	sort(v.begin(), v.end());
	sort(w.begin(), w.end());
	for(int i=0; i<n; ++i){
		int t = -1, ma = -1;
		for(int j=0; j<n; ++j){
			if(v[j].first < w[i].first && v[j].second < w[i].second){
				if(ma < v[j].second){
					ma = v[j].second;
					t = j;
				}
			}
		}
		if(t < 0) continue;
		v[t].first = 1e9+7;
		++ans;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
   int a,b;
   cin>>a>>b;
   if((a*b)%2==0)
    cout<<"Even"<<endl;
   else
    cout<<"Odd"<<endl;

    return 0;
}


Measured memory_bytes: 3636
def main():
  N = int(input())
  A = list(map(int, input().split()))
  Q = int(input())

  MAX = 10 ** 5

  total = sum(A)
  counts = [0] * (MAX + 1)

  for v in A:
    counts[v] += 1

  for _ in range(Q):
    B, C = list(map(int, input().split()))
    diff = C - B
    t = counts[B]
    counts[B] = 0
    counts[C] += t

    total += diff * t
    print(total)

if __name__ == "__main__":
  main()

Measured memory_bytes: 83424