akhauriyash/Code-Regression huggingface dataset:
#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;
    cin >> n;
    map<string,int> mp;
    rep(i,n){
        string s;
        cin >> s;
        mp[s]++;
    }
    int mx = 0;
    for(auto p: mp) mx = max(mx, p.second);
    for(auto p:mp){
        if(p.second != mx)continue;
        else cout << p.first << endl;
    }
    return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;

  int d;
  d = c - (a -b);

  if (d >= 0) {
    cout << d << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

string query(int k){
    cout << k << endl;
    string s;
    cin >> s;
    if(s == "Vacant"){
        exit(0);
    }
    return s;
}

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

    int n;
    cin >> n;

    string l = query(0);

    int left = 0, right = n;
    while(right - left > 1){
        int mid = (left + right) / 2;
        if((query(mid) == l) ^ (mid % 2 == 0)){
            right = mid;
        }else{
            left = mid;
        }
    }

    return 0;
}

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

int main()
{
  ll S;
  scanf("%lld",&S);

  ll x1=0, x2=0, x3=0;
  ll y1=0, y2=0, y3=0;

  ll n = 1;
  while (n*n<S) {
    n++;
  }
  x2 = n; y3 = n;
  ll t = n*n-S;
  if (t%n==0) {
    x2 = n-t/n;
  } else {
    x2 = n-t/n;
    y2 = 1;
    x3 = n*x2-S;
  }

  printf("%lld %lld %lld %lld %lld %lld\n",x1,y1,x2,y2,x3,y3);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
 int N,M;
 long long K;
 std::cin>>N>>M>>K;

 long long* A=new long long[N];
 long long* B=new long long[M];
 for(int i=0;i<N;i++){
  std::cin>>A[i];
 }
 for(int i=0;i<M;i++){
  std::cin>>B[i];
 }

 int pt=0;
 long long sumb=0;
 for(pt=0;pt<M;pt++){
  sumb+=B[pt];
  if(sumb>K){
    sumb-=B[pt];
    break;
  }
 }
 
 long long suma=0;
 int ans=pt;
 int tmp;
 for(int i=0;i<N;i++){
  suma+=A[i];
  if(suma>K){
   break;
  }
  while(K-suma<sumb && pt>0){
   pt--;
   sumb-=B[pt];
  }
  tmp=i+1+pt;
  if(tmp>ans){
    ans=tmp;
  }
 }
 
 std::cout<<ans<<std::endl;
 
}

Measured memory_bytes: 6692
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();
    int a = sc.nextInt();
    int ans = 10;

    if(x < a){
      ans = 0;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long i,j,k,x,y,z,a,b,n,d;
    cin>>n>>d;
    d=d*d;
    z=0;
    for (i=0;i<n;i++)
    {
    	cin>>a>>b;
    	y=a*a+b*b;
    	if (y<=d)
    	{
    		z++;
		}
	}
	cout<<z<<endl;
}

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

int main(){
  int N, i;
  string s;
  
  std::unordered_map<string, int> mp;
  std::vector<string> vec;
  int max = 0;
  
  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> s;
    if (mp[s]) {
      mp[s] = mp[s] + 1;
    } else {
      mp[s] = 1;
    }
    
    if (max == mp[s]) {
      vec.push_back(s);
    } else if (max < mp[s]) {
      vec.clear();
      vec.push_back(s);
      max = mp[s];
    }
  }
  std::sort(vec.begin(),vec.end());//昇順ソート
  
  for (i = 0; i < vec.size(); i++) {
    cout << vec.at(i) << endl;
  }
  return 0;
}

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

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))

using namespace std;
using LL=long long;

static const int MAX=100000;

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;

void dfs(int u){
    V[u]=true;
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i];
        if(!V[v]) dfs(v);
    }
    out.push_front(u);
}

int main(){
    int s,t,M;
    cin>>N>>M;
    for(int i=0;i<N;i++) V[i]=false;
    for(int i=0;i<M;i++){
        cin>>s>>t;
        G[s].push_back(t);
    }
    for(int i=0;i<N;i++){
        if(!V[i]) dfs(i);
    }
    for(list<int>::iterator it=out.begin();it!=out.end();it++) cout<<*it<<endl;
    return 0;
}



