akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b; cin>>a>>b;
  auto ma=prime_factor(a);
  auto mb=prime_factor(b);
  ll cnt=0;
  for(auto e: ma){
    if(mb[e.first]!=0) cnt++;
  }
  cnt++;
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	
	while (scanf("%d", &n) * n != 0){
		int i, j;
		int maxi = 0;
		int mini = 1000000;
		
		for (i = 0; i < n; i++){
			int sum = 0;
			
			for (j = 0; j < 5; j++){
				int t;
				
				scanf("%d", &t);
				sum += t;
			}
			if (maxi < sum) maxi = sum;
			if (mini > sum) mini = sum;
		}
		printf("%d %d\n", maxi, mini);
	}
	
	return 0;
}

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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

int main()
{
    int N;
    int X[105];
    cin >> N;
    REP(i, N)
        cin >> X[i];
    int sum = 0;
    REP(i, N)
        sum += X[i];
    double ave = (double)sum / (double)N;
    int ans = round(ave);
    int wa = 0;
    REP(i, N)
        wa += (X[i] - ans) * (X[i] - ans);
    cout << wa << endl;
    
    
    return 0;
    
}



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll MAX=-INF;
  ll MIN=INF;
  ll MAXa=-1;
  ll MINa=-1;
  vector<P>ans;
  rep(i,n){
    if(a[i]>MAX){
      MAXa=i;
      MAX=a[i];
    }
    if(a[i]<MIN){
      MINa=i;
      MIN=a[i];
    }
  }
  if(MAX==0&&MIN==0){
    cout<<0<<endl;
    return 0;
  }
  if(MAX>0&&MIN<0){
    if(MAX>=-MIN){
      rep(i,n){
        if(i==MAXa)continue;
        a[i]+=MAX;
        ans.push_back(make_pair(MAXa,i));
      }
    }
    else {
      rep(i,n){
        if(i==MINa)continue;
        a[i]+=MIN;
        ans.push_back(make_pair(MINa,i));
      }
    }
  }
  MAX=-INF;
  MIN=INF;
  MAXa=-1;
  MINa=-1;
  rep(i,n){
    if(a[i]>MAX){
      MAXa=i;
      MAX=a[i];
    }
    if(a[i]<MIN){
      MINa=i;
      MIN=a[i];
    }
  }
  if(MAX>0){
    if(MAXa!=0){
      a[0]+=MAX;
      ans.push_back(make_pair(MAXa,0));
    }
    for(ll i=1;i<n;i++){
      a[i]=a[i-1]+a[i];
      ans.push_back(make_pair(i-1,i));
    }
  }
  else {
    if(MINa!=n-1){
      a[n-1]+=MIN;
      ans.push_back(make_pair(MINa,n-1));
    }
    for(ll i=n-1;i>=1;i--){
      a[i-1]=a[i]+a[i-1];
      ans.push_back(make_pair(i,i-1));
    }
  }
  cout<<ans.size()<<endl;
  rep(i,ans.size()){
    cout<<ans[i].first+1<<" "<<ans[i].second+1<<endl;
  }
}
  
  
        

Measured memory_bytes: 256
n,a,b,c=map(int,input().split())
s=[input() for _ in range(n)]
ans=[]
d={'A':a,'B':b,'C':c}
for i in range(n):
  x,y=list(s[i])
  if d[x]==0 and d[y]==0:
    print('No')
    exit()
  elif d[x]==1 and d[y]==1 and i<n-1:
    if x in s[i+1]:
      d[x]+=1
      d[y]-=1
      ans.append(x)
    else:
      d[x]-=1
      d[y]+=1
      ans.append(y)
  elif set((d[x],d[y]))==set((1,0)):
    d[x],d[y]=d[y],d[x]
    ans.append(x if d[x]>d[y] else y)
  elif d[x]>=d[y]:
    d[y]+=1
    d[x]-=1
    ans.append(y)
  else:
    d[y]-=1
    d[x]+=1
    ans.append(x)
print('Yes')
for ansi in ans:
  print(ansi)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll n;
ll t[111111];

