akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace _20190413
{
    class Program
    {
        public static void Main(string[] args)
        {
            using (var sc = new SetConsole())
            {
                int n = GetIntInput();
                var input = GetArrayIntInput();
                int count = 1;
                int currentMax = input[0];

                for (int i = 1; i < n; i++)
                {
                    if (0 <= input[i] - currentMax)
                    {
                        count++;
                        currentMax = Math.Max(input[i], currentMax);
                    }
                }
                CWrite(count);
            }
        }

        static string[] GetArrayCharInput() => Console.ReadLine().Split();
        static int[] GetArrayIntInput() => Console.ReadLine().StringToIntArray();
        static int GetIntInput() => Console.ReadLine().ToInt();
        static void CWrite<T>(T str) => Console.WriteLine(str);
    }



    class SetConsole : IDisposable
    {
        readonly StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
        public SetConsole()
        {
            sw.AutoFlush = false;
            Console.SetOut(sw);
        }
        public void Dispose()
        {
            Console.Out.Flush();
            sw.AutoFlush = true;
            Console.SetOut(sw);
        }
    }

    static class ExtentionsLibrary
    {
        public static int[] StringToIntArray(this string str) =>
            str.Split().Select(int.Parse).ToArray();
        public static int ToInt(this string str) => int.Parse(str);
    }
}


Measured memory_bytes: 11348
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int mod=1e9+7;

signed main()
{
    int N; cin>>N;
    vint cnt(N+1);
    for(int i=1;i<=N;i++){
        int t=i;
        for(int j=2;j*j<=t;j++){
            while(t%j==0){
                cnt[j]++;
                t/=j;
            }
        }
        if(t>1) cnt[t]++;
    }
    int ans=1;
    for(int i=2;i<=N;i++) ans=ans*(cnt[i]+1)%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
using namespace std;



int main() {
	int ab, bc, ca;
	cin >> ab >> bc >> ca;
	cout << ab * bc / 2 << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define lf long double
#define F first
#define S second
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <pair <ll,ll> >vii;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
#define mod 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    ll n=s.size();
    ll dp[n][13];
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<13;j++)
        {
            dp[i][j]=0;
        }
    }
    if(s[0]>='0' && s[0]<='9')
    {
        dp[0][s[0]-'0']++;
    }
    for(ll j=0;j<=9 && s[0]=='?';j++)
    {
        dp[0][j]=1;
    }
    for(ll i=1;i<n;i++)
    {
        if(s[i]=='?')
        {
            for(ll ele=0;ele<=9;ele++)
            {
                for(ll j=0;j<13;j++)
                {
                    ll prev=j;
                    ll ne=10*j+ele;
                    ne%=13;
                    dp[i][ne]+=dp[i-1][j];
                    dp[i][ne]%=mod;
                }
            }
        }
        else
        {
            ll ele=s[i]-'0';
            for(ll j=0;j<13;j++)
            {
                ll prev=j;
                ll ne=10*j+ele;
                ne%=13;
                dp[i][ne]+=dp[i-1][j];
                dp[i][ne]%=mod;
            }
        }
    }
    cout<<dp[n-1][5]<<endl;
}


