akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    string s;
    cin >> s;


    int ans = 0;
    int count = 0;

    rep(i,s.size()){
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
            count++;
        }else{
            count = 0;
        }
        ans = max(ans,count);
    }
    
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include <cstdio>

int N;
int a[55];
int rx[120], ry[120], rL;

void calc(int l, int r)
{
	if(l==r)
		return ;
	if(a[l]<=0){
		calc(l+1, r);
		rx[rL] = l+1;
		ry[rL] = l;
		rL ++;
	}
	else if(a[r]>=0){
		calc(l, r-1);
		rx[rL] = r-1;
		ry[rL] = r;
		rL ++;
	}
	else{
		if(a[l]+a[r]<=0){
			rx[rL] = r;
			ry[rL] = l;
			rL ++;
			calc(l+1, r);
			rx[rL] = l+1;
			ry[rL] = l;
			rL ++;
		}
		else{
			rx[rL] = l;
			ry[rL] = r;
			rL ++;
			calc(l, r-1);
			rx[rL] = r-1;
			ry[rL] = r;
			rL ++;
		}
	}
}

void solve()
{
	int i;
	calc(0, N-1);
	for(i=0; i<rL; i++){
		rx[i] ++;
		ry[i] ++;
	}
	printf("%d\n", rL);
	for(i=0; i<rL; i++){
		printf("%d %d\n", rx[i], ry[i]);
	}
}

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

Measured memory_bytes: 128
/*
      H   H
       \ / 	
        C
       / \ 
      H   H
*/

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll, ll>
#define vi          vector<ll>
#define vvi			vector<vi>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        998244353
#define rep(i,a,b)	for(ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define tr(c,i)		for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)	((c).find(x) != (c).end()) 
#define cpresent(c,x)	(find(all(c),x) != (c).end()) 
#define int ll
using namespace std;

#define N  200005

int fact[N];

int power(int x, int y)
{
	if(y==0)
		return 1;
	int temp = power(x, y/2);
	if(y%2!=0)
		return (x*((temp*temp)%hell))%hell;
	else
		return (temp*temp)%hell;
}

int inverse(int a)
{
	return power(a, hell-2);
}

int c(int n, int r)
{
	int x = fact[n];
	x = (x*inverse(fact[n-r]))%hell;
	x = (x*inverse(fact[r]))%hell;
	return x;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		int n, m, k;
		cin >> n >> m >> k;

		int ans = 0;

		fact[0] = 1;

		rep(i, 1, N)
		fact[i] = (fact[i-1]*i)%hell;

		rep(p, n-k, n+1)
		{
			int x = (m*power(m-1, p-1))%hell;
			x = (x*c(n-1, p-1))%hell;
			ans = (ans+x)%hell;
		}

		cout << ans;

	}
	return 0;
}

Measured memory_bytes: 5176
#include<stdio.h>
#define SEN 2000000000
#define MAX 200000

long long merge(int a[], int n, int left, int mid, int right)
{
	int i, j, k;
	long long c = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	
	int l[MAX/2+2], r[MAX/2+2];
	
	for( i = 0; i < n1; i++ ){
		l[i] = a[left+i];
	}
	for( i = 0; i < n2; i++ ){
		r[i] = a[mid+i];
	}
	
	l[n1] = SEN;
	r[n2] = SEN;
	
	i = j = 0;
	
	for( k = left; k < right; k++ ){
		if( l[i] <= r[j] ){
			a[k] = l[i];
			i++;
		}else{
			a[k] = r[j];
			j++;
			c += n1 - i;
		}
	}
	return c;
}

long long mergeSort(int a[], int n, int left, int right)
{
	int mid;
	long long x, y, z;
	if( left+1 < right ){
		mid = (left+right) / 2;
		x = mergeSort(a, n, left, mid);
		y = mergeSort(a, n, mid, right);
		z = merge(a, n, left, mid, right);
		return x+y+z;
	}else{
		return 0;
	}
}

int main(){
	int n, i;
	long long c;
	scanf( "%d", &n );
	
	int a[n];
	for( i = 0; i < n; i++ ){
		scanf( "%d", &a[i] );
	}
	
	c = mergeSort(a, n, 0, n);
	printf( "%lld\n", c );
	
	return 0;
}
	


Measured memory_bytes: 3416
from itertools import accumulate
from bisect import bisect_right
 
R = lambda: map(int, input().split())
*_, k = R()
a = accumulate(R())
b = list(accumulate(R()))
r = bisect_right(b, k)
for i, x in enumerate(a, 1):
  if x > k:
    break
  r = max(r, i + bisect_right(b, k - x)) 
print(r)

