akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[allow(dead_code)]
const MOD: usize = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        A: usize, B: usize, C: usize, D: usize,
    }
    println!("{}", max(A*B, C*D));
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[3];
  for(int i=0;i<3;i++){
    cin>>a[i];
  }
  if(a[0]==a[1]){
    cout<<a[2]<<endl;return 0;
  }
  else{
    if(a[0]==a[2]){
      cout<<a[1]<<endl;return 0;
    }
    else{
      cout<<a[0]<<endl;return 0;
    }
  }
  return 0;
}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

ll cnt[N], ans;
int main () {
	ios::sync_with_stdio(0), cin.tie(0);
	ll n;
	cin >> n;
	while (n --) {
		ll x;
		cin >> x;
		cnt[x] ++;
		ans += x;
	}
	ll q;
	cin >> q;
	while (q --) {
		ll b, c;
		cin >> b >> c;
		ans -= b * cnt[b];
		ans += c * cnt[b];
		cnt[c] += cnt[b];
		cnt[b] = 0;
		cout << ans << '\n';
	}
}

Measured memory_bytes: 4436
#include <stdio.h>
#define N 100

int A[N][N];

int main(){
  int n,i,j,u,k,v;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n;j++){
      A[i][j] = 0;
    }
  }
  
  for(i = 0; i < n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j = 0; j < k;j++){
      scanf("%d",&v);
      v--;
      A[u][v] = 1;
    }
  }
  for(i = 0; i < n;i++){
    for(j = 0; j < n-1; j++){
      printf("%d ",A[i][j]);
    }
    printf("%d\n",A[i][j]);
  }
  return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
int main() {
	
	int n, k; scanf("%d%d", &n, &k);
	long long ans = 0;
	for (int i = k + 1; i <= n; ++i) {
		int t = n / i;
		ans += t * (i - k);
		t = t * i;
		ans += max(0, n - t - max(0, k - 1));
	}
	printf("%lld", ans);
	return 0;

}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    map<int,int> mp;
    for (int i = 0;i < n;i++){
        cin >> a.at(i);
        mp[i+1] = a.at(i);
    }
    
    int cnt = 0;
    int now = 1;
    bool ans = true;
    map<int,int> come;
    come[1] = 1;
    while(ans){
        cnt++;
        now = mp[now];
        if (now == 2){
            break;
        }
        
        if (come[now] == 1){
            ans = false;
            break;
        }
        come[now] = 1;
    }
    if (ans){
        cout << cnt << endl;
    }
    else {
        cout << -1 << endl;
    }
}

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

int main(){
    ll a;
    double b;
    cin >> a >>b ;
    int c = (b+0.0000000002)*100;
    
    ll d = a*c/100; 
    
    cout << d << endl;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,r,s,p;
    string t,ans;
    cin>>n>>k>>r>>s>>p>>t;
    for (int i=0 ; i<=t.size() ; i++){
    if (t[i]=='r')ans=ans+'p';
    else if (t[i]=='s')ans=ans+'r';
    else if (t[i]=='p')ans=ans+'s';
    }
    for(int i = k ; i < n; i++) 
		if(ans[i - k] == ans[i]) { ans[i] ='F';}
	
		long long a = 0;
	for(int i = 0; i < n; i++) {
		if(ans[i] == 'F') continue;
		if(ans[i] == 'r') a += r;
		else if(ans[i] == 'p') a += p;
		else a += s;
	}
	cout << a;
}

Measured memory_bytes: 696
#include <bits/stdc++.h>
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.end(),x.begin()
#define sz(x) ((int)x.size())
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pi;
int a, b, c, i, j, k;
long long ans = 0LL;
ll beatings(ll x){
    if (x == 0) return 0;
    if (x == 1) return 1;
    return 1 + 2*beatings(x/2);
}
int main ()
{
	ll a,h,n,val = 0,k;
	scanf("%lld",&n);
    cout << beatings(n) << endl;
	return 0;
}

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

int main()
{
    char c;
    cin >> c;
    string a = "aeiou";

    rep(i, a.size())
    {
        if (c == a[i])
        {
            cout << "vowel" << endl;
            return 0;
        }
    }

    cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}


