akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int a[55];
int main(){
	int n,i,sum=0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]!=i) sum++;
	}
	if(sum==2||sum==0) cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
PROGRAM ATCODER

implicit none
integer :: w,h,n,i,b_w,b_h
integer :: b_l=0, b_r=0, b_u=0, b_d=0 !それぞれ、黒色になる左、右、上、下側の長さ
integer,allocatable :: x(:),y(:),a(:)

read(*,*) w,h,n
allocate(x(n),y(n),a(n))

do i = 1, n
  read(*,*) x(i),y(i),a(i)
  if(a(i) == 1)then
    call chmax(b_l,x(i))
  else if(a(i) == 2)then
    call chmax(b_r,w-x(i))
  else if(a(i) == 3)then
    call chmax(b_u,y(i))
  else if(a(i) == 4)then
    call chmax(b_d,h-y(i))
  end if
end do

b_w = b_l+b_r ; b_h = b_u+b_d

if(b_w >= w .or. b_h >= h)then
  write(*,'(i0)') 0
  stop
end if

write(*,'(i0)') (w-b_w)*(h-b_h)

contains
!!!!!! サブルーチンは↓
subroutine chmax(dp,x)
implicit none
integer :: dp, x

if (dp < x) then
	dp = x
	return
end if

end subroutine
!!!!!!

END PROGRAM ATCODER

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
const int N=100010,M=16;
int s[N],cnt[M],ans,f[1000010];
void chkmin(int &x,int y)
{
	if(y<x)x=y;
}
int gi()
{
	int f=0; char ch=getchar();
	while(ch<'0' || ch>'9')ch=getchar();
	while(ch>='0' && ch<='9')f=f*10+ch-48,ch=getchar();
	return f;
}
int main()
{
	n=gi();
	int u,v,w;
	for(int i=1;i<n;i++)
		u=gi(),v=gi(),w=gi(),s[u]^=w,s[v]^=w;
	for(int i=0;i<n;i++)
		cnt[s[i]]++;
	int now=0;
	for(int i=1;i<16;i++)
		ans+=cnt[i]/2,now+=((cnt[i]&1)<<i-1);
	memset(f,127,sizeof(f)); f[now]=0;
	for(int i=(1<<15)-1;i;i--)
		if(f[i]<2000000000)
		{
			for(int j=1;j<=15;j++)
				if(i&(1<<j-1))
					for(int k=1;k<=15;k++)
						if(i&(1<<k-1) && j!=k)
						{
							int l=j^k;
							if(i&(1<<l-1))
								chkmin(f[i-(1<<j-1)-(1<<k-1)-(1<<l-1)],f[i]+2);
							else
								chkmin(f[i-(1<<j-1)-(1<<k-1)+(1<<l-1)],f[i]+1);
						}
		}
	printf("%d\n",f[0]+ans);
	return 0;
}


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

using namespace std;

int main()
{
  int n;
  cin>>n;
  if(!(n%2))
  {
    string s,s2,s3;
	cin>>s;
	s2=s.substr(0, s.length()/2);
	s3=s.substr(s.length()/2);
    if(s2==s3)
      cout<<"Yes";
    else
      cout<<"No";
    
  }
  else
  cout<<"No";
  return 0;
}

Measured memory_bytes: 256
n = int(input())
zm = -2e10
zn = 30000000000
wm = -2e10
wn = 30000000000
while(n):
  x,y = map(int,input().split())
  zm = max(zm,x+y)
  zn = min(zn,x+y)
  wm = max(wm,x-y)
  wn = min(wn,x-y)
  n-=1
  
print(max(zm-zn,wm-wn))


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

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

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

