akhauriyash/Code-Regression huggingface dataset:
// By "ANKI"
#include<bits/stdc++.h>
// #include<iostream>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define wr(i) cout<<#i<<" = "<<i<<",  ";
#define wre(i) cout<<#i<<"  =  "<<i<<endl;
#define all(v) v.begin(),v.end()
typedef long long ll;
#define lim 100000000000014LL
typedef unsigned long long ull;
#define M 300005
#define F first
#define S second
using u64= uint64_t;
 
/*
vector<pair<ll,ll>>v[M];
vector<ll>dis(M,lim);
vector<ll>path(M,-1);
void dijkstra(ll n){
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>pq;
    // priority_queue<pair<ll,ll>>pq;
    pq.push(mp(0,n));
    dis[n]=0LL;
    while(!pq.empty()){
        ll u=pq.top().second;
        pq.pop();
        for(auto x:v[u]){
            if(dis[x.first]>dis[u]+x.second){
                dis[x.first]=dis[u]+x.second;
                path[x.first]=u;
                pq.push(mp(dis[x.first],x.first));
            }
        }
    }
}
*/
 
int main()
{
fast
ll t=1LL;
// cin>>t;
while(t--)
{
ll x;
cin>>x;
for(int i=1;i<1000006;i++)if((i*x)%360==0){cout<<i<<" ";break;}
}
} 

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> hyoukou(N+1);
    for(int i=0;i<N;i++){
        cin >> hyoukou.at(i+1);
    }
    vector<int> good(N+1);
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        if(hyoukou.at(a)<hyoukou.at(b)){
            good.at(a)=-1;
        }else if(hyoukou.at(a)==hyoukou.at(b)){
            good.at(a)=-1;
            good.at(b)=-1;
        }else if(hyoukou.at(a)>hyoukou.at(b)){
            good.at(b)=-1;
        }
    }
    int num=0;
    for(int i=0;i<N;i++){
        if(good.at(i+1)==0){
            num++;
        }
    }
    cout << num << endl;
}

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



int main(){
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	ll n,i,s=0,ss=0,d=0,ans=0,sum=0;
	cin>>n;
	ll a[n],b[n];
	vector<ll> v;
	for(i=0;i<n;i++){
		cin>>a[i];
		s+=a[i];
	}for(i=0;i<n;i++){
		cin>>b[i];
		ss+=b[i];
	}if(s<ss){
		cout<<-1;
		return 0;
	}for(i=0;i<n;i++){
		if(a[i]>=b[i]){
			v.push_back(a[i]-b[i]);
		}else{
			d+=b[i]-a[i];
			ans++;
		}
	}if(ans==0){
		cout<<0;
		return 0;
	}
	sort(v.begin(),v.end());
		reverse(v.begin(),v.end());
		for(i=0;i<v.size();i++){
			sum+=v[i];
			ans++;
			if(sum>=d){
				break;
			}
		}
	cout<<ans;
  	
}


Measured memory_bytes: 2936
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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


