akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#define ll long long
#define frt first
#define scn second
using namespace std;
const int N = 1e5 + 5;
typedef pair <int, int> pnt;
int n, m;
int a[N];
ll s = 0;
pnt x[N];
priority_queue <int, vector<int>, greater<int> > q;

void inp() {
    scanf("%d%d", &n, &m);
    for(int i=1; i<=n; ++i) {
        scanf("%d", &a[i]);
        q.push(a[i]);
        s+=a[i];
    }
    for(int i=1; i<=m; ++i) scanf("%d%d", &x[i].frt, &x[i].scn);
}

bool cmp(pnt a, pnt b) {
    return a.scn > b.scn;
}

void pc() {
    sort(x+1, x+m+1, cmp);
    for(int i=1; i<=m; ++i) {
        for(int j=1; j<=x[i].frt; ++j) {
            int t = q.top();
            if(x[i].scn > t) {
                s = s-t+x[i].scn;
                q.pop(); q.push(x[i].scn);
            } else return;
        }
    }
}

int main()
{
    inp();
    pc();
    cout<<s;
    return 0;
}


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

int main () {

    int A, B, K;
    cin >> A >> B >> K;

    for (int i = 1; i <= K; i++) {

        if (i % 2 == 1) {
            if (A % 2 == 1) A--;

            B += A/2;
            A /= 2;
        }
        else {
            if (B % 2 == 1) B--;

            A += B/2;
            B /= 2;
        }
    }

    cout << A << " " << B << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
priority_queue<int,vector<int>,greater<int> >pq[33];
priority_queue<pii,vector<pii>,greater<pii> >program;
int main(){
	int n,c;
	cin>>n>>c;
	for(int i=0; i<n; i++){
		int s,t,ch;
		cin>>s>>t>>ch;
		program.push(make_pair(pi(s,t),ch));
	}
	while(!program.empty()){
		int start = program.top().first.first;
		int fin = program.top().first.second;
		int channel = program.top().second;
		program.pop();
		if(!pq[channel].empty() && pq[channel].top()<=start){
			pq[channel].pop();
			pq[channel].push(fin);
			continue;
		}
		bool found = false;
		for(int i=1; i<=c; i++){
			if(pq[i].empty()) continue;
			if(pq[i].top()<start){
				pq[i].pop();
				pq[channel].push(fin);
				found = true;
				break;
			}
		}
		if(!found) pq[channel].push(fin);
	}
	int ans = 0;
	for(int i=1; i<=c; i++) ans+=pq[i].size();
	cout<<ans;
}

Measured memory_bytes: 4892
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	
	public static int[] readInts(String cad) {
		String read[] = cad.split(" ");
		int res[] = new int[read.length];
		for (int i = 0; i < read.length; i++) {
			res[i] = Integer.parseInt(read[i]);
		}
		return res;
	}
	
	public static void main(String[] args) throws IOException {
		StringBuilder out = new StringBuilder();
		BufferedReader in;
		
			in = new BufferedReader(new InputStreamReader(System.in));

		int values[] = readInts(in.readLine());
		int n = values[0];
		int k = values[1];
		int hi[] = readInts(in.readLine());
		int dp[] = new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE/ 2 - 1);
		
		dp[0] = 0;
		for( int i = 0; i < n; i++ ) {
			for( int j = 1; j <= k; j++ ) {
				if( i + j < n ) {
					dp[i + j] = Math.min(dp[i+j], Math.abs(hi[i] - hi[i+j]) + dp[i]);
				}
			}
		}
		
		System.out.print(dp[n-1]);

	}
	
}


Measured memory_bytes: 33884
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		double a=stdIn.nextInt();
		double b=stdIn.nextInt();
		double x=stdIn.nextInt();
		double ans=0;
		if(x>a*a*b/2){
			x=a*a*b-x;
			ans=x*2/(a*a);
			System.out.println(Math.toDegrees(Math.atan(ans/a)));
		}
		else{
			ans=x*2/(b*a);
			System.out.println(Math.toDegrees(Math.atan(b/ans)));
		}
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=(n);i<(x);++i)
#define rem(i,n,x) for(int i=(n);i>=(x);--i)
#define pb push_back
#define setp(x) setprecision(x)
using ll = long long;

