akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdint>
#include <string>
#include <unordered_map>
#include <utility>
#include <algorithm>

int main() {
  std::string s;
  std::cin >> s;
  std::unordered_map<char, std::int_fast32_t> table;
  for (const char& c : s) {
    ++table[c];
  }
  std::cout << (std::all_of(table.begin(), table.end(), [](const std::pair<char, std::int_fast32_t> pair) {
    return pair.second % 2 == 0;
  }) ? "Yes" : "No") << std::endl;
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    int size_s = s.size();
    if (size_s == 3)
    {
        for (int i = size_s - 1; i >= 0; i--)
        {
            cout << s[i];
        }
        cout << endl;
    }
    else
    {
        cout << s << endl;
    }
    
}

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

//#define int long long

const int MAXN = 110;
const int INF = 2e9;
const int mod = 1e9 + 7;

int n;
char s[MAXN];
bool flag = true;

signed main () {
	cin >> s + 1;
	n = strlen(s + 1);
	for(register int i = 1;i <= n; ++i)
		if(s[i] != s[n - i + 1]) {flag = false; break;}
	for(register int i = 1;i <= (n - 1) / 2; ++i)
		if(s[i] != s[(n - 1) / 2 - i + 1]) {flag = false; break;}
	for(register int i = (n + 3) / 2;i <= n; ++i)
		if(s[i] != s[n - i + (n + 3) / 2]) {flag = false; break;}
	if(!flag) return puts("No"),0;
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
# 057_a
A, B = map(int, input().split())

if (0 <= A & A <= 23) & (0 <= B & B <= 23):
    if (A + B) > 24:
        print((A + B) - 24)
    elif (A + B) == 24:
        print(0)
    else:
        print(A + B)


Measured memory_bytes: 9060
import functools
import copy

N = int(input())
A = list(map(int, input().split()))

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

l = [0] * N  #L_i, i = 0, 1, 2, ..., N-1
for i in range(N):
    if i == 0:
        continue
    else:
        l[i] = gcd(l[i-1], A[i-1])

r = [0] * N #R_i, i = 0, 1, 2, ..., N-1
for j in range(N):
    if j == 0:
        continue
    else:
        r[N-j-1] = gcd(r[N-j], A[N-j])

m = [0] * N
for i in range(N):
    m[i] = gcd(l[i], r[i])

print(max(m))


Measured memory_bytes: 15080
import sys
sys.setrecursionlimit(100000)
s=input().strip()
x,y=map(int,input().split())
sl=[len(i) for i in s.split('T')]
x0,y0=sl[0],0
s_x = sl[::2]
s_y = sl[1::2]
s_y=[0]+s_y
dpx=[set() for i in s_x]
dpy=[set() for i in s_y]
dpx[0].add(s_x[0])
dpy[0].add(0)
for i,l in enumerate(s_x):
    if i==0:continue
    ll=dpx[i]
    for xx in dpx[i-1]:
        ll.add(xx-l)
        ll.add(xx+l)
for i,l in enumerate(s_y):
    if i==0:continue
    ll=dpy[i]
    for yy in dpy[i-1]:
        ll.add(yy-l)
        ll.add(yy+l)
print('Yes' if x in dpx[-1] and y in dpy[-1] else 'No')

Measured memory_bytes: 359940
#include<stdio.h>
int main(void)
{
	int i,h,k,a[3],b[3],c[5];
	for(i=0;i<2;i++) scanf("%d %d",&a[i],&b[i]);
	for(i=0;i<4;i++) scanf("%d",&c[i]);
	h=a[0]/10*c[2]+a[0]*c[0];
	k=a[1]/10*c[2]+a[1]*c[0];
	h=h+b[0]/20*c[3]+b[0]*c[1];
	k=k+b[1]/20*c[3]+b[1]*c[1];
	if(h>k) printf("hiroshi\n");
	else if(h==k) printf("even\n");	
	else printf("kenjiro\n");
	return 0;
}

Measured memory_bytes: 2688
/*
  The Island Was Silent before.
  .....
  And One day again it became Silent.
*/
#include<bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define rtt cerr << "Time: " << clock()*1.0 / CLOCKS_PER_SEC << endl;
#define ffe freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);
 int c[10010];
  int aa[100010];
int main() {
  #ifndef ONLINE_JUDGE
//  ioso ffe
  #endif
  ll x,n;
  cin >> x >> n;
  int a[n];
  //vector<>
  for(int i=0;i<n;i++) {
    cin >> a[i];
    //v.push_back(abs(a[i]-x));
    if(a[i]<x) {c[abs(a[i]-x)] = 0;}
    else {
      c[abs(a[i]-x)]=1;
    }
    aa[abs(a[i]-x)]++;
  }
//  sort(v.begin(),v.end());

 // for(auto i:v) {
 ///   aa[i]++;
 // }
  if(aa[0]==0) {
    cout << x << endl;
    return 0;
  }
  for(int i=1;i<=101;i++) {
    if(aa[i]==0) {
      cout << x-i; return 0;
    }
    else {
      if(aa[i]==1) {
        if(c[i]==0) {
          cout << x+i; return 0; 
        }
        else {
          cout << x-i; return 0;
        }
      }
    }
  }
 

}

Measured memory_bytes: 3636
import math

H,W = [int(i) for i in input().split()]

even = math.ceil(W/2)
odd = math.floor(W/2)

cnt = 0

if H==1 or W==1:
    cnt = 1
else:
    if H%2:
        cnt = even*math.ceil(H/2) + odd*math.floor(H/2)
    else:
        cnt = even*math.floor(H/2) + odd*math.ceil(H/2)
    
print(cnt)

Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	var n, l int
	fmt.Scan(&n)
	fmt.Scan(&l)
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = nextLine()
	}
	sort.Strings(s)
	var str string
	for i := 0; i < n; i++ {
		str += s[i]
	}
	fmt.Println(str)
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define REP0(i,j) for(int i = 0; i < j; i++)
#define REP1(i,j) for(int i = 1; i <= j; i++)
using namespace std;
typedef long long ll;
const int maxn = 100 + 50;
const ll mod = 1e9+7;
const int MAXN = (1<<30);
typedef vector<int> vi;
typedef pair<int, int> pii;
int n, p;
int a[maxn];
ll c[maxn][maxn];
void get_C(){
	for(int i = 0; i <= 50; i++){
		c[i][0] = 1;
		for(int j = 1; j <= i; j++){
			c[i][j] = c[i-1][j-1] + c[i-1][j];
		}
	}
}
int main(){
//freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	get_C();
	cin >> n >> p;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = 1; i <= n; i++)
		a[i]%=2;
	int cnt0 = 0, cnt1 = 0;
	for(int i = 1; i <= n; i++)
	{
		if(a[i] == 0) cnt0++;
		else cnt1++;
	}
	ll temp = 0;
	for(int i = 0; i <= cnt0; i++)
		temp+=c[cnt0][i];
	ll ans = 0;
	if(p == 1){
		int tt = cnt1;
		if(!(cnt1 & 1)) tt = cnt1-1;
		for(int i = 1; i <= tt; i+=2)
			ans+=c[cnt1][i];
		ans*=temp;
	}
	else{
		int tt = cnt1;
		if(cnt1 & 1) tt = cnt1-1;
		for(int i = 0; i <= tt; i+=2)
			ans+=c[cnt1][i];
		ans*=temp;
	}
	cout << ans << endl;
	return 0;
}

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

