akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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

    //偶数抜き出す
    vector<int> even;
    even.reserve(n);
    rep(i,n) if(a[i]%2 == 0) even.push_back(a[i]);

    //3または5で割り切れるかを見る
    for(int data : even)
    {
        if(data%3 != 0 && data%5 != 0)
        {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;

}

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

int N, K;

int main() {
    cin >> N >> K;
    
    if (K == 0) {
        cout << 1ll * N * N << endl;
        return 0;
    }
    
    long long ans = 0;
    for (int b = K + 1; b <= N; b++) {
        int q = N / b;
        if (K == 0) q--;
        ans += (b - K) * q + max(0, N % b - K + 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
/*cout<<setprecision(11)<<ret<<endl;で、数字部分を計11桁表示かつゼロ埋め無*/
/*cout<<fixed<<setprecision(11)<<ret<<endlで、小数部のみ11桁表示かつゼロ埋め有*/
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//Shift+Command+bでデバッグ
//その後ターミナルで./a.outを実行
//入力を貼り付ける

//////////////////
//  A
/*int main(void){
    int x;cin>>x;
    int a=-1;
    rep(i,4){
        int tmp=x%10;
        if(a==tmp){
            cout<<"Bad"<<endl;
            return 0;
        }else{
            a=tmp;
            x/=10;
        }
    }
    cout<<"Good"<<endl;

    return 0;
}*/
//////////////////
//  B
int main(void){
    int n,l;cin>>n>>l;
    int Left=l,Right=l+n-1;

    int eat;
    if(Left>=0)eat=Left;
    else if(0>=Right)eat=Right;
    else eat=0;

    int sum=n*(l-1) + n*(n+1)/2;//tigau

    cout<<(sum-eat)<<endl;
    return 0;
}
//////////////////
//  C
/*int main(void){
    double w,h,x,y;cin>>w>>h>>x>>y;
    bool ret=(2*x==w)&&(2*y==h);
    cout<<(double)((w*h)/2.0)<<" "<<ret<<endl;
    return 0;
}*/
//////////////////
//  D　いけそう感がある。しゃくとり法
/*int main(void){

    return 0;
}*/
//////////////////
//  E
/*int main(void){

    return 0;
}*/
//////////////////
//  F
/*int main(void){

    return 0;
}*/


Measured memory_bytes: 3608
class UnionFindVerSize():
    def __init__(self,init):
        """ N個のノードのUnion-Find木を作成する """
        # 親の番号を格納する。自分が親だった場合は、自分の番号になり、それがそのグループの番号になる
        self._parent = [n for n in range(0, len(init))]
        # グループのサイズ（個数）
        self._size = [1] * len(init)
        self._dict ={key:0 for key in init}
        for i in range(len(init)):
            v=init[i]
            self._dict[v]=i

    def find_root(self, x,key):
        """ xの木の根(xがどのグループか)を求める """
        if key==1:
            x=self._dict[x]
        if self._parent[x] == x: return x
        self._parent[x] = self.find_root(self._parent[x],0) # 縮約
        return self._parent[x]

    def unite(self, x, y):
        """ xとyの属するグループを併合する """
        x=self._dict[x]
        y=self._dict[y]
        gx = self.find_root(x,0)
        gy = self.find_root(y,0)
        if gx == gy: return

        # 小さい方を大きい方に併合させる（木の偏りが減るので）
        if self._size[gx] < self._size[gy]:
            self._parent[gx] = gy
            self._size[gy] += self._size[gx]
        else:
            self._parent[gy] = gx
            self._size[gx] += self._size[gy]

    def get_size(self, x):
        x=self._dict[x]
        """ xが属するグループのサイズ（個数）を返す """
        return self._size[self.find_root(x,0)]

    def is_same_group(self, x, y):
        x=self._dict[x]
        y=self._dict[y]
        """ xとyが同じ集合に属するか否か """
        return self.find_root(x,0) == self.find_root(y,0)

    def calc_group_num(self):
        """ グループ数を計算して返す """
        N = len(self._parent)
        ans = 0
        for i in range(N):
            if self.find_root(i,0) == i:
                ans += 1
        return ans

import sys

input=sys.stdin.readline

N,M=map(int,input().split())
company={}
cedge={}
node=N
edge={i:[] for i in range(N)}
for i in range(M):
    u,v,c=map(int,input().split())
    edge[u-1].append((v-1,1))
    edge[v-1].append((u-1,1))
    if c-1 not in company:
        company[c-1]=[]
        cedge[c-1]=[]
    company[c-1].append(u-1)
    company[c-1].append(v-1)
    cedge[c-1].append((u-1,v-1))

for i in company:
    uf=UnionFindVerSize(company[i])
    for u,v in cedge[i]:
        uf.unite(u,v)
    data={}
    for v in company[i]:
        p=uf.find_root(v,1)
        if p not in data:
            data[p]=[]
        data[p].append(v)
    for p in data:
        edge[node]=[]
        for v in data[p]:
            edge[v].append((node,0))
            edge[node].append((v,1))
        node+=1

from collections import deque
dist=[10**20]*node
dist[0]=0
que=deque([(0,0)])
while que:
    v,d=que.popleft()
    for nv,c in edge[v]:
        if dist[nv]>d+c:
            if c==1:
                dist[nv]=d+c
                que.append((nv,d+c))
            else:
                dist[nv]=d+c
                que.appendleft((nv,d+c))


ans=dist[N-1]
print(ans if ans!=10**20 else -1)

Measured memory_bytes: 192516
def func_odd(n):
    return int(3 * n + 1)


def func_even(n):
    return int(n / 2)


def is_finished(array):
    before_len = len(array)
    after_len = len(list(set(array)))
    return before_len != after_len


def main(s):
    array = [s]
    index = 0
    while True:
        if array[index] % 2 == 0:
            array.append(func_even(array[index]))
        else:
            array.append(func_odd(array[index]))
        if is_finished(array):
            break
        index += 1
    print(index + 2)


if __name__ == '__main__':
    main(int(input()))


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

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

    int m = max( b - (a + w), a - (b + w) );
    int ans = max(m, 0);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    vec<int> S(M),C(M);
    for(int i=0;i<M;i++) cin >> S[i] >> C[i];

    int inf = 1e9;
    int ans = inf;
    auto dfs = [&](auto&& self,int a,int len){
        if(len==N){
            string T = to_string(a);
            bool ok = true;
            for(int i=0;i<M;i++){
                ok &= C[i]==(T[S[i]-1]-'0');
            }
            if(ok) ans = min(ans,a);
            return ;
        }
        if(a) for(int i=0;i<10;i++) self(self,10*a+i,len+1);
    };
    for(int i=0;i<10;i++) dfs(dfs,i,1);
    cout << (ans!=inf? ans:-1) << "\n";
}

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

#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define urng(i, a, b) for(int i = int(b) - 1; i >= int(a); i--)
#define urep(i, b) urng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
  int n, a, b, c, ans = 0;
  //string s;
  cin >> a >> b >> c;
  //vector<int> v(n), c(n);
  if(a == b && a != c || a == c && a != b || b == c && a != b) cout << "Yes" << endl;
  else cout << "No" << endl;
  //((a == b)? "Yes" : "No")
  //for(int i = 0; i < n; i++){}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FI          freopen("input.txt", "r", stdin)
#define FO          freopen("output.txt", "w", stdout)
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1e5 + 5;
const ll mod = 1e8 + 7;
const double E = 1e-9;
//int dx[] = {0, -1}, dy[] = {-1, 0};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
void solve(){
    int n;
    cin >> n;
    cout << (n == 0 ? 1 : 0) << '\n';
}  
int main(){
    FIN;
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        solve(); 
    }
    //EjecuteTime;
    return 0;
}  

Measured memory_bytes: 3636
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		
		// 計算
		String result = "ABC";
		if(n >= 1000) result = "ABD";
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  map<int, int> card;
  rep(i, N) { int A; cin >> A; card[A]++; }

  int result = card.size();
  if (result%2==0) result--;

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int q = Integer.parseInt(br.readLine());
      String[] s = new String[q+q];
      Arrays.fill(s, "");
      List<String> list  = Arrays.asList(s);
      int head = q;
      int tail = q;

      String[] query;
      int op;
      for ( int i=0; i<q; i++ ){
        query = br.readLine().split(" ");
        op  = Integer.parseInt(query[0]);

        switch( op ) {
          case 0 :
            if ( Integer.parseInt(query[1]) == 0 )
              list.set(head--,query[2]);
            else
              list.set(++tail,query[2]);
            break;
          case 1 :
            System.out.println( list.get(head+1 + Integer.parseInt(query[1])) );
            break;
          case 2 :
            if ( Integer.parseInt(query[1]) == 0 )
              head++; // list.set(head++,"");
            else
              tail--; // list.set(tail--,"");
            break;
          default:
        }
      }
    }
  }
}


