akhauriyash/Code-Regression huggingface dataset:
// aftershock :D
#include "bits/stdc++.h"
#include "sstream"
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=3e5+1;
multiset<int> st;
int main() {
    quick
    int n, x; cin >> n;
    for (int i = 0; i < n; i++){
        cin >> x;
    auto it = st.lower_bound(x);
    if (it == st.begin())
        st.insert(x);
    else
        it--, st.erase(it), st.insert(x);}
    cout<<st.size();
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define VFOR(x,begin,num) for(int x=(begin);x<((begin)+(num));x++)
#define INF__ ((long long)1 << 60)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q; string S;
    cin >> N >> S >> Q;
    S.insert(S.begin(),' ');
    set<int> CharPlace[26];
    VFOR(i,0,26){CharPlace[i].insert(-1); CharPlace[i].insert(98765432);}
    VFOR(i,1,N) CharPlace[(int)(S[i]-'a')].insert(i); 
    VFOR(i,0,Q){
        int q; cin >> q;
        if(q == 1){
            int a; string b,c="  ";
            cin >> a >> b;
            c[0] = S[a]; 
            S[a] = b[0];
            //{auto it = CharPlace[(int)(c[0]-'a')].begin();while(it != CharPlace[(int)(c[0]-'a')].end()  ) {cout<<*(it++) << " ";} cout << endl;}
            //{auto it = CharPlace[(int)(b[0]-'a')].begin();while(it != CharPlace[(int)(b[0]-'a')].end()  ) {cout<<*(it++) << " ";} cout << endl;}
            CharPlace[(int)(c[0]-'a')].erase(a);//{auto it = CharPlace[(int)(c[0]-'a')].begin();while(it != CharPlace[(int)(c[0]-'a')].end()  ) {cout<<*(it++) << " ";} cout << endl;}
            CharPlace[(int)(b[0]-'a')].insert(a);//{auto it = CharPlace[(int)(b[0]-'a')].begin();while(it != CharPlace[(int)(b[0]-'a')].end()  ) {cout<<*(it++) << " ";} cout << endl;}
        }
        else{
            int a, b,cnt=0;
            cin >> a >> b;
            VFOR(j,0,26){
                //if( lower_bound(CharPlace[j].begin(),CharPlace[j].end(),b) != lower_bound(CharPlace[j].begin(),CharPlace[j].end(),a-1)) cnt++;
                //if( distance(CharPlace[j].lower_bound(CharPlace[j].begin(),CharPlace[j].end(),b) , CharPlace[j].lower_bound(CharPlace[j].begin(),CharPlace[j].end(),a) ) ) cnt++;
                //{auto it = CharPlace[j].begin();while(it != CharPlace[j].end()  ) {cout<<*(it++) << " ";} cout << endl;}
                auto it = CharPlace[j].lower_bound(a);
                if(  *it <= b && it != CharPlace[j].end()) cnt++;
            }
            cout << cnt << endl;
        }
    }
}

Measured memory_bytes: 24220
a=input()
l=[int(a[0]),int(a[1]),int(a[2]),int(a[3])]

for i in range (2**3):
    op=[]
    for j in range(3):
        if (i>>j) & 1 == 1:
            op.append(+1)
        else:
            op.append(-1)
    # print(op)
    # print('{}{}{}{}{}{}{}'.format(l[0],op[0],l[1],op[1],l[2],op[2],l[3]))
    # print(l)
    # print(op)

    # l[0]+(op[0]*l[1])+(op[1]*l[2])+(op[2]*l[3])==7
    if l[0]+(op[0]*l[1])+(op[1]*l[2])+(op[2]*l[3])==7: 
        options=[]
        for option in op:
            if option ==1:
                options.append('+')
            else:
                options.append("-")
        print('{}{}{}{}{}{}{}=7'.format(l[0],options[0],l[1],options[1],l[2],options[2],l[3]))
        break

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

int main(){
    string s; cin >> s;
    int count=0;
    bool chk=true;
    auto comp = [](char a, char b) { return a-'a' > b-'a'; };
    sort(s.begin()+2, s.end()-1, comp);
  
    if(s.front()!='A') chk=false;
    if(s[s.size()-2]!='C') chk=false;
    for(int i = 1; i < s.size()-2; i++) {
        if(!islower(s[i])) chk=false;
    }
    if(!islower(s.back())) chk=false;
    cout << (chk ? "AC" : "WA") << endl;
    return 0;
}

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

using namespace std;

typedef long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;

int n;
vi c;
vi dp;
vvi fa;
vvi coldp;
vi cpos;
vi colorlist;
ll mod = 1e9+7;