int main(void) {
    int W, H, x, y, r;
    
    cin >> W >> H >> x >> y >> r;

    if (0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1156
n = int(input())
H = [int(x) for x in input().split()]
H.reverse()
ans = 'Yes'
for i in range(n-1):
  if H[i] >= H[i+1]:
    continue
  elif H[i] + 1 == H[i+1]:
    H[i+1] = H[i]
  else:
    ans = "No"
    break
print(ans)

Measured memory_bytes: 14252
sx,sy,tx,ty=map(int,input().split())
dx=tx-sx
dy=ty-sy
tmp=""
tmp+="U"*dy+"R"*dx+"D"*dy+"L"*dx
tmp+="L"+"U"*(dy+1)+"R"*(dx+1)+"D"+"R"+"D"*(dy+1)+"L"*(dx+1)+"U"
print(tmp)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> v;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    for (int i = 0; i < n - 2; i++) {
        if (v[i].first == v[i].second && v[i + 1].first == v[i + 1].second && v[i + 2].first == v[i + 2].second) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}






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

using namespace std;

int N;
vector<int> vec;

bool handle(void) {
	for (int i = 0; i < N; i++) {
		if (vec[i] % 2 != 0) {
			return false;
		}

		vec[i] = vec[i] / 2;
	}

	return true;
}

int main(void) {

	int v;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> v;
		vec.push_back(v);
	}

	int num = 0;
	while (handle()) {
		++num;
	}

	cout << num << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
long long n, t[300000], T, u, ret;
int main() {
	cin >> n >> T; for (int i = 0; i < n; i++)cin >> t[i]; u = -1;
	for (int i = 0; i < n; i++) {
		if (u == -1)u = t[i];
		if (i == n - 1 || t[i + 1] - t[i] >= T) { ret += (t[i] + T - u); u = -1; }
	}
	cout << ret << endl;
	return 0;
}

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

ll f(ll x){
    return 10 * x + 7;
}
int main(void){
    ll k, ans;
    cin >> k;
    vector<ll> b(k);
    for(ll i = 0; i < k; i++) b[i] = 0;
    ll a = 7;
    ll i = 1;
    while(true){
        ll t = a % k;
        if(t == 0){
            ans = i;
            break;
        } else if(b[t] > 0){
            ans = -1;
            break;
        } else {
            b[t]++;
            a = f(t);
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
struct nodel{
    int x,id;
    nodel(){}
    nodel(int a,int b){x=a;id=b;}
    bool operator < (const nodel a)const {
        return a.x > x;
    }
};
struct noder{
    int x,id;
    noder(){}noder(int a,int b){x=a;id=b;}
    bool operator < (const noder a)const {
    return a.x < x;
    }
};
priority_queue<nodel> ql,ql2;
priority_queue<noder> qr,qr2;
int n,out[100000+100];
ll ans1,ans2;
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;++i) 
	{int l,r;
    scanf("%d%d",&l,&r);
    ql.push(nodel(l,i));
    ql2.push(nodel(l,i));
    qr.push(noder(r,i));
    qr2.push(noder(r,i));
    }
    int now=0;
    for(int ti=1;ti<=n;++ti) {
        while(!ql.empty()&&out[ql.top().id])ql.pop();
        while(!qr.empty()&&out[qr.top().id])qr.pop();
        if(ti%2&&now < ql.top().x)ans1+=abs(now-ql.top().x),now=ql.top().x,out[ql.top().id]=1,ql.pop();
        else if(now > qr.top().x) ans1+=abs(now-qr.top().x),now=qr.top().x,out[qr.top().id]=1,qr.pop();
    }
    ans1 += abs(now);
    memset(out,0,sizeof(out));
    now=0;
    for(int ti=1;ti<=n;++ti) {
    while(!ql2.empty()&&out[ql2.top().id])ql2.pop();
    while(!qr2.empty()&&out[qr2.top().id])qr2.pop();
    if(ti%2==0&&now<ql2.top().x)ans2+=abs(now-ql2.top().x),now=ql2.top().x,out[ql2.top().id]=1,ql2.pop();
    else if(now>qr2.top().x) ans2+=abs(now-qr2.top().x),now=qr2.top().x,out[qr2.top().id]=1,qr2.pop();
    }
    ans2+=abs(now);
    cout<<max(ans1,ans2) <<'\n';
    return 0;
}

Measured memory_bytes: 3924
str=input()
N=len(str)
s=list(str)
tehon=[]
if N%2==0:
    kai=N/2
    i=0
    while i<kai:
        tehon.append(1)
        tehon.append(0)
        i=i+1
else:
    kai=(N-1)/2
    i=0
    while i<kai:
        tehon.append(1)
        tehon.append(0)
        i=i+1
    tehon.append(1)
ss=0
cc=0
while cc<N:
    a=int(s[cc])
    b=int(tehon[cc])
    if a==b:
        ss=ss+1
    cc=cc+1
nn=N-ss
if nn<=ss:
    print(nn)
else:
    print(ss)

Measured memory_bytes: 4860
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    int(input())
    cnt=[0]*3
    for a in map(int,input().split()):
        if(a%4==0): cnt[2]+=1
        elif(a%2==0): cnt[1]+=1
        else: cnt[0]+=1
    if(cnt[1]): cnt[0]+=1
    print("Yes" if(cnt[2]>=cnt[0]-1) else "No")
resolve()

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

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

    vector<int> amari(b);
    for (int i = 1; i <= b; i++)
    {
        amari[i - 1] = a * i % b;
    }

    for (int i = 0; i < b; i++)
    {
        if (amari[i] == c)
        {
            puts("YES");
            exit(0);
        }
    }
    puts("NO");
}

Measured memory_bytes: 256
import  java.util.*;
public class Main
{
  public static void main(String[] args)
{  Scanner sc=new Scanner(System.in);
  //int s,w;
  
  int s=sc.nextInt();
  int w=sc.nextInt();
  if(w>=s)
    System.out.println("unsafe");
  else
    System.out.println("safe");
}
}

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

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

char s[55][55];
int h,w;

int main() {
    cin >> h >> w;
    rep1(i,h+1){
        rep1(j,w+1){
           cin >> s[i][j];
        }
    }

    bool ans = true;
    int dx[4] = {0, 1, 0, -1};
    int dy[4] = {1, 0, -1, 0};
    rep1(i,h+1){
        rep1(j,w+1){
            if(s[i][j] == '#'){
                bool can = false;
                rep(k,4){
                    if(s[i+dy[k]][j+dx[k]] == '#') can = true;
                }
                if(!(can)) ans = false;
            }
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int cup[3]={1,0,0};
  char trade[2];
  int tmp;
  while(scanf("%c,%c",&trade[0],&trade[1])!=EOF){
    tmp = cup[trade[0]-65];
    cup[trade[0]-65] = cup[trade[1]-65];
    cup[trade[1]-65] = tmp;
  }
  int k,ans;
  for(k=1;k<=3;k++){
    if(cup[k-1]==1){
      ans = 64 + k;
      printf("%c\n",ans);
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 544
# ABC110 A - Maximize the Formula
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
a,b,c = map(int, input().split())
ans = ''
max_s = max(a,b,c)

if max_s == a:
    ans = 10*a+b+c
elif max_s == b:
    ans = 10*b+c+a
elif max_s == c:
    ans = 10*c+a+b
print(ans)

Measured memory_bytes: 3316
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <memory.h>
#include <stdlib.h>


int main(void)
{	
	int i,n,l,r,sum=0;
	scanf("%d",&n);
	
	for(i=1;i<=n;i++){
		scanf("%d %d",&l,&r);
		sum+=r-l+1;
	}
	
	printf("%d\n",sum);
	
	return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			String input_str[] = new String[3];
			input_str = br.readLine().split("\\s+");
			int N = Integer.parseInt(input_str[0]);
			int M = Integer.parseInt(input_str[1]);
			int R = Integer.parseInt(input_str[2]);

			if(N*M > R){
				System.out.println(0);
				return;
			}

			int num = R-M*N+N-1;

			int[] bunbo = new int[N];
			for(int i = 0; i < N-1; i++){
				bunbo[i] = num-i;
			}

			int tmp,common;

			for(int i = N-1; i >= 2; i--){
				tmp = i;
				for(int k = 0; k < N-1; k++){

					if(bunbo[k] == 1)continue;

					common = gcd(tmp,bunbo[k]);
					if(common == 1)continue;

					tmp /= common;
					bunbo[k] /= common;

					if(tmp == 1)break;
				}
			}

			BigInteger ANS = new BigInteger("1");
			for(int i = 0; i < N-1; i++){
				ANS = ANS.multiply(new BigInteger(Integer.toString(bunbo[i])));
			}

			System.out.println(ANS.toString());

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	public static int gcd(int A,int B){
		if(A < B){
			int tmp = B;
			B = A;
			A = tmp;
		}
		if(B == 0){
			return A;
		}else{
			return gcd(B,A%B);
		}
	}

}




Measured memory_bytes: 42820
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007

ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}

int main(){
    ll n;cin>>n;
    cout<<n*n*3<<endl;
}


Measured memory_bytes: 256
open Printf
open Str

type node = {p : int option; cs : int list}
              
let read_list f =
  split (regexp " +") (read_line ()) |> List.map f

let string_of_list ls =
  let s = List.map string_of_int ls |> String.concat ", " in "[" ^ s ^ "]"

let int_of_parent n = match n.p with
    None -> (-1)
  | Some x -> x

let type_of_node = function
    {p = None} -> "root"
  | {cs = []} -> "leaf"
  | _ -> "internal node"

let length_of_node tr n =
  let rec iter d = function
      {p = Some x} -> iter (d+1) tr.(x)
    | _ -> d
  in iter 0 n
    
let () =
  let n = read_int () in
  let tree = Array.make n {p = None; cs = []} in
  let rec read n =
    if n = 0 then ()
    else begin
        begin
          match read_list int_of_string with
            id::_::rs -> begin
              tree.(id) <- begin let n = tree.(id) in {n with cs = rs} end;
              List.iter (fun x -> let n = tree.(x) in tree.(x) <- {n with p = Some id}) rs
            end
          | _ -> failwith "read"
        end;
        read (n-1)
      end
  in
  read n;
  Array.iteri (fun i x -> let pi = int_of_parent x in
                          let sl = string_of_list x.cs in
                          let tn = type_of_node x in
                          let ln = length_of_node tree x in
                          printf "node %d: parent = %d, depth = %d, %s, %s\n" i pi ln tn sl) tree

Measured memory_bytes: 22420
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    a,b,c,d = LI()
    while True:
        c -= b
        if c < 1:
            return "Yes"
        a -= d
        if a < 1:
            return "No"

    return -1


print(main())





Measured memory_bytes: 10996
import java.io.*;

public class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    int c500 = Integer.parseInt(br.readLine());
    int c100 = Integer.parseInt(br.readLine());
    int c50 = Integer.parseInt(br.readLine());
    int total = Integer.parseInt(br.readLine());
    
    int choice = 0;
    int left = total;
    
    for(int i = 0; i<=c500; i++){
      for(int j = 0; j<=c100; j++){
        for(int k = 0; k <= c50; k++){
          if (i * 500 + j * 100 + k * 50 == total){
            choice++;
          }else if(i * 500 + j * 100 + k *50 > total){
            break;
          }
        }
      }
    }
    System.out.println(choice);
  }
}
          


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

int main() {
	// your code goes here
	int a, b;
	cin >> a>>b;
	int s = 1;
	int ans = 0;
	while(s < b){
	    s += a - 1;
	    ans++;
	    
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pII;
#define pb push_back
#define mp make_pair
#define clr(x,y) memset(x,y,sizeof(x))
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=1e6+5;
//ll fmod(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;y>>=1;x=x*x%mod;}return res;}
//ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
set<string>p;
int main()
{
    int n;
    while(cin>>n)
    {
        p.clear();
        string s;
        string pre;
        int x1,x2;
        int have = 0;

        FOR(i,0,n)
        {
            if(!i)
            {
                cin>>pre;
                x1 = pre.size();
                p.insert(pre);
            }
            else
            {
                cin>>s;
                x2 = s.size();
                have = have|(s[0] != pre[x1-1]);
                if(p.count(s))
                  have = 1;
                //cout<<p.count(s)<<"  "<<have<<endl;
                p.insert(s);
                pre = s;
                x1 = x2;
            }
        }
        //cout<<have<<endl;
        cout<<(have?"No":"Yes")<<endl;
    }

}
















Measured memory_bytes: 256
//
//AtCoder Beginner Contest 127
//D - Integer Cards
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    priority_queue<int, vector<int>, greater<int>> pa;
    REP(i, n) {
        int a;
        cin >> a;
        pa.push(a);
    }

    vector<pair<int, int>> cb(m);
    REP(i,m) cin >> cb[i].second >> cb[i].first;
    sort(ALL(cb), greater<pair<int, int>>());

    REP(i,m){
        REP(j,cb[i].second){
            if (pa.top()<cb[i].first){
                pa.pop();
                pa.push(cb[i].first);
            }else{
                goto _END;
            }
        }
    }
_END:
    ll ans=0;
    REP(i,n){
        ans+=pa.top();
        pa.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4500
#include<stdio.h>
int main()
{
	int w, h, x, y, r;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	if((x + r <= w && x - r >= 0) && (y + r <= h && y - r >= 0)) 
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
} 


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    if(s[0] == '?'){
        if(s[1] == '?' || s[1] == 'D'){
            s[0] = 'P';
        }else{
            s[0] = 'D';
        }
    }
    for(int i = 1; i < n-1; i++){
        if(s[i] == '?'){
            if(s[i-1] == 'P'){
                s[i] = 'D';
            }else if(s[i+1] == 'D' || s[i+1] == '?'){
                s[i] = 'P';
            }else{
                s[i] = 'D';
            }
        }
    }
    if(s[n-1] == '?'){
        s[n-1] =  'D';
    }
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
using namespace std;

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  int left = 0;
  int right = 0;
  for (int i=0; i<M; i++) {
    int tmp;
    cin >> tmp;
    if (tmp < X) {
      left++;
    } else if (tmp > X) {
      right++;
    }
  }
  auto ans = min(left, right);
  std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    set<int> s;
    FOR(i, 0, 3) {
        int t;
        cin >> t;
        s.insert(t);
    }
    cout << s.size() << endl;
    return 0;
};


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<=e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
ll dp[2001];
ll go(ll s){
    if(s < 3)return 0;
    ll res = 0;
    if(dp[s] != -1)return dp[s];
    for(ll i = 3; i <= s - 3; i++){
        res += go(s - i);
        res %= MOD;
    }
    res++;
    res%=MOD;
    return dp[s] = res;
}
void solve(){
    ll s;
    cin >> s;
    fo(i, s + 1){
        dp[i] = -1;
    }
    dp[3] = 1;
    cout << go(s) << nl;
}
int main(){ 
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    //cin>>TC;
    fo(TT, TC){
        // Google,FB cout << "Case #"<< TT + 1 << ": ";
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3828
import java.io.*;
 
class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringBuilder out = new StringBuilder();
 
    public static void main(String[] args) throws IOException {
        int n = Integer.parseInt(br.readLine());
        int[] A = new int[n];
        String[] in = br.readLine().split(" ");
        for (int i=0; i<n; i++) A[i] = Integer.parseInt(in[i]);
        trace(A, n);
 
        for(int i=1; i<n; i++) {
            int key = A[i];
            int j=i-1;
            while(j>=0 && A[j]>key) {
                A[j+1] = A[j];
                j--;
            }
            A[j+1] = key;
            trace(A, n);
        }
        System.out.print(out);
    }
     
    static void trace(int A[], int n){
        for (int i=0; i<n; i++){
            if(i>0) out.append(' ');
            out.append(A[i]);
        }
        out.append('\n');
    }
}

Measured memory_bytes: 19852
#include <cstdio>
#include <algorithm>
using namespace std;
int v[100005];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&v[i]);
    sort(v+1, v+1+n);
    int t=1;
    for(;v[t]*2<v[n];t++);
    if(2*v[t]-v[n]<v[n]-2*v[t-1])
        printf("%d %d\n",v[n],v[t]);
    else
        printf("%d %d\n",v[n],v[t-1]);
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
	char name[100];
	int t;
}P;

P Q[LEN];
int head, tail,n;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail+1) % LEN;
}

P dequeue(){
	P x = Q[head];
	head = (head+1) % LEN;
	return x;
}

int min(int a,int b){return a<b ? a:b ;}


int main(void){
	
	int elaps =0, c;
	int i,q;
	P u;
	scanf("%d %d",&n, &q);
	
	for(i=1; i<=n; i++){
		scanf("%s",Q[i].name);
		scanf("%d",&Q[i].t);
	}
	
	head = 1;
	tail = n + 1;
	
	while(head != tail){
	u = dequeue();
	c = min(q, u.t);
	u.t -= c;
	elaps += c;
	if(u.t >0)enqueue(u);
		else{
			printf("%s %d\n", u.name, elaps);
		}
	}
	
	return 0;
}



Measured memory_bytes: 11836
#include<stdio.h>
int main(){
  int k[4]={0},n,i,t;
  scanf("%d",&n);
  for(i=0;i<n;i++){scanf("%d",&t);k[t%4]++;}
  printf(k[0]<k[1]+k[3]-!k[2]?"No":"Yes");
}


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

struct coor{
    pair<i64, i64> x, y;
};

int main(){
    i64 X,Y;
    cin >> X >> Y;
    vector<i64> fib(500);
    fib[0] = fib[1] = 1;
    for(int i = 2; i < 500; i++) {
        fib[i] = fib[i - 1] + fib[i - 2];
    }

    coor now = {{0, 1}, {0, 1}};
    i64 way = 0;
    i64 color = 0;
    int i = 1;
    while(i < 500){

        //cout << color << " -----" << endl;
        //cout << now.x.first << " " << now.x.second << endl;
        //cout << now.y.first << " " << now.y.second << endl;

        if(now.x.first <= X && X < now.x.second 
        && now.y.first <= Y && Y < now.y.second){
            cout << color+1 << endl;
            return 0;
        }
        
        coor next;
        if(way == 0) {
            next.x.first = now.x.second;
            next.x.second = next.x.first + fib[i];
            next.y.first = now.y.first;
            next.y.second = next.y.first + fib[i];
        }
        if(way == 1){
            next.x.second = now.x.second;
            next.x.first = next.x.second - fib[i];
            next.y.first = now.y.second;
            next.y.second = next.y.first + fib[i];
        }
        if(way == 2){
            next.x.second = now.x.first;
            next.x.first = next.x.second - fib[i];
            next.y.second = now.y.second;
            next.y.first = now.y.second - fib[i]; 
        }
        if(way == 3){
            next.x.first = now.x.first;
            next.x.second = next.x.first + fib[i];
            next.y.second = now.y.first;
            next.y.first = next.y.second - fib[i];
        }

        now = next;
        i++, way++, color++;
        way %= 4;
        color %= 3;
    }

    cout << 0 << endl;
}


Measured memory_bytes: 3116
def main():
    for i in range(n):
        b, f, r, v = map(int, raw_input().split())
        x[b-1][f-1][r-1] += v
    for b in range(4):
        for f in range(3):
            print(' ' + ' '.join(map(str,x[b][f])))
        if b != 3:
            print('#'*20)
n = input()
x = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
main()

Measured memory_bytes: 6456
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {



    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
            String s=sc.next();
            if(s.equals("ABC"))
            {
                System.out.println("ARC");
            }else
            {
                System.out.println("ABC");
            }




    }


}

Measured memory_bytes: 35608
#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 sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 200005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((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);
	
	string s,t;
	cin>>s>>t;
	ll i,j,k,an=0,n=s.length();
	for(i=0;i<n;i++){
		if(s[i]!=t[i]){
			an++;
		}
	}
	cout<<an<<endl;
	return 0;	
}

Measured memory_bytes: 3768
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  for (int i = 0; i < n; ++i) cin >> p[i];
  for (int i = 0; i < n; ++i) cin >> q[i];
  vector<int> order(n);
  for (int i = 0; i < n; ++i) order[i] = i + 1;
  int a = 0, b = 0;
  int t = 0;
  do {
    t++;
    if (p == order) a = t;
  } while (next_permutation(order.begin(), order.end()));
  t = 0;
  do {
    t++;
    if (q == order) b = t;
  } while (next_permutation(order.begin(), order.end()));
  cout << abs(a - b) << endl;
  return 0;
}

