akhauriyash/Code-Regression huggingface dataset:
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  double n;
  cin >> n;
  cout << 6.28 * n << endl;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 string s;
 cin >> s;
 int n;
 n = s.size();
 vector<vector<int>> dp(n,vector<int>(13,0));
 int ciconv; 
 
 if(s.at(0)=='?'){ 
   for(int i=0; i<10;i++){
   dp.at(0).at(i) = 1; 
   }
 }else{ 
   ciconv = s.at(0) - '0';
   dp.at(0).at(ciconv) = 1;
 }

 for(int i=1;i<n;i++){
   ciconv = s.at(i) - '0';
   for(int j=0 ; j!=13;j++){
      for(int k=0 ; k!=10 ; k++){
        if(s.at(i)!='?' && k!=ciconv) continue;
        dp.at(i).at((j*10+k)%13) += dp.at(i-1).at(j);
        dp.at(i).at((j*10+k)%13) %= 1000000007;
      }
    }
  }
  cout << dp.at(n-1).at(5);  
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define FOR(i,x,y) for(int i=x;i<y;i++)
using namespace std;
int main(){
  long int ans=1,N,K;
  cin >> N >> K;
  ans = K;
  FOR(i,0,N-1)ans*=(K-1);
  cout << ans << endl;
}


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

int main(){
int i,j,N,K,cnt=0,t;
cin>>N>>K;
for(i=0;i<=N;i++){
for(j=0;j<=N;j++){
t=K-i-j;
if(t>=0&&t<=N)cnt++;
}
}
cout <<cnt<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
string toLower(string n){
    string word = n;
    for (int i = 0;i < n.size(); i++){
        word[i] = tolower(n[i]);
    }
    return word;
}

int main(){
    int count = 0;
    string vocab,sentence;
    cin >> vocab;
    vocab = toLower(vocab);
    while(1){
        cin >> sentence;
        if (sentence == "END_OF_TEXT") break;
        sentence = toLower(sentence);
        if (vocab == sentence) count += 1;
    }
    cout << count << endl;
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  int a[3*n];
  for(int i=0;i<3*n;i++){
    cin>>a[i];
  }
  
  int64_t sum=0;
  sort(a,a+3*n);
  for(int i=0;i<n;i++){
    sum+=a[n+i*2];
  }
  
  cout<<sum<<endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
struct UnionFind{
  vector<int> parent;
  UnionFind(int x=1){
    parent.clear();
    parent.resize(x,-1);
  }
  int find(int x){
    if(parent[x]<0)return x;
    return parent[x]=find(parent[x]);
  }
  bool same(int x,int y){
    return (find(x)==find(y));
  }
  int size(int x){
    return -parent[find(x)];
  }
  void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(size(x)<size(y))swap(x,y);
    parent[x]+=parent[y];
    parent[y]=x;
  }
};




int main(){
  int n,q;
  scanf("%d %d",&n,&q);
  UnionFind T(n);
  for(int i=0;i<q;i++){
    int type,x,y;
    scanf("%d %d %d",&type,&x,&y);
    if(type==0){
      T.unite(x,y);
    }else{
      printf("%d\n",T.same(x,y));
    }
  }
  return 0;
}



Measured memory_bytes: 3236
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)