Measured memory_bytes: 51612
#include <bits/stdc++.h>
using namespace std;
namespace Flandre_Scarlet
{
    #define int long long 
    #define F(i,l,r) for(int i=l;i<=r;++i)
    #define D(i,r,l) for(int i=r;i>=l;--i)
    #define Fs(i,l,r,c) for(int i=l;i<=r;c)
    #define Ds(i,r,l,c) for(int i=r;i>=l;c)
    #define Tra(i,u) for(int i=G.Start(u),__v=G.To(i);~i;i=G.Next(i),__v=G.To(i))
    #define MEM(x,a) memset(x,a,sizeof(x))
    #define FK(x) MEM(x,0)
    int a,b,c,d;
    void R1(int &x)
    {
        x=0;char c=getchar();int f=1;
        while(c<'0' or c>'9') f=(c=='-')?-1:1,c=getchar();
        while(c>='0' and c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
        x=(f==1)?x:-x;
    }
    void Input()
    {
        R1(a),R1(b),R1(c),R1(d);
    }

    bool cxk(int mid)    
    {
        int k=(max(a,b)-1)/(min(a,b)+1)+1;
        int resta=a-mid/(k+1)*k-mid%(k+1);
        int restb=b-mid/(k+1);
        if (restb<=resta*k) return true;
        return false;
    }
    void Soviet()
    {
        int l=0,r=a+b+1;
        while(l<r)
        {
            int mid=(l+r)>>1;
            if (cxk(mid)) l=mid+1;
            else r=mid;
        }

        int k=(max(a,b)-1)/(min(a,b)+1)+1;
        int resta=a-r/(k+1)*k-r%(k+1);
        int restb=b-r/(k+1);
        int AB=r+restb-resta*k+1;
        F(i,c,min(d,r))   putchar(i%(k+1)?'A':'B');
        F(i,max(c,r+1),d) putchar((i-AB)%(k+1)?'B':'A');
        putchar('\n');
    }

    #define Flan void
    Flan IsMyWife()
    {
        int t;R1(t);
        while(t--)
        {
            Input();
            Soviet();
        }
    }
    #undef int //long long 
}
int main()
{
    Flandre_Scarlet::IsMyWife();
    getchar();getchar();
    return 0;
}

Measured memory_bytes: 384
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]


n,m = map(int, input().split())
g = [list(map(int,input().split())) for i in range(n)]
c = [list(map(int,input().split())) for i in range(m)]

total = []
for i in range(n):
    temp = []
    for j in range(m):
        distance = abs(g[i][0] - c[j][0]) + abs(g[i][1] - c[j][1])
        temp.append(distance)
    total.append(temp)

#print(total)
for i in range(n):
    midx = 0
    mv = 99999999999999999999999999
    for j in range(m):
        if (mv > total[i][j]):
            midx = j
            mv = total[i][j]
    print(midx+1)


Measured memory_bytes: 8888
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
double fura(int n,double leftx,double lefty,double rightx,double righty){
 
  if(n!=0){
  double s[3][2];
  s[0][0]=(2*leftx+rightx)/3;
  s[0][1]=(2*lefty+righty)/3;
  s[2][0]=(leftx+2*rightx)/3;
  s[2][1]=(lefty+2*righty)/3;
 
  s[1][0]=(s[2][0]-s[0][0])/2-(s[2][1]-s[0][1])*sqrt(3)/2+s[0][0];
  s[1][1]=(s[2][0]-s[0][0])*sqrt(3)/2+(s[2][1]-s[0][1])/2+s[0][1];
   
  fura(n-1,leftx,lefty,s[0][0],s[0][1]);
  printf("%lf %lf\n",s[0][0],s[0][1]);
  fura(n-1,s[0][0],s[0][1],s[1][0],s[1][1]);
  printf("%lf %lf\n",s[1][0],s[1][1]);
  fura(n-1,s[1][0],s[1][1],s[2][0],s[2][1]);
  printf("%lf %lf\n",s[2][0],s[2][1]);
  fura(n-1,s[2][0],s[2][1],rightx,righty);
  }
  if(n==0){
    //    printf("%lf %lf\n",rightx,righty);
    return 0;
  }
}
int main(void){
  int n;
  scanf("%d",&n);

  double p1x=0,p1y=0,p2x=100,p2y=0;
  printf("%lf %lf\n",p1x,p1y);
  fura(n,p1x,p1y,p2x,p2y);
  printf("%lf %lf\n",p2x,p2y);
  return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
 
using namespace std;
 
char in[10];
pair<pair<string,int>,int> p[101];
 
int main(){
int a;scanf("%d",&a);
for(int i=0;i<a;i++){
  int t;scanf("%s%d",in,&t);
  p[i]=make_pair(make_pair(in,-t),i);
}
sort(p,p+a);
for(int i=0;i<a;i++) printf("%d\n",p[i].second+1);
}

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

void ou(const vector<pair<int,int>>&vs){
	for(auto v:vs){
		cout<<v.first<<' '<<v.second<<endl;
	}
}

int main() {
	ios::sync_with_stdio(false);
	int N;cin>>N;
	int now=1;
	while(now<N)now*=2;
	if(now==N){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;

		vector<pair<int,int>>vs;

		if(N%2){
			for(int i=2;i<N;i+=2){
				int a=i;
				int b=i+1;
				vs.emplace_back(1,a);
				vs.emplace_back(a,b);
				vs.emplace_back(1,b+N);
				vs.emplace_back(a+N,b+N);
			}
			vs.emplace_back(3,1+N);
		}else{
			int num=N;
			int need=N ^ (N-1);
			int amemo=-1;
			for(int i=2;i<N-1;i+=2){
				int a=i;
				int b=i+1;

				if(b==need)swap(a,b);

				if(i==2)amemo=b;
				vs.emplace_back(1,a);
				vs.emplace_back(a,b);
				vs.emplace_back(1,b+N);
				vs.emplace_back(a+N,b+N);
			}
			vs.emplace_back(amemo,1+N);
			vs.emplace_back(N-2,N);
			vs.emplace_back(need,2*N);
		}
		ou(vs);
	}
	return 0;
}	

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MAX_N 20

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

struct Edge{
  int to, cost;
};

int N;
vector<vector<Edge> >G(MAX_N);
map<pi, int>m;
int g[32][32];

int dfs(int n, int prev, int v){
  if(G[n].size() == 1 && G[n][0].to == prev) return 0;
  int res = 0;
  rep(i, G[n].size()){
    int next = G[n][i].to;
    if(v >> next & 1) continue;
    v |= 1 << next;
    res += dfs(next, n, v);
  }

  return res + g[n][prev];
}

int root(int n, int prev, int v){
  //  printf("%d %d\n", n, prev);
  if(G[n].size() == 1 && G[n][0].to == prev) return 0;
  int res = 0;
  rep(i, G[n].size()){
    int next = G[n][i].to;
    if(v >> next & 1) continue;
    v |= 1 << next;
    res = max(res, root(next, n, v));
    //    printf("%d %d\n", next, res);
  }
  //  printf("%d %d %d\n", n, prev, res);
  return res + g[prev][n];
}

int main(){
  while(scanf("%d", &N) && N){
    rep(i, 32) rep(j, 32) g[i][j] = (i==j)?0:INF;
    rep(i, MAX_N) G[i].clear();
    m.clear();
    rep(i, N-1){
      int a, b, t;
      scanf("%d%d%d", &a, &b, &t); a--; b--;
      g[a][b] = g[b][a] = t;
      Edge e;
      e.to = b; e.cost = t;
      G[a].PB(e);
      e.to = a;
      G[b].PB(e);
    }

    //    printf("%d\n", dfs(0, 0, 0));
    //    printf("%d\n", root(0, 0, 0));
    printf("%d\n", 2*dfs(0, 0, 1)-root(0, 0, 1));
  }
  return 0;
}

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

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A(M);
    rep(i, M) cin >> A[i];
    int left_pos = X;
    int right_pos = X;
    int left_cost = 0;
    int right_cost = 0;
    while (true) {
        if (left_pos >= 0) {
            left_pos -= 1;
            auto itr = find(A.begin(), A.end(), left_pos);
            if (A.end() != itr) left_cost += 1;
        }
        if (right_pos <= N) {
            right_pos += 1;
            auto itr = find(A.begin(), A.end(), right_pos);
            if (A.end() != itr) right_cost += 1;
        }
        if (left_pos < 0 && right_pos > N) break;
    }
    cout << min(left_cost, right_cost) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int sum = 0;

        sum +=Math.min(a,b);
        sum +=Math.min(c,d);
        System.out.println(sum);

    }

}


