akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
#ABC135 C

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ans = 0
for i in range(n):
    if b[i] <= a[i]:
        ans += b[i]
        a[i] -= b[i]
    else:
        ans += a[i]
        su = b[i] - a[i]
        a[i] = 0
        if a[i+1] - su >= 0:
            ans += su
            a[i+1] -= su
        else:
            ans += a[i+1]
            a[i+1] = 0
print(ans)


Measured memory_bytes: 82020
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; i++)
  {
    cin >> h.at(i);
  }

  vector<int> dp(N, INF);
  dp.at(0) = 0;
  dp.at(1) = abs(h.at(1) - h.at(0));
  for (int i = 2; i < N; i++)
  {
    chmin(dp.at(i), dp.at(i - 1) + abs(h.at(i - 1) - h.at(i)));
    chmin(dp.at(i), dp.at(i - 2) + abs(h.at(i - 2) - h.at(i)));
  }
  
  int ans = dp.at(N - 1);
  cout << ans << endl;
  
  //for (int i = 0; i < N; i++) cerr << dp.at(i) << endl;
}

Measured memory_bytes: 1792
#include <iostream> 
#include <math.h>  
using namespace std; 
void findNumberOfDigits(long n, int base) 
{ 

    int dig = (int)(floor( log(n) /  
                         log(base)) + 1);  
      
 
    cout<< dig; 
} 
  

int main() 
{ 
   
   long long int n;
long long int b; 
cin>>n>>b;
     
    findNumberOfDigits(n,b); 
    return 0; 
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	vector<ll> res(k, 0);
	rrep(i, n + 1) res[i % k]++;
	for (int a = 0; a < k; ++a) {
		ll b = (k - a) % k;
		ll c = (k - a) % k;
		if ((b + c) % k != 0) continue;
		ans += res[a] * res[b] * res[c];
	}
	dunk(ans);

	return 0;
}

Measured memory_bytes: 1792
//http://baitop.hatenadiary.jp/entry/2018/07/09/193455
#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>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int n;
vector<ll>a,b,c,d;
ll solve(){
   ll ans=0;
   c.resize(n);
   d.resize(n);

   rep(i,29){
       ll cnt=0;
       ll t=1<<i;
       rep(j,n){
           c[j]=a[j]%(2*t);
           d[j]=b[j]%(2*t);
       }
       sort(d.begin(),d.end());
       rep(ci,n){
           cnt+=lower_bound(d.begin(),d.end(),2*t-c[ci])-lower_bound(d.begin(),d.end(),t-c[ci]);
           cnt+=lower_bound(d.begin(),d.end(),4*t-c[ci])-lower_bound(d.begin(),d.end(),3*t-c[ci]);
       }
       ans|=(cnt&1)<<i;
   }

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

    cin>>n;
    a.resize(n);
    b.resize(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;

#define ll long long

#define si(x) scanf("%d", &x)
#define sll(x) scanf("%lld", &x)

#define pi(x) printf("%d", x)

int main()
{
    ll t, n, count = 0, m;
    sll(t);

    while (t--)
    {
        sll(n), sll(m);
        bool prev = true;

        if (n == m && prev)
        {
            count++;
            prev = true;
        }
        else
        {
            if (count < 3)
            {
                count = 0;
            }
            prev = false;
        }
    }

    if (count >= 3)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }

    return 0;
}

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

# define ll long long 
# define VI vector<int>
# define VLL vector<ll>
# define PII pair<int,int> 
# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ld long double
# define FOR(i,a,b) for(int i = a ; i < b ; ++i)
# define RFOR(i,a,b) for(int i = a ; i >= b ; --i)
const int MxN = 200001 ; 
const int MOD = 1e9 + 7 ; 

/* VARIABLES */
int n  ;
int ans ; 
/* END OF VARIABLES */

inline bool check(ll x) {
	int a=0,b=0,c=0 ; 
	while(x) {
		ll r = x %10 ; 
		if(r == 3)
			a++;
		else if(r == 5)
			b++;
		else if(r == 7)
			c++;
		x /= 10 ; 
	}
	if(a>0&&b>0&&c>0)
		return true ; 
	else 
		return false ; 
}

void dfs(ll v) {
	
	if(v > n ) 
		return ; 
	if(check(v))
		ans++;
	dfs(v*10 + 3) ;
	dfs(v*10 + 5) ;
	dfs(v*10 + 7) ; 
}

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

	cin >> n ; 
	dfs(0) ; 
	cout << ans ; 
	
	return 0 ; 
}



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

