akhauriyash/Code-Regression huggingface dataset:
/* به نام یزدان */
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 10 * 1000 + 3, MAX_D = 100 + 3, MOD = 1e9 + 7;
int n, d, a[MAX_N], dp[MAX_N][MAX_D][2];

void read_input() {
	string k;
	cin >> k >> d;
	n = k.size();
	for (int i = 1; i <= n; i++)
		a[i] = k[n - i] - '0';
}

int get(int w, int x) {
	return ((w - x) % d + d) % d;
}

void solve() {
	dp[0][0][0] = dp[0][0][1] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 0; j < d; j++) {
			for (int k = 0; k < 10; k++)
				(dp[i][j][1] += dp[i - 1][get(j, k)][1]) %= MOD;
			for (int k = 0; k < a[i]; k++)
				(dp[i][j][0] += dp[i - 1][get(j, k)][1]) %= MOD;
			(dp[i][j][0] += dp[i - 1][get(j, a[i])][0]) %= MOD;
		}
}

void print_output() {
	cout << ((dp[n][0][0] - 1) % MOD + MOD) % MOD;
}

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


Measured memory_bytes: 8320
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    m = list(map(int, input().split()))

    a = [False]*(max(m)+1)
    for j in range(2**n):
        s = 0
        for k in range(n):
            if (j >> k) & 1:
                s += A[k]
        if s<=max(m):
            a[s] = True
    for i in m:
        if a[i]:
            print('yes')
        else:
            print('no')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 5628
input_line = input().split()
A = int(input_line[0])
B = int(input_line[1])
C = int(input_line[2])
D = int(input_line[3])
while (1):
    C -= B
    if C <= 0:
        print("Yes")
        break
    A -= D
    if A <= 0:
        print("No")
        break


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

using namespace std;
typedef long long ll;


int main(){
    int N;
    
    cin >> N;
    vector<vector<int> > adjlists(N);

    for(int i=0;i<N-1;i++){
        int u, v;
        cin >> u >> v;
        u--; v--;

        adjlists[u].push_back(v);
        adjlists[v].push_back(u);
    }
    /*
    for(int i=0;i<N;i++){
        cout << i << ": ";
        for(int j=0;j<adjlists[i].size();j++){
            cout << adjlists[i][j] << " ";
        }
        cout << endl;
    }*/

    // bfs
    queue<int> bfs;
    vector<bool> seen(N, false);
    vector<vector<int> > children(N);
    vector<int> preorder;
    bfs.push(0);
    seen[0] = true;
    while(!bfs.empty()){
        int cur = bfs.front();
        bfs.pop();

        preorder.push_back(cur);

        for(int j=0;j<adjlists[cur].size();j++){
            int nxt = adjlists[cur][j];
            if(!seen[nxt]){
                children[cur].push_back(nxt);
                seen[nxt] = true;
                bfs.push(nxt);
            }
        }
    }


    vector<int> values(N, 0);
    for(int i=N-1;i>=0;i--){
        int cur = preorder[i];
        for(int j=0;j<children[cur].size();j++){
            int child = children[cur][j];
            values[cur] ^= (values[child] + 1);
        }
    }

    if(values[0] == 0) cout << "Bob" << endl;
    else cout << "Alice" << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;

ll N,M;
vector<vector<ll>> G;
ll p[100000];

int main(){
    cin >> N >> M;
    G.resize(N);
    for(int i=0;i<M;i++){
        ll a,b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    for(int i=0;i<N;i++) p[i] = -1;
    p[0] = 0;
    queue<ll> q;
    q.push(0);
    while(!q.empty()){
        ll a = q.front();
        q.pop();
        for(auto &e : G[a]){
            if(p[e] != -1) continue;
            p[e] = a;
            q.push(e);
        }
    }
    cout << "Yes" << endl;
    for(int i=1;i<N;i++){
        cout << p[i]+1 << endl;
    }
    return 0;
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
int dp[100005];

int32_t main(){
   fast;
   int n,k;
   cin >> n >> k;

   int a[n+1];
   f(i,1,n+1)  cin >> a[i];
   for(int i=1 ; i<=k ; i++) {
      for(int j=1 ; j<=n ; j++) {
         if(i >= a[j] && dp[i - a[j]] == 0) {
            dp[i] = 1;
         }
      }
   }
   cout << (dp[k] ? "First" : "Second") << "\n";
}

Measured memory_bytes: 1024
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools




def main():
    num = int(input())
    data = [list(map(int, input().split())) for i in range(num)]
    mod = 10 ** 6 + 3

    origin = [0 for i in range(mod + 1)]
    origin[1] = 1
    for i in range(2, mod + 1):
        origin[i] = origin[i - 1] * i
        origin[i] %= mod

    for i in range(num):
        x, d, n = data[i]
        if d == 0:
            ans = pow(x, n, mod)
        else:
            t = x * pow(d, mod - 2, mod)
            t %= mod
            if t == 0 or t + n - 1 >= mod:
                ans = 0
            else:
                ans = origin[t + n - 1] * pow(origin[t - 1], mod - 2, mod)
                ans %= mod
                ans *= pow(d, n, mod)
                ans %= mod
        print(ans)

if __name__ == '__main__':
    main()



Measured memory_bytes: 115292
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, X, M := ReadInt(), ReadInt(), ReadInt()
	pos := make([]int, M)
	for i := 0; i < M; i++ {
		pos[i] = -1
	}
	sum := make([]int, M)
	cur := X
	ans := 0
	for i := 0; i < N; i++ {
		if pos[cur] >= 0 {
			length := i - pos[cur]
			cycles := (N - i - 1) / length
			i += cycles * length
			ans += cycles * (ans - sum[cur])
		} else {
			pos[cur] = i
			sum[cur] = ans
		}
		ans += cur
		cur = cur * cur % M
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) (a []int) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt())
	}
	return
}