Measured memory_bytes: 256
fn main() {
  let n: usize = read();
  let ps: Vec<usize> = read_vec();
  
  let mut seqa: Vec<usize> = vec![];
  let mut seqb: Vec<usize> = vec![];
  let step = 20000;
  
  for d in 0 .. n {
    seqa.push(step * d + ps.iter().position(|&p|p==d+1).unwrap() + 1);
    seqb.push(step * (n - d));
  }
  
  print_vec(&seqa, " ");
  print_vec(&seqb, " ");
}

fn print_vec<T: std::string::ToString>(vec: &Vec<T>, sep: &str) {
  let out = vec.iter().map(|e| e.to_string()).collect::<Vec<_>>().as_slice().join(sep);
  println!("{}", out);
}

fn read<T: std::str::FromStr>() -> T {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().parse::<T>().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
}


Measured memory_bytes: 6780
import java.util.Scanner;

/**
 * Created by sonetsuyoshi on 2016/07/31.
 */
public class Main {

    static public void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();

        int ans;
        if(k < n) {
            ans = k * x + (n - k) * y;
        }
        else {
            ans = n * x;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 10064
h, w = map(int, input().split())
map = []
ansList = [[0] * w for i in range(h)]
#print(list(input()))
for x in range(h):
    a = list(input())
    map.append(a)

prev = ""
for y in range(h):
    for x in range(w):
        if y == 0 and x == 0: 
            val = 0
            prev = ""
        elif y == 0 or (x > 0 and ansList[y - 1][x] > ansList[y][x - 1]):
            val = ansList[y][x - 1]
            prev = map[y][x - 1]
        elif x == 0 or (y > 0 and ansList[y - 1][x] < ansList[y][x - 1]):
            val = ansList[y - 1][x]
            prev = map[y - 1][x]
        if x > 0 and y > 0 and ansList[y - 1][x] == ansList[y][x - 1] and (map[y - 1][x] != map[y][x - 1]):
            val = ansList[y - 1][x]
            prev = "#"
        elif x > 0 and y > 0 and ansList[y - 1][x] == ansList[y][x - 1] and (map[y - 1][x] == map[y][x - 1]):
            val = ansList[y - 1][x]
            prev = map[y - 1][x]

        if map[y][x] == "#" and prev != "#": ansList[y][x] = val + 1
        elif map[y][x] == "#" and prev == "#": ansList[y][x] = val
        else: ansList[y][x] = val
print(ansList[h - 1][w - 1])

Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
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; }
//#define int long long

//2つのものに紐づく量についての集計の、集計順序を変更してみる感じ

void solve() {
	int n; cin >> n;
    vector<double> x(n), y(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
    }
    double ans = 0;
    rep(i, n) {
        for(int j = i + 1; j < n; ++j) {
            ans += sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
        }
    }
    cout << ans / (n * (n - 1) / 2) * (n - 1) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int ans = 0;
        int[] X = new int[N];
        for(int i=0;i<N;i++){
            X[i]=sc.nextInt();
            ans+=Math.min(X[i],K-X[i])*2;
        }
        System.out.println(ans);
    }

