akhauriyash/Code-Regression huggingface dataset:
//==================================================================================================
// Name        : Noragami.cpp
// Author      : lotus.eater086
// Copyright   : If you're reading this then this warning is for you. Every word you read of this 
//               useless fine print is another second of your life. Don't you've other things to do?
//               Is your life so empty that you honestly can't think of a better way to spend these
//               moments ? Or are you so impressed with authority that you give respect and 
//               credence to all who claim it ? Do you read everything you're supposed to read ? Do
//               you think everything you're supposed to think ? Buy what you're told you should 
//               want ? Get out of your apartment . Meet a member of the opposite sex. Stop the 
//               excessive shopping and self-improvement . Quit your boring job.
//               Start a fight. Prove you're alive. If you don't claim your humanity you'll become a
//               statistic. You've been warned !

// Description : 
// Date        : 2019-10-03
// Time        : 12:07:03
// Directory   : C:\Users\Lenovo\cpPractise\deliberatePractise\code_folder\.vscode
// FilePath    : C:\Users\Lenovo\cpPractise\deliberatePractise\code_folder\.vscode\Noragami.cpp
//==================================================================================================
    

#include <bits/stdc++.h>
#define LL long long
#define endl "\n"

using namespace std ;
    
//
template < typename T >

inline T read( T &x )
{

    x = 0 ;

    int f = 0 ;

    char ch = getchar() ;

    while( ch < '0' || ch > '9' )  {

        f |= ( ch == '-' ) , ch = getchar() ;

    }

    while( ch >= '0' && ch <= '9' )  {

        x = ( x << 1 ) + ( x << 3 ) + ch - '0' , ch = getchar() ;

    }

    return x = f ? -x:x ;

}
//

int cnt = 0 ; 

void bubble_sort( vector<int> &v , int n )
{

    for( int i = 0 ; i < n ; i++ )  {

        for( int j = n-1 ; j >= i+1 ; j-- )  {

            if( v[j] < v[j-1] )  {

                cnt++ ;

                swap(v[j],v[j-1]) ;  

            }

        }

    }

}

void print_vector( vector<int> v )
{

    for( int i = 0 ; i < v.size() ; i++ )  {

        if( i == 0 )  cout << v[i] ;

        else  cout << " " << v[i] ;

    }

    cout << endl ; 

}

void solve( void )
{

    int n ;

    cin >> n ;

    vector<int> v( n ) ;

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

    bubble_sort(v,n) ;

    print_vector(v) ;

    cout << cnt << endl ;  

}

int main( void )

{

    //ios_base::sync_with_stdio( false ) ;  cin.tie( NULL ) ;  cout.tie( NULL ) ;

  

    if( 0 )  {

        int t = 100 ;

        for( int i = 1 ; i <= t ; i++ )  solve() ;

    }

    else  {

        solve() ;

    }

    

    return 0 ;

}



Measured memory_bytes: 3140
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//Hang in there!

using namespace std;


int main() {
	int N;
	cin >> N;
	if (N < 1000) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ABD" << endl;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n;
string s;

int main(){
	cin >> n >> s;
	
	int ma=0,pos=0;
	REP(i,0,n) pos+=(s[i]=='I'?1:-1),ma=max(ma,pos);
	cout << ma << endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
    int n,m;
    scanf("%d",&n);
  	scanf("%d",&m);
    if(n==1&&m==2||n==2&&m==1)
    printf("3");
    else if(n==1&&m==3||n==3&&m==1)
    printf("2");
    else if(n==2&&m==3||n==3&&m==2)
    printf("1");
    return 0;
}

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

def _solve(i, k, bits, N):
    if i == -1:
        return 0
    m = 1 << i
    if bits[i] <= N // 2 and k >= m:
        return _solve(i-1, k-m, bits, N) + m
    return _solve(i-1, k, bits, N)

def solve(N: int, K: int, A: "List[int]"):
    L = 64
    bits = tuple(sum(a & (1 << i) > 0 for a in A) for i in range(L))
    x = _solve(L-1, K, bits, N) 
    return sum(x ^ a for a in A)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, K, A))