int main() {

	int s;
	cin >> s;

	int ans = 0;

	int l, r;
	l = s / 100;
	r = s % 100;

	if (l > 12 || l == 0) ans += 1;
	if (r > 12 || r == 0) ans += 2;

	if (ans == 3) cout << "NA" << endl;
	else if (ans == 2) cout << "MMYY" << endl;
	else if (ans == 1) cout << "YYMM" << endl;
	else cout << "AMBIGUOUS" << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W, N = lr()
pairs = []
for _ in range(N):
    a, b = lr()
    a -= 1; b -= 1
    for dh in [-2, -1, 0]:
        if a + dh < 0 or a + dh > H-3:
            continue
        for dw in [-2, -1, 0]:
            if b + dw < 0 or b + dw > W-3:
                continue
            pairs.append((a+dh, b+dw))

counter = Counter(pairs)
answer = [0] * 10
counter2 = Counter(counter.values())
for k, v in counter2.items():
    answer[k] = v

answer[0] = (H-2) * (W-2) - sum(answer)
print('\n'.join(map(str, answer)))
# 30

Measured memory_bytes: 198516
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
using ll = long long;

ll dp[51][51][2501]={};

int main(){
    ll n,a,ans=0;
    cin >> n >> a;
    vector<int> x(n+1);
    for(int i=1;i<=n;i++)   cin >> x[i];
    dp[0][0][0] = 1;
    for(int j=1;j<=n;j++){
        for(int k=0;k<=n;k++){
            for(int s=0;s<=2500;s++){
                dp[j][k][s] = dp[j-1][k][s];
                if(k>0&&s>=x[j])dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j]];
            }
        }
    }
    for(int i=1;i<=n;i++){
        ans+=dp[n][i][i*a];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 50048
#include <iostream>
#include <limits>
#include <algorithm>
#include <iomanip>

using namespace std;

int main()
{
    double c, l = numeric_limits<double>::max(), h = numeric_limits<double>::min();
    while( cin >> c ) {
        l = min( l, c );
        h = max( h, c );
    }

    cout << setprecision( 1 ) << fixed << h - l << endl;
}

Measured memory_bytes: 1284
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

const ll mod = 1000000007ll;
ll power(ll x, ll y){
    if(y == 0ll)return 1ll;
    ll res = 1ll, tmp = x;
    while(y){
        if(y&1){
            res *= tmp;
            res %= mod;
        }
        tmp *= tmp;
        tmp %= mod;
        y >>= 1;
    }
    return res;
}
ll COM(ll x, ll y){
    if(x < y) return 0;
    if(x < 0 || y < 0) return 0;
    ll res = 1;
    for(int i=0; i<y; i++){
        res *= x - i;
        res %= mod;
        res *= power(y-i, mod-2);
        res %= mod;
    }
    return res;
}

ll n, m, x[100100], y[100100], a=0, b=0;

ll hoge(ll nyaa, ll nyan){
    ll res = nyaa * (nyaa+1) % mod;
    res += (nyan - 2*nyaa) * nyaa;
    return res % mod;
}

main(){
    scanf("%lld%lld", &n, &m);
    for(int i=0; i<n; i++){
        scanf("%lld", &x[i]);
        if(i){
            a += (x[i]-x[i-1])*hoge(min(i, n-i), n-1);
            a %= mod;
        }
    }
    for(int i=0; i<m; i++){
        scanf("%lld", &y[i]);
        if(i){
            b += (y[i]-y[i-1])*hoge(min(i, m-i), m-1);
            b %= mod;
        }
    }
    printf("%lld\n", a * b % mod);
    return 0;
}

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

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

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    int n, m;
    cin >> n;
    for (int i = 1; i <= n; i <<= 1)
    {
        m = i;
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    string s;
    int i,j,x=0,k=0;
    cin >> s;
    for(i=0;i<s.size();i++){
        if(s[i]!='A' && s[i]!='C' && s[i]!='G' && s[i]!='T'){
            if(x>k)
                k=x;
            x=0;
        }
        else
            x++;
    }
    if(x>k)
        k=x;
    cout << k << endl;
    return 0;
}


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

class Main {

	void solve() {

		int num = 0;
		char[] a = incharar();
		for (int i=0; i<4; i++) {
			if (a[i] == '+') num++;
			else num--;
		}
		out.println(num);

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public String instr() {
		return in.next();
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

Measured memory_bytes: 21460
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll a,b,c,d,ans;
  cin >> a >> b >> c >> d;
  ans = max(max(a*c,a*d),max(b*c,b*d));
  cout << ans << endl;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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

ll dp[15][1<<15];
ll d[16][16];
ll sm[1<<15];
int main(){
    int n,m;
    cin >> n >> m;
    Fill(d,-(1LL<<60));
    ll res = 0;
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        res += c;
        d[a][b] = c; 
        d[b][a] = c;
    }
    rep(i,(1<<n)){
        vector<int>a;
        rep(j,n){
            if((i>>j)&1){
                a.push_back(j);
            }
        }
        ll c = 0;
        for(auto x:a){
            for(auto y:a){
                if(d[x][y]>=0)c += d[x][y];
            }
        }
        c/=2;
        sm[i] = c;
    }
    Fill(dp,-(1LL<<60));
    dp[0][0] = 0;
    for(int bits = 0 ;bits<(1<<n);bits++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(i==j)continue;
                if(d[i][j]<0)continue;
                if(dp[i][bits]<0)continue;
                if((bits>>i)&1)continue;
                if((bits>>j)&1)continue;
                int mask = ((1<<n)-1)^bits;
                mask ^= (1<<i);
                mask ^= (1<<j);
                for(int p = mask;p>=0;p--){
                    p &= mask;
                    int q  = p ^ (1<<i);
                    chmax(dp[j][bits^q],dp[i][bits]+sm[q]+d[i][j]);
                }
            }
        }
    }
    
    ll mx = 0;
    for(int bits = 0;bits<(1<<n);bits++){
        if((bits>>(n-1))&1)continue;
        int mask = ((1<<n)-1)^bits;
        chmax(mx,dp[n-1][bits] + sm[mask]);
    }
    cout << res-mx << endl;
    return 0;
}

Measured memory_bytes: 4984
import collections
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
n=int(readline())
s=read().rstrip().decode().split()
c=collections.Counter(s)
print("AC x " + str(c["AC"]))
print("WA x " + str(c["WA"]))
print("TLE x " + str(c["TLE"]))
print("RE x " + str(c["RE"]))

Measured memory_bytes: 17216
require "matrix"
n, d,= gets.split.map(&:to_i)
vec = []
n.times { vec << Vector.elements(gets.split.map(&:to_i))}
count =0
vec.combination(2).to_a.each do |n|
    count += 1 if (n[0]-n[1]).r.to_i == (n[0]-n[1]).r 
end
puts count

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

int gcd(int a,int b){

  int r = a % b;
  while (r!=0){
   a = b;
    b = r;
    r = a % b;
  }
  return b;
}


int main() {
long long a,b;
  cin >> a >> b;
  int r =0;
  long long p = gcd(a,b);
  long long q = a*b;
  //;
  cout << a/p*b;
//  cout << q/p;
  
  
}

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

int main() {
  string s;
  cin >> s;
  if ((s[0]==s[1]) && (s[2]==s[3])) {
    if (s[0]==s[2]) {
      cout << "No";
      return 0;
    }
    cout << "Yes";
    return 0;
  }
  if ((s[0]==s[2]) && (s[1]==s[3])) {
    if (s[0]==s[1]) {
      cout << "No";
      return 0;
    }
    cout << "Yes";
    return 0;
  }
  if ((s[0]==s[3]) && (s[1]==s[2])) {
    if (s[0]==s[1]) {
      cout << "No";
      return 0;
    }
    cout << "Yes";
    return 0;
  }
  cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
pair<char,int> A[100000];
map<int,vector<char> > m;
int partition(int p,int r){
  int x = A[r].second;
  int i = p - 1;
  for(int j=p;j<r;j++){
    if(A[j].second <= x){
      i = i+1;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}
void MyQuickSort(int p,int r){
  if(p<r){
    int q = partition(p,r);
    MyQuickSort(p,q-1);
    MyQuickSort(q+1,r);
  }
}
int main(){
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> A[i].first >> A[i].second;
    m[A[i].second].push_back(A[i].first);
  }
  MyQuickSort(0,n-1);
  int nowpos = 0;
  int oldnum = 0;
  for(int i = 0;i < n;i++){
    if(oldnum != A[i].second)nowpos=0;
    if(m[A[i].second][nowpos] == A[i].first){
      if(i == n -1)cout <<"Stable" << endl;
      nowpos++;
      oldnum = A[i].second;
      continue;
    }
    cout << "Not stable" << endl;
    break;
  }
  for(int i = 0;i<n;i++){
    cout << A[i].first <<" " << A[i].second <<endl;
  }
  return 0;
}



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

int main() {
    int n;
    cin >> n;
    int b[100000] {0};
    for(int i = 0; i < n; i++) {
        int x;
        std::cin >> x;
        b[x]++;
    }

    int cmax = 0;
    for(int i = 0; i < 100000-2; i++) {
        cmax = max(cmax, b[i] + b[i+1] + b[i+2]);
    }
    cout << cmax << endl;

    return 0;
}

Measured memory_bytes: 640
/*
 * written by Yaqi Zhang (zhang623@wisc.edu)
 * University of Wisconsin-Madison
 * 2020
 */
#include <bits/stdc++.h>

#define INF 0x3f3f3f3f

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
    
}



Measured memory_bytes: 3652
//In The Name Of God
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int, int>
#define pb push_back
using namespace std;
const int N = 1e5 + 5, Mod = 1e9 + 7, P = 727, Lg = 22, TOF = 1900, Inf = 3e18 + 10;

int Mark[N], Dp[N], Ans = 0;
vector< int > A[N], Tp, Ap[N];

void Dfs(int u){
      Mark[u] = 1;
      for(int i = 0; i < (int)A[u].size(); i++)
            if(!Mark[A[u][i]])
                  Dfs(A[u][i]);
      Tp.pb(u);
}
int main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      int n, m; cin >> n >> m;
      for(int i = 1; i <= m; i++){
            int x, y; cin >> x >> y;
            A[x].pb(y);
            Ap[y].pb(x);
      }
      for(int i = 1; i <= n; i++)
            if(!Mark[i])
                  Dfs(i);
      reverse(Tp.begin(), Tp.end());
      for(int i = 0; i < (int)Tp.size(); i++){
            int u = Tp[i];
            for(int j = 0; j < (int)Ap[u].size(); j++)
                  Dp[u] = max(Dp[u], Dp[Ap[u][j]] + 1);
            Ans = max(Ans, Dp[u]);
      }
      cout << Ans;
      return 0;
}



Measured memory_bytes: 14588
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n;
            cin>>n;
            int x=n%10;
            if(x==2 || x==4 || x==5 || x==7 || x==9)
            {
                cout<<"hon"<<endl;
            }
            else if(x==0 || x==1 || x==6 || x==8)
            {
                cout<<"pon"<<endl;
            }
            else
            {
                cout<<"bon"<<endl;
            }
        }
        return 0;
    }