ll f(int i);
ll colf(int col, int l) {
	
	int m = fa[col].size();
	if(l >= m) return 0;
	 if(coldp[col][l] == -1) {
		coldp[col][l] = (f(fa[col][l]+1)+colf(col, l+1))%mod;
		
	}
	return coldp[col][l];
}
ll f(int i) {
	if(i == n) return 1;
	else if(i > n) return 0;
	if(dp[i] == -1) {
		//cerr << "COMPUTING f(" << i << ")" << endl;
		dp[i] = 0;
		
		//int m = fac.size();
		int l = 0;
		//int r = fa[c[i]].size()-1;
		/*while(r-l > 0) {
			int d = (l+r)/2;
			if(fa[c[i]][d] < i) {
				l = d+1;
			}
			else if(fa[c[i]][d] == i) {
				l = d;
				r = d;
			}
			else {
				r = d-1;
			}
		}*/
		l = cpos[i];
		/*
		for(int j = l+1; j < m; j++) {
			dp[i] += f(fac[j]+1);
			dp[i] %= mod;
		}*/
		dp[i] += colf(c[i], l+1);
		dp[i] += f(i+1);
		dp[i] %= mod;
		//cerr << "f(" << i <<") = " << dp[i] << endl;
	}
	return dp[i]%mod;
	
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
	
	cin >> n;
	
	
	int prevcolor = -1;
	int in_n = n;
	fa = vvi(2e5, vi());
	for(int i=0; i < in_n; i++) {
		int color;
		cin >> color;
		color--;
		if(color != prevcolor) {
			fa[color].push_back(i-(in_n-n));
			if(fa[color].size() == 1) colorlist.push_back(color);
			c.push_back(color);
			cpos.push_back(fa[color].size()-1);
		}
		else n--;
		prevcolor = color;
		
	}
	dp = vi(n, -1);
	coldp = vvi(2e5, vi());
	for(int i=0; i < colorlist.size(); i++) {
		int col =colorlist[i];
		coldp[col] = vi(fa[col].size(), -1);
	}
	for(int i=n-1; i > 0; i--) f(i);
	cout << f(0) << endl;
}


Measured memory_bytes: 28372
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  char buf[1024];
  int N,A,B;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %d %d", &N, &A, &B);

  int ans=B-(N-A);
  if(ans<0){
    ans=0;
  }
  printf("%d\n",ans );

return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){FIN;
	int l,r,d; cin>>l>>r>>d;
	cout<<r/d-(l-1)/d<<"\n";
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int n,ans;
int gcd(int A,int B) { return B?gcd(B,A%B):A; }
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			for (int k=1;k<=n;k++)
				ans+=gcd(gcd(i,j),k);
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    string N;
    cin >> N;
    ll sum_n = 0;
    for (int i = 0; i < N.size(); ++i) {
        sum_n += N[i] - '0';
    }
    if (sum_n % 9 == 0) cout << "Yes" << endl; 
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3700
# -*- coding: utf-8 -*-

N = int(input())
AN = list(map(int, input().split()))

# Ai - i の各値を用意してソートする
BN = [AN[i] - (i + 1) for i in range(N)]
BN.sort()
# 中央値を取る
b = BN[len(BN) // 2]
# 最適な b で実際の計算をする
ans = 0
for i in range(N):
    ans += abs(AN[i] - (b + i + 1))
print(ans)

Measured memory_bytes: 26708
<?php
fscanf(STDIN, "%s", $a);
$input = trim(fgets(STDIN));
$inputs = explode(' ', $input);
$is_ok = true;

$inputs[0] -= 1;
for ($i = 0; $i < count($inputs); $i++) {
  if (!isset($inputs[$i + 1])) {
   	break; 
  }
  
  if ($inputs[$i + 1] == $inputs[$i]) {
    continue;
  }
  
  if ($inputs[$i + 1] > $inputs[$i]) {
    $inputs[$i + 1] -= 1;
    continue;
  }
  
  if ($inputs[$i + 1] < $inputs[$i]) {
    $is_ok = false;
    break;
  }
}


if ($is_ok) {
    echo "Yes\n"; 
} else {
    echo "No\n";
}

Measured memory_bytes: 14840
import math
N,D = map(int, input().split())
X=[]
for i in range(N):
    x = list(map(int,input().split()))
    X.append(x)

def caldist(a, b, n):
    sum = 0
    for i in range(n):
        sum +=abs(a[i]-b[i])**2
    ans = sum**(0.5)
    return ans

c=0
for i in range(N-1):
    for j in range(i+1,N):
        ans = (caldist(X[i],X[j],D))
        if ans.is_integer():
            c+=1

print(c)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() { 
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int x,a,b;
  cin>>x>>a>>b;
  if(abs(x-a)>abs(x-b)) cout<<"B"<<endl;
  else cout<<"A"<<endl;

  return 0;
}

  



Measured memory_bytes: 3628
#include <iostream>
#define llint long long
#define inf 1e18

using namespace std;

llint Q;
llint mul[100005];
llint sum[100005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> Q;
	for(int i = 1; i < 100005; i++) mul[i] = 1;
	
	for(int i = 1; i < 100005; i++){
		for(int j = 2*i; j < 100005; j+=i){
			mul[j] *= i;
			if(mul[j] >= 2*j) mul[j] = 2*j;
		}
	}
	for(int i = 2; i < 100005; i++){
		sum[i] = sum[i-1];
		if(mul[i] >= 2*i) sum[i]++;
	}
	
	llint n;
	for(int q = 0; q < Q; q++){
		cin >> n;
		cout << sum[n] << "\n";
	}
	flush(cout);
	
	return 0;
}


Measured memory_bytes: 4780
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

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

	return 0;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}
template<typename T>
void maxi(T &a, T &b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T &b) {
	a = min(a, b);
}

int main() {
	makei(N);
	makev(a, N);
	sort(all(a));
	int x = a.back();
	double min = INT_MAX;
	int index;
	rep(N) {
		if (abs((double)x / 2 - a[i]) < min) {
			index = i;
			min = abs((double)x / 2 - a[i]);
		}
	}
	cout << x << " " << a[index] << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(){
	while(1){
		int n,m,e,j;
		int i;
		scanf("%d",&n);
		if(n==0)return 0;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&m,&e,&j);
			if((m==100||e==100||j==100)||m+e>=180||m+e+j>=240)printf("A\n");
			else if(m+e+j>=210||(m+e+j>=150&&(m>=80||e>=80)))printf("B\n");
			else printf("C\n");
		}
	}
}

		