int main(){

  ll N;
  cin >> N;
  vector<P> A(N);

  FOR(i,0,N){
    cin >> A[i].first;
    A[i].second = i;
  }
  SORT(A);
  REV(A);
  
  ll dp[N+1][N+1] = {};

  FOR(k,0,N){
    FOR(j,0,k+1){
      ll i = k - j;

      dp[i+1][j] = max( dp[i+1][j]  ,  dp[i][j] + A[k].first*abs(i-A[k].second)  );
      dp[i][j+1] = max( dp[i][j+1]  ,  dp[i][j] + A[k].first*abs(N-j-1-A[k].second)  );

    }
  }

  ll ans = 0;
  FOR(i,0,N+1){
    ans = max(ans,dp[N-i][i]);
  }

  cout << ans << endl;

}


Measured memory_bytes: 34956
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# main
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7

C = dict(Counter(A))

ans = 1
if N%2==0:
    for i in range(N//2):
        if C.get(i*2+1) == 2:
            ans *= 2
            ans %= mod
        else:
            ans = 0
            break
else:
    if C[0] == 1:
        for i in range(N//2):
            if C.get(i*2+2) == 2:
                ans *= 2
                ans %= mod
            else:
                ans = 0
                break
    else:
        ans = 0

print(ans)

Measured memory_bytes: 16280
const int INF = 100000;
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int,int> P;

struct edge{
    int to, dist, cost;
    edge(int t, int d, int c) : 
    to(t), dist(d), cost(c) {}
};

vector<edge> edges[20000];
int d[10000];
//int c[10000];
//int from[10000];
int N, M;

void dijkstra() {
    priority_queue<P,vector<P>, greater<P> > que;
    d[0] = 0;
    //1つめ距離　3つめ先
    que.push(P(0,0));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < edges[v].size(); i++) {
            edge e = edges[v][i];
            if (d[e.to] > d[v] + e.dist) {
                d[e.to] = d[v] + e.dist;
                que.push(P(d[e.to], e.to));
            } 
        }
    }
}

void solve() {
    dijkstra();
    int res = 0;
    for (int i = 1; i < N; i++) {
        int mincost = INF;
        for (int j = 0; j < edges[i].size(); j++) {
            edge e = edges[i][j];
            if (d[i] == d[e.to] + e.dist) {
                mincost = min(mincost, e.cost);
            }
        }
        res += mincost;
    }

    cout << res << "\n";
}

int main() {
    int u, v, di, co;
    while (cin>>N>>M) {
        if (N==0 && M==0) break;
        for (int i = 0; i < N; i++) edges[i].clear();
        for (int i = 0; i < M; i++) {
            cin >> u >> v >> di >> co;
            edges[u-1].push_back(edge(v-1,di,co));
            edges[v-1].push_back(edge(u-1,di,co));
        }
        fill(d,d+N,INF);
        //fill(c,c+N,0);
        //fill(from,from+N,0);
        solve();
    }
}



Measured memory_bytes: 5272
#include <iostream>
#include <string>
#include <vector>