Measured memory_bytes: 3640
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int a, b, x;
    cin >> a >> b >> x;

    vector<int> v;
    FOR(i, a, min(a + x - 1, b)) {
        v.push_back(i);
    }
    FOR(i, max(b-x+1, a), b) {
        v.push_back(i);
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    REP(i, v.size()) {
        cout << v[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 8
#define FREE -1
#define NOT_FREE 1

void initialize();
void printBoard();
void recursive(int);

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
int X[N][N];

int main(){
  int i,j,k,r,c;
  initialize();
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)X[i][j]=0;
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d %d",&r,&c);
    X[r][c]=1;
  }
  recursive(0);
  return 0;
}

void initialize(){
  int i;
  for(i=0;i<N;i++){
    row[i]=FREE,col[i]=FREE;
  }
  for(i=0;i<2*N-1;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }
}
void printBoard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]){
	if(row[i]!=j)return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j){
      printf("Q");
      }
      else{
	printf(".");
      }
    }
    printf("\n");
  }
}
void recursive(int i){
  int j;
  if(i==N){
    printBoard();
    return;
  }
  for(j=0;j<N;j++){
    if(NOT_FREE==col[j]||NOT_FREE==dpos[i+j]||NOT_FREE==dneg[i-j+N-1])continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    recursive(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}




Measured memory_bytes: 2108
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	char str[27];
	int used[27]={0}, i, j, len;
	cin>>str;
	len = strlen(str);
	for(i=0; i<len; i++)
		used[str[i]-'a'] = 1;
	if(len<26){	
		for(i=0; i<26; i++){
			if(!used[i]){
				str[len] = i + 'a';
				str[len+1] = '\0';
				cout<<str<<endl;
				return 0;
			}
		}		
	} else {
		for(i=len-1; i>=0; i--){			
			for(j=str[i]-'a'+1; j<26; j++){
				if(!used[j]){
					str[i] = j + 'a';
					str[i+1] = '\0';
					cout<<str<<endl;
					return 0;
				}
			}		
			used[str[i]-'a'] = 0;			
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;   
for (int i = 0; i < N; i++){
int a, b, c; 
cin >> a >> b >> c; 
if(a > b) swap(a, b); 
if(b > c) swap(b, c);
if(a * a + b * b == c * c)
  cout << "YES" << endl; 
else
  cout << "NO" << endl; 
}
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long LL;
const int64_t INF=1e18+1;
const int mod = 1000000007;

int T;
map<LL,LL>s;
LL N,a,b,c,d;
LL dfs(LL n){
  	if(n==0)return s[0]=0;
    if(n==1)return s[1]=d;
	if(s[n]>0)return s[n];
	if(1e18/n<=d){s[n]=1e18;}
    else{s[n]=n*d;}
	s[n]=min(s[n],dfs(n/2)+a+(n%2)*d);
	s[n]=min(s[n],dfs(n/3)+b+(n%3)*d);
	s[n]=min(s[n],dfs(n/5)+c+(n%5)*d);
	s[n]=min(s[n],dfs(n/2+1)+a+(2-n%2)*d);
	s[n]=min(s[n],dfs(n/3+1)+b+(3-n%3)*d);
	s[n]=min(s[n],dfs(n/5+1)+c+(5-n%5)*d);
	return s[n];
}

int main(){
  cin>>T;
  for(int i=0;i<T;i++){
    cin>>N>>a>>b>>c>>d;
    s.clear();
    cout<<dfs(N)<<endl;
  }
  return 0;                       
}

Measured memory_bytes: 4700
#include <iostream>
#include <algorithm>

using namespace std;

void solve() {
    int a,b,c;
    cin >> a >> b >> c;
    long long t = 0;
    for (long long  i=1; i < 1e6; ++i) {
        t +=a ;
        if (t % b == c) {
            cout << "YES";
            return;
        }
    }
    cout << "NO";

}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000000000000
#define mod 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	int n, ans = 1;
	cin >> n;
	rep(i, n) {
		int a;
		cin >> a;
		if (a % 2 == 0) ans *= 2;
	}
	int x = 1;
	rep(i, n) {
		x *= 3;
	}
	cout << x - ans << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]
CD = [list(map(int, input().split())) for _ in range(n)]

AB_sorted_y = sorted(AB, key=lambda x: x[1])
CD_sorted_x = sorted(CD, key=lambda x: x[0])

bool_AB = [False] * n
bool_CD = [False] * n

res = 0
for i in range(n):
    c, d = CD_sorted_x[i]
    for j in range(n - 1, -1, -1):
        a, b = AB_sorted_y[j]
        if bool_CD[i] == False and bool_AB[j] == False and a < c and b < d:
            res += 1
            bool_AB[j] = True
            bool_CD[i] = True

print(res)

Measured memory_bytes: 40880
"""
NTC here
"""
from sys import stdin, setrecursionlimit
setrecursionlimit(10**7)

def iin(): return int(stdin.readline())
 
 
def lin(): return list(map(int, stdin.readline().split()))

# range = xrange
# input = raw_input
def main():
    n=iin()
    a=lin()
    s2=sum(a)
    s1=0
    mn=abs(s2-s1)
    for i in range(n-1):
        s1+=a[i]
        s2-=a[i]
        mn=min(mn,abs(s1-s2))
    print(mn)

"""
1 2 5 8 15 20 23 11 45
"""
        


    
    
            



    
                











main()

Measured memory_bytes: 80080
<?php

function input() {
    return trim(fgets(STDIN));
}
function input_array() {
    return explode(' ', input());
}

class Process
{
    public $name;
    public $time;
    public function __construct($name, $time)
    {
        $this->name = $name;
        $this->time = $time;
    }
}

class Queue
{
    private $_size;
    private $_queue;
    private $_head;
    private $_tail;
    public function __construct($size)
    {
        $this->_size = $size;
        $this->_queue = array_fill(0, $size, null);
        $this->_head = 0;
        $this->_tail = 0;
    }
    public function isEmpty()
    {
        return $this->_head === $this->_tail;
    }
    public function enqueue($x)
    {
        $this->_queue[$this->_tail] = $x;
        $this->_tail = ($this->_tail + 1) % $this->_size;
    }
    public function dequeue()
    {
        $x = $this->_queue[$this->_head];
        $this->_head = ($this->_head + 1) % $this->_size;
        return $x;
    }
}

list($n, $q) = array_map(function($numeric_string) {
    return (int)$numeric_string;
}, input_array());

$Q = new Queue($n + 5);
for ($_ = 0; $_ < $n; $_++) {
    list($name, $time) = input_array();
    $Q->enqueue(new Process($name, $time));
}

$elaps = 0;

while (!$Q->isEmpty()) {
    $u = $Q->dequeue();
    $c = min($q, $u->time);
    $u->time -= $c;
    $elaps += $c;
    if ($u->time > 0) {
        $Q->enqueue($u);
    } else {
        echo ($u->name) . ' ' . $elaps . "\n";
    }
}


Measured memory_bytes: 32032
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	int n, k; cin >> n >> k;
	vector<int>dl(k), l; for (auto&& x : dl)cin >> x;
	sort(dl.begin(), dl.end());

	for (int i = 0; i <= 9; i++) {
		if (count(dl.begin(), dl.end(), i) == 0)l.push_back(i);
	}

	int ans = n;
	while (1) {
		string ansSt = to_string(ans); bool ok = true;
		for (int i = 0; i < ansSt.size(); i++){
			if (count(l.begin(), l.end(), ansSt[i] - '0') == 0) { ok = false; ans++; break; }			
		}
		if (ok) { cout << ans << endl; break; }
	}

	return 0;
}

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

int u[108000];
typedef pair<int, int> P;
typedef pair<int, P> T;


int r(int x){
  if(x == u[x])return x;
  return u[x] = r(u[x]);
}

long long int res;
vector<T> edges;
vector<P> xs, ys;
int n, x, y;

void unite(int x, int y){
  x = r(x);
  y = r(y);
  u[x] = y;
}

int main(){
  for(int i = 0;i < 108000;i++){
    u[i] = i;
  }
  
  cin >> n ;
  for(int i = 0;i < n;i++){
    cin >> x >> y;
    xs.push_back(P(x, i));
    ys.push_back(P(y, i));
  }
  sort(xs.begin(), xs.end());
  sort(ys.begin(), ys.end());

  for(int i = 1;i < n;i++){
    int u = xs[i-1].second;
    int v = xs[i].second;
    int dist = xs[i].first - xs[i-1].first;
    edges.push_back(T(dist, P(u, v) ));

    
    u = ys[i-1].second;
    v = ys[i].second;
    dist = ys[i].first - ys[i-1].first;
    edges.push_back(T(dist, P(u, v) ));
  }

  sort(edges.begin(), edges.end());

  for(int i = 0;i < edges.size();i++){
    int dist = edges[i].first;
    int u = edges[i].second.first;
    int v = edges[i].second.second;
    if(r(u) == r(v))continue;
    unite(u, v);
    res += dist;
  }

  cout << res << endl;
  return 0;  		     
}

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

#define debug(x) cout << #x" = " << x;

#define st first
#define nd second

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

const int MAXN = 1E5 + 10, D = 10;

int n, m, q;
vector<int> E[MAXN];
PII a[2][MAXN][D + 1];
PII ans[MAXN];

int main(){
	scanf("%d%d", &n, &m);
	for (int u, v, i = 0; i < m; ++i){
		scanf("%d%d", &u, &v);
		E[u].push_back(v);
		E[v].push_back(u);
	}

	scanf("%d" ,&q);
	for (int i = 1; i <= q; ++i){
		int v, d, c;
		scanf("%d%d%d", &v, &d, &c);
		a[0][v][d] = PII(i, c);
	}

	for (int i = 1; i <= n; ++i){
		for (int j = D - 1; j >= 0; --j)
			a[0][i][j] = max(a[0][i][j], a[0][i][j + 1]);
		ans[i] = max(ans[i], a[0][i][0]);

//		printf("%d %d\n", i, ans[i].nd);
	}

	for (int di = 1; di <= D; ++di){
		PII (&f)[MAXN][D + 1] = a[di - 1 & 1];
		PII (&g)[MAXN][D + 1] = a[di & 1];

		for (int u = 1; u <= n; ++u){
			memset(g[u], 0, sizeof(g[u]));
			for (auto &v: E[u]){
				for (int j = D - di; j >= 0; --j)
					g[u][j] = max(g[u][j], f[v][j + 1]);
			}
			ans[u] = max(ans[u], g[u][0]);
		}
	}

	for (int i = 1; i <= n; ++i)
		printf("%d\n", ans[i].nd);
	return 0;
}


Measured memory_bytes: 24440
n = int(input())
ls = list(map(int, input().split()))
ls.sort()

ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1, n):
            if ls[i] == ls[j] or ls[i]==ls[k] or ls[k] == ls[j]:
                continue
            if ls[k] >= ls[i] + ls[j]:
                continue
            ans +=1
print(ans)

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

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

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

    long min = 1e10;
    long res = -1e10;
    REP(i, n) {
        int a;
        cin >> a;

        if (a-min>res) res=a-min;
        if (a<min) min=a;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <stack>

using namespace std;

int main(void) {
    int R, C, N;
    cin >> R >> C >> N;

    auto boundary = [R, C](int x, int y) {
        return (x == 0 || x == R || y == 0 || y == C);
    };

    vector< tuple<int,int,int> > v;
    for(int i=0; i<N; i++) {
        int x, y, z, w;
        cin >> x >> y >> z >> w;
        if(boundary(x, y) && boundary(z, w)) {
            v.emplace_back(x, y, i);
            v.emplace_back(z, w, i);
        }
    }

    stack<int> stk;
    sort(v.begin(), v.end());
    for(auto e: v) {
        if(get<0>(e) == 0 || get<1>(e) == C) {
            if(!stk.empty() && stk.top() == get<2>(e)) {
                stk.pop();
            } else {
                stk.push(get<2>(e));
            }
        }
    }

    sort(v.rbegin(), v.rend());
    for(auto e: v) {
        if(get<0>(e) == 0 || get<1>(e) == C) continue;
        if(!stk.empty() && stk.top() == get<2>(e)) {
            stk.pop();
        } else {
            stk.push(get<2>(e));
        }
    }

    if(stk.empty()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 4468
#pragma comment(linker, "/stack:640000000")
#include <bits/stdc++.h>
using namespace std;

const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
const double PI=acos(-1.0);

#define    READ(f) 	         freopen(f, "r", stdin)
#define    WRITE(f)   	     freopen(f, "w", stdout)
#define    MP(x, y) 	     make_pair(x, y)
#define    PB(x)             push_back(x)
#define    rep(i,n)          for(int i = 1 ; i<=(n) ; i++)
#define    repI(i,n)         for(int i = 0 ; i<(n) ; i++)
#define    FOR(i,L,R) 	     for (int i = L; i <= R; i++)
#define    ROF(i,L,R) 	     for (int i = L; i >= R; i--)
#define    FOREACH(i,t)      for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define    ALL(p) 	         p.begin(),p.end()
#define    ALLR(p) 	         p.rbegin(),p.rend()
#define    SET(p) 	         memset(p, -1, sizeof(p))
#define    CLR(p)            memset(p, 0, sizeof(p))
#define    MEM(p, v)         memset(p, v, sizeof(p))
#define    getI(a) 	         scanf("%d", &a)
#define    getII(a,b) 	     scanf("%d%d", &a, &b)
#define    getIII(a,b,c)     scanf("%d%d%d", &a, &b, &c)
#define    getL(a)           scanf("%lld",&a)
#define    getLL(a,b)        scanf("%lld%lld",&a,&b)
#define    getLLL(a,b,c)     scanf("%lld%lld%lld",&a,&b,&c)
#define    getC(n)           scanf("%c",&n)
#define    getF(n)           scanf("%lf",&n)
#define    getS(n)           scanf("%s",n)
#define    bitCheck(a,k)     ((bool)(a&(1<<(k))))
#define    bitOff(a,k)       (a&(~(1<<(k))))
#define    bitOn(a,k)        (a|(1<<(k)))
#define    bitFlip(a,k)      (a^(1<<(k)))
#define    iseq(a,b)         (fabs(a-b)<EPS)
#define    vi 	 vector < int >
#define    vii 	 vector < vector < int > >
#define    pii 	 pair< int, int >
#define    ff 	 first
#define    ss 	 second
#define    ll	 long long
#define    ull 	 unsigned long long
#define    POPCOUNT           __builtin_popcount
#define    POPCOUNTLL         __builtin_popcountll
#define    RIGHTMOST          __builtin_ctzll
#define    LEFTMOST(x)        (63-__builtin_clzll((x)))
#define    UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())

template< class T > inline T gcd(T a, T b) { return (b) == 0 ? (a) : gcd((b), ((a) % (b))); }
template< class T > inline T lcm(T a, T b) { return ((a) / gcd((a), (b)) * (b)); }
template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); }

#ifdef mamun
     #define debug(args...) {cerr<<"*: "; dbg,args; cerr<<endl;}
#else
    #define debug(args...)  // Just strip off all debug tokens
#endif

struct debugger{
    template<typename T> debugger& operator , (const T& v){
        cerr<<v<<" ";
        return *this;
    }
}dbg;
///****************** template ends here ****************
int t,n,m;


int main() {
    ///check for 0 or -1 if input not specified
    #ifdef mamun
//        READ("in.txt");
//        WRITE("out.txt");
    #endif // mamun
//    ios_base::sync_with_stdio(0);cin.tie(0);
string s;
while(cin >> s)
{
    int flag = 0;
    repI(i,s.size())if(s[i] == '9')flag = 1;
    if(flag)puts("Yes");
    else puts("No");
}

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 30005
#define N 105
int a[N];
int main()
{
    int ma=0,mi=1000,t,i,j,n,num=0,n1=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>t;
        switch(t/400)
        {
            case 0:a[0]=1;break;
            case 1:a[1]=1;break;
            case 2:a[2]=1;break;
            case 3:a[3]=1;break;
            case 4:a[4]=1;break;
            case 5:a[5]=1;break;
            case 6:a[6]=1;break;
            case 7:a[7]=1;break;
        }
        if(t>=3200)num++;
    }
    for(i=0;i<8;i++)
        n1+=a[i];
    if(n1==0)cout<<"1 ";
    else cout<<n1<<" ";
     cout<<n1+num;
    return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(ll int i=a;i<=b;++i)
#define rep(i,n) for(ll int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
ll int MOD=998244353;
#define N 3000000
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");
int n;
ll int a[51];

bool check(ll int m){
    ll int b=n-1-m;
    ll int res=0;
    rep(i,n){
        res+=max((ll)0,(a[i]-b+n)/(n+1));
    }
    return (res<=m);
}
main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    ll int sum=0;
    rep(i,n){
        sum+=a[i]-n+1;
    }
  	sum=max(sum,(ll)0);
    rep2(i,sum,sum+1000000){
        if(check(i)){
            cout<<i; return 0;
        }
    }
}

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

const long long MOD = 1000000007;
const long long MAX = 2000000;

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

int main()
{
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N;i++){
        cin >> A[i];
    }
    sort(A, A + N);
    bool ok = true;
    for (int i = 0; i < N - 1;i++){
        if(A[i]==A[i+1]){
            ok = false;
            break;
        }
    }
    if(ok){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 1024
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let mut s: Vec<char> = read::<String>().chars().collect();
    let mut t: Vec<char> = read::<String>().chars().collect();

    s.sort();
    t.sort_by(|c1, c2| c2.cmp(c1));

    println!("{}", if s < t { "Yes" } else { "No" });
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
from sys import stdin
import sys
from itertools import groupby
sys.setrecursionlimit(10**6) 
n,q = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n-1)]
lin = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]