Measured memory_bytes: 21204
///////////////////////////////////////////////
//		 ©Ahmad Haulian Yoga Pratama		 //
//          SMA TARUNA NUSANTARA		     //
//                MAGELANG					 //
//				   157503 					 //
// 		   	 All Right Reserved				 //
///////////////////////////////////////////////

#include<bits/stdc++.h>
using namespace std;
#define scanint(n) scanf("%d",&n)
#define scanll(n) scanf("%lld",&n)
#define mp make_pair
#define pb push_back
#define s second
#define f first
#define pii pair<int,int>
#define reset(a,b) memset(a,b,sizeof a)
#define ll long long
#define MAXAND 0x7fffffff
#define MOD 1000000007
#define lch(x) (2*x)
#define rch(x) (2*x+1)
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define dalam fl<=l && r<=fr
#define kiwo lch(idx),l,MID
#define tengen rch(idx),MID+1,r
/*
template <class T> void inp(T &N){
    char ch;
    int sign = 1;
    while(ch = getchar_unlocked(), isspace(ch)) {

    };
    N = 0;
    if(ch == '-')
        sign = -1;
    else N = ch - '0';
    while(ch = getchar_unlocked(), isdigit(ch))
        N = (N << 3) + (N << 1) + ch - '0';
    N *= sign;
}
*/

bool ada[200];
int n,x,cnt=0;
int main(){
	cin>>n;
	while(n--){
		cin>>x;
		if(!ada[x])cnt++;
		ada[x]=true;
	}
	cout<<cnt<<endl;
}



Measured memory_bytes: 256
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N = 200100;
int n , a[N] , q ;
ll sum [N];
int main ( ){
  cin >> n ;
  for  (int i = 1;  i <= n ;i++ ) {
        cin >> a[i] ;
      sum[i] = sum[i-1] + a[i] ;
  }
  ll mn = 1LL *inf*inf  ;
  for ( int i = 1 ; i <= n-1 ; i ++ ){
      mn = min ( mn , abs(sum[i]-(sum[n]-sum[i])));
  }
  cout << mn ;
return 0 ;
}


Measured memory_bytes: 5836
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=2000005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

ll nPk(ll n,ll k){
	return nCk(n,k)*F[k]%mod;
}

int h,w,k,sx,sy,gx,gy;
vs a;
vvi c;

int main(){
	cin>>h>>w>>k>>sx>>sy>>gx>>gy;
	sx--,sy--,gx--,gy--;
	a=vs(h);
	c=vvi(h,vi(w,inf));
	for(int i=0;i<h;i++) cin>>a[i];
	c[sx][sy]=0;
	queue<P> q;
	q.push({sx,sy});
	while(!q.empty()){
		P p=q.front();q.pop();
		int x=p.first,y=p.second;
		for(int i=0;i<4;i++){
			int X=x,Y=y;
			for(int j=1;j<=k;j++){
				X+=dx[i],Y+=dy[i];
				if(X<0||X>=h||Y<0||Y>=w||a[X][Y]=='@'||c[X][Y]<=c[x][y]) break;
				if(c[X][Y]==inf){
					c[X][Y]=c[x][y]+1;
					q.push({X,Y});
				}
			}
		}
	}
/*	for(int i=0;i<h;i++){
		for(auto j:c[i]) cout<<(j==inf?9:j)<<' ';
		cout<<endl;
	}*/
	int t=c[gx][gy];
	if(t==inf) t=-1;
	cout<<t<<endl;
}