ll dp[200020][5][2];

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<ll> a(n);
	rep(i,n){
		cin>>a[i];
	}
	rep(i,n+1)rep(j,5)rep(k,2) dp[i][j][k]=-inf;
	dp[1][0][1]=a[0];
	dp[2][0][0]=a[1];
	dp[2][0][1]=a[1];
	dp[3][0][0]=a[2];
	FOR(i,1,n)rep(j,5)rep(k,2){
		if(dp[i][j][k]==-inf) continue;
		int now=i/2;
		if(k) now=(i+1)/2;
		FOR(l,2,5){
			int ind=i+l;
			int nk;
			if(ind/2==now+1) nk=0;
			else if((ind+1)/2==now+1) nk=1;
			else continue;
			if(ind<=n){
				chmax(dp[ind][l][nk],dp[i][j][k]+a[ind-1]);
				if(ind%2==0){
					chmax(dp[ind][l][!nk],dp[i][j][k]+a[ind-1]);
				}
			}
			//cout<<i<<' '<<ind<<' '<<nk<<' '<<dp[i][j][k]<<' '<<dp[ind][l][nk]<<endl;
		}
	}
	ll ans=-inf;
	rep(i,n+1){
		if(i/2==n/2){
			rep(j,5) chmax(ans,dp[i][j][0]);
		}
		if((i+1)/2==n/2){
			rep(j,5) chmax(ans,dp[i][j][1]);
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


int main() {
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    rep(i, siz(s)) {
        if (s[i] != t[i]) cnt++;
    }
    prt(cnt);

    return 0;
}


Measured memory_bytes: 3920
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	cin>>n;
	vll v(n);
	rep(i,n) cin>>v[i];
	sort(ALL(v));
	vll sum = v;
	rep(i,n){
		if(i) sum[i] += sum[i-1];
	}
	vint ok(n);
	rep(i,n){
		if(i){
			if(v[i]<=2*sum[i-1]){
				ok[i-1] = 1;
			}
		}
	}
	ok.back()=1;
	// rep(i,n){
	// 	cout<<v[i]<<" "<<ok[i]<<endl;
	// }
	vint f(n,1);
	for(int i = n-1;i>=0;i--){
		f[i] &= ok[i];
		if(i<n-1){
			f[i] &= f[i+1];
		}
	}
	int ans = 0;
	rep(i,n){
		ans += f[i];
	}
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int t,x;


main() {
    cin >> t >> x;
    cout << (double)t/x << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
			Scanner s = new Scanner(System.in);
			int a = s.nextInt();
			int b = s.nextInt();
			int c = s.nextInt();

			int capacity = a - b;
			int zan = c - capacity;
			if(zan < 0) {
				zan = 0;
			}
				System.out.println(zan);

	}

}


Measured memory_bytes: 20692
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
#define Imax 1e9+5
#define LLmax 1e18
#define Imin -1e9-5
#define LLmin -1e18
string day [] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
vector <string> v;
bool sortByFirst(const pair<int,int>&a,const pair<int,int>&b){
    return a.first>b.first;
}
void dfs (string str, string t = "", int cnt = 0) {
    if (cnt == 2) {
        v.push_back (t);
        return;
    } else {
        for (int i = 0; i <str.size (); i ++) {
            dfs (str, t + str [i], cnt + 1);
        }
    }
}
int main () {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    while(cin>>n){
        cin.ignore();
        string str;
        cin>>str;
        int flag=1;
        if(n%2==0){
            for(int i=0,j=n/2;i<n/2,j<n;i++,j++){
                if(str[i]!=str[j]){
                    cout<<"No"<<endl;
                    flag=0;
                    break;
                }
            }
            if(flag)cout<<"Yes"<<endl;
        }else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramA
    {
        private class Point {
            public int R {get;set;}
            public int C {get;set;}
        }
        static void Main()
        {
            int h = NextInt, w = NextInt;
            var input = Enumerable.Range(0, h).Select(_ => Line).ToArray();
            var dp = Enumerable.Range(0, h).Select(_ => Enumerable.Repeat(int.MaxValue, w).ToArray()).ToArray();
            dp[0][0] = input[0][0] == '#' ? 1 : 0;

            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    if (i + 1 < h && input[i][j] == '.' && input[i + 1][j] == '#') dp[i + 1][j] = Math.Min(dp[i + 1][j], dp[i][j] + 1);
                    else if (i + 1 < h) dp[i + 1][j] = Math.Min(dp[i + 1][j], dp[i][j]);

                    if (j + 1 < w && input[i][j] == '.' && input[i][j + 1] == '#') dp[i][j + 1] = Math.Min(dp[i][j + 1], dp[i][j] + 1);
                    else if (j + 1 < w) dp[i][j + 1] = Math.Min(dp[i][j + 1], dp[i][j]);
                }
            }

            System.Console.WriteLine(dp[h - 1][w - 1]);
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	int wu=0,qi=0;
	cin>>a>>b>>c;
	if(a==5)
		wu++;
	if(a==7)
		qi++;
	if(b==5)
		wu++;
	if(b==7)
		qi++;
	if(c==5)
		wu++;
	if(c==7)
		qi++;
	if(wu==2&&qi==1)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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


int main(void){

	int N; cin >> N;
	vector<pair<int, int>> v(N);
	REP(i,N){
		int A; cin >> A;
		v[i] = make_pair(A, i+1);
	}
	
	SORT(v);

	REP(i,N-1) cout << v[i].second << ' ';
	cout << v.back().second << endl;



	return 0;

}


Measured memory_bytes: 1664
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

def combination_mod(n, k, mod):
    """ power_funcを用いて(nCk) mod p を求める """ 
    """ nCk = n!/((n-k)!k!)を使用 """

    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    a = fact[n] 
    b = fact[k]
    c = fact[n - k]
    return (a * pow(b, mod - 2, mod) * pow(c, mod - 2, mod)) % mod
    


#solve
def solve():
    x, y = LI()
    x, y = (2 * y - x) / 3, (2 * x - y) / 3
    if x.is_integer() and y.is_integer():
        print(combination_mod(int(x + y), int(x), mod))
    else:
        print(0)
    return


#main
if __name__ == '__main__':
    fact = [1] * (10 ** 6+1)
    for i in range(1, 10 ** 6):
        fact[i + 1] *= (fact[i] * (i+1)) % mod
    solve()


Measured memory_bytes: 49004
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

// const int N = ;
int n;

int main() {
	ios_base::sync_with_stdio(false);

	long long h, w;
	cin >> h >> w;
	long long ans = min(h, w);
	if(h % 3 == 0 || w % 3 == 0) ans = 0;

	for(int i = 1; i < h; i++) {
		long long mx = max((h - i) * w, ((w + 1) / 2) * i);
		long long mn = min((h - i) * w, (w / 2) *i );
		ans = min(ans, mx - mn);
	}
	swap(h, w);
	for(int i = 1; i < h; i++) {
		long long mx = max((h - i) * w, ((w + 1) / 2) * i);
		long long mn = min((h - i) * w, (w / 2) *i );
		ans = min(ans, mx - mn);
	}
	cout << ans << '\n';
}	

	

Measured memory_bytes: 256
import sys
mod = pow(10, 9) + 7
def C(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
NNN = (10**6)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range(2, NNN+1):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
n,m,k=map(int,input().split())
#n=m=k=2
print(C(n*m,k)*C(k,2)%mod*(n+m)*inverse[3]%mod)


Measured memory_bytes: 128300
from itertools import accumulate


def _solve(string):
    n, m, k, *ab = map(int, string.split())
    a, b = [0] + ab[:n], [0] + ab[n:]
    a, b = list(accumulate(a)), list(accumulate(b))
    i, j = n, 0
    while a[i] > k:
        i -= 1
    while j <= m and a[i] + b[j] <= k:
        j += 1
    ans = i + j - 1
    for i in range(i, -1, -1):
        while j <= m and a[i] + b[j] <= k:
            j += 1
        ans = max(ans, i + j - 1)
    return str(ans)


def solve(string):
    from bisect import bisect_right
    n, m, k, *ab = map(int, string.split())
    a, b = [0] + ab[:n], [0] + ab[n:]
    a, b = list(accumulate(a)), list(accumulate(b))

    ans = [0]

    for i in range(n + 1):
        c = bisect_right(b, k - a[i]) - 1
        if c != -1:
            ans.append(c + i)

    return str(max(ans))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


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


int main()
{
   int n,i=0,max=0,sum=0;
 int a[11];
scanf("%d",&n);
   for(i=0;i<n;i++)
    {
       scanf("%d",&a[i]);
        sum+=a[i];


    }

   for(i=0;i<n;i++)
   {
       if (a[i]>max)
        max=a[i];

   }
   printf("%d",sum-max/2);




return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int dp1[100001];
int dp2[100001];

int sum1(int l, int r)
{
	if(l==0) return dp1[r];
	else return dp1[r]-dp1[l-1];
}

int sum2(int l, int r)
{
	if(l==0) return dp2[r];
	else return dp2[r]-dp2[l-1];
}


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s, t;
	cin>>s>>t;
	int q; cin>>q;
	int n = s.length(); int m = t.length();
	for(int i=0;i<n;i++)
	{
		if(s[i]=='A') dp1[i]=1;
		else dp1[i]=-1;
		if(i>0) dp1[i]+=dp1[i-1];
	}
	for(int i=0;i<m;i++)
	{
		if(t[i]=='A') dp2[i]=1;
		else dp2[i]=-1;
		if(i>0) dp2[i]+=dp2[i-1];
	}
	while(q--)
	{
		int l1,r1,l2,r2;
		cin>>l1>>r1>>l2>>r2;
		l1--;r1--;l2--;r2--;
		int s1 = sum1(l1,r1);
		int s2 = sum2(l2,r2);
		s1-=s2;
		if(s1<0) s1=-s1;
		if(s1%3==0)
		{
			cout<<"YES\n";
		}
		else
		{
			cout<<"NO\n";
		}
	}
}


Measured memory_bytes: 1744
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	for(int n;cin>>n,n;){
		int m[n],a[n],b[n];
		for(int i=0;i<n;i++)
			cin>>m[i]>>a[i]>>b[i];
		
		int c[2*n];
		for(int i=0;i<n;i++){
			c[i]=a[i];
			c[n+i]=b[i];
		}
		sort(c,c+2*n);
		int csize=unique(c,c+2*n)-c;
		for(int i=0;i<n;i++){
			a[i]=lower_bound(c,c+csize,a[i])-c;
			b[i]=lower_bound(c,c+csize,b[i])-c;
		}
			
		int d[csize+1];
		fill(d,d+csize+1,0);
		for(int i=0;i<n;i++){
			d[a[i]]+=m[i];
			d[b[i]]-=m[i];
		}
		for(int i=0;i<csize;i++)
			d[i+1]+=d[i];
		
		bool ok=true;
		for(int i=0;i<=csize;i++)
			ok&=d[i]<=150;
		cout<<(ok?"OK":"NG")<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1172
def resolve():
    n=int(input())
    k=0
    c=0
    for i in range(n):
        a, b = map(int, input().split())
        if a==b:
            k+=1
        else:
            k=0
        if k==3:
            c=1
    if c==1:
        print("Yes")
    else:
        print("No")
resolve()

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

int main()
{
    int N, M; cin >> N >> M;

    vector< pair<int, int> > rawInput(M);
    vector<vector<int> > prifList(N);
    map<pair<int, int>, int> answer;

    for(int i = 0; i < M; ++i)
    {
        int P, Y; cin >> P >> Y;
        rawInput.at(i) = make_pair(P, Y);
        prifList.at(P - 1).push_back(Y);
        answer[make_pair(P, Y)] = 0;
    }

    for(int i = 0; i < N; ++i)
    {
        sort(prifList.at(i).begin(), prifList.at(i).end());
        for(int j = 0; j < prifList.at(i).size(); ++j)
        {
            answer[make_pair(i+1, prifList[i][j])] = j + 1;
        }
    }
    for(int i = 0; i < M; ++i)
    {
        cout << setw(6) << setfill('0') << rawInput.at(i).first;
        cout << setw(6) << setfill('0') << answer[rawInput.at(i)] << '\n';
    }
    return 0;
}


Measured memory_bytes: 12416
#include <iostream>
#include <climits>
using namespace std;
//C - GCD on Blackboard
int main(void){
    int n,a[100000];
    std::cin >> n;
    int s=0,min=INT_MAX;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        if(a[i]<=0)s++;
        if(abs(a[i])<min)min=abs(a[i]);
    }
    long long ans=0;
    for (int i = 0; i < n; i++) {
        ans+=abs(a[i]);
    }    
    if(s%2==1){
        ans-=min*2;        
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 640
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

int N, M, X;


int main(void) {
    scanf("%d %d %d", &N, &M, &X);
    
    int cnt = 0;
    REP (i, 0, M) {
      int a;
      scanf("%d", &a);
      if (a<X) cnt++;
    }
    
    printf("%d\n", min(cnt, M-cnt));

	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

all_black_num = S.count('#')
all_white_num = N - all_black_num

if all_black_num == 0 or all_white_num == 0:
    ans = 0
else:
    left_black_num = 0
    left_white_num = 0
    right_white_num = all_white_num - left_white_num
    right_black_num = all_black_num - left_black_num
    ans = left_black_num + right_white_num
    for i, c in enumerate(S):
        if c == '#':
            left_black_num += 1
        elif c == '.':
            left_white_num += 1
        right_white_num = all_white_num - left_white_num
        right_black_num = all_black_num - left_black_num
        ans = min(ans, left_black_num + right_white_num)
        if right_black_num == N - i - 1:
            break
print(ans)

Measured memory_bytes: 3624
n,k = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]


for i in range(len(a)):
    a[i] = '{:040b}'.format(a[i])
p = len(bin(k))-2
k = '{:040b}'.format(k)
ans = 0
for i in range(0,40-p):
    num_1 = 0
    num_0 = 0
    for j in range(n):
        if a[j][i] == '1':
            num_1 += 1
        elif a[j][i] == '0':
            num_0 += 1
    num = num_1
    ans += (2**(39-i))*num

t = True
for i in range(40-p,40):
    num_1 = 0
    num_0 = 0
    if t:
        if k[i] == '1':
            for j in range(n):
                if a[j][i] == '1':
                    num_1 += 1
                elif a[j][i] == '0':
                    num_0 += 1
            if num_0 > num_1:
                num = num_0
                ans += (2**(39-i))*num
            else:
                t = False
                num = num_1
                ans += (2**(39-i))*num
        elif k[i] == '0':
            for j in range(n):
                if a[j][i] == '1':
                    num_1 += 1
                elif a[j][i] == '0':
                    num_0 += 1
            num = num_1
            ans += (2**(39-i))*num
    else:
        for j in range(n):
            if a[j][i] == '1':
                num_1 += 1
            elif a[j][i] == '0':
                num_0 += 1
        if num_0 > num_1:
            num = num_0
            ans += (2**(39-i))*num
        else:
            num = num_1
            ans += (2**(39-i))*num
print(ans)

Measured memory_bytes: 91992
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    int sc[3];
    cin >> sc[1] >> sc[2] >> sc[0];

    string s;
    cin >> s;

    map<char, int> cti;
    cti['r'] = 0;
    cti['s'] = 1;
    cti['p'] = 2;

    ll ans = 0;
    bool check[N];
    fill(check, check + N, false);
    for(int i = 0; i < N; i++){
        if(i - K >= 0){
            if(check[i - K]){
                if(s[i] == s[i - K]){
                    check[i] = false;
                } else {
                    char c = s[i];
                    ans += sc[cti[c]];
                    check[i] = true;
                }
            }
            else {
                char c = s[i];
                ans += sc[cti[c]];
                check[i] = true;
            }
        } else {
            char c = s[i];
            ans += sc[cti[c]];
            check[i] = true;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a[3], b[3];
    rep(i,0,3) cin >> a[i] >> b[i];
    ll cnt[5] = {};
    rep(i,0,3){
        cnt[a[i] - 1]++;
        cnt[b[i] - 1]++;
    }
    sort(cnt, cnt+4, greater<ll>());
    if(cnt[0] == 2 && cnt[1] == 2 && cnt[2] == 1 && cnt[3] == 1){
        print("YES");
    }else{
        print("NO");
    }
}

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

int main(){
    int a, b;
    char op;
    while(1){
        cin >> a >> op >> b;
        if ( op == '?') break;   
        switch (op){
            case '+': cout << a+b << endl; break;
            case '-': cout << a-b << endl; break;
            case '*': cout << a*b << endl; break;
            case '/': cout << a/b << endl; break;
        }   
    }
    return 0;
}



Measured memory_bytes: 3044
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int a,c=0,d=0,i;
	int *b;
	scanf("%d",&a);
	b=(int *)malloc(a * sizeof(int));
	for(i=0;i<a;i++) scanf("%d",&b[i]);
	for(i=0;i<a-1;i++){
		if(b[i]>=b[i+1]) c++;
		else{ if(d<c) d=c; c=0; }
	}
	if(d<c) d=c;
	printf("%d\n",d);
}

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x.at(i);
  }
  int ans = 300000000;
  int right,left;
  left = 0;
  right = k-1;
  while (right <= n-1) {
    ans = min(ans,x.at(right)-x.at(left)+min(abs(x.at(right)),abs(x.at(left))));
    left++;
    right++;
  }

  cout << ans << endl;
}


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

int main()
{
       int a,b;
       char op;
       while(1){
       scanf("%d %c %d",&a,&op,&b);
       if(op == '?'){
             exit(0);
       }
       if(op == '+')
       printf("%d\n",a + b);
       if(op == '-')
       printf("%d\n",a - b);
       if(op == '*')
       printf("%d\n",a * b);
       if(op == '/')
       printf("%d\n",a / b);
       }
       return 0;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
int n,h[100005];
bool wwq[100005]={false};
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>h[i];
	for(int i=1;i<n;i++)
	{
		if(h[i]>h[i+1])
		{
			if(h[i]-h[i+1]>1)
			{
				cout<<"No";
				return 0;
			}
			if(wwq[i])
			{
				cout<<"No";
				return 0;
			}
			wwq[i]=true;
			h[i]--;
		}
		if(h[i]==h[i+1]) wwq[i+1]=wwq[i];
	}
	cout<<"Yes";
	return 0;
}

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

int main(){
  int N;
  int *a;
  int i = 0 ,j;
  int flag = 0;
  int min = 0;
  
  scanf("%d",&N);
  
  int count = 0;
  a = (int *)malloc(sizeof(int) * N+1);
  
  for(i;i<N;i++) scanf("%d",&a[i]);
 
  min = a[0];
  for(i=0;i<N;i++){
    if(min >= a[i]){
      min = a[i];
      count++;
    }
  }
  /*  for(j=0;j<=i;j++){
      if(a[j] >= ){
        flag = 1;
      }else{
        flag = 0;
        break;
      }
    }
    if(flag) count++;
    flag = 0;
  }*/
  
  printf("%d\n",count);
  return 0;
} 

Measured memory_bytes: 896
from functools import reduce
from operator import mul
import collections
n = int(input())
a = list(map(int, input().split()))
ra = [0]
for i in range(n):
    ra.append(ra[i]+a[i])

def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

ca = collections.Counter(ra)
ans = 0
for item, value in ca.items():
    # print(item, value)
    if value >= 2:
        ans += cmb(value, 2)
# print(ca)
print(ans)

Measured memory_bytes: 143512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
ll mod = 1e9 + 7;
//const double pi = acos(-1.0);
/*
ll kmp(string x)
{
    ll n= x.length();
    //cout<<x<<endl;
    vector<ll> lcp(x.length(), 0);
    for(ll i=1;i<n;i++)
    {
        ll j=lcp[i-1];
        while(j>0 && x[j]!=x[i])
            j=lcp[j-1];
        if(x[i]==x[j])
            j++;
        lcp[i]=j;
    }
    return lcp[n-1];
}

int N = 1000002;
int ar[100002];
void sieve()
{
    for(int i=1;i<=N;i++)
        ar[i] = 1;
    ar[0] = 0;
    for(int i=2;i*i<=N;i++)
    {
        if(ar[i] && i*i<=N)
        {
            for(int j = i*i; j<=N;j+=i)
                ar[j] = 0;
        }
    }
}

ll modex(ll a,ll b){
    if(b<=0){
        return 1;
    }
    if(b%2==0)
    {
        ll x = modex(a, b/2);
        return ((x*x)%mod);
    }
    else
        return ((a%mod * modex(a, b-1))%mod);
}

ll c[1010][1010];

ll combina(ll i, ll j){
        for (int i=0;i<=1005;i++)
        for (int j=0;j<=i;j++)
        {
            if (j==i||j==0)
                c[i][j]=1;
            else
            c[i][j]=c[i-1][j-1]+c[i-1][j];
            c[i][j]%=mod;
        }
        return c[i][j];
}
void find_fac(int x){
    vector<ll> di;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i==0){
            di.push_back(i);
            while(x%i==0)
                x/=i;
        }
    }
    if(x > 1)
        di.push_back(x);
}
*/
int N = 1000002;
int ar[1000002];
int arr[1000001];
int co[1000001];
void sieve()
{
    for(int i=1;i<N;i++)
        ar[i] = 1;
    ar[0] = 0;
    for(int i=2;i*i<N;i++)
    {
        if(ar[i] && i*i<=N)
        {
            for(int j = i*i; j<=N;j+=i){
                ar[j] = 0;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout.precision(12);
    sieve();
    vector<int> pr;
    for(int i=2;i<=1e6;i++){
        if(ar[i])
            pr.push_back(i);
    }
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
        arr[a[i]]++;
    }
    int f = 1;
    for(int i=0;i<pr.size();i++){
        for(int j=pr[i];j<=1e6;j+=pr[i]){
            co[pr[i]]+=arr[j];
        }
        if(co[pr[i]]>1)
            f = 0;
    }

    ll g = a[0];
    for(int i=1;i<n;i++){
        g = __gcd(g, a[i]);
    }
    if(g==1){
        if(f)
            cout<<"pairwise coprime"<<endl;
        else
            cout<<"setwise coprime"<<endl;
    }
    else{
        cout<<"not coprime"<<endl;
    }
    return 0;
}


Measured memory_bytes: 23228
#include<stdio.h>
  int main(){
    int N[100][100];
    int n,c,d,k,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++){
      for(j=0;j<n;j++)N[i][j]=0;
    }
    for(i=0;i<n;i++){
      scanf("%d%d",&c,&k);
      c--;
      for(j=0;j<k;j++){
        scanf("%d",&d);
        d--;
        N[c][d]=1;
      }
    }
for(i=0;i<n;i++){
  for(j=0;j<n;j++){
    if(j!=0&&j<=n-1)printf(" ");
    printf("%d",N[i][j]);
  }
  printf("\n");
}
return 0;
}



Measured memory_bytes: 2112
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<math.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;

int main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double hAngle = (h*60.0 + m)/2.0;
    double mAngle = m*6.0;
    double diff = abs(hAngle - mAngle);
    double result = sqrt(pow(a, 2.0) + pow(b, 2.0) -2.0*a*b*cos(diff * PI / 180.0));

    cout.precision(20);
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 4188
if __name__ == '__main__':
    n = int(input())
    d = {}
    max = 1


    for i in range(n):
        s = input()
        if s in d:
            d[s] = d[s]+1
            if d[s] > max:
                max = d[s]
        else:
            d[s]=1

    dict2 = sorted(d.items())
    for i in dict2:
        if i[1] == max:
            print(i[0])




Measured memory_bytes: 44124
def main():

    N = int(input())
    S = []
    pos = []
    neg1 = []
    neg2 = []
    tot_v = 0
    for _ in range(N):
        t = input()
        S.append(t)
        v = 0
        min_v = float('inf')
        for c in t:
            if c == '(': v += 1
            else: v -= 1
            min_v = min(min_v, v)
        tot_v += v
        if min_v >=0:
            pos.append([min_v, v])
        else:
            if v > 0:
                neg1.append([min_v, v])
            else:
                neg2.append([min_v-v, min_v, v])

    if tot_v !=  0: return "No"

    u = 0
    for _, v in pos:
        u += v

    neg1.sort(reverse = True, key = lambda x: x[0])
    for min_v, v in neg1:
        if u + min_v < 0:
            return "No"
        else:
            u += v


    neg2.sort(key = lambda x: x[0])
    for _, min_v, v in neg2:
        if u + min_v < 0:
            return "No"
        else:
            u += v

    return "Yes"


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 255564
#pragma warning(disable:4996)
#include<stdio.h>
#include<algorithm>
#define INF 9999999
using namespace std;
int n;
struct A{
	int x, y;
}w[100010];
int main(){
	int i, a, b, mx, my, Mx, My, B = 0, E, R, M;
	int mmx, mmy, MMx, MMy;
	scanf("%d", &n);
	mx = my = INF, Mx = My = -INF;
	for (i = 0; i < n; i++){
		scanf("%d%d", &a, &b);
		w[i].x = a + b, w[i].y = b - a;
		mx = min(w[i].x, mx);
		my = min(w[i].y, my);
		Mx = max(w[i].x, Mx);
		My = max(w[i].y, My);
	}
	E = max(Mx - mx, My - my);
	while (B <= E){
		M = (B + E) >> 1;
		mmx = mmy = INF, MMx = MMy = -INF;
		for (i = 0; i < n; i++){
			if (mx + M < w[i].x || my + M < w[i].y){
				mmx = min(w[i].x, mmx);
				mmy = min(w[i].y, mmy);
				MMx = max(w[i].x, MMx);
				MMy = max(w[i].y, MMy);
			}
		}
		if (MMx - mmx <= M && MMy - mmy <= M){
			R = M, E = M - 1;
			continue;
		}
		mmx = mmy = INF, MMx = MMy = -INF;
		for (i = 0; i < n; i++){
			if (mx + M < w[i].x || My - M > w[i].y){
				mmx = min(w[i].x, mmx);
				mmy = min(w[i].y, mmy);
				MMx = max(w[i].x, MMx);
				MMy = max(w[i].y, MMy);
			}
		}
		if (MMx - mmx <= M && MMy - mmy <= M){
			R = M, E = M - 1;
			continue;
		}
		B = M + 1;
	}
	printf("%d\n", R);
}

Measured memory_bytes: 1808
import sys 
sys.setrecursionlimit(10**6)
s = input()
def dfs(s):
    while True:
        f = True
        for i in ['dream', 'dreamer', 'erase', 'eraser']:
            if s[-len(i):]==i:
                s = s[:-len(i)]
                if s=='':
                    return True
                f = False
        if f: return False
    
if dfs(s):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3316
n, a, b = list(map(int, input().split()))
MOD = 10**9+7

#print(bin(n))

# 2のN乗の計算
def mypow(b, n):
    ans = 1
    x = b
    while n > 0:
        if bin(n & 1) == bin(1):
            ans *= x
            ans = ans % MOD
        x = x * x
        x = x % MOD
        n = n >> 1
#        print("{} {}".format(ans, bin(n)))
    return ans

# n combination cの計算


def mycob(n, c):
    x = 1
    y = 1
    for i in range(c):
        x = x * (n - i)
        x %= MOD
        y = y * (i + 1)
        y %= MOD

    ans = (x * mypow(y, MOD - 2)) % MOD
#    print("x:{} y:{} ans:{}".format(x, y, ans))
    return ans

ans1 = mypow(2, n)
ans2 = mycob(n, a)
ans3 = mycob(n, b)

ans = ans1 - ans2 - ans3 - 1
print(ans % MOD)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  int array[200005];
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>array[i];
  }
  
  vector<int>vec;
  bool flag[200005]={false};
  for(int i=n;i>0;i--){
    int temp=i;
    bool bit=0;
    while(temp<=n){
      bit^=flag[temp];
      temp+=i;
    }
    if(bit!=array[i]){
      vec.push_back(i);
      flag[i]=true;
    }
  }
  
  cout<<vec.size()<<endl;
  for(int i=vec.size()-1;i>=0;i--){
    cout<<vec[i]<<' ';
  }
  cout<<endl;
  return(0);
}

Measured memory_bytes: 2680
X, N = map(int, input().split())
ps = list(map(int, input().split()))
ps.sort()

diff = 1000
ans = None
for i in range(X - 51, X + 51, 1):
    isInPs = False
    index = 0
    for j in ps:
        if ps[index] == i:
            isInPs = True
            break
        index += 1
    if isInPs == False:
        testDiff = abs(X - i)
        if testDiff < diff:
            diff = testDiff
            ans = i
print(ans)

Measured memory_bytes: 9212
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;

void solve() {
    set<int> st;
    for (int i = 0; i < 3; i++) {
        int x;
        cin >> x;
        st.insert(x);
    }
    cout << (st.size() == 2 ? "Yes" : "No");
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
}

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

typedef long long ll;

const ll N = 1e5 + 10;
ll h[N], x[N];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    ll n, a, b, c;
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++)
        cin >> h[i];
    c = a - b;
    ll st = 0, en = 1000 * 1000 * 1000, ans = n;
    while (st <= en) {
        ll mid = (st + en) / 2;
        for (int i = 0; i < n; i++)
            x[i] = max(h[i] - mid * b, 0LL);
        ll sum = 0;
        for (int i = 0; i < n; i++)
            sum += (x[i] + c - 1) / c;
        if (sum <= mid) {
            ans = mid;
            en = mid - 1;
        }
        else
            st = mid + 1;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int counter[200005];
bool balls[200005];
bool picked[200005];
void solve(int k){
	for(int i=1; i*i<=k; i++){
		if(k%i==0){
			counter[i]++;
			if(i!=k/i) counter[k/i]++;
		}
	}
}
int main(){
	int n;
	cin>>n;
	int ret = 0;
	for(int i=1; i<=n; i++) cin>>balls[i];
	for(int i=n; i>=1; i--){
		if(balls[i] && counter[i]%2) continue;
		if(!balls[i] && counter[i]%2==0) continue;
		picked[i] = true;
		ret++;
		solve(i);
	}
	cout<<ret<<'\n';
	for(int i=1; i<=n; i++){
		if(picked[i]) cout<<i<<" ";
	}
}

Measured memory_bytes: 4760
def countingSort(A):
    max_a = max(A)
    C = []
    for i in range(max_a+1):
        C.append(0)

    for a in A:
        C[a] += 1
    cum_sum = 0
    for i in range(max_a+1):
        cum_sum += C[i]
        C[i] = cum_sum
        
    B = []
    for _ in range(len(A)):
        B.append(None)
    for a in A[::-1]:
        B[C[a]-1] = a
        C[a] -= 1
    return B

_ = input()
A = list(map(int, input().rstrip().split(" ")))
B = countingSort(A)
print(" ".join(list(map(str, B))))


Measured memory_bytes: 241952
import math

def prime(num):
	array=[]
	tmp=int(math.sqrt(n))+1
	for i in range(2,tmp):
		while num % i == 0:
			num/=i
			array.append(i)
	# リストが空なら入力(num)は素数
	
	if array==[]:
		return [num]
	else:
		if num>1:
			array.append(int(num))
		return array

n=int(input())
P=prime(n)
P=sorted(P)
num=n
if 1 in P:
	print(0)
else:
	ans=0
	tmp=0
	for i in range(0,len(P)):
		if i==0:
			tmp=P[i] 
		elif P[i]==P[i-1]:
			tmp*=P[i]
		else:
			tmp=P[i]
			num=n
		if num%tmp==0:
			num/=tmp
			ans+=1
			
	print(ans)

Measured memory_bytes: 9292
n,q = map(int,input().split())
sl = list(input())

ansl = [0]
a = 0
for i in range(n-1):
    if sl[i] == "A" and sl[i+1] == "C":
        a += 1
    ansl.append(a)

for _ in range(q):
    l,r = map(int,input().split())
    print(ansl[r-1] - ansl[l-1])




Measured memory_bytes: 55772
#include <iostream>
#include <map>
#include <vector>

using namespace std;


#define M 1000000007

int main() {
	long long int a = 1;
	long long int n;
	cin >> n;
	map<long long int, long long int> mp;
	vector<long long int> so;
	for (int i = 2; i <= 1000; i++) {
		bool h = true;
		for (int j = 2; j < i; j++) {
			if (i%j == 0) {
				h = false;
			}
		}
		if (h) {
			so.push_back(i);
			//cout << i <<  endl;
		}
	}

	for (long long int i = 1; i <= n; i++) {
		long long int b = i;
		for (int j = 0; j < so.size(); j++) {
			while (b != 1 && b % so[j] == 0) {
				mp[so[j]]++;
				b /= so[j];
			}
		}
	}
	
	for (int i = 0; i < so.size(); i++) {
		if (mp[so[i]] != 0) {
			a *= (mp[so[i]]+1);
			a %= M;
		}
	}
	/*
	for (map<long long int, long long int>::iterator ite = mp.begin(); ite != mp.end(); ite++) {
		
		a %= M;
	}*/
	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
//	"time"
)




var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := rdr.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}  

func stringToArr(str string )[]string{
   return strings.Split( str," ")	
}

func atoi(str string)int{
	 ret,_ := strconv.Atoi(str)
	 return ret
}
func atoi2(str []string)[]int{

	ret:= make([]int,len(str))

	for i,v := range(str){
		ret[i] = atoi(v)
	}
	return ret
}




func main (){
//	start := time.Now()
N:= readLine()
//s:= atoi2 (stringToArr( readLine()))
 
//N:=s[0]
//X:=s[1]
//T:=s[2]
cnt:=0
for i:=0; i< len(N); i++ {
	n :=  N[i] - '0'
	cnt += int( n)
}
r:="No"

if  cnt % 9 == 0{
	r="Yes"
}



fmt.Println(r)
    
   //n,_ := strconv.Atoi( readLine());
   //l:= strings.Split( readLine(), " ");

   /*
   for i:=0; i<n ;i++ {

   }
	
   for i:=1; i<n ;i++ {
	 
   }
 
   for i:=0; i<n ;i++ {
fmt.Println ( person[i].childrenNumber)
   }*/

 //  end := time.Now()
 //  fmt.Printf("%fç§’\n", (end.Sub(start)).Seconds())

}

Measured memory_bytes: 2412
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long h, w, n, x, ans;
	cin >> h >> w >> n;
	x = max(h, w);
	ans = (n + x - 1) / x;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const int mod = (int)1e9 + 7;
const int mod2 = 998244353;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll x; cin>>x;
	ll ans = 100;
	int u = 0;
	while(ans < x){
		ans = (ans * (1 + 0.01));
		u++;
	}
	cout<<u<<endl;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
	int sa[3], sb[3];
	cin >> sa[0] >> sa[1] >> sa[2] >> sa[3];
	cin >> sb[0] >> sb[1] >> sb[2] >> sb[3];
	if ((sa[0] + sa[1] + sa[2] + sa[3]) > (sb[0] + sb[1] + sb[2] + sb[3])){
		cout << sa[0] + sa[1] + sa[2] + sa[3] << endl;
	}
	else{
		cout << sb[0] + sb[1] + sb[2] + sb[3] << endl;
	}
return 0;
}

Measured memory_bytes: 1160