kazu = [[]for _ in range(n)]
point = [0]*n

for i in range(len(li)):
    kazu[li[i][0]-1].append(li[i][1]-1)
    kazu[li[i][1]-1].append(li[i][0]-1)
for i in range(q):
    point[lin[i][0]-1] += lin[i][1]

def dfs(li,li2,now,before):
    for i in (li[now]):
        if i == before:
            continue
        li2[i] += li2[now]
        dfs(kazu,point,i,now)
dfs(kazu,point,0,-1)
print(*point)

Measured memory_bytes: 312848
using System;

namespace abc161_c
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long N = long.Parse(input[0]);
            long K = long.Parse(input[1]);

            int x = 0;
            while(x == 0)
            {
                N = N % K;
                if(N  == 0)
                {
                    Console.WriteLine(0);
                    break;
                }

                if(N == 1)
                {
                    Console.WriteLine(1);
                    break;
                }

                if(Math.Abs(N-K) > N)
                {
                    Console.WriteLine(N);
                    break;
                }
                N = System.Math.Abs(N-K);
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 27544
n=int(input())
a=[int(i) for i in input().split()]
w=[0]*n
for i in range(n-1,-1,-1):
    cnt=0
    for j in range(i,n,i+1):
        cnt+=w[j]
    if cnt%2!=a[i]:
        w[i]=1
print(w.count(1))
if w.count(1):
    ans=[]
    for i in range(n):
        if w[i]==1:
            ans.append(i+1)
    print(*ans)

Measured memory_bytes: 71260
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define print(x) cout << x << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll MOD = 1000000007;

int main()
{
    ll A, B;
    cin >> A >> B;
    ll ans = 0;
    rep(i, 2)
    {
        if (A > B) {
            ans += A;
            A--;
        }
        else
        {
            ans += B;
            B--;
        }
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,j,s;
	for(i=1;i<=9;i++){
		for(j=1;j<=9;j++){
			s=i*j;
			printf("%dx%d=%d\n",i,j,s);
		}
	}
	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

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

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

vector<pii> g[MAXN];
int dis[MAXN];
int used[MAXN];

int dfs(int s) {
	used[s] = 1;
	REP(i, 0, SZ(g[s])) {
		int to = g[s][i]._1, d = g[s][i]._2;
		if (!used[to]) {
			dis[to] = dis[s] + d;
			if (dfs(to)) {
				return 1;
			}
		} else {
			if (dis[to] != dis[s] + d) {
				return 1;
			}
		}
	}
	return 0;
}

void solve(){
	int n, m, a, b, c;
	scanf("%d%d", &n, &m);
	REP(i, 0, m) {
		scanf("%d%d%d", &a, &b, &c);
		g[a].pb(mp(b, c));
		g[b].pb(mp(a, -c));
	}
	REPN(i, 1, n) {
		if (!used[i] && dfs(i)) {
			printf("No\n");
			return;
		}
	}
	printf("Yes\n");
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

using namespace std;
typedef long long ll;
#define  input freopen("in.txt","r",stdin)
#define  output freopen("out.txt","w",stdout)
const ll mxn = 1e5+5;

ll arr[mxn];

int main()
{
	//input;
	//output;

	ll n, k;
	cin >> n >> k;

	for(ll i = 0; i < n; i++)  cin >> arr[i];

	ll l = 0, r = k-1;
	ll ans = 1e16;

	while(r<n)
	{
		ll x = abs(arr[l])+abs(arr[r]-arr[l]);
		ll y = abs(arr[r])+abs(arr[r]-arr[l]);
		ans = min(ans, min(x, y));
		l++, r++;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1152
import sys
input = sys.stdin.readline
INF = 10**18
def li():
    return [int(x) for x in input().split()]

N = int(input())
A = [INF] + li()
M = 1000
K = 0

for i in range(1,N+1):
    if i == N:
        sell_cnt = K
        K = 0
        M += sell_cnt * A[i]
        break
    if A[i+1] > A[i] and A[i] <= A[i-1]:
        buy_cnt = M // A[i]
        K += buy_cnt
        M -= buy_cnt * A[i]
    elif A[i+1] < A[i] and A[i] >= A[i-1]:
        sell_cnt = K
        K = 0
        M += sell_cnt * A[i]

print(M)

Measured memory_bytes: 61872
#include <bits/stdc++.h>
using namespace std;
#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++)
using ll = long long;

int main() {
    int x;
    cin >> x;
    int sum = 0;
    int ans;
    rep(i,x){
        sum+=(i+1);
        if (sum >= x){
            ans = i+1;
            break;
        }
    }
    cout <<  ans << endl;
    // cout << int(ceil((-1+sqrt(8*x+1))/2)) << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var s = "Christmas"; 
            var D = ReadInt();
            if (D <= 24) s += " Eve";
            if (D <= 23) s += " Eve";
            if (D <= 22) s += " Eve";
            Println(s);
        }

        static List<int> ReadLines(int n)
        {
            var l = new List<int>();
            for (int i = 0; i < n; i++)
            {
                l.Add(ReadInt());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

Measured memory_bytes: 11092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";

        while (!(line = br.readLine()).equals("0 0")) {
            int n = Integer.parseInt(line);
            if (n == 0) {
                break;
            }
            int min = 1001, max = -1, sum = 0;
            for (int i = 0; i < n; i++) {
                int s = Integer.parseInt(br.readLine());
                sum += s;
                if (s < min) {
                    min = s;
                }
                if (s > max) {
                    max = s;
                }
            }
            System.out.println((sum - min - max) / (n - 2));
        }
    }
}

Measured memory_bytes: 16912
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int main() {
	int N, X, Y; cin >> N >> X >> Y;
	map<int, int> res;
	for (int i = 1; i < N; ++i) res[i];
	for (int i = 1; i <= N; ++i) {
		for (int j = i + 1; j <= N; ++j) {
			int d1 = j - i;
			int d2 = abs(X - i) + 1 + abs(j - Y);
			++res[min(d1, d2)];
		}
	}
	for (auto& e : res) cout << e.second << endl;
	return 0;
}

Measured memory_bytes: 384