    public static void main(String[] args) {
        new Main();
    }
}


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


int main() {
    int N;

    cin >> N;

    int a[100002];
    bool hist[100002];
    int count=0;

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

    int curbtn = 1;

    while(!hist[curbtn-1]){
        hist[curbtn-1]=true;
        curbtn = a[curbtn-1];
        count++;
        if(curbtn==2){
            cout << count << endl; 
            return 0;
        }
    }

    cout << -1 << endl;





}



Measured memory_bytes: 768
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef ONLINE_JUDGE
const int N = 1e6+50;
#else
const int N = 1e2+10;
#endif


ll x, y;
int dp[N][N];
int dfs(int x, int y) {
	int &ans = dp[x][y];
	if (~ans) return ans;
	REP(i,1,x/2) if (!dfs(x-2*i,y+i)) return 1;
	REP(i,1,y/2) if (!dfs(x+i,y-2*i)) return 1;
	return 0;
}
int main() {
	cin>>x>>y;
	puts(abs(x-y)<=1?"Brown":"Alice");
}








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

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

	int ans = 0;
	if (a > b) {
		ans += a;
		a--;
	}
	else {
		ans += b;
		b--;
	}
	
	ans += max(a, b);
	cout << ans << endl;

}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var T = Console.ReadLine();

            var upperDict = new Dictionary<char, int>();
            var lowerDict = new Dictionary<char, int>();

            for (var i = 0; i < S.Length; i++)
            {
                if (!Check(S, T, upperDict, i)) return;
                if (!Check(T, S, lowerDict, i)) return;
            }

            Console.WriteLine("Yes");
        }

        static bool Check(string key, string val, Dictionary<char, int> d1, int i)
        {
            if (d1.ContainsKey(key[i]))
            {
                if (val[d1[key[i]]] != val[i])
                {
                    Console.WriteLine("No");
                    return false; ;
                }
            }
            else
                d1[key[i]] = i;

            return true;
        }
    }
}