public class Main {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int l = in.nextInt();
		String[] strs = new String[n];
		
		for (int i  = 0; i < n; i++)
			strs[i] = in.next();
		
		Arrays.sort(strs);
		
		String ans = "";
		for (int i = 0; i < n; i++) {
			ans += strs[i];
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 25428
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair< long long int ,long long int > iil;
typedef long long ll;
typedef vector< ll > vl;
typedef vector< vl > vvl;
const ll MAX = 1e5+5;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for( auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define EE '\n'
#define ll long long int
#define forn(i,j,n) for ( auto i=j ; i<n ; i++ )
#define fornd(i,j,n) for ( auto i=j ; i>n ; i-- )
#define PI 3.14159265
#define g(a,b) a>b?a:b
#define l(a,b) a<b?a:b
#define SOT(A) sort(A.begin(),A.end())
#define SOTR(A) sort(A.rbegin(),A.rend())

const int N = 200043;
const int MOD = 998244353;
//////////////// ncr ///////////////////////
int mul(int x, int y) {return (x * 1ll * y) % MOD;}
int binpow(int x, int y){
    int z = 1;
    while(y){
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}
int inv(int x) {return binpow(x, MOD - 2);}
int divide(int x, int y) {return mul(x, inv(y));}
int fact[N];
void precalc(){
    fact[0] = 1;
    for(int i = 1; i < N; i++) fact[i] = mul(fact[i - 1], i);
}
int C(int n, int k)  {return divide(fact[n], mul(fact[k], fact[n - k]));}

/////////////// ncr  ///////////////////////


//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve(){
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) {
    	if (is_prime[i]) {
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


int main()
{
    int n;
    cin>>n;
	string s;
	cin>>s;
	set<int> r,g,b;
	forn(i,0,n){
	    char c=s[i];
	    if(c=='R') r.insert(i);
	    else if(c=='G') g.insert(i);
	    else b.insert(i);
	}
	ll count=0;
	for (auto x:r){
	    for(auto y:g){
	        if((x+y)%2==0 and b.find((x+y)/2)!=b.end()) count--;
	    }
	}
	for (auto x:b){
	    for(auto y:g){
	        if((x+y)%2==0 and r.find((x+y)/2)!=r.end()) count--;
	    }
	}
	for (auto x:r){
	    for(auto y:b){
	        if((x+y)%2==0 and g.find((x+y)/2)!=g.end()) count--;
	    }
	}
	count+=(r.size()*b.size()*g.size());
	cout<<count;
}	




Measured memory_bytes: 3796
#include<iostream>
using namespace std;
main()
{
	int n;cin>>n;
	for(;n--;)
	{
		long a,b;cin>>a>>b;
		int cnt=0;
		for(long i=-500;i<=500;i++)for(long j=-500;j<=500;j++)
		{
			if(!i&&!j||i*i+j*j>a*a+b*b)continue;
			cnt+=(i*a+j*b)%(i*i+j*j)==0&&(i*b-j*a)%(i*i+j*j)==0;
		}
		cout<<(cnt==8?"P":"C")<<endl;
	}
}



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

int main(void){
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if( abs(a-c) <=d){
		printf("Yes");
		return 0;
	}
	if( abs(a-b)<=d && abs(b-c)<=d){
		printf("Yes");
		return 0;
	}
	printf("No");
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <cmath>
using namespace std;
int main(){
	int N, D;
	int X[10][10];
	int sum = 0;
	int count = 0;
	cin >> N >> D;
	for (int i = 0; i < N; i++){
		for (int j = 0; j < D; j++){
			cin >> X[i][j];
		}
	}


	for (int i = 0; i < N; i++){
		for (int j = i + 1; j < N; j++){
			sum = 0;
			for (int k = 0; k<D; k++){
				sum += pow((X[i][k] - X[j][k]), 2);
			}
			int a = pow(sum, 0.5);
			if (pow(sum, 0.5) - a == 0){
				count++;
			}
		}
		
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] A = new int[N];
		
		String ans = "APPROVED";
		
		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
			if(A[i] % 2 == 0) {
				if(A[i] % 3 != 0 && A[i] % 5 != 0) {
					ans = "DENIED";
					break;
				}
			}
		}
		sc.close();
		System.out.println(ans);
	}

}

Measured memory_bytes: 35604
#include<bits/stdc++.h>
using namespace std;
#define re register
int a[110],qus[100100];
int main()
{
	re int n,k,q=0,x=0;a[0]=1e9;
	scanf("%d%d",&n,&k);
	for(re int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		a[i]--;
		if(a[i]<a[x])x=i;
	}
	for(re int i=1;i<=n;i++)if(i!=x)qus[++q]=i;
	qus[++q]=x;
	for(;k;k--)
	{
		re int x1=0;
		for(re int i=1;i<=n;i++)
		if(i!=x){
			if(!a[i]){puts("-1");return 0;}
			a[i]--;
			if(a[i]<a[x1])x1=i;
		}
		for(re int i=1;i<=n;i++)if(i!=x&&i!=x1)qus[++q]=i;
		qus[++q]=x1;x=x1;
	}printf("%d\n",q);
	for(re int i=1;i<=q;i++)printf("%d ",qus[i]);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;
typedef long long LL;

const int MOD = 1e9+7;

void solve(){
    int n,k;
    cin>>n>>k;
    vector<double> table(n,0.0);
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        table[i] = (1.0 + 1.0 * x)/2.0;
    }
    double ans = 0.0;
    double sum = 0.0;
    for(int i=0;i<n;i++){
        sum += table[i];
        if(i>=k) sum-=table[i-k];
        if(i>=(k-1)) ans = max(ans,sum);
    }

    cout.precision(8);
    cout<<ans<<endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    while(T--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 1792
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long A, B, C, X, Y;
    scan(A, B, C, X, Y);
    long ans = long.max;
    ans = ans.min(A * X + B * Y);
    ans = ans.min(min(X, Y) * C * 2 + max(0, X - min(X, Y)) * A + max(0, Y - min(X, Y)) * B);
    ans = ans.min(max(X, Y) * C * 2);
    writeln(ans);
}


Measured memory_bytes: 3676
// ARC095
// E - Symmetric Grid

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_H = 12;
const int MAX_W = 12;

int H, W;
int perm[MAX_W];
string s[MAX_H];

bool same(string a, string b) {
    reverse(b.begin(), b.end());
    return a == b;
}

bool check() {
    vector<string> ss(H);

    for (int j = 0; j < H; j++) {
        ss[j] = string(W, ' ');
        for (int i = 0; i < W; i++) {
            ss[j][i] = s[j][perm[i]];
        }
    }

    int odd_cnt = 0;
    vector<bool> used(H);
    for (int i = 0; i < H; i++) {
        if (used[i]) {
            continue;
        }
        used[i] = true;
        bool is_found = false;
        for (int j = i + 1; j < H; j++) {
            if (!used[j] && same(ss[i], ss[j])) {
                is_found = true;
                used[j] = true;
                break;
            }
        }
        if (!is_found) {
            if (H % 2 == 0 || odd_cnt >= 1) {
                return false;
            }
            odd_cnt++;
        }
    }

    return true;
}

bool dfs(int x, int b) {
    if (b == 0) {
        return check();
    }

    int li, ri;
    for (li = 0; li < W; li++) {
        if ((b >> li) & 1) {
            break;
        }
    }
    for (ri = li + 1; ri < W; ri++) {
        if ((b >> ri) & 1) {
            perm[x] = li;
            perm[W - 1 - x] = ri;
            if (dfs(x + 1, b - (1 << li) - (1 << ri))) {
                return true;
            }
        }
    }

    return false;
}

bool solve() {
    if (W % 2 == 0) {
        return dfs(0, (1 << W) - 1);
    }
    for (int k = 0; k < W; k++) {
        perm[W / 2] = k;
        if (dfs(0, (1 << W) - 1 - (1 << k))) {
            return true;
        }
    }

    return false;
}

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        cin >> s[i];
    }

    cout << (solve() ? "YES" : "NO") << endl;

    return 0;
}


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

#define int64_t long long

int main() {
	int n, K;
	cin >> n >> K;
	vector<int64_t> a(n);
	vector<int64_t> sum(n + 1);
	vector<int64_t> sumP(n + 1);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum[i + 1] = sum[i] + a[i];
		sumP[i + 1] = sumP[i];
		if (a[i] > 0) {
			sumP[i + 1] += a[i];
		}
	}

	int64_t ans = INT64_MIN;
	for (int i = 0; i + K <= n; i++) {
		ans = max(ans, max(0LL, sum[i + K] - sum[i]) + sumP[i] + sumP[n] - sumP[i + K]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define bit(n) 1 << n
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <pair <int, int> > vii;
typedef map <int, int> mii;

const int Inf = 1000000007;
const int mod = 1000000007;
const double Pi = acos(-1);

void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
set <string> S;

void Solve()
{
	string t;
	cin >> n;
	while(n--)
	{
		cin >> t;
		S.insert(t);
	}
	cout << S.size();
}

int main()
{
//	freopen("PARK.inp", "r", stdin);
//	freopen("PARK.out", "w", stdout);
	Fastio();
	Solve();
}

Measured memory_bytes: 19200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan=new Scanner (System.in);
		int n=scan.nextInt();
		int s=0;
		if(n%2==0 ) {
			System.out.println(n);
		}
		else {
			System.out.println(2*n);
		}
	}

}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)

#define MOD 1000000007

bitset<61> a[300100];

li cnt[66][2];

int main(void)
{
	li n;
	cin >> n;
	rep(i, n) {
		li aa;
		cin >> aa;
		a[i] = aa;
	}

	rep(i, 60)rep(j, 2)cnt[i][j] = 0;

	rep(i, n) {
		rep(j, 60) {
			cnt[j][a[i][j]]++;
		}
	}

	li res = 0;
	rep(i, 60) {
		li base = (1ll << i) % MOD;
		li num = (cnt[i][0] * cnt[i][1]) % MOD;
		res = (res + base * num) % MOD;
	}
	cout << res << endl;



	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
//long long a[200005];
int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    if (N >= S.length())
    {
        cout << S << endl;
    }
    else
    {
        cout << S.substr(0, N) << "..." << endl;
    }
}


Measured memory_bytes: 3548
/**
 * Title:
 * Url:
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

ll cal(ll a, ll b) {
    return a*a*a*a+a*a*a*b+a*a*b*b+a*b*b*b+b*b*b*b;
}

int main() {
    ll x; cin >> x;

    vector<ll> h;
    for(ll i=1; i<=sqrt(x); i++) {
        if(x%i==0) {
            h.push_back(i);
        }
    }

    for(auto hi:h) {
        for(ll a=0; a<1000; a++) {
            ll b = a-hi;
            auto hoge = cal(a, b);
            if(hi*cal(a, b)==x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3724
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

using namespace std;
using ll = long long int;

int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<ll>> MP(10, vector<ll>(10, 0));
  for (size_t i = 0; i <= 9; i++) {
    for (size_t j = 0; j <= 9; j++) {
      cin >> MP[i][j];
    }
  }

  for (ll k = 0; k <= 9; k++) {
    for (ll i = 0; i <= 9; i++) {
      for (ll j = 0; j <= 9; j++) {
          MP[i][j] = min(MP[i][j], MP[i][k] + MP[k][j]);
      }
    }
  }

  ll sum = 0;
  for (size_t i = 0; i < W; i++) {
    for (size_t j = 0; j < H; j++) {
      ll ai;
      cin >> ai;
      if (ai == -1 || ai == 1) {
        continue;
      }
      sum += MP[ai][1];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#define int long long
#define stoi stoll
using namespace std;

signed main() {
	string a; cin >> a;
	int b; cin >> b;
	vector<string>c;
	string e;
	for (char d : a) {
		if (d == '+' || d == '*') { c.push_back(e); e = ""; e += d; c.push_back(e); e = ""; }
		else e += d;
	}
	c.push_back(e);
	vector<string>x, y; x = y = c;
	int sum = stoi(x[0]);
	for (int i = 1; i<x.size(); i += 2) {
		if (x[i] == "+")sum += stoi(x[i + 1]);
		else sum *= stoi(x[i + 1]);
	}
	y.push_back("+");
	int S = 0;
	int J = 1;
	for (string t : y) {
		if (t == "+") { S += J; J = 1; }
		else if (t != "*")J *= stoi(t);
	}
	if (S == b) {
		if (sum == b) {
			puts("U");
		}
		else {
			puts("M");
		}
	}
	else {
		if (sum == b) {
			puts("L");
		}
		else {
			puts("I");
		}
	}
}

Measured memory_bytes: 3152
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#define mm(i,v) memset(i,v,sizeof i);
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int a,b,maxx,minn;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>a>>b;
	maxx=max(a,b);
	minn=min(a,b);
	if(maxx-1>=minn)
		cout<<maxx*2-1;
	else
		cout<<maxx+minn;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

constexpr int kMod = 1e9 + 7;
constexpr int kMax = 1e5;

vector<pair<int, int>> Factors(int num)
{
    vector<pair<int, int>> factors;
    int factor = 2;

    while (1LL * factor * factor <= num) {
        int count = 0;
        while (num % factor == 0) {
            num /= factor;
            count += 1;
        }

        if (count > 0) {
            factors.push_back({factor, count});
        }
        factor += 1;
    }

    if (num > 1) {
        factors.push_back({num, 1});
    }

    return factors;
}

pair<int, int> Euclid(int a, int b)
{
    if (b == 0) {
        return {1, 0};
    }

    auto p = Euclid(b, a % b);
    return {p.second, p.first - a / b * p.second};
}

int ModInv(int num)
{
    auto inv = Euclid(num, kMod).first;
    while (inv < 0) {
        inv += kMod;
    }
    return inv;
}

int Factorial(int n)
{
    static vector<int> fact(kMax + 1, 1);
    static int limit = 0;

    while (limit < n) {
        limit += 1;
        fact[limit] = (1LL * fact[limit - 1] * limit) % kMod;
    }
    return fact[n];
}

int Comb(int n, int k)
{
    int comb = Factorial(n);
    comb = (1LL * comb * ModInv(Factorial(k))) % kMod;
    comb = (1LL * comb * ModInv(Factorial(n - k))) % kMod;
    return comb;
}

int Solve(int parts, int sum)
{
    auto factors = Factors(sum);
    auto res = 1;

    for (const auto &p : factors) {
        res = (1LL * res * Comb(p.second + parts - 1, parts - 1)) % kMod;
    }
    return res;
}

int main()
{
    int parts, sum;
    cin >> parts >> sum;

    auto res = Solve(parts, sum);
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 640
class Uf:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def root(self, x): #連結しているもの
        if self.p[x] != x:
            self.p[x] = self.root(self.p[x])

        return self.p[x]

    def same(self, x, y): #根が同じか判定する
        return self.root(x) == self.root(y)

    def unite(self, x, y): #くっつける
        u = self.root(x)
        v = self.root(y)

        if u == v: return

        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0

            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1

    def count(self, x): #連結成分数
        return self.size[self.root(x)]

N,M,K=map(int,input().split())
A=[]
B=[]
C=[]
D=[]
for i in range(M):
    p,q=map(int,input().split())
    A.append(p-1)
    B.append(q-1)

for i in range(K):
    p,q=map(int,input().split())
    C.append(p-1)
    D.append(q-1)

Friend=Uf(N)
NG=[set() for _ in range(N)]

for i in range(M):
    Friend.unite(A[i],B[i])
    NG[A[i]].add(B[i])
    NG[B[i]].add(A[i])

for i in range(K):
    if Friend.same(C[i],D[i]): #同じ根なら・・・
        NG[C[i]].add(D[i])
        NG[D[i]].add(C[i])

for i in range(N):
    print(Friend.count(i)-len(NG[i])-1)



Measured memory_bytes: 70148
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <limits.h>
#include <float.h>
#include <numeric>
#include <queue>

using namespace std;

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


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

Measured memory_bytes: 256
from collections import defaultdict
dic=defaultdict(int)
n=int(input())
for _ in range(n): dic[input()]+=1
lis=sorted(dic.items(),key=lambda x:x[1],reverse=True)
M=lis[0][1]
ans=[]
for i in range(len(lis)):
    if lis[i][1]==M: ans.append(lis[i][0])
    else: break
ans.sort()
for i in ans: print(i)

Measured memory_bytes: 48512
#include <iostream>
#include <string>
using namespace std;
 
int main(){
    string s;
	cin >> s;
  	char c = s[3];
 
    if (s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
   cin.tie(0);
   ios::sync_with_stdio(false);
   ll n, k;
   cin >> n >> k;
   ll m = n;
   if(n>k) {
      n = n%k;
   }
   cout << min(n, abs(n-k)) << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll n=in(),a=in(),b=in();
    cout<<(n/(a+b)*a+min(a,n-n/(a+b)*(a+b)))<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll n;
    cin >> n;
    vector<vector<ll>> c(10, vector<ll>(10, 0));
    for(ll i = 1; i <= n; i++){
        string s = to_string(i);
        char a = s[0];
        char b = s[s.length()-1];
        c[a-48][b-48]++;
    }
    ll ans = 0;
    for(ll i = 1; i <= 9; i++){
        for(ll j = 1; j <= 9; j++){
            ans += c[i][j]*c[j][i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3720
// inputに入力データ全体が入る
function Main(input) {
	var input = input.split(' ');
	var N = input[0],
		Y = input[1];

	var result = "";
	for(/*10000*/var i = 0; i <= N; i++) {
		for(/*5000*/var j = 0; j <= N - i; j++) {
			var k = N - i - j;

			if(i * 10000 + j * 5000 + k * 1000 == Y) {
				result = i + " " + j + " " + k;
				break;
			}
		}
	}