Measured memory_bytes: 1012
#include <iostream>
#include <vector>

int main()
{
  int a, b, ans;
  std::string op;
  std::vector<int> list;
  while(1) {
    std::cin >> a >> op >> b;
    if(op=="?") break;
    if(op == "+") ans = a + b;
    else if(op == "-") ans = a - b;
    else if(op == "*") ans = a * b;
    else if(op == "/") ans = a / b;
    list.push_back(ans);
  }
  for(auto e : list) std::cout << e << std::endl;
  return 0;
}



Measured memory_bytes: 3236
n,a,b,c=map(int,input().split())
l=[int(input()) for i in range(n)]

def d(count1,count2,a1,b1,c1):
    if count1==n:
        if min(a1,b1,c1)==0:
            return float('inf')
        else:
            return abs(a-a1)+abs(b-b1)+abs(c-c1)+count2*10
    else:
        e1=d(count1+1,count2,a1,b1,c1)
        e2=d(count1+1,count2,a1+l[count1],b1,c1) if a1==0 else d(count1+1,count2+1,a1+l[count1],b1,c1)
        e3=d(count1+1,count2,a1,b1+l[count1],c1) if b1==0 else d(count1+1,count2+1,a1,b1+l[count1],c1)
        e4=d(count1+1,count2,a1,b1,c1+l[count1]) if c1==0 else d(count1+1,count2+1,a1,b1,c1+l[count1])
    return min(e1,e2,e3,e4)

