akhauriyash/Code-Regression huggingface dataset:
N,A,B,C=map(int,input().split())

S=['']*N
for i in range(N):
    S[i]=input()

result=[]
kekka=True


for i in range(N):
    if (A==0 and B==0 and S[i]=='AB') or (C==0 and B==0 and S[i]=='BC') or (A==0 and C==0 and S[i]=='AC'):
        kekka=False
        break
    else:
        if S[i]=='AB':
            if A==0:
                A += 1
                B -= 1
                result.append('A')
            elif B==0:
                A -=1
                B +=1
                result.append('B')
            elif A==1 and B==1 and C==0 and i !=N-1:
                if S[i+1]=='AC':
                    A += 1
                    B -= 1
                    result.append('A')
                else:
                    A -=1
                    B +=1
                    result.append('B')
            elif A>B:
                A -=1
                B +=1
                result.append('B')
            else:
                A +=1
                B -=1
                result.append('A')
        elif S[i]=='AC':
            if A==0:
                A += 1
                C -= 1
                result.append('A')
            elif C==0:
                A -=1
                C +=1
                result.append('C')
            elif A==1 and C==1 and B==0 and i != N-1:
                if S[i+1]=='AB':
                    A += 1
                    C -= 1
                    result.append('A')
                else:
                    A -=1
                    C +=1
                    result.append('C')
            elif A>C:
                A -=1
                C +=1
                result.append('C')
            else:
                A +=1
                C -=1
                result.append('A') 
        else:
            if B==0:
                B += 1
                C -= 1
                result.append('B')
            elif C==0:
                B -=1
                C +=1
                result.append('C')
            elif B==1 and C==1 and A==0 and i != N-1:
                if S[i+1]=='AB':
                    B += 1
                    C -= 1
                    result.append('B')
                else:
                    B -=1
                    C +=1
                    result.append('C')
            elif B>C:
                B -=1
                C +=1
                result.append('C')
            else:
                B +=1
                C -=1
                result.append('B')

if kekka ==False:
    print('No')
else:
    print('Yes')
    for i in range(N):
        print(result[i])            




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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

long long r[N], g[N];
priority_queue<long long> pq;