Measured memory_bytes: 6212
def main():
  n=int(input())
  s=list(input())
  q_=int(input())
  q=[input().split() for _ in range(q_)]
  class BIT:
    def __init__(self, n):
      self.n = n
      self.data = [0]*(n+1)
      self.el = [0]*(n+1)
    def sum(self, i):
      s = 0
      while i > 0:
        s += self.data[i]
        i -= i & -i
      return s
    def add(self, i, x):
      # assert i > 0
      self.el[i] += x
      while i <= self.n:
        self.data[i] += x
        i += i & -i
    def get(self, i, j=None):
      if j is None:
        return self.el[i]
      return self.sum(j) - self.sum(i)

  a2n = lambda c: ord(c) - ord('a')
  d=[BIT(n) for _ in range(26)]
  di=[0]*26
  for i in range(1,n+1):
    d[a2n(s[i-1])].add(i,1)
  for qi in q:
    if qi[0]=='1':
      i=int(qi[1])
      c=a2n(qi[2])
      si=a2n(s[i-1])
      d[c].add(i,1)
      d[si].add(i,-1)
      s[i-1]=qi[2]
    else:
      ans=0
      l,r=int(qi[1]),int(qi[2])
      for i in range(26):
        ls=d[i].sum(l-1)
        rs=d[i].sum(r)
        ans+=1 if rs-ls>0 else 0
      print(ans)
if __name__=='__main__':
  #import datetime
  #print(datetime.datetime.now())
  main()
  #print(datetime.datetime.now())