Measured memory_bytes: 3452
/*
  Warn - Don't change next line else you will get WA verdict. Online Judge is configured to give WA if next line is not present.
  Author - Aryan Choudhary (@aryanc403)
 
  const short DEBUG { 0 };
  #define debug(x) if (DEBUG) cout << #x << " = " << x << '\n'
*/

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"
#define PI 3.1415926535897932384626433832795
typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

//const lli [3] ={ 999119999L,1000000007L,1000992299L};
//const lli [3] ={ 97L,101L,103L};
//const lli  = chrono::high_resolution_clock::now().time_since_epoch().count();
clock_t time_p=clock();
void aryanc403()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

class CMP
{
public:
    bool operator()(lli a , lli b) //For min priority_queue .
    {
        return ! ( a <= b );
    }
};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    map<lli,lli> ::iterator jt;
    jt=m.find(x);
    if(jt==m.end())         m.insert(mp(x,cnt));
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    map<lli,lli> ::iterator jt;
    jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}
const lli INF = 0xFFFFFFFFFFFFFFFL;
const lli mod = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r;
    lli m;
    string s;
    vi a;
    vi :: iterator it;
    //priority_queue < lli , vector < lli > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    a.clear();a.reserve(n);
    
    fo(i,n)
    {
        cin>>in;
        a.pb(in);
        cnt+=in;
    }
    
    for(auto x:a)
    {
        if(x>=cnt-x)
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    
}   aryanc403();
    return 0;
}

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

int main()
{
  int food[5];for(int i=0;i<5;i++)scanf("%d ",&food[i]);
  int ans=0;int last=0;
  for(int i=0;i<5;i++)
  {
    if(food[i]%10!=0)
    {
      last=max(10-food[i]%10,last);
      ans+=((food[i]/10)+1)*10;
    }else ans+=food[i];
  }
  ans-=last;
  printf("%d",ans);
}

Measured memory_bytes: 3664
N,M=map(int,input().split())

S={}
T=[0]*(N+1)
F=[0]*M
for i in range(M):
    P,Y=map(int,input().split())
    F[i]=(P,Y)
    S[(P,Y)]=i
    T[P]+=1

U=[0]*(N+1)
X=[[0]*T[i] for i in range(N+1)]

for P,Y in F:
    X[P][U[P]]=Y
    U[P]+=1

H=[""]*M

for i in range(N+1):
    X[i].sort()

    for j in range(T[i]):
        g=S[(i,X[i][j])]
        H[g]=str(i).zfill(6)+str(j+1).zfill(6)
        j+=1
print("\n".join(H))

Measured memory_bytes: 118948
S = input()
A = [0] * (len(S) + 1)

for i in range(len(S)):
    if S[i] == "<":
        A[i + 1] = A[i] + 1

for i in range(len(S) - 1, -1, -1):
    if S[i] == ">":
        A[i] = max(A[i], A[i + 1] + 1)

print(sum(A))


Measured memory_bytes: 23340
n, q = map(int, input().split())
s = str(input())

count = [0] * n
for i in range(n - 1):
    if s[i:i+2] == "AC":
        count[i+1] = count[i] + 1
    else:
      count[i+1] = count[i]