int main(void) {
	string S, T, sub, ans;
	int i, j, k, tmp, cnt = 0;
	bool flag = true, ansok = false;

	cin >> S;
	cin >> T;
	//後ろから順番に走査
	for (i = S.length() - T.length(); i >= 0; i--) {
		sub = S.substr(i, T.length());//切り抜き
		flag = true;
		for (j = 0; j < T.length(); j++) {
			if (sub[j] != T[j] && sub[j] != '?') {//一致していない
				flag = false;
				break;
			}
		}
		if (flag) {//文字列Tが入る
			ansok = true;
			cnt = i;//cntに文字列格納する位置を退避
			break;
		}
	}

	if (ansok) {//正解ある
		//？の部分はaにして他はそのまま候補以降は普通に
		for (i = 0; i < S.length(); i++) {
			if (i == cnt) {
				i += T.length() - 1;
				printf("%s", T.c_str());
			}
			else if (S[i] == '?') {
				printf("a");
			}
			else {
				printf("%c", S[i]);
			}
		}
	}
	else {//ない
		printf("UNRESTORABLE\n");
	}




	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define INF 10000000

int main( void ) {
	int i, j, n, m, num[ 2 ][ 100 ], sum[ 2 ], min[ 2 ], diff;

	while ( scanf( "%d %d", &n, &m ), n ) {
		sum[ 0 ] = sum[ 1 ] = 0;
		for ( i = 0; i < n; i++ ) {
			scanf( "%d", num[ 0 ] + i );
			sum[ 0 ] += num[ 0 ][ i ];
		}
		for ( i = 0; i < m; i++ ) {
			scanf( "%d", num[ 1 ] + i );
			sum[ 1 ] += num[ 1 ][ i ];
		}

		diff = sum[ 0 ] - sum[ 1 ];
		min[ 0 ] = min[ 1 ] = INF;
		for ( i = 0; i < n; i++ )
			for ( j = 0; j < m; j++ )
				if ( ( num[ 0 ][ i ] - num[ 1 ][ j ] ) * 2 == diff )
					if ( num[ 0 ][ i ] + num[ 1 ][ j ] < min[ 0 ] + min[ 1 ] ) {
						min[ 0 ] = num[ 0 ][ i ];
						min[ 1 ] = num[ 1 ][ j ];
					}

		if ( min[ 0 ] == INF )
			puts( "-1" );
		else
			printf( "%d %d\n", min[ 0 ], min[ 1 ] );
	}

	return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int n,m;
cin >> n >> m;
vector<pair<int,int>> a(n);
for(int i = 0; i < n; i++){
    int c,b;
    cin >> c >> b;
    a[i] = make_pair(c,b);
}
sort(a.begin(),a.end());
int cnt = 0,sum = 0;
    for(int i = 0; i < n; i++){
        if(a[i].second + cnt <= m){
            sum += (abs(a[i].first) * a[i].second);
            cnt += a[i].second;
        }
        else
        {
            while(cnt < m){
                sum += abs(a[i].first);
                cnt++;
            }
        }
        
    }
    cout << sum << endl;
}

Measured memory_bytes: 1792
n = input()

dic = {}

for i in range(n):
    a = input()
    if a not in dic:
        dic[a] = 1
    elif dic[a] == 0:
        dic[a] = 1
    else:
        dic[a] = 0

keys = dic.keys()
ct = 0
for i in keys:
    if dic[i] > 0:
        ct += 1

print ct

Measured memory_bytes: 17084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

static class CodeJam
{
    static int Solve(int N, int[] A, List<int[]> seq)
    {
        Array.Sort(A);
        int sum = A[0];
        for (int i = 1; i < N - 1; ++i)
        {
            if (A[i] >= 0)
            {
                seq.Add(new[] { sum, A[i] });
                sum -= A[i];
            }
        }
        seq.Add(new[] { A[N - 1], sum });
        sum = A[N - 1] - sum;
        for (int i = 1; i < N - 1; ++i)
        {
            if (A[i] < 0)
            {
                seq.Add(new[] { sum, A[i] });
                sum -= A[i];
            }
        }
        return sum;
    }

    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var seq = new List<int[]>();
        Console.WriteLine(Solve(N, A, seq));
        foreach (int[] ans in seq) { Console.WriteLine(string.Join(" ", ans)); }
    }
}


Measured memory_bytes: 32712
#include <stdio.h>
int main(void) {
  int D;
  scanf("%d",&D);
  switch(D) {
    case 22:
      printf("Christmas Eve Eve Eve\n");
      break;
    case 23:
      printf("Christmas Eve Eve\n");
      break;
    case 24:
      printf("Christmas Eve\n");
      break;
    case 25:
      printf("Christmas\n");
      break;
  }
  return 0;
}

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

long long A , B , C;
int main(){
	cin>>A>>B>>C;
	A = abs(A);
	if(A/C >= B)cout<<A - B*C<<endl;
	else{
		long long X = A/C;
		A = A - C*X;
		B = B - X;
		if(B%2==0)cout<<A<<endl;
		else cout<<abs(A-C)<<endl;
	}
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

/*bool operator<(const data &d)const{
	return hoge;
}*/
 
const int dx[]={0,1,1,-1,-1,0};
const int dy[]={1,1,0,0,-1,-1};
set<char>vowel={'a','i','u','e','o'};

int marume(int x){
	if(x>255)return 255;
	if(x<=0)return 0;
	return x;
}
 
signed main(){
	IOS();
	int N;
	vector<int>ans;
	while(cin>>N,N){
		string s[N];
		rep(i,0,N)cin>>s[i];
		rep(i,0,N){
			int sz = s[i].size();
			rep(j,0,sz-1){
				if(s[i][j]=='.'&&s[i][j+1]!='.')s[i][j]='+';
			}
		}
		vector<int>flg(100010,0);
		rrep(i,0,N){
			rep(j,0,s[i].size()){
				if(s[i][j]=='+'){
					flg[j]=1;
				}else if(flg[j]&&s[i][j]=='.'){
					s[i][j]='|';
				}else flg[j] = 0;
			}
		}
		rep(i,0,N){
			rep(j,0,s[i].size())if(s[i][j]=='.')s[i][j]=' ';
		}
		rep(i,0,N)cout<<s[i]<<endl;
	}
}


Measured memory_bytes: 4504
#include<bits/stdc++.h>
#include <atcoder/all>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
using namespace atcoder;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

int main(){
    int n, m;
    cin >> n >> m;
    dsu uf(n);
    rep(i,m){
      int a,b;
      cin >> a >> b;
      a--;
      b--;
      uf.merge(a, b);
    }
    cout << uf.groups().size() - 1<< endl;
    return 0;
}

Measured memory_bytes: 8920
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  //val ls = in(0).split(' ').map(_.toInt)
  val str = in(0)
  val len = str.size
  val ret = (0 until len/2).count(i => str(i)!=str(len-i-1) )
  println(ret)
}