int main() {
	int n; cin >> n;
	vector<int> a(n); rep(i, 0, n) cin >> a[i];

	vector<int> ans(n);
	rep(i, 0, n) {
		ans[a[i] - 1] = i + 1;
	}

	rep(i, 0, n) {
		if (i > 0) cout << " ";
		cout << ans[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static MyUtil;

class MyUtil
{
    public static void Swap<T>(ref T a, ref T b)
    {
	var t = a;
	a = b;
	b = t;
    }

    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }

    public static long[] ReadLongArray()
    {
	return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var t = ReadIntArray();
	int a = t[0], b = t[1], c = t[2];
	int ans = Math.Min(b/a, c);
	WriteLine(ans);
    }
}


Measured memory_bytes: 13396
//kruskal tree
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#define M 999999
int parent[M],a[M],b[M];
pair<double,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int unite(int a,int b){
	int x=root(a),y=root(b);
	if(x==y)return 0;
	parent[x]=y;
	return 1;
}
typedef pair<pair<int,int>,int> X;
int main(){
	long long s=0;
	int i,n,m=0;
	scanf("%d",&n);
	vector<X>v(n);
	for(i=0;i<n;i++)scanf("%d%d",&v[i].first.first,&v[i].first.second),v[i].second=i;
	vector<function<bool(X&,X&)>> f={
		[](X &a,X &b){
			if(a.first.first!=b.first.first)return a.first.first<b.first.first;
			return a.first.second<b.first.second;
		},[](X &a,X &b){
			if(a.first.second!=b.first.second)return a.first.second<b.first.second;
			return a.first.first<b.first.first;
		}
	};
	for(auto &e:f){
		sort(v.begin(),v.end(),e);
		for(i=0;i<n-1;i++){
			a[m]=v[i].second,b[m]=v[i+1].second;
			node[m].first=min(abs(v[i].first.first-v[i+1].first.first),abs(v[i].first.second-v[i+1].first.second));
			node[m].second=m;
			m++;
		}
	}
	sort(node,node+m);
	for(i=0;i<n;i++)parent[i]=i;
	for(i=0;i<m;i++)if(unite(a[node[i].second],b[node[i].second]))s+=node[i].first;
	printf("%lld\n",s);
}

Measured memory_bytes: 15232
import Control.Monad
import Control.Applicative
solve :: [String] -> [String]
solve ("0":_) = []
solve (n:ss:lines) =
    let n' = read n :: Double in
    let ss' = [read s | s<-words ss] :: [Double] in
    let m = sum ss' / n' in
    let alpha = sqrt (sum [(s - m)^2 | s<-ss'] / n') in
    (show alpha) : solve lines

main = mapM_ putStrLn =<< solve . lines <$> getContents

Measured memory_bytes: 4932
#include <iostream>
#include <vector>
#include <map>
#include <string>

using namespace std;

#define INF 1 << 10

int main() {
	int n;

	while (cin >> n, n++) {
		map<string, int> items;
		int prices[101];
		fill(&prices[0], &prices[0]+101, INF);

		for (int i = 1; i < n; ++i) {
			string name; cin >> name;
			int price; cin >> price;
			items[name] = i;
			prices[i] = price;
		}

		int m; cin >> m;
		vector< vector< vector<int> > > recipes(n);
		for (int i = 0; i < m; ++i) {
			string o; cin >> o;
			int k; cin >> k;

			vector<int> v;
			for (int j = 0; j < k; ++j) {
				string name; cin >> name;
				v.push_back(items[name]);
			}
			recipes[items[o]].push_back(v);
		}

		while (1) {
			bool update = false;

			for (int i = 1; i < n; ++i) {
				for (int j = 0; j < recipes[i].size(); ++j) {
					int price = 0;
					for (int k = 0; k < recipes[i][j].size(); ++k)
						price += prices[recipes[i][j][k]];

					if (price < prices[i]) prices[i] = price, update = true;
				}
			}

			if (!update) break;
		}

		string query; cin >> query;
		cout << prices[items[query]] << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

using Graph = vector<vector<int>>;

vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue;
        dfs(G, next_v);
    }
}


int main(){
    ll N, X, Y;
    cin >> N >> X >> Y;

    vvi glaph(N, vi(N));
    vl count(N);

    for(int i=0; i<N-1; i++){
        glaph.at(i).at(i+1) = 1;
    }

    glaph.at(X-1).at(Y-1) = 1;

    for(ll i=0; i<N; i++){
        for(ll j=i+1; j<N; j++){
            if(glaph.at(i).at(j) == 0){
                glaph.at(i).at(j) = min(min(abs(j-i), abs((X-1)-i)+1 + abs(j-(Y-1))), abs((Y-1)-i)+1+abs(j-(X-1)));
            }
            count.at(glaph.at(i).at(j)) += 1;
        }
    }

    for(int i=1; i<N; i++){
        cout << count.at(i) << endl;
    }
}

Measured memory_bytes: 16000
from collections import deque
h,w = map(int,input().split())
lst1 = [list(list(input())) for i in range(h)]
    
#たかだか2500マスで、上下左右のショートカットをしてもあまり意味はないので4近傍全探索

def dfs(maze,sh, sw):
    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]): #4近傍について探索
        new_h, new_w = sh+j, sw+k
        if new_h < 0 or new_h >= h or \
            new_w < 0 or new_w >= w: #リスト外でないならelif条件へ
            continue
        elif maze[new_h][new_w] == "#":
            return True
    return False

for i in range(h):
    for j in range(w):
        if lst1[i][j] == "#":
            if not dfs(lst1,i,j):
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 40812
S=[ord(i)-97 for i in list(input())]
K=int(input())
N=len(S)
T=[chr(S[i]+97) for i in range(N)]
for i in range(N):
    if K>=(26-S[i]):
        K-=(26-S[i])%26
        T[i]='a'
        S[i]=0
    else:
        continue
S[-1]=(S[-1]+K)%26
T[-1]=chr(S[-1]+97)
ans=""
for i in range(N):
    ans=ans+T[i]
print(ans)


Measured memory_bytes: 4964
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
int n;
vector<double> p;
double dp[3010][3010];

int main(){
  cin >> n;
  p.resize(n);
  for(int i = 0; i < n; ++i)cin >> p[i];
  
  dp[0][0] = 1.0;
  
  for(int i = 0; i < n; ++i){
    for(int j = 0; j <= i; ++j){
      dp[i+1][j+1] += dp[i][j]*p[i];
      dp[i+1][j] += dp[i][j]*(1.0 - p[i]);
    }
  }
  double ans = 0.0;
  for(int i = (n+1)/2; i <= n; ++i){
    ans += dp[n][i];
  }
 
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}



Measured memory_bytes: 69120
#include<iostream>
#include <cmath>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    const int N = 2000;
    int a,b = 0,n[N];
    string s;

    cin >> a;

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

        for(int j = i; j > 0; --j){
            if(n[j] < n[j-1])break;
            int t = n[j-1];
            n[j-1] = n[j];
            n[j] = t;
        }
    }


    for(int i = 0;i < a;++i){
        for(int j = i + 1; j < a; ++j){
            for(int k = j + 1; k < a; ++k){
                if(n[i] < n[j] + n[k]){
                    b++;
                }else{
                    break;
                }
            }
        }
    }

   cout << b << endl;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define IMP cout << "IMPOSSIBLE" << endl