int main(){
	cin.sync_with_stdio(false);
  cin>>n;
  rep(i,n)cin>>t[i];
  ll res=t[0];
  repl(i,1,n){
    ll tmp=res/__gcd(res,t[i])*t[i];
    res=tmp;
  }
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;
typedef long double ld;
typedef long long ll;
int n, q;

struct dsu {
    vector<int> p;
    vector<int> sz;

    dsu(int n) {
        p.resize(n);
        sz.resize(n, 1);
        iota(p.begin(), p.end(), 0);
    }

    int find(int a) {
        if (a == p[a]) return a;
        return p[a] = find(p[a]);
    }

    bool unite(int a, int b) {
        a = find(a);
        b = find(b);
        if (a == b) return false;
        if (sz[a] < sz[b]) swap(a, b);
        sz[a] += sz[b];
        p[b] = a;
        return true;
    }

    bool are_connected(int a, int b) {
        return find(a) == find(b);
    }
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> q;
    dsu P(n);
    vector<tuple<int, int, int> > ed;
    int INF = 1e9 + 5 * n;
    vector<int> g(2 * n, INF);
    for (int i = 0; i < q; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        ed.emplace_back(c, a, b);
        g[a] = min(g[a], c + 1);
        g[b] = min(g[b], c + 2);
        g[a + n] = min(g[a + n], c + n);
        g[b + n] = min(g[b + n], c + 1 + n);
    }
    int mn = INF;
    for (int i = 0; i < 2 * n; i++) {
        mn += 2;
        mn = min(mn, g[i]);
        if (mn < INF) {
            ed.emplace_back(mn, i % n, (i + 1) % n);
        }
    }
    sort(ed.begin(), ed.end());
    ll ans = 0;
    for (auto &it : ed) {
        if (P.unite(get<1>(it), get<2>(it))) ans += get<0>(it);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 18664
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int N, K;
    string S;
    cin >> N >> S >> K;
    
    char c;
    c = S[K - 1];
    
    for(int i = 0; i < S.length(); i++){
        if(S[i] != c){
            S[i] = '*';
        }
    }
    
    cout << S;
}

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

double data[101][5],mst[101];
bool used[101];
double cur,kyori,sum;
int cur_pos;

void prim(int n){
  
  for(int _= 1 ; _ <= n ; _++){
    used[_]=false;
    mst[_]=1e9;
  }
  
  mst[1]=0;
  
  for(int _=0 ; _ < n ; _++){
    cur=1e9;
    for(int i=1 ; i <= n ; i++){
      if(cur >= mst[i] && used[i] == false){
	cur=mst[i];
	cur_pos=i;
      }
    }
    
    used[cur_pos]=true;
    
    for(int i=1 ; i <= n ; i++){  
      if(i == cur_pos || used[i] == true)continue;
      kyori=sqrt((data[i][1]-data[cur_pos][1])*(data[i][1]-data[cur_pos][1])+(data[i][2]-data[cur_pos][2])*(data[i][2]-data[cur_pos][2])+(data[i][3]-data[cur_pos][3])*(data[i][3]-data[cur_pos][3]))-(data[i][4]+data[cur_pos][4]);
      if(kyori < 0)kyori=0;
      //cout <<kyori<<endl;
      if(mst[i] > kyori){
	mst[i]=kyori;
      }
    }
    
  }

  //for(int i=1 ; i <= n ; i++)cout <<mst[i]<<endl;
  
  sum=0;
  for(int i=1 ; i <= n ; i++)sum+=mst[i];

  printf("%.3lf\n",sum);

}
int main(){
  
  int n;
  
  while(1){
    
    cin >> n; 
    if(n == 0)break;
    
    for(int i=1 ; i <= n ; i++){
      for(int j=1 ; j < 5 ; j++){
	cin >>data[i][j];
      }
    }

    prim(n);

  }
  return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll MOD = ll(1e9+7);

int main() {
    ll n, t, ans = 1;
    cin >> n >> t;
    vector<ll> d(n);
    for(int i=0;i<n;i++){
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    for(int i=0;i<n;i++){
        ans *= (upper_bound(d.begin(), d.end(), d[i]+t)-d.begin()-i);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int a[10004];
int main() {
int n;
cin>>n;
int mx=a[0];
int s=0;
for(int i=0;i<n;i++){
    cin>>a[i];
    if(mx<a[i])
        mx=a[i];
}
sort(a,a+n);
for(int i=0;i<n-1;i++){
    s+=a[i];
}
if(s>mx){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector<int64_t> l(n);
    for (auto&& ll : l) {
        cin >> ll;
    }

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

    int64_t ans = 0;
    for (auto i : irange(0L, n)) {
        auto a = l[i];
        for (auto j : irange(i + 1, n)) {
            auto b = l[j];
            auto it = upper_bound(l.begin() + j + 1, l.end(), b - a);
            auto it2 = lower_bound(l.begin() + j + 1, l.end(), a + b);
            ans += it2 - it;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#define int long long
using namespace std;
  
int32_t main(){
  int n;
  map<int,int> m;
  cin >> n;
  int v[n];
  for(int i=0; i<n; i++) cin >> v[i];
  int sum = 0;
  int ans = 0;
  m[0]++;
  for(int i=0; i<n; i++){
    sum += v[i];
    ans += m[sum];
    m[sum]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 14336
class dice:
    def __init__(self, X):
        self.x = [0] * 6
        self.x[0] = X[0]
        self.x[1] = X[1]
        self.x[2] = X[2]
        self.x[3] = X[3]
        self.x[4] = X[4]
        self.x[5] = X[5]

    def roll(self, d):
        if d == 'S':
            self.x[0], self.x[1], self.x[2], self.x[3], self.x[4], self.x[5] = \
            self.x[4], self.x[0], self.x[2], self.x[3], self.x[5], self.x[1]
        elif d == 'E':
            self.x[0], self.x[1], self.x[2], self.x[3], self.x[4], self.x[5] = \
            self.x[3], self.x[1], self.x[0], self.x[5], self.x[4], self.x[2]
        elif d == 'W':
            self.x[0], self.x[1], self.x[2], self.x[3], self.x[4], self.x[5] = \
            self.x[2], self.x[1], self.x[5], self.x[0], self.x[4], self.x[3]
        elif d == 'N':
            self.x[0], self.x[1], self.x[2], self.x[3], self.x[4], self.x[5] = \
            self.x[1], self.x[5], self.x[2], self.x[3], self.x[0], self.x[4]

X = list(map(int, input().split()))
directions = list(input())
d_one = dice(X)
for dist in directions:
    d_one.roll(dist)
print(d_one.x[0])


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

#define cc(x) cout << (x) << endl
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<long long> vll;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

const ll inf = 1LL<<58;
const int iinf = 1<<30;
const int MAX = 1e6+2;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    ll x,y;
    cin >> x >> y;
    ll mod=1e9+7;
    if((x+y)%3!=0){
        cc(0);
        return 0;
    }
    COMinit();
    ll n = (x+y)/3;
    ll m = x-n;
    cc(COM(n, m)%mod);
}

Measured memory_bytes: 23680
W, H, x, y, r = map(int, raw_input().split())
if x - r < 0 or x + r > W or y - r < 0 or y + r > H:
    print('No')
elif x -r >= 0 and x + r <= W and y - r >= 0 and y + r <= H:
    print('Yes')

    


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

struct Acc {
  vector<lli> sum;
  Acc() {}
  void init(vector<lli> v) {
    sum.clear();
    sum.push_back(0);
    each (i, v) {
      sum.push_back(sum.back() + i);
    }
    return ;
  }
  lli query(lli begin, lli end) {
    return sum[end] - sum[begin];
  }
};
Acc acc;

vector<lli> a;
const int N = 4000 + 5;
lli memo[N][N];
lli rec(int begin, int end)
{
  lli& ret = memo[begin][end];
  if (ret != -1) return ret;
  if (begin + 1 == end) return 0;

  lli mn = 1LL << 60;
  for (int i = begin + 1; i < end; ++i) {
    setmin(mn, rec(begin, i) + rec(i, end) + acc.query(begin, i) + acc.query(i, end));
  }

  return ret = mn;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    a.resize(n);
    cin >> a;
    acc.init(a);

    fill(&memo[0][0], &memo[N - 1][N - 1] + 1, -1);
    cout << rec(0, n) << endl;
  }

  return 0;
}


Measured memory_bytes: 125568
#include<stdio.h>
#define MAX 100000
#define SEN 2000000000

struct Card{
  char MARK;
  int N;
};

struct Card Li[MAX /2+2],Ri[MAX/2+2];

void merge(struct Card A[], int num,int le,int mid,int ri){
  int i,j,k;
  int n1=mid-le;
  int n2=ri - mid;

  for(i=0;i<n1;i++){
    Li[i]=A[le+i];
  }

  for(i=0;i<n2;i++){
    Ri[i]=A[mid+i];
  }

  Li[n1].N=Ri[n2].N=SEN;
  i=j=0;

  for(k=le;k<ri;k++){
    if(Li[i].N<=Ri[j].N){
      A[k]=Li[i++];
    }
    else{
      A[k] = Ri[j++];
    }
  }
}

  void mergeSort(struct Card X[],int num,int le,int ri){
    int mid;
    if(le +1<ri){
      mid =(le+ri) /2;
      mergeSort(X,num,le,mid);
      mergeSort(X,num,mid,ri);
      merge(X,num,le,mid,ri);
    }
  }

  
    int partition(struct Card A[],int num,int p,int r){
      int i,j;
      struct Card t,x;
      x = A[r];
      i = p-1;
      for(j=p;j<r;j++){
	if(A[j].N<=x.N){
	  i++;
	  t= A[i];
	  A[i] = A[j];
	  A[j] = t;
	}
      }
      t = A[i+1];
      A[i+1]=A[r];
      A[r]=t;
      return i+1;
    }

    void quickSort(struct Card Y[],int num,int p,int r){
      int q;
      if(p<r){
	q=partition(Y,num,p,r);
	quickSort(Y,num,p,q-1);
	quickSort(Y,num,q+1,r);
      }
    }


    
    int main(){
      int num,i,v;
      struct Card X[MAX],Y[MAX];
      char Sx[10];
      int sta =1;

      scanf("%d",&num);

      for(i=0;i<num;i++){
	scanf("%s %d",Sx,&v);
	X[i].MARK = Y[i].MARK =Sx[0];
	X[i].N = Y[i].N =v;
      }
      mergeSort(X,num,0,num);
      quickSort(Y,num,0,num-1);

      for(i=0;i<num;i++){
	if(X[i].MARK !=Y[i].MARK){
	  sta =0;
	}
      }

      if(sta ==1){
	printf("Stable\n");
      }
      else{
	printf("Not stable\n");
      }

      for(i=0;i<num;i++){
	printf("%c %d\n",Y[i].MARK,Y[i].N);
      }
    }
  



Measured memory_bytes: 4072
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import math

N = int(sys.stdin.readline().rstrip())

def ndigits(n):
  return int(math.log10(n) + 1)


# print(ndigits(N))
r = int(math.sqrt(N))

for i in range(r,0,-1):
  # print(i)
  if N%i == 0:
    break

print(max(ndigits(i), ndigits(N/i)))

Measured memory_bytes: 3060
/*
* @Author: Kabid
* @Date:   2020-04-29 14:50:32
* @Last Modified by:   Kabid
* @Last Modified time: 2020-05-13 14:02:40
*/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define  in(x) scanf("%d",&x);
#define out(x) printf("%d",x);
#define  ins(x)  scanf("%s",x);
#define outs(x) printf("%s",x);
#define lin puts("");
#define _ putchar(' ');

int t;       //test cases
int i,j;	 //iterators
ll  n,k,p,f,c,s;   //variables
string q;
char h;
int main(){
	cin>>q;
	if(q[2]==q[3]&&q[4]==q[5]){
		puts("Yes");
	}
	else{
		puts("No");
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <istream>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
int main(){
	int n;
	cin>>n;
	set<int> s;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		s.insert(a);
	}
	if(s.size()==n){
		cout<<"YES"<<endl;
	}
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 9600
N=int(input())
K=int(input())
#桁の数字を取得
dig=[]
n=N
while n>0:
  dig.append(n%10)
  n//=10
a=dig[-1]
digit=len(dig)

dp=[[0 for _ in range(digit)] for _ in range(3)]

dp[0][0]=dig[0]
for i in range(1,digit):
  if dig[i]==0:
    dp[0][i]=dp[0][i-1]
  else:
    dp[0][i]=dig[i]+9*i

for i in range(1,digit):
  if dig[i]==0:
    dp[1][i]=dp[1][i-1]
  else:
    dp[1][i]=dp[0][i-1]+(dig[i]-1)*9*i+81*i*(i-1)//2
    
for i in range(1,digit):
  if dig[i]==0:
    dp[2][i]=dp[2][i-1]
  else:
    dp[2][i]=(dp[1][i-1]  #i桁目がギリギリの場合
              +(dig[i]-1)*81*i*(i-1)//2 #i桁目を使う場合
              +729*i*(i-1)*(i-2)//6) #i桁目を使わない場合
print(dp[K-1][digit-1])

Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
N,K = [int(i) for i in readline().split()]
d = []
A = []
for _ in range(K):
  d.append(int(input()))
  A.append([int(i) for i in readline().split()])

concat_A = []
for a in A:
  concat_A += a
concat_A = set(concat_A)
print(N-len(concat_A))

Measured memory_bytes: 9296
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  std::map<int, int> mp;
  int N, Q;
  scanf("%d", &N);
  std::vector<int > A(N);
  long long sum=0;
  for (int i=0; i<N; i++){
    scanf("%d", &A[i]);
    mp[A[i]]++;
    sum+=A[i];
  }
  scanf("%d", &Q);
  std::vector<int > B(Q), C(Q);
  for (int i=0; i<Q; i++){
    scanf("%d", &B[i]);
    scanf("%d", &C[i]);
  }
  for (int i=0; i<Q; i++){
    sum-=(long long)B[i]*mp[B[i]];
    sum+=(long long)C[i]*mp[B[i]];
    //printf("-= %d*%d=%d\n", B[i], mp[B[i]], B[i]*mp[B[i]]);
    //printf("+= %d*%d=%d\n", C[i], mp[B[i]], C[i]*mp[B[i]]);
    mp[C[i]]+=mp[B[i]];
    mp[B[i]]=0;
    printf("%lld\n", sum);
  }
  
  return 0;
}
 

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


int main(){
  int n;
  cin >> n;
  int max1=0;
  int ans,total;
  rep(i,n){
     int p ;
     cin >> p;
     rep(i,n) max1 = max(max1,p);
     total+=p;
  }
  ans = total - max1/2 ;
  cout << ans << endl;
  }

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

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

typedef pair<int,int> P;

int main(){
    string a;
    while(cin>>a){
        int ans=0;
        rep(i,a.size()){
            long int A,B;
            if(i==0){
                A=0;
                B=stol(a);
            } else {
                if(a[i]=='0') continue;
                A=stol("0"+a.substr(0,i));
                B=stol(a.substr(i));
            }
            //cout<<A<<" "<<B<<endl;
            if(A<=B && A%2==B%2) ans++;
        }
        //cout<<"ans ";
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1204
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1 << 30;
LL ans=0;

LL gd(LL x,LL y){
//	if(x==1 && y==1)return 2333;
	if(!y)return ans-=x,x;
	if(x<y)swap(x,y);
	ans+=x/y*y*2;
//	printf("%lld %lld %lld  %lld\n",x,y,ans,x/y*y*2);
	return gd(y,x%y);
}

int main(){
	LL n,x;cin>>n>>x;
	ans=n;
	gd(max(n-x,x),min(n-x,x));
	printf("%lld\n",ans);

	return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	inline int ts(char *s)
	{
		int a=0,c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)s[a++]=c,c=fetch();
		s[a]=0;
		return a;
	}
}
using ae86::ty;
using ae86::ts;

const int _ = 200007;

int n;char s[_];

int main()
{
	n=ts(s+1);

	lint ans=0;int cnta=0;
	for(int i=1;i<=n;)
	{
		if(s[i]=='A')cnta++,i++;
		else if(s[i]=='B' && s[i+1]=='C')ans+=cnta,i+=2;
		else cnta=0,i++;
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;

int main(){
	int h,w;
	cin >> h >> w;
	char field[h][w];
	rep(i,h){
		rep(j,w){
			cin >> field[i][j];
		}
	}
	bool can = true;
	rep(i,h){
		rep(j,w){
			if(field[i][j]=='.') continue;
			bool a = false;
			bool b = false;
			bool c = false;
			bool d = false;
			if(i==0);
			else if(field[i-1][j] == '#') a = true;
			if(i==h-1);
			else if(field[i+1][j] == '#') c = true;
			if(j==0);
			else if(field[i][j-1] == '#') b = true;
			if(j==w-1);
			else if(field[i][j+1] == '#') d = true;
			//来た未知が2つあったら
			if(a&&b) can = false;
			//行く未知が2つあったら
			if(c&&d) can = false;
		}
	}
	if(can) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int gcd(int i,int j){
  
  int k=i%j;

  while(k!=0){
     i=j;
     j=k;
     k=i%j;
   }
  return j;
}

int main(){
  int i,j;
  scanf("%d %d",&i,&j);
  printf("%d\n", gcd(i,j));
  return 0;
}



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

using namespace std;

int sumOfNum(int number)
{
	int total = 0;
	while (number > 0) {
		total += number % 10;
		number /= 10;
	}
	return total;
}

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

	int result = 0;

	for (int i = 1; i <= n; i++) {
		if (a <= sumOfNum(i) && sumOfNum(i) <= b) {
			result += i;
		}
	}

	cout << result << endl;
	return 0;
}


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

int main() {
  int x, y;
  for(int i = 0; i < 3000 ; i++){
    cin >> x >> y;
    if(x==0 && y== 0){
      break;
    }
    int z;
    if(x>y){
      z = x;
      x = y;
      y = z;
    }
    cout << x << " " << y << endl;
  }
}



Measured memory_bytes: 3012
fun main(args: Array<String>) {
    val line = readLine()!!.split(' ')
    var amount = Integer.parseInt(line[0])

    val ignore = readLine()!!.split(' ')


    while(true) {
        var flag = false
        ignore.forEach {
            if(amount.toString().contains(it)) {
                flag = true
            }
        }
        if(!flag){
            break
        }
        amount++
    }
    println(amount)
}

Measured memory_bytes: 48496
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;

int par[maxn], rank_[maxn];

int find(int x) {
    if (par[x]==x) return x;
    return par[x]=find(par[x]);
}
 
void unite(int x, int y) {
    x=find(x), y=find(y);
    if (x==y) return;
    if (rank_[x] < rank_[y]) par[x]=y;
    else {
        par[y]=x;
        if (rank_[x]==rank_[y]) rank_[x]++;
    }
}

void solve() {
	ll n,m,u,v; cin >> n >> m;
	rep(i,0,n+1) par[i] = i;
	rep(i,0,m) {
		cin >> u >> v;
		unite(u,v);
	}
	set<int> s;
	rep(i,1,n+1) {
		s.insert(find(i));
	}
	cout << s.size() - 1 << '\n';
}

int main(int argc, char * argv[]) 
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:/Users/Fish_Brother/Desktop/in", "r", stdin);
	//freopen("C:/Users/Fish_Brother/Desktop/out", "w", stdout);
#endif

	//int t; cin >> t; while(t--)
	solve();

    return 0;
}

Measured memory_bytes: 7968
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
  int n, c;
  const int num[10][7] = {
    {0, 1, 1, 1, 1, 1, 1},
    {0, 0, 0, 0, 1, 1, 0},
    {1, 0, 1, 1, 0, 1, 1},
    {1, 0, 0, 1, 1, 1, 1},
    {1, 1, 0, 0, 1, 1, 0},
    {1, 1, 0, 1, 1, 0, 1},
    {1, 1, 1, 1, 1, 0, 1},
    {0, 1, 0, 0, 1, 1, 1},
    {1, 1, 1, 1, 1, 1, 1},
    {1, 1, 0, 1, 1, 1, 1}
  };

  while (cin >> n, n != -1){
    int seg[] = {0, 0, 0, 0, 0, 0, 0};
    while (n--){
      cin >> c;
      for (int i = 0; i < 7; i++){
        if (seg[i] != num[c][i]){
          seg[i] = 1;
        }
        else {
          seg[i] = 0;
        }
        cout << seg[i];
      }
      memcpy(seg, num[c], sizeof(int) * 7);
      cout << endl;
    }
  }

  return (0);
}

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

using namespace std;

int main()
{
    string s ;
    cin>>s ;
    int n = s.size() ;
    int cnt = 0 ;
    for(int i = 0 ; i < n ; ++i)
    {
        if(s[i] == 'o')
            cnt++ ;
    }
    if(cnt + 15-n >= 8)
        return cout<<"YES\n" , 0 ;
    return cout<<"NO\n" , 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N,K;
  cin>>N>>K;
  
  vector<int> d;
  vector<vector<int>> A;
  
  d.resize(K);
  A.resize(K,vector<int>());
  for(int i=0;i<K;i++){
    cin>>d[i];
    A[i].resize(d[i]);
    for(int j=0;j<d[i];j++){
      cin>>A[i][j];
    }
  }
  
  vector<int> check(N);
  for(int i=0;i<N;i++){
    check[i]=i+1;
  }
  
  for(int i=0;i<K;i++){
    for(int j=0;j<d[i];j++){
      for(int k=0;k<N;k++){
        if(A[i][j]==check[k]){
          check[k]=1000;
        }
      }
    }
  }
  
  int ans=0;
  
  for(int k=0;k<N;k++){
    if(check[k]==1000){
      ans++;
    }
  }
  
  cout<<N-ans<<endl;
}

Measured memory_bytes: 3556
S = input()
T = input()
len_t = len(T)
len_s = len(S)
ans = [''] * (len_s)
for i in range(len_s)[::-1]:
  if len_t-1 > i:
    break
  hasT = True
  for j in range(len_t):
    if T[j] != S[i-len_t+1+j] and S[i-len_t+1+j] != '?':
      hasT = False
      break
  if hasT:
    for j in range(len_t):
      if S[i-len_t+1+j] == '?':
        ans[i-len_t+1+j] = T[j]
    for k in range(len_s):
      if S[k] == '?' and ans[k] == '':
        ans[k] = 'a'
      elif ans[k] == '':
        ans[k] = S[k]
    print(''.join(ans))
    exit()
print('UNRESTORABLE')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 303;
bool vis[N][N][N];
double dp[N][N][N];

int n;

double E(int x, int y, int z){
    if(x+y+z == 0) return 0;
    if(vis[x][y][z]) return dp[x][y][z];

    int w = n-(x+y+z);

    double ret = 1;
    if(x>0) ret += E(x-1,y,z)*x/n;
    if(y>0) ret += E(x+1,y-1,z)*y/n;
    if(z>0) ret += E(x,y+1,z-1)*z/n;

    ret /= (double)(n-w)/n;
    vis[x][y][z] = true;
    return dp[x][y][z] = ret;
}

int main(){
    scanf(" %d", &n);

    int a[4]={};
    rep(i,n){
        int num;
        scanf(" %d", &num);
        ++a[num];
    }

    printf("%.15f\n", E(a[1],a[2],a[3]));
    return 0;
}


Measured memory_bytes: 244096
n = int(input())
a = list(map(int,input().split()))
a.append(0)
a = sorted(a)

while len(a) > 2:
    for i in range(2,n):
        a[i] %= a[1]
        
    a = sorted(set(a))
    n = len(a)
    
print(a[1])

Measured memory_bytes: 14224
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#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 ALL(a) (a).begin(), (a).end()
#define MOD 1000000007

int main() {
    ll N, K, A[2000];
    cin >> N >> K;
    map<ll, ll> m;
    REP(i, N) {
        cin >> A[i];
        m[A[i]]++;
    }

    ll ans = 0, n;
    if (K % 2 == 0) n = K / 2 * (K - 1) % MOD;
    else n = (K - 1) / 2 * K % MOD;
    REP(i, N) {
        ll tmp = 0;
        FOR(j, i + 1, N) {
            if (A[j] < A[i]) tmp++;
        }
        tmp %= MOD;
        ans += tmp * K % MOD;
        ans %= MOD;

        tmp = 0;
        for (auto p : m) {
            if (p.first < A[i]) tmp += p.second;
        }
        tmp %= MOD;
        ans += tmp * n % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ');
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
//cout << fixed << setprecision(10);

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

  vi c_ac(n), c_wa(n);
  rep(i,m) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    
    if (s == "AC" && c_ac[p] == 0) {
      c_ac[p]++;
    }
    else if (s == "WA" && c_ac[p] == 0) {
      c_wa[p]++;
    }
  }

  int x = 0, y = 0;
  rep(i,n) {
    x += c_ac[i];
    if (c_ac[i] >= 1) {
      y += c_wa[i];
    }
  }

  cout << x SP y << endl;
  return 0;
}

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

ll sad (vector<ll> &a,ll b){
	ll ans=0;
	for(ll i=0;i<a.size();i++){
		ans+=abs(a.at(i)-(b+i+1));
	}
	return ans;
}


int main() {
	ll N;
	cin>>N;
	vector<ll> a(N);
	for(ll i=0;i<N;i++){
		cin>>a.at(i);
		a.at(i)=a.at(i)-(i+1);
	}
	sort(a.begin(),a.end());
	ll mi=a.at(N/2);
	ll ans=0;
	for(ll i=0;i<N;i++){
		ans+=llabs(a.at(i)-mi);
	}
	
	
	cout<<ans<<endl;
	
}





Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;cin >> N;
    int a[3];
    string str;
    str = std::to_string(N);
    string ans = "No";
    if(str[1]==str[2]){
        if(str[1]==str[0]||str[1]==str[3]){
            ans = "Yes";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()

ans=10**100
sumarr=sum(arr)
sum2arr=sum(list(map(lambda  x:x**2,arr)))


for i in range(-100,101):
    b=n*(i**2)-2*sumarr*i+sum2arr
    ans=min(b,ans)
print(ans)


Measured memory_bytes: 63980
import math
s = [1 if x == "R" else -1 for x in input()]
ans = [0]*len(s)
i = 0
while i < len(s):
    locate = i
    if locate < len(s)-1:
        while s[locate+1] == s[i]:
            locate += 1
            if locate >= len(s)-1:
                break
    count = locate - i + 1
    tmp = math.ceil(count/2)
    if s[i] == 1:
        ans[locate] += tmp
        ans[locate+1] += count - tmp
    else:
        ans[i] += tmp
        ans[i-1] += count - tmp
    i = locate + 1
print(*ans)


Measured memory_bytes: 7080
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

    cout << 24+ 24-n << endl;
    
    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)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<lint, lint> pll;
typedef complex<double> xy_t;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    string s;
    cin>>s;
    set<int> G[n];
    int a[n], b[n];
    bool ok[n];
    rep(i, n){
        a[i]=b[i]=0;
        ok[i]=true;
    }
    rep(i, m){
        int x, y;
        scanf("%d%d", &x, &y);
        --x; --y;
        G[x].insert(y);
        G[y].insert(x);
    }

    rep(v, n)for(int nv: G[v]){
        if(s[nv]=='A') ++a[v];
        else ++b[v];
    }
    queue<int> que;
    rep(i, n)if(!a[i] || !b[i]){
        que.push(i);
        ok[i]=false;
    }
    while(!que.empty()){
        int v=que.front(); que.pop();
        for(int nv: G[v])if(ok[nv]){
            if(s[v]=='A') --a[nv];
            else --b[nv];
            if(!a[nv] || !b[nv]){
                que.push(nv);
                ok[nv]=false;
            }
        }
    }
    rep(i, n)if(ok[i]){
        printf("Yes\n");
        return 0;
    }
    printf("No\n");
}

Measured memory_bytes: 29188
K = int(input()) - 1
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[K])

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;

	int a = A, b = B, c = C;
	int ans = 0;
	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
	{
		int nA = (b + c) / 2, nB = (a + c) / 2, nC = (a + b) / 2;
		if (nA == A&&nB == B&&nC == C)
		{
			cout << -1 << endl;
			return 0;
		}
		a = nA, b = nB, c = nC;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n,m = gets.chomp.split(" ").map(&:to_i)
a_arr = gets.chomp.split(" ").map(&:to_i)

sum = a_arr.sum.to_f / (4 * m)
if a_arr.count{|a| a >= sum } >= m
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 14400
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	bool p[33000]={false};
	bool f = false;
	
	for(int i = 3; i < 32790; i+=2){
		f = false;
		for(int j = 2; j * j <= i; j++){
			if(i % j == 0){
				f = true;
				break;
			}
		}
		if(f == false){
			p[i] = true;
		}
	}
	p[2] = true;
	
	//素数作り
	
	int n;
	while(scanf("%d",&n),n){
		int cnt = 0;
		bool check[33000] = {false};
		for(int i = 1; i < 32768; i++){
			if(p[i] == false || check[i] == true)continue;
			for(int j = i ; j < 32768; j++){
				if(p[j] == false || check[j] == true)continue;
				if(i + j == n){
					cnt++;
					//printf("d:%d %d\n",i,j);
					check[i] = true;
					check[j] = true;
					break;
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 1100
#include <iostream>
#include <math.h>
#include <algorithm>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
W,H,N = map(int, input().split())
minX = 0
maxX = W
minY = 0
maxY = H

for i in range(N):
  x,y,a = map(int, input().split())
  if a==1:
    minX = max(minX,x)
  elif a==2:
    maxX = min(maxX,x)
  elif a==3:
    minY = max(minY,y)
  elif a==4:
    maxY = min(maxY,y)

#print(minX,maxX,minY,maxY)
    
if minX >= maxX or minY >= maxY:
  print(0)
else:
  print((maxX - minX)*(maxY - minY))

Measured memory_bytes: 3064
import heapq

N = int(input())
tasks = []

fin = 0
for _ in range(N):
    A, B = map(int, input().split())
    fin = max(fin, B)
    heapq.heappush(tasks, (-B, A, B))

now = fin

while len(tasks)>0:
    _, time, deadline = heapq.heappop(tasks)
    now = min(deadline, now)
    now -= time

if now >= 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 36660
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" "<<x<<endl;
int main()
{
    int n;

    cin >> n;

    vector<int> a(n),b(n),c(n);

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

      int dp1[n],dp2[n],dp3[n];

      dp1[0] = a[0];
      dp2[0] = b[0];
      dp3[0] = c[0];

     for(int i = 1; i < n; i++)
     {
         dp1[i] = a[i] + max(dp2[i-1],dp3[i-1]);
         dp2[i] = b[i] + max(dp1[i-1],dp3[i-1]);
         dp3[i] = c[i] + max(dp2[i-1],dp1[i-1]);
     }

     cout << max(dp1[n-1],max(dp2[n-1],dp3[n-1]));
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<ctime>
using namespace std;
template<typename T>void read(T &x){
	x=0;int f(1);char c(getchar());
	for(;!isdigit(c);c=getchar())if(c=='-')f=-f;
	for(; isdigit(c);c=getchar())x=(x<<3)+(x<<1)+(c-'0');
	x*=f;
}
template<typename T>void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x/10)write(x/10),x%=10;
	putchar(x+'0');
}
const int maxn=100005;
int va[maxn],a,b,c;
char Ans[maxn];
int judge(int v){
	if(v==0)return a||b;
	if(v==1)return a||c;
	if(v==2)return b||c;
	return 0;
}
int main(){
	int n;
	read(n),read(a),read(b),read(c);
	for(int i=1;i<=n;++i){
		char s[3];scanf("%s",s);
		if(s[0]=='A'&&s[1]=='B')va[i]=0;
		if(s[0]=='A'&&s[1]=='C')va[i]=1;
		if(s[0]=='B'&&s[1]=='C')va[i]=2;
	}
	for(int i=1;i<=n;++i){
		if(!judge(va[i])){
			puts("No");return 0;
		}
		if(va[i]==0){
			if(i!=n&&a==b){
				--a,++b;
				if(judge(va[i+1]))Ans[i]='B';
				else ++a,++a,--b,--b,Ans[i]='A';
			}
			else if(a>b)--a,++b,Ans[i]='B';
			else ++a,--b,Ans[i]='A';
		}
		if(va[i]==1){
			if(i!=n&&a==c){
				--a,++c;
				if(judge(va[i+1]))Ans[i]='C';
				else ++a,++a,--c,--c,Ans[i]='A';
			}
			else if(a>c)--a,++c,Ans[i]='C';
			else ++a,--c,Ans[i]='A';
		}
		if(va[i]==2){
			if(i!=n&&b==c){
				--b,++c;
				if(judge(va[i+1]))Ans[i]='C';
				else ++b,++b,--c,--c,Ans[i]='B';
			}
			else if(b>c)--b,++c,Ans[i]='C';
			else ++b,--c,Ans[i]='B';
		}
	}
	puts("Yes");
	for(int i=1;i<=n;++i){
		putchar(Ans[i]),putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 4296
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int x,ans=700;
    char s[4];
    cin >> s;
    for(x=0;x<3; x++){
        if(s[x] == 'o'){
            ans = ans + 100;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*====Corycle====*/
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<cstdio>
#include<vector>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const int M=1<<21;
const int N=21;
int read(){
	int s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
	return s*f;
}
char s[M];
int n,m,f[N][M],num[M],ch[M][2];
int main(){
//	freopen("_.in","r",stdin);
//	freopen("_.out","w",stdout);
	n=read();m=read();
	for(int i=0;i<=n;i++){
		scanf("%s",s);
		for(int j=0;j<(1<<i);j++){
			f[i][j|(1<<i)]=s[j]-'0';
		}
	}
	num[0]=-1;
	for(int i=1;i<(2<<n);i++)num[i]=num[i>>1]+1;
	for(int i=2;i<(2<<n);i++){
		if((i>>(num[i]-1))&1){
			ch[i][1]=i^(1<<num[i]);
			ch[i][0]=ch[ch[i][1]][0];
		}
		else{
			ch[i][0]=i^(3<<(num[i]-1));
			ch[i][1]=ch[ch[i][0]][1];
		}
	}
	for(int i=n;i>=1;i--){
		for(int S=1<<i;S<(2<<n);S++){
			if(!f[i][S])continue;
			int tmp=S>>i;
			int T=(S&((1<<i)-1))^(1<<i);
			if(ch[T][0])f[num[ch[T][0]]][(((tmp<<1)^1)<<num[ch[T][0]])^ch[T][0]]+=f[i][S];
			if(ch[T][1])f[num[ch[T][1]]][(((tmp<<1)^0)<<num[ch[T][1]])^ch[T][1]]+=f[i][S];
			f[0][tmp]+=f[i][S];
		}
	}
	int Ans=1;
	for(int S=2;S<(2<<n);S++){
		if(f[0][S]>=m&&num[S]>num[Ans])Ans=S;
	}
	for(int i=num[Ans]-1;i>=0;i--)printf("%d",(Ans>>i)&1);
	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

char s[MAXN];
char c[] = "CODEFESTIVAL2016";

void solve(){
	scanf("%s", &s[0]);
	int ans = 0;
	for(int i = 0; c[i]; i++){
		if (s[i] != c[i]){
			ans++;
		}
	}
	printf("%d\n", ans);
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

Measured memory_bytes: 256
#include <limits.h>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>

#include <bits/stdc++.h>

namespace test {
std::string to_string(char val) {
    return std::string(1, val);
    // return std::string{val};
}
}  // namespace test

using namespace std;

int main(void) {
    int a,b; cin >> a >> b;
    int result = 0;
    for(int i = 0; i< 2; i++){
        if(a > b){
            result += a;
            --a;
        } else {
            result += b;
            --b;
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256