for i in range(q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    print(count[r] - count[l])

Measured memory_bytes: 6060
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

string a,b;
cin>>a>>b;
if(a.length()>b.length()){
    cout<<"GREATER"<<endl;
    return 0;
}else if(a.length()<b.length()){
    cout<<"LESS"<<endl;
    return 0;
}else{
    for(int i=0;i<a.length();i++){
        if(a[i]>b[i]){
            cout<<"GREATER"<<endl;
            return 0;;
        }else if(a[i]<b[i]){
            cout<<"LESS"<<endl;
            return 0;
        }
    }

    cout<<"EQUAL"<<endl;


}

return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
N, C = map(int, input().split())
X, V = [], []
for i in range(N):
    x, v = map(int, input().split())
    X.append(x)
    V.append(v)


# 右回り・左回りに進んだ場合の、効用の累積和
R_acc_val = [0] + list(accumulate(V))
L_acc_val = [0] + list(accumulate(V[::-1]))


# 右回り・左回りに進んだ場合のコストを加味した効用
R_val, L_val = [0], [0]
for i in range(1, N + 1):
    R_val.append(R_acc_val[i] - X[i - 1])
    L_val.append(L_acc_val[i] - (C - X[-i]))


# コストを加味した効用の、max累積和
R_max_val, L_max_val = list(accumulate(R_val, func=max)), list(accumulate(L_val, func=max))


ans = 0
for i in range(N + 1):
    ans = max(ans,
              R_val[i],
              R_val[i] + L_max_val[-i-1] - X[i - 1],
              L_val[i],
              L_val[i] + R_max_val[-i-1] - (C - X[-i]))

print(ans)


Measured memory_bytes: 30744
#include<bits/stdc++.h>
    #define ll double
    #define fr(a,b) for(int i = a; i < b; i++)
    #define mod 1000000007
    #define triplet pair<int,pair<int,int>>
    #define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
    using namespace std;
     
    ll dp[301][301][301];
    ll solve(int one, int two, int three, int& n)
    {
        if(one < 0 || two < 0 || three < 0)
            return 0;
        if(three == 0 && two == 0 && one == 0)
            return 0;
     
        if(dp[one][two][three] > 0)
            return dp[one][two][three];
     
        int remaining = one + two + three;
        ll exp_val = n+one*solve(one-1,two,three,n) + two*solve(one+1,two-1,three,n) +
                        three*solve(one,two+1,three-1,n);
     
        return dp[one][two][three] = exp_val/remaining;
    }
     
    int main(){
        int i,j,t,n,m,p,k;
        //fast_io;
        //cin>>t;
        t=1;
        while(t--)
        {
            cin>>n;
            int one=0,two=0,three=0;
     
            fr(0,n){
                int x;
                cin >> x;
                if(x == 1)one++;
                else if(x == 2)two++;
                else three++;
            }
     
            memset(dp, -1, sizeof dp);
            cout<<fixed<<setprecision(9)<<solve(one,two,three,n);
        }
        return 0;
    }

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

#define ll long long
#define ull unsigned long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    int d2=0, d4=0;
    rep(i, n){
        int x;
        cin >> x;
        if(x%4 == 2){
            d2 ++;
        }
        else if(x%4==0){
            d4 ++;
        }
    }
    n -= (d2-d2%2) + d4;
    d2 = d2%2;
    if(d4 >= n-1){
        cout << "Yes";
    }
    else cout << "No";
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main(void)
{
	int c1, c2, c3, flag, i;
	
	while (scanf("%d %d %d", &c1, &c2, &c3) != EOF){
		flag = 0;
		
		for (i = 1; i <= 10; i++){
			if (i == c1 || i == c2 || i == c3){
				continue;
			}
			if (c1 + c2 + i <= 20){
				flag++;
			}
		}
		
		if (flag <= 3){
			printf("NO\n");
		}
		else {
			printf("YES\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 580
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

// AtCoder Functions
var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()

	fl := math.Ceil(float64(N) / 2.0)

	ret := fl / float64(N)
	fmt.Println(ret)
}


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

using namespace std;
const int maxn = 1e5 + 5;
int n;
int sex[maxn];
char str[100];
bool query(int i){
    cout<<i<<endl;
    cin>>str;
    if(str[0] == 'V')return true;
    if(str[0] == 'M')sex[i] = 1;
    else sex[i] = 0;
    return false;
}
bool solve(int l, int r){
    int m = (l + r) / 2;
    if(query(m))return true;
    if((m - l)%2==1 && sex[l] == sex[m])
        return solve(l, m);
    else if((m - l)%2==0 && sex[l] != sex[m])
        return solve(l, m);
    return solve(m, r);
}
int main()
{
    memset(sex, -1, sizeof(sex));
    cin>>n;
    if(query(0))return 0;
    sex[n] == sex[0];
    solve(0, n);
    return 0;
}


Measured memory_bytes: 1236
#include <iostream>
#include <cmath>

using namespace std;

const double EPS = 1e-10;

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

    int hist[6];
    fill(hist, hist+6, 0);
    double h;
    while(n--) {
        cin >> h;
        if(h < 165.0) {
            hist[0]++;
        } else if(h + EPS > 165.0 && h < 170.0) {
            hist[1]++;
        } else if(h + EPS > 170.0 && h < 175.0) {
            hist[2]++;
        } else if(h + EPS > 175.0 && h < 180.0) {
            hist[3]++;
        } else if(h + EPS > 180.0 && h < 185.0) {
            hist[4]++;
        } else {
            hist[5]++;
        }
    }
    
    for(int i = 0; i < 6; i++) {
        cout << (i+1) << ":";
        for(int j = 0; j < hist[i]; j++) cout << "*";
        cout << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main(){
int x,v;
cin>>x>>v;
int y,w;
cin>>y>>w;
int t;
cin>>t;
if(x == y){
    cout<<"YES"<<endl;
}
if(x<y){
    if((v>w) and  (t * (v-w) ) >= y-x)
    {
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }

}
else{if((v>w) and (t * (v-w) ) >= x-y)
   {cout<<"YES"<<endl;}
   else{cout<<"NO"<<endl;}
}

    return 0;
}

Measured memory_bytes: 3656
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define lim 100000ll
#define siz 1000005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define MAX lim
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

signed main(){ 
    IOS
    //io_set();
    ll n;
    cin >> n;
    ll a[n+1] = {0}, dp[n+1] = {0};
    rep(i, n){
        cin >> a[i+1];
    }
    dp[2] = abs(a[2] - a[1]);
    fo(i, 3, n){
        dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
    }
    cout << dp[n] << endl;
    return 0;
} 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N,M;
    cin>>N>>M;
    vll p(N+1,-1);
    for(int i=0;i<M;i++){
        int a;
        cin>>a;
        p[a]=0;
    }
    p[0]=1;
    if(p[1]!=0)p[1]=1;
    for(int i=2;i<=N;i++){
        if(p[i]==0)continue;
        p[i]=(p[i-1]+p[i-2])%MOD;
    }
    cout<<p[N]<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[500];
bool le[30],ri[30];
int n;
int main()
{
	int ans=0;
	cin>>n;
	cin>>a;
	for(int i=1;i<n-1;i++)
	{
		memset(le,0,sizeof(le));
		memset(ri,0,sizeof(ri));
		for(int j=0;j<i;j++)
		{
			le[a[j]-'a']=1;
		}
		for(int j=i;j<n;j++)
		{
			ri[a[j]-'a']=1;
		}
		int q=0;
		for(int j=0;j<26;j++)
		{
			if(ri[j]==0||le[j]==0)
				continue;
			if(ri[j]==le[j])
				q++;
		}
		ans=max(ans,q);
		//cout<<i<<" "<<q1<<" "<<q2<<endl;
		//q1=min(q1,q2);
		//ans=max(ans,q1);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
v = [True] * n

for _ in range(k):
    d = input()
    l = list(map(int, input().split()))
    for i in l:
        v[i - 1] = False

ans = 0
for i in v:
    if i:
        ans += 1
print(ans)

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

struct NODE{
  int parent, degree, *sons;
};

int main(){
  int n, id, k, c, depth, idx;
  cin >> n;
  NODE *nodes = new NODE[n];
  for(int i = 0; i < n; i++) nodes[i].parent = -1;
  for(int i = 0; i < n; i++){
    cin >> id >> k;
    nodes[id].sons = NULL;
    nodes[id].degree = k;
    if(k) nodes[id].sons = new int[k];
    for(int j = 0; j < k; j++){
      cin >> c;
      nodes[id].sons[j] = c;
      nodes[c].parent = id;
    }
  }
  for(int i = 0; i < n; i++){
    cout << "node " << i << ": parent = " << nodes[i].parent << ", depth = ";
    depth = 0;
    idx = i;
    while(nodes[idx].parent != -1){
      depth++;
      idx = nodes[idx].parent;
    }
    cout << depth << ", ";
    if(nodes[i].parent == -1) cout << "root, ";
    else if(nodes[i].degree) cout << "internal node, ";
    else cout << "leaf, ";
    cout << "[";
    for(int j = 0; j < nodes[i].degree; j++) cout << nodes[i].sons[j] <<
					       (j == nodes[i].degree - 1 ? "" : ", ");
    cout << "]" << endl;
  }
  return 0;
}



Measured memory_bytes: 5088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int acnt = 0, bcnt = 0, abcnt = 0, tmp = 0;
    int ans = 0;
    rep(i, n) {
        string s;
        cin >> s;
        int sl = s.length();
        rep(ii, sl - 1) {
            if ((s[ii] == 'A') && (s[ii + 1] == 'B')) {
                ans++;
            }
        }
        if ((s[sl - 1] == 'A') && (s[0] == 'B')) abcnt++;
        else if (s[sl - 1] == 'A') acnt++;
        else if (s[0] == 'B') bcnt++;
    }
    if (abcnt) {
        ans += abcnt - 1;
        if (acnt) {
            acnt--;
            ans++;
        }
        if (bcnt) {
            bcnt--;
            ans++;
        }
    }
    ans += min(acnt, bcnt);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long int ll;
ll Dp[50];
int main()
{
Dp[0]=1;
Dp[1]=1;
for(int i=2;i<50;i++)Dp[i]=Dp[i-1]+Dp[i-2];
int N;
cin >> N;
cout << Dp[N] << "\n";
 
return 0;
}

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

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H-h)*(W-w) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, sum, minsum = 1000000;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i];
    }
    for (int i = 1; i <= 100; i++)
    {
        sum = 0;
        for (int j = 0; j < n; j++)
        {
            sum += (x[j] - i) * (x[j] - i);
        }
        if (minsum > sum)
        {
            minsum = sum;
        }
    }
    cout << minsum << endl;
    return 0;
}

Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
const long long base=311;
const long long mod=1311322777;
long long n,kt=0,ans=0,hash_s[500005],mu[500005];
bool check_pre[500005],check_suf[500005];
string s;
long long get_hash(long l,long r){
	return (hash_s[r]-hash_s[l-1]*mu[r-l+1]+mod*mod)%mod;
}
int main(){
	cin>>s;
	n=s.length(); s=" "+s;
	mu[0]=1;
	for(int i=1;i<=n;i++){
		mu[i]=(mu[i-1]*base)%mod;
	}
	for(int i=1;i<=n;i++){
		hash_s[i]=(hash_s[i-1]*base+s[i])%mod;
	}
	for(int i=2;i<=n;i++){
		if(s[i]!=s[1]){
			kt=1;
			break;
		}
	}
	if(kt==0){
		cout<<n<<endl<<"1";
		return 0;
	}
	for(int len=1;len<=n;len++){
		for(int i=len*2;i<=n;i=i+len){
			if(get_hash(i-len+1,i)==get_hash(1,len)){
				check_pre[i]=1;
			}else{
				break;
			}
		}
	}
	for(int len=1;len<=n;len++){
		for(int i=n-len*2+1;i>=1;i=i-len){
			if(get_hash(n-len+1,n)==get_hash(i,i+len-1)){
				check_suf[i]=1;
			}else{
				break;
			}
		}
	}
	if(check_pre[n]==0){
		cout<<"1"<<endl<<"1";
		return 0;
	}
	for(int i=1;i<n;i++){
		if(check_pre[i]==0 && check_suf[i+1]==0){
			ans++;
		}
	}
	cout<<"2"<<endl;
	cout<<ans;
}

Measured memory_bytes: 9624
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int N;
	long long C;
	cin >> N >> C;

	vector<pair<long long, long long>> list;
	for (auto i = 0; i < N; ++i)
	{
		long long x, v;
		cin >> x >> v;
		list.push_back(make_pair(x, v));
	}

	auto result = 0ll;
	vector<long long> sumListA;
	vector<long long> maxListA;
	auto tempSumA = 0ll;
	auto tempMaxA = 0ll;
	vector<long long> sumListB;
	vector<long long> maxListB;
	auto tempSumB = 0ll;
	auto tempMaxB = 0ll;
	for (auto i = 0; i < N; ++i)
	{
		tempSumA += list[i].second;
		tempMaxA = max(tempSumA - list[i].first, tempMaxA);
		sumListA.push_back(tempSumA);
		maxListA.push_back(tempMaxA);

		auto j = N - i - 1;
		tempSumB += list[j].second;
		tempMaxB = max(tempSumB - (C - list[j].first), tempMaxB);
		sumListB.push_back(tempSumB);
		maxListB.push_back(tempMaxB);
	}

	for (auto i = 0; i < N; ++i)
	{
		auto sumA = sumListA[i];
		auto sumB = sumListB[i];
		sumA -= list[i].first;
		sumB -= C - list[N - i - 1].first;
		if (i < N - 1)
		{
			auto b = maxListB[N - (i + 1) - 1];
			auto cost = list[i].first;
			if (b > cost)
			{
				sumA -= cost;
				sumA += b;
			}

			auto a = maxListA[N - i - 2];
			cost = C - list[N - i - 1].first;
			if (a > cost)
			{
				sumB -= cost;
				sumB += a;
			}
		}
		result = max(result, sumA);
		result = max(result, sumB);
	}

	cout << result << endl;

	return 0;
}


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

#define F(i, a, b) for(int i=a; i<b; i++)
#define rev(str) reverse(str.begin(), str.end())
#define UPPER(str) transform(str.begin(), str.end(), str.begin(), ::toupper)
#define LOWER(str) transform(str.begin(), str.end(), str.begin(), ::tolower)
#define MOD 1000000007
#define INF 1000000001
#define epsilon 1e-15
typedef long long int ll;
typedef unsigned long long int ull;

#define MAX 100000 
#define init(arr, val) memset(arr, val, sizeof(arr))

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);                                       
    freopen("output.txt", "w", stdout);
    #endif

    int N, D;
    cin >> N >> D;
    int cnt = 0;
    double x, y ,d;

    for(int i=0; i<N; i++){
        cin >> x >> y;
        d = sqrt(x*x + y*y);
        if(d<=D) cnt++;
    }

    cout << cnt << '\n';



    return 0;
}

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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 200010, M = 2 * N;