void solve() {
  int x, y, a, b, c; scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);
  for (int i = 0; i < a; ++i) scanf("%lld", r+i);
  for (int i = 0; i < b; ++i) scanf("%lld", g+i);
  for (int t, i = 0; i < c; ++i) {
    scanf("%lld", &t);
    pq.push(t);
  }
  sort(r, r+a, greater<long long>());
  sort(g, g+b, greater<long long>());
  long long ans = 0;
  for (int i = 0; i < x; ++i) {
    ans += r[i];
    if (pq.empty() || pq.top() <= r[i]) continue;
    ans = ans-r[i]+pq.top();
    pq.pop();
    pq.push(r[i]);
  }
  for (int i = 0; i < y; ++i) {
    ans += g[i];
    if (pq.empty() || pq.top() <= g[i]) continue;
    ans = ans-g[i]+pq.top();
    pq.pop();
    pq.push(g[i]);
  }
  printf("%lld", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

int main(){
    int n;
    int a,b;
    int i,j;
    char t;
char t1[1000];
char t2[1510];
char t3[1510];
    scanf("%s",&t1);
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",&t3);
        if(strcmp(t3,"replace")==0){
            scanf("%d %d %s",&a,&b,&t2);
            for(j=0;j<b-a+1;j++){
                t1[a+j]=t2[j];
            }
        }
        else if(strcmp(t3,"reverse")==0){
            scanf("%d %d",&a,&b);
            for(;a<b;){
                t=t1[a];
                t1[a]=t1[b];
                t1[b]=t;
                a++;
                b--;
            }
        }
        else if(strcmp(t3,"print")==0){
            scanf("%d %d",&a,&b);
            for(j=a;j<b+1;j++){
                printf("%c",t1[j]);
            }
             printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>

using namespace std;

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

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

typedef long long ll;

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

    double r; cin >> r;
    const double PI = (acos(-1));
    printf("%.6lf %.6lf\n",PI*r*r,2*PI*r);
    return 0;
}


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

long long pow5(long long a){
    return a*a*a*a*a;
}

int main() {
    long long x, i, j;
    cin >> x;
    for(i = 1; pow5(i)-pow5(i-1)<1000000000; i++){
        for(j = 0; j < i; j++){
            if(pow5(i) - pow5(j) == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    for(i = 0; i < 100; i++){
        for(j = -100; j < 0; j++){
            if(pow5(i) - pow5(j) == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

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

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int x, y, z;
    cin >> x >> y >> z;
    int k;
    cin >> k;
    vector<ll> a(x), b(y), c(z);
    for (int i = 0; i < x; i++) cin >> a[i];
    for (int i = 0; i < y; i++) cin >> b[i];
    for (int i = 0; i < z; i++) cin >> c[i];
    vector<ll> ab;
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            ab.push_back(a[i] + b[j]);
        }
    }
    sort(ab.begin(), ab.end(), greater<ll>());
    vector<ll> ans;
    for (int i = 0, sz = min(k, (int)ab.size()); i < sz; i++) {
        for (int j = 0; j < z; j++) {
            ans.push_back(ab[i] + c[j]);
        }
    }
    sort(ans.begin(), ans.end(), greater<ll>());
    for (int i = 0; i < k; i++)
        cout << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 43240
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on

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

  if (x < 1200) {
    cout << "ABC" << endl;
  } else {
    cout << "ARC" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const int MOD = (int)1e9 + 7;

ll pow3(int n) {
    if(n == 0) return 1;
    else if(n == -1) return 0;
    else if(n % 2 == 0) return pow3(n / 2) * pow3(n / 2) % MOD;
    else return (pow3((n - 1) / 2) * pow3((n - 1) / 2) % MOD) * 3 % MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    VL a(n, 0), aq(n, 0), c(n, 0), cq(n, 0);
    
    if(s[0] == 'A') a[0] = 1;
    else if(s[0] == '?') aq[0] = 1;
    FOR(i, 1, n - 1) {
        a[i] = a[i - 1];
        aq[i] = aq[i - 1];
        if(s[i] == 'A') a[i]++;
        else if(s[i] == '?') aq[i]++;
    }
    if(s[n - 1] == 'C') c[n - 1] = 1;
    else if(s[n - 1] == '?') cq[n - 1] = 1;
    FORR(i, n - 2, 0) {
        c[i] = c[i + 1];
        cq[i] = cq[i + 1];
        if(s[i] == 'C') c[i]++;
        else if(s[i] == '?') cq[i]++;
    }

    ll ans = 0;
    FOR(i, 1, n - 2) {
        if(s[i] == 'A' or s[i] == 'C') continue;
        ll a_cnt = 0;
        a_cnt = pow3(aq[i - 1]) * a[i - 1] % MOD;
        a_cnt = (a_cnt + (pow3(aq[i - 1] - 1) * aq[i - 1] % MOD)) % MOD;
        ll b_cnt = 0;
        b_cnt = pow3(cq[i + 1]) * c[i + 1] % MOD;
        b_cnt = (b_cnt + (pow3(cq[i + 1] - 1) * cq[i + 1] % MOD)) % MOD;
        ans = (ans + a_cnt * b_cnt % MOD) % MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3664
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: usize = read();
    let m = n / 2;
    let mut avec: Vec<usize> = read_vec();
    avec.sort();
    let mut cnt: u32 = 0;
    let mut tmp: usize = 1000000;
    if n % 2 == 0 {
        for a in &avec {
            if *a > n || *a % 2 == 0 {
                println!("0");
                return;
            }
            if *a == tmp {
                cnt += 1;
                if cnt > 2 {
                    println!("0");
                    return;
                }
            } else {
                cnt = 1;
                tmp = *a;
            }
        }
    } else {
        for a in &avec {
            if *a > n || *a % 2 == 1 {
                println!("0");
                return;
            }
            if *a == tmp {
                cnt += 1;
                if cnt > 2 || (cnt > 1 && tmp == 0) {
                    println!("0");
                    return;
                }
            } else {
                cnt = 1;
                tmp = *a;
            }
        }
    }

    let mut ans: u64 = 1;
    for _ in 0..m {
        ans = ans * 2 % 1000000007;
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define ll long long
#define us unsigned short int
#define fin freopen("/home/imtiaz/Desktop/in.txt", "r", stdin)
#define fout freopen("/home/imtiaz/Desktop/out.txt","w", stdout)
#define dbg(x) cerr << #x << ": " << x << endl
#define fastio ios::sync_with_stdio (false); cin.tie (0);
using namespace std;


int main(){
    ll n;
    cin>>n;
    ll div_sum[n+1];
    memset(div_sum,0,sizeof div_sum);
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = i; j <= n; j+=i)
        {
            div_sum[j]++;
        }
        
    }
    ll total=0;
    for (ll i = 1; i <= n; i++)
    {
        total+=div_sum[i]*i;
    }
    
    cout<<total<<endl;
    return 0;
}

Measured memory_bytes: 81756
#include<stdio.h>
#define N 100000
#define Q 50000
 
int binarysearch(int);
void sort(void);
int S[N];
int n;
main(){
   
  int q,T[N],i,j,x,count=0;
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  
  for(i=0;i<q;i++){
    x= binarysearch(T[i]);
    if(x!=n){
      count++;
    }
  } 
  printf("%d\n",count);
  return 0;
}
 
void sort(void){
  int flag,i,j,x,minj;
  for(i=0;i<=n-1;i++){
    minj=i;
    flag=0;
    for(j=i;j<=n-1;j++){
      if(S[j]<S[minj]){
    minj=j;
    flag=1;
      }
    }
    if(flag==1){
      x=S[i];
      S[i]=S[minj];
      S[minj]=x; 
    }
  }
}
 
int binarysearch(int key){
  int left=0,right=n;
  int mid;
  while(left<right){
    mid=(left+right)/2;
    if(S[mid]==key)
      return mid;
    else if(key<S[mid])
      right=mid;
    else{
      left=mid+1;
    }
  } 
  return n;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
const ll INF = 1LL << 60;

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;
}

int a, b;

void input() {
    cin >> a >> b;
}

void solve() {
    if(a==1 && b ==2) {
        cout << 3 << endl;
    } else if (a==1 && b == 3) {
        cout << 2 << endl;
    } else if (a == 2 && b == 1) {
        cout << 3 << endl;
    } else if( a == 2 && b == 3) {
        cout << 1 << endl;
    } else if( a == 3 && b == 1) {
        cout << 2 << endl;
    } else if( a==3 && b == 2) {
        cout << 1 << endl;
    }

}



int main() {
    input();
    solve();
}


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

int main(void) {
	int n,k;
	scanf("%d %d",&n,&k);
	int sunuke[n];
	int i,count=0;
	for(i=0;i<n;i++){//sunuke初期化
		sunuke[i] = 0;
	}
	for(i=0;i<k;i++){
		int okasi[n];//お菓子を持っているsunukeの番号を記録
		int id;
		scanf("%d",&id);
		int j=0,l=0;
       for(j=0;j<id;j++){
         scanf("%d",&okasi[j]);//ここはあってる
       }
		for(j=0;j<id;j++){
			sunuke[okasi[j]-1]++;
		}
	}
	for(i=0;i<n;i++){
		if(sunuke[i] == 0){
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define int long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second

    using namespace std;
int power(int base, int exp)
{
    if (exp == 0)
       return 1;
    else if (exp == 1)
       return base;
    else
    {
       int calc;
       if (exp % 2 == 0)
       {
         calc = power(base, exp/2);
         calc =(calc* calc)%mod;
       }
       else
       {
         calc = (base*power(base, exp-1))%mod;
       }
       return calc%mod;
    }
}

#define MAX 100

void printString(int n)
{
	char str[MAX]; 	int i = 0;

	while (n > 0) {
int rem = n % 26;

			if (rem == 0) {
			str[i++] = 'Z';
			n = (n / 26) - 1;
		}
		else {
			str[i++] = (rem - 1) + 'A';
			n = n / 26;
		}
	}
	str[i] = '\0';

	reverse(str, str + strlen(str));
	for(int i=0;i<strlen(str);i++)
    {
        cout<<char(str[i]+32);
    }

	return;
}
int32_t main()
{
    int n;
    cin>>n;
    printString(n);
}


Measured memory_bytes: 3628
import sys
s = input()
k = int(input())

if k <= 100:
    a = 0
    for i in range(k):
        if s[i] != '1':
            break
        if i == str(k-1):
            print(1)
            sys.exit()
    print(s[i])
    
else:
    for i in range(100):
        if s[i] != '1':
            print(s[i])
            break

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
using namespace std;
const long long inf = 1e10;
const long long mod = 1e9+7;

int main(void){
    string s;
    cin >> s;
    for(int i=0; i<s.length()-8; i++){
        cout <<  s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import bisect
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a2 = [0] * (n + 1)
b2 = [0] * (m + 1)
for i in range(0, n):
    a2[i+1] = a[i] + a2[i]
for i in range(0, m):
    b2[i+1] = b[i] + b2[i]

ans = 0
for i in range(n+1):
    tmp = bisect.bisect_right(b2, k-a2[i]) - 1
    if a2[i] + b2[tmp] <= k and tmp >= 0:
        ans = max(ans, i+tmp)

print(ans)

Measured memory_bytes: 47616
def ARC068D():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    count_list = []
    cnt = 1
    #print(A)
    for i in range(1, N):
        if A[i] == A[i - 1]:
            cnt += 1
        else:
            count_list.append(cnt)
            cnt = 1
    count_list.append(cnt)
    ans_cnt = 0
    #print(count_list)
    for i in range(len(count_list)):
        if count_list[i] > 2:
            ans_cnt += (count_list[i] % 2) - 1
            count_list[i] %= 2
            if count_list[i] == 0:
                count_list[i] = 2
    #print(ans_cnt)
    count_list = sorted(count_list)[::-1]
    for i in range(len(count_list) - 1):
        if count_list[i] == 2 and count_list[i + 1] == 2:
            ans_cnt += 1
            count_list[i] = 1
            count_list[i + 1] = 1
    count_list = sorted(count_list)[::-1]
    if count_list[0] == 2:
        count_list[0] = 0
    #print(ans_cnt)
    #print(count_list)
    print(sum(count_list))
ARC068D()

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int counter = 0;
    ll sum = 0;
    int minimum = INT_MAX;
    REP(i, n) {
        cin >> a[i];
        counter ^= (a[i]<0)?1:0;
        minimum = min(minimum, abs(a[i]));
        sum += abs(a[i]);
    }
    if (counter == 1) {
        sum -= minimum*2;
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;

#define ll  long long
#define vi  vector<int>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b == 0) return b;
  else gcd(b, a%b);
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a/gcd(a , b))*b;
}

int main(){

  int n,x;
  int minn = inf;
  cin >> n >>x;
  int ans = n;
  vi m(110);
  rep(i,n){
    cin >> m[i];
    x-=m[i];
    chmin(minn,m[i]);
  }

  ans += (x/minn);

  pr(ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

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

int main(void) {
    int a,b,c;

    cin>>a>>b>>c;

    if(a+b+c>=22){
        cout<<"bust"<<endl;
    }else{
        cout<<"win"<<endl;
    }
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/cf17-final/tasks/cf17_final_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  VL ds(N);

  map<ll, ll> cts;
  cts[0]++;

  rep(i, N) {
    ll d;
    cin >> d;

    ds[i] = d;
    cts[d]++;
  }

  if (cts[0] >= 2 || cts[12] >= 2) drop(0);
  rep1(i, 11) if (cts[i] >= 3) drop(0);

  ll res = 0;

  rep(bit, (1ll << 12) - 1) {
    VL ts(0);

    if (cts[0] > 0) ts.push_back(0);
    if (cts[12] > 0) ts.push_back(12);

    rep1(time, 11) {
      if (cts[time] == 0) continue;

      if (cts[time] == 2) {
        ts.push_back(time);
        ts.push_back(24-time);
        continue;
      }

      ll mask = 1ll << (time - 1);
      if ((bit & mask) == mask) {
        // 右側
        ts.push_back(time);
      } else {
        // 左側
        ts.push_back(24 - time);
      }
    }

    ll min_d = INF;

    rep(j, ts.size()) rep(i, j) {
      ll t_diff = abs(ts[i] - ts[j]);
      ll d = min(t_diff, 24- t_diff);
      chmin(min_d, d);
    }

    chmax(res, min_d);
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
//package NomuraContest2020;

import java.util.*;
import java.io.*;
import java.math.*;


class Main {
    public static void main(String args[] ) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        //Start here:
        String s=br.readLine();
        
        int n=s.length();
        StringBuffer bf=new StringBuffer("");
        for(int i=0;i<n;i++)
        {
        	char ch=s.charAt(i);
        	if(ch=='?')
        	{
        		bf.append("D");
        	}
        	else
        	{
        		bf.append(ch);
        	}
        }
        System.out.println(bf.toString());

    }
    //D?D?
    //PDDDDDP
}

Measured memory_bytes: 36840
/***
 ** " Success is most often achieved by those who don't know that failure is inevitable. "
 **     -- Coco Chanel
***/

/**
  *  Author: dhruv_gheewala
  *  Problem: Logs
  *  Date:   03.08.2020
  *  Time:   15:26:20
**/

#if __has_include("debug.h")
    #include "debug.h"
#else
    #include<bits/stdc++.h>
    using namespace std;
    
    #define fundri 108
    #define debug(...) 1729
#endif

#define int int64_t
typedef pair<int, int> pii;
typedef vector<int> vi;

const bool testcases = false;
#define ff first
#define ss second
#define endl '\n'
#define all(s) s.begin(), s.end()

// if vector isn't soted then it will remove consecutive same elements
#define make_unique(vec) vec.erase(unique(all(vec)), vec.end())
#define test int TC = 1;if(testcases)cin >> TC;for(int tc = 1 ; tc <= TC ; tc++)solve(), fundri
#define sort_by(cont,expr) sort(all(cont),[&](const auto &lhs,const auto &rhs){return expr;})

int seed; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l = 0, int r = INT_MAX) {return uniform_int_distribution<int>(l, r)(rng);}

inline bool in_range(int a, int l, int r) {return (a >= l && a <= r);}
template<typename H, typename ...T>void inp(H &head) {cin >> head;}
template<typename H, typename ...T>void inp(H &head, T &...tail) {cin >> head;inp(tail...);}
template<typename T>bool isPrime(T n) {for(T i = 2; i * i <= n; i++)if(n % i == 0)return false; return n >= 2;}
template<typename T>inline istream &operator >>(istream &in, vector<T> &a) {for(T &x : a)in >> x; return in;}
template<typename T, typename U>inline istream &operator >>(istream &in, pair<T, U> &a) {in >> a.ff >> a.ss; return in;}

void solve();
void fast_io();

int32_t main(int32_t argc, char **argv)
{
    fast_io();
    test;
    return 0;
}

void solve()
{
    int n, k;
    cin >> n >> k;
    vi a(n);
    cin >> a;
    // cerr << 1.12345678901234567890 << endl;
    
    int sum, ans;
    long double l, r, mid, eps;
    l = 0;
    r = 1e9 + 7;
    eps = 1e-10;
    ans = INT_MAX;

    while(l <= r) {
        mid = (l + r) / 2;
        // debug(l, mid, r);

        sum = 0;
        // for(int i = 0 ; i < n ; i++)
        for(int i = 0 ; i < n ; i++) {
            if(a[i] >= mid)
                sum += int(ceil(1.00 * a[i] / mid)) - 1;
        }

        if(sum <= k) {
            debug(ans, mid);
            ans = min(ans, int(ceil(mid - eps)));
            r = mid - eps;
            continue;
        }
        l = mid + eps;
    }
    cout << ans << endl;
}

void fast_io()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cerr << fixed << setprecision(15);

#ifdef DHRUV_GHEEWALA
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

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

    string ans = "";
    REP(i, S.size()){
        ans.push_back('x');
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int x,y;cin>>x>>y;

    if(x==2&&y==2){
      cout<<"Yes"<<endl; return 0;
    }

    if((x==4&&(y==4||y==6||y==9||y==11))||
    (x==6&&(y==4||y==6||y==9||y==11))||
    (x==9&&(y==4||y==6||y==9||y==11))||
    (x==11&&(y==4||y==6||y==9||y==11))){
      cout<<"Yes"<<endl; return 0;
    }

    if((x==1&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))||
    (x==3&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))||
    (x==5&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))||
    (x==7&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))||
    (x==8&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))||
    (x==10&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))||
    (x==12&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))
    ){
      cout<<"Yes"<<endl; return 0;
    }


    cout<<"No"<<endl;
    return 0;
}


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

void solve() {
  string s;
  cin >> s;
  string ans = "hon";
  if (s.back() == '3') {
    ans = "bon";
  } else if (s.back() == '0' or s.back() == '1' or s.back() == '6' or
             s.back() == '8') {
    ans = "pon";
  }
  cout << ans << endl;
}

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

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

#define int long long

signed main(){

	int n; cin >> n;
	vector<int> x(n+1, 0);

	map<int, int> mp;

	mp[0] = 0;
	for(int i = 0;i < n;i++){
		cin >> x[i+1]; x[i+1] += x[i];
		mp[x[i+1]] = i+1;
	}

	int ans = 0;
	for(int i = 0;i < n;i++){
		ans = max(ans, mp[x[i]] - i);
	}

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



Measured memory_bytes: 16692
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;
//ここから

const int INFTY=(numeric_limits<int>::max())/2;
vector<vector<int>>d;//d[u][v]は辺uvのコスト、ただし存在しないときINFTY,d[i][i]=0

void warshall_floyd(int V){//Vは頂点数
	for(int k=0;k<V;++k){//経由する頂点
		for(int i=0;i<V;++i){//始点となる頂点
			for(int j=0;j<V;++j)//目的地の頂点
      d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		}
	}
}

void solve(){
  int n,m;
  cin>>n>>m;
  d.resize(n,vector<int>(n,INFTY));
  rep(i,n)d[i][i]=0;
  vector<int>a(m),b(m),c(m);
  rep(i,m){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;b[i]--;
    d[a[i]][b[i]]=c[i];
    d[b[i]][a[i]]=c[i];
  }
  warshall_floyd(n);
  vector<bool>used(m);
  //rep(i,n)rep(j,n)cout<<d[i][j]<<endl;
  rep(i,n){
    rep(j,n){
      rep(k,m){
        if(d[i][j]==d[i][a[k]]+d[b[k]][j]+c[k])used[k]=true;
      }
    }
  }
  //rep(i,m)cout<<used[i]<<"\n";
  int cnt=0;
  rep(i,m)if(!used[i])++cnt;
  cout<<cnt;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 384
from pprint import pprint as pp
import collections
import math

n = int(input())
txy = [tuple(map(int, input().split())) for _ in range(n)]

now_t = 0
now_x = 0
now_y = 0

for t, x, y in txy:
  dt = t - now_t
  dx = x - now_x
  dy = y - now_y
  dp = dx + dy
  diff = dt - dp
  if ((diff % 2) == 1) or (diff < 0):
    print('No')
    break
  now_t = t
  now_x = x
  now_y = y
else:
  print('Yes')


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

int main()
{
    int a,b,k=0;
    cin>>a>>b;
    k=(a+b)/2;
    abs(a-k);
    abs(b-k);

    if(abs(a-k)==abs(b-k))
    {
        cout<<k;
    }
    else
        cout<<"IMPOSSIBLE";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll a = 1; a <= n; ++a) {
    for (ll b = 1; b <= n; ++b) {
      ll x = a * b;
      if (x >= n) break;
      ans ++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
long long mod=998244353;
long long p[1000001],px[1000001];
inline long long power(long long x,long long y)
{
	long long t=1;
	while(y!=0)
	{
		if(y%2==1)
			t=t*x%mod;
		x=x*x%mod;
		y/=2;
	}
	return t;
}
void prepare()
{
	int i;
	p[0]=1;
	px[0]=1;
	for(i=1;i<=1000000;i++)
	{
		p[i]=p[i-1]*(long long)i%mod;
		px[i]=power(p[i],mod-2);
	}
}
int main()
{
	prepare();
	int n;
	long long a,b;
	long long k;
	cin>>n>>a>>b>>k;
	long long ans=0;
	long long sa=n,sb=0,d=0;
	while(sa>=0)
	{
		while(sa*a+sb*b<k&&sb<n)
			sb++;
		if(sa*a+sb*b==k)
	/*	{
			long long tmp=(p[n]*px[n-sa]%mod*px[sa])%mod;
			tmp*=(p[n-sa]*px[n-sa-sb]%mod*px[sb])%mod;
			tmp%=mod;
			long long tx=0;
		//	tx++;
			if(sa<sb&&sa+sb>0)
				tx+=(p[sa+sb]*px[sb]%mod)*px[sa]%mod;
			else if(sa+sb>0)
				tx+=(p[sa+sb]*px[sa]%mod)*px[sb]%mod;
			tx%=mod;
		//	tx-=d;
		//	tx=(tx+mod)%mod;
		//	d++;
			ans=(ans+tx*tmp%mod)%mod;
		}*/
		{
			long long tmp=(p[n]*px[n-sa]%mod*px[sa])%mod;
			tmp*=(p[n]*px[n-sb]%mod*px[sb])%mod;
			tmp%=mod;
		//	tx-=d;
		//	tx=(tx+mod)%mod;
		//	d++;
			tmp%=mod;
			ans=(ans+tmp)%mod;
		}
		sa--;

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

Measured memory_bytes: 15872
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1e6+5;

vi v(N),w(N);

void solve()
{
    int n;
    cin>>n;

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

    for(auto c:a)
        ++v[c];

    int ans=0;
    for(int i=1;i<N;++i)
    {
        if(!v[i])
            continue;

        if(v[i]==1 && w[i]==0)
            ++ans;

        for(int j=2*i;j<N;j+=i)
            ++w[j];
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 20356
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    map<int, int> mp;
    mp[0] = 1;
    int now = 0;
    rep(i, 0, n){
        now += a[i];
        mp[now]++;
    }
    int ans = 0;
    for(auto i : mp){
        ans += i.second * (i.second - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int n,l;
cin>>n>>l;
string t;
vector<string>s(n);
for(int i=0;i<n;i++){
  cin>>s.at(i);
  }
sort(s.begin(),s.end());
for(int i=0;i<n;i++){
  t+=s.at(i);
  }
  cout<<t<<endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=20;
int x[N][N][2],len[N],n,ans=0;
bool ishonest[N];
int check();
void dfs(int now)
{
  if(now==n)
  {
    ans=max(ans,check());
    return;
  }
  dfs(now+1);
  ishonest[now]=true;
  dfs(now+1);
  ishonest[now]=false;
}
int change(int a,int b)
{
	if(a==0)return !b;
	else return b;
}
int check()
{
	int res=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<len[i];j++)
		{
    		if(change(ishonest[i],x[i][j][1])!=ishonest[x[i][j][0]]&&ishonest[i])
    		{
    			return -1;
			}
		}
		res+=ishonest[i];
	}
//	if(res==2)cout<<ishonest[0]<<' '<<ishonest[1]<<endl;
	return res;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>len[i];
		for(int j=0;j<len[i];j++)
		{
			cin>>x[i][j][0]>>x[i][j][1];
			x[i][j][0]--;
		}
	}
	dfs(0);
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int N; cin >> N;
    int F[N][10];
    int P[N][11];
    ll ans = -1e9;

    for(int i = 0; i < N; i++){
        for(int j = 0; j < 10; j++){
            cin >> F[i][j];
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 11; j++){
            cin >> P[i][j];
        }
    }

    for (int bits = 1; bits < (1<<10); bits++) {
       ll sum = 0;
       for (int i = 0; i < N; i++) {
          int cnt = 0;
          for (int j = 0; j < 10; j++) {
             if (((bits>>j)&1) && F[i][j]) cnt++;
          }
          sum += P[i][cnt];
       }
       ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1e18;

int main(void) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<ll> candidate;
    candidate.push_back(a*c);
    candidate.push_back(b*c);
    candidate.push_back(a*d);
    candidate.push_back(b*d);
    ll max = *max_element(all(candidate));
    cout << max << endl;
    return 0;
}



Measured memory_bytes: 3200
#include <stdio.h>
int main(void){
  char s[128];
  int a;
  if(scanf("%s",s) == 1){};
  if(s[0] == 0 || s[1]  == 0 || s[2] == 0|| s[3] ==0){puts("No");return 0;}
  if(s[0] == s[1] && s[0] == s[1] && s[0] == s[2])   {puts("No");return 0;}
if( (s[0] == s[1] && s[2] == s[3]) || (s[0] == s[2] && s[1] == s[3]) || (s[0] == s[3] && s[2] == s[1])){
   puts("Yes");
  }else{
   puts("No");
}
return 0;
}
  


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
    int a;
    int b[10]={0};
    for(int i=0;i<3;i++)
    {
        scanf("%d",&a);
        b[a]++;
    }
    if(b[5]==2&&b[7]==1)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
n,k = map(int, input().split())
p = [i for i in map(int, input().split())]

ex = []
for i in range(n):
    ex += [(1+p[i])]

s = sum(ex[0:k])
t = s
for i in range(n-k):
    s = s-ex[i]+ex[i+k]
    t = max(t, s)

print(t/2)

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

using namespace std;

int main() {
    int n;
    cin >> n;
    map<int, int> cnt;

    bool ok = true;
    for (int i = 0; i < n; i++) {
        int cur;
        cin >> cur;
        cnt[cur]++;
        if (cnt[cur] > 1) ok = false;
    }
    cout << (ok ? "YES\n" : "NO\n");
}

Measured memory_bytes: 9600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int ans = 10101, cnt = 0; string s, t;
    cin >> s >> t;
    for(int i = 0; i < s.size() - t.size() + 1; ++i){
        for(int j = 0; j < t.size(); ++j){
            if(s.at(i + j) != t.at(j)) cnt++;
        }
        ans = min(ans, cnt);
        cnt = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main() {
  string n;
  cin >> n;
  int mex = 0, a = 0;
  for(int i = 0; i < n.size(); i++){
      
    if(n.at(i) == 'A' || n.at(i) == 'C' || n.at(i) == 'G' || n.at(i) == 'T'){
        a++;
        mex = max(mex,a);
    }else{
        a = 0;
    }
  }
  cout << mex << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  string s;
  cin >> s;
  int a0=0,a1=1;
  int na0,na1;
  int r=0;
  for(int i=0;i<s.size();i++){
    r=s[i]-'0';
    if(r==9){
      na0=a1+1;
      na1=a1;
    }else{
      na0=min(a0+r,a1+10-r);
      na1=min(a0+r+1,a1+9-r);
    }
    a0=na0; a1=na1;
    //cout << a0 << " " << a1 << endl;
  }

  cout << na0 << endl;
  
  return 0;
}


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

#define SIZE 1000

int stack[SIZE];
int pos = 0;

int empty()
{
	return pos == SIZE;
}

void push(int x)
{
	if (empty())
		printf("ERROR\n");
	else
		stack[pos++] = x;
}

int pop()
{
	int x;

	if (pos == 0)
	{
		printf("ERROR\n");
		exit(1);
	}
	else
		x = stack[--pos];

	return x;
}

void swap(int *a, int *b)
{
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

void print(int A[], int N)
{
	int i;
	for (i = 0; i < N; i++)
	{
		if (i == N - 1)
			printf("%d\n", A[i]);
		else
			printf("%d ", A[i]);
	}
}

int binary_search(int A[], int N, int key)
{
	int left, right, middle;

	left = 0, right = N - 1;

	while (left <= right)
	{
		middle = (left + right) / 2;

		if (A[middle] == key)
			return 1;
		else if (A[middle] < key)
			left = middle + 1;
		else
			right = middle - 1;
	}

	return 0;
}

int dfs(int A[], int n, int k, int num, int sum)
{
	if (k == n)
	{
		if (num == sum)
			return 1;
		else 
			return 0;
	}
	else
	{
		if (dfs(A, n, k + 1, num + A[k], sum))
			return 1;
		if (dfs(A, n, k + 1, num, sum))
			return 1;
	}
	return 0;
}

int fibo(n)
{
	double a = (1 + sqrt(5)) / 2;
	double b = (1 - sqrt(5)) / 2;
	return (int)((pow(a, n) - pow(b, n))/sqrt(5));
}

int main()
{
	int n;

	scanf("%d", &n);

	printf("%d\n", fibo(n+1));

	return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    ll l[100];
    l[0] = 2;
    l[1] = 1;
    FOR(i,2,87){
        l[i] = l[i-1] + l[i-2];
    }
    cout << l[n] << endl;
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

class UnionFind {
    int root(int x) {
        return parent.at(x) < 0 ? x : parent.at(x) = root(parent.at(x));
    }
    std::vector<int> parent;

public:
    UnionFind(int max) : parent(max + 1, -1) {}
    void unite(int x, int y);
    bool isFamily(int x, int y) { return root(x) == root(y); }
};

void UnionFind::unite(int x, int y) {
    x = root(x), y = root(y);
    if (x != y) {
        if (parent.at(x) > parent.at(y)) std::swap(x, y);
        if (parent.at(x) == parent.at(y)) parent.at(x)--;
        parent.at(y) = x;
    }
}

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

    int N, M, ans = 0;
    cin >> N >> M;
    vector<int> x(M), y(M), p(N + 1);
    rep (i, N)
        cin >> p[i + 1];
    rep (i, M)
        cin >> x[i] >> y[i];

    UnionFind uf(N);
    rep (i, M)
        uf.unite(x[i], y[i]);

    rep (i, N) {
        if (uf.isFamily(i + 1, p[i + 1])) ans++;
    }

    print(ans);

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 1792
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

S,T = input().split()

A,B=input_int()

U=one_str()

if U==S:
    print(A-1, B)
else:
    print(A,B-1)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
#include <iomanip>
using namespace std;

int main(){
    vector<int> a(10,0);
    for ( int i = 0 ; i < 3 ; i++){
        int x ; cin >> x;
        if ( x == 5 ) a[5]++;
        if ( x == 7 ) a[7]++;
    }
    string ans;
    if ( a[5] ==2 && a[7] == 1 ) ans = "YES";
    else ans = "NO";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s;
  getline(cin,s);
  int l,count=0;
  l=s.length();
  int max=0;
  for(int i=0;i<l;i++)
  {
    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')
    {
      count ++;
      if(count>max)
      {
        max=count;
      }
    }
    else
      {
      
        count=0;
      }
  }
  cout<<max;
  return 0;
}


Measured memory_bytes: 256