akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    string s; cin >> s;
    stack<char> sc;
    REP(i, s.size()){
        char c = s[i];
        if(c != 'B'){
            sc.push(c);
        }
        else{
            if(!sc.empty()) sc.pop();
        }
    }
    string res;
    REP(i, sc.size()){
        res += sc.top();
        sc.pop();
    }
    reverse(ALL(res));
    cout << res << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,ans;
  cin >> N;
  vector<int> X(N);
  vector<int> Y(N);
  for(int i=0; i<N; i++){
  	cin >> X[i];
    Y[i]=X[i];
  }
  sort(Y.begin(), Y.end());
  int L=Y[N/2-1],R=Y[N/2];
  for(int i=0; i<N; i++){
    if(X[i]<=L)ans=R;
    if(X[i]>=R)ans=L;
    cout << ans << endl;
  }
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}


int main(void){
    int N;
    cin >> N;
    vector<int> l(N);
    rep(i , N)cin >> l[i];
    sort(l.begin(), l.end());
    int sum = 0;
    rep(i, N-1){
        sum += l[i];
    }
    string ans = l[N-1] < sum ? "Yes" : "No";
    cout << ans << endl;
}

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


void solve(std::string s){
  for(long long i = 0; i < s.size(); i++) {
    if(i%2==0) cout << s[i];
  }

  cout << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string s;
  std::cin >> s;
    solve(s);
    return 0;
}


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

int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    int a[10000];
    int sum = n;
    for(int i = 0;i < m;i++){
        scanf("%d",&a[i]);
    }

    for(int i = 0;i < m && sum >= 0;i++){
        sum -= a[i];
    }
    if(sum >= 0){
        printf("%d",sum);
    }else{
        printf("-1");
    }
    return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int n;
	cin >> n;
	vec(P)
	fx(n) {
		vecp(P)
	}
	int ans = 0;
	for (int x = 1; x < n - 1;x++) {
		if (P.at(x - 1) < P.at(x)) {
			if (P.at(x + 1) > P.at(x)) {
				ans++;
			}
		}
		else {
			if (P.at(x + 1) < P.at(x)) {
				ans++;
			}
		}
	}
	ce(ans)
    return 0;
}



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

using namespace std;

#define X   first
#define Y   second
#define ld  double

const int   N   = 2e5 + 5;
const int   mod = 1e9 + 7;

typedef pair<int,int>   ii;

int add(int a,int b)    {
    a += b;
    if(a >= mod)a -= mod;
    return  a;
}
int sub(int a,int b)    {
    a -= b;
    if(a <  0)  a += mod;
    return  a;
}
int mul(int a,int b)    {
    return  1ll * a * b % mod;
}

vector<int> g[N];
map<int,ii> p[N];

int mrg(int u,int v)    {
    if (p[u].size() < p[v].size())
        p[u].swap(p[v]);
    for(auto it : p[v]) {
        int d = it.X;
        int cur = mul(p[u][d].X,it.Y.X);
        int res = add(mul(p[u][d].X,it.Y.Y),mul(p[u][d].Y,it.Y.X));
        p[u][d] = ii (cur,res);
    }
}

int dfs(int u,int d)    {
    for(int v : g[u])
        dfs(v,d + 1),
        mrg(u,v);
    for(auto &it : p[u]){
        if (it.Y.X != sub(1,it.Y.Y))
            it.Y.X  = sub(1,it.Y.Y);
        else
            break;
    }
    p[u][d].X = 500000004;
    p[u][d].Y = 500000004;
}

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

    int n;  cin >> n;

    for(int i = 1 ; i <= n ; ++i)   {
        int x;  cin >> x;
        g[x].push_back(i);
    }

    dfs(0,0);

    int ans = 0;

    for(auto it : p[0])
        ans = add(ans,it.Y.Y);

    for(int i = 0 ; i <= n ; ++i)
        ans = mul(ans,2);

    cout << ans << endl;
}

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