Measured memory_bytes: 271940
//ios::sync_with_stdio(false);
#include<bits/stdc++.h>
#define LL long long
#define F(x,y,z) for(int x=y;x<=z;++x)
#define D(x,y,z) for(int x=y;x>=z;--x)
#define ckmax(a,b) (a)=max(a,b)
#define ckmin(a,b) (a)=min(a,b)
using namespace std;
const int N=1010;
LL R(){
    LL ans=0,f=1;char c=getchar();
    for(;c<'0'||c>'9';c=getchar()) if (c=='-') f=-1;
    for(;c>='0'&&c<='9';c=getchar()) ans=ans*10+c-'0';
    return ans*f;
}
LL n,fg[2],tp;
LL a[N],b[N],p[N];
char an[N];
void Work(LL x,LL y){
	F(i,1,tp){
		if(abs(x)>abs(y)){
			if(x>0){
				an[i]='R';
				x-=p[i];
			}
			else{
				an[i]='L';
				x+=p[i];
			}
		}
		else{
			if(y>0){
				an[i]='U';
				y-=p[i];
			}
			else{
				an[i]='D';
				y+=p[i];
			}
		}
	}
	F(i,1,tp)cout<<an[i];
	cout<<'\n';
}
int main(){
	//freopen("1.in","r",stdin);freopen("1.out","w",stdout);
    n=R();
    F(i,1,n){
    	a[i]=R(),b[i]=R();
    	fg[(a[i]+b[i])&1]=1;
	}
	if(fg[0]&&fg[1]){cout<<-1;return 0;}
	F(i,0,30)p[31-i]=(1<<i);
	tp=31;
	if(fg[0])p[++tp]=1;
	cout<<tp<<'\n';
	F(i,1,tp)cout<<p[i]<<' ';
	cout<<'\n';
	F(i,1,n)Work(a[i],b[i]);
	return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange

#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

void solve() {
    int x;
    cin >> x;
    cout << abs(x-1) << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3492
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
    m = a[i]
    while True:
        if m % 2 == 0:
            ans += 1
            m = m//2
        elif m % 2 == 1:
            break
print(ans)
             

Measured memory_bytes: 41840
#include <iostream>
using namespace std;
 
int main() {
    int x, y;
    cin >> x >> y;
    if ((x == 4)||(x == 6)||(x == 9)||(x == 11)){
      x = 0;
    } else if (x == 2){
      x = 2;
    } else {
      x = 1;
    }
    if ((y == 4)||(y == 6)||(y == 9)||(y == 11)){
      y = 0;
    } else if (y == 2){
      y = 2;
    } else {
      y = 1;
    }

    if (x == y){
       cout << "Yes" << endl;
    }else{
       cout << "No" << endl;
    }
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut k: u64,
        mut a: [usize; n],
    }
    for i in 0..n {
        a[i] = a[i] - 1;
    }

    let mut b = vec![0; n];
    for i in 0..n {
        b[i] = i;
    }
    for i in 0..63 {
        let t = 1 << i;
        if (k & t) != 0 {
            for j in 0..n {
                b[j] = a[b[j]];
            }
        }
        let mut tmp = vec![0; n];
        for j in 0..n {
            tmp[j] = a[a[j]];
        }
        a = tmp;

        // eprintln!("{:?}", a);
    }
    println!("{}", b[0] + 1);
}


Measured memory_bytes: 7956
using System;
using System.Collections.Generic;

namespace cswork
{

    class Program
    {
        public Program() { }

        Scanner cin;

        void Omame()
        {
            cin = new Scanner();
            long n = cin.nextLong();
            List<int> ii = new List<int>();
            for (int i = 0; i < n; i++)
            {
                ii.Add(cin.nextInt());
            }

            ii.Sort();
            ii.Reverse();

            long a = 0;
            long b = 0;
            for (int i = 0; i < n; i++)
            {
                if (i % 2 == 0)
                {
                    a += ii[i]; ;
                }
                else
                {
                    b += ii[i]; ;
                }
            }

            Console.WriteLine(a - b);
        }

        static void Main(string[] args)
        {
            new Program().Omame();
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();

            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next();
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }
    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w; cin>>h>>w;
	char field[51][51];
	rep(i, h)rep(j, w){
		cin >> field[i][j];
	}

	rep(i, h)rep(j, w){
		int cnt=0;
		if (field[i][j] == '#') continue;
		for(int k=max(0, i-1); k<=min(i+1, h-1); k++){
			for(int l=max(0, j-1); l<=min(j+1, w-1); l++){
				if (field[k][l] == '#') cnt++;
			}
		}
		field[i][j] = (char)(cnt+'0');
	}
	rep(i, h){
		rep(j, w) cout << field[i][j];
		cout << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, ans = 0;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 && i % 5)ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

data Calc = Init | Value Int | Func (Int -> Int)
getValue :: Calc -> Int
getValue (Value x) = x
capply :: Calc -> String -> Calc
capply Init num = Value (read num)
capply (Value x) "+" = Func (x+)
capply (Value x) "-" = Func (x-)
capply (Value x) "*" = Func (x*)
capply (Value x) "/" = Func (x`div`)
capply (Value x) "=" = Value x
capply (Func f) num = Value (f (read num))


main = lines <$> getContents >>= print . getValue . foldl capply Init


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

#define ll long long int

int main()
{
        ll n,a,b;
        cin>>n>>a>>b;
        if(a>b){
            cout<<"0";
            return 0;}
        else if(n==1 && a==b){
            cout<<"1";
            return 0;
            }
        else if(n==1 && a!=b)
        {
            cout<<"0";
            return 0;
        }
   
        cout<< (a + (n-1)*b ) - (a*(n-1) + b) + 1;
}


Measured memory_bytes: 256
(function(input) {
    var lines = input.split('\n');
    var n = Number(lines[0]);
    var items = lines[1].split(' ').map(Number);
    var min = Infinity, max = -Infinity, sum = 0;
    for (var i = 0; i < items.length; i++) {
        var a = items[i];
        if (a < min) {
            min = a;
        }
        if (a > max) {
            max = a;
        }
        sum += a;
    }
    console.log('%d %d %d', min, max, sum)
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

char s[105];

int main(){
    ll k;
    scanf("%s",s+1);
    scanf("%lld",&k);
    ll n=strlen(s+1); bool f=0,flag=0;
    ll ss=0,fi=0,now=1,res=0,ans=0;
    for(ll i=2;i<=n;i++){
        if(s[i]==s[i-1]) now++;
        else{
            if(!fi) fi=now;
            res+=now/2;
            now=1;
        }
    }
    res+=now/2;
    if(!fi) fi=now,flag=1;


    //cout<<fi<<" "<<now<<endl;
    if(!flag){
        if(s[1]==s[n]){
            res-=fi/2;
            res-=now/2;
            ans+=k*res;
            ans+=(fi+now)/2*(k-1);
            ans+=fi/2;
            ans+=now/2;
        }else{
            ans=res*k;
        }
    }else{
        ans+=k*n/2;
    }
    cout<<ans<<endl;

}
/*

acaaadsafayyyy
3

aaaba
3

aaa
5
*/


Measured memory_bytes: 256
from math import gcd

def solve(a,b,c,d):
  
    if a < b:
        return False
    if d < b:
        return False

    g = gcd(b,d)
    c += 1
    m = c + (a-c)%g
    return b <= m

T = int(input())
for _ in range(T):
    print('Yes' if solve(*map(int,input().split())) else 'No')

Measured memory_bytes: 66188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;

ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;
	cin >> n >> m;
	vector <bool> arr(n,true);
	for (int z=0;z<m;z++){
		ll temp;
		cin >> temp;
		arr[temp] = false;
	}
	vector <ll> dp(n+1	,0);
	dp[0] = 1;
	if (arr[1]) dp[1] = 1;
	for (int z=2;z<=n;z++){
		if (!arr[z]) continue;
		if (arr[z-1]){
			dp[z] += dp[z-1];
		}
		if (arr[z-2]){
			dp[z] += dp[z-2];
		}
		dp[z] %= mod;
	}
	cout << dp[n] << endl;
	cin >> n;
}


Measured memory_bytes: 1024
/*
By Snickeen
*/
#include<bits/stdc++.h>
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define MST(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector<int>
#define VL vector<LL>
#define VII vector<PII >
#define VLL vector<PLL >
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define FF first
#define SS second

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}
 
const LL MAXN=1e5+10;
LL t,n,m,ans;
LL MOD=1e9+7,inf=0x1f1f1f1f;
db eps=1e-5;

string s,s1,s2;
LL len;
string ss[4]={"dream","dreamer","erase","eraser"};

LL check(LL x){
	LL i,j,k,l;
	l=ss[x].size();
	s1="";
	for(i=s.size()-1,j=0;j<l&&i>=0;j++,i--){
		s1+=s[i];
	}
	reverse(all(s1));
//	cout<<l<<" "<<s1<<endl;
	repu(i,0,3){
		if(s1==ss[i])return 1;
	}
	return 0;
}

int main()
{
//	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,ca=0;
	cin>>s;
	len=l=s.size();
	//reverse(all(s));
	while(s.size()){
		k=0;
		repu(i,0,3){
			if(s.size()<ss[i].size())continue;
			if(check(i)){
				k=1;
				j=ss[i].size();
				s.erase(s.size()-j,j);
//				cout<<s.size()<<" "<<j<<" "<<s<<endl;
				break;
			}
		}
		if(k==0)return cout<<"NO"<<endl,0;
	}
	cout<<"YES"<<endl;
	return 0;
}

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

using namespace std;

int main(){
    int n, p;
    cin >> n;
    vector<int> P(n);
    for(int i = 0; i < n; ++i){
        cin >> P[i];
    }
    int ans = 0;
    for(int i = 0; i < n-2; ++i){
        // cout << i << endl;
        if((P[i] < P[i+1] && P[i+1] < P[i+2]) || (P[i] > P[i+1] && P[i+1] > P[i+2])){
            ++ans;
            // cout << i+1 << endl;
        }
    }
    cout << ans << endl;

    return 0;
}

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

int timeLimit = 1990;
/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
    //d = 365
    int D; cin >> D;
    int N = 26;
    D++; N++;
    
    //しばらく特定のタイプのコンテストが開催されないと、満足度が下がってしまいます
    int c[N]; rep(i,1,N) cin >> c[i]; 
    
    //d日目にiタイプのコンテスト開催　＝＞　満足度 += s[d][i]
    int s[D][N];
    rep(d,1,D) rep(i,1,N) cin >> s[d][i];

    // タイプ i のコンテストを開催した最後の日
    int last[N] = {};

    int ans[D];

    //満足度の合計
    ll satisfaction = 0;
    rep(d,1,D){
        ll tmpSatisfaction = -1e9;
        int tmpAns = 1;

        rep(i,1,N){
            ll minus = 0;
            rep(j,1,N){
                if(i != j) minus += c[j]*(d-last[j]);
            }
            if(satisfaction + s[d][i] - minus > tmpSatisfaction){
                tmpAns = i;
                tmpSatisfaction = satisfaction + s[d][i] - minus;
            }
        }
        satisfaction = tmpSatisfaction;
        last[tmpAns] = d;
        ans[d] = tmpAns;
    }
    
    //満足度が　sum 1.to 26 ci * (d-last[i]) 低下する
    // つまり、個々のタイプに対しての和、満足度の下がりやすさ×空いた日数
    // 満足度の下がりやすさのほうが重みが大きい

    /*
    while(1){
        end = chrono::system_clock::now();
        int time = static_cast<int>(chrono::duration_cast<chrono::microseconds>(end - start).count()/1000);
        if(time > timeLimit){
            break;
        }

        int tmpD = rand()%(D-1)+1;
        int tmpI = rand()%(N-1)+1;



    }
    */

    rep(d,1,D){
        cout << ans[d] << "\n";
    }
}


Measured memory_bytes: 3676
N,M = map(int,input().split())
py_list = []
d = dict()
for i in range(M):
    p,y = map(int,input().split())
    py_list.append([p,y])
py_sorted =  sorted(py_list)
p_temp = py_sorted[0][0]
count = 1
for p,y in py_sorted:
    if p_temp != p:
        p_temp = p
        count = 1
    d[(p,y)] = count
    count += 1

for i in range(M):
    s = d[(py_list[i][0],py_list[i][-1])]
    s = str(s)
    ss = str(py_list[i][0]).zfill(6) + s.zfill(6)
    print(ss.strip())



Measured memory_bytes: 38016
#include<bits/stdc++.h>
#define N 100100
using namespace std;
map<long long,long long,greater<long long> > num; 
long long a[N];
long long ans[N];
int main(){
	int n,q;
	long long mn;
	scanf("%d%d",&n,&q);
	a[0]=n;
	for(int i=1;i<=q;i++){
		scanf("%lld",&a[i]);
	}
	mn=a[q];
	num[a[q]]=1;
	for(int i=q-1;i>=0;i--){
		if(a[i]<mn){
			mn=a[i];
			for(auto it=num.begin();it!=num.end()&&it->first>a[i];it=num.erase(it)){
				num[a[i]]+=it->first/a[i]*it->second;
				if(it->first%a[i]) num[it->first%a[i]]+=it->second;
			}
		}
	}
	for(int i=n;i>=1;i--){
		ans[i]=ans[i+1]+num[i];
	}
	for(int i=1;i<=n;i++) printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 9472
#include <iostream>
#include <stdio.h>
#include <string>
#include <map>
#include <stack>
#include <vector>
#include <string.h>
#include <set>
#include <queue>
#include <cmath>
#include <algorithm>

using namespace std;

struct node
{
	int number;
	int dist;

	node(int number , int dist)
	{
		this -> number = number;
		this -> dist = dist;
	}
};

int input[2][4];
int res[100010];
int dx[4] = {- 1 , 0 , 1 , 0};
int dy[4] = {0 , 1 , 0 , - 1};
queue<node> q;

// ??¶???
int fact(int n)
{
	int ans = 1;
	for (int i = 1;i <= n;i ++)
		ans = ans * i;
	return ans;
}

// ????????¬?????°???
int toNumber()
{
	// ?????¬????????´??°???
	int temp[8];
	int i , j , next = 0 , number = 0;
	for (i = 0;i < 2;i ++)
		for (j = 0;j < 4;j ++)
		{
			temp[next] = input[i][j];
			next ++;
		}

	// ????????????
	for (i = 0;i < 8;i ++)
	{
		int tot = 0;
		for (j = i + 1;j < 8;j ++)
		{
			if (temp[j] < temp[i])
				tot ++;
		}
		number += tot * fact(8 - i - 1);
	}
	return number + 1;
}

// ??°?????¬???2 x 4?????°???
void toArray(int number)
{
	// ???????????????
	number --;

	int temp[8];
	bool vis[8];
	memset(vis , false , sizeof(vis));

	int next = 0;
	for (int i = 0;i < 8;i ++)
	{
		int f = fact(8 - i - 1) , count = 0 , v;
		int value = number / f;		// ?¬¬value??????
		number = number % f;
		for (int j = 0;j < 8;j ++)
		{
			if (!vis[j])
			{
				if (count == value)
				{
					v = j;
					vis[j] = true;
					break;
				}
				count ++;
			}
		}
		temp[i] = v;
	}
	// temp??¬???input
	for (int i = 0;i < 2;i ++)
		for (int j = 0;j < 4;j ++)
		{
			input[i][j] = temp[next];
			next ++;
		}
}

bool inArea(int x , int y)
{
	return x >= 0 && x < 2 && y >= 0 && y < 4;
}

// ??????bfs????´¢
void bfs()
{
	while (!q.empty())
		q.pop();

	// input??¬???number
	q.push(node(1 , 0));
	res[1] = 0;

	int count = 0;
	while (!q.empty())
	{
		node no = q.front();
		q.pop();

		toArray(no.number);

		for (int i = 0;i < 2;i ++)
			for (int j = 0;j < 4;j ++)
			{
				// ?????°0
				if (input[i][j] == 0)
				{
					for (int k = 0;k < 4;k ++)
					{
						int x1 = i , y1 = j , x2 = x1 + dx[k] , y2 = y1 + dy[k] , temp , number;
						// ????????¨?????´??????
						if (inArea(x2 , y2))
						{
							// ?????¢(x1,y1)???(x2,y2)??????
							temp = input[x1][y1];
							input[x1][y1] = input[x2][y2];
							input[x2][y2] = temp;

							number = toNumber();

							if (res[number] < 0)
							{
								res[number] = no.dist + 1;
								q.push(node(number , no.dist + 1));
							}

							temp = input[x1][y1];
							input[x1][y1] = input[x2][y2];
							input[x2][y2] = temp;
						}
					}
				}
			}
	}
}

int main()
{
	memset(res , - 1 , sizeof(res));
	bfs();
	int i , j;
	while (scanf("%d" , &input[0][0]) != EOF)
	{
		for (i = 1;i < 4;i ++)
			scanf("%d" , &input[0][i]);
		for (i = 0;i < 4;i ++)
			scanf("%d" , &input[1][i]);

		int number = toNumber();

		printf("%d\n" , res[number]);
	}
	return 0;
}

Measured memory_bytes: 1624
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(){

    int a,b,c,cont5=0,cont7=0;
    scanf("%d %d %d",&a,&b,&c);

    if(a==5)
        cont5++;
        if(b==5)
            cont5++;
            if(c==5)
                cont5++;
    if(a==7)
        cont7++;
        if(b==7)
            cont7++;
            if(c==7)
                cont7++;

    if(cont5==2 && cont7==1)
        printf("YES\n");
    else printf("NO\n");

    return 0;
}


Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	int N;
	cin >> N;
	string S;
	cin >> S;
	int Rcnt = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'R') Rcnt++;
	}
	int ans = 0;
	for (int i = 0; i < Rcnt; i++) {
		if (S[i] == 'W') {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int l = 1, cnt = 0;
vector<int> h(300);

void mizuyari(int l, int r) {
	if (l > r) return;
	for (int i = l; i <= r; i++) {
		h[i]--;
	}
	cnt++;
}


int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> h[i];

	while (true) {
		for (int i = 0; h[i] == 0; i++) l = i + 1;
		for (int i = 1; i <= n + 1; i++) {
			if (h[i] == 0) {
				mizuyari(l, i - 1);
				for (int j = i; h[j] == 0; j++) {
					l = j + 1;
				}
			}
		}

		for (int i = 1; i <= n; i++) {
			if (h[i] != 0) break;
			if (i == n && h[i] == 0) {
				cout << cnt << endl;
				return 0;
			}
		}
	}
	return 0;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

struct DisjointSet{
    vector<int> p;  // ノードの親を格納する１次元ベクトル
    // コンストラクタ
    DisjointSet(int n) : p(n){
        rep(i,n) p[i] = i;
    }

    int root(int x){
        if(p[x] == x) return x;
        return root(p[x]);
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        p[rx] = ry;
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int n, q; cin >> n >> q;
    DisjointSet dis = DisjointSet(n);
    rep(_,q){
        int com, x, y; cin >> com >> x >> y;
        if(com == 0){
            dis.unite(x, y);
        }else{
            if(dis.same(x, y)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  ll h,w,n;
  cin>>h>>w>>n;
  auto ceil = [](auto a,auto b){
    return (a-1)/b+1;
  };
  cout<<(min(ceil(n,h),ceil(n,w)))<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,a,b;
    string str[101];
    string s1,s2;
    cin>>a>>b;
    for(i=0;i<a;i++)
        cin>>str[i];
    for(i=0;i<a;i++)
    {
        for(j=i+1;j<a;j++)
        {
            if(str[i]>str[j])
            {
                s1=str[i];
                str[i]=str[j];
                str[j]=s1;
            }
        }
    }
    for(i=0;i<a;i++)
        s2=s2+str[i];
    cout<<s2<<endl;
    return 0;
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=105,mod=1000000007;
int n,m,ans,a[N],dp[N>>1][N][N];
int main(){
	m=read(); n=m*2-1;
	for(int i=1;i<=n;i++)a[i]=read();
	sort(&a[1],&a[n+1]); a[0]=a[1]; a[n+1]=a[n];
	dp[m][1][1]=1;
	for(int i=m;i;i--){
		int t=(a[i]!=a[i-1])+(a[m*2-i]!=a[m*2-i+1]),tt=(a[i]!=a[i-1]);
		for(int j=0;j<=n;j++){
			for(int k=1;k<=j;k++)if(dp[i][j][k]){
				//cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k]<<endl;
				for(int l=1;l<k;l++){
					dp[i-1][j-(k-l-1)+t][l+tt]=(dp[i-1][j-(k-l-1)+t][l+tt]+dp[i][j][k])%mod;
					//cout<<i<<" "<<j<<" "<<k<<" "<<l<<" "<<t<<endl;
				}
				dp[i-1][j+t][k+tt]=(dp[i-1][j+t][k+tt]+dp[i][j][k])%mod;
				for(int l=k+1;l<=j;l++){
					dp[i-1][j-(l-k-1)+t][k+tt+1]=(dp[i-1][j-(l-k-1)+t][k+tt+1]+dp[i][j][k])%mod;
				}
			}
		}
	}
	for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)ans=(ans+dp[0][i][j])%mod;
	cout<<ans<<endl;
}
/*
条件1.a[i]<=b[i]<=a[2n-i]
条件2.不存在i,j(i<j)，满足b[j]<b[i]<b[j+1]或b[j]>b[i]>b[j+1]
1 2 3 4 5 6 xi+1=5
*/

Measured memory_bytes: 1408
/* 1 6 0 8 10 0 0 0 */
/* 6 10 8 1 */

#include <stdio.h>
int main(void){
  int input;
  int cars[11] = {0};
  int stack = 0;
  while(scanf("%d",&input) != EOF)
    {
      if ( input == 0)
        {
          printf("%d\n",cars[stack-1]);
          stack--;
        }
      else
        {
          cars[stack] = input;
          stack++;
        }
    }
return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int d, t, s;
  cin >> d >> t >> s;
  d > t * s ? cout << "No" << '\n' : cout << "Yes" << '\n';
  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    int h,w;
  cin>>h>>w;
  char a[h][w];
  for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){
		cin>>a[i][j];
    }
  }
  char b[h][w];
  for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){
		if(a[i][j]=='#'){
          b[i][j]=a[i][j];
        }else{
          int count=0;
          if((i-1)>=0&&(j-1)>=0&&a[i-1][j-1]=='#'){
            count++;
          }
          if((i-1)>=0&&a[i-1][j]=='#'){
            count++;
          }
          if((i-1)>=0&&(j+1)<=(w-1)&&a[i-1][j+1]=='#'){
            count++;
          }
          if((j-1)>=0&&a[i][j-1]=='#'){
            count++;
          }
          if((j+1)<=(w-1)&&a[i][j+1]=='#'){
            count++;
          }
          if((i+1)<=(h-1)&&(j-1)>=0&&a[i+1][j-1]=='#'){
            count++;
          }
          if((i+1)<=(h-1)&&a[i+1][j]=='#'){
            count++;
          }
          if((i+1)<=(h-1)&&(j+1)<=(w-1)&&a[i+1][j+1]=='#'){
            count++;
          }
        b[i][j]='0'+count;
    }
  }
  }
  for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){
		cout<<b[i][j];
    }
    cout<<endl;
  }
    return 0;
}


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

using namespace std;

using int64 = long long;

bool IsPowerOfTwo(int x) {
  return x > 0 && (x & (x - 1)) == 0;
}

void PrintEdge(int v1, int v2) {
  cout << v1 << " " << v2 << endl;
}

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

  int n;
  cin >> n;
  if (IsPowerOfTwo(n)) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  PrintEdge(1, 2);
  PrintEdge(2, 3);
  PrintEdge(3, n + 1);
  PrintEdge(n + 1, n + 2);
  PrintEdge(n + 2, n + 3);
  for (int i = 4; i + 1 <= n; i += 2) {
    PrintEdge(1, i);
    PrintEdge(i, i + 1);
    PrintEdge(1, n + i + 1);
    PrintEdge(n + i + 1, n + i);
  }

  if (n % 2 == 0) {
    for (int i = 1; i <= n - 1; i++) {
      if ((n ^ 1 ^ i) < n) {
        int v1 = i;
        int v2 = n ^ i ^ 1;
        if (v1 == v2) continue;
        if (v1 % 2 == 1) v1 += n;
        if (v2 % 2 == 1) v2 += n;
        PrintEdge(n, v1);
        PrintEdge(v2, 2 * n);
        return 0;
      }
    }
  }
}


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

const ll MAXN = 200000;

ll N, K, c, ans=0;
string S;

signed main(){
    cin >> N >> K >> S;
    for(int i=1;i<N;i++) {
        if(S[i]!=S[i-1]) c++;
        else ans++;
    }
    if(2*K>=c) {
        ans += c;
    }
    else {
        ans += 2*K;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

/**
 * http://abc068.contest.atcoder.jp/tasks/abc068_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		sc.close();
		
		int[] candidates = {2,4,8,16,32,64};
		int ans = 1;
		for(int c:candidates){
			if(c<=N){
				ans = c;
			}
		}
		
		System.out.println(ans);
		
		
	}

}

Measured memory_bytes: 23764
X,Y = map(int,input().split())
b = (2*X -Y) / 3
if b != int(b):
    print(0)
    quit()
b = int(b)
a = X - 2 * b
if a < 0 or b < 0:
    print(0)
    quit()


def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


ans = combination(a+b,a)

print(ans)


Measured memory_bytes: 40900
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
	int n;
	cin>>n;
	int a[n];
	int mx=-1e9,mn=1e9;
	rep(i,n){
		cin>>a[i];
		mx=max(mx,a[i]);
		mn=min(mn,a[i]);
	}
	cout<<mx-mn;
}

int main(){
	Red;
	int t=1;
	// cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	int a,b,c;
	string s="NO";
	vector<int>vec;
	cin >> a >> b >> c;
	for(int i=1;i<b;i++){
		vec.push_back((a*i)%b);
	}
	for(int i=0;i<vec.size();i++){
		if(vec[i]==c)s="YES";
	}
	cout << s << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    agc017a()
}

fun agc017a() {
    val (n, p) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map { it.toInt() % 2 }
    //    val counts = mutableMapOf(0 to 0, 1 to 0)
    //    generatePattern(0, 0, a, counts)
    //    println(counts[p])
    var evenCount = 0
    var oddCount = 0
//    readLine()!!.split(" ")
//        .stream()
//        .map { it.toInt() % 2 }
//        .forEach {
//            if (it == 0) {
//                evenCount++
//            } else {
//                oddCount++
//            }
//        }
    oddCount = a.count { it == 1 }
    val ans = if (oddCount == 0) {
        if (p == 0) {
            Math.pow(2.0, n.toDouble()).toLong()
        } else {
            0
        }
    } else {
        Math.pow(2.0, n - 1.0).toLong()
    }
    println(ans)
}

// これでやると組み合わせが2^50で10＾15くらいの計算量になる
// したがってこれでは入力例4もクリアできない
private fun generatePattern(index: Int, total: Int, array: List<Int>,
    counts: MutableMap<Int, Int>) {
    if (index == array.size) {
        counts[total % 2] = counts[total % 2]!! + 1
        return
    }
    generatePattern(index + 1, total, array, counts)
    val current = array[index] + total
    generatePattern(index + 1, current, array, counts)
}

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

long gcf(long a,long b){
    if(b == 0) return a;
    return gcf(b,a%b);
}
long lcm(long a,long b){
    long g = gcf(a,b);
    return a/g*b;
}
int main(){
  int N; cin >> N;
  int ans = 0;
  for(int i = 0; i < N; i++){
      int a; cin >> a;
      ans += a-1;
  }
  
  cout << ans << endl;
}



Measured memory_bytes: 256
n,m,x = map(int,input().split())
pattern = []
for i in range(2**(n)):
    tmp = [0 for i in range(n)]
    for j in range(n):
        if i>>j & 1:
            tmp[j] = 1
    pattern.append(tmp)

ans = 10**9
Input= []
for i in range(n):
    tmp = [int(i) for i in input().split()]
    Input.append(tmp)
for i in pattern:
    score = [0 for j in range(m)]
    tmp_ans = 0
    Flag = True
    for j in range(len(i)):
        if i[j]==0:
            continue
        else:
            tmp_ans += Input[j][0]
            for k in range(m):
                score[k] += Input[j][k+1]
    for k in range(m):
        if score[k]<x:
            Flag = False
    if Flag == False:
        continue
    ans = min(ans,tmp_ans)
if ans==10**9:
    print(-1)
else:
    print(ans)


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  int card[10];
  int c[3];

  while(cin >> c[0] >> c[1] >> c[2]) {
    REP(i, 10) card[i] = i+1;
    REP(j, 3) card[c[j]-1] = 100;
   
    int p  = c[0]+c[1];
    int cnt = 0;
    REP(i, 10) {
      if(p+card[i] <= 20) cnt++;
    }
    
    if(cnt >= 4) cout << "YES" << endl;
    else cout << "NO" << endl;
  }    
}

Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int main()
{
    long long N, A, B;

    cin >> N >> A >> B;

    long long sum = A + B;

    long long ans;

    if (sum <= N)
    {
        ans = (N / sum) * A;
        N %= sum;
    }
    else
    {
        ans = N > A ? A : N;
        cout << ans << endl;
        return 0;
    }

    ans += N > A ? A : N;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
using namespace std;

const long long mod = 1e9+7;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int N, M;
  cin >> N >> M;
  vector<int> oks(N+1, true);
  for(int i = 0; i < M; i++) {
    int a;
    cin >> a;
    oks[a] = false;
  }

  vector<long long int> dp(N+1);
  dp[0]=1;
  for(int now=0; now<N; ++now) {
    for(int next=now+1; next<=min(N,now+2); ++next) {
      if(oks[next]) {
        dp[next] += dp[now];
        dp[next] %= mod;
      }
    }
  }

  cout << dp[N] << endl;

  return 0;
}


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

using namespace std;

using ll = int_fast64_t;
constexpr ll llmax = INT_FAST64_MAX; // std::numeric_limits<int_fast64_t>::max()
constexpr ll llmin = INT_FAST64_MIN; // std::numeric_limits<int_fast64_t>::min()
using ull = uint_fast64_t;
constexpr ull ullmax = UINT_FAST64_MAX; // std::numeric_limits<uint_fast64_t>::max()

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(L);
    vector<int> V; V.reserve(N);
    REP(i, N){
        V.emplace_back(L + i);
    }
    sort(V.begin(), V.end(), [](int l, int r){return abs(l) < abs(r);});
    // for (auto& v : V){
    //     cout << v << " ";
    // }
    // cout << endl;
    ll sum = 0;
    FOR(i, 1, N){
        sum += V[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
/*
                         ----------------------------
                              Ankur Kumar Singh    
                         ----------------------------
*/


#include <bits/stdc++.h>
using namespace std;
# define ll  long long  int
# define ld  long double
# define pb push_back
# define pp pop_back
# define ff first
# define ss second
# define mp make_pair
# define ac accumulate
# define mod 1000000007
# define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
# define trace1(x)                cerr << #x << ": " << x << "\n";
# define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
# define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << "\n";
# define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << "\n";

int  main()
{

   IOS;
   ll h;
   cin>>h;
   ll cnt=1,sum=0;
   while(h>0)
   {
      h=h/2;
      sum+=cnt;
      cnt=cnt*2;
   }
   cout<<sum;

}


Measured memory_bytes: 256