	if(!result) result = "-1 -1 -1";

	console.log(result)
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7756
#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 factormod(ll a)
{
    if (a == 1)
    {
        return 1;
    }
    else
    {
        return a * factormod(a - 1) % mod;
    }
}

signed main()
{
    ll n, m;
    cin >> n >> m;
    ll ans;
    if (n == m)
    {
        ans = (2 * factormod(n) % mod) * factormod(m) % mod;
    }
    else if (n == m + 1 || n + 1 == m)
    {
        ans = factormod(n) * factormod(m) % mod;
    }
    else
    {
        ans = 0;
    }
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 5128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,A,B,C;
	
    cin >> N >> A >> B >> C;
    vector<int> l(N);
	for(int i=0;i<N;++i){
		cin >> l[i];
	}
	SORT(l);
	int res=1e9;
	do{
		for(size_t i=1;i<N;++i){
			for(size_t j=i+1;j<N;++j){
				for(size_t k=j+1;k<=N;++k){
					int a,b,c;
					a=accumulate(l.begin(),l.begin()+i,0);
					b=accumulate(l.begin()+i,l.begin()+j,0);
					c=accumulate(l.begin()+j,l.begin()+k,0);
					if(a==0||b==0||c==0) continue;
					
					int cost=0;
					cost+=10*(i-1);
					cost+=10*(j-i-1);
					cost+=10*(k-j-1);
					cost+=abs(a-A);
					cost+=abs(b-B);
					cost+=abs(c-C);
					res=min(cost,res);
				}
			}
		}
	}while(next_permutation(l.begin(),l.end()));
    cout <<res <<endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
"""
count=0
for i in range(1,N):
    for j in range(1,N):
        if (N-i)%j==0:count+=1
print(count)
"""
count=0
for i in range(1,N):
    count+=(N//i)-(N%i==0)
print(count)


Measured memory_bytes: 9068
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int minIndex = -1, maxIndex = 0;
		for(int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if(c == 'A' && minIndex < 0) minIndex = i;
			else if(c == 'Z' && i > maxIndex) maxIndex = i;
		}
		System.out.println(maxIndex - minIndex + 1);
	}

}

Measured memory_bytes: 26668
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define  REP(i, n) for(int i=0; i<(n); ++i)
#define  ALL(obj) (obj).begin(), (obj).end()
#define ll long long
#define ul unsigned long

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int M, D;
  cin >> M >> D;
  ++M; ++D;
  int d1;
  int counter=0;
  FOR(i, 4, M)
  {
    int r=(int)sqrt((double)i);
    ++r;
    r = (r>10)? 10:r;
    FOR(d10,2,r){
      d1 = i/d10;
      if(10*d10+d1<D && d1<10 && d1>1 && i%d10==0){
        if(d1!=d10 && 10*d1+d10<D) ++counter;
        ++counter;
        //cout << i << d10 << d1 << '\n';
      }
    }
  }
  cout << counter << '\n';
  return 0;
}


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

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 1e9+7;
    static vector<modint> factorial;

    modint(): num(0) {};
    modint(ll _n): num((_n + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return (num+MOD)%MOD; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
    modint operator+(const modint &r) const { return modint(num + r.num); }
    modint operator-(const modint &r) const { return modint(num - r.num); }
    modint operator*(const modint &r) const { return modint(num * r.num); }

    template<typename T>
    modint operator^(const T &r) const {
        if(r == 0) return 1;
        return (((*this)*(*this)) ^ (r/2)) * modint(r&1 ? num : 1);
    }
    modint operator/(const modint &r) const { return num * (r^(MOD-2)); }

    modint operator+=(const modint &r) { return *this = *this + r; }
    modint operator-=(const modint &r) { return *this = *this - r; }
    modint operator*=(const modint &r) { return *this = *this * r; }
    modint operator/=(const modint &r) { return *this = *this / r; }

    template<typename T>
    modint operator^=(const T &r) { return *this = *this ^ r; }

    static modint fact(int n){
        if((int)factorial.size() <= n) factorial.resize(n+1);
        if(factorial[n]) return factorial[n];
        if(n == 0) return 1;
        return factorial[n] = modint(n) * fact(n-1);
    }

    static modint com(ll n,ll r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial;


int main(void){
    int n,l=0,r=0;
    cin>>n;
    vector<int> a(n+1),pos(n+1,-1);
    rep(i,n+1){
        cin>>a[i];
        if(pos[a[i]]>=0){
            l = pos[a[i]];
            r = i;
        }
        pos[a[i]] = i;
    }
    
    for(int k = 1; k <= n+1; k++){
        cout<<modint::com(n+1,k) - modint::com(l+n-r,k-1)<<endl;
    }
    return 0;
}


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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <

// Output, Common Containers
template <typename T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const set<T> &v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const pair<T,S> &v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const map<T,S> &v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef SANYAM1101
	#define trace(args...) do{ cerr << "TRACE ON! (Line: " << __LINE__ << ")\n"; auto _stream = istringstream{string{#args}}; d_f(_stream, args); } while(0)
	void d_f(__attribute__((unused)) istringstream& _stream) {}
	template<typename Head, typename... Tails> void d_f(istringstream& _stream, Head H, Tails... T) { string _name; _stream >> _name; if(_name.back() == ',') _name.pop_back(); cerr << "\t" << _name << " <=> [" << H << "]\n"; d_f(_stream, T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

void solve(){
	int n;
	cin >> n;

	vector<int> a(n);
	for(auto& i : a) cin >> i;

	cout << *max_element(a.begin(), a.end())
            - *min_element(a.begin(), a.end())
         << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3576
#include<iostream>


using namespace std;

int main() {
	int X, A, B;
	cin >> X >> A >> B;

	int passed = B - A;//賞味期限が切れた日数

	if (passed <= 0) {
		cout << "delicious" << endl;
	}
	else {
		if (passed <= X) {
			cout << "safe" << endl;
		}
		else {
			cout << "dangerous" << endl;
		}
	}

}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    Yes( (abs(b-a) <= d && abs(c-b)<=d) || abs(c-a)<=d);
    return  0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>

using namespace std;

int calc(const vector<int>& v, const vector<int>& L, const vector<int>& ABC)
{
    int mp = 0;
    int min_sum_length = std::numeric_limits<int>::max();

    for (int i = 0; i < 3; ++i) {
        int count = 0;
        int sum_length = 0;

        for (int j = 0; j < v.size(); ++j) {
            if (v[j] == i) {
                ++count;
                sum_length += L[j];
            }
        }

        min_sum_length = min(sum_length, min_sum_length);

        if (count > 1) {
            mp += (count-1) * 10;
        }

        mp += abs(sum_length - ABC[i]);
    }

    if (min_sum_length > 0) {
        return mp;
    }

    return std::numeric_limits<int>::max();
}

int dfs(int depth, vector<int> v, const vector<int>& L, const vector<int>& ABC)
{
    if (depth == L.size()) {
        return calc(v, L, ABC);
    }

    int min = std::numeric_limits<int>::max();

    for (int i = 0; i < 4; ++i) {
        v[depth] = i;
        int mp = dfs(depth+1, v, L, ABC);
        min = std::min(mp, min);
    }

    return min;
}

int main()
{
    int N, A, B, C;
    cin >> N >> A >> B >> C;

    vector<int> ABC{ A, B, C };

    vector<int> L(N);
    for (auto&& Li : L) {
        cin >> Li;
    }

    vector<int> v(N, 0);

    int ans = dfs(0, v, L, ABC);
    std::cout << ans << std::endl;

    return 0;
}


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

int main() {
  ll n,m; cin >>n >>m;
  vector<pair<ll,ll>> ab;
  ll bufa, bufb;
  for (int i=0; i<n; i++){
    cin >>bufa >>bufb;
    ab.push_back(make_pair(bufa,bufb));
  }
  sort(ab.begin(),ab.end());
  ll cost = 0, drinks = 0;
  
  for (int i=0; i<n; i++){
    if (drinks+ab.at(i).second > m){
      cost += ab.at(i).first * (m - drinks);
      break;
    }else{
      cost += ab.at(i).first * ab.at(i).second;
      drinks += ab.at(i).second;
    }
  }
  ll ans = cost;
  cout <<ans;
  cout <<endl;
}

Measured memory_bytes: 2420
sx, sy, tx, ty = map(int,input().split())
a1 = "U"*(ty-sy)+"R"*(tx-sx)
a2 = "D"*(ty-sy)+"L"*(tx-sx)
a3 = "L"+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D"
a4 = "R"+"D"*(ty-sy+1)+"L"*(tx-sx+1)+"U"
print(a1+a2+a3+a4)

Measured memory_bytes: 3060
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

const int N=1e5+10;
int n,m;
VI e[N];

int clr[N];
bool go( int p, int c ) {
    clr[p]=c;
    for ( int i:e[p] ) {
        if ( !clr[i] ) {
            if ( !go(i,3-c) ) return 0;
        } else {
            if ( clr[i]==clr[p] ) return 0;
        }
    }
    return 1;
}

void main() {
    R(n,m);
    REP(i,m) {
        int a,b;
        R(a,b);
        e[a].PB(b);
        e[b].PB(a);
    }
    bool ok=go(1,1);
    if ( ok ) {
        LL cc[2]={};
        REP1(i,1,n) cc[clr[i]-1]++;
        LL ans=cc[0]*cc[1]-m;
        W(ans);
    } else {
        LL ans=1LL*n*(n-1)/2-m;
        W(ans);
    }
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//#define int long long
using bll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(v) (v).begin(), (v).end()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
template<typename T> inline void pv(vector<T> v) { for(ll i=0, N=v.size(); i<N; i++) cout<< v[i] << (i==N-1 ? '\n' : ' '); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2> inline T1 power(T1 x, T2 n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> class dvector : public std::vector<T> {
public:
	dvector() : std::vector<T>() {}
	explicit dvector(size_t n, const T& value = T()) : std::vector<T>(n,value) {}
	dvector(const std::vector<T>& v) : std::vector<T>(v) {}
	T& operator[](size_t n){ return this->at(n); }
};
template<typename T1, typename T2> ostream& operator<<(ostream& s, pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, dvector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){ s << v[i]; if (i < len - 1) s << "\t"; } return s; }
template<typename T> ostream& operator<<(ostream& s, dvector< dvector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){ s << vv[i] << endl; } return s; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, map<T1, T2>& m) {
	s << "{" << endl; for (auto itr = m.begin(); itr != m.end(); ++itr){ s << "\t" << (*itr).first << " : " << (*itr).second << endl; } s << "}" << endl; return s; }
template<typename T> ostream& operator<<(ostream& s, set<T>& se) {
	s << "{ "; for (auto itr = se.begin(); itr != se.end(); ++itr){ s << (*itr) << "\t"; } s << "}" << endl; return s; }
template<typename T> ostream& operator<<(ostream& s, multiset<T>& se) {
	s << "{ "; for (auto itr = se.begin(); itr != se.end(); ++itr){ s << (*itr) << "\t"; } s << "}" << endl; return s; }
#ifdef LOCAL_DEV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#ifdef LOCAL_TEST
	#define vector dvector
#endif

/*-----8<-----8<-----*/

signed main() {
	vector<ll> a;
	rep(i,3){
		ll t;
		cin>>t;
		a.push_back(t);
	}
	sort(all(a));
	p(a[0]+a[1]+a[2]*10);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
	
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
	
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
	
class fact {
public:
	int fmod = 1e9+7;
	vector<int> fac, inv;
	fact (int n, int Mod = 1e9+7) {
		fmod = Mod;
		fac = vector<int>(n,0);
		inv = vector<int>(n,0);
		fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
		for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
	}
	ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
	ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
	
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}
	
bool solve() {
	int a,b; cin >> a >> b;
	if ((a+b)%2 == 0) {
		cout << (a+b)/2 << endl;
	} else {
		cout << "IMPOSSIBLE" << endl;
	}
}
	
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 256
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');

  (function(S) {
    var h = Math.floor(S / (60 * 60));
    var m = Math.floor(S / 60 % 60);
    var s = Math.floor(S % 60);

    console.log([h,m,s].join(':'));
  })(parseInt(inputs[0], 10)); 

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15548