Measured memory_bytes: 124504
def c_factors_of_factorial(N):
    import math

    def prime_decomposition(n):
        # nを素因数分解
        from collections import defaultdict
        i = 2
        table = defaultdict(int)
        while i**2 <= n:
            while n % i == 0:
                n //= i
                table[i] += 1
            i += 1
        if n > 1:
            table[n] += 1
        return table

    exp_list = prime_decomposition(math.factorial(N))
    ans = 1
    for v in exp_list.values():
        ans = (ans * (v + 1)) % (10**9 + 7)
    return ans

N = int(input())
print(c_factors_of_factorial(N))

Measured memory_bytes: 3316
h, w = map(int, input().split())

s = [input() for i in range(h)]

init = lambda :[[0] * (w+2) for i in range(h+2)]
r, l, u, d = init(), init(), init(), init()

for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i-1][j-1] == ".":
            l[i][j] = l[i][j-1] + 1
            u[i][j] = u[i-1][j] + 1
        else:
            l[i][j] = 0
            u[i][j] = 0

for i in range(h, 0, -1):
    for j in range(w, 0, -1):
        if s[i-1][j-1] == ".":
            r[i][j] = r[i][j+1] + 1
            d[i][j] = d[i+1][j] + 1
        else:
            r[i][j] = 0
            d[i][j] = 0