Measured memory_bytes: 10704
void main() {
    int[] tmp = readln.split.to!(int[]);
    int a = tmp[0], b = tmp[1];
    writeln((a + b) % 24);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

using namespace std;

int main(void) {
    int64_t N, K;
    cin >> N >> K;
    if(K == 0) {
        cout << N*N << endl;
    } else {
        int64_t ans = 0;
        for(int64_t b=K+1; b<=N; b++) {
            int64_t n = (N+1) / b;
            ans += n * (b-K);
            // cout << b << " " << n << " " << n*(b-K) << endl;
            ans += max(N - (n*b-1LL) - K, 0LL);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;

int main(){
    string s;
    int cnt ;
    cin >> s;
    vector<int> v(s.length(),0);
    for(int i = 0;i < s.length();i++){
        if((s[i] == 'A')||(s[i] == 'C')||(s[i] == 'G')||(s[i] == 'T')){
            cnt += 1;
            v.at(i) = cnt;
        }
        else{
            cnt = 0;
            v.at(i) = cnt;
        }
    }
    int max = *max_element(v.begin() , v.end());
    cout << max << endl;
}

Measured memory_bytes: 256
#演習2-18

def solve(N,P,Q,menu):
    all_happy = [P*(Q-i) - menu[i] for i in range(N)] 
    all_happy = sorted(all_happy, reverse = True) 
    happy = [sum(menu)] 
    for i in range(N):
        happy.append(happy[-1] + P*i*2 + all_happy[i])
    return(max(happy))




while True:
    try:
        
        N,P,Q = map(int,input().split())
        menu = []
        for i in range(N):
            menu.append(int(input()))
        print(solve(N,P,Q,menu))
    except:
        break


    
    


Measured memory_bytes: 72908
#include <bits/stdc++.h>
#define ll long long
#define eps 1e-9
#define PI 2 * acos (0.0)
using namespace std;

int ar[100005];


int main()
{

  
    int a,b,c,d,e,x,y,z;

    cin>>x>>y;

    string st;

    while(x--)
    {
        cin>>st;
        cout<<st<<endl<<st<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
K = int(input())

N = [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]

print(N[K-1])

Measured memory_bytes: 3060
#!/usr/bin/env ruby
k = gets.chomp.to_i

gcd_arr = Array.new(k+1, 0)


def gcd(m, n)
  m, n = n, m if n >= m

  return m if n == 0

  gcd(n, m % n)
end

ans = 0
1.upto(k) do |i|
  1.upto(k) do |j|
    x = gcd(i, j)

    1.upto(k) do |k|
      ans += gcd(x, k)
    end
  end
end

puts ans


Measured memory_bytes: 14404
#include <stdio.h>
int main(void)
{
    int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
    
    if(a==b+c) printf("Yes\n");
    else if(b==a+c) printf("Yes\n");
    else if(c==a+b) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1e9 + 7

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

    int a,b;
    
    cin >> a >> b;
    
    cout << b*2-a;
}


Measured memory_bytes: 892
n = int(input())
a,b = map(int, input().split())
cnta = cntb = cntc = 0
for p in map(int, input().split()):
    if p <= a:
        cnta += 1
    if a < p <= b:
        cntb += 1
    if b < p:
        cntc += 1
print(min(cnta, cntb, cntc))


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

int main(){
    ll n,l,r;
    while(1){
        cin>>n>>l>>r;
        if(n==0&&r==0&&l==0)break;
        ll a[n];
        for(ll i=0;i<n;i++)cin>>a[i];
        ll res = 0;
        bool flag=false;
        for(ll i=l;i<=r;i++){
            flag=false;
            for(ll j=0;j<n;j++){
                if(i%a[j]==0){
                    if((j+1)%2==1){
                        res++;
                        //cout<<i<<endl;
                        flag=true;
                    }else{
                        flag=true;
                    }
                    break;
                }
            }
            if(!flag){
                if(n%2==0)res++;
            }
        }
        cout<<res<<endl;
    }
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstring>
using namespace std;
int pd[100010],arr[100010];
int main()
{
    int n,ans=0,T=0;
    cin>>n;
    arr[0]=10;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
        if(arr[i]==i) {
            if(T==0&&arr[i-1]==i-1)
            {
                T=1;
            }
            else {ans++;T=0;}
        }
        
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
INF = float("inf")
from collections import defaultdict


def solve(N: int, M: int, p: "List[int]", x: "List[int]", y: "List[int]"):

    par = list(range(N+1))

    def root(i):
        if par[i] == i:
            return i
        else:
            par[i] = root(par[i])
            return par[i]

    def same(x, y):
        return root(x) == root(y)

    def unite(x, y):
        x = root(x)
        y = root(y)
        if x != y:
            par[x] = y

    for i in range(M):          # O(M)
        unite(x[i], y[i])

    counter = 0
    for i in range(N):
        if same(p[i], i+1):
            counter += 1
    print(counter)

    return


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
    M = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    x = [int()] * (M)  # type: "List[int]"
    y = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, M, p, x, y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19748
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<functional>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
#include <stack>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	int a, b;
	char s;
	string ans="Yes";
	cin >> a >> b;
	for (int i = 0;i < a;i++) {
		cin >> s;
		if (!(s >= '0' && s <= '9')) {
			ans = "No";
		}
	}
	cin >> s;
	if (s != '-')ans = "No";
	for (int i = 0;i < b;i++) {
		cin >> s;
		if (!(s >= '0' && s <= '9')) {
			ans = "No";
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int N,surface,max,i;
  scanf("%d",&N);

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

  surface=0;
  max=1;
  for(i=0; i<N; i++){
    if(A[i]==1)
      surface++;
    else if(A[i]==0){
      if(max<surface+1)
	max=surface+1;
      surface=0;
    }
    if(max<surface+1)
      max=surface+1;
  }
  printf("%d\n",max);
  return 0;
}



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

int	main()
{
  long a, b, c, d;
  vector<long> v(4);
  
  cin >> a >> b >> c >> d;
  v.at(0) = a * c;
  v.at(1) = a * d;
  v.at(2) = b * c;
  v.at(3) = b * d;
  sort(v.begin(), v.end());
  cout << v.at(3) << endl;
  return (0);
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define F first
#define S second
#define pii pair<int,int>
#define pb push_back
typedef long long ll;
using namespace std;
const int N = 3 * 1e5 + 10 , M = 1e5 + 10 , LOG = 20 , inf = 1e9;
pii l[N];
int ans[M] , seg[LOG][N];

void build(int lg , int s , int e){
    if(e - s < 2){
        seg[lg][s] = l[s].S;
        return ;
    }int mid = (s + e)/2;
    build(lg + 1 , s , mid);
    build(lg + 1 , mid , e);
    merge(seg[lg + 1] + s , seg[lg + 1] + mid , seg[lg + 1] + mid , seg[lg + 1] + e , seg[lg] + s);
    return ;
}

int get(int lg , int L , int R , int s , int e , int v){
    if(L<=s && e<=R){
        return lower_bound(seg[lg] + s , seg[lg] + e , v) - (seg[lg] + s);
    }if(L>=e || s>=R)return 0;
    int mid = (s + e)/2;
    return get(lg + 1 , L , R , s , mid , v) + get(lg + 1 , L , R ,mid , e , v);
}

int main(){
    int n , m; cin >> n >> m;
    for(int i=0;i<n;i++)cin >> l[i].F >> l[i].S;
    sort(l , l + n);
    build(0 , 0 , n); int d;
    for(d=1;d*d<=m;d++){
        for(int i=0;i<n;i++){
            if((l[i].S / d) * d >= l[i].F)ans[d]++;
        }
    }//cout << d << " SHIR " << endl;
    for(;d<=m;d++){
        ans[d] = n;
        for(int j=d;j<=m;j+=d){
            int indL = upper_bound(l , l + n , pii(j - d , inf)) - l;
            int indR = lower_bound(l , l + n , pii(j , 0)) - l;
            ans[d] -= get(0 , indL , indR , 0 , n , j);
        }
        int ls = (m / d) * d;
        ans[d] -= n - (upper_bound(l , l + n , pii(ls , inf)) - l);
    }
    for(int d=1;d<=m;d++)cout << ans[d] << '\n';
}


Measured memory_bytes: 27136
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

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

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

int main(void) {
    int N;
    cin >> N;
    vector<int> P(N,0), Q(N,0), R(N,0);
    for (int i=0;i<N;i++) cin >> P[i];
    for (int i=0;i<N;i++) cin >> Q[i];
    iota(R.begin(), R.end(), 1);
    int a = 0, b = 0, c = 1;
    if (P == R) a = c;
    if (Q == R) b = c;
    while (next_permutation(R.begin(), R.end())) {
        c++;
        if (P == R) a = c;
        if (Q == R) b = c;
        if (a && b) break;        
    }
    cout << abs(a-b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<string> s(n);
	rep(i, n) cin >> s[i] >> a[i];
	string x;
	cin >> x;
	int ans = 0;
	bool flag = false;
  int k;
	rep(i, n) {
		if (s[i] == x){
          flag = true;
          k=i;
        }
		if (flag) ans += a[i];
	}
  ans-=a[k];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P;
typedef vector<int> Vi;
int const MOD = 1000000007;
double const PI = acos(-1);
template<class T> inline bool chmin(T& a, T b) { if (a > b) { return a = b; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { return a = b; } return false; }


int main(){
    cin.tie(0); ios::sync_with_stdio(false);
   
    int n,k; cin>>n>>k; Int a[n],ans=0; vector<Int> s;
    for (int i = 0; i < n; i++)cin>>a[i];
    for (int i = 0; i < n; i++){
        Int sum=0;
        for (int j = i; j < n; j++){sum+=a[j]; s.push_back(sum);}
    }
    for (int i = 40; i >= 0; i--){
        vector<Int> use;
        for (auto j:s){if((j>>i)&1LL)use.push_back(j);}
        if(use.size()>=k){ans+=(1LL<<i); s=use;}
    }
    cout<<ans<<'\n';
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define check if (false_max > final) final = false_max

int main() {
	int n, temp; cin >> n; 
	int false_max = 0; int final = 0;
	rep(i, n) {
		cin >> temp;
		if (temp == 1) false_max++;
		else { check; false_max = 0; }
	}
	check; cout << final + 1 << endl;
	return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__ << '\n';

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
int main()
{
	ll i,n;
	cin >> n;
	vl a(n);
	forn(0,n,i)
		cin >> a[i];
	//solve(0ll);
	vl dp(n,0);
	for(i=1;i<n;i++)
	{
		if(i >= 2)
		{
			dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]),dp[i-2] + abs(a[i] - a[i - 2]));
		}
		else
		{
			dp[i] = abs(a[i] - a[i - 1]);
		}
	}
	cout << dp[n-1] << '\n';
}












Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] numbers = new long[N];
		long[] cnts = new long[N];
		for (int i=0;i<N;i++) {
			long n = sc.nextLong();
			numbers[i] = n;
			cnts[(int) (n-1)]++;
		}
//		System.out.println(Arrays.toString(cnts));
		long[][] kumis = new long[2][N];
		int i = 0;
		for(long c:cnts) {
			if (c!=0) {
				kumis[0][i]= c*(c-1)/2;
				if(c!=1) {
					kumis[1][i]= (c-2)*(c-1)/2;
				}
			}
			i++;
			
		}
//		System.out.println(Arrays.toString(kumis[0]));
		long total = Arrays.stream(kumis[0]).sum();
		for(long n :numbers) {
			long ans = total-kumis[0][(int) (n-1)]+kumis[1][(int) (n-1)];
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 107772
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
# define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(bool f) { if(f) return "True"; else return "False";}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }

/************/

signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		string s;
		cin >> s;
		rep(i,0,sz(s)){
			if(s[i]!='?') continue;
			s[i] = 'D';
		}
		int ans = 0;
		for(auto j:s) if(j=='D') ans++;
			rep(i,0,sz(s)-1){
				if(s[i]=='P' and s[i+1] == 'D') ans++;
			}
		cout << s;
		// trace(ans);
	}
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

int main(){
    int n;
    int ans = 0;
    cin >> n;
    vector<int> a;
    vector<int> b;
    vector<int> c;

        b.pb(0);
    c.pb(0);

    REP(i,n){
        int t;
        cin >> t;
        a.pb(t);
    }

    REP(i,n){
        int t;
        cin >> t;
        b.pb(t);
    }
    REP(i,(n-1)){
        int t;
        cin >> t;
        c.pb(t);
    }

    int preveat = -1;

    REP(i,n){
        ans+=b[a[i]];
        if((preveat + 1) == a[i]) ans += c[preveat];
        preveat = a[i];
    }
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  int fors = 0;
  int odd = 0;
  int even = 0;
  for(int i=0;i<N;++i){
    int p;
    cin >> p;
    if(p%4==0){
      fors++;
    }else if(p%2==0){
      even++;
    }else{
      odd++;
    }
  }
  if(odd > fors){
    if(odd == fors+1 && even==0){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }else{
    cout<<"Yes"<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
k, n = map(int, input().split())
a = list(map(int, input().split()))
a += [k]
x = [a[0]]
for i in range(n):
    _a = a[i+1] - a[i]
    x += [_a]
x[0] = x[0]+x[-1]
x = x[:-1]
x.remove(max(x))
print(sum(x))

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

int main() {
  int N;
  cin >> N;
  string S, T;
  
  for(int i = 0; i < N; i++){
    
    cin >> S;
    
    if(S == "Y"){
     T = "Four";
     break;
   }
    else{
     T = "Three";
   }
  }
    cout << T << endl;
}


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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 a, b; cin >> a >> b; cout << a * b << " " << (a + b) * 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int N; cin >> N;
  for (int i = 1; i <= N; ++i) {
    auto x = i * 108 / 100;
    if (x == N) {
      cout << i << CRLF;
      return;
    }
  }
  cout << ":(" << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

typedef pair<int,int> P;
typedef vector<P> Vp;
typedef vector<Vp> Mp;

int N;
int objective_flag;
int objective_number;
vector<string> s;
vector<int> in_count;
string longest = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
string ans;

void dfs(Mp& up, int now, int point, string str, int used) {
    str += string(s[now].begin() + point, s[now].end());
    for (int i = 0; i < N; i++) {
        if (objective_flag & (1<<i) && ~used & (1<<i)) {
            if (str.find(s[i]) != string::npos)
                used |= (1 << i);
        }
    }
    if ((~used & objective_flag) == 0) {
        if (str.size() < ans.size() || (ans.size() == str.size() && str < ans)) ans = str;
    }

    if (ans.size() < str.size()) return ;

    auto res = ans;

    for (int i = 0, len = up[now].size(); i < len; i++) {
        int next = up[now][i].first;
        int npoint = up[now][i].second;

        if (used & (1 << next)) continue;
        dfs(up, next, npoint, str, used | (1 << next));
    }

    if (up[now].size() == 0) {
        for (int i = 0; i < N; i++) {
            if (objective_flag & (1 << i) && ~used & (1<<i)) {
                dfs(up, i, 0, str, used | (1<<i));
            }
        }
    }
}

void solve() {
    s.resize(N);
    for (auto& i : s) cin >> i;
    in_count.resize(0);
    in_count.resize(N);
    sort(s.begin(), s.end());

    Mp unite_point(N);
    vector<bool> erased(N, false);
    objective_flag = 0;
    objective_number = 0;
    for (int i = 0; i < N; i++) {
        if (!erased[i]) objective_flag |= (1<<i);
        if (erased[i])objective_number++;
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if(i == j) continue;
            if (erased[i] || erased[j]) continue;
            int K = 0;
            for (int k = 1, len = min(s[i].size(), s[j].size()); k < len; k++) {
                auto s1 = string(s[i].end() - k, s[i].end());
                auto s2 = string(s[j].begin(), s[j].begin() + k);
                if (s1 == s2) {
                    K = max(k, K);
                    in_count[j]++;
                }
            }
            unite_point[i].push_back(P(j, K));
        }
    }

    ans = longest;
    for (int i = 0; i < N; i++) {
        if (!erased[i]) {
            dfs(unite_point, i, 0, "", 1 << i);
        }
    }
    cout << ans << endl;
}

int main() {
    while (cin >> N, N) solve();

    return 0;
}

Measured memory_bytes: 3244
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace COJ1_7
{
    public class Node
    {
        public int value;
        public Node parent;
        public Node left;
        public Node right;
    }
    class Program
    {

        static void Main(string[] args)
        {
            Node root = new Node();
            int cnt = int.Parse(Console.ReadLine());

            while (cnt-- > 0)
            {
                var command = Console.ReadLine().Split(' ');
                switch (command[0])
                {
                    case "insert": Insert(root, int.Parse(command[1])); break;
                    case "find": Find(root, int.Parse(command[1]));break;
                    default: Print(root); break;
                }
            }
        }

        public static void Insert(Node node, int key)
        {
            Node x = node;
            Node y = null;
            while (x != null&&x.value!=0)
            {
                y = x;
                if (key < x.value)
                    x = x.left;
                else x = x.right;
            }
            Node tmp = new Node();
            tmp.value = key;
            tmp.parent = y;

            if (y==null) 
            {
                node.value = key;
            }
            else if (key < y.value)
            {
                y.left = tmp;
            }
            else
            {
                y.right = tmp;
            }
        }

        public static void Find(Node node, int key)
        {
            Node x = node;
            while (x != null)
            {
                if (key < x.value) x = x.left;
                else if(key>x.value) x = x.right;
                else
                {
                    Console.WriteLine("yes");
                    return;
                }
            }
            Console.WriteLine("no");
        }

        public static void Print(Node node)
        {
            StringBuilder builder = new StringBuilder();
            InOrder(node, builder);
            builder.Append("\n");
            PreOrder(node, builder);
            builder.Append("\n");
            Console.Write(builder.ToString());
        }
        public static void InOrder(Node node, StringBuilder builder)
        {
            if (node == null) return;
            InOrder(node.left, builder);
            builder.Append(" ").Append(node.value);
            InOrder(node.right, builder);
        }
        public static void PreOrder(Node node, StringBuilder builder)
        {
            if (node == null) return;
            builder.Append(" ").Append(node.value);
            PreOrder(node.left, builder);
            PreOrder(node.right, builder);
        }
    }
}

Measured memory_bytes: 72144
n=int(input())
a=[]
b=[]
for i in range(n):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
a=sorted(a)
b=sorted(b,reverse=True)
if n%2==1:
    x=1+n//2
    print(b[x-1]-a[x-1]+1)
else:
    x=n//2
    print(b[x-1]+b[x]-a[x-1]-a[x]+1)
    

Measured memory_bytes: 27000
from collections import deque
N = int(input())
E = [[] for _ in range(N)]
  
for i in range(N-1):
  a,b = list(map(int, input().split()))
  a,b = a-1, b-1
  # 出力のために、何番目のEdgeだったかを保有させる必要がある
  E[a].append([i,b])
  E[b].append([i,a])
  
k = 0
for e in E:
  k = max(k, len(e))
print(k)


def bfs():
  colors = [-1 for _ in range(N-1)]
  visited = [False for _ in range(N)]
  d = deque()
  d.append([0,-1])
  while d:
    now,edge_color = d.pop()
    visited[now] = True
    cand_color = 1
    for i, nxt in E[now]:
      #print(i, nxt, visited[i], colors[i])
      if visited[nxt]:
        continue # TreeでBFSだとここは通らない・・・？
      if colors[i] > -1:
        assert("１エッジに２色塗ろうとする・・・？")
        continue
      if cand_color == edge_color:
        cand_color += 1
      colors[i] = cand_color
      d.append([nxt, colors[i]])
      cand_color += 1
  return colors

colors = bfs()

for i in range(len(colors)):
  print(colors[i])

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

using namespace std;

const int INF=1000000000;

int main(){
        int n, m;
        cin>>n>>m;
        int a[1000], b[1000], c[1000], dist[100][100];
        for(int i=0;i<m;i++){
                cin>>a[i]>>b[i]>>c[i];
                a[i]--;b[i]--;
        }
        for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                        if(i==j){
                                dist[i][j]=0;
                        }
                        else{
                                dist[i][j]=INF;
                        }
                }
        }
        for(int i=0;i<m;i++){
                dist[a[i]][b[i]]=min(dist[a[i]][b[i]], c[i]);
                dist[b[i]][a[i]]=min(dist[b[i]][a[i]], c[i]);
        }
        //ワーシャルフロイド
        for(int k=0;k<n;k++){
                for(int i=0;i<n;i++){
                        for(int j=0;j<n;j++){
                                dist[i][j]=min(dist[i][j], dist[i][k]+dist[k][j]);
                        }
                }
        }
        int ans=m;
        for(int i=0;i<m;i++){
                bool shortest=false;
                for(int j=0;j<n;j++){
                        if(dist[j][a[i]]+c[i]==dist[j][b[i]])
                                shortest=true;
                }
                if(shortest==true){
                        ans=ans-1;
                }
        }
        cout<<ans<<endl;
}


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

int main() {
    // 例 1: 2 つの整数 a, b を入力し、a と b の最大公約数と最小公倍数を出力する
   	int a,b,c;
  	int k;
  	int sum=0;
    cin >> a >> b >> c >>k;
  
  	if(k-a >= 0) sum += a;
  	else sum+= k;
  	
  	if(k-a-b> 0) sum -= (k-a-b);
    cout << sum;
  	
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define inchar			getchar
#define outchar(x)		putchar(x)
#define ll long long 
#define int long long //
#define all(v) v.begin(), v.end()
#define SP outchar(' ')
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
#define LN outchar('\n')
using namespace std;

template<typename T> void inpos(T &x){x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=0; if(c=='-')neg=1;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}
template<typename T> void outpos(T n){if(n<0){outchar('-');n*=-1;}char snum[65];int i=0;do{snum[i++]=n%10+'0';n/=10;}while(n);i=i-1;while(i>=0)outchar(snum[i--]);}
inline void instr(char *str){register char c=0;register int i=0;while(c<33)c=inchar();while(c!='\n'&&c!=' '&&c!=EOF){str[i]=c;c=inchar();++i;}str[i]='\0';}


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

	int n;cin>> n;vector <int> arr(n);
	for(int i = 0; i<n;i++) {
		cin >> arr[i];
	}
	vector <int> minCost(n);
	minCost[0] = 0;
	minCost[1] = abs(arr[1] - arr[0]);
	for(int i = 2; i<n;i++) {
		minCost[i] = min(minCost[i-2] + abs(arr[i-2] - arr[i]) , minCost[i-1] + abs(arr[i-1] - arr[i]) );
	}
	cout << minCost.back() <<endl; 
	
}

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

int dist[400][400];

int main(){
	int H,W;
	cin >> H >> W;
	vector<string> A(H);
	for(auto &i:A)cin >> i;
	
	for(int i=0;i<H*W;i++)for(int j=0;j<H*W;j++){
		if(i==j)dist[i][j]=0;
		else dist[i][j]=444;
	}
	
	for(int i=0;i<H;i++)for(int j=0;j<W;j++){
		int x=i*W+j;
		int y=x+1;
		int z=x+W;
		if(j<W-1 && A[i][j]=='.' && A[i][j+1]=='.')dist[x][y]=dist[y][x]=1;
		if(i<H-1 && A[i][j]=='.' && A[i+1][j]=='.')dist[x][z]=dist[z][x]=1;
	}
	
	for(int i=0;i<H*W;i++)for(int j=0;j<H*W;j++)for(int k=0;k<H*W;k++){
		dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
	}
	
	int ans=0;
	for(int i=0;i<H*W;i++)for(int j=0;j<H*W;j++)if(dist[i][j]<444)ans=max(ans,dist[i][j]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 896
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let t: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let a: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let mut hv = vec![0i32; n];
    for i in 0..(n - 1) {
        hv[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    hv[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut min_b = (a * 1000 - (t * 1000 - hv[0] * 6)).abs();
    let mut ans = 1;
    for i in 1..n {
        let b = (a * 1000 - (t * 1000 - hv[i] * 6)).abs();
        if b < min_b {
            min_b = b;
            ans = i + 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
	int n,a[100],i;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=0;i<n;i++)
		if(a[i]%2==0)
			if((a[i]%3!=0)&&(a[i]%5!=0)){
				printf("DENIED\n");
				return 0;
			}
	printf("APPROVED\n");
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
int main(){
	#define ll long long
	ll n, w;
	cin>>n>>w;
	vector<pair<ll,ll>> v(n);
	for(int i=0;i<n;i++)
		cin>>v[i].first>>v[i].second;
	vector<ll> dp(100100,1e18); //dp[i]=min weigth for value i
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=100010;j>=0;j--){
			if(j+v[i].second<100010)
				dp[j+v[i].second]=min(dp[j+v[i].second],dp[j]+v[i].first);
		}
	}
	int ans=0;
	for(int i=0;i<100100;i++)
		if(dp[i]<=w)
          	ans=i;
  cout<<ans;
}


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

char S[100];
char T[100];
int snum = 0;
int tnum = 0;
int swapcount = 0;

int compare();
void swap();

int main()
{
    scanf("%s", S);
    scanf("%s", T);

    snum = strlen(S);
    tnum = strlen(T);

    if (snum != tnum)
    {
        exit(1);
    }
    
    if (compare() == 1)
    {
        printf("Yes\n");
    }
    else
    {
        while (swapcount != snum)
        {
            swap();
            swapcount++;
            if(compare() == 1){
                break;
            }
        }
        if (compare() == 1)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
    return 0;
}

int compare()
{
    int count = 0;

    for (int i = 0; i < snum; i++)
    {
        if (S[i] == T[i])
        {
            count++;
        }
    }

    if (snum == count)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

void swap()
{
    char sfirst = S[0];

    for (int i = 0; i < snum; i++)
    {
        S[i] = S[i + 1];
    }
    S[snum -1] = sfirst;
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  ll N; cin >> N;
  string ans = "";
  while(N > 0){
    N--;
    ll tmp = N % 26;
    char c = 'a' + tmp;
    ans = c + ans;
    // cerr << ans << endl;
    N /= 26;
  }
  cout << ans << endl;

}


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

int main()
{
  int x, a, b;
  cin >> x >> a >> b;
  //
  if(a >= b)
  {
    cout << "delicious";
  }
  else if(a < b && a + x >= b)
  {
    cout << "safe";
  }
  else
  {
    cout << "dangerous";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  ll n;
  cin >> n;
  vector<ll> a(n);  rep(i, 0, n) cin >> a[i];
  sort(all(a));
  ll m = 1;
  ll inf = 1000000000000000000;
  rep(i, 0, n) {
    if(a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
    else if(m > inf/a[i]) {
      cout << -1 << endl;
      return 0;
    }
    else m *= a[i];
  }
  cout << m << "\n";
}

Measured memory_bytes: 3988
def main():
    from decimal import Decimal

    N, A, B = map(int, input().split())
    *v, = map(Decimal, input().split())

    v.sort(reverse=True)

    max_average = sum(v[:A]) / A

    tail = v[A - 1]
    contained = [0] * (N + 1)
    s = 0
    for i, x in enumerate(v, start=1):
        if x == tail:
            s += 1
        contained[i] = s

    def choose(n, a):
        if n - a < a:
            return choose(n, n - a)
        x, y = 1, 1
        for i in range(a):
            x = x * (n - i)
            y = y * (i + 1)
        return x // y

    count = 0
    for k in range(A, B + 1):
        if (k > A) and (v[k - 1] != max_average): break
        count += choose(contained[-1], contained[k])

    print(max_average)
    print(count)


if __name__ == '__main__':
    main()

# editorial
# K個選んだときの品物の価値の平均の最大値と
# K+1個個選んだときの品物の価値の平均の最大値の差を比較

# v[:A]は一つの値からなる->平均値を下げずに要素を追加できる可能性
# v[:A]は異なる値を含む->範囲外の値はより小さいので要素を追加できない


Measured memory_bytes: 5204
a_red,b_green,c_blue = list(map(int,input().split()))
kai = int(input())

for i in range(kai+1):
    if a_red >= b_green:
        b_green = b_green *2
    elif b_green >= c_blue:
        c_blue = c_blue *2
    else:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (b==0) return a;
    else{
    	return gcd(b,a%b);
    }
}
 
int main() {
	ll a,b,c;
  	cin >> a >> b >> c;
  	if(0< -b+c && -b+c <= a){
      cout << "safe" << endl;
    }
  	else if(a+b>c){
      cout << "delicious" << endl;
    }
  	else{
      cout << "dangerous" << endl;
    }
  	
}

Measured memory_bytes: 256
s = int(input())

flag1 =  0< s//100 <= 12
flag2 =  0< s%100 <= 12

ans = ""

if flag1 and flag2:
    ans = "AMBIGUOUS"
elif not flag1 and flag2:
    ans = "YYMM"
elif flag1 and not flag2:
    ans = "MMYY"
else:
    ans = "NA"

if s/100==0 and flag2:
    ans = "YYMM"
if s%100==0 and flag1:
    ans = "MMYY"

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<climits>
#include<string>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<math.h>
#include<algorithm>
using namespace std;

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

int N,K;

#define INF ( 1 << 30 )
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

int main()
{
    // get a integer
    ll N, L;
    scanf( "%lld", &N );
    scanf( "%lld", &L );
    vector<string> v;
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        v.push_back( s );
    }
    sort(v.begin(), v.end(), []( const string& a, const string&  b) -> bool {
            /* cout << a << "," << b << " : " << strcmp( a.c_str(), b.c_str() ) << endl; */
            return strcmp( a.c_str(), b.c_str() ) < 0; 
            }
            );

    for (int i = 0; i < N; ++i) {
        cout << v[i];
    }
    cout << endl;

    /* for (auto&& v_ : v) { */
    /*     cout << v_ << endl; */
    /* } */

    /* auto it = v.begin(); */
    /* if( *it++ == 5 && *it++ == 5 && *it == 7 ) printf( "YES" ); */
    /* else printf( "NO" ); */

    /* printf( "%lld\n", N ); */
    /* printf( "%lld\n", K ); */
}



Measured memory_bytes: 256
from itertools import product

#入力
N,M=map(int,input().split())
ks=[list(map(int,input().split())) for _ in range(M)]
p=[int(x) for x in input().split()]

ans=0
for i in product([0,1],repeat=N):
    ok=True
    for j in range(M):
        j_on_cnt=0
        for k in ks[j][1:]:
            j_on_cnt+=i[k-1]
            
        if j_on_cnt % 2!=p[j]:
            ok=False
            break
    if ok:
        ans+=1
print(ans)
        
    

Measured memory_bytes: 9108
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

// const ll mod = 1e9 + 7;
const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

bool isOK(vi& a, ll k, ll index) {
	return a[index] < k * (index + 1);
}

ll binary_search(vi& a, ll k) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		if (isOK(a, k, mid))
			right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

template<class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
	return os << "{" << p.first << "," << p.second << "}";
}

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

int main() {
	ll N;
	cin >> N;

	vi A(N);

	rep(i, N) {
		cin >> A[i];
	}

	sort(all(A));

	vi T(N);

	ll t = 0;
	ll a = A[0];
	ll kind = 0;

	repa(i, 1, N) {
		if (a == A[i]) {
			t++;
		}
		else {
			T[t]++;
			kind++;
			a = A[i];
			t = 0;
		}
	}
	T[t]++;
	kind++;

	vi S(N);
	rep(i, N) {
		if (i == 0) {
			S[i] = kind;
		}
		else {
			S[i] = S[i - 1] + kind;
		}

		kind -= T[i];
	}

	/*
	for (ll k : S) {
		cout << k << " ";
	}
	cout << endl;
	//*/

	rep(i, N) {
		cout << binary_search(S, i+1) << endl;
	}

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

Measured memory_bytes: 7936