akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  int N, A, B, C, D;
  string S;
  cin >> N >> A >> B >> C >> D >> S;
  A--; B--; C--; D--;
  bool reach = true;
  for (int i = min(A, B)+2; i<max(C, D); i++) {
    if (S[i] == '#' && S[i-1] == '#') {
      reach = false;
      break;
    }
  }
  if (A < B && C < D || A > B && C > D) {
    if (reach)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
    return 0;
  }
  bool swp = false;
  for (int i = max(A, B); i <= min(C, D); i++){
    if (S[i+1] == '.' && S[i] == '.' && S[i-1] == '.') {
      swp = true;
      break;
    }
  }
  if (reach && swp)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());

        var a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

        // a[0]を正にするパターン
        long num1 = 0;
        long sum = 0;
        for (int i = 0; i < a.Length; i++)
        {
            if (i % 2 == 0)
            {
                if (sum + a[i] <= 0)
                {
                    num1 += (1 - (sum + a[i]));
                    sum = 1;
                }
                else
                {
                    sum += a[i];
                }
            }
            else
            {
                if (sum + a[i] >= 0)
                {
                    num1 += (sum + a[i]) - (-1);
                    sum = -1;
                }
                else
                {
                    sum += a[i];
                }
            }
        }

        // a[0]を負にするパターン
        long num2 = 0;
        sum = 0;
        for (int i = 0; i < a.Length; i++)
        {
            if (i % 2 == 1)  // ここが違うよ！
            {
                if (sum + a[i] <= 0)
                {
                    num2 += (1 - (sum + a[i]));
                    sum = 1;
                }
                else
                {
                    sum += a[i];
                }
            }
            else
            {
                if (sum + a[i] >= 0)
                {
                    num2 += (sum + a[i]) - (-1);
                    sum = -1;
                }
                else
                {
                    sum += a[i];
                }
            }
        }
        
        Console.WriteLine(Math.Min(num1, num2));

    }
}

Measured memory_bytes: 31196
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
// use std::num;
const MOD: i64 = 1_000_000_007;
fn main() {
    input! {
        n:usize,m:usize
    }
    let mut fact = vec![1i64; m + 1];
    for i in 2..(1 + m) {
        fact[i] = fact[i - 1] * (i as i64) % MOD;
    }
    let perm = |m, n| fact[m] * modInv(fact[m - n]) % MOD;
    let comb = |m, n| fact[m] * modInv(fact[m - n]) % MOD * modInv(fact[n]) % MOD;
    //let comb2 = |m| n * (n - 1) * modInv(2) % MOD;
    // Aを固定して、Bを考える。
    // 求めたいパターンは、全てのパターン(0個以上が同じ) - 1個以上が同じ + 2個以上が同じ - ...
    // all = m P n
    // k以上が同じケース。
    let mut ans = 0;
    for i in 0..n + 1 {
        if i % 2 == 0 {
            ans += comb(n, i) * perm(m - i, n - i) % MOD;
        } else {
            ans -= comb(n, i) * perm(m - i, n - i) % MOD;
        };
    }
    ans = ans % MOD * perm(m, n) % MOD;
    // println!("{},{}", fact[2], modInv(fact[2]));
    // println!("{}", x);
    println!("{}", (ans + MOD) % MOD);
}

fn modPow(a: i64, n: i64) -> i64 {
    let mut res = 1;
    let mut a = a;
    let mut n = n;
    while n > 0 {
        if n % 2 != 0 {
            res = res * a % MOD;
        }
        a = a * a % MOD;
        n = n / 2;
    }
    return res;
}
fn modInv(a: i64) -> i64 {
    modPow(a, MOD - 2)
}


