akhauriyash/Code-Regression huggingface dataset:
def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_

H, W = cin()

def calc(W, H):
    ans = 10 ** 9 + 7
    for h in range(1, H):
        S1 = W * h
        j = H - h
        k = j // 2
        l = j - k
        S2 = W * k
        S3 = W * l
        if S1 and S2 and S3:  ans = min(ans, max(S1, S2, S3) - min(S1, S2, S3))
    for h in range(1, H):
        S1 = h * W
        k = W // 2
        l = W - k
        S2 = (H - h) * k
        S3 = (H - h) * l
        if S1 and S2 and S3:  ans = min(ans, max(S1, S2, S3) - min(S1, S2, S3))
    return ans
ans = calc(W, H)
ans = min(ans, calc(H, W))
print(ans)

Measured memory_bytes: 73924
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;

int main() {
	
	pair<pair<string,int>,int> p[101];
	
	int n, inttmp; char s[11]; cin>>n;
	
	for(int i=0;i<n;i++){
		scanf("%s %d", s, &inttmp);
		string strtmp = s;
		p[i]= make_pair(make_pair(strtmp, -inttmp),i);
	}
	sort(p,p+n);
	for(int i=0;i<n;i++){
		cout<<p[i].second+1<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef pair <int,int> P;
int n;
P book[1001];

int solve(){
  int sumf=0,sums=0;
  for(int i=0;i<n;i++)sumf+=book[i].f,sums+=book[i].s;

  int d=max(0,2*book[0].f-sumf),dp[3000]={1};
  for(int i=1;i<n;i++)
    for(int j=d-book[i].s;j>=0;j--) dp[j+book[i].s]|=dp[j];

  int cnt=0;
  while(!dp[d--])cnt++;
  return sumf+sums+cnt;
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++) cin>>book[i].f>>book[i].s;
    sort(book,book+n,greater<P>());
    cout <<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#ABC 110 B
n, m, x, y = map(int, input().split())
max_x = max(list(map(int, input().split())))
min_y = min(list(map(int, input().split())))
if max_x < min_y and max_x < y and min_y > x:
    print("No War")
else:
    print("War")
    



Measured memory_bytes: 2940
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
m=int(pow(n,0.5))
s=set()
t=set()
for i in range(1,m+1):
    if n%i==0:
        s.add(i)
        s.add(n//i)
    if (n-1)%i==0:
       t.add(i)
       t.add((n-1)//i) 
ans=len(t)-1
for i in s:
    if i==1:
      continue
    c=n
    while True:
        if c%i==0:
            c=c//i
        else:
            if c%i==1:
                ans+=1
            break
print(ans)

Measured memory_bytes: 10140
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    cout << ((e - a <= k) ? "Yay!" : ":(")
         << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef pair<pl, ll> ppl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;
  vl a(n);
  ll sum=0, cnt=0, m=INF;
  rep(i, n) {
    cin >> a[i];
    sum += abs(a[i]);
    if(a[i]<0) cnt++;
    chmin(m, abs(a[i]));
  }
  if(cnt&1) sum -= m*2;
  cout << sum << newl;
  return 0;
}

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

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

int H, W;
int sima[55][55];

bool seen[55][55];
void dfs(int h, int w){
  seen[h][w] = true;
  for(int dir=0; dir<8; dir++){
    int nh = h + dy[dir];
    int nw = w + dx[dir];
    if(nh>=H || nh<0 || nw>=W || nw<0){
      continue;
    }
    if(sima[nh][nw] == 0){
      continue;
    }
    if(seen[nh][nw]){
      continue;
    }
    dfs(nh, nw);
  }
}

int main(){
  while(1){
    cin >> W >> H;
    if(H == 0 && W == 0){
      break;
    }
    for(int h=0; h<H; h++){
      for(int w=0; w<W; w++){
        cin >> sima[h][w];
      }
    }
    memset(seen, 0, sizeof(seen));
    int count=0;
    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
        if(seen[i][j]){
          continue;
        }
        if(sima[i][j] == 0){
          continue;
        }
        dfs(i, j);
        count++;
      }
    }
    cout << count << endl;
  }
  return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N; 
  string W;
  cin >> N >> W;
  bool Gudge = true;
  
  for(int i = 0;i < N / 2;i++){
    if(W.at(i) != W.at(N / 2 + i)){
    Gudge = false;
    }
  }
  
  if(N % 2 != 0) cout << "No" << endl;
  else if(Gudge) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
(* O(n * log(max a_s)) *)
let _ = Scanf.scanf "%d" @@ fun n ->
  let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0 in
  let rec count m =
    for i = 0 to n - 1 do
      if a_s.(i) mod 2 = 1 then (Printf.printf "%d\n" m; exit 0);
      a_s.(i) <- a_s.(i) / 2
    done;
    count (m + 1) in
  count 0 |> Printf.printf "%d\n"

Measured memory_bytes: 2432
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = main' 1
main' c  = do
  n <- getl toInt
  unless (n == 0) $ do
    solve <$> replicateM n (getl (toTpl . wrds toDbl)) >>= printAnswer c
    getLine
    main' (c+1)

solve :: [(Double, Double)] -> Double
solve (x:xs) = f 0 xs
  where
    f s [p] = abs s * 0.5
    f s (p1:p2:ps) = f (s + cross x p1 p2) (p2:ps)

printAnswer :: Int -> Double -> IO ()
printAnswer c a = putStrLn $ show c ++ " " ++ show a

cross :: (Double, Double) -> (Double, Double) -> (Double, Double) -> Double
cross (px1, py1) (px2, py2) (px3, py3) = (px2 - px1) * (py3 - py1) - (py2 - py1) * (px3 - px1)

toTpl :: [a] -> (a,a)
toTpl [x,y] = (x,y)
  
toInt :: String -> Int
toInt = read

toDbl :: String -> Double
toDbl = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n-1);

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

    for (int i = 0; i < n - 1; i++) {
        if (b[i] < a[i] || i == 0) {
            a[i] = b[i];
        }
        a[i + 1] = b[i];
    }
    int max = 0;
    for (int i = 0; i < n; i++) {
        max += a[i];
    }
    cout << max << endl;
    return 0;
}