#define Imp cout << "Impossible" << endl
#define imp cout << "impossible" << endl
#define M1 cout << "-1" << endl
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in(), k = in();
    vint v = in(n);

    int ans = 0;
    rep(get, k + 1)
    {
        priority_queue<int, vint, greater<int>> q;
        rep(left, get + 1)
        {
            int l = min(left, n);
            int r = min(get - l, n - l);
            rep(i, l)
            {
                q.push(v[i]);
            }
            rep(i, r)
            {
                q.push(v[n - 1 - i]);
            }

            rep(i, k - (l + r))
            {
                if (q.empty() || q.top() >= 0)
                    break;
                q.pop();
            }

            int cnt = 0;
            while (!q.empty())
            {
                cnt += q.top();
                q.pop();
            }
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

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

    // 素数である
    return 1;
}


  int main(){
lint N;
cin >>N; lint M[N+2];
lint G[N];
lint D[N+1];
M[0]=0;
M[N+1]=0;
rep(i,N){cin >> M[i+1];
}
rep(i,N){
    G[i]=abs(M[i+2]-M[i]);
}
lint accum=0;
rep(i,N+1){
    D[i]=abs(M[i+1]-M[i]);
  accum+=D[i];
}

rep(i,N){
    cout<<accum-D[i+1]-D[i]+G[i]<<endl;
}
  }

Measured memory_bytes: 3584
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vs>		vvs;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


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

	vi cand;
	for (int i = 1; i <= min(A, B); i++)
		if (A % i == 0 && B % i == 0)
			cand.push_back(i);

	cout << cand[cand.size() - K] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int h,w,n;
    cin>>h>>w>>n;
    if(h>w){//列を塗った方が良い
        cout<<(n+h-1)/h<<endl;
    }else{
        cout<<(n+w-1)/w<<endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int K, N ;
  int A[200001];
  int min;
  
  scanf("%d %d",&K , &N);

  for(int i=1;i<=N;i++)
    scanf("%d", &A[i]);

  A[0] = A[N] - K;

  min = K;
  for(int i=1;i<=N;i++)
    if( min > K - A[i]+A[i-1] )
      min = K - A[i] + A[i-1] ;

  printf("%d\n",min);

  return 0;
}


Measured memory_bytes: 896
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, T: int):
    ret = B * (T // A)
    print(ret)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(A, B, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
// Aaradhya Beri
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
 

signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    int n;
    cin>>n;
    vi a(n);
    rep(i,0,n)
        cin>>a[i];
    w(m)
    {
        int ind,val;
        cin>>ind>>val;
        vi b = a;
        b[ind-1] = val;
        cout<<accumulate(all(b),0)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    Out(180 * (N - 2));

    return 0;
}


Measured memory_bytes: 256
#-*- utf-8 -*-

n = int(input())

a = n % 10

if a in [2, 4, 5, 7, 9]:
    print("hon", flush = True)
elif a in [0, 1, 6, 8]:
    print("pon", flush = True)
else:
    print("bon", flush = True)


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

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();
        int[] T = new int[N];
        for (int i=0; i<N; i++) {
            T[i] = sc.nextInt();
        }

        System.out.println(solve(N, C, K, T));
    }

    private static int solve(int N, int C, int K, int[] T) {
        int count = 0;

        Arrays.sort(T);

        int idx = T[0];
        int sum = 0;
        for (int i=0; i<N; i++) {
            if (T[i] - idx > K) {
                count++;
                idx = T[i];
                sum = 1;
            } else if (sum+1 > C) {
                count++;
                idx = T[i];
                sum = 1;
            } else {
                sum++;
            }
        }

        if (sum > 0) {
            count++;
        }

        return count;
    }
}