int main() {
  int n, q;
  std::string s;
  std::cin >> n >> q >> s;

  std::vector<int> l(q);
  std::vector<int> r(q);
  for (int i = 0; i < q; ++i) std::cin >> l[i] >> r[i];

  std::vector<int> cum(n);
  cum[0] = 0;
  for (int i = 1; i < n; ++i)
    cum[i] = (s[i - 1] == 'A' && s[i] == 'C') ? (cum[i - 1] + 1) : cum[i - 1];

  for (int i = 0; i < q; ++i)
    std::cout << (cum[r[i] - 1] - cum[l[i] - 1]) << std::endl;
}

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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    int tmp = 0;
    for(int i = 1; i <= n; i++){
        tmp = i % 10 + (i / 10) % 10 + (i / 100) % 10 + (i / 1000) % 10 + (i / 10000) % 10;
        if(tmp >= a && tmp <= b) ans += i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,a,b,c,x,i,t,y[101];
	for( ; scanf("%d%d%d%d%d",&n,&a,&b,&c,&x),n|a|b|c|x ; printf("%d\n",t>10000?-1:t) ){
		for(i=0;i<n;i++)
			scanf("%d",y+i);
		for(t=i=0;t<10001&&i<n;){
			if( y[i] == x )
				if(++i==n)break;
			x=(a*x+b)%c;
			t++;
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;


int N,M,k;
int main() {
    cin >> N >> M;
    vector<vector<int> > v(M);
    REP(i,M){
        cin >> k;
        REP(j,k){
            int t;
            cin >> t;
            v[i].push_back(--t);
        }
    }
    vector<int> p(M);
    REP(i,M) cin >> p[i];

    ll ans = 0;
    for(int bit = 0; bit < (1<<N); ++bit){
        vector<int> on;
        REP(i,N){
            if(bit & (1<<i)){
                on.push_back(i);
            }
        }
        bool isok = true;
        REP(i,M){
            int cnt = 0;
            REP(j,v[i].size()){
                REP(k,on.size()){
                    if(on[k]==v[i][j]) ++cnt;
                }
            }
            if(cnt%2 != p[i]){
                isok = false;
                break;
            }
        }
        if(isok) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextInt()
  val result = n % 10 match {
    case 2 | 4 | 5 | 7 | 9 => "hon"
    case 0 | 1 | 6 | 8 => "pon"
    case _ => "bon"
  }
  println(result)
}


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

int main(){
    int n,temp;
    char d;
    int trump[4][13]={};
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>d>>temp;
        switch(d){
            case 'S':
            trump[0][temp-1]=temp;
            break;
            case 'H':
            trump[1][temp-1]=temp;
            break;
            case 'C':
            trump[2][temp-1]=temp;
            break;
            case 'D':
            trump[3][temp-1]=temp;
            break;
        }
    }
    for(int j=0;j<4;j++){
        for(int k=0;k<13;k++){
            if(trump[j][k]==0){
                switch(j){
                    case 0:
                    cout<<"S "<<k+1<<endl;
                    break;
                    case 1:
                    cout<<"H "<<k+1<<endl;
                    break;
                    case 2:
                    cout<<"C "<<k+1<<endl;
                    break;
                    case 3:
                    cout<<"D "<<k+1<<endl;
                }
            }
        }
    }
}


Measured memory_bytes: 3124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = "";
		int[] top = new int[] { 21, -1 };

		br.readLine();
		// int n = Integer.parseInt(br.readLine());
		// int i = 0;
		while ((s = br.readLine()) != null) {
			// if (i == n)
			// break;
			int _angler = Integer.parseInt(s.split(" ")[0]);
			int _catch = Integer.parseInt(s.split(" ")[1]);

			// if (_angler < 0 || _angler > 20)
			// continue;
			// if (_catch < 0 || _angler > 100)
			// continue;

			if (top[1] < _catch || (top[1] == _catch && top[0] > _angler)) {
				top[0] = _angler;
				top[1] = _catch;
			}
			// i++;
		}
		System.out.println(top[0] + " " + top[1]);
	}
}

Measured memory_bytes: 16984
# -*- coding: utf-8 -*-
import numpy as np
N, X, Y = list(map(int, input().split()))

distance_lis = [0]*(N-1)
for i in range(1, N + 1):
    for j in range(i+1, N + 1):
        # XYを使わない場合
        a = j - i
        b = abs(X - i) + abs(Y - j) + 1
        distance = min(a, b)
        distance_lis[distance-1] += 1
for dis in distance_lis:
    print(dis)


Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int a[3];
  rep(i,3) R a[i];
  sort(a,a+3);
  if(a[0]==5&&a[1]==5&&a[2]==7) pr("YES");
  else pr("NO");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

bool myfunction(vector<int>& a,vector<int>& b)
{
	return a[1]<b[1];
}

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

	int n,m;
	cin>>n>>m;
	vector<vector<ll> > inp(n);
	for(int i=0;i<n;++i)
	{
		vector<ll> tmp(3);
		cin>>tmp[0]>>tmp[1]>>tmp[2];
		inp[i] = tmp;
	}

	ll gmax = 0;
	for(int bm=0;bm<8;++bm)
	{
		vector<ll> sor(n);
		for(int i=0;i<n;++i)
		{
			ll cur=0;	
			for(int j=0;j<3;++j)
				if((bm>>j)&1)
					cur += inp[i][j];
				else
					cur -= inp[i][j];
			sor[i] = cur;
		}
		sort(sor.begin(),sor.end());
		reverse(sor.begin(),sor.end());
		ll cans = 0;
		for(int i=0;i<m;++i)
			cans += sor[i];
 		gmax = max(gmax,cans);
 	}
 	cout<<gmax;
	return 0;
}

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

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define setIO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define trav(e, x) for (const auto &(e) : (x))
#define pb(x) push_back(x)
#define eb(x...) emplace_back(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define lc(i) 2*i
#define rc(i) 2*i+1
#define int long long
using namespace std;
using ii = pair<int, int>;
using vi = vector<int>;
using vb = vector<bool>;
using vii = vector<ii>;