int n, m;
int h[N], e[M], ne[M], idx;
int w[N];

void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

void dfs(int u, int fa, int s)
{
	for (int i = h[u]; ~i; i = ne[i])
	{
		int j = e[i];
		if (j == fa) continue;
		
		w[j] += s;
		dfs(j, u, w[j]);
	}
}

int main()
{
	memset(h, -1, sizeof h);
	
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n - 1; i ++ )
	{
		int a, b;
		scanf("%d%d", &a, &b);
		add(a, b), add(b, a);
	}
	
	for (int i = 0; i < m; i ++ )
	{
		int p, x;
		scanf("%d%d", &p, &x);
		w[p] += x;
	}
	
	dfs(1, -1, w[1]);
	
	for (int i = 1; i <= n; i ++ ) cout << w[i] << ' ';
	puts("");
    return 0;
}

Measured memory_bytes: 16512
#include <iostream>
#include <map>
#include <string>
#include <stack>
#include <utility>
#include <cctype>
using namespace std;


string expr;
map<char,int> m_op;
bool op_left[100];

string postfix;
int child[100][2];

int pos;


int find_child( int k ){
	--pos;
	if( !isalpha( postfix[k] ) ){
		child[k][1] = find_child( pos );
		child[k][0] = find_child( pos );
	}

	return k;
}