if __name__ == '__main__':
    main()


Measured memory_bytes: 18260
#include <stdio.h>
#include <string.h>

int main(void){
	char s[100001];
	char x;
	int count = 0, l = 0, r;

	scanf("%s", s);
	r = strlen(s) - 1;

	while(l < r){
		if(s[r] == s[l]) {
			l++;
			r--;
		}
		else if(s[l] == 'x'){
			count++;
			l++;
		}
		else if(s[r] == 'x'){
			count++;
			r--;
		}
		else {
			printf("-1\n");
			return 0;
	}
	}

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

return 0;
	}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k;
  cin>>n>>k;
  string s,t;
  rep(i,k){
    cin>>t;
    s+=t;
  }
  while(string::npos!=to_string(n).find_first_of(s)) n++;
  cout<<n<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict
import heapq


def submit():
    n, m = map(int, input().split())
    jobs = defaultdict(list)
    job_q = []

    # jobs[a] : a日後に報酬をもらえる仕事についてヒープ
    for _ in range(n):
        a, b = map(int, input().split())
        heapq.heappush(jobs[a], -b)

    # 1日前~m日前について、えらぶべきjobを選択する
    ans = 0
    for i in range(1, m + 1):
        # print("jobs", jobs)
        # print("jobq", job_q)
        if jobs[i]: # 今日期限の仕事について、最大報酬の仕事を候補に入れる
            heapq.heappush(job_q, (heapq.heappop(jobs[i]), i))
        
        # 仕事の候補がある
        if job_q:
            pay, day = heapq.heappop(job_q)
            ans -= pay
            if jobs[day]: # 仕事をしたことにした日の次のjobを候補に追加
                heapq.heappush(job_q, (heapq.heappop(jobs[day]), day))
    print(ans)
            
            
submit()

Measured memory_bytes: 27740
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	for(int i = 0; a > 0 && c> 0 ; i++) {
		if(i & 1) a -= d;
		else c -= b;
	}
	cout << (a > 0? "Yes": "No") << '\n';
}



Measured memory_bytes: 3660
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cerr<<endl; 
	}
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int a,b,c,k;
		cin>>a>>b>>c>>k;
		ll int ans=0;
		if(k!=0)
		{
			ll int tmp=min(k,a);
			ans+=tmp;
			k-=tmp;
		}
		if(k!=0)
		{
			ll int tmp=min(k,b);
			k-=tmp;	
		}
		if(k!=0)
		{
			ll int tmp=min(k,c);
			ans-=tmp;
			k-=tmp;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N,X;
int L[505];

ll from[505][505];
ll to[505][505];
const ll mo=1000000007;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>X;
	FOR(i,N) cin>>L[i];
	sort(L,L+N);
	reverse(L,L+N);
	from[0][0]=1;
	FOR(i,N) {
		ZERO(to);
		for(x=0;x<=N/2+2;x++) {
			FOR(y,X+1) if(from[x][y]) {
				// add
				if(y+L[i]<=X) (to[x+1][y+L[i]]+=from[x][y])%=mo;
				//keep
				if(x) (to[x][y]+=from[x][y]*(y-(L[i]-1)*x))%=mo;
				
				for(j=1;j<=L[i]&&y+j<=X;j++) {
					// conn1
					if(x) (to[x][y+j]+=from[x][y]*2*x)%=mo;
					// conn2
					if(x>=2) (to[x-1][y+j]+=from[x][y]*x*(x-1)*(L[i]-j+1))%=mo;
				}
			}
		}
		swap(from,to);
	}
	
	cout<<from[1][X]<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main() {
  int n;
  cin >> n;
  int a[n];
  double ans = 0;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    ans += 1.0 / a[i];
  }
  cout << 1 / ans << endl;
}

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

using namespace std;