Measured memory_bytes: 11116
#include "bits/stdc++.h"
#define en "\n"
using namespace std;
const int M=1e5+100;



int main()
{
    int a,b;
    cin>>a>>b;
    if(2*max(a,b)-1>=a+b)cout<<2*max(a,b)-1<<en;
    else cout<<a+b<<en;
    return 0;
}


Measured memory_bytes: 256
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
    ll a, b, c, l, r;
    cin >> a >> b >> c;
    if(a + b > c){
        cout << "No" << endl;
        return 0;
    }
    l = 4 * a * b;
    r = (c - a - b) * (c - a - b);
    if(l < r){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;





int main(){
	vector< pair<int, int> > edge;
	
	int n, m;
	cin >> n >> m;

	
	rep(i, 0, m) {
		int a, b;
		cin >> a >> b;
		auto p1 = make_pair(a, b);
		auto p2 = make_pair(b, a);
		edge.push_back(p1);
		edge.push_back(p2);

	}

	vector<int> node;
	rep(i, 1, n + 1) {
		node.push_back(i);
	}


	int ans = 0;
	do {
		int match = 0;
		rep(i, 0, n - 1) {
			int from = node[i];
			int to = node[i + 1];
			for (auto x : edge) {
				if (from == x.first && to == x.second) {
					match++;
				}
			}
		}
		if (match == n - 1 && node[0]==1)ans++;
	} while (next_permutation(node.begin(), node.end()));

	cout << ans << endl;
	




	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

MAX = 5*10**5+100
MOD = 10**9+7
fact = [0]*MAX #fact[i]: i!
inv = [0]*MAX #inv[i]: iの逆元
finv = [0]*MAX #finv[i]: i!の逆元
fact[0] = 1
fact[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1
    
for i in range(2, MAX):
    fact[i] = fact[i-1]*i%MOD
    inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
    finv[i] = finv[i-1]*inv[i]%MOD

def C(n, r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD

N, M = map(int, input().split())
ans = (C(M, N)*fact[N])**2%MOD

for i in range(1, N+1):
    if i%2==0:
        ans += C(N, i)*C(M, i)*fact[i]*(C(M-i, N-i)*fact[N-i])**2
    else:
        ans -= C(N, i)*C(M, i)*fact[i]*(C(M-i, N-i)*fact[N-i])**2
    
    ans %= MOD

print(ans)

Measured memory_bytes: 107740
#include <bits/stdc++.h>
using namespace std;
bool is_ok(vector<vector<int>> A){
  for(int i=0;i<3;i++){
  	if(A.at(i).at(0)==0&&A.at(i).at(1)==0&&A.at(i).at(2)==0){
    	return true;
  	}
  }
  for(int i=0;i<3;i++){
  	if(A.at(0).at(i)==0&&A.at(1).at(i)==0&&A.at(2).at(i)==0){
    	return true;
  	}
  }
   if(A.at(0).at(0)==0&&A.at(1).at(1)==0&&A.at(2).at(2)==0){
     return true;
   }
    if(A.at(2).at(0)==0&&A.at(1).at(1)==0&&A.at(0).at(2)==0){
     return true;
   }
  return false;      
}
    
    
int main() {
 vector<vector<int>> A(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
     cin>>A.at(i).at(j);
    }
  }
 int N;
 cin>>N;
 vector<int> B(N);
  for(int i=0;i<N ;i++){
    cin>>B.at(i);
  }
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<N;k++){
        if(A.at(i).at(j)==B.at(k)){
          A.at(i).at(j)=0;
        }
      }
    }
  }
 bool x=is_ok(A);  
   if(x){
     cout<<"Yes"<<endl;
   }
   else{
     cout<<"No"<<endl;
   }
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split(' ')))

count = 0
for i in range(n-2):
	for j in range(i+1, n-1):
		for k in range(j+1, n):
			a = l[i]
			b = l[j]
			c = l[k]
			if (a+b>c) and (abs(a-b)<c) and (a!=b) and (b!=c) and (c!=a):
				count += 1
print(count)

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

const ll INF = 1LL<<60;
vector<ll> dijkstra(int n, int s, vector<vector<pair<ll,ll>>> G) {
  priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>> > que;
  vector<ll> d(n,INF);
  d[s] = 0;
  que.push(P(0,s));
  while(!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < G[v].size(); ++i) {
      int to = G[v][i].first;
      ll cost = G[v][i].second;
      if (d[to] > d[v] + cost) {
        d[to] = p.first + cost;
        que.push(P(d[to], to));
      }
    }
  }
  return d;
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  s--; t--;
  vector<vector<P> > enG(n), suG(n);
  rep(i,m) {
    int u, v;
    ll a, b;
    cin >> u >> v >> a >> b;
    u--; v--;
    enG[u].push_back(P(v,a));
    enG[v].push_back(P(u,a));
    suG[u].push_back(P(v,b));
    suG[v].push_back(P(u,b));
  }
  vector<ll> endist = dijkstra(n, s, enG);
  vector<ll> sudist = dijkstra(n, t, suG);
  priority_queue<P, vector<P>, greater<P>> que;
  for (int exch = 0; exch < n; ++exch) {
    ll cost = endist[exch] + sudist[exch];
    que.push(P(cost,exch));
  }
  rep(year,n) {
    ll ans;
    P p;
    while (true) {
      p = que.top();
      if (p.second+1 <= year) {
        que.pop(); continue;
      }
      else break;
    }
    ans = 1000000000000000 - p.first;
    cout << ans << "\n";
  }
  return 0;
}