void to_infix( int k ){
	if( isalpha( postfix[k] ) ){
		cout << postfix[k];
	}
	else{
		cout << '(';
		to_infix( child[k][0] );
		cout << postfix[k];
		to_infix( child[k][1] );
		cout << ')';
	}
}


void solve(){
	stack< pair<char,int> > st_op;
		//演算子と、優先度*2 を保持
	st_op.push( make_pair( '$', -999 ) );

	postfix.clear();

	for( int i = 0; i < expr.length(); ++i ){
		if( expr[i] == '(' ){
			st_op.push( make_pair( '(', -500 ) );
		}
		else if( expr[i] == ')' ){
			while( st_op.top().first != '(' ){
				postfix += st_op.top().first;
				st_op.pop();
			}
			st_op.pop();
		}
		else{
			map<char,int>::iterator it = m_op.find( expr[i] );

			if( it == m_op.end() ){
				postfix += expr[i];
			}
			else{
				int g = it->second;
				int g2 = g * 2 - op_left[g];
					//左結合なら優先度*2-1
					//右結合なら優先度*2(元と同じ)

				while( g2 < st_op.top().second ){
					postfix += st_op.top().first;
					st_op.pop();
				}

				st_op.push( make_pair( expr[i], g * 2 ) );
			}
		}
	}

	while( st_op.size() > 1 ){
		postfix += st_op.top().first;
		st_op.pop();
	}

	pos = postfix.length() - 1;
	find_child( pos );
	
	to_infix( postfix.length() - 1 );
	cout << endl;
}