int main(){
   string a, b;
   cin>>a>>b;



   if(a.length()>b.length()) cout<<"GREATER";
   else if(a.length()<b.length()) cout<<"LESS";
   else{
        int c1, c2;
        bool bb=true;
        for(int i=0; a[i]; i++){
            if(a[i]==b[i]){}
            else{
                bb=false;
                c1= a[i]-'0';
                c2= b[i]-'0';
                break;
            }
        }
        if(bb) cout<<"EQUAL";
        else if(c1>c2) cout<<"GREATER";
        else if(c1<c2) cout<<"LESS";
   }
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

ll Combination(ll n, ll r){
    ll num = 1;
    for(int i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
        num %= mod;
    }
    return num;
}

int main()
{
    int n,p;
    cin >> n >> p;
    int odd = 0,even = 0;
    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        if(k%2==0){
            even++;
        }else{
            odd++;
        }
    }
    ll ans = 0;
    if(p == 0){
        ll x = 0,y = 1;
        for(int i = 0; i <= odd; i += 2){
            x += Combination(odd,i);
        }
        for(int i = 0; i < even; i++){
            y *= 2;
        }
        ans += (x * y);
    }else{
        ll x = 0, y = 1;
        for(int i = 1; i <= odd; i += 2){
            x += Combination(odd,i);
        }
        for(int i = 0; i < even; i++){
            y *= 2;
        }
        ans += (x * y);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
function median(list)
  table.sort(list)
  local center = math.floor(#list / 2)
  if #list % 2 == 0 then
    return (list[center] + list[center + 1]) / 2
  else
    return list[center + 1]
  end
end

function sad(A, b)
  local acc = 0
  for i, v in ipairs(A) do
    acc = acc + math.abs(v - (b + i))
  end
  return acc
end

local N = tonumber(io.read())
local A = {}
for n in io.read():gmatch('%d+') do
  table.insert(A, tonumber(n))
end

local B = {}
for i, v in ipairs(A) do
  table.insert(B, (v - i))
end
local result = sad(A, median(B))
io.write(result)


Measured memory_bytes: 20180
n = int(input())
dict1 = {}

for _ in range(n):
    s = input()
    if s in dict1:
        dict1[s] += 1
    else:
        dict1[s] = 1

dict_sorted = sorted(list(dict1.items()), key = lambda x: x[0])
dict_sorted.sort(key = lambda x: x[1], reverse = True)

max1 = dict_sorted[0][1]

for i in range(len(dict_sorted)):
    if dict_sorted[i][1] == max1:
        print(dict_sorted[i][0])
    else:
        break


Measured memory_bytes: 108504
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll K; std::cin >> K;

  std::priority_queue<ll, std::vector<ll>, std::greater<ll>> pq;
  for(int i=1; i<=9; i++) pq.push(i);
  
  for(int i=0; i<K; i++) {
    ll p = pq.top(); pq.pop();
    if ( p % 10 == 0 ) {
      pq.push(10*p+(p%10));
      pq.push(10*p+(p%10)+1);
    }
    else if ( p % 10 == 9 ) {
      pq.push(10*p+(p%10)-1);
      pq.push(10*p+(p%10));
    }
    else {
      pq.push(10*p+(p%10)-1);
      pq.push(10*p+(p%10));
      pq.push(10*p+(p%10)+1);
    }
    
    if ( i == K-1 ) {
      std::cout << p << std::endl;
      return 0;
    }
  }
  return 0;
}



Measured memory_bytes: 2420
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    string s;cin>>s;
    string foo="abc";
    do{
        if(s==foo){
            cout<<"Yes"<<endl;
            return 0;
        }
    }while(next_permutation(foo.begin(),foo.end()));
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

typedef db T;
const db eps = 1e-8;
int sgn(T x){return (x>eps)-(x<-eps);}
struct P{
    T x,y;
    P(){} P(T x,T y):x(x),y(y){}
    void read(){scanf("%lf%lf",&x,&y);}
    P operator - (const P&b) const {return P(x-b.x,y-b.y);}
    P operator + (const P&b) const {return P(x+b.x,y+b.y);}
    T operator * (const P&b) const {return x*b.x+y*b.y;}
    P operator * (const T&k) const {return P(x*k,y*k);}
    T operator ^ (const P&b) const {return x*b.y-y*b.x;}
    bool operator < (const P&b) const {return sgn(y-b.y)?y<b.y:x<b.x;}
};
T abs(P a){return sqrt(a*a);}

namespace NearestPoints{
    T solve(int l,int r,vector<P>&p){
        if(l == r) return 1e100;
        int m=(l+r)>>1;
        T Xm = p[m].x , lim = min(solve(l,m,p) , solve(m+1,r,p));
        inplace_merge(p.begin()+l,p.begin()+m+1,p.begin()+r+1);
        vector<P> V;
        rep(i,l,r+1) if(fabs(p[i].x - Xm) <= lim) V.pb(p[i]);
        rep(i,0,sz(V)) rep(j,i+1,sz(V)){
            if(fabs(V[j].y - V[i].y) >= lim) break;
            T dis = abs(V[i]-V[j]);
            lim = min(lim,dis);
        }
        return lim;
    }
    T solve(vector<P> A){
        sort(all(A),[&](P a,P b){return a.x<b.x;});
        return solve(0,sz(A)-1,A);
    }
}

int main(){
    int n;scanf("%d",&n);
    vector<P> A;
    rep(i,0,n){
        P p;p.read();
        A.pb(p);
    }
    printf("%.10f\n",NearestPoints::solve(A));
    return 0;
}

Measured memory_bytes: 9112
#include <fstream>
#include <numeric>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}

#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)

#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define pb push_back
#define pii pair <int, int>
#define print(x) for(auto it : x) cout << it << ' ';
#define endl "\n" // TODO: remove
#define int long long

const int N = (int)(1e6) + 322;
const int inf = (int)(2e18);
const int mod = (int)(1e9) + 7; // check modulo
const double eps = (1e-6);


void solve(int test) {
    char ch; cin >> ch;
    if (islower(ch)) cout << 'a';
    else cout << 'A';
}

signed main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int test = 1;// cin >> test;
    for(int tt = 1; tt <= test; ++tt) {
        solve(tt);
    }


    return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;

long long extgcd(long long a, long long b, long long &x, long long &y) {
	long long d = a;
	if(b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else {
		x = 1;
		y = 0;
	}
	return d;
}

long long mod_inverse(long long a, long long m) {
	long long x, y;
	extgcd(a, m, x, y);
	return (x % m + m) % m;
}

pair<long long, long long> linear_congruence(const vector<long long> &A, const vector<long long> &B, const vector<long long> &M) {
	long long x = 0, m = 1;

	for(unsigned i = 0; i < A.size(); ++i) {
		if(B[i] == -1) continue;

		long long a = A[i] * m, b = B[i] - A[i] * x, d = __gcd(M[i], a);
		if(b % d != 0) return make_pair(0, -1);
		long long t = b / d * mod_inverse(a / d, M[i] / d) % (M[i] / d);
		x = x + m * t;
		m *= M[i] / d;
	}

	return make_pair(x % m, m);
}

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

	int n, m, d;
	cin >> n >> m >> d;

	vector<long long> M(m);
	for(auto &e : M) cin >> e;

	vector<long long> A(m, 1);

	for(int i = 0; i < d; ++i) {
		vector<long long> B(m);
		for(auto &e : B) cin >> e;

		long long b, mod;
		tie(b, mod) = linear_congruence(A, B, M);

		const long long p = n / mod;
		const long long q = n % mod;
		const long long k = (q - b + mod) % mod;

		n = p * mod + q - k;

		if(mod == -1 || n < 0) {
			n = -1;
			break;
		}
	}

	cout << n << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define NIL -1
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<char>>;
using P =pair<int,int>;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const ll mod=1000000007;

int main(){
    string s;
    cin>>s;
    int cnt=0;
    int ans=0;
    rep(i,3){
        if(s[i]=='R'){
            ++cnt;
            ans=max(cnt,ans);
        }else{
            cnt=0;
        }
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 3596
#include <stdio.h>
#include <string.h>

char s[110];
 
int main() {
    scanf("%s", s);
    int n = strlen(s);
    int ans = 0;
    for (int i = 0; i < n / 2; i++) {
        if (s[i] != s[n - 1 - i]) ans++;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<string, int> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


int main()
{
	ios_base::sync_with_stdio(false);
	ll n, m, x, y;
	cin >> n >> m >> x >> y;
	vi v(n), w(m);
	rep(i, n) cin >> v[i];
	rep(i, m)cin >> w[i];
	sort(all(w));
	sort(reall(v));
	if (w[0] > v[0] && v[0] >= x && w[0] <= y) cout << "No War\n";
	else cout << "War\n";
	return 0;
}

Measured memory_bytes: 256
import numpy as np
from scipy.sparse.csgraph import shortest_path

H, W, *t = map(int, open(0).read().split())
c = np.array(t[:100]).reshape((10, 10))
A = np.array(t[100:])
print(int(np.sum(shortest_path(c)[:, 1][A[A >= 0]])))


Measured memory_bytes: 40884
while (n = gets.to_i) > 0
  shain, tanka, suryo = []*n, []*n, []*n
  0.upto(n-1) do |i|
    shain[i], tanka[i], suryo[i] = gets.split(" ").map(&:to_i)
  end
  shain_uriage_sum = {}
  0.upto(n-1) do |i|
    shain_uriage_sum[shain[i]] = 0 if shain_uriage_sum[shain[i]].nil?
    shain_uriage_sum[shain[i]] += tanka[i] * suryo[i]
  end
  flag = false
  shain_uriage_sum.each do |key,val|
    if val >= 1000000
      puts key
      flag = true
    end
  end
  puts "NA" if !flag
end

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};


int main() {
//    ifstream myfile("C:\\Users\\riku\\Downloads\\20.txt");


    int n;
    cin >> n;
    vector<ll> numbers(n);
    rep(i, n) cin >> numbers[i];
    rep(i, n) numbers[i]--;
    vector<mint> counts(100000 * 2 + 1, 0);

    vector<mint> dp(n);
    counts[numbers[0]] = 1;
    dp[0] = 1;
    rep(i, n) {
        if (i == 0) continue;
        dp[i] = dp[i - 1];
        if (numbers[i - 1] == numbers[i]) continue;
        assert(counts.size() > numbers[i]);
        dp[i] += counts[numbers[i]];
        counts[numbers[i]] = dp[i];
    }

    cout << dp.back() << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  int s, w;
  while (scanf("%d %d", &s, &w) != EOF)
    printf("%s\n", w >= s ? "unsafe" : "safe");
  return 0;
}

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


int main(){
	vector<P> T;
	rep(i,5){
		int a, b;
		cin >> b;
		if(b%10==0) a = 0;
		else a = 10 -b % 10;

		T.push_back(make_pair(a,b));
	}
	sort(T.begin(),T.end());
	int ans = 0;
	rep(i,4) ans += T[i].first + T[i].second;
	ans += T[4].second;
	cout << ans << endl;	
}













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

int arr[101];

int main()
{
   int n;
   cin>>n;
   int sum=0;
   for(int i=1;i<=n;i++){
        scanf("%d",&arr[i]);
        sum+=arr[i];
   
    
   }
   int m;
   scanf("%d",&m);
   for(int i=0;i<m;i++)
   {
       int u,v;
       scanf("%d %d",&u,&v);
       printf("%d\n",sum-arr[u]+v);
       
   }
   return 0;
   
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};

// 二分探索
// llrep(i,N){
//     b = B[i];
//     auto cntA = lower_bound(A.begin(), A.end(), b);//イテレータなのでそのままllに変換とかはできない
//     auto cntC = upper_bound(C.begin(), C.end(), b);
//     ll cntA_ll = distance(A.begin(), cntA);
//     ll cntC_ll = C.size() - distance(C.begin(), cntC);
//     cnt += (cntA_ll * cntC_ll);
// }


bool visited[52];
int N,M,a,b;
bool edge[52][52];


void dfs(int v){
    visited[v] = true;
    Rep(i,N){
        if (edge[v][i] && !visited[i]){
            dfs(i);
        }
    }
}

int main(){
    string S;
    cin >> S;
    int a = stoi(S);
    int first = a/100;
    int second = a % 100;
    if (first>0 && first<= 12){
        if (second>0 && second<=12){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if (second>0 && second<=12){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int a[100100];
int b[100100];
int c[100100],d[100100];
int f[100100];
bool vis[100100];
int fa(int x){
	if(f[x]==x) return x;
	return f[x]=fa(f[x]);
}
int main(){
//	freopen("D.in","r",stdin);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		a[n+1]^=a[i];
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i]);
		b[n+1]^=b[i];
	}
	for(int i=1;i<=n+1;i++)
		c[i]=a[i],d[i]=b[i];
	sort(c+1,c+n+2);
	sort(d+1,d+n+2);
	for(int i=1;i<=n+1;i++){
		if(c[i]!=d[i]){
			printf("-1\n");
			return 0;
		}
	}
	for(int i=1;i<=n+1;i++)
		f[i]=i;
	for(int i=1;i<=n+1;i++)
	{
		a[i]=lower_bound(c+1,c+n+2,a[i])-c;
		b[i]=lower_bound(d+1,d+n+2,b[i])-d;
	}
	int ans=0;
	for(int i=1;i<=n+1;i++){
		if(a[i]!=b[i])
		{
			f[fa(a[i])]=fa(b[i]);
		}
	}
	for(int i=1;i<=n;i++){
		if(a[i]!=b[i])
		{
			ans++;
			if(!vis[fa(a[i])]){
				if(fa(a[n+1])!=fa(a[i]))
					ans++;
				vis[fa(a[i])]=1;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

int main()
{

    // Get the inputs
    int H;
    int W;
    cin >> H >> W;
    vector<vector<char>> map(H, vector<char>(W));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> map[i][j];
        }
    }

    // main
    vector<vector<int>> ans(H, vector<int>(W));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (map[i][j] == '#')
            {
                for (int k = -1; k <= 1; k++)
                {
                    for (int l = -1; l <= 1; l++)
                    {

                        if (0 <= i + k && i + k < H && 0 <= j + l && j + l < W)
                        {
                            ans[i + k][j + l] += 1;
                        }
                    }
                }
            }
        }
    }

    //Print the result
    for (int i = 0; i < H; i++)
    {
        string ansrow = "";
        for (int j = 0; j < W; j++)
        {
            if (map[i][j] == '#')
            {
                ansrow += '#';
            }
            else
            {
                ansrow += char(ans[i][j] + '0');
            }
        }

        cout << ansrow << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define fio ios_base::sync_with_stdio(0);cin.tie(0)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define slld(t) scanf("%lld",&t)
#define plld(t) printf("%lld\n",t)
#define sc(t) scanf("%c",&t)
#define pb(x) push_back(x)
#define ii pair<int,int>
#define vi vector<int>
#define vvi vector<vi >
#define vii vector<ii >
#define vvii vector<vii >
#define clr(x) memset(x,0,sizeof(x))
#define rep(i,begin,end) for(__typeof(end) i=begin-(begin>end);i!=end-(begin>end);i+=1-2*(begin>end))
#define M_PI 3.14159265358979323846
#define MOD 1000000007
#define MAX 100005
#define EPS 1e-12
using namespace std;

int main()
{
	int n; sd(n);
	map<ll,ll> m;

	for(ll i=1; i<=n; i++)
	{
		ll x = i;
		for(ll j=2; j<=n; j++)
		{
			while(x%j==0)
			{
				m[j]++;
				x /= j;
			}
		}
		if(x > 1) m[x]++;
	}

	ll ans = 1;
	for(auto it:m) ans = (ans * (it.second+1))%MOD;
	plld(ans);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <set>
#include <map>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)

typedef long long ll;

int d[15][15];

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

    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            d[i][j] = -1;
        }
    }

    rep(i, n)
    {
        int a;
        cin >> a;
        rep(j, a)
        {
            int x, y;
            cin >> x >> y;
            --x;
            d[i][x] = y;
        }
    }

    int ans = 0;

    rep(i, 1<<n)
    {
        vector<int> vec(n);
        rep(j, n)
        {
            if((i>>j)&1)
            {
                vec.at(j) = 1;
            }
        }
        bool flag = true;
        rep(j, n)
        {
            if(vec.at(j))
            {
                rep(k, n)
                {
                    if(d[j][k] == -1) continue;
                    if(d[j][k] != vec.at(k)) flag = false;
                }
            }
        }

        if(flag) ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
def main():
    A1,A2,A3 = map(int, input().split())
    a12 = abs(A1-A2)
    a23 = abs(A2-A3)
    a31 = abs(A3-A1)
    cost = [a12+a23, a23+a31, a31+a12]
    return min(cost)

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


Measured memory_bytes: 3060
n = int(input())
ans = [0]*4
for i in range(n):
	s = input()
	if s == 'AC':
		ans[0] += 1
	if s == 'WA':
		ans[1] += 1
	if s == 'TLE':
		ans[2] += 1
	if s == 'RE':
		ans[3] += 1
print('AC x',ans[0])
print('WA x',ans[1])
print('TLE x',ans[2])
print('RE x',ans[3])

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

int main() {
    ios::sync_with_stdio(false);
    int n,mi=1110,ma=-1110;
    cin>>n;
    for(int i=0; i<n; ++i){
        int t; cin >> t;
        mi = min(mi,t);
        ma = max(ma,t);
    }
    cout<<ma-mi<<"\n";

    return 0;
}


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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#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 REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll X,A,B;
    cin>>X>>A>>B;
    cout<<X-A-B*((X-A)/B)<<endl;;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

ll euclidean_gcd(ll a,  ll b) {
  if(a < b) euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
    ll N;
    cin >> N;
    vector<ll> A;
    rep(i, N) {
        ll ai;
        cin >> ai;
        A.pb(ai); 
    }

    ll result = A[0];
    for (int i = 1; i < A.size(); i++){
        result = euclidean_gcd(result, A[i]);
    }
    cout << result << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}
template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

int main(){
    ll d, t, s;cin >> d >> t >> s;
    if(d <= t * s) cout << "Yes\n";
    else cout << "No\n";
}

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

#if 1
#define MOD_BY 1000000007

int add(int a, int b) {
	return a + b - MOD_BY * (a + b >= MOD_BY);
}

int mul(int a, int b) {
	int r = 0;
	while (b > 0) {
		if (b & 1) r = add(r, a);
		a = add(a, a);
		b >>= 1;
	}
	return r;
}

int N, M;

int gen;
int memo_gen[114514][64];
int memo[114514][64];

int search(int pos, int left) {
	int answer = 0;
	int i;
	if (pos >= N) return left == 0;
	if (memo_gen[pos][left] == gen) return memo[pos][left];
	for (i = 0; i <= left; i++) {
		answer = add(answer, search(pos + 1, left - i));
	}
	memo_gen[pos][left] = gen;
	memo[pos][left] = answer;
	return answer;
}

int sumipe = 0;
int asumisu[1024], mizuhasu[1024];

int main(void) {
	int i;
	int hayaminn;
	int mikakosi;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	if (M == 1) {
		puts("1");
		return 0;
	}
	sumipe = 0;
	hayaminn = M;
	for (i = 2; i * i <= hayaminn; i++) {
		if (hayaminn % i == 0) {
			asumisu[sumipe] = i;
			mizuhasu[sumipe] = 0;
			while (hayaminn % i == 0) {
				mizuhasu[sumipe]++;
				hayaminn /= i;
			}
			sumipe++;
		}
	}
	if (hayaminn > 1) {
		asumisu[sumipe] = hayaminn;
		mizuhasu[sumipe] = 1;
		sumipe++;
	}
	mikakosi = 1;
	for (i = 0; i < sumipe; i++) {
		gen++;
		mikakosi = mul(mikakosi, search(0, mizuhasu[i]));
	}
	printf("%d\n", mikakosi);
	return 0;
}
#else
int cmp(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a < b ? -1 : a > b;
}

int N, M;

int yc;
int yakusu[512];

int ayane[512];
int asumi[512][512];

int yukachi(int tomatu) {
	int l = 0, r = yc - 1;
	while (l <= r) {
		int m = l + (r - l) / 2;
		if (yakusu[m] == tomatu) return m;
		else if (yakusu[m] < tomatu) l = m + 1;
		else r = m - 1;
	}
	printf("ERROR: %d not found\n", tomatu);
	exit(2);
	return 0;
}

#define MOD_BY 1000000007

int add(int a, int b) {
	return a + b - MOD_BY * (a + b >= MOD_BY);
}

int memo[114514][512];

int search(int pos, int current) {
	int answer = 0;
	int i;
	if (pos >= N) return yakusu[current] == 1;
	if (memo[pos][current]) return ~memo[pos][current];
	for (i = 0; i < ayane[current]; i++) {
		answer = add(answer, search(pos + 1, asumi[current][i]));
	}
	return ~(memo[pos][current] = ~answer);
}

int main(void) {
	int i, j;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	yc = 0;
	yakusu[yc++] = 1;
	if (M != 1) yakusu[yc++] = M;
	for (i = 2; i * i <= M; i++) {
		if (M % i == 0) {
			yakusu[yc++] = i;
			if (M / i != i) yakusu[yc++] = M / i;
			if (yc >= (int)(sizeof(yakusu) / sizeof(*yakusu)) - 2) {
				printf("ERROR: too many dividers!\n");
				return 2;
			}
		}
	}
	qsort(yakusu, yc, sizeof(*yakusu), cmp);
	for (i = 0; i < yc; i++) {
		ayane[i] = 0;
		for (j = 0; j < yc; j++) {
			if (yakusu[i] % yakusu[j] == 0) {
				asumi[i][ayane[i]++] = yukachi(yakusu[i] / yakusu[j]);
			}
		}
	}
	printf("%d\n", search(0, yukachi(M)));
	return 0;
}
#endif


Measured memory_bytes: 63232
N=int(input())
S=list(map(int,input().split()))
lenS=len(S)
T=[]
for i in range(1,N+1):
    T.append(abs(i-(N+1-i)))

T.sort()
S.sort()



for i in range(N):
    if T[i]!=S[i]:
        print(0)
        exit()


ans=1
nagasa=lenS//2
for i in range(nagasa):
    
    ans=(ans*2)%(10**9+7)

print(ans)




Measured memory_bytes: 20712
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,q,z;
    cin>>n>>k>>q;
    int a[n+1]={};
    for(int m=1;m<=q;m++)
    {
        cin>>z;
        a[z]=a[z]+1;
    }
    for(int i=1;i<=n;i++)
    {
        if(((k+a[i])-q)>0)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

#define MX 200005
#define INF 1000000000000000000

int n;
int a[MX];
long long dp[MX][3][3];

long long maxsum(int pos, int taken, int skip)
{
	if(pos >= n)
	{
		if(n&1)
			return (skip == 2) ? -INF : 0;
		else
			return 0;
	}
	long long &ret = dp[pos][taken][skip];
	if(ret != -1)
		return ret;

	if(taken)
	{
		ret = maxsum(pos+1,0,skip);
	}
	else
	{
		if(skip)
		{
			ret = max(a[pos] + maxsum(pos+1,1,skip), maxsum(pos+1,0,skip-1));
		}
		else
		{
			ret = a[pos] + maxsum(pos+1,1,0);
		}
	}
	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	cin >> n;
	for(int i=0; i<n; i++)
		cin >> a[i];
	memset(dp,-1,sizeof(dp));
	long long ret = (n&1) ? maxsum(0,0,2) : maxsum(0,0,1);
	cout << ret << endl;
}


Measured memory_bytes: 34072
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

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

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int r, g, b, n;
	std::cin >> r >> g >> b >> n;
	int ans = 0;
	for(int i = 0; i * r <= n; i++) {
		for(int j = 0; i * r + j * g <= n; j++) {
			if((n - i * r - j * g) % b == 0) {
				ans++;
			}
		}
	}
	std::cout << ans << '\n';
}

Measured memory_bytes: 256