ans = 0
for i in range(1, h + 1):
    for j in range(1, w + 1):
        ans = max(ans, r[i][j] + l[i][j] + u[i][j] + d[i][j])

print(ans-3)

Measured memory_bytes: 183896
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

#define YES "Yes"
#define NO "No"

int res[200000];

int main(int argc, char **argv) {
	int n, x;
	cin >> n >> x;
	if (x == 1 || x == 2 * n - 1) {
		cout << NO << endl;
		return 0;
	}
	cout << YES << endl;
	REP(i, 2 * n - 1) res[i] = i + 1;
	if (n == 3) {
		if (x == 2) {
			res[0] = 3;
			res[1] = 5;
			res[2] = 2;
			res[3] = 1;
			res[4] = 4;
		}
		else if (x == 4) {
			res[0] = 3;
			res[1] = 1;
			res[2] = 4;
			res[3] = 5;
			res[4] = 2;
		}
	}
	else if (n != 2) {
		if (x == 2) {
			swap(res[n - 2], res[2 * n - 2]);
			swap(res[n - 1], res[x - 1]);
			swap(res[n], res[0]);
			swap(res[n + 1], res[2 * n - 3]);
		}
		else {
			swap(res[n - 2], res[0]);
			swap(res[n - 1], res[x - 1]);
			swap(res[n], res[2 * n - 2]);
			swap(res[n + 1], res[1]);
		}
	}
	REP(i, 2 * n - 1) cout << res[i] << endl;
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll gcd(ll a,ll b) {
    while(b != 0) {
        ll rem = a % b;
        a = b;
        b = rem;
    }
    return(a);
}
int main() {
    ll a,b;
    cin >> a >> b;
    ll gc = __gcd(a,b);
    vector<ll> num;
    for (int i = 1;i <= sqrt(gc);i++) {
        if (gc % i == 0) {
            if (i == gc / i) {
                num.push_back(i);
            } else {
                num.push_back(gc / i);
                num.push_back(i);
            }
        }
    }
    sort(num.begin(),num.end(),greater<ll>());
    ll i = 0;
    ll flag = 0;
    while(i < num.size()) {
        ll j = i + 1;
        while(j < num.size()) {
            if (gcd(num[i],num[j]) != 1) {
                num.erase(num.begin() + i);
                flag = 1;
            }
            j++;
        }
        i++;
        if (flag == 1) {
            flag = 0;
            i--;
        }
    }
    cout << num.size() << "\n";
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;
int main() {
  string s;
  cin >> s;
  for (int i = 0; i <= 7; i++) {
	  if (s.substr(0, i) + s.substr(s.length() - 7 + i) == "keyence") {
		  cout << "YES" << endl;
		  return 0;
		}
	}
  cout << "NO" << endl;
  return 0;
}


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

int main() {
    long long a, b, c, d;
    cin >> a >> b >> c;
  
  	d = c-a-b;

    if (4*a*b < d*d) {
        if (d > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 256
/*****************************
 Filename: kljlddf.cpp
 Author: hbb
 Create: 2020-04-06 14:54:41
*****************************/
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
const int inf = INT_MAX >> 1;
typedef long long int LL;

int x, y, a, b, c;
int p[maxn], q[maxn], r[maxn];
priority_queue<int, vector<int>, greater<int> > que;

bool cmp(int a, int b){
	return a > b;
}

int main(){
	scanf("%d %d %d %d %d", &x, &y, &a, &b, &c);
	for(int i = 1; i <= a; i++) scanf("%d", &p[i]);
	for(int i = 1; i <= b; i++) scanf("%d", &q[i]);
	for(int i = 1; i <= c; i++) scanf("%d", &r[i]);
	sort(p + 1, p + 1 + a, cmp);
	sort(q + 1, q + 1 + b, cmp);
	sort(r + 1, r + 1 + c, cmp);
	while(que.size()) que.pop();
	for(int i = 1; i <= x; i++){
		que.push(p[i]);
	}
	for(int i = 1; i <= y; i++){
		que.push(q[i]);
	}
	for(int i = 1; i <= c; i++){
		que.push(r[i]);
	}
	while(que.size() > x + y){
		que.pop();
	}
	LL ans = 0;
	while(que.size()){
		ans += que.top();
		que.pop();
	}
	printf("%lld\n", ans);
}

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

int main() {
	int n,a,b,c,ans,temp;
	
	cin >> n >> a;
	
	if( a <= n){
	    cout <<10;
	}else{
	    cout << 0;
	}
	
	//cout <<  ;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define LEN 10001

using namespace std;

int main(void){
	int N;
    int count;
    bool prime[LEN] = {0};
    prime[0] = 1;
    prime[1] = 1;
    for(int i = 2; i*i < LEN; i++){
        if (!prime[i]) {
            for(int j = i*2; j < LEN; j += i){
                prime[j] = 1;
            }
        }
    }
    while(cin >> N){
        count = 0;
        for(int i = 1; i <= N; i++){
            if((!prime[i]) && (!prime[N-i+1])) count++;
        }
        cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#include<stack>
using namespace std;
int main()
{
	char s[200010];
	scanf("%s",&s);
	int x=strlen(s);
	stack<int> a;
	for(int i=0;i<x;i++)
	{
		if(a.empty())
		{
			if(s[i]=='S')
			a.push(0);
			else
			a.push(1);
			continue;
		}
		if(a.top()==0&&s[i]=='T')
		a.pop();
		else{
			if(s[i]=='S')
			a.push(0);
			else
			a.push(1);
		}
		
	}
	cout << a.size() << endl;
}


Measured memory_bytes: 4580
#include<bits/stdc++.h>
#define int long long
#define all(x) x.begin(),x.end()
using namespace std;
#define mod 1000000007
const int maxn=1000000;
int wt[10005];
int val[10005];
int n, w;
int dp[105][1000005];
int ks(int v,int in) {
    if (in == 0) {
        if (v == 0) return 0;
        else return INT_MAX;
    }
    if(dp[in][v]!=-1) return dp[in][v];
    int a = ks(v, in - 1);
    int b = wt[in - 1] + ks(v - val[in - 1], in - 1);
    dp[in][v]=min(a, b);
    return min(a,b);
}
int res(int totVal) {
    for (int i = totVal; i >= 0; --i) {
        if (ks(i, n) <= w) {
            return i;
        }
    }
    return 0;
}
void solve() {
    cin >> n >> w;
    memset(dp,-1, sizeof(dp));
    int totVal = 0;
    for (int i = 0; i < n; ++i) {
        cin >> wt[i] >> val[i];
        totVal += val[i];
    }
    cout << res(totVal);
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}

Measured memory_bytes: 823816
class Integer
  def prime?
    return true if self == 2

    return false if self < 2 || (self % 2).zero?

    sqrt = Math.sqrt(self)
    3.step(sqrt, 2) do |i|
      return false if (self % i).zero?
    end

    true
  end
end

answer = 0
count = gets.chomp.to_i
count.times do
  n = gets.chomp.to_i
  answer += 1 if n.prime?
end

puts answer



Measured memory_bytes: 6896
#include<stdio.h>
int main(void)
{
	char s;

	scanf("%c", &s);

	switch (s) {
	case 'A':
		printf("T");
		break;

	case 'C':
		printf("G");
		break;

	case 'G':
		printf("C");
		break;

	case 'T':
		printf("A");
		break;

	default:
		break;
	}

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String words[] = new String[n];
        String result = "Yes";
        for(int i = 0; i < n; i++){
            words[i] = sc.next();
            for(int j = 0; j < i - 1; j++){
                if(words[j].equals(words[i])){
                    result = "No";
                }
            }
        }
        char firstEnd = words[0].charAt(words[0].length() - 1);
        for(int i = 1; i < n; i++){
            if(firstEnd != words[i].charAt(0)){
                result = "No";
            }
            firstEnd = words[i].charAt(words[i].length() - 1);
        }
    
        System.out.println(result);
    }
}


Measured memory_bytes: 23124
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
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 DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
def dump(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    N, A, B = map(int, input().split())
    S = input()

    c = 0
    o = 0
    for n in range(N):
        i = S[n]
        if (i=='a'):
            if c < A+B:
                print("Yes")
                c += 1
            else:
                print("No")
        elif (i=='b'):
            o += 1
            if c < A+B and o<=B:
                print("Yes")
                c += 1
            else:
                print("No")
        else:
            print("No")
    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
    except:
        pass
    solve()
# vim: set foldmethod=marker:}}}


Measured memory_bytes: 7592
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	resolve()
}

func resolve() {
	n, m := scanInt(sc), scanInt(sc)
	ok := 0
	acs := make([]bool, n)
	penas := make([]int, n)
	pena := 0
	for _ = range loop0(m) {
		p := scanInt(sc) - 1
		ans := scanString(sc)
		if acs[p] {
			continue
		}
		if ans == "AC" {
			ok++
			acs[p] = true
			pena += penas[p]
		} else {
			penas[p]++
		}
	}
	fmt.Printf("%d %d\n", ok, pena)
}

func loop0(n int) chan int {
	return loop(0, n-1, 1)
}

func loop1(n int) chan int {
	return loop(1, n, 1)
}

func loop(s, e, d int) chan int {
	ch := make(chan int)
	go func() {
		for i := s; i <= e; i += d {
			ch <- i
		}
		close(ch)
	}()
	return ch
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 3344
// https://atcoder.jp/contests/abc124/tasks/abc124_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

// Run length encoding
vector<pair<char, int>> encode(string code) {
    vector<pair<char, int>> ret;
    const int len = code.length();
    for (int i = 0; i < len; i++) {
        int count = 1;
        while (code[i] == code[i + 1] && i < len - 1) {
            count++;
            i++;
        }
        ret.emplace_back(code[i], count);
    }
    return ret;
}

void solve() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    auto v = encode(S);
    int ans = 0, sum = 0, r = 0, l = 0, sz = v.size();
    while (r < sz) {
        if (r < sz && v[r].first == '1') {
            sum += v[r++].second;
        }
        ans = max(ans, sum);
        if (r < sz && v[r].first == '0') {
            sum += v[r++].second;
        }
        K--;
        if (K < 0) {
            if (l < sz && v[l].first == '1') {
                sum -= v[l++].second;
            }
            if (l < sz && v[l].first == '0') {
                sum -= v[l++].second;
            }
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 5520
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.length()-2;i++){
    	int x=(s[i]-48)*100+(s[i+1]-48)*10+(s[i+2]-48);
    	if(abs(753-x)<abs(753-ans)){
    		ans=x;
		}
	}
	cout<<abs(753-ans)<<"\n";
    return 0;
}


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

public class Main {
    public static void main(String[] args) throws Exception {
	
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        OutputStream outputStream = System.out;
    	PrintWriter out = new PrintWriter(outputStream);

        int i, n, m, c, k;

		int t = Integer.parseInt(br.readLine());    
        String str = br.readLine();
	
      	if(t<3200)
          	System.out.print("red");
     	else
          	System.out.print(str);
          	
	out.flush();
	out.close();
	
	}
}

Measured memory_bytes: 21332
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Integer> map = new HashMap<>();
    boolean flag = true;
    String s = sc.next();
    map.put(s, 1);
    char s_last = s.charAt(s.length() - 1);
    for (int i = 1; i < n; i++) {
      s = sc.next();
      char s_first = s.charAt(0);
      if (map.containsKey(s)) {
        flag = false;
      }
      if (s_last != s_first) {
        flag = false;
      }
      map.put(s, 1);
      s_last = s.charAt(s.length() - 1);
    }
    if (flag) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 25172
n = STDIN.gets.chomp.to_i
k = STDIN.gets.chomp.to_i
xn = STDIN.gets.chomp.split(" ").map(&:to_i)

distance = 0

xn.each do |xi|
  if xi < k - xi
    distance += 2 * xi
  else
    distance += 2 * (k - xi)
  end
end

puts distance


Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <algorithm>
#include <string>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, a, b) for(int i = a; i < b; i++)

int main() {
    int N;
    cin >> N;
    vector<vector<int>> jobs(N);
    rep(i, N) {
        vector<int> job(2);
        cin >> job[0];
        cin >> job[1];
        jobs[i] = job;
    }

    sort(jobs.begin(), jobs.end(), [](vector<int> a, vector<int> b) {
        return a[1] < b[1];
    });

    int sum_time = 0;

    rep(i, N) {
        sum_time += jobs.at(i).at(0);
        if (sum_time > jobs.at(i).at(1)) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 11136
n = gets.strip.to_i
a = gets.strip.split.map(&:to_i)
b = gets.strip.split.map(&:to_i)
c = gets.strip.split.map(&:to_i)

s = 0
before = -1

a.each do |i|
  s += b[i - 1]
  s += c[before - 1] if i == before.succ
  before = i
end

puts s

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

int main(void){
    
    int H,W;
    cin >> H >> W;
    
    string S[H];
    
    for(int i = 0; i < H;i++)cin >> S[i];
    
    //cout << S[0][0]<<endl;
    int F[H][W];
    int cont = 0;
    for(int i = 0; i < H;i++){
        for(int j = 0; j < W;j++){
            F[i][j]=0;
            if(S[i][j]=='#')cont++;
        }
    }
    
    stack<pair<int,int>> que;
    que.push(make_pair(0,0));
    F[0][0]=1;
    int h,w;
    
    
    int contf = 0;
    while(que.size()){
        
        h = que.top().first;
        w = que.top().second;
        que.pop();
        
        contf = F[h][w];
        
        if(h+1<H){
            if(S[h+1][w]=='#'){
                que.push(make_pair(h+1,w));
                F[h+1][w] = contf + 1;
            }
        }
        
        if(w+1<W){
            if(S[h][w+1]=='#'){
                que.push(make_pair(h,w+1));
                F[h][w+1] = contf + 1;
            }
        }
        
        
        if(F[h][w]==cont){
            
            cout << "Possible"<<endl;
            return 0;
        }
        
        
    }

    cout << "Impossible"<<endl;
    return 0;
    
}


Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N, K;
    cin >> N >> K;
    if(K == 1) cout << 0 << endl;
    else cout << N - K << endl;
    return 0;
}


Measured memory_bytes: 256
A, B, K = map(int, input().split())
printed = set()
for i in range(K):
    if(A + i <= B):
        print(A + i)
        printed.add(A + i)
for i in range(K):
    if B - K + 1 + i >= A and B - K + 1 + i not in printed:
        print(B - K + 1 + i)

Measured memory_bytes: 3060
s=input()
if len(s)%2!=0:

    print("No")
else:
    bool=False
    for i in range(len(s)):
        if i%2==0:
            if s[i]!="h":

                print("No")
                bool=True
                break
        else:
            if s[i]!="i":
                print("No")

                bool=True
                break
    if bool is False:
        print("Yes")


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

using ll = long long;

int main() {
    string s; cin >> s;
    const int n = s.size();
    ll ans = 0, last = -1;
    for(int i = 0; i < n; ++i) {
        if(s[i] == 'B' && last == -1) {
            last = i;
        } else if(s[i] == 'W') {
            if(last != -1) {
                ans += i - last;
                last += 1;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
import scipy.sparse.csgraph as c,numpy
_,*s=open(0)
s=numpy.int32([list(t[:-1])for t in s])
m=c.floyd_warshall(s)
i=m[0]%2<1
j=i^True
print((s[i][:,i].any()|s[j][:,j].any()or~int(m.max()))*-1)

Measured memory_bytes: 14652
n = int(input())
p = list(map(int, input().split()))
#n = 9
#p = [9, 6, 3, 2, 5, 8, 7, 4, 1]

collect = 0
for i in range(n - 2):
    p_small = p[i: i + 3]
    #print(p_small, (p_small[0] < p_small[1] and p_small[2] >= p_small[1]) or (p_small[2] < p_small[1] and p_small[0] >= p_small[1]))
    
    if (p_small[0] < p_small[1] and p_small[2] >= p_small[1]) or (p_small[2] < p_small[1] and p_small[0] >= p_small[1]):
        collect += 1
        
print(collect)

Measured memory_bytes: 3060
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num){
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; 
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2){
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n-1) + f(n-2);
}

int main() {
	ll N, M; cin >> N >> M;
	vector<ll> x(M), y(M); rep(i, M)cin >> x[i] >> y[i];

	map<int, int> cnt;
	map<int, int> red;//赤い球がある可能性があるなら１
	for (int i = 1; i <= N; i++) cnt[i] = 1;//球の数
	red[1] = 1;

	rep(i, M) {
		if (red[x[i]]) red[y[i]] = 1;
		cnt[x[i]]--;
		cnt[y[i]]++;
		if (cnt[x[i]] == 0)red[x[i]] = 0;
	}

	ll ans = 0;
	auto begin = red.begin(), end = red.end();
	for (auto it = begin; it != end; it++) {
		if (it->second == 1) ans++;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 18944
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

string YorN(bool P) { if (P)return "YES"; else return "NO"; }

int main() {
    int N;
    cin >> N;
    set<int>ans;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (ans.find(a) == ans.end())ans.insert(a);
        else ans.erase(a);
    }

    cout << ans.size() << endl;

    return 0;

}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define rrep1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int main() {
    ll s; cin >> s;
    
    ll mod = 1e9;
    ll x = (mod - s % mod) % mod;
    ll y = (s + x) / mod;
    cout << "0 0 1000000000 1 " << x << " " << y << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,m) = get!(usize, usize);
    let ab = get!(usize, usize; m);

    let mut nodes = vec![Vec::new(); n+1];
    for (a,b) in ab {
        nodes[a].push(b);
        nodes[b].push(a);
    }

    let mut colors = vec![None; n+1];
    let mut queue = VecDeque::new();
    queue.push_back((1,false));
    colors[1] = Some(false);
    while let Some((node, color)) = queue.pop_front() {
        for &next in &nodes[node] {
            if let Some(c) = colors[next] {
                if c == color {
                    println!("{}", n*(n-1)/2-m);
                    return;
                }
                continue;
            }
            queue.push_back((next,!color));
            colors[next] = Some(!color);
        }
    }
    let mut count = 0;
    for i in 1..n+1 {
        if colors[i].unwrap() {
            count += 1;
        }
    }
    println!("{}", count*(n-count)-m);
}


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

#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for (int i=a;i>=b;i--)
#define LL long long
#define INF (2147483647)
#define sqr(x)	((x)*(x))

using namespace std;

inline void read(int &data){
    data=0;
	int w=1; char ch=0;
    while (ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if (ch=='-') w=-1,ch=getchar();
    while  (ch>='0' && ch<='9') data=data*10+ch-'0',ch=getchar();
    data=data*w;
}

inline void write(int x){
	if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
} 

inline void read(LL &data){
    data=0;
	int w=1; char ch=0;
    while (ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if (ch=='-') w=-1,ch=getchar();
    while  (ch>='0' && ch<='9') data=data*10+ch-'0',ch=getchar();
    data=data*w;
}

inline void write(LL x){
	if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
} 

int main(){	
	LL x,y;
	read(x),read(y);
	if (abs(x-y)<=1)	puts("Brown");
	else puts("Alice");
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
   int n;
  cin>>n;
  int d=n%10;
  if(d==3)
    cout<<"bon"<<"\n";
  else if(d==2||d==4||d==7||d==5||d==9)
    cout<<"hon"<<"\n";
  else
    cout<<"pon\n";
  return 0;
}

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

int main() {
int N;
  cin>>N;
  vector<int> V(N);
  vector<int> C(N);
  for(int i=0; i<N; i++){
    cin>>V.at(i);
  }
  for(int i=0; i<N; i++){
    cin>>C.at(i);
  }
  int X=0; int Y=0;
  for(int j=0; j<N; j++){
    if(V.at(j)>C.at(j)){
     X+=V.at(j);
      Y+=C.at(j);
    }
    else continue;
  }
  cout<<X-Y<<endl;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int len;
int flag;
int main()
{
	cin>>s;
	len=s.size();
	for(int i=0;i<len;++i)
	{
		if(s[i]=='C')
			flag=1;
		if(s[i]=='F'&&flag==1)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 2000
int sca(int ,int);
int A[N];
int n,q;
int main(){
  int i,t;
  int B[N];
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&B[i]);

  for(i=0;i<q;i++){
    t=sca(0,B[i]);
    if(t==1) printf("yes\n");
    else printf("no\n");

  }


  return 0;
}

int sca(int i,int m){
  int res;

  if(m==0) return 1;
  if(i>=n) return 0;

  res=sca(i+1,m)||sca(i+1,m-A[i]);
  return res;
}

Measured memory_bytes: 592
using System;
 
class Scc
{
	static public void Main(string[] args)
	{
		string[] vals = Console.ReadLine().Split(' ');
		long N = long.Parse(vals[0]);
		long M = long.Parse(vals[1]);
 
		if(N*2 >= M)
		{
			Console.WriteLine(M/2);
		}
		else
		{
			Console.WriteLine(N + (M-N*2)/4);
		}
	}
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N, 0);
    rep(i, N)
        cin >> A.at(i);
    
    rep(i, N)
    {
        if(A.at(i)%2 == 0)
        {
            if(!(A.at(i)%3 == 0 || A.at(i)%5 == 0))
            {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())

    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    token = lines[0].split()
    r = int(token[0])
    d = int(token[1])
    x = int(token[2])

    return (r, d, x)


def solve(r, d, x):

    y = x
    result = 0
    for i in range(10):
        y = r*y - d
        print(y)

    return result


def main():
    # 出力

#    print("%s" % solve(*parse_input()))

    solve(*parse_input())

if __name__ == '__main__':

    main()


Measured memory_bytes: 3064
import sys
s ,v = [], []
for e in sys.stdin:
    try:
        v[s.index(int(e))] += 1
    except:
        s.append(int(e))
        v.append(1)
c = list(zip(s, v))
c.sort()
c.sort(key = lambda x: x[1], reverse = True)
for i in c:
    if i[1] == c[0][1]:print(i[0])
    else:break


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



int main(){
    int n,cwt=0;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
   int cwnt = 0;
    sort(a.begin(),a.end());
    for(int s=1;s<n;s++){
        if(a[s]==a[s-1]){
            cwnt++;
        }
    }
    if(cwnt>0){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
    }
}



Measured memory_bytes: 1024