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

using namespace std;
#define int long long
const int N = 45, MOD = 1e9 + 7;
long long dp[1 << 18][N];

int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, x, y, z; cin >> n >> x >> y >> z;
    long long ans = 1;
    y+=x; z+=y;
    dp[1][0] = 1;
    for (int i = 1; i <= n; i ++) {
        for (int mask = 1; mask < (1 << 18); mask++) if (dp[mask][i - 1]) {
            for (int j = 1; j <= 10; j++) {
                int _mask = (mask << j | 1) & ((1 << 18) - 1);
                if ((_mask & (1 << x)) && (_mask & (1 << y)) && (_mask & (1 << z))) continue ;
                dp[_mask][i] += dp[mask][i - 1];
                dp[_mask][i] %= MOD;
            }
        }
        ans = (ans * 10) % MOD;
    }
    for (int mask = 0; mask < (1 << 18); mask++) {
        if ((mask & (1 << x)) && (mask & (1 << y)) && (mask & (1 << z))) continue ;
        ans = (ans - dp[mask][n] + MOD) % MOD;
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 92416
import sys
readline = sys.stdin.readline
write = sys.stdout.write

class KMP:
    def __init__(self, W):
        L = len(W)
        T = [0] * (L+1)
        T[0] = -1
        c = 0
        for p in range(1, L):
            if W[p] == W[c]:
                T[p] = T[c]
            else:
                T[p] = c
                c = T[c]
                while c >= 0 and W[p] != W[c]:
                    c = T[c]
            c += 1
        T[L] = c
        self.T = T
        self.W = W

    def search(self, S):
        W = self.W; T = self.T
        R = []
        LS = len(S); LW = len(W)
        # S[i], W[j]
        i = j = 0
        while i < LS:
            if S[i] == W[j]:
                i += 1; j += 1
                if j == LW:
                    R.append(i-j)
                    j = T[j]
            else:
                j = T[j]
                if j < 0:
                    i += 1
                    j += 1
        return R

def solve():
    T = readline().strip()
    P = readline().strip()
    kmp = KMP(P)
    res = kmp.search(T)
    for p in res:
        write("%d\n" % p)
solve()


Measured memory_bytes: 47928
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

bool prb[10000001];

int main(){
	
	int n;
	
	int max = 0;
	
	cin >> n;
	
	for(int i = 0; i < 10000001; i++){
		prb[i] = false;
	}
	
	for(long long int i = 0; i < 100000; i++){
		if(i * (i + 1) / 2 >= n){
			max = i;
			break;
		}
	}
	
	//cout << max << endl;;
	
	for(int i = max; i > 0; i--){
		if(n - i >= 0){
			n -= i;
			prb[i] = true;
		}
	}
	
	for(int i = 1; i < 10000001; i++){
		if(prb[i]){
			cout << i << endl;
		}
	}
	
	return 0;
}



Measured memory_bytes: 10112
import sys
import copy

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	SS = IS()
	ans = 0
	for l in range(N-1):
		i = 1
		j = 0
		S = copy.copy(SS[l:])
		A = [0]*len(S)
		while (i < len(S)):
			while (i+j < len(S) and S[j] == S[i+j]):
				j+=1
			A[i] = j
			if (j == 0):
				i+=1
				continue
			k = 1
			while (i+k < len(S) and k+A[k] < j):
				A[i+k] = A[k]
				k+=1
			i += k
			j -= k
		for m in range(len(S)):
			ans = max(ans, min(m, A[m]))
	print(ans)

main()

Measured memory_bytes: 49116
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n;
LL x;
vector<LL> a;
LL ans = 0;
/**********************************************/

int main(){
    cin >> n >> x;
    a.resize(n);
    REP(i, n) cin >> a[i];
    
    REP(i, n-1){
        if(a[i]+a[i+1] > x){
            if(a[i+1] - ((a[i] + a[i+1]) - x) >= 0){
                ans += (a[i] + a[i+1]) - x;
                a[i+1] -= (a[i] + a[i+1]) - x;
            }else{
                ans += a[i+1];
                a[i+1] = 0;
            }
        }
    }

    REPR(i, n-1){
        if(i <= 0) break;
        if(a[i]+a[i-1] > x){
            if(a[i-1] - ((a[i] + a[i-1]) - x) >= 0){
                ans += (a[i] + a[i-1]) - x;
                a[i-1] -= (a[i] + a[i-1]) - x;
            }else{
                ans += a[i-1];
                a[i-1] = 0;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 6010
using namespace std;
int n;
char s[MAXN];
char dp[MAXN][MAXN];
int a[MAXN],b[MAXN],cnta,cntb,mat[MAXN];
int main(){
	SF("%d",&n);
	n<<=1;
	SF("%s",s);
	for(int i=0;i<n;i++){
		if(s[i]=='a')
			a[cnta++]=i;
		else
			b[cntb++]=i;
	}
	for(int i=0;i<n/2;i++){
		mat[a[i]]=b[i];
		mat[b[i]]=a[i];	
	}
	for(int i=n-1;i>=0;i--){
		if(mat[i]<i){
			strcpy(dp[i],dp[i+1]);
			continue;
		}
		else{
			if(s[i]=='a'){
				dp[i][0]='a';
				dp[i][1]='b';
				strcpy(dp[i]+2,dp[mat[i]+1]);
			}
			else{
				int end=mat[i];
				int siz=0;
				for(int j=i;j<=end;j++)
					if(mat[j]>=i){
						dp[i][siz++]=s[j];
						end=max(end,mat[j]);	
					}
				strcpy(dp[i]+siz,dp[end+1]);
			}
		}
		if(strcmp(dp[i],dp[i+1])<0)
			strcpy(dp[i],dp[i+1]);
	}
	PF("%s",dp[0]);
}

Measured memory_bytes: 35200
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
#define int long long
	long long n;
	cin >> n;
	long long n1 = n;
	int ans = 0;
	for (int i = 2; i * i <= n1; i++) {
		if (n % i == 0) {
			int co = 0;
			while (n % i == 0) {
				n /= i;
				co++;
			}
			int co1 = 0;
			for (int j = 1;; j++) {
				co -= j;
				if (co >= 0) {
					co1++;
				}
				else {
					break;
				}
			}
			ans += co1;
		}
	}
	if (n != 1) {
		ans++;
	}
	if (ans == 0) {
		if (n != 1) {
			ans = 1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>

int main(void)
{
	int x[101][101],i,j,a,b,sum=0;
	
	scanf("%d %d", &i, &j);
	for (a = 0; a <= i;a++)
	{
		for (b = 0; b <= j; b++)
		{
			x[a][b] = 0;
		}
	}
	for (a = 0; a < i; a++)
	{
		for (b = 0; b < j; b++)
		{
			scanf("%d", &x[a][b]);
			x[a][j] = x[a][j] + x[a][b];
			x[i][b] = x[i][b] + x[a][b];
			sum = sum + x[a][b];
		}
	}
	x[i][j] = sum;
	for (a = 0; a <= i; a++)
	{
		for (b = 0; b <= j; b++)
		{
			if (b == j)
			{
				printf("%d", x[a][b]);
			}
			else
			{
				printf("%d ", x[a][b]);
			}
		}
		printf("\n");
	}
	return 0;
}


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

using namespace std;

const int size = 31;

char map[size][size];
char map2[size][size];

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

int getDir(char c) {
  return c == 'N' ? 1
      : c == 'E' ? 0
      : c == 'W' ? 2
      : c == 'S' ? 3
      : -1;
}
char dirs[] = {'E', 'N', 'W', 'S'};

int main()
{
  int w, h;
  while(cin >> w >> h, w || h) {
    int numPeeps = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        char c;
        cin >> c;
        int dir = getDir(c);
        if(dir != -1) {
          numPeeps++;
        }
        map[i][j] = c;
      }
    }
    int t;
    for (t = 0; t <= 180 && numPeeps > 0; t++) {
      for (int i = 1; i < h-1; i++) {
        for (int j = 1; j < w-1; j++) {
          int dir = getDir(map[i][j]);
          if (dir != -1) {
            for (int k = 0; k < 4; k++) {
              int nextX = j + dx[(dir+k+3)%4];
              int nextY = i + dy[(dir+k+3)%4];
              char nextC = map[nextY][nextX];
              if(nextC == '.' || nextC == 'X') {
                map[i][j] = dirs[(dir+k+3)%4];
                break;
              }
            }
          }
        }
      }
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          map2[i][j] = map[i][j];
        }
      }

      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          if (map[i][j] != '.' && map[i][j] != 'X') continue;
          for (int k = 0; k < 4; k++) {
            int neibX = j + dx[k];
            int neibY = i + dy[k];
            if (neibX < 0 || w <= neibX || neibY < 0 || h <= neibY) continue;
            char neibC = map[neibY][neibX];
            int dir = getDir(neibC);
            if (dir == (k+2)%4) {
              if (map[i][j] == 'X') {
                map2[neibY][neibX] = '.';
                numPeeps--;
              }
              else {
                map2[i][j] = dirs[dir];
                map2[neibY][neibX] = '.';
              }
              break;
            }
          }
        }
      }
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          map[i][j] = map2[i][j];
        }
      }
    }
    if (t <= 180) cout << t << endl;
    else cout << "NA" << endl;

  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define REP(i,n)for(int i=0;i<(n);i++)
 
int n;
int a[125252];
 
int main(void){
    scanf("%d",&n);
    REP(i,n)scanf("%d",a+i);
    int cnt[3] = {0,0,0};
    REP(i,n)cnt[(a[i]%4==0?0:(a[i]%2==0?1:2))]++;
    bool yes = false;;
    if(cnt[0]>0 && 2*cnt[0]+1>=n)yes=true;
    if(2*cnt[0]+cnt[1]>=n)yes=true;
    puts(yes?"Yes":"No");
}

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

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

int main(){
  //input
  string S, T;
  cin >> S >> T;
  string ans = "";

  for (int i = 0; i < S.size(); i++) {
    bool check = true;//TをSにいれることができるか否か
    string tmp = S;
    for (int j = 0; j < T.size(); j++) {
      if (i + j >= S.size()) { check = false; break; }//Tをいれるには文字数オーバーならパス
      if (S[i+j] != '?' && S[i+j] != T[j]) { check = false; break; }//？でもなくTの入れたい文字を入れられないならパス
      tmp[i+j] = T[j];//Tの条件クリアなので？にはTの文字を入れる
    }
    if (check) {
      for (int i = 0; i < tmp.size(); i++) {
	//任意の文字でいいならaにするのが辞書順で一番早い
	if (tmp[i] == '?') tmp[i] = 'a';
      }
      if (ans == "") ans = tmp;//とりあえずの解答を
      else chmin(ans, tmp);
    }
  }
  if (ans != "") cout << ans << endl;
  else cout << "UNRESTORABLE" << endl;
      
  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		double ans = 0;
		int max = 1;

		if (x==1) {
			System.out.println(x);
			return;
		}

		for (int i=2;i<=x;i++) {
			for (int j=2;j<=10;j++) {
				ans = Math.pow(i, j);
				if ((ans <= x) && (ans > max)) {
						max = (int)ans;
				}
			}
		}

		System.out.println(max);

		scan.close();

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;
static const double EPS = 1e-6;

double x[3],y[3];
double xp,yp;

double dist(P a,P b){
	return (sqrt((real(a)-real(b))*(real(a)-real(b))+(imag(a)-imag(b))*(imag(a)-imag(b))));
}

double tri_pro(P a,P b,P c){
	double aa,bb,cc;
	aa = dist(b,c);
	bb = dist(c,a);
	cc = dist(a,b);
	double s = (aa+bb+cc)/2.0;
	return sqrt(s*(s-aa)*(s-bb)*(s-cc));
}


int main(){
	while(cin>>x[0]>>y[0]){
		rep(i,2) cin>>x[i+1]>>y[i+1];
		cin>>xp>>yp;
		P a(x[0],y[0]),b(x[1],y[1]),c(x[2],y[2]);
		P p(xp,yp);
		double sa,sb,sc;
		sa = tri_pro(b,c,p);
		sb = tri_pro(c,a,p);
		sc = tri_pro(a,b,p);
		double s = tri_pro(a,b,c);
		//cout<<"s="<<s<<"\nsa sb sc "<<sa<<" "<<sb<<" "<<sc<<endl;
		//printf("s=%.8f\nsa+sb+sc %.8f\n",s,sa+sb+sc);
		if((sa+sb+sc)-s<EPS) cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}

Measured memory_bytes: 1188
N, M = map(int, input().split())
X = [int(i) for i in input().split()]

X.sort()
difX = []
for i in range(len(X) - 1):
    difX.append(X[i + 1] - X[i])
difX.sort()
# print(difX[::-1])
if N > M:
    print("0")
else:
    print(sum(difX[:M - N]))


Measured memory_bytes: 13832
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC130_1
{
    class C
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(double.Parse).ToArray();

            var res = (a[0] * a[1]) / 2;
            var res2 = 0;

            if ((a[0] % 2 == 0 && a[0] / 2 == a[2]) && (a[1] % 2 == 0 && a[1] / 2 == a[3])) res2 = 1;
            Console.WriteLine("{0} {1}", res, res2);
        }
    }
}


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

int main() {
  vector<int> V(9);
  for (int i = 0; i < 9; i++) cin >> V.at(i);
  int N, b;
  cin >> N;
  while (cin >> b) for (int i = 0; i < 9; i++) if (b == V.at(i)) V.at(i) = 0;

  string ans = "No";
  if (!(V.at(0) + V.at(1) + V.at(2))) ans = "Yes";
  if (!(V.at(3) + V.at(4) + V.at(5))) ans = "Yes";
  if (!(V.at(6) + V.at(7) + V.at(8))) ans = "Yes";
  if (!(V.at(0) + V.at(3) + V.at(6))) ans = "Yes";
  if (!(V.at(1) + V.at(4) + V.at(7))) ans = "Yes";
  if (!(V.at(2) + V.at(5) + V.at(8))) ans = "Yes";
  if (!(V.at(0) + V.at(4) + V.at(8))) ans = "Yes";
  if (!(V.at(2) + V.at(4) + V.at(6))) ans = "Yes";

  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

using namespace atcoder;
using namespace std;

int main(void){
  ll t;
  cin >> t;
  
  for (int i = 0; i < t; i++){
    ll n, m, a, b;
    cin >> n >> m >> a >> b;
    
    cout << floor_sum(n, m, a, b) << endl;
  }

  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
ll bigmod(ll a,ll n)
{
    if(n==0)
        return 1;
    ll ans=bigmod(a,n/2);
    ans=(ans*ans)%M;
    if(n%2)
    {
        ans=(ans*a)%M;
    }
    return ans;
}

main()
{
    vector<pii>v;
    ll n,k;
    cin>>n>>k;
    for(ll i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        if(x>=0)
        {
            v.push_back({x,+1});
        }
        else
        {
            v.push_back({-x,-1});
        }
    }
    sort(v.rbegin(),v.rend());
    ll now=1;
    ll v_p=2e9,v_n=2e9;
    ll sign=1;
    for(ll i=0;i<k;i++)
    {
        now=(now*v[i].first)%M;
        sign*=v[i].second;
        if(v[i].second==+1)
        {
            v_p=min(v_p,v[i].first);
        }
        if(v[i].second==-1)
        {
            v_n=min(v_n,v[i].first);
        }
    }
    if(now==0)
    {
        cout<<0;
        return 0;
    }
    if(sign==1)
    {
        cout<<now;
        return 0;
    }
    int lav1=0;
    int lav2=0;
    ll a,b,c,d;
    ll ans1=now;
    ll ans2=now;


    for(ll i=k;i<n;i++)
    {
        if(v[i].second==+1&&v_n!=2e9)
        {
             lav1=1;
             a=v[i].first;
             b=v_n;
             ans1=(ans1*bigmod(v_n,M-2))%M;
             ans1=(ans1*v[i].first)%M;
             break;
        }
    }
    for(ll i=k;i<n;i++)
    {
        if(v[i].second==-1&&v_p!=2e9)
        {
             lav2=1;
             c=v[i].first;
             d=v_p;
             ans2=(ans2*bigmod(v_p,M-2))%M;
             ans2=(ans2*v[i].first)%M;
             break;
        }
    }
    if(lav1==0&&lav2==0)
    {
        ll now=1;
        sort(v.begin(),v.end());
        for(int i=0;i<k;i++)
        {
            now=(now*v[i].first)%M;
        }
        now=-now;
        now%=M;
        now=(now+M)%M;
        cout<<now;
        return 0;
    }
    if(lav1==0)
    {
        cout<<ans2;
    }
    else if(lav2==0)
    {
        cout<<ans1;
    }
    else
    {
        if(a*d>c*b)
        {
            cout<<ans1;
        }
        else
            cout<<ans2;
    }


}


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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v) for_each((v).begin(), (v).end(), [](int& a) { cout << a << " "; }); cout << endl;

using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

V<PII> v;

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int x;
    REP(i, 5) {
        cin >> x;
        v.push_back(PII((x % 10 == 0) ? 1024 : x % 10, x/10));
    }
    std::sort(ALL(v),  [](const PII& x, const PII& y) { return x.first > y.first; } );
    int s = 0;
    REP(i, 4) {
        if(v[i].first == 1024) s += v[i].second * 10;
        else s += (v[i].second + 1) * 10;
    }
    if(v[4].first == 1024)
        cout << s + v[4].second * 10 << "\n";
    else
        cout << s + (v[4].first + v[4].second * 10) << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<int>;
using A = array<int, 2>;
using P = pair<int, int>;
constexpr int MOD{1000000000 + 7};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr array<int, 4> dx{1, 0, -1, 0}, dy{0, 1, 0, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
constexpr int div_roundup(int a, int b)
{
    return (a + b - 1) / b;
}

// vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));

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

void solve()
{
    int n;
    cin >> n;
    V a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    // -1: 未定 0: 入れない 1: 入れる
    V b(n, -1);

    // 逆から考える
    for (int i = 0; i < n; i++)
    {
        // n-1, n-2, ...0
        const int ii = n - i - 1;

        // b[i] where i>=n/2 は一意に定まる
        if (2 * (ii + 1) > n)
        {
            b[ii] = a[ii];
        }
        else
        {
            int tmp = 0;
            for (int j = ii + ii + 1; j < n; j += ii + 1)
            {
                tmp = tmp != b[j];
            }
            b[ii] = a[ii] != tmp;
        }
    }

    int m = 0;
    for (int i = 0; i < n; i++)
    {
        if (b[i] == 1)
            m++;
    }
    cout << m << endl;
    for (int i = 0; i < n; i++)
    {
        if (b[i] == 1)
            cout << i + 1 << endl;
    }
}

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

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

    solve();
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  char c;
  cin >> c;
  if(c>='A'&&c<='Z'){
    cout << 'A' << endl;
  }else{
    cout << 'a' << endl;
  }
}


Measured memory_bytes: 3592
parseInt(x) = parse(Int, x)

function main()
	n = parseInt(readline())
	a = readline() |> split |> x->parseInt.(x)
	d = Dict{Int, Int}()
	for i in 1:n
		if haskey(d,a[i])
			d[a[i]] += 1
		else
			d[a[i]]=1
		end
	end
	count = 0
	for i in keys(d)
		if i < d[i]
			count += d[i]-i
		elseif i > d[i]
			count += d[i]
		end
	end
	print(count)
end

main()

Measured memory_bytes: 134656
/*input
5
1 2 3 4 5
*/
#include<bits/stdc++.h>
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int l,r;
	cin>>l>>r;
	if(r - l >= 2018)
		cout<<0;
	else{
	int ans = INT_MAX;
	for(int i = l; i <= r; i++){
		for(int j = i ; j <=r; j++ ){
			if(i == j)
				continue;
			ans = min((((i%2019) * (j%2019))%2019),ans);
		}
	}
	cout<<ans;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	int N;
	cin>>N;
	ll A;
	map<ll,int>mp;
	string Ans;
	Ans="YES";
	rep(i,0,N){
		cin>>A;
		mp[A]++;
		if(mp[A]>1){
			Ans="NO";
		}
	}
	cout<<Ans<<endl;
	return 0;
}


Measured memory_bytes: 12800
//package atcoder.dpContest;

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

public class Main {
    public static void main(String[] args) {
//        try {
//            FastScanner in = new FastScanner(new FileInputStream("src/input.in"));
//            PrintWriter out = new PrintWriter(new FileOutputStream("src/output.out"));
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(1, in, out);
//        }
//        catch (IOException e) {
//            e.printStackTrace();
//        }
    }

    private static void solve(int q, FastScanner in, PrintWriter out) {
        for(int qq = 0; qq < q; qq++) {
            int N = in.nextInt(), W = in.nextInt();
            int[] w = new int[N], v = new int[N];
            for(int i = 0; i < N; i++) {
                w[i] = in.nextInt();
                v[i] = in.nextInt();
            }

            long[][] dp = new long[W + 1][N];
            for(int i = 1; i <= W; i++) {
                for(int j = 0; j < N; j++) {
                    dp[i][j] = j == 0 ? 0 : dp[i][j - 1];
                    if(i >= w[j]) {
                        dp[i][j] = Math.max(dp[i][j], (j == 0 ? 0 : dp[i - w[j]][j - 1]) + v[j]);
                    }
                }
            }

            out.println(dp[W][N - 1]);
        }
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}




Measured memory_bytes: 128212
#include <stdio.h>
#include <math.h>
double PI;

double deg2rad(double deg){
    return (deg/360)*2*PI;
}

int main()
{
    int a,b,c;
    double cr;

    PI=acos(-1);

    scanf("%d %d %d",&a,&b,&c);
    cr=deg2rad(c);
    
    printf("%f\n",(a*b*sin(cr))/2);
    printf("%f\n",a+b+sqrt(a*a+b*b-2*a*b*cos(cr)));
    printf("%f\n",b*sin(cr));
    
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) cout << "pon" << endl;
    else if (N % 10 == 3) cout << "bon" << endl;
    else cout << "hon" << endl;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  ll a,b,x, result=0;
  cin>>a>>b>>x;
  if(a==0){
    result=b/x+1;
  }else{
    result = b/x-(a-1)/x;
  }


  cout<<result;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define ll long long
#define ii pair<int,int>
ll ara[200005];char st[200004];
ll a[200004]; ll b[200004];
int main()
{
    ll c,d,m,n,i,j,k,l,t,x,y,z;

        ll ans=0;
        ll maxi=0,mini=0,sum=0,mul=1;
        cin>>c>>d;
        cout<<c*d<<endl;

    return 0;
}





Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int N,M;

bool visitable[1010];
tuple<int,int,int> G[2010];
vector<int> G2[1010],rG[1010];
bool used1[1010],used2[1010];

void dfs(int u){
    if(used1[u]) return;
    used1[u] = true;
    for(int v : G2[u]) dfs(v);
}

void rdfs(int u){
    if(used2[u] || !used1[u]) return;
    used2[u] = true;
    visitable[u] = true;
    for(int v : rG[u]) rdfs(v);
}


int main(){
    cin >> N >> M;
    rep(i,1010){
        visitable[i] = false;
        used1[i] = false;
        used2[i] = false;
    }
    rep(i,M){
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        c = -c;
        G[i] = tie(a,b,c);
        G2[a].push_back(b);
        rG[b].push_back(a);
    }
    dfs(0);
    rdfs(N-1);

    vector<ll> dist(N,LINF);
    dist[0] = 0;
    int cnt = 0;
    while(true){
        cnt++;
        bool update = false;
        rep(i,M){
            int a,b,c;
            tie(a,b,c) = G[i];
            if(!visitable[a]||!visitable[b]) continue;
            if(dist[b] > dist[a]+c){
                update = true;
                dist[b] = dist[a]+c;
            }
        }
        if(!update) break;
        if(cnt == N){
            cout << "inf" << endl;
            return 0;
        }
    }
    cout << -dist[N-1] << endl;
}

    



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

int main(){
    int n; cin >> n;
    int h[n];
    int c[n];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    c[0] = 0;
    c[1] = abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        c[i] = min(c[i-1] + abs(h[i]-h[i-1]), c[i-2] + abs(h[i]-h[i-2]));
    }
    cout << c[n-1] << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<int, int>> r(n), b(n);
    
    REP(i, n) cin >> r[i].second >> r[i].first;
    REP(i, n) cin >> b[i].first >> b[i].second;
    sort(r.begin(), r.end(), greater<pair<int,int>>());
    sort(b.begin(), b.end());

    int ans = 0;
    REP(i, n) {
        REP(j, r.size()) {
            if(r[j].second < b[i].first && r[j].first < b[i].second) {
                ans++;
                r.erase(r.begin() + j);
                break;
            }
        }
    }
    cout << ans << endl;



    return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if(s.Contains("a")&&s.Contains("b")&&s.Contains("c"))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

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

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

    int64_t s = 0;
    for (auto i : irange(0L, m)) {
        int64_t a;
        cin >> a;
        s += a;
    }

    if (s > n) {
        cout << -1 << endl;
    } else {
        cout << n - s << endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}


int main() {
  vector<int> a(3,0);
  rep(i,3) cin >> a[i];
  int cnt = 0;
  sort(all(a));
  if((a[2]-a[1])%2 == 0 && (a[2]-a[0])%2 == 0){
    cnt+=((a[2]-a[1])/2 + (a[2]-a[0])/2);
  }else if(((a[2]-a[1])%2 == 0 && (a[2]-a[0])%2 == 1) || ((a[2]-a[1])%2==1 && (a[2]-a[0])%2==0)){
    cnt+=(a[2]-a[1]) / 2 +(a[2] - a[0]) / 2 + 2;
  }else{
    cnt+=((a[2]-a[1])/2 + (a[2]-a[0])/2) + 1;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

struct cake{
    int num, kind;
};

bool operator< (const cake &cake1, const cake &cake2){
    return cake1.num<cake2.num;
}
bool operator> (const cake &cake1, const cake &cake2){
    return cake1.num>cake2.num;
}


int main(){
    int K, T;
    cin >> K >> T;
    priority_queue<cake, vector<cake>, less<cake>> pque;
    for(int i=0; i<T; i++){
        int a;
        cin >> a;
        pque.push({a,i});
    }
    pque.push({0,-1});

    int ans=0;
    int prev=-1;
    for(int i=0; i<K; i++){
        cake tmp=pque.top();
        pque.pop();

        if(prev!=tmp.kind){
            tmp.num--;
            prev=tmp.kind;
        }else{
            if(pque.top().num==0){
                tmp.num--;
                ans++;
            }else{
                cake tmp2=pque.top();
                pque.pop();
                tmp2.num--;
                pque.push(tmp2);
                prev=tmp2.kind;
            }
        }
        pque.push(tmp);
        //cout << prev << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=100010;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,f[N];
int bgn[N],nxt[N<<1],to[N<<1],E;
inline void add_edge(int u,int v){nxt[++E]=bgn[u],bgn[u]=E,to[E]=v;}
inline void dfs(int u,int fa)
{
	int cnt=0,son=0;f[u]=0;
	for(int v,i=bgn[u];i;i=nxt[i])
	{
		if((v=to[i])==fa)continue;
		dfs(v,u);
		f[u]+=f[v];
		son++;
		cnt+=f[v]==0;
	}
	f[u]+=max(cnt-1,0)+(!fa&&son-cnt<=1&&cnt<=1);
}
int main()
{
	int x,y;
	file();
	read(n);
	For(i,2,n)
	{
		read(x),read(y),++x,++y;
		add_edge(x,y),add_edge(y,x);
	}
	dfs(1,0);
	//For(i,1,n)printf("%d %d\n",i,f[i]);
	printf("%d\n",f[1]);
	return 0;
}


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

int N;
const int MAX_N = 1.0e5 + 100;
int A[MAX_N];
const int MOD = 1.0e9 + 7;

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    int color[3];
    memset(color, 0, sizeof(color));

    ll ans = 1;
    for (int i = 0; i < N; i++) {
        ll cnt = 0;
        bool f = false;
        for (int j = 0; j < 3; j++) {
            if (A[i] == color[j]) {
                if (!f) {
                    f = true;
                    color[j]++;
                }
                cnt++;    
            }
        }
        ans = (ans * cnt) % MOD;
    }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    unordered_set<int> st;
    rep(i, n) {
        if (st.count(a[i])) {
            st.erase(a[i]);
        } else {
            st.insert(a[i]);
        }
    }
    cout << st.size() << endl;
}

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

using namespace std;

#define ii pair<int, int>
#define iii pair<int, ii>
#define M 90001
#define pb push_back
#define mp make_pair
#define x first
#define y second

int h, w, k, q, px[90001], py[90001];
int f[M];

int main(){
    cin >> h >> w >> k;
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++){
            int x;
            cin >> x;
            px[x] = i, py[x] = j;
        }
    for (int j = k + 1; j <= h*w; j++){
        f[j] = f[j - k] + abs(px[j - k] - px[j]) + abs(py[j - k] - py[j]);
    }
    
    cin >> q;
    for (int i = 1; i <= q; i++){
        int x, y;
        cin >> x >> y;
        cout << f[y] - f[x] << endl;
    }
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

const int mod = 2019;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n,int m) {
  if (n == 0) return 1;
  mint x = f(n/2,m);
  x *= x;
  if (n%2 == 1) x *= m;
  return x;
}

int main(){
    string s;
    cin >> s;
    int n = s.size();
    ll now = 0;
    ll mod[n];
    for(int i=n-1;i>=0;i--){
        //cout << now << endl;
        now += (s[i]-'0')*f(n-1-i,10).x;
        now %= 2019;
        mod[i]=now;
    }
    map<ll,ll> mp;
    rep(i,n)mp[mod[i]]++;
    ll ans = 0;
    for(auto p:mp){
        ll b = p.second;
        ans += (ll)b*(b-1)/2;
    }
    ans += mp[0];
    // rep(i,n-1){
    //     if(mod[i]==mod[i+1])ans-=mp[mod[i]]-1;
    // }
    cout << ans << endl;
}

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int maxn = 5e5 + 5;

int n;
int a[maxn], b[maxn], l[maxn], r[maxn], p[maxn];
vector<int> vec[maxn];

inline void work1(){
	FOR(i, 0, n)
		p[i] = i;
	ll ans = 0;
	do{
		ll res = 0; 
		FOR(i, 0, n)
			res += (p[i] < a[i] ? l[i] : r[i]);
		ans = max(ans, res);
	}while(next_permutation(p, p + n));
	printf("%lld\n", ans);
	return;
}

inline void solve(){
	scanf("%d", &n);
	bool f = true;
	FOR(i, 0, n){
		scanf("%d%d%d", a + i, l + i, r + i);
		f &= (l[i] <= r[i]);
	}
	if(false)
		work1();
	else{
		ll ans = 0;
		vector<pii> vec;
		FOR(i, 0, n){
			ans += min(l[i], r[i]);
			if(l[i] > r[i])
				vec.PB(MP(a[i], l[i] - r[i]));
		}
		sort(vec.begin(), vec.end());
		priority_queue<int, vector<int>, greater<int> > que;
		FOR(i, 0, vec.size()){
			que.PH(vec[i].snd);
			while(que.size() > vec[i].fst)
				que.pop();
		}
		while(!que.empty())
			ans += que.top(), que.pop();
		vec.clear();
		FOR(i, 0, n){
			if(r[i] > l[i])
				vec.PB(MP(a[i], r[i] - l[i]));
		}
		sort(vec.begin(), vec.end());
		for(int i = vec.size() - 1; i >= 0; --i){
			que.PH(vec[i].snd);
			while(que.size() > n - vec[i].fst)
				que.pop();
		}
		while(!que.empty())
			ans += que.top(), que.pop();
		printf("%lld\n", ans);
	} 
	return;
}

int main(){
//	freopen("b.in", "r", stdin);
//	freopen("b.out", "w", stdout);
	int T;
	for(scanf("%d", &T); T--; solve());
	return 0;
}


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

int main()
{
	string s;
	cin>>s;
	int s1=0,s2=0;
	
	for(int i=0; i<s.size(); i++)
	{
		if(s[i]=='A')
			s1++;
		else if(s[i]=='B')
			s2++;
	}
	
	if(s1>=1 && s2>=1)
		cout<<"Yes"<< endl;
	else
		cout<<"No"<< endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
unsigned int x, y;
int main() {
	int max;
	cin >> x >> y;
	if (x == y) {
		cout << x << endl;
		goto end;
	}
	if (x >= y) {
		x = x%y;
		if (x <= y) {
			for (int i = x; i > 0; i--) {
				if (x%i == 0 && y%i == 0) {
					cout << i << endl;
					goto end;
				}
			}
		}
		else {
			for (int i = y; i > 0; i--) {
				if (x%i == 0 && y%i == 0) {
					cout << i << endl;
					goto end;
				}
			}
		}
	}
	else {
		y=y%x;
		if (x <= y) {
			for (int i = x; i > 0; i--) {
				if (x%i == 0 && y%i == 0) {
					cout << i << endl;
					goto end;
				}
			}
		}
		else {
			for (int i = y; i > 0; i--) {
				if (x%i == 0 && y%i == 0) {
					cout << i << endl;
					goto end;
				}
			}
		}
	}

	/*if (x <= y) {
		for (int i = x; i > 0; i--) {
			if (x%i == 0 && y%i == 0) {
				cout << i << endl;
				goto end;
			}
		}
	}
	else {
		for (int i = y; i > 0; i--) {
			if (x%i == 0 && y%i == 0) {
				cout << i << endl;
				goto end;
			}
		}
	}*/
end:;
}

Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long int lli;
const lli mod = 1e9+7;
const lli inf = 1e18;
typedef pair<int ,int> pii;
typedef pair<lli, lli> pll;

int main(){
    lli n;
    cin >> n;
    string ans = "";
    for(int i=0; n>0; i++){
        n--;
        ans += (char)('a' +n%26);
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>

char a;

int main(){

    std::cin>>a;

    if(a=='A')
    a='T';
    else
    if(a=='T')
    a='A';
    else
    if(a=='C')
    a='G';
    else
    a='C';
    
    std::cout<<a<<std::endl;

    return 0;

}

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

bool check(int n);

using namespace std;

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

    bool b = check(n);
    cout << (b ? "Yes" : "No") << endl;
}

bool check(int n) {
    if (n > 81) {
        return false;
    }

    for (int i = 1; i <= 9; i++) {
        if (n % i == 0 && n / i <= 9) {
            return true;
        }
    }
    return false;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define P pair<int,int>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define re(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
int n;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n,k;
    cin>>n>>k;
    for(int i=-1000000;i<=1000000-1;i++){
        if(i>=k-n+1){
            cout<<i;
        if(i+1<=k+n-1){
            cout<<" ";
        }
        else{
            cout<<endl;
            return 0;
        }
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	// input
	int N; 
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; ++i) {
		cin >> H[i];
	}
	// compute
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		bool is_candidate = true;
		for (int j = 0; j < i; ++j) {
			if (H[j] > H[i]) {
				is_candidate = false;
				break;
			}
		}
		if (is_candidate) {
			++ans;
		}
	}
	// output
	cout << ans << endl ;
	return 0;
}

Measured memory_bytes: 384
import std.stdio, std.algorithm, std.conv, std.array, std.string;

void main()
{
    long X, Y;
    readf("%d %d", &X, &Y);
    auto n = X;
    long cnt = 0;
    while (n <= Y) {
        cnt++;
        n *= 2;
    }
    writeln(cnt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int cal(int x)
{
	int j=1;
	while(x-j>=0)
	{
		x-=j;
		j++;
	}
	return j-1;
}
int main()
{
	long long n;
	cin>>n;
	int m=int(sqrt(n));
	int a[m+1];
	for (int i=1;i<=m;i++) 
		a[i]=0;
	while (n%2==0)
	{
		n/=2;
		a[2]++;
	}
	int t=3, ans=0;
	while (n!=1&&t<=m)
	{
		while (n%t==0)
		{
			n/=t;
			a[t]++;
		}
		t+=2;
	}
	for(int i=1; i<=m; i++)
		if (a[i]!=0) 
			ans+=cal(a[i]);
	if (n==1) 
		cout<<ans<<endl;
	else cout<<ans+1<<endl;
	return 0;
}


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

void pout(string s) {
  cout << s << endl;
  exit(0);
}

int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  int k = A.at(0);
  int c = 1;
  int d = 0;
  for (int i = 1; i < N; i++) {
    if (A.at(i) == k) c++;
    else if (A.at(i) == k-1) d++;
    else if (A.at(i) == k+1) {
      if (d > 0) pout("No");
      d = c;
      c = 1;
      k = k + 1;
    }
    else pout("No");
  }
  if (d == 0) {
    if (2 * k <= N || k + 1 == N) pout("Yes");
    else pout("No");
  }else {
    if (2 * k - N <= d && d <= k - 1) pout("Yes");
    else pout("No");
  }

  return 0;
}



Measured memory_bytes: 640
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
    def print_top(self): print(self.top)
  
label = list(map(int,input().split()))
op_list = list(input())
d = dice(label)
for op in op_list:
    d.roll(op)
d.print_top()


Measured memory_bytes: 5600