Measured memory_bytes: 256
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())

val = 0
flag = False

for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                A[j][k] = 0

val = 0
for i in range(3):
    val += A[i][i]
if val == 0:
    flag = True

val = A[0][2] + A[1][1] + A[2][0]
if val == 0:
    flag = True

for i in range(3):
    if sum(A[i]) == 0:
        flag = True
    
    val = 0
    for j in range(3):
        val += A[j][i]
    if val == 0:
        flag = True

if flag == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    vi a(N);
    cin >> a;
    sort(ALL(a));
    ans = accumulate(ALL(a), 0);
    if (ans % 10 == 0) {
        REP(i, N) {
            ll tmp = ans - a[i];
            if (tmp % 10 != 0) {
                ans = tmp;
                break;
            }
        }
    }
    if (ans % 10 == 0)
        ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n;
    cin >> n;
    vector <int> l(n);
    REP(i,n) cin >> l[i]; 
    sort(ALL(l));
    int ans=0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(l[k]>=l[i]+l[j]) break;
                if(l[i]<l[j]+l[k] && l[j]<l[i]+l[k]) ans++;
            }
        }
    }
    cout << ans;
    return 0;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (size_t i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

struct UF {
    vector<int> par, sz;

    UF(int n) {
        par.resize(n);
        sz.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find_root(int x) {
        return par[x] == x ? x : par[x] = find_root(par[x]);
    }

    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return;
        
        if (sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }
};

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

    int n, k, l;
    cin >> n >> k >> l;
    UF road(n), rail(n);
    rep(i, k) {
        int p, q;
        cin >> p >> q;
        road.unite(p - 1, q - 1);
    }
    rep(i ,l) {
        int r, s;
        cin >> r >> s;
        rail.unite(r - 1, s - 1);
    }

    vector<pair<int, int> > V(n);
    map<pair<int, int>, int> M;
    rep(i, n) {
        V[i].first = road.find_root(i);
        V[i].second = rail.find_root(i);
        ++M[V[i]];
    }

    rep(i, n) {
        if (i) cout << " ";
        cout << M[V[i]];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
#include<math.h>
#define ll long long int
#define ve vector<int>
#define vl vector<long long int>
#define all(a) a.begin(),a.end()
using namespace std;
ll inf =1e10;

int main(){
  ll n,k,A=inf;
  cin>>n>>k;
  vl h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  sort(all(h));
  for(int i=0;i<n-k+1;i++){
    if(A>h[i+k-1]-h[i]){
      A=h[i+k-1]-h[i];
    }
    
  }
  cout<<A<<endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<vector<pair<int, int>>> edge(N+1);
    for (int i = 0; i < N-1; i++) {
        int a, b;
        cin >> a >> b;
        edge[a].push_back({b, i});
        edge[b].push_back({a, i});
    }
    int M;
    cin >> M;
    vector<ll> route(M);
    for (int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        queue<pair<pair<int, int>, ll>> q;
        q.push({{u, -1}, 0});
        while (!q.empty()) {
            int now = q.front().first.first;
            int par = q.front().first.second;
            ll r = q.front().second;
            q.pop();
            if (now == v) {
                route[i] = r;
                break;
            }
            for (auto p : edge[now]) {
                if (p.first == par) continue;
                q.push({{p.first, now}, r+(1LL<<p.second)});
            }
        }
    }
    vector<ll> bit(1LL << M, 0);
    for (int i = 1; i < (1LL<<M); i++) {
        for (int j = 0; j < M; j++) {
            if ((i>>j)&1) {
                bit[i] = bit[i-(1LL<<j)] | route[j];
                break;
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < (1LL<<M); i++) {
        int t = 0, u = 0;
        t = __builtin_popcountll(bit[i]);
        u = __builtin_parity(i);
        if (u == 0) ans += (1LL << (N-1-t));
        else ans -= (1LL << (N-1-t));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8448
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

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

    if (a == 1 && b == 2) {
        OUT("Borys");
    } else {
        if ((b - a + 1) % 2) {
            OUT("Alice");
        } else {
            OUT("Borys");
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>

struct Node
{
    int key ;
    Node *prev, *next ;
} ;

Node *nil ;
void init()
{
    nil = (Node *)malloc(sizeof(Node)) ;
    nil->next = nil ;
    nil->prev = nil ;
}

void insert(int key)
{
    Node *x = (Node *)malloc(sizeof(Node)) ;
    x->key = key ;
    x->next = nil->next ;
    nil->next->prev = x ;
    nil->next = x ;
    x->prev = nil ;
}

Node* listSearch(int key)
{
    Node *cur = nil->next ;
    while( cur != nil && cur->key != key )
    {
        cur = cur->next ;
    }
    return cur ;
}

void deleteNode(Node * t)
{
    if( t == nil )
        return ;
    t->prev->next = t->next ;
    t->next->prev = t->prev ;
    free(t) ;
}

void deleteFirst()
{
    deleteNode(nil->next) ;
}
void deleteLast()
{
    deleteNode(nil->prev) ;
}
void deleteKey(int key)
{
    deleteNode(listSearch(key)) ;
}

void printList()
{
    Node * cur = nil->next ;
    int isf = 0 ;
    while(1)
    {
        if( cur == nil )
            break ;
        if( isf++ > 0 )
            printf(" ") ;
        printf("%d", cur->key) ;
        cur = cur->next ;
    }
    printf("\n") ;
}
std::size_t strlen( const char * s)
{
    auto i = s ;
    while( *i != '\0')
    {
        ++i ;
    }
    return i -s ;
}

int main()
{
    int key, n, i ;
    int size = 0 ;
    char com[20] ;
    int np = 0, nd = 0 ;
    scanf("%d", &n) ;
    init() ;
    for(i=0 ; i<n ; ++i )
    {
        scanf("%s%d", com , &key) ;
        if( com[0] == 'i' )
        {
            insert(key);
            np++ ;
            size++ ;
        }
        else if(com[0] == 'd')
        {
            if( strlen(com)>6 )
            {
                if( com[6] == 'F' )
                    deleteFirst() ;
                else if(com[6] = 'L' )
                    deleteLast() ;
            }
            else
            {
                deleteKey(key) ;
                nd++ ;
            }
            size-- ;
        }
    }
    printList() ;
    return 0 ;

}



Measured memory_bytes: 33848
#include <stdio.h>

int main()
{
    int x, y, z, min = 1000000, max = -1000000;
    long long sum = 0;
    scanf("%d", &x);
    for (int i = 1; i <= x; i++)
    {
        scanf("%d", &y);
        if (y < min)
        
            min = y;
        
        if (y > max)
            max = y;
        sum = sum + y;
        
    }
        printf("%d %d %lld\n", min, max, sum);
    return 0;
}


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

// Macros
#define F      first
#define S      second
#define PB     push_back
#define MP     make_pair
#define ALL(c) c.begin(),c.end()

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = std::pair <int,int>;

// Random
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/* [a,b] */ template<class T> T rnd_IntType(T a, T b){ return uniform_int_distribution<T>(a, b)(rng); }
/* [a,b) */ template<class T> T rnd_RealType(T a, T b){ return uniform_real_distribution<T>(a,b)(rng); }

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m; ll y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// Output, Common Containers
template <typename T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const deque<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef LOCAL
	#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); d__f(_it, args); }
	void d__f(istream_iterator<string> it) {}
	template<typename Head, typename... Tail> void d__f(istream_iterator<string> it, Head H, Tail... T) { cerr << *it << " <=> [" << H << "]\n"; d__f(++it, T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

const int mod = 998244353;

ll add(ll a, ll b) { return (a + b) % mod; }
ll sub(ll a, ll b) { return (a - b) % mod; }
ll mul(ll a, ll b) { return (a * b) % mod; }

signed main() {
	std::ios::sync_with_stdio(false); //Warning: Do NOT use C I/O now.
	std::cin.tie(nullptr); //Note: Comment out this line for interactive questions.
	std::cout.setf(std::ios::fixed); std::cout.precision(20); //Note: To output decimals correctly.

	// int t; cin>>t;
	// for(int test_no = 1; test_no <= t; ++test_no){}

	int n;
	cin>>n;

	vector<ld> p(n);
	for(int i=0; i<n; ++i) cin>>p[i];

	vector<vector<ld>> dp(n, vector<ld>(2*n + 1));
	fill(ALL(dp[0]),0);
	dp[0][n+1] = p[0];
	dp[0][n-1] = 1-p[0];

	for(int i=1; i<n; ++i)
		for(int j=0; j<=2*n; ++j)
			dp[i][j] = (j==0 ? 0 : dp[i-1][j-1]*p[i])
			           + (j==2*n ? 0 : dp[i-1][j+1]*(1-p[i]));
	
	ld ans = 0;
	for(int j=n+1; j<=2*n; ++j) ans += dp[n-1][j];

	cout<<ans;
}

Measured memory_bytes: 281600
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S,T;
  cin>>S>>T;
  int sz=S.size();
  bool ans=false;
  for(int j=0;j<sz;j++){
  char x=S.at(0);
  for(int i=0;i<sz-1;i++){
    S.at(i)=S.at(i+1);
  }
  S.at(sz-1)=x;
  if(S==T) ans=true;
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main() {
	string s;
	cin >> s;
	char ch1 = s[2];
	char ch2 = s[3];
	char ch3 = s[4];
	char ch4 = s[5];
	if(ch1==ch2&&ch3==ch4){
	    cout << "Yes";
	}
	else{
	    cout << "No";
	}
	return 0;
}


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

int main() {
	int N, H;
	cin >> N >> H;
	int AMAX = 0;
	vector<int> B(N);
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a >> B[i];
		AMAX = max(AMAX, a);
	}
	sort(B.begin(), B.end(), greater<int>());
	int ans = 0;
	for (int i = 0; i < N; i++) {
		H -= max(AMAX, B[i]);
		ans++;
		if (H <= 0) break;
	}
	cout << ans + max(0, (H + AMAX - 1) / AMAX) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mod 1000000007
#define mi first
#define ma second
#define N 100000000
#define fo(i,m,n) for(int i=m;i<n;i++)
#define M 7
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
using ul=unsigned long long;
using pii=pair<int,int>;
using vvi=vector<vector<int>>;
using vi=vector<int>;
using pll=pair<ll,ll>;
using vsi=vector<set<int>>;
using vll=vector<ll>;

ll power(ll a,ll n){
    ll j=0;
    ll x=1;
    while(1ll<<j<=n){
        if(1ll<<j&n)
            x=(x*a)%mod;

        a=a*a%mod;
        j++;
    }

    return x;
}

int gcd(int a,int b){
    if(b==0)
        return a;
    else
        return gcd(b,a%b);

}

int lb(vi &a,int x){
    int n=a.size();
    int l=0;
    int r=n-1;
    int ind=-1;
    while(l<=r){
        int mid=(l+r)/2;
        if(x>=a[mid]){
            l=mid+1;
            ind=mid;
        }
        else
            r=mid-1;

    }

    return ind+1;

}

int up(vll &a,ll x){
    int n=a.size();
    int l=0;
    int r=n-1;
    int ind=-1;

    while(l<=r){
        int mid=(l+r)/2;
        if(a[mid]>x){
            r=mid-1;
            ind=mid;
        }
        else
            l=mid+1;

    }

    return ind;
}

ll max(ll a,ll b){
    if(a>b)
        return a;
    else
        return b;

}

ll min(ll a, ll b){
    if(a>b)
        return b;
    else
        return a;

}

void yn(bool a){
    if(a)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

}


struct fenwick_tree{
    int n;
    int* bit;
    fenwick_tree(int n){
        this->n=n;
        bit=new int[n+1];
        fill(bit,bit+n+1,0);
    }

    void update(int idx,int x){
        while(idx<=n){
            bit[idx]+=x;
            x+=(x&-x);
        }
    }

    int query(int r){
        int tot;
        while(r){
            tot+=bit[r];
            r-=(r&-r);
        }
        return tot;
    }

};


int main(){
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);


    if(x/d>=k){
        cout<<(x-k*d)<<endl;
    }
    else{
        ll m=x/d;
        if((k-m)%2)
            cout<<(d-x%d)<<endl;
        else
            cout<<x%d<<endl;

    }

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
int main(){
    int n;
    cin>>n;
    vector<string> s(n);
    set<string> f;
    rep(i,n){
        cin>>s[i];
        f.insert(s[i]);
    }
    cout<<f.size()<<endl;

}

Measured memory_bytes: 24992
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int A, B, C;
	cin >> A >> B >> C;
	if(A == B){
		cout << C << endl;
	}
	else{
		if(A == C){
			cout << B << endl;
		}
		else{
			cout << A << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll D, T, S;
    cin >> D >> T >> S;
    if (T * S >= D)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

int main() {
    string s;
    cin>>s;
    if(s=="RSS" || s=="SRS" || s=="SSR" || s=="RSR") {
        cout<<1<<"\n";
    }
    else if(s=="RRS" || s=="SRR") {
        cout<<2<<"\n";
    }
    else if(s=="RRR"){
        cout<<3<<"\n";
    }
    else {
        cout<<0<<"\n";
    }
}

Measured memory_bytes: 3584
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) {if (x % y == 0) return y;else return LGCD(y, x % y);}
ll LLCM(ll x, ll y) {return x * y / LGCD(x, y);}

int GCD(int x, int y) {if (x % y == 0) return y;else return GCD(y, x % y);}
int LCM(int x, int y) {return x * y / GCD(x, y);}
ll dp[10000][10000];
ll combination(ll n, ll r) {
         if (n == r){dp[n][n] = 1;}
	else if (r == 0) {return dp[n][0] = 1;}
	else if (r == 1) {return dp[n][1]=n;}
	else {dp[n][r]=dp[n - 1][r - 1] % 1000000007 + dp[n - 1][r] % 1000000007;
	return dp[n][r]=combination(n - 1, r - 1) % 1000000007 + combination(n - 1, r) % 1000000007;}
}
int main() {

	//int N;
	int O, W, C, R;

	int cons;
	
	int i = 0;
	while (1){
		i = 0;
		cin >> O >> W >> C >> R;
		cons = O;
		if (O == 0 && W == 0 && C == 0 && R == 0)break;
		while (1) {
			if (cons >= C*W) { break; }
			else { cons = cons + R; }
			i++;
		}
	cout << i << endl;
	}
	return 0;
}



Measured memory_bytes: 3124
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Vector;

public class Main {

	public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);
		String s=ob.next();
		int a[]=new int[s.length()];
		int k=0;
		for (int i=0; i<s.length(); i++) {
			if (s.charAt(i)=='R') {
				a[k]++;
			}
			else {
				k++;
			}
		}
	                   Vector  v=new Vector ();
		for(int i=0;i<a.length;i++){v.add(a[i]);}
		System.out.println(Collections.max(v));
	}
}


Measured memory_bytes: 26988
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int kashicounts[] = new int[N+1];
		for (int i = 0; i < K; i++) {
			int di = sc.nextInt();
			for (int j = 0; j < di; j++) {
				int kashicountpeople = sc.nextInt();
				kashicounts[kashicountpeople]++;
			}
		}
		
		int count=0;
		for (int i = 1; i < N+1; i++) {
			if (kashicounts[i] == 0) {
				count++;
			}
		}		
		
		System.out.println(count);
	}		
}


Measured memory_bytes: 46148
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<iomanip>
#include<string>
#include<algorithm>
using namespace std;

int gcd(long long int m,long long int n){
	while(m!=n){
		if(m>n){m=m-n;
		}
		else n=n-m;
	}
	return m;
}
int lmc(long long int m,long long int n){
return m*n/gcd(m,n);
}

int main(){
int a[5];
for (int i=0;i<5;i++){
	cin>>a[i];
}
sort(a,a+5);
for (int i=0;i<5;i++){
	if (i==4){
		cout<<a[4-i];
	}
	else cout<<a[4-i]<<" ";
}
cout<<endl;
}

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

int main(){
	int n,m;
	cin>>n>>m;
	
	if(n>m){
		cout<<2*n-1<<"\n";
	}
	else if(n==m){
		cout<<2*n<<"\n";
	}
	else if(n<m){
		cout<<2*m-1<<"\n";
	}
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
int main()
{
    char s[105];
    int a[28]={0};
    cin>>s;
    for(int i=0;i<strlen(s);i++)
    {
        int temp=(int)s[i]-'a';
        a[temp]++;
    }
    for(int i=0;i<27;i++)
    {
        if(a[i]%2)
        {
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n"<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];
const int MOD = 1000000007;

int main()
{
    int n; ll k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> s;
    vector<int> check(n + 1, -1);
    int v = 1, T = 0, l = 0;
    while(check[v] == -1)
    {
        check[v] = s.size();
        s.push_back(v);
        v = a[v - 1];
    }
    T = s.size() - check[v];
    l = check[v];

    if (k < l) cout << s[k] << endl;
    else
    {
        k -= l;
        k %= T;
        cout << s[l + k] << endl;
    }
    return 0;
}

Measured memory_bytes: 5812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
const double pi=acos(-1);

set<int>st;
const int maxn=1e6+5;
ll isp[maxn],p[maxn];
int main ()
{
    double a,b,x,k;
    while(~scanf("%lf %lf %lf",&a,&b,&x))
    {
        //cout<<pi/4<<endl;
        double c=2*x/(a*b);
        if(c>=a)
        {
            //cout<<c<<endl;
            double h=b-2*x/(a*a)+b;
                k=h/a;


            printf("%f\n",atan(k)/pi*180);
        }
        else
        {
            k=b/c;
            printf("%f\n",atan(k)/pi*180);
        }
    }
    return 0;
}



Measured memory_bytes: 256
def main():
    S = input()
    from string import ascii_lowercase
    dic = {a: i for i, a in enumerate(ascii_lowercase)}
    rdic = {i: a for i, a in enumerate(ascii_lowercase)}
    if len(S) != 26:
        for s in ascii_lowercase:
            if s not in S:
                return print(S + s)
    elif S == "zyxwvutsrqponmlkjihgfedcba":
        return print(-1)

    pre = S[-1]
    mi = [pre]
    for i, s in enumerate(S[-2::-1], start=2):
        if s < pre:
            # 後ろから見て、'b' < 'd'のように初めて隣接する文字が昇順に
            # なる場所を探す。'd'以降の文字の中で、'b'より大きいもののうち最小
            # のものを'b'より前の文字列に足して出力
            # 'zyxwvutsrqponmlkjihgfebdca' -> 'zyxwvutsrqponmlkjihgfec'
            m = min(mi, key=lambda p: s > p)
            return print(S[:-i] + m)
        pre = s
        mi.append(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
#include<cstdio>

using namespace std;

char c[1000001];
int a[1000001];
int main(){
	int n;
	scanf("%d",&n);
	scanf("%s",c+1);
	int ans=0;
	for(int i=1;i<=n;i++){
		int w=1;
		for(int j=0;j<20;j++)
			if(!(n-1>>j&1)&&((i-1>>j)&1))w=0;
		int z=w?c[i]-'1':0;
		a[i]=z;
		ans^=z;
	}
	int ok=0;
	for(int i=1;i<=n;i++)
		if(c[i]=='2')ok=1;
	if(!ok){
		printf("%d\n",ans&2);
	}
	else printf("%d\n",ans&1);
}


Measured memory_bytes: 6588
n = gets.to_i
alpahbet = ("a".."z").to_a
string = []
while n > 0
  r = n % 26
  n = r == 0 ? (n / 26 -1) : n / 26
#   p "#{n} #{r} #{alpahbet[r-1]}"
  string << alpahbet[r-1]
end
puts string.reverse.join

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

using namespace std;


int main(void) {

    string s;
    cin >> s;

    // yyyy/mm/dd

    string year = s.substr(0, 4);
    string month = s.substr(5,2);
    string day = s.substr(8,2);

    // cout << year << "-" << month << "-" << day;

    string heisei = "Heisei";
    string tbd = "TBD";

    if ( 2019 < stoi(year) ){
        cout << tbd << endl;
    } else {
        if ( 4 < stoi(month)) {
            cout << tbd << endl;
        } else {
            cout << heisei << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
# 正の整数aとb
a, b = map(int, input().split())
# aとbの積が偶数か奇数か判別する

# 積が奇数なら'Odd'、偶数なら'Even'と出力する
if int(a * b / 2) < int(a * b / 2 + 0.5):
    print('Odd')
else:
    print('Even')

Measured memory_bytes: 9080
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& );

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

    int a,b;
    cin>>a>>b;

    if ( a % k == 0 )
    {
        cout<<"OK"<<endl;
    }
    else
    {
        int x = (a/k + 1)*k;

        if ( x >= a && x <= b )
        {
            cout<<"OK"<<endl;
        }
        else
        {
            cout<<"NG"<<endl;
        }
        
    }
    
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis )
{
    queue<int> q;
    q.push(x);

    while( !q.empty() )
    {
        int p = q.front();
        q.pop();

        rep(i,0,v[p].size())
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
            }
        }
    }
}

Measured memory_bytes: 3652
#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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    int64_t m = s.size();

    vector a(1, 0L);
    int64_t t = 0;
    for (auto c : s) {
        if (c == '0') {
            a.push_back(t);
        } else {
            ++t;
        }
    }
    a.push_back(t);

    int64_t k;
    cin >> k;
    k = min(k, a.back());

    int64_t n = a.size();

    constexpr auto M = 998244353L;

    vector dp(vector(k + 1, vector(a.back() + 1, 0L)));
    int64_t mk = 0;
    dp[0][0] = 1;
    for (auto i : irange(0L, n - 1)) {
        for (auto j : irange(mk, -1L, -1L)) {
            auto r = min(k - j, a[i + 1] - a[i]);
            for (auto c : irange(0L, a.back() - a[i + 1] + 1)) {
                for (auto b : irange(c + 1, c + r + 1)) {
                    auto w = j + b - c;
                    dp[w][c] += dp[j][b];
                }
            }

            while (dp[j][0] >= M) {
                dp[j][0] -= M;
            }
            for (auto c : irange(1L, a.back() - a[i + 1] + 1)) {
                dp[j][c] += dp[j][c - 1];
                while (dp[j][c] >= M) {
                    dp[j][c] -= M;
                }
            }
        }
        mk = min(k, mk + a[i + 1] - a[i]);
    }

    int64_t ans = 0;
    for (auto i : irange(0L, mk + 1)) {
        ans += dp[i][0];
    }

    cout << ans % M << endl;
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	ll t1, t2, a1, a2, b1, b2;
	cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

	if (a1 > b1) swap(a1, b1), swap(a2, b2);

	if (a1*t1 + a2*t2 < b1*t1 + b2*t2)
	{
		cout << "0\n";
		return 0;
	}

	if (a1*t1 + a2*t2 == b1*t1 + b2*t2)
	{
		cout << "infinity\n";
		return 0;
	}

	ll l = (b1*t1 - a1*t1) / (a1*t1 + a2*t2 - (b1*t1 + b2*t2)) + 1;

	bool x = (b1*t1 - a1*t1) % (a1*t1 + a2*t2 - (b1*t1 + b2*t2)) == 0;
	l *= 2;
	l -= x;
	cout << l-1 << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int len = s.length();
        StringBuilder sb = new StringBuilder();
        int left = 0;
        while(left<len){
            int right = left+1;
            while(right<len&&s.charAt(right)==s.charAt(left)) right++;
            sb.append(s.charAt(left));
            left=right;
        }
        String res = sb.toString();
        System.out.println(res.length()-1);
    }
}


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

int main() {
    const int num[3] = {3, 5, 7};
    int64_t n, ans = 0;
    cin >> n;
    queue<pair<int64_t, vector<bool>>> q;
    for (auto i = 0; i < 3; i++) {
        vector<bool> tmp(3, false);
        tmp[i] = true;
        q.emplace(num[i], tmp);
    }
    while (not q.empty()) {
        auto p = q.front();
        q.pop();
        if (p.first > n) continue;
        for (auto i = 0; i < 3; i++) {
            auto tmp = p;
            tmp.first = tmp.first * 10 + num[i];
            tmp.second[i] = true;
            auto flg = true;
            for (auto j = 0; j < 3; j++)
                flg &= tmp.second[j];
            if (tmp.first <= n and flg) ans++;
            q.push(tmp);
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

int main() {
  int n ;
  cin >> n;
  vector<ll>a(n);
  rep(i,n){
    cin >> a[i];
  }
  ll k =0;
  rep(j,n-1){
    if(a[j]>a[j+1]){
      k+=a[j]-a[j+1];
      a[j+1]=a[j];
    }
  }
  cout << k << endl;
    

  return 0;

}

Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    char s[n];
    for(int i=0; i<n; i++){
        char temp;
        cin >> temp;
        s[i] = temp;
    }
    int counter = 0;
    for(int i=0; i<n; i++){
        if(s[i] == 'A'){
            if(i+1 < n){
                if(s[i+1]=='B'){
                    if(i+2 < n){
                        if(s[i+2]=='C'){
                            counter++;
                        }
                    }
                }
            }
        }
    }
    cout << counter << endl;

}




Measured memory_bytes: 256
'use strict';
process.stdin.on('data', function(chunk) {
  var lines = chunk.toString().split('\n');
  var params = lines[0].split(' ').map(Number)
  var result = (function(a,b) {
    if (a > b) {
      return 'a > b';
    } else if (a < b){
      return 'a < b';
    } else {
      return 'a == b';
    }

  }(params[0],params[1]
  ));

  console.log(result);
});

process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 7648
n=int(input())
Values=list(map(int,input().split()))
Values=sorted(Values)
i=1
while i<=n-1:
    x=Values.pop(0)
    y=Values.pop(0)
    new=(x+y)/2
    Values.append(new)
    Values=sorted(Values)
    i+=1
print(*Values)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    static HashMap<Integer, HashMap<Integer, Long>> dp = new HashMap<>();
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long total = 0;
        for (int i = 1; i * Math.pow(2, k - 1) <= n; i++) {
            total += search(i, k - 1, n);
        } 
        System.out.println(total);
    }
    
    static long search(int num, int count, int max) {
        if (count == 0) {
            return 1;
        }
        if (dp.containsKey(num)) {
            if (dp.get(num).containsKey(count)) {
                return dp.get(num).get(count);
            }
        }
        long total = 0;
        for (int i = 2; num * i * Math.pow(2, count - 1) <= max; i++) {
            total += search(num * i, count - 1, max);
        }
        if (dp.containsKey(num)) {
            dp.get(num).put(count, total);
        } else {
            HashMap<Integer, Long> map = new HashMap<>();
            map.put(count, total);
            dp.put(num, map);
        }
        return total;
    }
}


Measured memory_bytes: 85876
def bubble(d):
    for i in range(len(d) - 1):
        for j in range(len(d) - 1, i, -1):
            if int(d[j][1]) < int(d[j - 1][1]):
                d[j],d[j - 1] = d[j - 1],d[j]

def selection(d):
    for i in range(len(b)):
        min_j = i
        for j in range(i, len(d)):
            if int(d[j][1]) < int(d[min_j][1]):
                min_j = j
        if min_j != i:
            d[i],d[min_j] = d[min_j], d[i]

n = int(input())
a = list(map(str, input().split()))

b = a.copy()
c = a.copy()

bubble(b)
selection(c)

for d in [b, c]:
    print(" ".join(d))
    if d == b:
        print("Stable")
    else:
        print("Not stable")

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

#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    int N; cin >> N;

    bool res = false;
    REP(i, 100) REP(j, 100) {
        if (i * 4 + j * 7 == N) res = true;
    }

    if (res) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
num_list = list(map(int, input().split()))
k_sum = sum(num_list[0:b])
max_sum = k_sum
for i, j in zip(num_list[0:], num_list[b:]):
    k_sum -= i
    k_sum += j
    max_sum = max(max_sum, k_sum)
out = (max_sum + b) / 2
print(out)

Measured memory_bytes: 25060
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;


/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/

int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
       int n;
       cin>>n;
       vll v(n);
       for(int i=0;i<n;i++)cin>>v[i];
      ll ans=0;
       for(int i=1;i<n;i++){
         if(v[i]<v[i-1]){
          ans+=v[i-1]-v[i];
          v[i]=v[i-1];
         }
       }
       cout<<ans<<endl;
    }
}











Measured memory_bytes: 4780
n = int(input())

sp = []
for i in range(n):
    l =list(input().split())
    l[1] = int(l[1])
    l.append(i+1)
    sp.append(l)
    

sp.sort(key=lambda x: -x[1])
sp.sort(key=lambda x: x[0])
for i in range(n):
    print(sp[i][2])

Measured memory_bytes: 38512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	s := Scanner()
	if s[2] == s[3] && s[4] == s[5] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


int main(){
  ll N;
  cin >> N;
  string S;
  cin >> S;
  string res = "";

  REP(i,S.size())
  {
    int tmp = S[i] - 'A';
    tmp += N;
    tmp %= 26;
    char c = 'A' + tmp;
    res += c;
  }
  cout << res << endl;

  return 0;    
}



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

const int MAX = 1e6 + 100;

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int main(){
    long long a, b;
    cin >> a >> b;
    long long GCD = gcd(a, b);
    vector<bool> primes(MAX, true);
    primes[0] = primes[1] = false;
    int ans = 1;
    for (int i = 2; i < MAX; ++i) {
        if (!primes[i]) continue;
        for (int j = 2 * i; j < MAX; j += i) {
            primes[j] = false;
        }

        if (GCD % i) continue;
        while (GCD % i == 0) GCD /= i;
        ans++;
    }
    if (GCD != 1) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3724