Measured memory_bytes: 5888
#include<stdio.h>
#include<string.h>
int main(void){
    int x=0,N,i,X[100];
    char S[100];
    scanf("%d",&N);
    scanf("%s",S);
    for(i=0;i<N;i++){
        if(S[i]=='I'){
          x++;  
        }else if(S[i]=='D'){
            x--;
        }
        X[i]=x;
    }
    x=0;
    for(i=0;i<N;i++){
        if(x<X[i]){
            x=X[i];
        }
    }
    printf("%d",x);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main( ) {
    //freopen("B.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin >> n >> k;
    int c = 1;
    while(n--){
        if (c < k){
            c *= 2;
        }
        else {
            c += k;
        }
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int s,min,max,n,p,i;
  while(scanf("%d",&n),n){
    min=2000;
    for(i=max=s=0;i<n;i++){
      scanf("%d",&p);
      s+=p;
      if(max<p)max=p;
      if(min>p)min=p;
    }
    s-=min+max;
    printf("%d\n",s/(n-2));
  }
  return 0;
}

Measured memory_bytes: 600
n=int(input())
childs=[0]*n

for i in range(n):
    node=list(map(int,input().split()))
    childs[node[0]] = node[1:]

class BisectTree:
    def __init__(self,childs):
        self.n=len(childs) 
        self.left_child=[0]*self.n
        self.right_child=[0]*self.n
        self.parent=[-1]*self.n
        for i in range(self.n):
            self.left_child[i]=childs[i][0]
            self.right_child[i]=childs[i][1]
            if childs[i][0] != -1:
                self.parent[childs[i][0]]=i
            if childs[i][1] != -1:
                self.parent[childs[i][1]]=i
        
        self.root=self.parent.index(-1)
        self.d=[0]*self.n
        self.degree=[0]*self.n
        self.sibling=[-1]*self.n
        self.node_type=[0]*self.n
        self.height=[-1]*self.n

    def set_depth(self,id,d):
        if id != -1:
            self.d[id]=d
            self.set_depth(self.left_child[id],d+1)
            self.set_depth(self.right_child[id],d+1)
    
    def set_degree(self):
        for i in range(self.n):
            deg=0
            if self.left_child[i] != -1:
                deg += 1
            if self.right_child[i] != -1:
                deg += 1
            self.degree[i]=deg
    
    def set_sibling(self):
        for i in range(self.n):
            if self.right_child[i] != -1 and self.left_child[i] != -1:
                self.sibling[self.right_child[i]]=self.left_child[i]
                self.sibling[self.left_child[i]]=self.right_child[i]
    
    def set_height(self,id):
        if self.left_child[id] == -1 and self.right_child[id] == -1:
            self.height[id]=0
        else:
            h1=self.set_height(self.left_child[id])
            h2=self.set_height(self.right_child[id])
            self.height[id]=max(h1,h2)+1
        return self.height[id]


    
    def set_node_type(self):
        for i in range(self.n):
            if self.parent[i] == -1:
                self.node_type[i]="root"
            elif self.left_child[i] == -1 and self.right_child[i] == -1:
                self.node_type[i]="leaf"
            else:
                self.node_type[i]="internal node"
    
tree = BisectTree(childs)
tree.set_sibling()
tree.set_degree()
tree.set_depth(tree.root,0)
tree.set_height(tree.root)
tree.set_node_type()

for i in range(n):
    print("node {}: ".format(i),end="")
    print("parent = {}, ".format(tree.parent[i]),end="")
    print("sibling = {}, ".format(tree.sibling[i]),end="")
    print("degree = {}, ".format(tree.degree[i]),end="")
    print("depth = {}, ".format(tree.d[i]),end="")
    print("height = {}, ".format(tree.height[i]),end="")
    print(tree.node_type[i])


            

            
    


Measured memory_bytes: 5632
package main

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

func main() {
	log.SetFlags(log.Lshortfile)
	n := nextInt()
	h := nextInt()
	w := nextInt()
	fmt.Println((n - h + 1) * (n - w + 1))

}

func intPow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func intMax(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func intMin(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func intSum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func intAbs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = newScanner()
}

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline

W,H=map(int,input().split())
p=sorted(int(input()) for i in range(W))
q=sorted(int(input()) for i in range(H))
ans=sum(p)*(H+1)+sum(q)*(W+1)
for i in range(W+H):
  if p[len(p)-1]>=q[len(q)-1]:
    ans-=p[len(p)-1]*len(q)
    p.pop()
    if p==[]:
      print(ans)
      exit()
  else:
    ans-=q[len(q)-1]*len(p)
    q.pop()
    if q==[]:
      print(ans)
      exit()

Measured memory_bytes: 48476
# import sys
# sys.setrecursionlimit
# getarr = lambda _f: list(map(_f, input().split()))

n = int(input())
s = input()

s += '_'

ans = 0
for i in range(1, n):
    tmp = 0
    for j in range(i, n + 1):
        if s[j - i] == s[j]:
            tmp += 1
            if tmp >= i:
                ans = i
                break
        else:
            ans = max(ans, tmp)
            tmp = 0

print(ans)


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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

const int MAXN = 500100, MAXK = 30;
const ll MOD = 1e9+7;
const ll INF = 1e18;
const ld PI = asin(1) * 2;

int h, w;
bool grid[50][50];
int dist[50][50][50][50];

void bfs (pii st) {
    if (!grid[st.f][st.s]) return;
    FOR(i, 1, h) FOR(j, 1, w)
        dist[st.f][st.s][i][j] = -1;

    dist[st.f][st.s][st.f][st.s] = 0;
    queue<pii> q;
    q.push(st);
    while (!q.empty()) {
        pii p = q.front(); q.pop();
        int i = p.f, j = p.s;
        if (grid[i-1][j] && dist[st.f][st.s][i-1][j] == -1) {
            q.push({i-1,j});
            dist[st.f][st.s][i-1][j] = dist[st.f][st.s][i][j]+1;
        }
        if (grid[i+1][j] && dist[st.f][st.s][i+1][j] == -1) {
            q.push({i+1,j});
            dist[st.f][st.s][i+1][j] = dist[st.f][st.s][i][j]+1;
        }
        if (grid[i][j-1] && dist[st.f][st.s][i][j-1] == -1) {
            q.push({i,j-1});
            dist[st.f][st.s][i][j-1] = dist[st.f][st.s][i][j]+1;
        }
        if (grid[i][j+1] && dist[st.f][st.s][i][j+1] == -1) {
            q.push({i,j+1});
            dist[st.f][st.s][i][j+1] = dist[st.f][st.s][i][j]+1;
        }
    }
}

int main()
{
    FAST_IO;

    cin >> h >> w;
    FOR(i, 1, h) FOR(j, 1, w) {
        char c; cin >> c;
        grid[i][j] = (c=='.');
    }
    int ans = 0;

    FOR(i, 1, h) FOR(j,1,w) {
        if (grid[i][j]) bfs({i,j});

        FOR(x, 1, h) FOR(y, 1, w)
            ans = max(ans, dist[i][j][x][y]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8960
/*.....Bismillahir Rahmanir Rahim.....*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld long double
#define   pb push_back
#define   sz(x)  (int)x.size()
#define   ff first
#define   ss second
#define   pii  pair<int,int> 
#define   pb  push_back
#define   eb  emplace_back
using namespace std;

void solve(){
	int  n,T,A,t,a;
	cin >> n >>T >> A ; 
	//cout << 1 <<" "<< T <<' '<< A<<endl;
	for (int i=1;i<n;i++){
		cin>>t>>a;
		int m;
		T += (t-1);
		A += (a-1);
		m = max(T/t,A/a);
		T = t*m;
		A = a*m;
		//cout << m <<" "<< T <<" "<< A << endl;
	}
	cout << T+A << endl; 
}

signed main()
{
	int  n=1; // cin >> n;
	while (n--) 
	solve();
    return 0;
}
/*
5
3 10
48 17
31 199
231 23
3 2

*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 

////////////////////////////////////////////////////////


int main() {
    string s; cin >> s;
    string t[] = {"Sunny", "Cloudy", "Rainy"};
    if(s == t[0]) co(t[1]);
    if(s == t[1]) co(t[2]);
    if(s == t[2]) co(t[0]);

    return 0;
}


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

#define rep(i,n) for (int i=0; i<(n); i++)
const int INF =1001001001;
const ll BIG = 1000000007;
const double PI = 3.141592653589793;

int main(){
    string s;
    int q;
    bool inverse=true;
    cin >> s >> q;
    rep(i,q){
        int ti, fi;
        string ci;
        cin >> ti;
        if(ti==1) inverse = !inverse;
        if(ti==2){
            cin >> fi >> ci;
            if(inverse){
                if(fi==1) s.insert(0,ci);
                else s.append(ci);
            }else{
                if(fi==1) s.append(ci);
                else s.insert(0,ci);
            }
        }
    }
    if(inverse) cout << s << endl;
    else {
        reverse(s.begin(),s.end());
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 900
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;

int main() {
	ll N;
	cin >> N;
	ll ans = 0;
	while (N - 3 >= 0) {
		ans++;
		N -= 3;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;
typedef long long ll;

int date[4];
int board[3];

char Print(int a){
    if(a)return '+';
    else return '-';
}

int main(){
    char str[10];
    while(scanf("%s",str)!=EOF){
        for(int i=0 ; i<4 ; i++){
            date[i] = str[i]-'0';
        }
        int sum = date[0];
        int key = 0;
        for(int i=0 ; i<2 ; i++){
            if(key)break;
            int mid;
            if(i)mid = sum+date[1];
            else mid = sum-date[1];
            for(int j=0 ; j<2 ; j++){
                if(key)break;
                int mid2;
                if(j)mid2 = mid+date[2];
                else mid2 = mid-date[2];
                for(int k=0 ; k<2 ; k++){
                    if(key)break;
                    int mid3;
                    if(k)mid3 = mid2+date[3];
                    else mid3 = mid2-date[3];
                    if(mid3 == 7){
                        key = 1;
                        board[0] = i;
                        board[1] = j;
                        board[2] = k;
                    }
                }
            }
        }
        cout<<str[0]<<Print(board[0])<<str[1]<<Print(board[1])<<str[2]<<Print(board[2])<<str[3]<<"=7"<<endl;
    }
}

Measured memory_bytes: 256
/**
 *  author: mahfuzz
 *  created: 03.04.2020
**/
 
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end();
#define debug(x) cout << #x << ':' << x << "\n";
typedef long long ll;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    int a, b, c; cin >> a >> b >> c;
    
    int temp = b;
    
    b = a;
    a = temp;
    
    temp = c;
    
    c = a;
    
    a = temp;
    
    
    cout << a << " " << b << " " << c << "\n";
    
    
        
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;


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

	int ans = N;

	for(int i=0;i<=N;i++){
		int tmp = 0;
		int n = i;
		while(n>0){
			tmp += n%6;
			n /= 6;
		}
		n = N-i;
		while(n>0){
			tmp += n%9;
			n /= 9;
		}
		if(tmp < ans) ans = tmp;
	}

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

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[200005] = {}, b[200005] = {};
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i], b[i] = a[i];
    sort(b + 1, b + n + 1);
    for (int i = 1; i <= n; i++) {
        if (a[i] <= b[n / 2]) cout << b[n / 2 + 1] << '\n';
        else cout << b[n / 2] << '\n';
    }
}


Measured memory_bytes: 3840
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		if (A == B && B != C) {
			System.out.println("Yes");
		} else if (C == B && B != A) {
			System.out.println("Yes");
		} else if (C == A && B != A) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21716
k,n = map(int,input().split())
a = list(map(int,input().split()))

#湖の周長からaの間隔が一番大きいところを引く
a.append(k+a[0])
max_len = 0

for i in range(1,n+1):
    max_len = max(max_len,a[i]-a[i-1])

print(k-max_len)

Measured memory_bytes: 26444
#include<bits/stdc++.h>
long long i,a,N,s,A=INT_MAX,l,r,S[100002];int main(){scanf("%ld%ld",&N,&s);for(;i<N;i++){scanf("%ld",&a);S[i+1]+=S[i]+a;}for(;;){if(S[r]-S[l]>=s){A=std::min(A,r-l);l++;}else r++;if(r>N){if(A==INT_MAX)A=0;printf("%ld\n",A);return 0;}}}

Measured memory_bytes: 4008
/*
 * 競技プログラミング用テンプレート
 * by yuma140902
 * 2020/06/01
 * ver 0.3.1
 */
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef tuple<int, int> ii;
typedef tuple<int, int, int> iii;
const int INF = 900000;
const ll INFL = 9000000;

#define vi vector<int>
#define vii vector<vector<int> >
#define vi_def(n) vector<int>((n))
#define vii_def(n,m) vector<vector<int> >((n), vector<int>((m)))
#define vi_def_dflt(n, def) vector<int>((n), (def))
#define vii_def_dflt(n, m, def) vector<vector<int> >((n), vector<int>((m), (def)))

#define rep(i, n) for(int i=0; i < (n); ++i)
#define per(i, n) for(int i=(n)-1; i >= 0; --i)
#define range(i, begin, end) for(int i=(begin); i < (end); ++i)

#define ALL(vec) vec.begin(), vec.end()

#ifdef DBG_FLAG
#define pdbg(msg) cout << (msg)
#define dbg if(true)
#else
#define pdbg(msg) ;
#define dbg if(false)
#endif

int N;
int A, B;
string S;
vector<bool> res;
int main(){
  cin >> N >> A >> B;
  cin >> S;
  res = vector<bool>(N, false);

  int numFinCntestnt = 0;
  int numFinCntestntAbroad = 0;
  rep(i, N){
    if(S.at(i) == 'a'){
      if(numFinCntestnt < A+B){
        ++numFinCntestnt;
        res[i] = true;
      }
    }
    else if(S.at(i) == 'b'){
      if(numFinCntestnt < A+B && numFinCntestntAbroad < B){
        ++numFinCntestnt;
        ++numFinCntestntAbroad;
        res[i] = true;
      }
    }
  }

  rep(i, N){
    if(res[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


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

int main() {
  int N, K;
  cin >> N >> K;
  std::vector<int> h;
  h.reserve(N);
  copy_n(istream_iterator<int>(cin), N, back_inserter(h));
  std::vector<int> D(N, INT_MAX);
  D[0] = 0;
  for (int i = 1; i < N; ++i)
    for (int k = 1; k <= K && i - k >= 0; k++)
      D[i] = min(D[i], D[i - k] + abs(h[i] - h[i - k]));
  cout << D[N - 1] << endl;
  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 int ll;
typedef pair<int, int> P;
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 int D = 60;
int to[D][200005];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll k;
	cin >> n >> k;
	rep(i,n){
		cin >> to[0][i];
		--to[0][i];
	}
	rep(i,D-1)rep(j,n) to[i+1][j] = to[i][to[i][j]];
	int cur = 0;
	for(int i = D-1; i >= 0; --i){
		ll two = 1LL << i;
		if(two <= k){
			cur = to[i][cur];
			k -= two;
		}
	}
	int ans = cur + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 50536
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-')
		jp = getchar();
	if (jp == '-')
		fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9')
		out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
const int N = 1e5 + 10, inf = 1e9;
int n, m, a[N], b[N], k;
int main()
{
	int ma = inf, mb = inf;
	n = read(), m = read(), k = read();
	for (int i = 1; i <= n; ++i)
		ma = min(ma, a[i] = read());
	for (int i = 1; i <= m; ++i)
		mb = min(mb, b[i] = read());
	int ans = ma + mb;
	for (int i = 1; i <= k; ++i)
	{
		int x = read(), y = read();
		ans = min(ans, a[x] + b[y] - read()); 
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
int main(){
	int num,ac;
	multimap<int,int,greater<int> > teams;
	while(scanf("%d,%d",&num,&ac)!=EOF){
		if(num==0&&ac==0)break;
		teams.insert(multimap<int,int>::value_type(ac,num));
	}
	int rank=1,acl;
	map<int,int> ranking;
	for(multimap<int,int>::iterator it=teams.begin();it!=teams.end();++it){
		if(it==teams.begin()){
			acl=(*it).first;
			ranking[(*it).second]=rank;
		}else{
			if(acl!=(*it).first) ++rank;
			acl=(*it).first;
			ranking[(*it).second]=rank;
		}
	}
	while(cin>>num) cout<<ranking[num]<<endl;
	return 0;
}

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

A = []
for i in range(N):
	A.append(list(map(int,input().split())))
ans = 0
for j in range(1,M+1):
	n = 0
	for i in range(N):
		if j in A[i][1:]:
			n +=1
		if n == N:
			ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s, w; cin >> s >> w;
    if(s <= w) cout << "unsafe";
    else cout << "safe";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll a, b, c;
    cin >> a >> b >> c;

    ll _min, _max;

    _min = min(a, b);
    _min = min(_min, c);

    _max = max(a, b);
    _max = max(_max, c);

    cout << _min << ' ' << _max << endl;

    return 0;
}



Measured memory_bytes: 3180
#include <iostream>

using namespace std;

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

    int a0;
    cin >> a0;
    int prev = a0;
    int mdist = 0;
    int cur;

    for (int i = 1; i < n; ++i)
    {
        cin >> cur;

        if (cur-prev > mdist)
        {
            mdist = cur-prev;
        }
        prev = cur;
    }

    if (k-cur + a0 > mdist)
    {
        mdist = k-cur+a0;
    }

    cout << k-mdist << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;


public class Main {

	public static final long MOD = 1_000_000_007;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long p = sc.nextLong();
		
		TreeMap<Long, Integer> map = new TreeMap<>();
		
		
		for (long i=2;i*i<=p;i++) {
			int counter = 0;
				while(p%i==0) {
					p/=i;
					counter++;
				}
			
			if(counter>0) {
				map.put(i, counter);
			}
		}
		if (p>1) {
			map.put(p, 1);
		}
		
		
		long ans = 1;
		for (Map.Entry<Long, Integer> e : map.entrySet()) {
			for (int i=0;i<e.getValue()/n;i++) {
				ans*=e.getKey();
			}
		}
		System.out.println(ans);
	}
	
	

}


Measured memory_bytes: 23892
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int n, i, sum=0;
    scanf("%d", &n);
    char s[n+1];
    scanf("%s", s);
    for(i=0; i<n; i++){
		if(s[i]!=s[i+1]){
			sum++;
		}
    }
    printf("%d", sum);
    return 0;
}


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

int main(){
    vector<int> array;
    
    for(int i = 0;;i++){
        int a;
        cin >> a;
        if(a == 0) break;
        array.push_back(a);
    }
    
    for(int i = 0; i < array.size(); i++){
        cout << "Case " << i + 1 << ": " << array[i] << endl;
    }
}




Measured memory_bytes: 3184
#include <cmath>  
#include <algorithm>
#include <iostream>
#include <utility>

using namespace std;

const double eps=1e-8; 
struct point{
	double x,y;	
}P[310];
int x,y,N;
int ans=1;

double cal_distance(point a, point b){
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

point cal_center(point a, point b){
	point mid,center;
	mid.x = (a.x+b.x)/2.0;
	mid.y = (a.y+b.y)/2.0;
	double angle = atan2(a.x-b.x,b.y-a.y);
	double line = sqrt(1-(cal_distance(a,mid)*cal_distance(a,mid)));
	center.x = mid.x+line*cos(angle);
	center.y = mid.y+line*sin(angle);
	return center;
}

int main(){
	while(cin >> N && N>0){
		ans = 1;
		for (int i=0; i<N; i++){
				cin >> P[i].x >> P[i].y;
			}
			for (int i=0; i<N; i++){
				for (int j=i+1; j<N; j++){
					if (cal_distance(P[i],P[j]) > 2.0) continue;
					point center = cal_center(P[i], P[j]);
					int count = 0;
					for (int k=0; k<N;k++){
						if (cal_distance(P[k],center) < (1.0+eps)) count++;
					}
					ans = max(ans,count);
				}
			}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define CLR(a) memset((a),0,sizeof(a))
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
void pkuassert(bool t){t=1/t;};
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};

int main(int argc, char *argv[])
{
  int a,b,d;
  while(cin >> a >> b >> d && a && b){
    pair<PI,PI> ans(mp(1<<29,1<<29),mp(1<<29,1<<29));
    for(int i=0;i<=100000;++i){
      if(a*i>=d){
        if((a*i-d)%b==0){
          int j=(a*i-d)/b;
          ans=min(ans,
                  mp(mp(i+j,a*i+j*b),mp(i,j)));
        }
      }

      if(a*i<=d){
        if((d-a*i)%b==0){
          int j=(d-a*i)/b;
          ans=min(ans,
                  mp(mp(i+j,a*i+j*b),mp(i,j)));
        }
      }      

      if((a*i+d)%b==0){
        int j=(a*i+d)/b;
        ans=min(ans,
                mp(mp(i+j,a*i+j*b),mp(i,j)));
      }
    }
    cout << ans.S.F << ' ' << ans.S.S << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
# -*- coding: utf-8 -*-
n = int(input())
h = [int(i) for i in input().split()]

ans = []
tmp = 0
for i in range(1, n):
    #print(h[i - 1], h[i])
    if h[i - 1] >= h[i]:
        tmp += 1
    else:
        ans.append(tmp)
        tmp = 0
    #print(tmp, ans)
ans.append(tmp)
print(max(ans))


Measured memory_bytes: 14252
import sys
from heapq import heappop, heappush
input = sys.stdin.readline

class UnionFind:
    def __init__(self, n):
        self.parent = [-1] * (n + 1)

    def root(self, x):
        if self.parent[x] < 0:
            return x
        else:
            rx = self.root(self.parent[x])
            self.parent[x] = rx
            return rx

    def size(self, x):
        return -self.parent[self.root(x)]
    
    def same(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        return ra == rb
    
    def merge(self, a, b):
        a = self.root(a)
        b = self.root(b)
        if a == b:
            return False
        if self.parent[a] > self.parent[b]:
            a, b = b, a
        self.parent[a] += self.parent[b]
        self.parent[b] = a
        return True

N, M = map(int, input().split())
edges = []
for i in range(0, M):
    a, b = map(int, input().split())
    edges.append((a, b))

ans = 0
for i in range(0, M):
    uf = UnionFind(N)
    for j in range(0, M):
        if i == j:
            continue
        uf.merge(edges[j][0], edges[j][1])
    same = True
    ans = ans + (uf.same(edges[i][0], edges[i][1]) == False)


print(ans)

Measured memory_bytes: 41072
a = list(map(int, input().split()))

L = [0] * 3
L[0] = abs(a[0] - a[1])
L[1] = abs(a[0] - a[2])  
L[2] = abs(a[1] - a[2])

L = sorted(L)
re = L[0] + L[1]
print(re)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,a,diff;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if(a!=i)
			diff++;
	}
	if(diff<=2)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
($H,$W,$D)=glob<>;
for$y(1..$H){
	@_[glob<>]=map[$y,$_],1..$W
}
for(1..9e4){
	$s[$_+$D]=
		$s[$_]+
		abs(@{$_[$_+$D]}[0]-@{$_[$_]}[0])+
		abs(@{$_[$_+$D]}[1]-@{$_[$_]}[1])
}
<>;/ /,print$s[$']-$s[$`],$/for<>


Measured memory_bytes: 49280
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int x = int.Parse(input[0]);
        int a = int.Parse(input[1]);
        int b = int.Parse(input[2]);

        if( b - a <= 0)
        {
            Console.WriteLine("delicious");
        }
        else if( b - a <= x)
        {
            Console.WriteLine("safe");
        }
        else
        {
            Console.WriteLine("dangerous");
        }
    }
}



Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

void show(vector<vector <int>> v,int N){
    for(int i=0;i<N;i++){
        cout << v[i][0] << " " << v[i][1] << endl;
    }
}

int main(){
    int N,M,last_num = 0,ans=0;
    cin >>N >>M;
    vector<int> a(2);
    vector< vector<int>> jobs(N,a);
    priority_queue<int> q;

    //日数、報酬
    for(int i=0; i<N; i++){
        cin >>jobs[i][0] >>jobs[i][1];
    }
    sort(jobs.begin(),jobs.end());
    //show(jobs,N);
    for(int i=1;i<=M;i++){
        while(last_num != N){
            if(jobs[last_num][0] <= i){
                q.push(jobs[last_num][1]);
                last_num++;
            }
            else break;
        }
        if(q.empty())continue;
        else{
            ans += q.top();
            //cout << ans << endl;
            q.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

inline int add(int x,int y)
{
    return (x + y)%MOD;
}

inline int sub(int x,int y)
{
    return (x+MOD-y)%MOD;
}

inline int mul(int x,int y)
{
    return (ll)x*y%MOD;
}

int a[105];
int dp[105][MAX_N];
int sm[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, K;
    cin >> n >> K;
    rep(i,n){
        cin >> a[i];
    }
    dp[0][K] = 1;
    rep(i,n){
        rep(j,K+1){
            sm[j] = 0;
        }
        rep(j,K+1){
            sm[max(0, j-a[i])] = add(sm[max(0, j-a[i])], dp[i][j]);
            sm[j+1] = sub(sm[j+1], dp[i][j]);
        }
        rep(j,K){
            sm[j+1] = add(sm[j+1], sm[j]);
        }
        rep(j,K+1){
            dp[i+1][j] = sm[j];
        }
    }
    cout << dp[n][0] << "\n";
    return 0;
}

Measured memory_bytes: 40832
/*#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	
	return 0;
}*/
/*
1
y eazqyp pnop pngtg ye obmpngt xmybp mr lygw
*/

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
 
#define rep(i,n) for(int i=0; i<n; i++)
int dp[1001][1001];
 
int main(){
    int W, cnt=1;
    while( cin >> W, W ){
        int n, v[1000], w[1000];
        memset( dp, 0, sizeof(dp) );
        cin >> n;
        rep(i,n){
            scanf("%d,%d", &v[i], &w[i]);
        }
        dp[0][0] = 0;
    	
        
    	rep(i,n){
            rep(j,W+1){
                if( j<w[i] )
                    dp[i+1][j] = dp[i][j];
                else
                    dp[i+1][j] = max( dp[i][j], dp[i][j-w[i]]+v[i] );
            }
        }
        int mw = 0;
        rep(i,W+1){
            if( dp[n][i]>dp[n][mw] ) mw = i;
        }
    	
    	/*for(int i = 0;i < n;i++){
    		for(int j = 0;j < W+1;j++){
    			cout << dp[i][j] << " ";
    		}
    		cout << endl;
    	}*/
    	
        cout << "Case " << cnt << ":" << endl;
        cnt++;
        cout << dp[n][mw] << endl;
        cout << mw << endl;
    }
	return 0;
}
/*
20
5
60,5
100,10
120,15
210,20
10,2
*/

Measured memory_bytes: 7060
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;


int main(){
  string s;
  cin >> s;
  cout << "ABC" << s << endl;
}

Measured memory_bytes: 3636
s = input()
q = int(input())
order_list = list()
for i in range(q):
    order = list(map(str,input().split()))
    order_list.append(order)

for order in order_list:
    a = int(order[1])
    b = int(order[2])
    if order[0] == "print":
        print(s[a:b+1])
    elif order[0] == "reverse":
        s_rv = s[a:b+1]
        s_rv = s_rv[::-1]
        s = s.replace(s[a:b+1], s_rv)
    elif order[0] == "replace":
        s_part = s[a:b+1]
        s_part = s_part.replace(s[a:b+1], order[3])
        s = s[:a] + s_part + s[b+1:]



Measured memory_bytes: 5612
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int n, m, i, j, k, x, s;
	cin >> n >> m;
	vector<int> ct(m + 1, 0);
	for (i = 0; i < n; i++) {
		cin >> s;
		while (s--) {
			cin >> x;
			ct[x]++;
		}
	}

	s = 0;
	for (i = 1; i <= m; i++) {
		if (ct[i] == n) s++;
	}
	cout << s << "\n";

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

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

int main() {
	for (;;) {
		int e; cin >> e;
		if (e == 0) break;
		int m = INT_MAX;
		for (int z = 0; z * z * z <= e; z++)
			for (int y = 0; y * y + z * z * z <= e; y++) {
				int x = e - y * y - z * z * z;
				if (x >= 0) m = min(m, x + y + z);
			}
		cout << m << endl;
	}
}

Measured memory_bytes: 1160
#include<stdio.h>
int main()
{
    int x,y,z,a,b;
    scanf("%d",&x);
    scanf("%d",&a);
    scanf("%d",&b);
    if(x>a&&x>b)
    {
        y=x-a;
        z=x-b;
    }
    else if(x>a&&x<b)
    {
        y=x-a;
        z=b-x;
    }
    else if(x<a&&x>b)
    {
        y=a-x;
        z=x-b;
    }
    else
    {
        y=a-x;
        z=b-x;
    }
    if(y<z)
    {
        printf("A");
    }
    else
    {
        printf("B");
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
const char sp =' ';
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	vpi a(n);
	int i;
	for(i=0;i<n;i++){
        cin >> a[i].f>>a[i].s;
	}
	int count=0;
	for(i=0;i<n;i++){
        if(a[i].f==a[i].s){
            count++;
        if(count==3){
            cout<< "Yes";
        break;
        }
        }else count=0;

	}
	if(count!=3)cout << "No";
		return 0;
}

// read the question correctly (ll vs int)
// template by bqi343


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sax(x) cout << "!!!!!!!!!!! " << #x << " = " << x << '\n'
#define inf (sizeof(int) == 4 ? (int)1E9 : (int)1E18)
#define one(x) x.insert(x.begin(), 0);
#define TCT template <class T>
#define TCT12 template <class T1, class T2>
#define IS istream
#define OS ostream
#define OP operator

//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,
//tree_order_statistics_node_update> imsi;

TCT IS& OP>>(IS &I, vector<T>& v) {for (T &e: v) I >> e; return I;}
TCT OS& OP<<(OS &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const unordered_set<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const set<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const unordered_multiset<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, const multiset<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT IS& OP>>(IS &I, deque<T>& v) {for (T &e: v) I >> e; return I;}
TCT OS& OP<<(OS &O, const deque<T>& v) {for (const T &e: v) O << e << ' '; return O;}
TCT OS& OP<<(OS &O, priority_queue<T> v) {while (!v.empty()) {O << v.top() << ' '; v.pop();} return O;}
TCT OS& OP<<(OS &O, stack<T> v) {while (!v.empty()) {O << v.top() << '\n'; v.pop();} return O;}
TCT OS& OP<<(OS &O, queue<T> v) {while (!v.empty()) {O << v.front() << ' '; v.pop();} return O;}
TCT12 IS& OP>>(IS &I, pair<T1,T2>& p) {return I >> p.first >> p.second;}
TCT12 OS& OP<<(OS &O, const pair<T1,T2>& p) {return O << '(' << p.first << ' ' << p.second << ')';}
TCT12 OS& OP<<(OS &O, const unordered_map<T1,T2>& v) {for (const auto &e: v) O << e << ' '; return O;}
TCT12 OS& OP<<(OS &O, const map<T1,T2>& v) {for (const auto &e: v) O << e << ' '; return O;}
typedef pair<int,int> pii;
typedef vector<int> vi;





void _main() {
        int n; cin >> n;
        cout << n * (n + 1) / 2 - n;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 256
//
//  count_ball.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <math.h>
typedef long long ll;
int main(int argc, const char* argv[]) {
  int a, b;
  std::cin >> a >> b;

  int price_before8 = a * 100 / 8;
  int price_before10 = b * 100 / 10;

  int min = 0;
  int max = 0;
  if (price_before8 <= price_before10) {
    min = price_before8;
    max = price_before10;
  }
  else {
    min = price_before10;
    max = price_before8;
  }

  int result = -1;
  for (int i=min; i<=max+1; i++) {
    int tax8 = i * 8 / 100;
    int tax10 = i / 10 ;
    if (tax8 == a && b == tax10) {
      result = i;
      break;
    }
  }

  std::cout << result << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    bool ok = true;
    string prev;
    map<string, bool> W;
    REP(i, 0, N) {
        string w;
        cin >> w;
        if (W[w]) {
            ok = false;
            break;
        }
        if (i != 0 && prev.back() != w[0]) {
            ok = false;
            break;
        }
        W[w] = true;
        prev = w;
    }
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  
  for(int i=0; i<3; i++){
    if(S[i]==S[i+1]){
      cout << "Bad";
      return 0;
    }
  }
  cout << "Good";
  return 0;
}

Measured memory_bytes: 256
mod=10**9+7

def add(a, b):
    return (a + b) % mod

def sub(a, b):
    return (a + mod - b) % mod

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))

def cc(ii):
    iii=1
    for ii in range(1,ii+1):
        iii=iii*ii
    return iii

def cmb(a,b):
    iii=1
    for ii in range(a-b+1,a+1):
        iii=(iii*ii)%mod
    iiii=1
    for ii in range(1,b+1):
        iiii=(iiii*ii)%mod
#        print("ii,iiii:",ii,iiii)
#    print("a:",a,"b:",b,"iii:",iii,"iiii:",iiii)
#    print("a:",a,"b:",b,"a-b:",a-b,"a!:",iii,"b!:",iiii,"cmb:",iii//iiii)
    return div(iii,iiii)        

from functools import reduce

def cmb2(n,r):
    r = min(n-r,r)
    if r == 0: return 1
#    if r==1 : return n
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return div(over,under)        

n,k=map(int,input().split())

ib=k-1
ir=n-ib

for i in range(1,ib+2):
    if i>ir:
        print(0)
        continue
#    cb=cc(ib)//cc(ib-i+1)//cc(i-1)
#    cr=cc(ir)//cc(ir-i)//cc(i)
    cb=cmb2(ib,i-1)
    cr=cmb2(ir,i)
#    print("ib:",ib,i-1,cb,"ir:",ir,i,cr)
    print(mul(cb,cr))
    


Measured memory_bytes: 9708
#include<stdio.h>
 
int main(void)
{
	int i, j, k, l, cnt, n;
	while(scanf("%d",&n)!=EOF)
	{
		cnt = 0;
		for(i = 0; i <= 9; i++)
		for(j = 0; j <= 9; j++)
		for(k = 0; k <= 9; k++)
		for(l = 0; l <= 9; l++)
		if(i + j + k + l == n)	cnt++;
		
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 596