int main(){
	postfix.reserve( 100 );

	int D;
	cin >> D;
	for( int d = 0; d < D; ++d ){
		if( d != 0 ) cout << '\n';

		m_op.clear();
		
		int G;
		cin >> G;
		for( int g = 0; g < G; ++g ){
			char join, op;
			int M;
			cin >> join >> M;
			op_left[g] = ( join == 'L' );
			for( int m = 0; m < M; ++m ){
				cin >> op;
				m_op.insert( make_pair( op, g ) );
			}
		}

		int N;
		cin >> N;
		for( int n = 0; n < N; ++n ){
			cin >> expr;
			solve();

		}
	}
}

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

int main() {
    long long N, x;
    cin >> N >> x;

    vector<long long> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());
    long long sum = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (sum + a[i] <= x) {
            ans++;
            sum += a[i];
        }
    }

    if (ans == N && sum != x) {
        cout << ans - 1 << endl;
    }
    else {
        cout << ans << endl;
    }
}

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

int N, M;
vector<P> score[200100];

struct lazysegtree {
    int size;
    vector<int> node, lazy;
    
    lazysegtree(int n) {
        size = 1;
        while (size<n) size *= 2;
        node.resize(2*size-1);
        lazy.resize(2*size-1);
    }
    
    void eval(int k) {
        node[k] += lazy[k];
        if (k<size-1) {
            lazy[2*k+1] += lazy[k];
            lazy[2*k+2] += lazy[k];
        }
        lazy[k] = 0;
    }
    
    void update(int a, int b, int x, int k, int l, int r) {
        eval(k);
        if (b<=l || r<=a) return;
        if (a<=l && r<=b) {
            lazy[k] += x;
            eval(k);
        }
        else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = max(node[2*k+1], node[2*k+2]);
        }
    }
    
    int query(int a, int b, int k, int l, int r) {
        eval(k);
        if (b<=l || r<=a) return -1000000000000000;
        if (a<=l && r<=b) return node[k];
        int vl = query(a, b, 2*k+1, l, (l+r)/2);
        int vr = query(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }

    void add(int a, int b, int x) {
        update(a, b, x, 0, 0, size);
    }
    
    int get(int a, int b) {
        return query(a, b, 0, 0, size);
    }
};

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i, M) {
        int l, r, a; cin >> l >> r >> a;
        score[r].pb(P(l, a));
    }
    
    lazysegtree lst(N+1);
    for (int i=1; i<=N; i++) {
        int su = 0;
        rep(j, score[i].size()) su += score[i][j].second;
        lst.add(i, i+1, lst.get(0, i)+su);
        rep(j, score[i].size()) {
            P p = score[i][j];
            int l = p.first, a = p.second;
            lst.add(l, i, a);
        }
    }
    cout << lst.get(0, N+1) << endl;
}

Measured memory_bytes: 19456
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int N, X, Y;
	cin >> N >> X >> Y;
	X--; Y--;
	vector<vector<int>>dp(N, vector<int>(N, INF));
	rep(i, N)rep(j, N)dp[i][j] = abs(j - i);
	dp[X][Y] = 1;
	dp[Y][X] = 1;
	for (int i = 0; i < N; i++) { //始点
		for (int j = 0; j < N; j++) { //終点
			dp[i][j] = min({ dp[i][j], dp[i][X] + dp[Y][j] + 1, dp[i][Y] + dp[X][j] + 1 });
		}
	}
	map<int, int>m;
	rep(i, N)rep(j, N)m[dp[i][j]]++;
	for (int i = 1; i <= N - 1; i++)cout << m[i] / 2 << endl;
}