print(d(0,0,0,0,0))

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

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

	vector<long long> a(n*3);
	rep(i, n*3) cin >> a[i];
	sort(a.begin(), a.end());


	long long ans = 0;
	for (int i = n; i < 3*n; i += 2) {
		ans += a[i];
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    int ans = 0;
    int left = 0;
    int right = 0;
    int remain = K;
    if (S[0] == '0') {
        remain--;
    }
    while (left < N) {
        while (remain >= 0 && right < N) {
            if (S[right] == '1' && right + 1 < N && S[right + 1] == '0') {
                remain--;
            }
            right++;
        }
        ans = max(ans, right - left);
        if (right == left) {
            right++;
        } else {
            if (S[left] == '0' && left + 1 >= 0 && S[left+1] == '1') {
                remain ++;
            }
        }
        left++;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
template <typename T>
using V = std::vector<T>;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

#define chmax(x, y) x = max(x, y)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int R, C, K;
  cin >> R >> C >> K;
  V<V<int>> grid(R, V<int>(C));
  REP(i, K) {
    int r, c, v;
    cin >> r >> c >> v;
    r--;
    c--;
    grid[r][c] = v;
  }

  V<V<V<i64>>> dp(R + 1, V<V<i64>>(C + 1, V<i64>(4)));
  for (int r = 1; r <= R; ++r) {
    for (int c = 1; c <= C; ++c) {
      i64 prow = 0;
      REP(s, 4) { chmax(prow, dp[r - 1][c][s]); }
      dp[r][c][0] = max(prow, dp[r][c - 1][0]);
      dp[r][c][1] = prow + grid[r - 1][c - 1];
      for (int s = 1; s <= 3; ++s) {
        chmax(dp[r][c][s], dp[r][c - 1][s]);
        chmax(dp[r][c][s], dp[r][c - 1][s - 1] + grid[r - 1][c - 1]);
      }
    }
  }

  i64 ans = 0;
  REP(s, 4) { chmax(ans, dp[R][C][s]); }
  cout << ans << endl;
}


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

#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)
#define pd(x) printf("%lf\n", x)
#define ps(x) printf("%s\n", x)

#define INF 1000000000000000000
#define MOD 1000000007

#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

int main() {
  long N, K, S;
  long i, j;
  long ans = 0;
  
  sl(N); sl(K); sl(S);
  if(N == K) {
    for(i=0;i<N;i++) {
      if(i < N-1) printf("%ld ", S);
      else printf("%ld\n", S);
    }
  } else if(S == 1) {
    for(i=0;i<K;i++) {
      printf("1 ");
    }
    for(i=K;i<N;i++) {
      if(i < N-1) printf("1000000000 ");
      else printf("1000000000\n");
    }
  } else {
    for(i=0;i<K+1;i++) {
      if(i%2 == 0) printf("%ld ", S-1);
      else printf("1 ");
    }
    if(S == 1000000000) {
      for(i=K+1;i<N;i++) {
        if(i < N-1) printf("500000001 ");
        else printf("500000001\n");
      }
    } else {
      for(i=K+1;i<N;i++) {
        if(i < N-1) printf("1000000000 ");
        else printf("1000000000\n");
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int ans = 0;
  int g = 0, p = 0;
  for (int i = 0; i < s.size(); i++)
  {
    if (p < g)
    {
      if (s[i] == 'g')
      {
        p++;
        ans++;
      }
      else
        p++;
    }
    else
    {
      if (s[i] == 'g')
        g++;
      else
      {
        g++;
        ans--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <tuple>
#include <set>
#include <functional>

using namespace std;

int main() {
    int y, m, d;
    scanf("%d/%d/%d", &y, &m, &d);
    
    if (y > 2019) {
        cout << "TBD" << endl;
        return 0;
    }
    if (y == 2019 && m > 4) {
        cout << "TBD" << endl;
        return 0;
    }
    if (y == 2019 && m == 4 && d > 30) {
        cout << "TBD" << endl;
        return 0;
    }
    cout << "Heisei" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

typedef long long ll;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

const int N=1e5+50; 

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	//freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	long long ai,ao,at,aj,al,as,az,ans=0,qwq=0;
	cin>>ai>>ao>>at>>aj>>al>>as>>az;
	qwq+=ai/2*2+ao+aj/2*2+al/2*2; 
	if(ai&&aj&&al)ans+=3,--ai,--aj,--al;
	ans+=ai/2*2+ao+aj/2*2+al/2*2; 
	cout<<max(ans,qwq)<<endl;
	return 0;
}


Measured memory_bytes: 256
/**
 * 与えられた英文に含まれる、
 * 各アルファベットの数を数えるプログラムを作成して下さい。 なお、小文字と大文字は区別しません。
 */

//スキャナつかうため

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	// プログラムのエントリポイント
	public static void main(String[] args) {
		// 入力ストリームの生成
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

		// アルファベットの数配列を作る
		int[] cou = new int[26];

		// 処理を繰り返す
		while (sc.hasNext()) {
			// 受け取った文字列を受け取り、小文字にする
			String stralf = sc.nextLine();
			stralf = stralf.toLowerCase();
			// 文字列をcharに変換して配列に入れていく
			char[] chalf = stralf.toCharArray();
			// 受け取った文字列の長さだけ繰り返す
			for (int i = 0; i < chalf.length; i++) {
				// chalfにアルファベットはいっていた場合、couの配列の数字に＋１していく
				if (chalf[i] >= 'a' && chalf[i] <= 'z')
					cou[chalf[i] - 'a']++;
			}
		}
		// アルファベット＋１でつ次の文字表示
		// アルファベトに対応している数値表示
		for (int k = 0; k < 26; k++) {
			System.out.println((char) ('a' + k) + " : " + cou[k]);
		}

	}
}

Measured memory_bytes: 17336
#include<stdio.h>
#include<string.h>
#include <stdlib.h>
int main(){
  int i,stack[100],n=0,m=-1;
  char enz[1000][1000];
  while(scanf(" %s ",enz[n]) != EOF) n++ ;
  for(i=0;i<n;i++){
    if(enz[i][0] >= '0' && enz[i][0]<= '9'){
      m++;
      stack[m]=atoi(enz[i]);
    }else if(enz[i][0] == '+'){
      m--;
      stack[m]=stack[m]+stack[m+1];
    }else if(enz[i][0] == '-'){
      m--;
      stack[m]=stack[m]-stack[m+1];
    }else if(enz[i][0] == '*'){
      m--;
      stack[m]=stack[m]*stack[m+1];
    }
 //   printf("%d m=%d str = %s\n",stack[m],m,enz[i]);
  }
  printf("%d\n",stack[m]);
  

}


Measured memory_bytes: 2100
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

bool incl(char a){
    if(a=='A')return true;
    if(a=='T')return true;
    if(a=='C')return true;
    if(a=='G')return true;
    return false;
}

int main(){
    string s;
    cin >> s;
    s.push_back('Z');
    int n = s.size();
    int res = 0;
    int con = 0;
    REP(i,n){
        if(incl(s[i])){
            con++;
        }else{
            chmax(res, con);
            con = 0;
        }
    }
    put(res);
    return 0;
}


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

int main() {
  vector<vector<int>> c(3, vector<int> (3));
  for (int i = 0; i < 3; i ++) {
    for (int j = 0; j < 3; j ++) {
      cin >> c[i][j];
    }
  }

  int a1 = 0;
  int b1 = c[0][0];
  int b2 = c[0][1];
  int b3 = c[0][2];
  int a2 = c[1][0] - b1;
  int a3 = c[2][0] - b1;
  vector<int> A = {a1, a2, a3};
  vector<int> B = {b1, b2, b3};
  string ans = "Yes";
  for (int i = 0; i < 3; i ++) {
    for (int j = 0; j < 3; j ++) {
      if (c[i][j] != A[i] + B[j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int s = kb.nextInt();
		int w = kb.nextInt();
		if (w >= s) {
			System.out.println("unsafe");
		} else {
			System.out.println("safe");
		}
		kb.close();
	}

}


Measured memory_bytes: 27056
#include<bits/stdc++.h>
#define H 10001
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    vector<int> h(n);
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    vector<int> dp(n,H);
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    printf("%d\n",dp[n-1]);
    return 0;
}

Measured memory_bytes: 1024
S=input()
a=int(S[:2])
b=int(S[2:])
YYMM,MMYY=False,False
if 1<=a<=12:
  MMYY=True
if 1<=b<=12:
  YYMM=True
if YYMM and MMYY:
  print("AMBIGUOUS")
if YYMM and not MMYY:
  print("YYMM")
if not YYMM and MMYY:
  print("MMYY")
if not YYMM and not MMYY:
  print("NA")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

// [A - Digit Sum 2](https://atcoder.jp/contests/agc021/tasks/agc021_a)
void solve() {
    string N;
    cin >> N;
    vector<vector<int>> dp(N.size()+1,vector<int>(2,-INF));
    dp[0][0] = 0;
    REP(i,N.size()) {
        chmax(dp[i+1][0],dp[i][0]+N[i]-'0');
        chmax(dp[i+1][1],dp[i][1]+9);
        if (N[i]!='0') chmax(dp[i+1][1],dp[i][0]+N[i]-'0'-1);
    }
    cout << max(dp[N.size()][0],dp[N.size()][1]) << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
import numpy as np

# 整数Nを入力する
N = int(input())

# 整数A、Bの桁数のうち、大きい方を返す関数F(A, B)を定義
def F(A, B):
    C = np.vstack((A, B))
    digit_C = np.array(np.log10(C) + 1, dtype = int)
    return np.max(digit_C, axis = 0)

# 除数の配列を作成
divisor = np.arange(1, int(N ** 0.5) + 1)
# 商および余りを計算
quotient = N // divisor
residue = N % divisor

# N = A * B となるようなAおよびBの配列を作成
A = divisor[residue == 0]
B = quotient[residue == 0]

# F(A, B)の最小値を返す
print(np.min(F(A, B)))

Measured memory_bytes: 20748
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b) - 1; i >= (a); --i)
#define sz(x) (int)x.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(a) (1ll<<(a))
#define endl "\n"
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
/*并查集
 * int f[];
 * int Find(int x){x==f[x]?return f[x]:f[x]=Find(f[x]);}
 * int join(int x,int y){if(Find(x)!=Find(y))f[Find(x)]=Find(y);}
 * 快速幂*/
int qpow(ll a,ll b,ll m){ll c=1;while(b){if(b&1)c=c*a%m;b>>=1;a=a*a%m;}return c;}
string s1="ARC",s2="ABC";
int main(){
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	if(s1==s){
		cout<<s2;
	}else{
		cout<<s1;
	}
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;

int main(){
  int n;
  cin >> n;
  string s1, s2;

  for(int i=0; i<n; i++){
    cin >> s1 >> s2;
    int num = 1;
    int i1 = 0;
    int i2 = 0;
    for(unsigned int j=0; j<s1.length(); j++){
      if(isdigit(s1[j])){
	num = atoi(&s1[j]);
      }else{
	if(s1[j] == 'm'){
	  i1 += num*1000;
	}else if(s1[j] == 'c'){
	  i1 += num*100;
	}else if(s1[j] == 'x'){
	  i1 += num*10;
	}else if(s1[j] == 'i'){
	  i1 += num;
	}
	num = 1;
      }
    }
    num = 1;
    for(unsigned int j=0; j<s2.length(); j++){
      if(isdigit(s2[j])){
	num = atoi(&s2[j]);
      }else{
	if(s2[j] == 'm'){
	  i2 += num*1000;
	}else if(s2[j] == 'c'){
	  i2 += num*100;
	}else if(s2[j] == 'x'){
	  i2 += num*10;
	}else if(s2[j] == 'i'){
	  i2 += num;
	}
	num = 1;
      }
    }
    num = i1 + i2;

    int m[4] = {0};
    if(num/1000 > 0){
      m[0] = num/1000;
      num %= 1000;
    }
    if(num/100 > 0){
      m[1] = num/100;
      num %= 100;
    }
    if(num/10 > 0){
      m[2] = num/10;
      num %= 10;
    }
    if(num > 0){
      m[3] = num;
    }

    string aaa[4] = {"m", "c", "x", "i"};
    for(int j=0; j<4; j++){
      if(m[j] > 1){
	cout <<  m[j];
      }
      if(m[j] > 0){
	cout <<  aaa[j];
      }
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1224
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = sorted(readInts())
dic = defaultdict(int)
cnt = 0
for i in A:
   dic[i] += 1
A = list(set(A))
# ------------
is_prime = [True] * (10**6+1)
#print('a')
for i in range(len(A)):
    #ll += 1
    #print(i)
    #print(A[i])
    if is_prime[A[i]] == True:
        for j in range(2*A[i], 10**6+1,A[i]):
            is_prime[j] = False # その素数の倍数のやつ

 # -----------
cnt = 0
if A[0] == 1:
    if dic[1] >= 2:
        print(0)
        exit()
    else:
        print(1)
        exit()
for a in A:
    if is_prime[a] and not dic[a] >= 2:
        #print(a)
        cnt += 1
print(cnt)


Measured memory_bytes: 45220
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long answer =0;
    for(int i=0;i<n;i++){
      answer=answer+sc.nextLong();
    }
    answer=answer-n;
    System.out.println(answer);
  }
  

  
}


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

int main(void){
    // Your code here!
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(abs(a-c) <= d)
    {
        printf("Yes\n");
    }
    else if(abs(a-b)<=d && abs(b-c)<=d)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  ll K;
  cin >> N >> K;
  string S;
  cin >> S;
  while (K != 1) {
    K--;
    bool Flag = true;
    char c = S[0];
    for (int i = 0; i < N; i++) {
      if (S[i] != c) {
        Flag = false;
      }
    }
    if (Flag) {
      break;
    }
    string SS = S;
    reverse(S.begin(),S.end());
    string revS = S;
    string str = SS + revS;
    string mini = SS;
    for (int i = 0; i < N; i++) {
      string sub = str.substr(i,N);
      reverse(sub.begin(),sub.end());
      if (mini > sub) {
        mini = sub;
      }
    }
    reverse(mini.begin(),mini.end());
    S = mini;
  }
  string tmp = S;
  string mi = S;
  reverse(S.begin(),S.end());
  tmp += S;
  for (int i = 0; i < N; i++) {
    string sub = tmp.substr(i,N);
    if (mi > sub) {
      mi = sub;
    }
  }
  cout << mi << endl;
  return 0;
}

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

int main()
{
    int n, d, x, a[100];
    scanf("%d", &n);
    scanf("%d%d", &d, &x);
    int i, j;
    for (i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
    }
    int eaten = 0;
    for (i=0; i<n; i++)
    {
        for (j=0; j*a[i]+1<=d; j++)
        {
            eaten ++;
        }
    }
    printf("%d\n", eaten + x);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long



#if 0
const int MOD = ;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int inv(int x) {
    return lgput(x, MOD - 2);
}
#endif

#if 0
int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}
#endif

using namespace std;

const int INF = 1e9;
const int MAXN = 1000;

char mat[MAXN + 1][MAXN + 1];

int main() {
#if 0
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int i, j, n, m;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n >> m;
    for(i = 1; i <= n; i++) {
        cin >> mat[i] + 1;
    }

    queue < pair <int, int> > Q;
    vector < vector <int> > dst(n + 1, vector <int>(m + 1, INF));
    for(i = 1; i <= n; i++) {
        for(j = 1; j <= m; j++) {
            if(mat[i][j] == '#') {
                Q.push({i, j});
                dst[i][j] = 0;
            }
        }
    }

    vector <int> dl = {-1, 0, 1, 0};
    vector <int> dc = {0, -1, 0, 1};

    while(Q.size()) {
        int l = Q.front().first;
        int c = Q.front().second;
        Q.pop();
        for(int i = 0; i < 4; i++) {
            int lin = l + dl[i], col = c + dc[i];
            if(lin > 0 && lin <= n && col > 0 && col <= m && dst[lin][col] == INF) {
                dst[lin][col] = dst[l][c] + 1;
                Q.push({lin, col});
            }
        }
    }

    int ans = 0;
    for(i = 1; i <= n; i++) {
        for(j = 1; j <= m; j++) {
            ans = max(ans, dst[i][j]);
        }
    }
    cout << ans;

    return 0;
}



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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L = A + B;
  int R = C + D;
  
  if(L > R){
    cout << "Left" << endl;
  }
  else if(L == R){
    cout << "Balanced" << endl;
  }
  else{
  	cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n';
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    string s; cin >> s;
    if(s=="Sunny") out("Cloudy");
    if(s=="Cloudy") out("Rainy");
    if(s=="Rainy") out("Sunny");

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pb push_back
const int N = 2e5+5;
vector<int>v[N];
vector<int>b[N];
int vis[N];
int siz[N];
int cmp;
void dfs(int x){
    vis[x] = cmp;
    siz[cmp]++;
    for(int y:v[x]){
        if(vis[y])continue;
        dfs(y);
    }
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    int x,y;
    for(int i=0;i<m;i++){
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    for(int i=0;i<k;i++){
        cin>>x>>y;
        b[x].pb(y);
        b[y].pb(x);
    }
    for(int i=1;i<=n;i++){
        if(vis[i]==0){
            cmp++;
            dfs(i);
        }
    }
    for(int i=1;i<=n;i++){
        int ans = siz[vis[i]];
        for(int y:b[i]){
            if(vis[y]==vis[i])ans--;
        }
        cout<<ans-1-v[i].size()<<" ";
    }
    return 0;
}


Measured memory_bytes: 17024
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
#define pi 3.1415926


int main(){
    int a, b;
    cin >> a;
    cin >> b;
    if(a + b == 3)
        cout << "3";
    else if(a + b == 4)
        cout << "2";
    else
        cout << "1";
    
    
    
}

    

		


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

int main() {
  int n,m;
  cin >> n >> m;
  if(n == 0){
    n = 1;
  }
  int sc[m][2];
  for(int i = 0; i < m; i++){
    cin >> sc[i][0] >> sc[i][1];
  }
  for(int i = 0; i < 1000; i++){
    int keta = 1;
    int x = i / 10;
    vector<int> a(1,i % 10);
    while(x){   
      keta++;
      a.push_back(x % 10);
      x /= 10;
    }
    reverse(a.begin(), a.end());
    if(n != keta){
      continue;
    }
    bool flg = true;
    for(int j = 0; j < m; j++){
      if(a[sc[j][0]-1] != sc[j][1]){
        flg = false;
      }
    }
    if(flg){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char S;
  cin >> S;
  if ((S == 'a')||(S == 'e')||(S == 'i')||(S == 'o')||(S == 'u')){
    cout << "vowel" <<endl;
  }else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
//#define int long long
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0)
int f(int x){
	if(x == 0) return 0;
	return (x%10) + f(x/10);
}
int32_t main(){
	IOS;
	int n;
	cin >> n;
	int ans = 1000;
	for(int i=1; i<n; i++){
		ans = min(ans, f(i) + f(n-i));
	}
	cout << ans << endl;
	
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;




int main() {
    int n; cin >> n;
    int a[n],total = 0;;
    for(int i = 0;i < n;i++) {
        cin >> a[i];
        total += a[i];
    }
    
    int m; cin >> m;
    for(int i = 0;i < m;i++){
        int e,f;
        cin >> e >> f;
        cout << total - a[e-1] + f << endl;
    }
}



Measured memory_bytes: 256
ansli=[]

while 1:
    n=input()
    if n=="0":
        break
    a=input().split()
    up=0
    down=1
    lu=0
    ru=0
    ld=0
    rd=0
    count=0
    for i in a:
        if i=="ru":
            ru=1
            rd=0
        elif i=="lu":
            lu=1
            ld=0
        elif i=="rd":
            rd=1
            ru=0
        elif i=="ld":
            ld=1
            lu=0

        if ru==1 and lu==1 and down==1:
            count+=1
            down=0
            up=1
        elif rd==1 and ld==1 and up==1:
            count+=1
            down=1
            up=0
    ansli.append(count)
    #print(count)
for i in ansli:
    print(i)



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

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  for (int i = 0; i < a; i++) {
    cin >> p.at(i);
  }
  for (int i = 0; i < b; i++) {
    cin >> q.at(i);
  }
  for (int i = 0; i < c; i++) {
    cin >> r.at(i);
  }
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  sort(r.rbegin(), r.rend());
  int64_t ans = accumulate(p.begin(), p.begin() + x, 0ll)
    + accumulate(q.begin(), q.begin() + y, 0ll);
  int k = x, l = y;
  for (int i = 0; i < c; i++) {
    if (k == 0) {
      if (l == 0) break;
      if (q.at(l - 1) >= r.at(i)) break;
      ans += r.at(i) - q.at(l - 1);
      l--;
    } else if (l == 0 || p.at(k - 1) < q.at(l - 1)) {
      if (p.at(k - 1) >= r.at(i)) break;
      ans += r.at(i) - p.at(k - 1);
      k--;
    } else {
      if (q.at(l - 1) >= r.at(i)) break;
      ans += r.at(i) - q.at(l - 1);
      l--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
def CP(a,b):
	x = a[1]*b[2]-a[2]*b[1]
	y = a[2]*b[0]-a[0]*b[2]
	z = a[0]*b[1]-a[1]*b[0]
	return (x,y,z)

minus = lambda d:tuple(-i for i in d)

class dice:
	def __init__(self,data):
		names = [(1,0,0),(0,0,1),(0,1,0),(0,-1,0),(0,0,-1),(-1,0,0)]
		self.faces = {n:d for n,d in zip(names,data)}
		self.top = (1,0,0)
		self.north = (0,0,-1)
	
	def turn(self,direction):
		if direction == 'N':
			self.top,self.north = minus(self.north),self.top
		elif direction == 'S':
			[self.turn('N') for i in range(3)]
		elif direction == 'W':
			self.top = CP(self.top,self.north)
		elif direction == 'E':
			[self.turn('W') for i in range(3)]
	
	def get_name(self,value):
		for n,v in self.faces.items():
			if v == value:
				return n


if __name__ == '__main__':
	data = [int(i) for i in input().split()]
	d = dice(data)
	q = int(input())
	for i in range(q):
		a,b = [int(s) for s in input().split()]
		a_name = d.get_name(a)
		b_name = d.get_name(b)
		c_name = CP(b_name,a_name)
		print(d.faces[c_name])

Measured memory_bytes: 7748
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long a, b, k;
  	cin >> a >> b >> k;
  	if(k<=a){
  		a -= k;
  	}else if(k<=a+b){
  		b -= (k - a);
        a = 0;
  	}else{
  		a = 0;
  		b = 0;
  	}
  	cout << a << " " << b <<endl;
}



Measured memory_bytes: 256
require 'set'

def click(a, i, j)
    a[i][j] += 1
    if a[i][j] == 5
        a[i][j] = 0
        blow(a, [ [i, j, 1, 0], [i, j, -1, 0], [i, j, 0, 1], [i, j, 0, -1]])
    end
end

def blow(a, arrows)
    new_arrows = []
    arrows.each do |i, j, di, dj|
        i += di
        j += dj
        next if i < 0 or i > 3 or j < 0 or j > 3
        if a[i][j] > 0
            a[i][j] += 1
        else
            new_arrows << [i, j, di, dj]
        end
    end
    (0..3).each do |i|
        (0..3).each do |j|
            if a[i][j] >= 5
                a[i][j] = 0
                new_arrows += [ [i, j, 1, 0], [i, j, -1, 0], [i, j, 0, 1], [i, j, 0, -1] ]
            end
        end
    end
    return if new_arrows.empty?
    blow(a, new_arrows)
end

def encode(a)
    a.flatten.inject {|sum, x| (sum << 2) + x}
end

start = (1..4).map { gets.split.map(&:to_i) }
if encode(start) == 0
    puts 0
    exit
end
reached = Set.new
reached << encode(start)

queue = [start]
(1..5).each do |c|
    new_queue = []
    until queue.empty?
        a = queue.shift
        (0..3).each do |i|
            (0..3).each do |j|
                b = Marshal.load(Marshal.dump(a))
                click(b, i, j)
                code = encode(b)
                if code == 0
                    puts c
                    exit
                end
                next if reached.include?(code)
                reached << code
                new_queue << b
            end
        end
    end
    queue = new_queue
end

puts -1

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

int main() {
  ll K, A, B;
  cin >> K >> A >> B;
  if (B-A < 3) {
    cout << K+1 << endl;
    return 0;
  }
  ll L = K-A+1;
  cout << L/2 * (B-A) + A + L%2 << endl;
}

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


int main(void)
{
    double x1, x2, y1, y2;

    cin >> x1 >> y1 >> x2 >> y2;
    double distance = sqrt(pow(x1-x2, 2) + pow(y1-y2, 2));
    cout << setprecision(10) << distance << endl;

    return 0;
}

Measured memory_bytes: 3284
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back

int N,D;
float X[20][20];
int ans=0;
int MOD=1000000007;
signed main(){
    scanf("%lld %lld",&N,&D);
    rep(i,N){
        rep(j,D){
            scanf("%f",&X[i][j]);
        }
    }
    rep(i,N){
        for(int j=i+1;j<N;j++){
            float kyori=0;
            rep(k,D){
                kyori+=pow(X[i][k]-X[j][k],2.0);
            }
            if(sqrt(kyori)==(int)sqrt(kyori)){
                ans++;
            }
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 128
import math

N = int(input())
A = [int(n) for n in input().split()]

gcd_l = [0]
gcd_r = [0]


for i in range(N):
    gcd_l.append(math.gcd(gcd_l[i], A[i]))
    gcd_r.append(math.gcd(gcd_r[i], A[-(i+1)]))

gcd_r = gcd_r[::-1]

max_gcd = 0
for i in range(N):
    max_gcd = max(max_gcd, math.gcd(gcd_l[i], gcd_r[i+1]))

print(max_gcd)

Measured memory_bytes: 21804
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    ll sum = 0;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        a[i] = temp;
        sum += temp;
    }
    ll ave1 = sum / n;
    ll ave2 = ave1 + 1;

    ll cost1 = 0, cost2 = 0;

    for (ll i = 0; i < n; i++)
    {
        ll temp1 = (a[i] - ave1) * (a[i] - ave1);
        ll temp2 = (a[i] - ave2) * (a[i] - ave2);
        cost1 += temp1;
        cost2 += temp2;
    }

    cout << min(cost1, cost2) << endl;
}


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

int main() {
    long long n; cin >> n; vector<int> v;
    while (n > 0) {
        int q = n % 26; 
        if (q == 0) {v.push_back(26); n/= 26; n--;}
        else {v.push_back(q); n /= 26;}
    } for (int i = v.size()-1; i >= 0; i --) cout << char('a'+v[i]-1); cout << endl;
}

Measured memory_bytes: 3604
import itertools
n = int(input())
data = list(map(int, input().split()))
data1=sorted(data)
a = list(itertools.combinations(data1,3))
ans=0
for m in range(len(a)):
  if a[m][0]!=a[m][1] and a[m][1]!=a[m][2]:
    if a[m][0]+a[m][1]>a[m][2]:
      ans=ans+1
print(ans)

Measured memory_bytes: 20568
#include<stdio.h>

int main(){
  int a,b,i,j,k;
  scanf("%d%d",&a,&b);
  if(a > b){
    i = a;
    j = b;
  }
  else{
    i = b;
    j = a;
  }
  while( j != 0){
    k = j;
    j = i % j;
    i = k;
  }
  printf("%d\n",i);
  return 0;
}

Measured memory_bytes: 592
import itertools

n=int(input())
p=[int(i) for i in input().split()]
q=[int(i) for i in input().split()]
t=[int(i) for i in range(1,n+1)]
a=b=0
for i,j in enumerate(list(itertools.permutations(t,n))):
    w=[1,1]
    for x,y in enumerate(j):
        if p[x]!=y: w[0]=0
        if q[x]!=y: w[1]=0
    if w[0]: a=i
    if w[1]: b=i

print(abs(a-b))

Measured memory_bytes: 80280