Measured memory_bytes: 26684
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int count = 0;
    double per = 0;
    for (int i = 1;i <= N;i++) {
      if (i % 2 == 1) {
        count += 1;
      }
    }
    per = (double)count / N;
    System.out.println(per);
  }
}


Measured memory_bytes: 23252
#include <iostream>
using std::string;
using std::cin;
using std::cout;
using std::endl;

int main(void){
  std::string str;
  int n;
  cin >> str >> n;
  std::string meirei;
  int a,b;
  std::string tmp;
  std::string rep;
  for(int i = 0; i < n ;i++){
    cin >> meirei >> a >> b;
    if(meirei == "print"){
      for(int j = a;j <= b;j++){
        cout << str[j];
      }
      cout << endl;
    }else if(meirei == "reverse"){
      for(int j = 0;j <= (b-a)/2;j++){
        tmp[0] = str[a+j];
        str[a+j] = str[b-j];
        str[b-j] = tmp[0];
      }
    }else if(meirei == "replace"){
      cin >> rep;
      for(int j = a;j <= b;j++){
        str[j] = rep[j-a];
      }
    }
  }
}

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

template <int mod = (int)(1e9 + 7)>
struct ModInt {
  int x;
  constexpr ModInt() : x(0) {}
  constexpr ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  constexpr ModInt &operator+=(const ModInt &p) noexcept {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt &p) noexcept {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt &p) noexcept {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  constexpr ModInt &operator/=(const ModInt &p) noexcept {
    *this *= p.inverse();
    return *this;
  }
  constexpr ModInt operator-() const { return ModInt(-x); }
  constexpr ModInt operator+(const ModInt &p) const noexcept {
    return ModInt(*this) += p;
  }
  constexpr ModInt operator-(const ModInt &p) const noexcept {
    return ModInt(*this) -= p;
  }
  constexpr ModInt operator*(const ModInt &p) const noexcept {
    return ModInt(*this) *= p;
  }
  constexpr ModInt operator/(const ModInt &p) const noexcept {
    return ModInt(*this) /= p;
  }
  constexpr bool operator==(const ModInt &p) const noexcept { return x == p.x; }
  constexpr bool operator!=(const ModInt &p) const noexcept { return x != p.x; }
  constexpr ModInt inverse() const noexcept {
    int a = x, b = mod, u = 1, v = 0, t = 0;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  constexpr ModInt pow(int64_t n) const {
    ModInt res(1), mul(x);
    while (n) {
      if (n & 1) res *= mul;
      mul *= mul;
      n >>= 1;
    }
    return res;
  }
  friend constexpr ostream &operator<<(ostream &os, const ModInt &p) noexcept {
    return os << p.x;
  }
  friend constexpr istream &operator>>(istream &is, ModInt &a) noexcept {
    int64_t t = 0;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  constexpr int get_mod() { return mod; }
};

int n, len;
string s;

ModInt<> solve();

int main() {
  cin >> n >> s;
  len = s.size();
  cout << solve() << endl;
  return 0;
}

ModInt<> solve() {
  vector<vector<ModInt<>>> dp(n + 1, vector<ModInt<>>(n + 1, 0));
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j <= n; ++j) {
      // 1 or 0
      if (j != 0) dp[i + 1][j] += dp[i][j - 1] * 2;
      // del
      if (j != n) dp[i + 1][j] += dp[i][j + 1];
      if (j == 0) dp[i + 1][j] += dp[i][j];
    }
  return dp[n][len] / ModInt<>(2).pow(len);
}

Measured memory_bytes: 101128
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

// ^= -> ビットごとの排他的論理和を計算する




signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, a, b; cin >> n >> a >> b;
	if (abs(a - b) % 2 == 0) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Borys" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

H, W, K = mapint()
cake = [list(str(input())) for _ in range(H)]
ans = [['0']*W for _ in range(H)]
cnt = 0
unchecked_row = [0]*H
for h in range(H):
    row = cake[h]
    if '#' in row:
        cnt += 1
        first = 1
        for i, r in enumerate(row):
            if r=='.':
                ans[h][i] = str(cnt)
            else:
                if first:
                    first=0
                    ans[h][i] = str(cnt)
                    continue
                cnt += 1
                ans[h][i] = str(cnt)
    else:
        unchecked_row[h] = 1
for i, unchecked in enumerate(unchecked_row):
    if unchecked:
        for j in range(1, H):
            if i-j>=0 and not unchecked_row[i-j]:
                ans[i] = ans[i-j][:]
                unchecked_row[i] = 0
                break
            elif i+j<=H and not unchecked_row[i+j]:
                ans[i] = ans[i+j][:]
                unchecked_row[i] = 0
                break
for h in range(H):
    print(' '.join(ans[h]))

Measured memory_bytes: 48112
#include<iostream>
#include<algorithm>
#include<iomanip>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

int main(){
    int N;
    int i;
    double a;
    double sum;

    cin >> N;
    for(i=0;i<N;i++){
        cin >> a;
        sum += 1 / a;
    }
    cout << setprecision(10) << 1 / sum << endl;
    return 0;
}


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

int main(){
    
    int n;
    std::cin >> n;
    
    const int N = n;
    int Array[N];
    
    for(int i = 0; i < N; i++){
        std::cin >> Array[i];
    }
    
    for(int i = 1; i < N; i++){
        
        for(int k = 0; k < N; k++){
            std::cout << Array[k];
            if(k == N -1 ){
                std::cout << "\n";
            } else {std::cout << " ";}
        }
        
        int key = Array[i];
        int j = i - 1;
        while( (j >= 0) && (Array[j] > key) ){
            Array[j + 1] = Array[j];
            j--;
        }
        Array[j + 1] = key;
    }
    for(int k = 0; k < N; k++){
        std::cout << Array[k];
        if(k == N -1 ){
            std::cout << "\n";
        } else {std::cout << " ";}
    }
    
    return 0;
}


Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		String n = kb.next();
		if (n.contains("7")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		kb.close();
	}

}


Measured memory_bytes: 35652
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

int calc(int x)
{
    if (x == 1)
        return 1;
    return 2 * calc(x / 2) + 1;
}

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