Measured memory_bytes: 50692
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define Aint(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<int> v;
typedef vector<ll> vll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
const int INF = 1001001001;
const int mINF = -1001001001;
const int mod = 1000000007;
// << fixed << setprecision(0) <<
// sort(ALL(),greater<int>());


int main() {
  int x,y,z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include <math.h>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using namespace std;
 
int main() {
	ll n;
	cin >> n;
	ll ans = 2 * n;
	rep2(i, 1,  sqrt(n)+1) {
		if (n%i == 0) ans = min(ans, i + n / i);
	}
	cout << ans - 2 << endl;
}

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

int main() {
  ll X;
  double cur = 100;
  cin >> X;
  int year = 0;
  while (cur < X) {
    cur = floor(cur * 1.01);
    year++;
  }
  cout << year << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  ll a,b,v,w,t;
  cin >> a >> v >>b >> w >> t;
  if(abs(a-b)<=t*(v-w))cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 3644
while True:
  a, b, c = input().split()
  a = int(a)
  c = int(c)
  if b == "+":
    print(a+c)
  elif b == "-":
    print(a-c)
  elif b == "/":
    print(int(a/c) )
  elif b == "*":
    print(a*c)
  else:
    break


Measured memory_bytes: 5596
from collections import deque

letters = deque(input())
n = int(input())

top = "head"

for i in range(0,n):
    command = list(input().split())
    if command[0] == "1":
        if top == "head":
            top = "tail"
        else:
            top = "head"
        
    
    else:
        if (command[1] == "2" and top == "head") or (command[1] == "1" and top == "tail"):
            letters.append(command[2])
        else:
            letters.appendleft(command[2])

if top == "tail":
    letters.reverse()
    
 
ans = "".join(letters)
print(ans)

Measured memory_bytes: 8436
#include <stdio.h>
#include <ctype.h>

int main( void ) {

	char str[200];
	int i = 0;

	gets( str );

	while ( str[i] != '\0' ) {

		if ( islower( str[i] ) ) { str[i] = toupper( str[i] ); }

		i++;

	}

	printf( "%s\n", str );

	return 0;

}

Measured memory_bytes: 524
def pushBack(ary, elem):
    ary.append(elem)


def randomAccess(ary, idx):
    print(ary[idx])


def popBack(ary):
    ary.pop()


def main():
    n = int(input())
    ary = []
    for i in range(n):
        query = input()
        if (query[0] == '0'):
            elem = int(query[2:])
            pushBack(ary, elem)
        elif (query[0] == '1'):
            idx = int(query[2:])
            randomAccess(ary, idx)
        elif (query[0] == '2'):
            popBack(ary)


if __name__ == '__main__':
    main()



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

#define zerol

using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif


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

const int MAXN = 3e5+5;
const LL MOD = 998244353;
typedef vector<int>vi;

vi r, g, b, low, mid, high;

char s[MAXN];

int n, len;




int main(int argc, char const *argv[])
{
    scanf("%d%s", &n, s);
    // printf("%d %s\n", n, s);
    len = n * 3;
    // dbg(n, len);
    for (int i=0; i<len; ++i) {
        if (s[i] == 'R') r.push_back(i);
        else if (s[i] == 'G') g.push_back(i);
        else if (s[i] == 'B') b.push_back(i);
    }
    low.resize(n);
    high.resize(n);
    mid.resize(n);
    for (int i=0; i<n; ++i) {
        vi tmp = {r[i], g[i], b[i]};
        sort(tmp.begin(), tmp.end());
        low[i] = tmp[0];
        mid[i] = tmp[1];
        high[i] = tmp[2];
    }
    

    LL ans = 1;
    for (int i=1; i<=n; ++i)
        ans = ans * i % MOD;
    int j = 0;
    for (int i=0; i<n; ++i) {
        while (j+1<n && low[j+1] <= mid[i]) ++j;
        ans = ans * (j-i+1) % MOD;
    }
    j = 0;
    for (int i=0; i<n; ++i) {
        while (j+1<n && mid[j+1] <= high[i]) ++j;
        ans = ans * (j-i+1) % MOD;
    }
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip> 
#define pb push_back
#define mp make_pair
#define fi first 
#define se second
#define rep(i, a, b) for (long long i = a; i < b; i++)
#define per(j, a, b) for (long long j = a; j >= b; j--)
using namespace std;
long long const MOD = 1000000007;
vector < set<int> > v;
vector <int> vis;
int g;
void loo(int p){
	if(vis[p])return;
	vis[p]=1;
	g++;
	for(auto i=v[p].begin(); i!=v[p].end(); ++i){
		if(vis[*i]==0)loo(*i);
	}
	return;
}
int main(){
	long long n, m;
	cin >> n >> m;
	v.resize(n+2);
	rep(i,0,m){
		int x, y;
		cin >> x >> y;
		v[x].insert(y);
		v[y].insert(x);
	}
	vis.assign(n+2, 0);
	int ans = 0;
	rep(i,1,n+1){
		if(vis[i]==0){
			g = 0;
			loo(i);
			ans = max(ans, g);
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 38320
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;

int main() {
    int A, B;
    cin >> A >> B;
    if (1 <= A && A <= 9 && 1 <= B && B <= 9) {
        cout << A * B << endl;
    } else {
        cout << -1 << endl;
    }
}

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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vector<int>> mi;
typedef vector<vector<pair<int, int>>> w_graph;
typedef vector<vector<int>> uw_graph;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   	#ifdef DEBUG
		freopen("out.txt", "w", stdout);
	#endif
	const int maxn = 3005;
	ll dp[maxn][maxn];
	
	int n;
	cin >> n;
	vector<ll> a(n);
	
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < maxn; i++){
		for (int j = 0; j < maxn; j++){
			dp[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n - i; j++){
			int left = j, right = j + i;
			if (right == left) dp[left][right] = a[left];
			else{
				dp[left][right] = max(a[left] - dp[left + 1][right], a[right] - dp[left][right - 1]);
			}
		}
	}
	cout << dp[0][n - 1] << endl;


	return 0;
}


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

int main() {
  string N;
  cin >> N;
  
  if (N == "Sunny") {
    cout << "Cloudy" << endl;
  } else if (N == "Cloudy") {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t ;
    t = 1;
    for(int i=0;i<t;i++)
    {
        int n;
        cin>>n;
        for(int j=1;j<100000001;j++)
        {
            ll x = j*n;
            if(x%360==0)
            {
                cout<<j;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3640
#include <cstdio>

typedef unsigned long long uint64;

const int B = 31;
const int MAXN = 5000 + 10;

uint64 sum[MAXN][MAXN];
char s[MAXN];

int main() {
	int i, j, n, len;
	
	scanf("%d %s", &n, s+1);
	for(i=1; i<=n; i++) 
		for(j=i; j<=n; j++)
			sum[i][j] = sum[i][j - 1] * B + s[j] - 'a';
	
	len = 0;
	for(i=1; i<=n; i++) 
		for(j=i; j<=n; j++) 
			while(sum[i][i + len] == sum[j][j + len] and i + len < j and j + len <= n) 
				len++;
	printf("%d\n", len);
	return 0;
}

Measured memory_bytes: 194944
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
ll dp[402][402];
ll a[402];
ll sum[402];
void solve (ll i, ll j)
{
	if (dp[i][j]!=-1)
		return;
	else
	{
		if (i==j)
		{
			dp[i][j]=0;
			return;
		}
		else if (i<j)
		{
			dp[i][j]=1e18;
			for (ll k=i;k<j;k++)
			{
				solve(i,k);
				solve(k+1,j);
				ll a=dp[i][k]+dp[k+1][j]+(sum[j]-sum[k])+(sum[k]-sum[i-1]);
				dp[i][j]=min(dp[i][j],a);
			}
				return;
		}
	}
}
int main()
{
	ll n;
	cin>>n;
	memset(sum,0,sizeof(sum));
	for (ll i=1;i<=n;i++)
	{
		cin>>a[i];
		if (i==1)
			sum[i]=a[i];
		else
			sum[i]=sum[i-1]+a[i];
	}
	// for (ll i=0;i<=n;i++)
	// 	dp[i][i]=0;
	// for (ll l=2;l<=n;l++)
	// {
	// 	for (ll i=1;i<=n-l+1;i++)
	// 	{
	// 		ll j=i+l-1;
	// 		dp[i][j]=1e18;
	// 		for (ll k=i;k<j;k++)
	// 		{
	// 			ll ans=dp[i][k]+dp[k+1][j]+(sum[k]-sum[i-1]+sum[j]-sum[k]);
	// 			dp[i][j]=min(dp[i][j],ans);
	// 		}
	// 	}
	// }
	for (ll i=1;i<=n;i++)
	{
		for (ll j=1;j<=n;j++)
		{
			dp[i][j]=-1;
		}
	}
	solve(1,n);
	cout<<dp[1][n];
}

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

int H, W;
char board[30][30];
bool visited[30][30];

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

void dfs(int x, int y) {
   for (int i = 0; i < 4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
      if (board[nx][ny] == '#') continue;
      if (visited[nx][ny]) continue;
      visited[nx][ny] = true;
      dfs(nx, ny);
   }
}

int main() {
   while (cin >> W >> H, W || H) {
      memset(visited, false, sizeof(visited));

      int sx = 0, sy = 0;
      for (int i = 0; i < H; i++) {
         for (int j = 0; j < W; j++) {
            cin >> board[i][j];
            if (board[i][j] == '@') {
               sx = i, sy = j;
            }
         }
      }

      visited[sx][sy] = true;
      dfs(sx, sy);

      int cnt = 0;
      for (int i = 0; i < H; i++) {
         for (int j = 0; j < W; j++) {
            if (visited[i][j]) cnt++;
         }
      }
      cout << cnt << endl;

   }
   return 0;
}


Measured memory_bytes: 3012
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Queue;

public class Main {
	static ContestScanner in;
	static Writer out;
	public static void main(String[] args) {
		Main main = new Main();
		try {
			in = new ContestScanner();
			out = new Writer();
			main.solve();
			out.close();
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	void solve() throws IOException {
		int n = in.nextInt();
		a = in.nextLong();
		b = in.nextLong();
		diff = a - b;
		h = new long[n];
		for(int i = 0; i < n; i++) {
			h[i] = in.nextLong();
		}
		long left = 0;
		long right = 1000000000;
		long ans = right;
		while(left <= right) {
			long mid = (left + right) / 2;
			if(check(mid)) {
				right = mid - 1;
				ans = mid;
			} else {
				left = mid + 1;
			}
		}
		System.out.println(ans);
	}
	
	long[] h;
	long a, b, diff;
	boolean check(long m) {
		long lim = m;
		for(int i = 0; i < h.length; i++) {
			long sub = h[i] - m * b;
			if(sub > 0) {
				lim -= (sub + diff - 1) / diff;
				if(lim < 0) return false;
			}
		}
		return true;
	}
}

class Writer extends PrintWriter{
	public Writer(String filename)throws IOException
	{super(new BufferedWriter(new FileWriter(filename)));}
	public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
	private BufferedReader in;private int c=-2;
	public ContestScanner()throws IOException 
	{in=new BufferedReader(new InputStreamReader(System.in));}
	public ContestScanner(String filename)throws IOException
	{in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
	public String nextToken()throws IOException {
		StringBuilder sb=new StringBuilder();
		while((c=in.read())!=-1&&Character.isWhitespace(c));
		while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public String readLine()throws IOException{
		StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
		while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public long nextLong()throws IOException,NumberFormatException
	{return Long.parseLong(nextToken());}
	public int nextInt()throws NumberFormatException,IOException
	{return(int)nextLong();}
	public double nextDouble()throws NumberFormatException,IOException 
	{return Double.parseDouble(nextToken());}
	public void close() throws IOException {in.close();}
}

Measured memory_bytes: 40868
n=int(input())
if n<3:
  print(0)
else:
  L=[int(i) for i in input().split()]
  x=0
  for i in range(0,n-2):
    for j in range(i+1,n-1):
      for k in range(j+1,n):
        if L[i]==L[j] or L[j]==L[k] or L[k]==L[i]:
          pass
        elif L[i]+L[j]>L[k] and L[i]+L[k]>L[j] and L[j]+L[k]>L[i]:
          x+=1
        else:
          pass
  print(x)

Measured memory_bytes: 73932
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++){
    if (s[i] == s[i+1]){
      cout << "Bad\n";
      return 0; 
    }
  }
  cout << "Good\n";
  return 0; 
}

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

int main(){
    string s,t;
    cin >> s >> t;
    int l = s.size();
    int flag = 0;
    string x = s;
    while(l > 0){
        if(x == t){
            flag++;
            cout << "Yes";
            break;
        }
        x = x.back() + x.substr(0,x.size()-1);
        l--;
    }
    if(flag == 0) cout << "No";
}

Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

A, B = LI()

ans = 0
for i in range(2):
    if A >= B:
        ans += A
        A -= 1
    else:
        ans += B
        B -= 1

print(ans)



Measured memory_bytes: 67052
h, w = gets.split.map(&:to_i)
grid = []
h.times do
  grid << gets.chomp.split('')
end

grid.delete_if { |row| row.all? { |cell| cell == '.' } }
grid = grid.transpose
grid.delete_if { |row| row.all? { |cell| cell == '.' } }
grid = grid.transpose

puts grid.map(&:join)


Measured memory_bytes: 2556
#include<bits/stdc++.h>
using namespace std;
#define _ ios::sync_with_stdio(false);cin.tie(0);
#define __ cout<<fixed;cout<<setprecision(10);
#define int long long

int32_t main() {
	_ __

#ifdef LOCAL_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	string s;
	cin >> s;
	int count;
	if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
		count = 3;
	}
	else if ((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')) {
		count = 2;
	}
	else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
		count = 1;
	}
	else {
		count = 0;
	}
	cout << count << "\n";


#ifdef LOCAL_JUDGE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif

	return 0;
}

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


int main() {
    int k,A,B;
    cin >> k >> A >> B;
    string ans ="NG";
    for(int i=A;i<=B;i++){
        if( i%k == 0 ){
            ans = "OK";
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};



int main(){
   string s;
   while(cin >> s){
       if(s == "#")return 0;
       int y,m,d;
       cin >> y  >> m >> d;
       tuple<int, int, int> t = make_tuple(y, m ,d), w = make_tuple(31, 4, 30);
       if(t > w){
           cout<<"?"<<" "<<y-30<<" "<<m<<" "<<d<<endl;
       }else{
           cout<<"HEISEI"<<" "<<y<<" "<<m<<" "<<d<<endl;
       }
   }
}



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

int GetDigits(int n){
	int digits=0;
	while(true){
		if(n==0) break;
		digits++;
		n/=10;
	}
	return digits;
}

int main(){
	long N;
	cin>>N;
	int ans=100;
	for(int i=1;i<=N;++i){
		if(N/i<i) break;
		if(N%i==0){
			long j=N/i;
			if(GetDigits(j)<ans) ans=GetDigits(j);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
using namespace std;

//#define fileio

#ifndef fileio
#include <iostream>
#endif
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <string>
#include <ctime>

typedef long long ll;

#ifdef fileio
ifstream cin;
ofstream cout;
#endif



int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef fileio
    cin.open("Text.txt");
    cout.open("Output.txt");
#endif

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;

}


Measured memory_bytes: 3648
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

int main()
{
    ll X,ans=0;
    cin>>X;
    ans+=(X/500)*1000;
    ans+=((X%500)/5)*5;
    cout<<ans;
}


Measured memory_bytes: 256
/*
lakshaygpt28
Lakshay Gupta
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
using vll = vector < ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;


#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

ll ans[N], a[N];

int main() {
    fast_io();
    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll sum = 0;
    for (ll i = 0; i < n; i++) {
        if (i & 1) {
            sum -= a[i];
        } else {
            sum += a[i];
        }
    }
    ans[0] = sum;
    for (ll i = 1; i < n; i++) {
        ans[i] = 2 * a[i - 1] - ans[i - 1];
    }
    for (ll i = 0; i < n; i++) {
        cout << ans[i] << " \n"[i == n - 1];
    }
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
using namespace std;

const int MP = 999983;
bool sieve[MP+1];
int ac[MP+1];

void makeSieve() {
    memset(sieve, false, sizeof sieve);
    sieve[0] = sieve[1] = true;
    for (int i=2; i*i<=MP; ++i) {
        if (sieve[i]) continue;
        for (int j=i*i; j<=MP; j+=i) {
            sieve[j] = true;
        }
    }
}

void acum() {
    ac[0] = 0;
    for (int i=1; i<=MP; ++i) {
        ac[i] = ac[i-1] + !sieve[i];
    }
}

int main() {
    makeSieve(); acum();
    int n, p, m;
    while (cin >> n, n) {
        int ret = 0;
        for (int i=0; i<n; ++i) {
            cin >> p >> m;
            int l = max(0, p-m);
            int h = min(MP, p+m);
            int X = ac[h] - (l-1 < 0 ? 0 : ac[l-1]);
            ret += X - 1;
        }
        cout << ret << endl;
    }
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  if(n<=2) return cout << 0 <<endl,0;
  int ans=0;
  for(int i=0;i<n-2;++i){
    for(int j=i+1;j<n-1;++j){
      for(int k=j+1;k<n;++k){
         if(l[i]==l[j]||l[j]==l[k]||l[k]==l[i])continue;
         if(l[i]+l[j]<=l[k] || l[j]+l[k]<=l[i] || l[k]+l[i]<=l[j])continue;
         ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600