const int N = 1e5 + 5, MOD = 1e9 + 7, INF = 1e9 + 5;

signed main() {
    FAST_IO;
//    setIO("input.txt", "output.txt");

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int res = a * c;
    res = max(res, a * c);
    res = max(res, a * d);
    res = max(res, b * c);
    res = max(res, b * d);
    res = max(res, a * d);
    cout << res;
}

Measured memory_bytes: 3648
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	int h, w;
	{
		int[] tmp = readln.chomp.split.map!(to!int).array;
		h = tmp[0], w = tmp[1];
		}
	char[][] css;
	for(int i = 0; i < h; i ++){
		css ~= readln.chomp.to!(char[]);
		}
	debug css.writeln;
	
	ulong ans = 0;
	for(int k = 0; k < w - 1; k ++){
		
		int[][] friction;
		// friction[i][j]はa[0..i]とb[0..j]で右揃えにしたとき一致してる個数
		// friction[i][j] = friction[i-1][j-1] + (a[i]==b[i]? 1: 0)
		for(int i = 0; i <= h; i ++){
			friction ~= [0];
			friction[i].length = h + 1;
			}
		friction[0].fill(0);
		for(int i = 1; i <= h; i ++){
			friction[i][0] = 0;
			for(int j = 1; j <= h; j ++){
				friction[i][j] = friction[i - 1][j - 1]
						+ ((css[i - 1][k] == css[j - 1][k + 1])? 1: 0);
				debug write(css[i - 1][k], " ", css[j - 1][k+1], " ");
				debug friction.writeln;
				}
			}
		debug friction.writeln;
		
		int[][] xs;
		for(int i = 0; i <= h; i ++){
			xs ~= [0];
			xs[i].length = h + 1;
			}
		xs[0].fill(0);
		
		for(int i = 1; i <= h; i ++){
			xs[i][0] = 0;
			for(int j = 1; j <= h; j ++){
				xs[i][j] = min(xs[i][j - 1], xs[i - 1][j]) + friction[i][j];
				debug xs.writeln;
				}
			}
		debug xs.writeln;
		
		ans += xs[h][h];
		
		}
	
	ans.writeln;
	
	}


/*


隣接する2列だけで考えればよい
それの総和

*/