Measured memory_bytes: 14688
#include<stdio.h>
#include<math.h>
int main()
{
    long long int a,b,c,i,d,f,sum;
    scanf("%lld\n",&a);
    c=a+1;
    f=sqrt(a);
    for(i=f; i>=1; i--)
    {
        if(a%i==0)
        {
            d=a/i;
            b=d+i;

            if(b<=c)
            {
                c=b;
                sum=c-2;
            }
        }
    }
    printf("%lld\n",sum);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
typedef long long ll;

using namespace std;

int main()
{
    int r, g;
    cin >> r >> g;
    cout << (g*2-r) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)

int main() {
	char s[27];
	int i,j,l,count[26]={0};
	scanf("%s",s);
	l=strlen(s);
	if(l<26){
		rep(i,l)count[s[i]-'a']=1;
		for(i=0;count[i]==1;i++){/*何もしない*/};
		s[l]='a'+i;
		s[l+1]='\0';
		printf("%s",s);
		return 0;
	}else{
		for(i=l-1;i>=0;i--){
			count[s[i]-'a']=1;
			for(j=s[i]-'a'+1;j<26&&count[j]==0;j++);
			if(j<26){
				s[i]='a'+j;
				s[i+1]='\0';
				printf("%s",s);
				return 0;
	}}}
	printf("-1");
}

Measured memory_bytes: 128
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O30")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << (x) << "\n")
using ll = long long; using ld = long double; using namespace std;

#ifndef __GNUC__
string text =
R"X(
6
3 14 159 2 6 53
58 9 79 323 84 6
2643 383 2 79 50 288
)X";
stringstream iss{text};
#endif 