int main(){
  string s;
  cin >> s;
  if(s == "KIHBR"){
    puts("YES");
    return 0;
  }
  if(s == "AKIHBR"){
    puts("YES");
    return 0;
  }
  if(s == "KIHABR"){
    puts("YES");
    return 0;
  }
  if(s == "KIHBAR"){
    puts("YES");
    return 0;
  }
  if(s == "KIHBRA"){
    puts("YES");
    return 0;
  }
  if(s == "AKIHABR"){
    puts("YES");
    return 0;
  }
  if(s == "AKIHBAR"){
    puts("YES");
    return 0;
  }
  if(s == "AKIHBRA"){
    puts("YES");
    return 0;
  }
  if(s == "KIHABAR"){
    puts("YES");
    return 0;
  }
  if(s == "KIHABRA"){
    puts("YES");
    return 0;
  }
  if(s == "KIHBARA"){
    puts("YES");
    return 0;
  }
  if(s == "AKIHABAR"){
    puts("YES");
    return 0;
  }
  if(s == "AKIHABRA"){
    puts("YES");
    return 0;
  }
  if(s == "AKIHBARA"){
    puts("YES");
    return 0;
  }
  if(s == "KIHABARA"){
    puts("YES");
    return 0;
  }
  if(s == "AKIHABARA"){
    puts("YES");
    return 0;
  }
  else puts("NO");
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
r=max(a)
e=len(bin(r))-2
p=[[]for _ in range(n)]
for i in range(e):
	for j in range(n):
		p[j].append(a[j]%2)
		a[j]//=2
ans=0
cnt=[0]*e
j=0
for i in range(n):
	while 2 not in cnt and j<n:
		for k in range(e):
			cnt[k]+=p[j][k]
		j+=1
	if 2 not in cnt:
		ans+=1
	ans+=j-i-1
	for k in range(e):
		cnt[k]-=p[i][k]
print(ans)

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

int main(){
    int A,B,C;
    cin >> A >> B >> C;

    if (A == B){
        cout << C << endl;
    }

    else if (A==C){
        cout << B << endl;
    }

    else{
        cout << A << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n, m = [int(_) for _ in input().split()]
h = [int(_) for _ in input().split()]
l = [[] for i in range(n)]
for i in range(m):
    a, b = [int(_) for _ in input().split()]
    l[a-1].append(b-1)
    l[b-1].append(a-1)
ans = 0
for i in range(n):
    high = h[i]
    p = l[i]
    flag = 0
    for j in range(len(p)):
        if h[p[j]] >= high:
            flag = 1
    if flag == 0:
        ans += 1
print(ans)

Measured memory_bytes: 94648
#include "bits/stdc++.h"
using namespace std;

long long N, MAX = 0;
static vector<pair<long long, long long> > V[100000];
static long long ANS[100000] = {};

void DFS(long long P, long long Q, long long C) {
	long long NOW = 1;
	for (pair<long long, long long> NP : V[P]) {
		long long To = NP.first, X = NP.second;
		if (To == Q) continue;
		else {
			if (C == NOW) NOW++;
			ANS[X] = NOW;
			DFS(To, P, NOW);
		}
		NOW++;
	}
}

int main() {
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		long long A, B;
		cin >> A >> B;
		A--, B--;
		V[A].push_back({ B, i });
		V[B].push_back({ A, i });
	}
	for (int i = 0; i < N; i++) {
		MAX = max(MAX, (long long)(V[i].size()));
	}
	DFS(0, -1, 0);
	cout << MAX << endl;
	for (int i = 0; i < N - 1; i++) cout << ANS[i] << endl;
}

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

int main(){
    string s;
    cin>>s;
    ll n = s.size();
    for(ll i=1;i<n;++i){
        if((n-i)%2==0){
            string x = s.substr(0, (n-i)/2);
            string y = s.substr((n-i)/2, (n-i)/2);
            if(x==y){
                cout<<n-i<<endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()) {
      String[] v = sc.nextLine().split(" ");
      double xa1 = Double.valueOf(v[0]);
      double ya1 = Double.valueOf(v[1]);
      double xa2 = Double.valueOf(v[2]);
      double ya2 = Double.valueOf(v[3]);
      double xb1 = Double.valueOf(v[4]);
      double yb1 = Double.valueOf(v[5]);
      double xb2 = Double.valueOf(v[6]);
      double yb2 = Double.valueOf(v[7]);
      if(yb1<=ya2 && ya1<=yb2 && xb1<=xa2 && xa1<=xb2) {
        System.out.println("YES");
      }
      else {
        System.out.println("NO");
      }
    }
  }
}

Measured memory_bytes: 25996
/*
  単語の検索(１つの単語Wと文章Tが与えられます。
  Tの中にあるWの数を出力するプログラム)
  2018/03/02
*/

#include<stdio.h>

/*大文字を小文字、小文字を大文字に変える*/
char Change_Word(char t[],int i){
  char str;
  if(t[i] >='A' && t[i] <= 'Z'){
    str = t[i]+32;
  }
  else{
    if(t[i] >= 'a' && t[i] <= 'z')
      str = t[i] -32;
    }
  return str;
}

int Judge_Word(char t[],char w[]){
  char word;/*大文字を小文字、小文字を大文字に変えた英文字*/
  int i;
  int flag = 1;
  i=0;
  word = Change_Word(t,i);
  while(t[i] != '\0' && w[i] != '\0' && flag == 1){
    if(t[i] == w[i] || word == w[i]){
      i++;
      word = Change_Word(t,i);
    }
    else{
      flag = 0;
      i++;
    }
  }
  if(w[i] != '\0' || t[i] != '\0')
    flag = 0;
  return flag;
}

int main(void){
  char w[11];
  char t[1000];
  char end[]= "END_OF_TEXT";/*END_OF_TEXT という文字列が文章の終わり*/
  int count,judge,i;/*文章tの中に単語wがある回数,END_OF_TEXTかどうか判断*/

  scanf("%s",w);
  count = 0;
  while(1){
    scanf("%s",t);
    i=0;
    while(end[i] == t[i] && end[i] != '\0')
      i++;
    if(end[i] == '\0')
      break; 
    count += Judge_Word(t,w);
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    string s;
    cin >> s;
    rep(i,s.size()){
        cout << 'x';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;

int main(){
    ll N;
    cin >> N;
    vector<double> p(N+1,0);
    for(ll i=0;i<N;i++){
        cin>>p[i+1];
    ;}

    //dp[i][j]はi枚投げてうちj枚表が出る確率
    vector<vector<double>> dp(N+1, vector<double>(N+1,0));
    dp[0][0]=1;
    for(ll i=1;i<=N;i++){
     for(ll j=0;j<=i;j++){
         if(j>0)
         dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
         else dp[i][0]=dp[i-1][0]*(1-p[i]);
     ;}
    ;}
    double ans=0;
    for(ll i=N;i>N-i;i--){
        ans+=dp[N][i];
    ;}

    cout << fixed << setprecision(12);
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 70656
#include<stdio.h>

int main(void)
{
  char S[4];
  int flag[3]={0,0,0};

  scanf("%s",S);

  for (int i = 0; i < 3; i++)
  {
    if(S[i]=='a')
      flag[0]=1;
      else if(S[i]=='b')
        flag[1]=1;
        else if(S[i]=='c')
          flag[2]=1;
  }

if(flag[0]==1&&flag[1]==1&&flag[2]==1)
  printf("Yes\n");
else
  printf("No\n");

  return 0;
}



Measured memory_bytes: 128
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define pb push_back
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	cout << (10000 - n) % 1000 << "\n";
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long int
ll N, M, K, A[200100], B[200100], i, st, ans;
using namespace std;
int main()
{
    cin >> N >> M >> K;
    for(i=1;i<=N;i++)
    {
        cin >> st;
        A[i] = A[i-1]+st;
    }
    for(i=1;i<=M;i++)
    {
        cin >> st;
        B[i] = B[i-1]+st;
    }
    for(i=0;i<=N;i++)
    {
        if(A[i]>K)
            break;
        while(M>0 && A[i]+B[M]>K)
            M--;
        ans = max(ans, i+M);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6724
#include<stdio.h>

int main(){

	int a,b;
	char op;
	
	while(1){
	scanf("%d %c %d\n",&a,&op,&b);
	if(op=='+')
		printf("%d\n",a+b);
	else if(op=='-')
		printf("%d\n",a-b);
	else if(op=='*')
		printf("%d\n",a*b);
	else if(op=='/')
		printf("%d\n",a/b);
	else 	
		break;
	}
	return 0;
}

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

map<int,int>prime_factor(int n){
	map<int,int>res;
	for(int i=2;i*i<=n;i++){
		while(n%i==0){
			res[i]++;
			n/=i;
		}
	}
	if(n!=1)res[n]++;
	return res;
}

struct UnionFind{
	vector<int>par;
	UnionFind(int n){
		par=vector<int>(n);
		rep(i,n)par[i]=i;
	}
	int find(int x){
		if(par[x]==x)return x;
		return par[x]=find(par[x]);
	}
	void unite(int x,int y){
		x=find(x);y=find(y);
		par[x]=y;
	}
};

int a[200000];
vector<int>v[200000];
vector<int>b[200000];

int main(){
	int n;cin>>n;
	rep(i,n){
		scanf("%d",&a[i]);
		auto mp=prime_factor(a[i]);
		for(auto p:mp){
			v[p.first].push_back(i);
		}
	}
	UnionFind uf(n);
	for(int i=2;i<200000;i++){
		for(int j=0;j+1<v[i].size();j++){
			uf.unite(v[i][j],v[i][j+1]);
		}
	}
	rep(i,n){
		b[uf.find(i)].push_back(a[i]);
	}
	rep(i,n){
		sort(b[i].begin(),b[i].end(),greater<>());
	}
	vector<int>ans;
	rep(i,n){
		int p=uf.find(i);
		ans.push_back(b[p].back());
		b[p].pop_back();
	}
	rep(i,ans.size()-1){
		if(ans[i]>ans[i+1]){
			puts("0");return 0;
		}
	}
	puts("1");
}


Measured memory_bytes: 16688
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

bool IsOkay(const string &s) {
  const int32_t length = static_cast<int32_t>(s.length());
  if (length % 2 != 0) {
    return false;
  }
  const int32_t half = length / 2;
  return (s.substr(0, half) == s.substr(half, half));
}

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

  string S;
  cin >> S;
  const int32_t length = static_cast<int32_t>(S.length());
  for (int32_t i = length - 2; i >= 2; i -= 2) {
    if (IsOkay(S.substr(0, i))) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


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

int main(){
  int N;
  cin >> N;

  vector<int> d(N);
  for(int i = 0; i < N; i++){
    cin >> d[i];
  } 


  sort(d.begin(), d.end());

  int cnt = 0;
  int x = d[N / 2 - 1];
  while(x < d[N /2]){
    cnt++;
    x++;
  }

  cout << cnt << endl;
 
  return 0;
}

Measured memory_bytes: 640
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	string a, b, c; cin >> a >> b >> c;
	cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n; cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    sort(v.begin(),v.end());
    cout << v[n/2+1-1]-v[n/2-1] << endl;
}

Measured memory_bytes: 640
n,k=map(int,input().split())
dp=[10**10]*n
h=list(map(int,input().split()))
dp[0]=0
for i in range(1,n):
    dp[i]=min(dp[i-j]+abs(h[i-j]-h[i]) for j in range(1,1+min(k,i)))

print(dp[-1])

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

int n;
int x[105];

int dist(int a, int b)
{
	return (a - b) * (a - b);
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> x[i];
	
	long long minn = 1000000000;
	for (int i = 1; i <= 100; i++)
	{
		long long current = 0;
		for (int j = 1; j <= n; j++)
			current += dist(x[j], i);
		minn = min(current, minn);
	}
	cout << minn << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
const ll MOD = 1000000007;

set<int> S;
int A[100010], B[100010], N, sa, sb, sc, sd;
vector<int> ss(3);

int dfs(int x) {
	if (x == N)return -1;
	//for (int i = 0;i <= N;i++)cout << B[i] << " ";cout << endl;
	auto it = S.begin();
	int y = *it, j;

	if (S.size() == 3) {
		sa = B[x];
		sb = *it;
		it++;
		sc = *it;
		it++;
		sd = *it;

		
		//ある要素Nの前に来れるような要素がない時
		//その要素Nとのつながりを否定しないような要素が現れるまで戻るべき
		
		ss = { sb,sc,sd };
		for (int i = 0;i < 6;i++) {
			if (A[sa] != ss[0] && A[ss[0]] != ss[1] && A[ss[1]] != ss[2]) {
				for (int j = 0;j < 3;j++)B[x + 1 + j] = ss[j];
				S = { -1,-2,-3,-4 };
				return -1;
			}
			next_permutation(all(ss));
		}
		S.insert(sa);
		return A[sa];
	}

	if (y == A[B[x]]) {
		S.erase(S.begin());

		B[x + 1] = *S.begin();
		S.erase(S.begin());
		S.insert(y);
	}
	else {
		S.erase(S.begin());
		B[x + 1] = y;
	}

	j = dfs(x + 1);
	if (j < 0)return j;
	S.insert(B[x + 1]);
	if (A[B[x]] == j) {
		return j;
	}
	else {
		B[x + 1] = j;
		S.erase(j);
		dfs(x + 1);
		return -1;
	}
}

int main() {
	cin >> N;
	for (int i = 1;i <= N;i++) {
		cin >> A[i];
		S.insert(i);
	}
	if (N == 2) {
		cout << -1 << endl;
		return 0;
	}
	int ans = dfs(0);
	
	for (int i = 1;i <= N;i++) {
		cout << B[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 12544
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
void solve() {
    int n;
    cin>>n;
    int ans1=0,ans2=0;
    int prev;
    cin>>prev;
    rep(i,n-1) {
        int a;
        cin>>a;
        if(a<prev) ans1=max(ans1,prev-a);
        else ans2=max(ans2,a-prev);
        prev = a;
    }
    swap(ans1,ans2);
    cout<<ans1<<" "<<ans2<<endl;


}

int main() {
    
    int t;
    cin>>t;
    rep(i,t) solve();
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long
#define P pair<int,int>
#define MAX_N 200002
using namespace std;

ll n;
ll p[MAX_N];

int main(){
    map<string, int> mp;
    string A,B;
    int a,b;
    cin>>A>>B;
    cin>>a>>b;
    string C;
    cin>>C;
    mp[A] = a;
    mp[B] = b;
    mp[C]--;

    int ansa = mp[A];
    int ansb = mp[B];
    cout<< ansa << ' ' << ansb<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int k, n,i;
char str[100001];
int main()
{
    scanf("%s%d",str,&k);
    n = strlen(str);
    for (i = 0; i < n; i++)
        if (k >= ('z' - str[i] + 1) % 26)
        {
            k -= ('z' - str[i] + 1) % 26;
            str[i] = 'a';
        }
    str[n - 1] += k%26;
    while (str[n - 1] > 'z')
        str[n - 1] -= 26;
    printf("%s\n",str);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)

int main() {
  int a,b,c; cin>>a>>b>>c;
  cout << max(a*10+b+c,max(a+b*10+c,a+b+c*10)) << endl;
}


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

using namespace std;
typedef long long LL;

#define MAXN 100000
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz size
#define FAIL {cout <<-1 << endl; return 0;}

pair<int, int> P[MAXN];

int main(int argc, char** argv) {
#ifdef OJ
    freopen("input.txt", "r", stdin);
    //    freopen("output.txt", "w", stdout);
#endif
    std::ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; i++)
        cin >> P[i].fi >> P[i].se;

    sort(P, P + m);

    int ans = 0;
    int l = 1, r = n;
    for (int i = 0; i < m; i++) {
        if (r <= P[i].fi) {
            ans++;
            l = P[i].fi;
            r = P[i].se;
        } else {
            l = max(l, P[i].fi);
            r = min(r, P[i].se);
        }
    }

    cout << ans + 1 << endl;
    return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int h, w;
  cin >> h >> w;
  rep(i, h) {
    rep(j, w) {
      string s;
      cin >> s;
      if(s == "snuke") cout << (char)(j+'A') << (i+1) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    
    val N, M = sc.nextLong()
    
    // cが足りなければ無理
    // Sを起点, cの余りでSccを作る
    // 下の奴は, O(N)なので 10^12は間に合わない
//    def solve(N: Long, M: Long): Long = {
//      @scala.annotation.tailrec
//      def useS(N: Long, M: Long, scc: Long): Long =
//        if (N > 0) {
//          if (M >= 2) useS(N - 1, M - 2, scc + 1)
//          else scc
//        } else M / 4 + scc
//      useS(N, M, 0)
//    }

    // 以下の奴でO(1)で計算可能
    val r = (((2 * N) min M) / 2) + (((M - (2 * N)) max 0) / 4)

    println(r)
  }

}


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

using ll = long long;

#define for_(i, a, b) for(int i = (a);i < (b);++i)
#define rfor_(i, a, b) for(int i = (b)-1;i >= (a);--i)
#define rep(i, n) for_(i, 0, n)
#define rrep(i, n) rfor_(i, 0, n)

int x[4], y[4];

int main() {
  cin.tie(0);cout.tie(0);
  ios_base::sync_with_stdio(false);
  
  rep(i, 2)cin>>x[i]>>y[i];
  
  int a = x[1] - x[0], b = y[1] - y[0];
  
  rep(i, 2)cout<<(x[1-i] - b)<<' '<<(y[1-i] + a)<<(i?'\n':' ');

  return 0;
}


Measured memory_bytes: 888
#include<cstdio>
#include<algorithm>
#include<cmath>
#define cmax(_i,_j) ((_i)<(_j)?(_i)=(_j):0)
#define cmin(_i,_j) ((_i)>(_j)?(_i)=(_j):0)
using namespace std;
namespace runzhe2000
{
	void main()
	{
		int a, b; scanf("%d%d",&a,&b);
		if(a <= 8 && b <= 8) puts("Yay!");
		else puts(":(");
	}
}
int main()
{
	runzhe2000::main();
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <list>
#include <cstring>
#include <map>
#include <queue>
#include <ctime>
#include <set>
#include <sstream>
#include <unordered_set>
#include <unordered_map>
#include <cmath>

#define pb push_back
#define mp make_pair
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ull unsigned long long
#define iloop(a,b) for(ll i = a; i < b; ++i)
#define jloop(a,b) for(ll j = a; j < b; ++j)
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(typeofa((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define p(a) cout << a << "\n";
#define p1(a) cout << a << " ";

#define PI 3.141592653589793
#define MOD (ll)(1e9 + 7)

using namespace std;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 

void solve()
{
	int n;
	cin >> n;
	map<ll, ll> m;
	ll a;
	iloop(0,n)	
	{
		cin >> a;
		m[a]++;
	}
	ll first = -1, last = -1;
	for(auto i = m.begin(); i != m.end(); ++i)
	{
		if(i->second >= 2 && i->second < 4)
		{
			last = first;
			first = i->first;
		}
		else if(i->second >= 4)
		{
			last = i->first;
			first = i->first;
		}
	}
	if(last == -1 || first == -1)
		p("0")
	else
	{
		p(first*last)
	}
}
int main()
{
	bool testing = false;
	IOS
	if(testing)
	{
		freopen("test.txt","rt",stdin);
		int start = clock();
		solve();
		int end = clock();
		cout << "time: " << (end - start)/(double)(CLOCKS_PER_SEC)*1000 << " milliseconds\n";
	}
	else
	{
		solve();
	}
} 

Measured memory_bytes: 6528
#include <iostream>
#include <string>
 
using namespace std;
 
int main(void)
{
  string s;
  cin >> s;
  if(s.length()==2) {
    cout << s << endl;
  } else {
    for(int i=2; i>=0; i--){
      cout << s[i];
    }
    cout << endl;
  }
}

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

int main() {
int n,m;
  cin>>n>>m;
  cout<<pow(2,m)*(1900*m+100*(n-m))<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

int main() {
	ll n, a, b, c, d;	cin >> n >> a >> b >> c >> d;
	n -= 1;
	if (a > b)	swap(a, b);
	b -= a;
	ll k = d - c;
	REP(i, n) {
		//i個が負、(n-i)個が正
		//(n-2*i)c-ik<=b<=(n-2*i)c+(n-i)k
		if ((n - 2 * i)*c - i*k <= b&&b <= (n - 2 * i)*c + (n - i)*k) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

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

using namespace std;
const int maxn=2e5+5;

int main()
{
   int n,a;
   cin>>n;
   int flag=0;
   for(int i=1;i<=n;i++)
   {
       cin>>a;
       if(a%5!=0&&a%3!=0&&a%2==0)
        flag=1;
   }
   if(flag)
    cout<<"DENIED"<<endl;
    else
    cout<<"APPROVED"<<endl;
}


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


int main() {
    string s;
    int n;
    long r = 0, g = 0, b = 0, count;
    cin >> n;
    cin >> s;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R')
            r++;
        if (s[i] == 'G')
            g++;
        if (s[i] == 'B')
            b++;
    }
    count = r * g * b;
    for (int i = 0; i < n; i++)
        for (int j = 1; i + 2 * j < n; j++)
            if (s[i] != s[i + j] && s[i] != s[i + 2 * j] && s[i + j] != s[i + 2 * j])
                count--;
    cout << count;
    return 0;
}

Measured memory_bytes: 3160
from sys import stdin

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort()
    return divisors

n = int(stdin.readline().rstrip())
ds = make_divisors(n)

#print(ds)

sum = 0
for x in ds:
   if x==n:
     continue
   m = int(n/x-1)
   if m==1:
     continue
#   print(x,m, int(n/m), n%m)
   if(int(n/m) == n%m):
     sum += m

print(sum)

Measured memory_bytes: 3264
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
ll MOD = 1000000007;
ll INF =1<<30;



int main(){
   ll a,b;
   cin >> a>>b;
   if(a<=0&&b>=0) {
       cout << "Zero" <<endl;
       return 0;
   }
   if(a>0){
       cout << "Positive" <<endl;
       return 0;
   }
   if((b-a)%2==1) cout << "Positive"<<endl;
   else cout << "Negative" <<endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int k = sc.nextInt();
		String ans = "";
		String check = String.valueOf(s.charAt(k - 1));

		for (int i = 0; i < s.length(); i++) {
			if (!String.valueOf(s.charAt(i)).equals(check)) {
				ans += "*";

			} else {
				ans += check;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 22996
def computeXOR(n) : 
    if n % 4 == 0 : 
        return n 
  
    if n % 4 == 1 : 
        return 1
  
    if n % 4 == 2 : 
        return n + 1
  
    return 0

A, B = (int(x) for x in raw_input().split())
print ( computeXOR(A-1) ^ computeXOR(B) )


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

bool check(int n, int maxi){
  for (int i = maxi; i > 0; i--) {
    if(n >= i){
      n -= i;
    }
  }
  return (n == 0);
}

int main(){
  int n;
  std::cin >> n;
  int l = 0, r = n, mid = (r + l)/2;
  while(r - l > 1){
    if(check(n, mid)){
      r = mid;
    }else{
      l = mid;
    }
    mid = (l + r)/2;
  }
  for (int i = r; i > 0; i--) {
    if(n >= i){
      std::cout << i << std::endl;
      n -= i;
    }
  }
  return 0;
}


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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll a,b;
    cin>>a>>b;
    ll x=a-((a/b)*b);
    ll y=(((a/b)+1)*b)-a;
    cout<<min(x,y)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n, k, c;
    cin >> n >> k >> c;

    string s;
    cin >> s;

    vector<int> dp1(n + 1, -1);
    dp1[0] = 0;

    reps(i, n){
        chmax(dp1[i], dp1[i - 1]);
        if(s[i - 1] == 'o'){
            chmax(dp1[i], dp1[max(i - c - 1, 0)] + 1);
        }
    }

    vector<int> dp2(n + 1, -1);
    dp2[n] = 0;

    rrep(i, n){
        chmax(dp2[i], dp2[i + 1]);
        if(s[i] == 'o'){
            chmax(dp2[i], dp2[min(i + c + 1, n)] + 1);
        }
    }

    vector<int> nx(n);
    int now = n;

    rrep(i, n){
        nx[i] = now;
        if(s[i] == 'o'){
            now = i;
        }
    }

    // rep(i, n + 1){
    //     cout << dp1[i] << ' ';
    // }
    // cout << endl;
    // rep(i, n + 1){
    //     cout << dp2[i] << ' ';
    // }
    // cout << endl;

    rep(i, n){
        if(s[i] == 'x'){
            continue;
        }

        if(dp1[i] + dp2[nx[i]] < k){
            cout << i + 1 << '\n';
        }
    }

    cout << flush;

    return 0;
}

Measured memory_bytes: 4244
#include <stdio.h>

int main(void) {
	int a[4]={0},b[2]={0},c,i;
	scanf("%d",&a[0]);
	scanf("%d",&a[1]);
	scanf("%d",&a[2]);
	scanf("%d",&a[3]);
	scanf("%d",&b[0]);
	scanf("%d",&b[1]);
	for(i = 2;i >= 0;i--){
		if(a[i] > a[i+1]){c = a[i+1];a[i+1] = a[i];a[i] = c;}
	}
	if(b[0] > b[1]){c = b[1];b[1] = b[0];b[0] = c;}
	printf("%d\n",a[1]+a[2]+a[3]+b[1]);
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <cassert>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    string s; cin >> s;
    string ans = "No";
    rep(i, 3){
        if (s[i] == '7') ans = "Yes";
    }
    cout << ans << endl;
}


Measured memory_bytes: 3132
def bellmanford(xyw, n, start):
    inf = float("inf")
    dist = [inf]*n
    dist[start] = 0

    for _ in range(n-1):
        for x,y,w in xyw:
            if dist[x] == inf:
                continue
            if dist[y] > dist[x] + w:
                dist[y] = dist[x] + w
    result = dist[n-1]
    negative = [0]*n
    for _ in range(n):
        for x, y, w in xyw:
            if dist[x] == inf:
                continue
            if dist[y] > dist[x] + w:
                dist[y] = dist[x] + w
                negative[y] = True
            if negative[x]:
                negative[y] = True
    return inf if negative[n-1] else -result


N, M = map(int, input().split())
ABC = (map(int, input().split()) for i in range(M))
ABC = [(a-1,b-1,-c) for a,b,c in ABC]

print(bellmanford(ABC, N, 0))


Measured memory_bytes: 48488
n,a,b,c=map(int,input().split())
M=10**9+7
m=2*n
fact=[1]*(m+1)
ifact=[1]*(m+1)
r=1
for i in range(1,m+1):fact[i]=r=r*i%M
ifact[m]=r=pow(fact[m],M-2,M)
for i in range(m,0,-1):ifact[i-1]=r=r*i%M
r=pow(a+b,M-2,M) 
p=0
d=b*r%M
e=1
for k in range(n):
    v=fact[n+k-1]*ifact[n-1]*ifact[k]%M*e*(n+k)%M
    e=e*d%M
    p+=v
p*=pow(a*r%M,n,M)*100*r%M
q=0
d=a*r%M
e=1
for k in range(n):
    v=fact[n+k-1]*ifact[n-1]*ifact[k]%M*e*(n+k)%M
    e=e*d%M
    q+=v
q*=pow(b*r%M,n,M)*100*r%M
print((p+q)%M)

Measured memory_bytes: 18804
#include<stdio.h>
int main(void)
{
	int N, L[11], max = 0, wa = 0;
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		scanf("%d", &L[i]);
		if (L[i] > max) {
			max = L[i];
			}
		wa += L[i];
	}
	//printf("max=%d wa=%d ", max, wa);
	if (max < (wa - max)) {
		printf("Yes");
		return 0;
	}
	else {
		printf("No");
		return 0;
	}
	
}

Measured memory_bytes: 128
anum = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)[0..anum]
tnum = gets.chomp.to_i
tarr = gets.chomp.split.map(&:to_i)[0..tnum]
cnt = 0
tarr.each do |item|
  sidx = 0
  eidx = arr.length 
  while sidx + 1< eidx
    idx = sidx + (eidx - sidx) / 2 
    if item == arr[idx]
      cnt += 1
      break
    end
    sidx = idx  if item > arr[idx]
    eidx = idx  if item < arr[idx]
  end
end

puts cnt

Measured memory_bytes: 18100
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int a[100000];

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int cnt = 0;
    int(n);
    scn(n, a);
    rep(i, n)--a[i];
    rep(i, n){
      //pri2(a[i], a[a[i]]);
      if(a[a[i]] == i)++cnt;
    }
    pri(cnt / 2);

/*/

//*/ break;
  }
  return 0;
}


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

bool check(int x){
    int l = x%10;
    x/=10;
    while(x){
        if(x%10!=l)return false;
        x/=10;
    }
    return true;
}
int main() {
    int x;
    cin >> x;
    while(!check(x)){
        x++;
    }
    cout << x;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int Min = 30; //割り切れる回数は30未満
  int times = 0;
  int a;
  
  for (int i=0; i<N; i++) {
    //A一つ一つについて調査
    times = 0;
    cin >> a;
    //新しいAを入力し、2で割り切れる回数を調査
    for (int j=0; j<Min; j++) {
      if (a%2 == 0) { //2で割り切れた場合
        a /= 2;
        times += 1;
        //割り切れる限り回数増加
      }
      else { //2で割り切れなかった場合
        if (Min > times)
          Min = times;
        times = 0;
        //回数の最小を保存、回数は初期化
        break;
        //このAの調査を終了、次のAへ
      }
    }
  }
  
  cout <<Min <<endl;
}


Measured memory_bytes: 256
n=int(input())
d=list(map(int,input().split()))

mod=998244353
if d[0]!=0:
    print(0)
    exit()
if 0 in d[1:]:
    print(0)
    exit()

ans=1
from collections import Counter
c=Counter(d)

for i in range(1,max(d)+1):
    if not i in c:
        print(0)
        exit()
    ans*=(c[i-1]**c[i])
    ans%=mod

print(ans)


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

int main(){
    long long A,B,C;
    cin>>A>>B>>C;
    long long rest;
    if((A*B*C)%2==0){
        cout<<0<<endl;
        return 0;
    }else{
        long long MAX=max({A,B,C});
        if(MAX==A)rest=B*C;
        else if(MAX==B)rest=A*C;
        else rest=A*B;
        cout<<rest<<endl;
    }
    
}

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

int main() {

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
    int n;
    cin>>n;
    int l[n];
    for (int i=0; i<n; i++){
        cin>>l[i];
    }

    sort(l, l+n);
    int cnt = 0;
    for (int i=0; i<n; i++){
        for (int j=i+1; j<n; j++){
            int curr = l[i]+l[j];
            for (int k=j+1; k<n; k++){
                if(curr> l[k]) cnt++;
            }
        }
    }
    cout<<cnt;
}

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

const int INF = 1e+9;

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

vector<int> maze[8];

void search(int x, int y){
	for(int i = 0; i < 12; ++i){
		int nx = x + dx[i], ny = y + dy[i];
		if(nx >= 0 && nx < 8 && ny >= 0 && ny < 8 && maze[ny][nx] == 1){
			maze[ny][nx] = 0;
			search(nx, ny);
		}
	}
	return;
}

int main() {
	int n, sx, sy;
	cin >> n;
	string s;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < 8; ++j){
			cin >> s;
			for(int k = 0; k < 8; ++k)
				maze[j].push_back(s[k] - '0');
		}
		cin >> sx >> sy;
		sx--; sy--;
		if(maze[sy][sx] == 1){
			maze[sy][sx] = 0;
			search(sx, sy);
		}
		printf("Data %d:\n", i + 1);
		for(int j = 0; j < 8; ++j){
			for(int k = 0; k < 8; ++k){
				cout << maze[j][k];
			}
			cout << endl;
			maze[j].clear();
		}
		
	}
	return 0;
}

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

int main() {
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  for(int i=0;i<k;i++){
    if(a>=b){
      b*=2;
      continue;
    }
    if(b>=c){
      c*=2;
      continue;
    }
  }
  if(a<b&&b<c){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
      
}


Measured memory_bytes: 3616
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

map<int, int> prime_factor(int n) {
    map<int, int> ret;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }

    if (n != 1) ret[n] = 1;
    return move(ret);
}

signed main() {
    int A, B;
    cin >> A >> B;
    int C = gcd(A, B);

    int ret = prime_factor(C).size() + 1;
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
	char s;
	cin >> s;
	if (isupper(s))
		cout << "A" << endl;
	else
	{
		cout << "a" << endl;
	}
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 2e9 + 10;
const ld EPS = 1e-9;
const ld PI = acos(-1);
const int M = 1e3 + 10;
const int N = 1e6 + 10;


int main() {
    //freopen("a.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    string s, t;
    ll n, m;
    cin >> n >> m;
    cin >> s >> t;
    ll g = n * m / __gcd(n, m);
    for (ll i = 0; i < n; i++) {
        if (i * m % n == 0) {
            ll j = i * m / n;
            if (s[i] != t[j]) {
                cout << "-1";
                return 0;
            }
        }
    }
    cout << g;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
LLI c[51][51]={};
void comb(){
    FOR(i,0,51){
        FOR(j,0,i+1){
            if(j==0||j==i){
                c[i][j]=1;
            }else{
                c[i][j]=c[i-1][j-1]+c[i-1][j];
            }
        }
    }
}

int main(){
    int n,a,b; cin>>n>>a>>b;
    LLI v[50];
    FOR(i,0,n) cin>>v[i];
    sort(v,v+n,greater<LLI>());
    double av=0;
    FOR(i,0,a) av+=v[i];
    av/=a;
    int st=a-1,en=a-1;
    while(v[st-1]==v[a-1]) st--;
    while(v[en+1]==v[a-1]) en++;
    comb();
    LLI ans=0;
    if(st==0){
        FOR(i,a,b+1){
            ans+=c[en+1][i];
        }
    }else{
        ans=c[en-st+1][a-st];
    }
    cout.precision(20);
    cout<<fixed<<av<<endl;
    cout<<ans<<endl;
}


Measured memory_bytes: 256