Measured memory_bytes: 8828
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();

        final String[] names = new String[n];
        final int[] times = new int[n];

        for (int i = 0; i < n; i++) {
            names[i] = scanner.next();
            times[i] = scanner.nextInt();
        }

        final String name = scanner.next();
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (name.equals(names[i])) {
                for (int j = n - 1; j > i; j--) {
                    count += times[j];
                }

                System.out.println(count);
                return;
            }
        }
    }
}


Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int ooo[30][100001]={};
int main(){
    int n,c,s,t,x,r,ans=0;
    cin>>n>>c;
    
    for(int i=0;i<n;i++){
        cin>>s>>t>>x;
        ooo[x-1][s-1]++;ooo[x-1][t]--;
    }
    for(int i=0;i<c;i++){
        for(int j=1;j<=100000;j++)ooo[i][j]+=ooo[i][j-1];
        for(int j=0;j<=100000;j++)if(ooo[i][j])ooo[i][j]=1;
    }
    for(int i=1;i<=100000;i++){
        r=0;
        for(int j=0;j<c;j++)r+=ooo[j][i];
        ans=max(ans,r);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11904
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int64> a(n);
    vector<int64> ans(n-k+1, 1);
    for (int i=0; i<n; i++) {
        cin >> a[i];
        if (i < k) ans[0] += a[i];
    }
    for (int i=k; i<n; i++) {
        ans[i-k+1] = ans[i-k] - a[i-k];
        ans[i-k+1] += a[i];
    }
    for (int i=1; i<n-k+1; i++) {
        if (ans[i] > ans[i-1])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}


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

using namespace std;

int main(void)
{
    u_int n;
    cin >> n;
    
    int x[n], y[n];
    for (u_int i = 0; i < n; i++)
        cin >> x[i];
    for (u_int i = 0; i < n; i++)
        cin >> y[i];

    double manh[4] = {0, 0, 0, 0};

    for (u_int i = 0; i < n; i++) {
        double d = abs(x[i] - y[i]);
        manh[0] += d;
        manh[1] += d * d;
        manh[2] += d * d * d;
        if (d > manh[3])
            manh[3] = d;
    }

    manh[1] = sqrt(manh[1]);
    manh[2] = pow(manh[2], 0.333333333333);

    printf("%f\n%f\n%f\n%f\n", manh[0], manh[1], manh[2], manh[3]);

    return 0;
}

Measured memory_bytes: 1220
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

int solve()
{
    int N;

    std::cin >> N;

    cout << 2.0 * M_PI * N << endl;

    return 0;
}

int main()
{
//    std::cout << solve() << std::endl;
    solve();

    return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD 1000000007
#define INF 1000000
#define PI 3.14159265358979323846264338327950L
#define MAX_N 200010
#define lb lower_bound //[2,4)=lb(4)-lb(2);

ll countPrimes(ll n)
{
  ll count=0;
  ll N=n;
  if (n%2==0) 
  {
    count++;
    while (n%2==0) n/=2;
  }
  for (ll i=3;i*i<=N;i=i+2)
  {
    while (n%i==0) 
    {
      n /= i;
      if (n%i!=0) count++;
    }
  }
  if (n != 1) count++;
  return (count);
}
  
int main()
{
  ll a,b;
  cin>>a>>b;
  ll g = __gcd(a,b);
  
  cout<<countPrimes(g)+1<<endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

int countBits(int bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main()
{
    ll N;
    cin >> N;
    ll fijk, pij;
    vector<int> F(N, 0);
    vector<vector<ll>> P(N, vector<ll>(11, 0));
    for(int i=0;i<N;i++){
        int tmp=0;
        for(int j=0;j<10;j++){
            cin >> fijk;
            tmp <<= 1;
            if(fijk) tmp++;
        }
        F[i] = tmp;
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<11;j++){
            cin >> pij;
            P[i][j] = pij;
        }
    }
    ll res = LLONG_MIN;
    int bit = 1;
    while(bit < 1<<10){
        ll sum = 0;
        for(int i=0;i<N;i++){
            sum += P[i][countBits(bit & F[i])];
        }
        res = max(res, sum);
        bit++;
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
#include <queue>
#include <vector>
#include <set>
#include <stdio.h>
#include <cstdio>
using namespace std;
int V,E,R,S[500010],T[500010],D[500010];
int C[100010];
const int Inf = 10000*100000+100;

int main() {
	cin >> V >> E >> R;
	for (int i = 0; i < E;i++) {
		cin >>S[i] >> T[i] >> D[i];
	}
	for (int i = 0; i < V;i++) {
		C[i]= Inf;
	}
	C[R]=0;
	for (int i = 0; i < V;i++) {
		bool update = false;
		for (int j=0;j <E;j++) {
			int s= S[j], t=T[j],d=D[j];
			if (C[s] < Inf && C[t] > C[s] + d) {
				C[t] = C[s] + d;
				update = true;
			}
		}
		if(!update) break;
	}
	for (int i =0;i < V;i++){
		if (C[i] == Inf) cout << "INF" << endl;
		else cout << C[i] <<endl;
	}
}

Measured memory_bytes: 7368
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i = 0 ; i < n ; i++)
 
int c[10];
 
bool check(){
    int sum = 0, MOD = c[9];
    rep(i,3) sum = (sum + c[i]) % MOD; 
    if((c[3]+c[4]+c[5])%MOD != sum) return false;
    if((c[6]+c[7]+c[8])%MOD != sum) return false;
    if((c[0]+c[3]+c[6])%MOD != sum) return false;
    if((c[1]+c[4]+c[7])%MOD != sum) return false;
    if((c[2]+c[5]+c[8])%MOD != sum) return false;
    if((c[0]+c[4]+c[8])%MOD != sum) return false;
    if((c[2]+c[4]+c[6])%MOD != sum) return false;
    return true;
}
 
int rec(int p,int S){
    int res = 0;
    if(__builtin_popcount(S) == 10){
	return check();
    }
    if(!c[p]){
	rep(i,10){
	    if((S >> i) & 1) continue;
	    c[p] = i+1;
	    res += rec(p+1,S|(1<<i));
	    c[p] = 0;
	}
    }else{
	res += rec(p+1,S);
    }
    return res;
}
 
int main(){
    while(true){
	int S = 0;
	bool EXIT = false;
	rep(i,10){
	    cin >> c[i];
	    if(c[i] > 0){
		S |= 1<<(c[i]-1);
	    }else if(c[i] == -1){
		EXIT = true;
	    }
	}
	if(EXIT) break;
	cout << rec(0,S) << endl;
    }
    return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define pb emplace_back
#define em emplace
#define fi first
#define se second
#define USE1(...) template <typename __VA_ARGS__> inline
#define USE2(T, ...) USE1(T, typename __VA_ARGS__)
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
using ll = long long;
template<typename T> using vec = std::vector<T>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE2(T=int,V=vec<T>)V reserved(int n){V v;v.reserve(n);return v;}
USE1(T=int)vec<T>in(int n){auto v=reserved<T>(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=std::pair<T,int>)vec<U>enume(const vec<T>&x,int s=0){int N=x.size();auto v=reserved<U>(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE2(T,U)void prif(bool b,T t,U f){if(b)pr(t);else pr(f);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(20);
    std::cout.setf(std::ios::fixed);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

int N;
int A[100100];
int B[100100];

signed main() {
  cin >> N;
  rep(i, N) {
    cin >> A[i] >> B[i];
  }
  ll ans = 0;
  rrep(i, N) {
    int M = B[i];
    ans += (M - (A[i] + ans) % M) % M;
  }
  pr(ans);
  return 0;
}


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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
int a[300][300];
ll dist[300][300];

int main(){
    cin >> n;
    rep(i,n) rep(j,n) cin >> a[i][j];
    rep(i,n) rep(j,n) dist[i][j] = a[i][j];
    rep(k,n) rep(i,n) rep(j,n) {
        dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
    }
    rep(i,n) rep(j,n) {
        if(i == j) continue;
        if(a[i][j] != dist[i][j]) {
            cout << -1 << endl;
            return 0;
        }
    }
    ll ans = 0;
    rep(i,n) for(int j = i+1; j < n; j++) {
        ans += dist[i][j];
    }
    rep(i,n) for(int j = i+1; j < n; j++) {
        rep(k,n) {
            if(k == i || k == j) continue;
            if(dist[i][j] == dist[i][k] + dist[k][j]) {
                ans -= dist[i][j];
                break;
            }
        }
    }
    cout << ans << endl;
}
































Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	string s;
	cin>>s;
	set<ll> st[26];
	for(i=0;i<n;i++){
		st[s[i]-'a'].insert(i+1);
	}

	ll q;
	cin>>q;
	while(q--){
		cin>>i;
		if(i==2){
			ll a,b,c=0;
			cin>>a>>b;
			for(i=0;i<26;i++){
				auto it=st[i].lower_bound(a);
				if(it!=st[i].end()&&(*it)<=b){
					c++;
				}
			}
			cout<<c<<endl;
		}
		else{
			ll a; char c;
			cin>>a>>c;
			k=s[a-1]-'a';
			st[k].erase(a);
			s[a-1]=c;
			st[c-'a'].insert(a);
		}
	}
	return 0;
}

Measured memory_bytes: 24348
///not today

#include <bits/stdc++.h>
using namespace std;

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
//#define int long long
#define pipii pair<int, pair<int, int> >
#define pf push_front

int32_t main(){
    string s;
    cin >>s;
    if(s == "SAT")
        cout <<1 <<endl;
    else if(s == "SUN")
        cout <<7 <<endl;
    else if(s == "MON")
        cout <<6 <<endl;
    else if(s == "TUE")
        cout <<5 <<endl;
    else if(s == "WED")
        cout <<4 <<endl;
    else if(s == "THU")
        cout <<3 <<endl;
    else
        cout <<2 <<endl;
    return false;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007


#A
"""
def check(n):
    n = list(map(int,list(str(n))))
    s = 0
    for i in n:
        s += f[i]
    return s == 0
n,k = LI()
d = LI()
f = [0 for i in range(10)]
for i in d:
    f[i] = 1
while 1:
    if check(n):
        print(n)
        quit()
    n += 1
"""
#B
def f(x,y):
    return fact[x-1+h-y]*fact[y-1+w-x]*inv_fact[x-1]*inv_fact[y-1]*inv_fact[w-x]*inv_fact[h-y]%mod
h,w,a,b = LI()
fact = [1]*(h+w+1)
for i in range(h+w):
    fact[i+1] = fact[i]*(i+1)%mod
inv_fact = [0]*(h+w+1)
inv_fact[h+w] = pow(fact[-1],mod-2,mod)
for i in range(h+w)[::-1]:
    inv_fact[i] = inv_fact[i+1]*(i+1)%mod
ans = 0
for i in range(1,min(w-b,h-a)+1):
    ans += f(b+i,a+i)
    ans %= mod
print(ans)

#C

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 19564
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ

int main(){
	int a,b;scanf("%d%d",&a,&b);
	printf("%.12f\n",(1.0/(1.0/a+1.0/b)));

}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)

using Graph = vector<vector<int>>;
using Pii = pair<int, int>;

void dfs(int v, int& i, const Graph& G, vector<Pii>& vp) {
  vp[v].first = i++;
  for (auto u : G[v]) {
    dfs(u, i, G, vp);
  }
  vp[v].second = i;
}

template<class T, class E>
struct SegTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  typedef function<E(E,E)> H;
  typedef function<E(E,int)> P;
  int n;
  F f;
  G g;
  H h;
  P p;
  T d1;
  E d0;
  vector<T> dat;
  vector<E> lazy;
  SegTree(int n_, F f, G g, H h, T d1, E d0, P p=[](E a, int b){ return a; })
    : f(f), g(g), h(h), d1(d1), d0(d0), p(p) {
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, d1);
    lazy.resize(2 * n - 1, d0);
  }
  void eval(int k, int l, int r) {
    if (lazy[k] == d0) return;
    dat[k] = g(dat[k], p(lazy[k], r - l));
    if (k < n - 1) {
      lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
      lazy[2 * k + 2] = h(lazy[2 * k + 2], lazy[k]);
    }
    lazy[k] = d0;
  }
  void update(int a, int b, E x, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    eval(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      lazy[k] = h(lazy[k], x);
      eval(k, l, r);
    }
    else {
      update(a, b, x, 2 * k + 1, l, (l + r) / 2);
      update(a, b, x, 2 * k + 2, (l + r) / 2, r);
      dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
    }
  }
  // return op[a..b)
  // k: node id, [l, r): node interval
  E query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    eval(k, l, r);
    if (r <= a || b <= l) return d1;
    if (a <= l && r <= b) return dat[k];
    E vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    E vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return f(vl, vr);
  }
};

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

  int n, q;
  cin >> n >> q;
  Graph G(n);
  rep2(i, 1, n) {
    int x;
    cin >> x;
    x--;
    G[x].push_back(i);
  }

  vector<Pii> vp(n);
  int cnt = 0;
  dfs(0, cnt, G, vp);

  SegTree<int, int> seg(
    n,
    [](int a, int b){ return a + b; },
    [](int a, int b){ return b - a; },
    [](int a, int b){ return (a + b) % 2; },
    0,
    0,
    [](int a, int b){ return b; }
  );
  rep(i, n) {
    char c;
    cin >> c;
    if (c == 'G') {
      seg.update(vp[i].first, vp[i].first + 1, 1);
    }
  }

  rep(i, q) {
    int v;
    cin >> v;
    v--;
    seg.update(vp[v].first, vp[v].second, 1);
    int sm = seg.query(0, n);
    cout << (2 * sm > n ? "broccoli" : "cauliflower") << endl;
  }

  return 0;
}



Measured memory_bytes: 17244
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define f first
#define s second
#define mset(m,v) memset(m,v,sizeof(m))
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
long double EPS = 1e-9;
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(int x, int y) { x -= y; if (x < 0) x += mod; return x; }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
void solve() {
	int k;
	cin >> k;
	int a, b;
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i%k == 0) {
			cout << "OK" << endl;
			return;
		}
	}
	cout << "NG" << endl;
}

signed main()
{
	fastio;
	//cout<<fixed<<setprecision(15);
	//clock_t begin = clock();
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--) {
		solve();
	}
	//clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}


//Error?
// clear lists for every test case
// print new line for each tc
// check for int or ll
// check if problem can be solved without any heavy DS like priority_queue or map



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

int main() {
  int H, W;
  cin >> H >> W;
  vector<char> vec(W+2);
  
  for (int i=0; i < W+2; i++) {
    cout << "#";
  }
  cout << endl;
  
  for (int i = 0; i < H; i++) {
    vec.at(0) = '#';
    
    for (int j = 0; j < W; j++) {
      cin >> vec.at(j+1);
    }
    
    vec.at(W+1) ='#';
    
    for (int j = 0; j < W+2; j++) {
      cout << vec.at(j);
    }
    cout << endl;
  }
  for (int i=0; i < W+2; i++) {
    cout << "#";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,b)  for(int i=0;i<(int)(b);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define ii pair<int,int>
#define fi first
#define se second
typedef long long ll;
typedef long double ld;

using namespace std;

int main(){
    cs
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC";
    else cout<<"ABC";
}

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

int main(){
    int n, l;
    string s[10000];
    cin >> n >> l;
    for(int i = 0; i<n; i++)
        cin >> s[i];
    sort(s, s+n);
    for(int i = 0; i<n; i++)
        cout << s[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

signed main(){
char s[200000]={};
char t[200000]={};

scanf("%s %s",s,t);
int i=0;
int count=0;
for(i=0;i<200000;i++){
    if(s[i]!=t[i]){
        count++;
    }
}

printf("%d\n",count);




return 0;    
}

Measured memory_bytes: 2124
#include <stdio.h>
int main(void){
    int a,b,c,d,x,y;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    x = (a+d-1)/d;
    y = (c+b-1)/b;
    if(x>=y) printf("Yes");
    else printf("No");
    return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int r = 0,b = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R'){
            r++;
        }else{
            b++;
        }
    }
    if(r > b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//*************** Constraints are always Imaginary,I'm real **************
using namespace std;
#define int long long 
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define fi first
#define se second
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<PII> VPII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
int32_t 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 a,b,rep;
          string ans,who;
          cin>>a>>b;
          if(a==b)
          {
                    rep=a,who=to_string(a);
          }
          else
          {
                    who=to_string(min(a,b));
                    rep=max(a,b);
          }
          for(int i=1;i<=rep;i++)
          {
                    ans+=who;
          }
          cout<<ans;
          return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    S = input().strip()
    if len(S) < 26:
        for i in range(97, 123):
            if chr(i) not in S:
                print(S + chr(i))
                return
    
    p = 0
    q = []
    for i, s in enumerate(S[::-1]):
        if ord(s) > p:
            p = ord(s)
            q.append(ord(s))
        else:
            min_ = 123
            for j in q:
                if j > ord(s):
                    min_ = min(min_, j)
            print(S[:-i-1] + chr(min_))
            return
    print('-1')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const ll M=2e5+5;
ll ct[M],a[M],cs[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,p;
	cin>>n>>p;
	string s;
	cin>>s;
	for(ll i=1;i<=n;i++)
		a[i]=s[i-1]-'0';
	if(p==2 || p==5)
	{
		ll ans=0;
		for(ll i=1;i<=n;i++)
		{
			if(a[i]%p==0)
				ans+=i;
		}
		cout<<ans<<"\n";
		return 0;
	}
	ct[0]++;
	ll z=1;
	ll ans=0;
	for(ll i=n;i>=1;i--)
	{
		cs[i]=(z*a[i]+cs[i+1])%p;
		ans+=ct[cs[i]];
		ct[cs[i]]++;
		z=(z*10)%p;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 4628
N,Q=map(int,input().split())
S=input()

t=[0]*(N+1)
for i in range(N):
  t[i+1]=t[i]+(1 if S[i:i+2] == 'AC' else 0)
for i in range(Q):
  l,r=map(int,input().split())
  print(t[r-1]-t[l-1])

Measured memory_bytes: 7748