Measured memory_bytes: 31744
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
    cin>>n;bool flag=true;int h,mem=0;
    for(int i=0;i<n;i++){
            cin>>h;
            if(mem-1<=h)mem=((mem-1==h)?mem:h);
            else {flag=false;break;}
    }
    cout<<(flag?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define eps 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



// using P = pair<ll, ll>; は消しておく
using P = complex<double>;
#define rad first
#define pnt second

double cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
double dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

// 最小包含円の半径と座標（複素数平面）を返す
pair<double, P> smallest_enclosing_disc(vector<P> ps){
  auto c3 = [](const P &a, const P &b, const P &c){
    double A = norm(b - c);
    double B = norm(c - a);
    double C = norm(a - b);
    double S = abs(cross(b - a, c - a));
    P p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S);
    double r = abs(p - a);
    return make_pair(r, p);
  };
 
  auto c2 = [](const P &a, const P &b){
    P c = (a + b) / (double)2;
    double r = abs(a - c);
    return make_pair(r, c);
  };
 
  auto in_circle = [](const P &a, const pair<double, P> &c){
    return norm(a - c.pnt) <= c.rad*c.rad + eps;
  };
 
  int n = ps.size();
  random_shuffle(ps.begin(), ps.end());
  pair<double, P> c = c2(ps[0], ps[1]);
  for(int i = 2; i < n; ++i){
    if(!in_circle(ps[i], c)){
      c = c2(ps[0], ps[i]);
      for(int j = 1; j < i; ++j){
        if(!in_circle(ps[j], c)){
          c = c2(ps[j], ps[i]);
          for(int k = 0; k < j; ++k){
            if(!in_circle(ps[k], c)){
              c = c3(ps[i], ps[j], ps[k]);
            }
          }
        }
      }
    }
  }

  return c;
}


int N;

int main () {
  cin >> N;
  vector<P> v;

  rep(i, N) {
    double x, y;
    cin >> x >> y;
    complex<double> c(x, y);
    v.push_back(c);
  }

  printf("%.16f\n", smallest_enclosing_disc(v).rad);
}

Measured memory_bytes: 256
# include<bits/stdc++.h>
using namespace std;
vector<int>dp(100000,-1);
vector<int> h;
int k;
int c(int i)
{
	if(dp[i]!=-1)
      return dp[i];
  	if(i<=0) return 0;
  	if(i==1) return abs(h[1]-h[0]);
  dp[i]=INT_MAX;
  	for(int j=1;j<=k&&i-j>=0;j++)
		dp[i]=min(abs(h[i]-h[i-j])+c(i-j),dp[i]);
  	return dp[i];
}

int main()
{
	int n,i,ans;
  	cin>>n>>k;
  	h.resize(n);
  	for(i=0;i<n;i++)
      cin>>h[i];
  	ans=c(n-1);
  	cout<<ans;
return 0;
}

Measured memory_bytes: 8832
A, B = map(int, input().split())

import math
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = prime_factorize(math.gcd(A, B))
c = collections.Counter(c)
c = c.values()

print(len(c) + 1)

Measured memory_bytes: 9464
using System;
using System.Linq;

namespace ABC163B {
    class Program {
        static void Main(string[] args) {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var n = input[0];
            var m = input[1];
            var homeworks = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var l = n - homeworks.Sum();
            Console.WriteLine(Math.Max(-1,l));
        }
    }
}

Measured memory_bytes: 29264
#include <iostream>
#include <sstream>
#include <bitset>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;