    int n;
    cin >> n;
    cout << calc(n) << endl;
}


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

int a[200010];

int main() {
	int N, K;
	cin >> N >> K;
	for(int i=0; i<N; ++i) cin >> a[i];
	for(int i=K; i<N; ++i){
		if(a[i]>a[i-K]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using Matrix = vector<vector<ll>>;

inline ll ceil_ll(ll x, ll y) { return (x + y - 1) / y; }

Matrix mulMatrix(const Matrix &A, const Matrix &B, const ll MOD) {
    Matrix C(3, vector<ll>(3));
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                (C[i][j] += (A[i][k] * B[k][j]) % MOD) %= MOD;
            }
        }
    }
    return C;
}

Matrix powMatrix(Matrix A, ll e, const ll MOD) {
    vector<vector<ll>> X(3, vector<ll>(3));
    X[0][0] = X[1][1] = X[2][2] = 1;

    for ( ; 0 < e; e >>= 1) {
        if (e & 1) X = mulMatrix(X, A, MOD);
        A = mulMatrix(A, A, MOD);
    }
    return X;
}

ll fast_pow10(ull e, const ull MOD) {
    ull a = 10, x = 1;
    for ( ; 0 < e; e >>= 1) {
        if (e & 1) (x *= a) %= MOD;
        (a *= a) %= MOD;
    }
    return x;
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    constexpr int DIGITS = 19;
    vector<ll> pow10(DIGITS);
    pow10[0] = 1;
    for (int i = 1; i < DIGITS; ++i)
        pow10[i] = 10 * pow10[i - 1];


    ll L, A, B, M;
    cin >> L >> A >> B >> M;

    vector<ll> begin(DIGITS), num(DIGITS);
    for (ll d = 1; d < DIGITS; ++d) {
        begin[d] = max(0ll, ceil_ll(pow10[d - 1] - A, B));
        const ll end = min((pow10[d] - A - 1) / B, L - 1);

        const ll s_l = A + B * begin[d], s_r = A + B * end;
        if (pow10[d - 1] <= s_l && s_r < pow10[d] && begin[d] <= end)
            num[d] = end - begin[d] + 1;
    }

    ll ans = 0;
    for (ll d = 1; d < DIGITS; ++d) {
        if (num[d] == 0) continue;

        Matrix X(3, vector<ll>(3));
        X[0][0] = pow10[d] % M; X[0][1] = 1;
        X[1][1] = 1; X[1][2] = B % M;
        X[2][2] = 1;

        X = powMatrix(X, num[d], M);

        const ll s0 = (A + B * begin[d]) % M;
        const ll s = ((X[0][1] * s0) % M + X[0][2]) % M;

        (ans *= fast_pow10((ull)d * num[d], M)) %= M;
        (ans += s) %= M;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int N;
	cin>>N;
	int mini=10000000;
	fx(N){
		ll n;
		cin>>n;
		int count=0;
		while(n%2==0){
			n/=2;
			count++;
		}
		mini=min(mini,count);
	}
	ce(mini)
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e18
#define eps (1e-8)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int main()
{
  int n,count=0;
  string s,ans="YES";

  cin>>n;
  FOR(i,0,n){
    cin>>s;
    if(s=="A")count++;
    else {
      count--;
      if(count<0)ans="NO";
    }
  }
  if(count!=0)ans="NO";
  cout<<ans<<endl;
  return 0;
}

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

int main(){
    int a,b;
    string s,t,u;
    cin >> s >>t>>a>>b>>u;
    if (s==u){
        cout << a-1 << " " << b;
    }else{
        cout << a<< " " << b-1;
    }
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int MOD = 1e9+7;
const int N = 5*1e5;

struct mi {
	ll v; explicit operator ll() const { return v; }
	mi() { v = 0; }
	mi(ll _v) { 
		v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
		if (v < 0) v += MOD;
	}
	friend bool operator==(const mi& a, const mi& b) { 
		return a.v == b.v; }
	friend bool operator!=(const mi& a, const mi& b) { 
		return !(a == b); }
	friend bool operator<(const mi& a, const mi& b) { 
		return a.v < b.v; }
   
	mi& operator+=(const mi& m) { 
		if ((v += m.v) >= MOD) v -= MOD; 
		return *this; }
	mi& operator-=(const mi& m) { 
		if ((v -= m.v) < 0) v += MOD; 
		return *this; }
	mi& operator*=(const mi& m) { 
		v = v*m.v%MOD; return *this; }
	mi& operator/=(const mi& m) { return (*this) *= inv(m); }
	friend mi pow(mi a, ll p) {
		mi ans = 1; assert(p >= 0);
		for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	friend mi inv(const mi& a) { assert(a.v != 0); 
		return pow(a,MOD-2); }
		
	mi operator-() const { return mi(-v); }
	mi& operator++() { return *this += 1; }
	mi& operator--() { return *this -= 1; }
    mi operator++(int) { mi temp; temp.v = v++; return temp; }
    mi operator--(int) { mi temp; temp.v = v--; return temp; }
	friend mi operator+(mi a, const mi& b) { return a += b; }
	friend mi operator-(mi a, const mi& b) { return a -= b; }
	friend mi operator*(mi a, const mi& b) { return a *= b; }
	friend mi operator/(mi a, const mi& b) { return a /= b; }
    friend ostream& operator<<(ostream& os, const mi& m) {
        os << m.v; return os;
    }
    friend istream& operator>>(istream& is, mi& m) {
        ll x; is >> x;
        m.v = x;
        return is;
    }
};

int n, m;
mi fac[N+5];
mi facInv[N+5];

void initFac(){
    fac[0] = 1;
    facInv[0] = 1;
    for(int i=1; i<=m; i++){
        fac[i] = fac[i-1]*i;
        facInv[i] = inv(fac[i]);
    }
}

mi choose(int n, int k){
    if(k<0) return 0;
    if(n<0) return 0;
    if(k>n) return 0;

    mi res = fac[n]*facInv[n-k]*facInv[k];
    return res;
}


int main(){
    AC
    cin>>n>>m;
    initFac();
    mi res = 0;
    mi cur = 1;
    for(int k=0; k<=n; k++){
        res+=cur*choose(n, k)*choose(m-k, n-k)*fac[n-k];
        cur = -cur;
    }

    cout<<res*choose(m,n)*fac[n]<<endl;
}

Measured memory_bytes: 11428
x,y = map(int,input().split())
if x == y :
    ans = 0
elif (x+y) == 0 :
    ans = 1
elif x < y :
    if x*y >= 0 :
        ans = y-x
    else :
        if -x < y :
            ans = (y+x)+1
        else :
            ans = -(y+x)+1
else :
    if x*y > 0 :
        ans = x-y+2
    else :
        if -x > y :
            ans = -(y+x)+1
        else :
            ans = (y+x)+1
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<ext/pb_ds/priority_queue.hpp>
using namespace std;
#define MAXN 100000+10
const int INF=99999999;
struct Ed{
    int u,dis;
    Ed(){}
    Ed(int u,int dis):u(u),dis(dis){}
    bool operator >(const Ed &a)const{return dis>a.dis;}
};
typedef __gnu_pbds::priority_queue<Ed,greater<Ed>,__gnu_pbds::thin_heap_tag> heap;
heap q;
heap::point_iterator it[MAXN];
int k,vis[MAXN],dis[MAXN];
void dijkstra(){
    for(int i=0;i<k;i++)dis[i]=INF;    
    dis[1]=0;
    for(int i=0;i<k;i++)it[i]=q.push((Ed){i,dis[i]});
    while(!q.empty()){
        int t,u=q.top().u;
        q.pop();
        if(vis[u])continue;
        vis[u]=1;
        t=u*10%k;
        if(!vis[t]&&dis[u]<dis[t]){
            dis[t]=dis[u];
            q.modify(it[t],(Ed){t,dis[t]});
        }
        t=(u+1)%k;
        if(!vis[t]&&dis[u]+1<dis[t]){
            dis[t]=dis[u]+1;
            q.modify(it[t],(Ed){t,dis[t]});
        }
    }
}
int main(){
    scanf("%d",&k);
    dijkstra();
    printf("%d\n",dis[0]+1);
    return 0;
}

Measured memory_bytes: 6528
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int x[252521];
int ne[252521][20],rne[252521][20];
int dp[(1<<20)+10],rdp[(1<<20)+10];
vector<int> v;
int main()
{
	int n,V;
	cin>>n>>V;
	rep(i,n) cin>>x[i];
	while(V>0){
		v.pb(V);V/=2;
	}
	v.pb(0);int m=v.size();
	rep(i,n) rep(j,m){
		rne[i][j]=i;
		if(i>0 && x[i]-x[i-1]<=v[j]) rne[i][j]=rne[i-1][j];
	}
	for(int i=n-1;i>=0;i--) rep(j,m){
		ne[i][j]=i;
		if(i<n-1 && x[i+1]-x[i]<=v[j]) ne[i][j]=ne[i+1][j];
	}
	memset(dp,0,sizeof(dp));
	rep(i,(1<<20)+5) rdp[i]=n-1;
	rep(i,(1<<m)) rep(j,m){
		if((i&(1<<j))>0) continue;
		dp[i+(1<<j)]=max(dp[i+(1<<j)],ne[dp[i]][j]+1);
		rdp[i+(1<<j)]=min(rdp[i+(1<<j)],rne[rdp[i]][j]-1);
	}
	//rep(i,(1<<m)) cout<<i<<' '<<dp[i]<<' '<<rdp[i]<<endl;
	if(rdp[(1<<m)-1]>=0){
		//assert(dp[(1<<m)-1]<n && rdp[(1<<m)-1]>=0);
		rep(i,n) cout<<"Impossible"<<endl;
		return 0;
	}
	int now=0;
	while(now<n){
		int f=0;
		rep(i,(1<<(m-1))){
			if(dp[(1<<m)-2-(i<<1)]>=now && rdp[(i<<1)]<=ne[now][0]) f=1;
		}
		REP(i,now,ne[now][0]+1){
			if(f>0) cout<<"Possible"<<endl;
			else cout<<"Impossible"<<endl;
		}
		now=ne[now][0]+1;
	}
}


Measured memory_bytes: 46208
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int N;
int A[500010];
int sum[500010] = {};
vector<vector<int>> v(1<<20);
ll inf = 1e9+7;

int main(){
    cin >> N;
    int a = 0;
    for(int i=0;i<(1<<20);i++) v[i].push_back(0);
    for(int i=1;i<=N;i++){
        cin >> A[i];
        a ^= A[i];
        v[a].push_back(i);
        if(!a) sum[i]++;
        sum[i] += sum[i-1];
    }
    ll ans = 0;
    for(int i=1;i<(1<<20);i++){
        int n = v[i].size();
        if(n==1) continue;
        ll dp[n][2] = {};
        dp[0][0] = 1;
        for(int j=1;j<v[i].size();j++){
            ll c = sum[v[i][j]]-sum[max(v[i][j-1]-1,0)];
            if(j==1) c = 0;
            dp[j][0] = dp[j-1][1]*c%inf;
            (dp[j][0] += dp[j-1][0])%=inf;
            dp[j][1] = (dp[j-1][0]+c*dp[j-1][1])%inf;
            (dp[j][1] += dp[j-1][1])%=inf;
        }
/*        cerr << i << endl;
        for(int j=0;j<n;j++){
            cerr << dp[j][0] << " ";
        }
        cerr << endl;
        for(int j=0;j<n;j++){
            cerr << dp[j][1] << " ";
        }
        cerr << endl;
*/        if(a!=0 && i==a) (ans += (dp[n-1][1]-dp[n-2][1]+inf))%=inf;
        else if(a==0){
            (ans += dp[n-1][1])%=inf;
        }
    }
    if(a==0){
        ll res = 1;
        for(int i=0;i<sum[N]-1;i++) (res *= 2)%=inf;
        (ans += res)%=inf;
    }
    cout << ans << endl;
}

Measured memory_bytes: 67560
#include<stdio.h>
#define MAX_HEAP_SIZE 250
int heap[MAX_HEAP_SIZE + 1];

int hsize = 0;

int parent(int id);

int left(int id);

int right(int id);

int main(){
  int n;

  scanf("%d", &n);
  for(int i = 1; i <= n; i++){
    scanf("%d", &heap[i]);
    hsize++;
  }

  for(int i = 1; i <= n; i++){
    printf("node %d: key = %d, ", i, heap[i]);
    if(parent(i) > 0){
      printf("parent key = %d, ", heap[parent(i)]);
    }
    if(left(i) <= hsize){
      printf("left key = %d, ", heap[left(i)]);
    }
    if(right(i) <= hsize){
      printf("right key = %d, ", heap[right(i)]);
    }
    printf("\n");
  }
  return 0;
}

int parent(int id){

  return id/2;
}

int left(int id){
  return 2*id;
}

int right(int id){
  return 2*id + 1;
}



Measured memory_bytes: 2040
#include <stdio.h>
int main(void){
    int i,n,cnt,k[1001]={},a[1001]={},b[1001]={},c[1001]={},t[1001]={};
    int p,q,r,s;
    
    while(1){
        scanf("%d",&n);
        if(n==0){
            break;
        }
        
        cnt=0;
        for(i=1;i<=n;i++){
            scanf("%d %d %d %d",&k[i],&a[i],&b[i],&c[i]);
            t[i]=4*a[i]+9*b[i]+4*c[i];
           // printf("%d\n",t[i]);
        }
        scanf("%d %d %d %d",&p,&q,&r,&s);
        
        for(i=1;i<=n;i++){
            if((p>=a[i] && q>=b[i])&&(r>=c[i] && s>=t[i])){
                printf("%d\n",k[i]);
                cnt++;
            }
        }
        if(cnt==0)puts("NA");
    }
    
    return 0;
}

Measured memory_bytes: 632
import sys

x = sys.stdin.readline()
x = x.split(' ')
(n,k)=[int(str) for str in x]

h = sys.stdin.readline()
h = h.split(' ')
h = [int(str) for str in h]
h = sorted(h,reverse=True)

sum = 0
for i in range(k,n):
  sum += h[i]

print(sum)

sys.stdout.flush()


Measured memory_bytes: 26032
import sys
import math
input = sys.stdin.buffer.readline
def int_array():
	return list(map(int, input().strip().split()))
def str_array():
	return input().strip().split()
 
######################## TEMPLATE ENDS HERE ########################

d, n = int_array()
days = d-sum(int_array())
if days >= 0:
	print(days)
else:
	print(-1)

Measured memory_bytes: 68240