Measured memory_bytes: 27476
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    long long N, A[200010], i, judge=1;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> A[i];
    }

    sort(A+1, A+N+1);

    for(i=1; i<=N-1; i++){
        if(A[i] == A[i+1]){
            judge = 0;
        }
    }

    if(judge == 1){
        cout << "YES" << endl;
    }

    else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
n,m=map(int,input().split())
import math
a=math.factorial(n)
b=math.factorial(m)
if abs(n-m) > 1:
    print(0)

elif abs(n-m)==1:

    print((a*b)%(10**9+7))
else:
    print((a*b*2)%(10**9+7))

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




int main() {
	vector<int> vec(32);
	vec = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int K;
	cin >> K;
	cout << vec.at(K - 1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
typedef long long ll;
ll n,a[N],b[N],ans=0;
int main(){
	cin>>n;
	for(int i=0;i<n+1;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	for(int i=0;i<n;i++){
		if(a[i]>=b[i]) a[i]-=b[i],ans+=b[i],b[i]=0;
		else ans+=a[i],b[i]-=a[i],a[i]=0;
		if(b[i]!=0&&a[i+1]>=b[i]) a[i+1]-=b[i],ans+=b[i];
		else if(b[i]!=0&&a[i+1]<b[i]) ans+=a[i+1],a[i+1]=0;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1792
X, N = list(map(int, input().split()))
P = list(map(int, input().split()))

min_ = 100
for i in range(0, 102):
    cur = i 
    if cur in P:
        continue
    diff = abs(X - cur)
    if diff < min_:
        min_ = diff

front = X - min_
back = X + min_
if front not in P:
    print(front)
else:
    print(back)

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    ll n,a;
    ll max=-1000000000;
    ll min=1000000000;
    ll sum=0;
    cin>>n;
    REP(i,n){
        cin>>a;
        sum+=a;
        if(max<a)max=a;
        if(min>a)min=a;
    }
    cout<< min << " " << max<<" " << sum<<endl;
    return 0;
}


Measured memory_bytes: 3096
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sm = sum(A)
for i in range(N):
    if B[i] >= A[i] + A[i + 1]:
        A[i] = A[i + 1] = 0
    elif B[i] >= A[i]:
        A[i + 1] -= B[i] - A[i]
        A[i] = 0
    else:
        A[i] -= B[i]

print(sm - sum(A))


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

typedef long long ll;
typedef unsigned long long ull;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N;
ll A[200010];

int main(){

    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    map<ll, ll> s;
    ll tot = 0;
    ll ans = 0;
    for(int i = 0; i < N; i++){
        s[-tot]++;
        tot += A[i];
        ans += s[-tot];
    }
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 14336
#include<iostream>

using namespace std;
int N,V[50],C[50];

void solve(){
    int res[50];
    int sum=0;
    for(int i=0;i<N;i++){
        int tmp;
        tmp = V[i]-C[i];
        if(tmp > 0){
            sum+=tmp;
        }
    }
    cout << sum;
}

int main(){
    cin >> N;
    for (int i=0;i<N;i++){
        cin >> V[i];
    }
    for (int i=0;i<N;i++){
        cin >> C[i];
    }
    solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
	
  string s;
  int a,b,c,d,i,j,k;
  
  cin >> s;
  a=0;
  for(i=0;i<6;i++){
	if(s[i]=='1') a++;
  } 
  cout << a <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }


int n;
int a[2100];

ll dp[110][30];

int main() {
    while (cin >> n) {
        for (int i = 0; i < n; ++i) cin >> a[i];
        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;
        for (int i = 0; i < n-1; ++i) {
            for (int j = 0; j <= 20; ++j) {
                //if (dp[i][j]) cout << i << ", " << j << " : " << dp[i][j] << endl;
                if (j + a[i] >= 0 && j + a[i] <= 20) dp[i+1][j+a[i]] += dp[i][j];
                if (i != 0 && j - a[i] >= 0 && j - a[i] <= 20) dp[i+1][j-a[i]] += dp[i][j];
            }
        }
        
        long long res = dp[n-1][a[n-1]];
        
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll x,y,z,K,a[1010],b[1010],c[1010],cnt=1;
  cin>>x>>y>>z>>K;
  for(int i=1;i<=x;i++) cin>>a[i];
  for(int i=1;i<=y;i++) cin>>b[i];
  for(int i=1;i<=z;i++) cin>>c[i];
  a[0]=b[0]=c[0]=0;
  sort(a+1,a+x+1);
  sort(b+1,b+y+1);
  sort(c+1,c+z+1);
  int i=x,j=y,k=z;
  set <pair<pair<ll,int>,pair<int,int>>> q;
  /*set<int> q;
  q.insert(-1);
  // q.insert(40);
  set<int> ::iterator ele;
  ele=q.end();
  ele--;
  q.erase(ele);*/
  q.insert({{a[i]+b[j]+c[k],i},{j,k}});
  while(!q.empty() && cnt<=K)
  {
    // pair<pair<ll,int>,pair<int,int>> ele=q.top();
    // q.pop();
    set <pair<pair<ll,int>,pair<int,int>>> ::iterator ele;
    ele=q.end();
    ele--;
    cout<<ele->first.first<<endl;
    cnt++;
    i=ele->first.second,j=ele->second.first,k=ele->second.second;
    q.erase(ele);
    // cout<<i<<" "<<j<<" "<<k<<endl;
    if(j-1>0) q.insert({{a[i]+b[j-1]+c[k],i},{j-1,k}});
    if(k-1>0) q.insert({{a[i]+b[j]+c[k-1],i},{j,k-1}});
    if(i-1>0) q.insert({{a[i-1]+b[j]+c[k],i-1},{j,k}});
  }
  return 0;
}


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 100010
using namespace std;
typedef pair<int,int>pii;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,x;
    cin>>n;
    int ok=true;

    for(int i=0;i<n;i++ ){
        cin>>x;
        if(x%2==0){
            if(x%3!=0 && x%5!=0){
                ok=false;
                break;
            }
        }
    }

    if(ok)cout<<"APPROVED\n";
    else cout<<"DENIED\n";

}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  long long ans = N;
  int now;
  int x;
  long value = 1;
  for (int i=0; i<N-1; i++) {
    now = A[i];
    if (A[i] == 0) {
      value++;
      continue;
    }
    for (int j=i+1; j<N; j++) {
      x = now & A[j];
      if (x == 0) {
        ans += value;
        now = now | A[j];
      }
      else {
        break;
      }
    }
    ans += value * (value-1) / 2;
    value = 1;
  }
  ans += value * (value-1) /2;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
    string S, T;
    cin >> S;
    cin >> T;

    if (T.size() != S.size() + 1) {
            cout << "No" << endl;
            return 0;
    }

    for (int i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3132
use std::io;

fn main() {
    let ints = read_ints();
    let (n, m, x) = (ints[0], ints[1], ints[2]);

    let mut books = Vec::with_capacity(n as usize);
    for _ in 0..n {
        books.push(read_ints())
    }

    let combinations = 0..1 << n;
    let mut min = i32::max_value();
    for comb in combinations {
        let masks = &(0..n).filter(|mask| (comb >> *mask) & 1 == 1).collect::<Vec<_>>();
        let price = masks.iter().fold(0, |sum, it| sum + books[*it as usize][0]);
        let understanding = (0..m).collect::<Vec<_>>().iter().
            map(|it| masks.iter().fold(0, |sum, mask| sum + books[*mask as usize][*it as usize + 1])).
            min().unwrap_or_default();

        //println!("mask = {:?}, price = {}, understanding = {}", masks, price, understanding);
        if min > price && understanding >= x {
            min = price;
        }
    }

    if min == i32::max_value() {
        println!("{}", -1);
        return;
    }
    println!("{}", min)
}

fn read_ints() -> Vec<i32> {
    let mut guess = String::new();
    io::stdin().read_line(&mut guess);
    return guess.split_whitespace().filter_map(|s| s.parse().ok()).collect::<Vec<i32>>();
}

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

using namespace std;

#define MOD 1000000007
#define ll long long int
#define ld long double
#define pb push_back
#define mkp make_pair
#define pii pair<int, int> 
#define pll pair<long long int, long long int>
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define fi first
#define sc second
#define eps 1e-9

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

	int i, j, k, x, y;
	int a, b, c;
	cin >> a >> b >> c;
	x = max(a, max(b, c));
	y = min(a, min(b, c));
	cout << x-y << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	ll i,a[5],b[5],n,ans=0,min;
	cin>>n>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
	sort(a,a+5);
	min=a[0];
	if(min>n)cout<<5<<endl;
	else{
		if(n%min==0)ans+=n/min;
		else ans+=n/min+1;
		ans+=4;
		cout<<ans<<endl;
	}
	
	
	
	
	
	
//////////////////////////////////////////////////////
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
	int n,m;
	cin >> n >> m;
	cout << n*(n-1)/2 + m*(m-1)/2 << endl;
  return 0;
}

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

int N;
vector< int >arr;

int INF=1e9;

vector< int >MEMO;

int min_cost(int index)
{
	if(index >= N)
		return INF;
	else if(index==(N-1))
		return 0;
	if(MEMO[index]!=-1)
		return MEMO[index];
	return(MEMO[index]= min( min_cost(index+1)+abs(arr[index+1]-arr[index]) , min_cost(index+2)+abs(arr[index+2]-arr[index]) ));
}


int main()
{
	cin>>N;
	int i,temp;
	MEMO.assign(N,-1);
	for(i=0;i<N;i++)
	{
		cin>>temp;
		arr.emplace_back(temp);
	}
	arr.emplace_back(0);
	arr.emplace_back(0);
	cout<<min_cost(0);
	return 0;

}

Measured memory_bytes: 3448
class Array
	def accum
		inject([0]){|a, x| a + [a[-1] + x]}
	end

	def accum!
		(1..size-1).each{|i|
			self[i] += self[i-1]
		}
		self.unshift(0)
	end

	def accum_2d
		ac = map{|r| r.accum}
		(1..size-1).each{|i|
			(1..ac[0].size-1).each{|j|
				ac[i][j] += ac[i-1][j]
			}
		}
		ac.unshift([0] * ac[0].size)
		ac
	end

	def accum_2d!
		each{|r| r.accum!}
		(1..size-1).each{|i|
			(1..self[0].size-1).each{|j|
				self[i][j] += self[i-1][j]
			}
		}
		unshift([0] * self[0].size)
	end
		
	def bsearch_first_index(l = 0, r = size - 1, &pred)
		return nil if l > r
		c = (l + r) / 2 
		if pred[self[c]]
			bsearch_first_index(l, c-1, &pred) || c
		else
			bsearch_first_index(c+1, r, &pred)
		end
	end

	def bsearch_first_item(l = 0, r = size - 1, &pred)
		i = bsearch_first_index(l, r, &pred)
		i ? self[i] : nil
	end

	def bsearch_last_index(l = 0, r = size - 1, &pred)
		return nil if l > r
		c = (l + r) / 2 
		if pred[self[c]]
			bsearch_last_index(c+1, r, &pred) || c
		else
			bsearch_last_index(l, c-1, &pred)
		end
	end

	def bsearch_last_item(l = 0, r = size - 1, &pred)
		i = bsearch_last_index(l, r, &pred)
		i ? self[i] : nil
	end
end

n, m, l = gets.split.map &:to_i

def comb(n, k)
	c = 1	
	(1..k).each do |i|
		c = c * (n - i + 1) / i
	end
	c
end

a = []
(0..n-1).each do |i|
	a[i] = []
	p, r, v = gets.split.map &:to_i		
	p /= 100.0
	a[i] = (0..m).map do |k|
		prob = p ** k * (1 - p) ** (m - k) * comb(m, k)
		[(v == 0 ? Float::INFINITY : l.to_f / v + r * k), prob]
	end
	
	tmp = a[i].map(&:last).reverse.accum[1..-1].reverse
	(0..m).each {|k| a[i][k] << tmp[k] }
end

(0..n-1).each do |i|
	total_prob = 0
	(0..m).map do |k|
		time, prob = a[i][k]
		(0..n-1).each do |j|
			next if j == i
			dist = a[j]
			item = dist.bsearch_first_item {|t, _, _| t > time}	
			prob *= (item ? item[-1] : 0)
		end
		total_prob += prob
	end
    puts "%.08f" % total_prob
end

Measured memory_bytes: 10912
// http://drken1215.hatenablog.com/entry/2019/02/24/224100
//参考にさせて頂いた解説

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

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

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
#define rep(i,n) for(int i=0;i<(n);i++)
int N,A,B,C,INF=1e9+7;
vector<int> L;


//recで帰ってくるのはMP量である。したがって、chmin内の処理で二本結合の処理を行える。
int rec(int i,int a,int b,int c){
    if(i==N){
        if(!a || !b|| !c)return INF;//true,falseは0,1と同義であるため、判定できる
        //a,b,c,は竹の長さであり、そのどれかが0である時、一つも竹を選んでいないということになる。
        return abs(a-A)+abs(b-B)+abs(c-C); //a,b,cをA,B,Cにするコスト。10とかは別計算？
    }
    //今ある竹を採用しない場合なので、変化なし。
    int res=rec(i+1,a,b,c);

    //A,B,Cを使う場合。
    //(a? 10:0)  ←条件演算子というらしい！！！
    //条件演算子の一つ目はboolへ変換されて、評価される。その結果がtrueであれば二つ目が、そうでなければ、三つ目を値として出す？
    // (a ? 10 : 0)などは、最初の一本は合体コストなし、二本目からはコスト10がかかることを意味している。
    chmin(res,rec(i+1,a+L[i],b,c)+(a ? 10 : 0));
    chmin(res,rec(i+1,a,b+L[i],c)+(b ? 10 : 0));
    chmin(res,rec(i+1,a,b,c+L[i])+(c ? 10 : 0));

    return res;
}

int main(){
    cin>>N>>A>>B>>C;
    L.resize(N);
    rep(i,N)cin>>L[i];

    //再帰
    cout<<rec(0,0,0,0)<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 //#define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
//const int INF=4e18+10;
 const int INF=1e9+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}

void precomp()
{
}


void solve()
{
    int n;
    cin>>n;
    vector<int> cnt(24e4+1);
    for(int x = 1;x<=2e2; x++)
    {

        for(int y = 1;y<=2e2; y++)
        {

            for(int z = 1;z<=2e2; z++)
            {
                cnt[x*x + y*y + z*z + x*y + x*z + y*z]++;
            }
        }
    }
    for(int i= 1;i<=n;i++)
    {
        cout<<cnt[i]<<endl;
    }
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------
    precomp();
    int t = 1;
    // cin>>t;

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();

        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 4304
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

#include <bits/stdc++.h>
using namespace std;

signed main(){
    int W,H,A,B; cin>>W>>H>>A>>B;
    double ans = (double)W*H/2.0;
    int N = 0;
    if(W==2*A&&H==2*B) N = 1;
    cout<<ans<<" "<<N<<endl;
}

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




int main() {
  ll q;
  cin >> q;
  priority_queue <ll> l;
  priority_queue <ll, vector<ll>, greater <ll>> r;
  ll cnt=0;

  rep(i,q){
    ll Q;
    cin>>Q;

  //  ll ans=0;
    if(Q==1){
      ll a,b;
      cin>>a>>b;
      cnt+=b;
      l.push(a);
      r.push(a);
      ll l1=l.top();
      ll r1=r.top();
      l.pop();r.pop();
      if(l1>r1){
        swap(l1,r1);
        cnt+=abs(l1-r1);


      }
      l.push(l1);
      r.push(r1);
    }

    else if (Q==2){
      cout<<l.top()<<' '<<cnt<<endl;

    }
  }
}


Measured memory_bytes: 6552
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#include <map>


using namespace std;

typedef long long ll;
#define INF 0x3f3f3f3f
#define ESP 1e-8;
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
const double PI = acos(-1.0);

int a1[10], a9[10], l1, l9;
char str[10];

int main(){
    int i;
    while(scanf("%s", str+1)!=EOF){
        l1 = l9 = 0;
        for(i = 1; i <= 3; i++){
            if(str[i]=='1')
                a1[l1++] = i;
            else if(str[i]=='9')
                a9[l9++] = i;
        }
        for(i = 0; i < l1; i++)
            str[a1[i]] = '9';
        for(i = 0; i < l9; i++)
            str[a9[i]] = '1';
        printf("%s\n", str+1);
    }

    return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin >> N;
	vector<int>A(N);
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}

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

	for (int i = 1; i < N; i++){
		if (A[i] == A[i - 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    long long n, a, b;
    cin >> n >> a >> b;
    long long full = n / (a + b);
    cout << full * a + min(a, n % (a + b));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define pb push_back
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(false);cin.tie(0)
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 1e5+5;
const ll MOD = 1e9+7;

#define NIL -1
struct node
{
    int p, l, r;
} t[MAXN];
int n, depth[MAXN], height[MAXN];

void get_depth(int p, int d)
{
    if (p == NIL)
        return;
    depth[p] = d;
    get_depth(t[p].l, d+1);
    get_depth(t[p].r, d+1);
}

int get_height(int p)
{
    int h1 = 0, h2 = 0;
    if (t[p].l != NIL)
        h1 = get_height(t[p].l)+1;
    if (t[p].r != NIL)
        h2 = get_height(t[p].r)+1;
    return height[p] = max(h1, h2);
}

int get_sib(int p)
{
    if (t[p].p == NIL)
        return -1;
    if (t[t[p].p].l != p && t[t[p].p].l != NIL)
        return t[t[p].p].l;
    if (t[t[p].p].r != p && t[t[p].p].r != NIL)
        return t[t[p].p].r;
    return NIL;
}

int get_deg(int p)
{
    int ret = 0;
    if (t[p].l != NIL) ret++;
    if (t[p].r != NIL) ret++;
    return ret;
}

void print()
{
    rep(i, 0, n-1){
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, t[i].p, get_sib(i), get_deg(i), depth[i], height[i]);
        if (t[i].p == NIL)
            printf("root\n");
        else if (t[i].l == NIL && t[i].r == NIL)
            printf("leaf\n");
        else
            printf("internal node\n");
    }
    return;
}

int main()
{
    int root, id, l, r;
    cin >> n;
    rep(i, 0, n-1){
        t[i].p = t[i].l = t[i].r = NIL;
    }
    rep(i, 0, n-1){
        cin >> id;
        cin >> t[id].l >> t[id].r;
        if (t[id].l != NIL)
            t[t[id].l].p = id;
        if (t[id].r != NIL)
            t[t[id].r].p = id;
    }
    rep(i, 0, n-1){
        if (t[i].p == NIL){
            root = i;
            break;
        }
    }
    get_depth(root, 0);
    get_height(root);
    print();

    return 0;
}



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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<vector<int> > vec(N,vector<int>(2));
    for(int i=0; i<N; i++){
        vec[i] = {1,1000000000};
    }
    int tmp=0;
    for(int i=0; i<N; i++){
        int T;
        cin >> T;

        if (T==tmp){
            vec[i][1]=T;
        }else{
            vec[i]={T,T};
        }
        tmp=T;
    }
    tmp=0;
    vector<int> arr(N,0);
    for(int i=0; i<N; i++){
        cin >> arr[i];
    }
    for(int i=N-1; i>=0; i--){
        int A=arr[i];

        if (A==tmp){
            vec[i][1]=min(vec[i][1],A);
        }else{
            vec[i]={max(A,vec[i][0]),min(A,vec[i][1])};
        }
        tmp=A;
    }
    long long ans=1;
    for(int i=0; i<N; i++){
        ans*=max(0,vec[i][1]-vec[i][0]+1);
        ans%=1000000007;
    }
    cout << ans << endl;
}

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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

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

  if (X == 7 || X == 5 || X == 3)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
import numpy as np

L, R = map(int, input().split())

if R-L < 2019:
    ans = 10**20

    for i in range(L, R):
        ans = min(ans, np.min(np.arange(i+1, R+1) * i % 2019))
else:
    ans = 0
print(ans)

Measured memory_bytes: 12792
#include <iostream>
#include <vector>
#define MAX 100010

using namespace std;
vector<int> G[MAX];
int dp[MAX][12],v[MAX],d[MAX],c[MAX];

void dfs(int v, int d, int c){
	if(d>=0 && !dp[v][d]){
		dp[v][d] = c;
		dfs(v,d-1,c);
		for(int i=0;i<G[v].size();i++){
			dfs(G[v][i],d-1,c);
		}
	}
}

int main(){
	int i,j,n,m,q;
	cin >> n >> m ;
	for(i=0;i<m;i++){
		int s,t;
		cin >> s >> t;
		s--; t--;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	cin >> q;
	for(i=0;i<q;i++){
		cin >> v[i] >> d[i] >> c[i];
	}
	
	for(i=0;i<n;i++){
		for(j=0;j<=10;j++){
			dp[i][j] = 0;
		}
	}
	
	
	for(i=q-1;i>=0;i--){
		dfs(v[i]-1,d[i],c[i]);
	}
	
	for(i=0;i<n;i++){
		cout << dp[i][0] << endl;
	}
}
	

Measured memory_bytes: 12408
n = int(input())
l = list(map(int,input().split()))
ans = max(l)
for i in l:
  count = 0
  while i % 2 == 0:
    count += 1
    i //= 2
  ans = min(ans,count)
  if ans == 0:
    print(0)
    exit()
print(ans)
         

Measured memory_bytes: 3060
from typing import List, Union


class Stack():
    def __init__(self):
        self.top = 0
        self.max = 200
        self.lst = [None] * self.max

    def is_empty(self) -> bool:
        if self.top == 0:
            return True
        else:
            return False

    def is_full(self) -> bool:
        if self.top >= self.max - 1:
            return True
        else:
            return False

    def push(self, x: int) -> bool:
        if self.is_full() == True:
            print("ERROR: OVERFLOW")
            return False
        self.top += 1
        self.lst[self.top] = x
        return True

    def pop(self) -> Union[bool, int]:
        if self.is_empty() == True:
            print("ERROR: UNDERFLOW")
            return False
        self.top -= 1
        return self.lst[self.top + 1]


def main():
    lst: List = list(input().split())
    S = Stack()

    for char in lst:
        if char == "+":
            b = S.pop()
            a = S.pop()
            S.push(a + b)
        elif char == "-":
            b = S.pop()
            a = S.pop()
            S.push(a - b)
        elif char == "*":
            b = S.pop()
            a = S.pop()
            S.push(a * b)
        else:
            S.push(int(char))

    print(S.lst[S.top])


if __name__ == "__main__":
    main()



Measured memory_bytes: 7172
n = list(map(int, input().split()))
n = n[0]

ab=[]

for i in range(n):
    cd = list(map(int, input().split()))
    ab.append(cd)

ab = sorted(ab, key=lambda x:x[1])

#print(ab)

le = 0

flag = "Yes"

for i in range(n):
    le += ab[i][0]
    if(le>ab[i][1]):
        flag = "No"
        
print(flag)

Measured memory_bytes: 55252
L,M,N,i,g;
main(){
	for(;~scanf("%d",&L),L;){
		g=0;
		for(i=1;i<=12;i++){
			scanf("%d%d",&M,&N);
			L-=M-N;
			if(!g&&L<=0){
				printf("%d\n",i);
				g=1;
			}
		}
		if(!g)
			puts("NA");
		g=0;
	}
	exit(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 10007;
using namespace std;

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    int res = 0;


    for(int i = 1; i <= N; ++i)
    {
        int tar = i;
        int tmp = 0;

        while(tar/10 != 0)
        {
            tmp += tar % 10;
            tar /= 10;
        }
        tmp += tar % 10;

        if(A <= tmp && tmp <= B)
        {
            res += i;
        }
    }

    cout << res << endl;

    return 0;    
}



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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

vector<string> vs;
vector<vector<int>> vd;
vector<vector<bool>> used;
vector<pair<int, int>> ds = {
    {-1, 0}, {0, -1}, {0, 1}, {1, 0}
};
int h, w;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    cin >> h >> w;

    rep(i, h) {
        string s;
        cin >> s;
        vs.push_back(s);
        vd.emplace_back(vi(w, -1));
    }

    queue<pair<int,int>> que;
    rep(y, h) rep(x, w) {
        if (vs[y][x] == '#') {
            vd[y][x] = 0;
            que.emplace(x, y);
        }
    }

    int ans = 0;
    while(!que.empty()) {
        auto p = que.front();
        que.pop();

        for (auto& dp: ds) {
            int nx = p.first + dp.first;
            int ny = p.second + dp.second;
            
            if (0 <= nx and nx < w and 0 <= ny and ny < h and vd[ny][nx] < 0) {
                vd[ny][nx] = vd[p.second][p.first] + 1;
                ans = max(ans, vd[ny][nx]);
                que.emplace(nx, ny);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13456
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		double[] x = new double[num];
		String[] u = new String[num];
		double answer = 0;
		for(int i = 0; i < num; i++) {
			x[i] = sc.nextDouble();
			u[i] = sc.next();
			if(u[i].equals("BTC")) {
				answer += x[i]*380000.0;
			}
			else answer += x[i];
		}
		System.out.println(answer);
	}

}


Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}




struct KMP{

    string s;
    string t;
    int s_size,t_size;
    vector<bool> match;
    vector<int> table;

    KMP(string a, string b){
        s = a;
        t = b;
        s_size = s.size();
        t_size = t.size();
        match.resize(s.size());
        REP(i,s_size) match[i] = false;

        table.resize(t_size + 1);

        make_table();
        compute_match();
    }


    void make_table();

    void compute_match();

};


void KMP::make_table(){
    table[0] = -1;
    table[1] = 0;

    int j = 0;
    int i = 2;
    while(i < t.size() + 1){

        if(t[i-1] == t[j]){
            j += 1;
            table[i] = j;
        }
        else if(j > 0){
            j = table[j];
            i -= 1;
        }

        i += 1;
    }
}


void KMP::compute_match(){
    int m = 0,i = 0;

    while(m  < s_size){
        if(s[(m + i) % s_size] != t[i]){
            m = m + i - table[i];
            i = table[i];
            if(i == -1) i = 0;
            
        }
        else i += 1;
        if(i == t.size()){
            match[m] = true;
            m = m + i - table[i];
            i = table[i];
        }
    }


}

signed main(){

    string s,t;
    cin >> s >> t;
    if(s.size() < t.size()){
        return 0;
    }

    KMP kmp(s,t);
    int s_size = s.size(), t_size = t.size();
    REP(i,s_size - t_size + 1){
        if(kmp.match[i]) cout << i << endl;
    }

}


Measured memory_bytes: 5040