class Festival
{
	ll N{0};
	vector<vector<ll>> A;
	void inp( ) {
		iss >> N; A.resize(3, vector<ll>(N));
		for (auto &abc : A) {
			for (auto &a : abc)  iss >> a;
		}		
		sort(begin(A[0]), end(A[0]));
		sort(begin(A[2]), end(A[2]));
	}
	void biSearch( ) {
		ll cnt{0};
		for (auto &b : A[1]) {
			cnt += (end(A[2]) - upper_bound(begin(A[2]), end(A[2]), b))
				* (lower_bound(begin(A[0]), end(A[0]), b) - begin(A[0]));
		}
		p(cnt);
	}
public:
	void procedures( ) {
		inp( );	biSearch( );
	}
};
int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	class Festival a; a.procedures( );
}

Measured memory_bytes: 6360
#include <bits/stdc++.h>
#define ll long long int
#define Mod 1000000007

using namespace std;

void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int main(){
	fastio();
	ll n;
	cin>>n;
	vector<pair<ll,ll> >v;
	for(ll i=1;i<=n;i++){
		ll x;
		cin>>x;
		v.push_back({x,i});
	}
	sort(v.begin(),v.end());
	for(ll i=0;i<v.size();i++)cout<<v[i].second<<" ";
	
}

Measured memory_bytes: 2544
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using namespace std;

vector<int> field(10*10);
int way[4] = { -1,1,-10,10 };

inline int xy2pos(int x, int y) {
	return x + y * 10;
}

void solve(int firstpos) {
	queue<int> bomb;
	bomb.push(firstpos);
	while (!bomb.empty()) {
		int kaboom = bomb.front(); bomb.pop();
		field[kaboom] = 0;
		for (int i = 0; i < 4; i++) {
			for (int n = 1; n <= 3; n++) {
				int pos = kaboom + n * way[i];
				if (field[pos] == -1) break;
				if (field[pos] == 1) 
					bomb.push(pos);
			}
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		fill(field.begin(), field.end(), -1);
		for (int y = 1; y <= 8; y++) 
			for (int x = 1; x <= 8; x++) {
				char c;
				cin >> c;
				field[xy2pos(x, y)] = c - '0';
			}
		int x, y;
		cin >> x >> y;
		solve(xy2pos(x,y));
		cout << "Data " << i + 1 << ":" << endl;
		for (int y = 1; y <= 8; y++) {
			for (int x = 1; x <= 8; x++)
				cout << field[xy2pos(x, y)];
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1228