int main()
{
  int K, S;
  cin >> K >> S;
  int ans=0;
  for (int x = 0; x <= K; x++)
  {
    for (int y = 0; y <= K;y++){
      int z = S - x - y;
      if(0<=z && z<=K)
        ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {	
	private static void solve(){
		//Implement solution here.
		char[] S = next().toCharArray();
		int A = 0;
		int B = 0;
		for(char c:S){
			if(c == 'A') {
				A++;
			}else {
				B++;
			}
		}
		System.out.println(A*B > 0 ? "Yes" : "No");
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 23124
# Date [ 2020-09-08 00:35:49 ]
# Problem [ j.py ]
# Author Koki_tkg

import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

class SegmentTree:
    def __init__(self, array, function, identify):
        self.length = len(array)
        self.func, self.ide_ele = function, identify

        self.size = 1 << (self.length-1).bit_length()
        self.data = [self.ide_ele] * 2*self.size
        # set
        for i in range(self.length):
            self.data[self.size + i] = array[i]
        # build
        for i in range(self.size-1, 0, -1):
            self.data[i] = self.func(self.data[2*i], self.data[2*i + 1])

    def update(self, idx, x):
        idx += self.size
        self.data[idx] = x
        while idx > 0:
            idx >>= 1
            self.data[idx] = self.func(self.data[2*idx], self.data[2*idx + 1])
 
    def query(self, l, r):
        l += self.size; r += self.size+1
        l_ret = r_ret = self.ide_ele
        while l < r:
            if l & 1:
                l_ret = self.func(l_ret, self.data[l])
                l += 1
            if r & 1:
                r -= 1
                r_ret = self.func(self.data[r], r_ret)
            l >>= 1; r >>= 1
        return self.func(l_ret, r_ret)

    def get(self, idx):
        return self.data[idx+self.size]

def Main():
    n, q = read_ints()
    a = read_int_list()
    seg = SegmentTree(a, max, -float('inf'))
    for _ in range(q):
        t, x, v = read_ints()
        if t == 1:
            seg.update(~-x, v)
        elif t == 2:
            print(seg.query(~-x, ~-v))
        else:
            l = x - 1; r = n + 1
            while r - l > 1:
                mid = (l + r) // 2
                if seg.query(~-x, ~-mid) >= v:
                    r = mid
                else:
                    l = mid
            print(r)

if __name__ == '__main__':
    Main()

Measured memory_bytes: 102232
#include<stdio.h>
int main()
{
  int n;
  int cnt=0;
  char s[100];
  scanf("%d %s",&n,s);
  for(int i=0;i<n;i++){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
      cnt++;
    }
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 128
function Main(input) {
    input = input.split(" ");
    const a = parseInt(input[0],10);
    const b = parseInt(input[1],10);
    const h = parseInt(input[2],10);
    const m = parseInt(input[3],10);

    const ratioH = 30 * h + (1/2) * m ;
    const ratioM = 6 * m;
    
    const rad = Math.abs( ratioH - ratioM ) * (2 * Math.PI) / 360;


    console.log(Math.sqrt(  a*a + b*b - 2*a*b* Math.cos(rad) ));
}
 
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

typedef complex<double> P;

// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)

// 外積 (cross product) : a×b = |a||b|sinΘ
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

// 2直線の平行判定 : a//b <=> cross(a, b) = 0
int is_parallel(P a1, P a2, P b1, P b2) {
  return EQ( cross(a1-a2, b1-b2), 0.0 );
}

int main(){
	int n;
	double x1,x2,x3,x4,y1,y2,y3,y4;

	cin >> n;
	for(int i=0 ; i<n ; i++){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		P a(x1,y1), b(x2,y2), c(x3,y3), d(x4,y4);
		if( is_parallel(a,b,c,d) ){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}

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



int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
   	long long n;
   	cin>>n;

   	vector<long long> nums(n), p(n), q(n);
   	for(long long i = 0; i < n; i++) {
   		cin>>p[i];
   		nums[i] = i+1;
   	}

	for(long long i = 0; i < n; i++) {
   		cin>>q[i];
   	}
   	long long pRank = 1, qRank = 1, counter = 1;
   	do {
   		if(nums == p)
   			pRank = counter;
   		if(nums == q)
   			qRank = counter;
   		counter++;
   	} while(next_permutation(nums.begin(), nums.end()));

   	cout<<abs(pRank - qRank);
   	
	return 0;		
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr ll INF = 2000000000;
constexpr ll mod = 1000000007;

int times(int x) {
	int a = 0;
	while (x % 2 == 0) {
		++a;
		x /= 2;
	}
	return a;
}

int main() {
	int N; cin >> N;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	int ans = INF;
	rep(i, N) ans = min(ans, times(A[i]));
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  string S;
  cin>>S;
  
  int ans=S.size()-2;
  
  
  while(true){
    bool check=true;
    
    S.pop_back();
    S.pop_back();
    
    for(int i=0;i<S.size()/2;i++){
      if(S[i]!=S[i+S.size()/2]){
        check=false;
      }
    }
    
    if(check){
      cout<<ans<<endl;
      return 0;
    }
    
    ans=ans-2;
  }
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] b = new int[n + 1];
        for (int i = 1; i <= n; ++i) {
            b[i] = scanner.nextInt();
        }
        int j = 0;
        int [] res = new int[n];
        int oldLen = n;
        for (int i = n; i >= 1;) {
            if (b[i] == i) {
              //  System.out.println("push: " + i);
                res[j] = i;
                ++j;
                delete(b, i, oldLen);
                --oldLen;
                i = oldLen;
            } else {
                --i;
            }
        }
        if (j != n) {
            System.out.println(-1);
            return;
        } else {
            for (int i = n - 1; i >= 0; --i) {
                System.out.println(res[i]);
            }
        }
    }

    public static void delete(int[] b, int i, int oldLen) {
        for (int j = i; j < oldLen; ++j) {
            b[j] = b[j + 1];
        }
    }
}


Measured memory_bytes: 21460
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int n;
    int a[110];
    cin>>n;
    double ave=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        ave+=a[i];
    }
    double x=n;
    ave/=x;
    double minn=1e9;
    int ans=0;
    for(int i=0;i<n;i++){
        double temp=a[i]-ave;
        if(temp<0){
            temp=0-temp;
        }
        if(temp<minn){
            minn=temp;
            ans=i;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256