akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
int N;
string s;
int MODplus1[200005];
int MODminus1[200005];

int f(int x) {
  if (x==0) return 0;
  int cnt=0;
  rep(i, 20) {
    if ((1<<i)&x) cnt++;
  }
  return f(x%cnt)+1;
} 

int calc_mod(int x, int _mod[200005]) {
  if (x==0) return 0;
  _mod[0] = 1;
  rep(i, N) {
    if (i==0) continue;
    _mod[i] = 2*_mod[i-1]%x;
  }
  int sum = 0;
  rep(i, N) {
    if (s[i]=='1') sum+=_mod[N-1-i];
    sum%=x;
  }
  return sum;
}

int main() {
  INCANT;
  cin >> N >> s;
  int cnt=0;
  rep(i, N) if (s[i]=='1') cnt++;
  int sum1 = calc_mod(cnt+1, MODplus1);
  int sum2 = calc_mod(cnt-1, MODminus1);
  rep(i, N) {
    int sum;
    if (s[i]=='1') { // 1→0
      if (cnt-1==0) {
        cout << 0 << endl;
        continue;
      }
      sum=sum2;
      sum-=MODminus1[N-1-i];
      sum+=(cnt-1);
      sum%=(cnt-1);
    } else { // 0→1
      sum=sum1;
      sum+=MODplus1[N-1-i];
      sum%=(cnt+1);
    }
    cout << f(sum) + 1 << endl;
  }  
  return 0;
}


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

int main(){
  constexpr int Amax= 1e6;
  constexpr int Nbit= Amax+ 1;
  int N;
  cin >> N;

  map<int, int> data;
  int buf;
  for(int i=0; i<N; i++){
    cin >> buf;
    if(data.count(buf)){ data.at(buf)++; }
    else               { data[buf]= 1; }
  }
  
  bitset<Nbit> divisible;
  for(auto [num, freq]:data){
    for(int i=2*num; i<Nbit; i+=num){
      divisible.set(i);
    }
  }

  int ans= 0;
  for(auto [num, freq]:data){
    if(!divisible.test(num) && freq==1){ ans++; }
  }

  cout << ans << endl;
}

Measured memory_bytes: 12976
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n,k;
    scanf("%d%d", &n, &k);

    vector<int> a(n);
    vector<ll> sa(n+1),s0(n+1);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
        sa[i+1]=sa[i]+a[i];
        s0[i+1]=s0[i]+(a[i]>0? a[i]: 0);
    }

    ll max=-LINF;
    for(i=0; i<=n-k; i++) {
        ll tmp0=s0[n]-(s0[i+k]-s0[i]);
        max=MAX(max,tmp0);
        ll tmp1=s0[n]-(s0[i+k]-s0[i])+(sa[i+k]-sa[i]);
        max=MAX(max,tmp1);
    }
    printf("%lld\n", max);

    return 0;
}



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

using namespace std;

#define lli long long 
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000007

int main(){
        int n,m,l;
        cin >> n >> m;
        if(0<n&&n<10&&0<m&&m<10)cout << n*m;
        else cout << -1;

}


Measured memory_bytes: 256
# /usr/bin/python3
# -*- coding: utf-8 -*-
# from queue import Queue
# from queue import LifoQueue as Stack
# from math import sqrt, floor, ceil, log2, pi
from math import pi
# from fractions import gcd
# from itertools import permutations, combinations
# from operator import itemgetter
# from functools import cmp_to_key


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x



if __name__ == '__main__':
    # N = intinput()
# 
    # # 出力
    # print(2*N*pi)
    N = int(input())
    print(2*pi*N)


Measured memory_bytes: 9348
#include <stdio.h>
void	ft_swap(long *a, long *b)
{
	long tmp;
	
	tmp = *a;
	*a = *b;
	*b = tmp;
}

/* 昇順 */
void	a_qsort(long *tab, long left, long right)
{
	long Left = left;
	long Right = right;
	long pivot = tab[(left + right) / 2];

	while (1)
	{
		while (tab[Left] < pivot)
			Left++;
		while (tab[Right] > pivot)
			Right--;
		if (Left >= Right)
			break ;
		ft_swap(&tab[Left], &tab[Right]);
		Left++;
		Right--;
	}

	if (Left - 1 > left)
		a_qsort(tab, left, Left - 1);
	if (Right + 1 < right)
		a_qsort(tab, Right + 1, right);
}

int		main()
{
	long A,B,M;
	scanf("%ld%ld%ld", &A,&B,&M);
	long a[A + 1],b[B + 1];
	long m[M + 1][4];
	long dis[M + 1];
	long i,j;
	for (i = 1; i <= A; i++)
		scanf("%ld", &a[i]);
	for (i = 1; i <= B; i++)
		scanf("%ld", &b[i]);
	for (i = 1; i <= M; i++)
	{
		for (j = 1;j <= 3; j++)
		{
			scanf("%ld", &m[i][j]);
		}
	}
	for (i = 1; i <= M; i++)
	{
		dis[i] = (a[m[i][1]] + b[m[i][2]]) - m[i][3];
	}
	a_qsort(a, 1, A);
	a_qsort(b, 1, B);
	long min = a[1] + b[1];
	for (i = 1; i <= M; i++)
	{
		if (dis[i] < min)
			min = dis[i];
	}
	printf("%ld\n", min);
	return (0);
}

Measured memory_bytes: 5632
#include<iostream>
using namespace std;
struct node{ int parent,left,right; };
node type[100001];
int depth[100001];
void output(int x){
  cout<<"node "<<x<<": ";
  cout<<"parent = "<<type[x].parent<<", ";
  cout<<"depth = "<<depth[x]<<", ";
  if(type[x].parent==-1) cout<<"root, ";
  else if(type[x].left==-1) cout<<"leaf, ";
  else cout<<"internal node, ";
  cout<<"[";
  for(int i=0,cur=type[x].left;cur!=-1;++i,cur=type[cur].right){
    if(i) cout<<", ";
    cout<<cur;
  }
  cout<<"]"<<endl;
}
void solve(int p,int d){
  depth[p]=d;
  if(type[p].right!=-1) solve(type[p].right,d);
  if(type[p].left!=-1) solve(type[p].left,d+1);
}
int main(){
  int n,l,r; cin>>n;
  for(int i=0;i<n;++i) type[i].parent=type[i].left=type[i].right=-1;
  for(int i=0;i<n;++i){
    int id,k; cin>>id>>k;
    for(int j=0;j<k;++j){
      int c; cin>>c;
      if(j==0) type[id].left=c;
      else type[l].right=c;
      l=c;
      type[c].parent=id;
    }
  }
  for(int i=0;i<n;++i)
    if(type[i].parent==-1){
      r=i; break;
    }
  solve(r,0);
  for(int i=0;i<n;++i) output(i);
  return 0;
}



Measured memory_bytes: 7772
a = list(input())
# op = []
# for i in ["+", "-"]:
#     for j in ["+", "-"]:
#         for k in ["+", "-"]:
#             op.append([i,j,k])
# print(op)
op = [
    ["+", "+", "+"],
    ["+", "+", "-"],
    ["+", "-", "+"],
    ["+", "-", "-"],
    ["-", "+", "+"],
    ["-", "+", "-"],
    ["-", "-", "+"],
    ["-", "-", "-"],
]

for i in range(2 ** 3):
    for j in op:
        s = a[0] + j[0] + a[1] + j[1] + a[2] + j[2] + a[3]
        if eval(s) == 7:
            print(s + "=7")
            exit()


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



int main(){
	long long x, sum=0, n, m;
	cin>>n;
	int ar[n+1];
	for(int i=1; i<=n; i++) ar[i]=0;
	for(int i=1; i<n; i++) {
		cin>>x;
		ar[x]++;
	}
	for(int i=0; i<n; i++) {
		cout<<ar[i+1]<<'\n';
	}
}

Measured memory_bytes: 4412
MOD = 10**9+7
r1,c1,r2,c2 = map(int,input().split())

size = 1010000*2
f_list = [1]*(size)
for i in range(1,size):
    f_list[i] = (f_list[i-1]*i)%MOD

def func(r,c):
    return (f_list[r+c]*pow(f_list[r],MOD-2,MOD)*pow(f_list[c],MOD-2,MOD))

ans = func(r2+1,c2+1)-1
ans += func(r1,c1)-1
ans -= func(r2+1,c1)-1
ans -= func(r1,c2+1)-1
print(ans%MOD)



Measured memory_bytes: 82940
#include<bits/stdc++.h>
using namespace std;
long long N,K,ok,ng,mid;

int main(){
    cin>>N>>K;
    long long A[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
        ok=max(ok,A[i]);
    }
    while(abs(ok-ng)>1LL){
        //cout<<ng<<" "<<ok<<endl;
        mid=(ok+ng)/2LL;
        //cout<<"mid:"<<mid<<endl;
        bool f=false;
        long long cut=0LL;
        for(int i=0;i<N;i++){
            cut+=(A[i]+mid-1)/mid-1;
        }
        //cout<<"cut_cnt:"<<cut<<endl;
        (cut<=K)?ok=mid:ng=mid;
    }

    cout<<ok<<endl;
    return 0;
}

Measured memory_bytes: 5184
#include <stdio.h>

#define LEN 100005

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

P Q[LEN+1];
int head=1, tail=1, n;
void enqueue(P x){
  Q[tail] = x;
  if (tail + 1 == LEN) tail = 0;
  else     tail++;
       }
P dequeue(){
  P x;
  x = Q[head];
  if (head + 1 == LEN)head = 0;
  else head++; 
  return x;
}




int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    tail++;
  }
  //Qの設定

  while(head!=tail){
    u = dequeue();
    if(u.t<=q){
      elaps += u.t;
      printf("%s %d\n",u.name,elaps);
    }
    else {
      elaps += q;
      u.t -= q;
      enqueue(u);
    }

  }

  
  return 0;
}



Measured memory_bytes: 11860
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
vector<int>pat[101010];
bool flag[101010];
int ds[101010][2];
void dfs(int node, int mode, int d)
{
	if (flag[node])return;
	flag[node] = true;
	ds[node][mode] = d;
	for (int i = 0; i < pat[node].size(); i++)dfs(pat[node][i], mode, d + 1);
}
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num - 1; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		za--, zb--;
		pat[za].push_back(zb);
		pat[zb].push_back(za);
	}
	dfs(0, 0, 0);
	fill(flag, flag + num, false);
	dfs(num - 1, 1, 0);
	int c = 0;
	for (int i = 0; i < num; i++)if (ds[i][0] <= ds[i][1])c++;
	if (c + c > num)printf("Fennec\n");
	else printf("Snuke\n");
}

Measured memory_bytes: 11264
#include <cstdio>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>

using namespace std;

int main() {
    int N=0,M=0,X=0,Y=0,A[100],B[100],max=-100000,min=100000;
    cin>> N>>M>>X>>Y;

    for(int i=0; i<N; i++){
        cin>>A[i];
        if(max<A[i]){
            max=A[i];
        }
    }
    for(int i=0; i<M; i++){
        cin>>B[i];
        if(min>B[i]){
            min=B[i];
        }
    }

    if(max<min){
        for(int i=max+1; i<=min; i++){
            if(i>X && i<=Y){
                printf("No War");
                return 0;
            }
        }
        printf("War");
    }else{
        printf("War");
    }
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,k,type;
int read()
{
  char c=0;
  int sum=0;
  while (c<'0'||c>'9')
    c=getchar();
  while ('0'<=c&&c<='9')
    {
      sum=sum*10+c-'0';
      c=getchar();
    }
  return sum;
}
int main()
{
  n=read(),m=read(),k=read();
  for (int i=1;i<=n;++i)
    {
      for (int j=1;j<=m;++j)
	{
	  type=(((i+j-2)/k)&1)*2+(((i-j+m)/k)&1);
	  if (type==0) printf("R");
	  if (type==1) printf("Y");
	  if (type==2) printf("G");
	  if (type==3) printf("B");
	}
      puts("");
    }
  return 0;
}

Measured memory_bytes: 3040
#include<cstdio>
using namespace std;
int main(){
  int g[13]={0,1,3,1,2,1,2,1,1,2,1,2,1},x,y;
  scanf("%d %d",&x,&y);
  if(g[x]==g[y])
    printf("Yes\n");
  else
    printf("No\n");
}

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

#define FOR(a, b) for (int i = a; i < b; ++i)
#define FOR_EACH(container) for (const auto& p: container)
#define SORT(container) sort(container.begin(), container.end())
#define DSORT(container) sort(container.begin(), container.end(), greater<>())

using namespace std;

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

    int A, B, C;

    cin >> A >> B >> C;

    if ((C > A & C < B) || (C > B && C < A))
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }

    cout << flush;

    return 0;
}


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

int main(){
    int k;
    cin >> k;
    
    int cnt = 0;
    for(int i = 1; i <= k; i ++){
        for(int j = i + 1; j <= k; j += 2){
            cnt++;
            //cout << "i:" << i << endl;
            //cout << "j:" << j << endl;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [[0]*(n+1) for i in range(n+1)]
np = (n//2)*2

for i in range(0,np//2):
    a[i+1][np-i] = -1

print(int(n*(n-1)/2-(n//2)))

for i in range(1,n+1):
    for j in range(i+1,n+1):
        if a[i][j] == -1:
            continue
        else:
            print(i,j)

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

int main(){
  int N;
  cin >> N;
  vector<int64_t> A(N),ans(N);
  int64_t sum=0;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    sum+=A.at(i);
  }
  int64_t x=0;
  for(int i=1;i<N;i+=2){
    x+=A.at(i);
  }
  ans.at(0)=sum-2*x;
  for(int i=1;i<N;i++){
    ans.at(i)=2*A.at(i-1)-ans.at(i-1);
  }
  for(int i=0;i<N;i++){
    cout << ans.at(i);
    if(i==N-1){
      cout << endl;
    }else{
      cout << " ";
    }
  }
  return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;
 
int main(){
    string S;
    cin >> S;
 
    int N = S.size();
 
    string s1 = S.substr(0, (N-1)/2);
    string s1r = S.substr(0, (N-1)/2);
    string s2 = S.substr((N-1)/2 + 1, (N-1)/2);
    string s2r = S.substr((N-1)/2 + 1, (N-1)/2);
    string Sr = S;

    reverse(Sr.begin(), Sr.end());
    reverse(s1r.begin(), s1r.end()); 
    reverse(s2r.begin(), s2r.end()); 
 
    if(S == Sr && s1 == s1r && s2 == s2r){
        cout << "Yes" << endl;
        return 0;
    }
 
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	num := []int{}
	total := 0
	for i := 0; i < N; i++ {
		s := sc.nextInt()
		total += s
		if s%10 != 0 {
			num = append(num, s)
		}
	}
	ans := 0
	if total%10 != 0 {
		ans = total
	} else if len(num) != 0 {
		sort.Ints(num)
		ans = total - num[0]
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


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

const int mod = 1000000007;
int n;
int p[100004];

int main() {
	ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin>>n;
	int ans = 0;
	for(int i = 1 ; i <= n ; i ++)
		cin>>p[i];
	for(int i = 1 ; i <= n ; i ++)
		if(p[i] == i){
			swap(p[i],p[i+1]);
			ans++;
		}
	cout<<ans;
	return 0;
}

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

#define mod 1'000'000'007
typedef long long ll;

template<typename T>
void deb(initializer_list<T> l)
{
	for (auto &e : l)
		cout << e << ' ';
	cout << endl;
}

void no()
{
	cout << -1 << '\n';
	exit(0);
}

void solve()
{
	ll n;
	cin >> n;
	vector<ll> a(n + 1);
	for (auto& e : a)
		cin >> e;

	if (n == 0)
	{
		cout << (a[0] == 1 ? 1 : -1) << '\n';
		return;
	}

	if (a[0])
	{
		cout << -1 << '\n';
		return;
	}

	vector<ll> suff(n + 1);
	suff[n] = a[n];
	for (ll i = n - 1; i >= 0; --i)
		suff[i] = a[i] + suff[i + 1];

	ll nodes = 1;
	ll NonLeaf = 1;
	ll nodesHere = 1;
	for (ll depth = 0; depth < n; ++depth)
	{
		ll nextNodes = suff[depth + 1];
		ll maxNextNodes = 2 * (nodesHere - a[depth]);
		nextNodes = min(nextNodes, maxNextNodes);
		if (nextNodes < a[depth + 1])
			no();
		if (nextNodes == a[depth + 1] && depth + 1 != n)
			no();

		// deb({nodesHere, nextNodes});
		nodes += nextNodes;
		nodesHere = nextNodes;
		continue;

		// ll nextNonLeaf = 2 * NonLeaf - a[depth + 1];
		// // nextNonLeaf = min(nextNonLeaf, lastLeaves);
		// if (nextNonLeaf < 0)
		// 	no();
		// if (nextNonLeaf == 0 && depth + 1 != n)
		// 	no();

		// deb({NonLeaf, nextNonLeaf});
		// nodes += a[depth + 1] + (depth + 1 != n ? nextNonLeaf : 0);
		// NonLeaf = nextNonLeaf;
	}

	cout << nodes << '\n';
}

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

	int t = 1;
	// cin >> t;
	while (t--)
		solve();

	return 0;
}


Measured memory_bytes: 5112
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.function.BinaryOperator;

class SegmentTree<T> {

	private List<T> nodes;
	private T e; // 単位元
	private int n;
	private BinaryOperator<T> operator;

	/**
	 * セグメント木を生成
	 *
	 * @param n  要素数
	 * @param e  単位元
	 * @param op
	 */
	public SegmentTree(int n, T e, BinaryOperator<T> op) {
		this.e = e;
		this.operator = op;

		n = 1 << (32 - Integer.numberOfLeadingZeros(Math.max(n - 1, 0))); // n以上で最小の2のべき乗
		this.n = n;

		nodes = new ArrayList<>(2 * n - 1);
		for (int i = 0; i < 2 * n - 1; i++) {
			nodes.add(e);
		}
	}

	//
	public void update(int k, T val) {
		k += n - 1;
		nodes.set(k, val);

		while (k > 0) {
			k = (k - 1) / 2;
			nodes.set(k, operator.apply(nodes.get(2 * k + 1), nodes.get(2 * k + 2)));
		}
	}

	// 区間 [a,b) のoperatorの結果を返す
	// 0-indexed
	public T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}

	private T query(int a, int b, int k, int l, int r) {
		if (a >= r || b <= l) {
			return e;
		}

		if (a <= l && r <= b) {
			return nodes.get(k);
		}

		T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
		T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
		return operator.apply(vl, vr);
	}

}

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	static private List<Character> merge(List<Character> a, List<Character> b) {
		List<Character> r = new ArrayList<>();

		int ai = 0;
		int bi = 0;

		for (;;) {
			if (ai >= a.size()) {
				for (; bi < b.size(); bi++) {
					r.add(b.get(bi));
				}
				break;
			}
			if (bi >= b.size()) {
				for (; ai < a.size(); ai++) {
					r.add(a.get(ai));
				}
				break;
			}

			if (a.get(ai) == b.get(bi)) {
				r.add(a.get(ai));
				ai++;
				bi++;
			} else if (a.get(ai) < b.get(bi)) {
				r.add(a.get(ai));
				ai++;
			} else {
				r.add(b.get(bi));
				bi++;
			}

		}

		return r;
	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		String S = sc.next();
		int Q = sc.nextInt();

		SegmentTree<Integer> seg = new SegmentTree<>(N, 0, (a, b) -> (a|b));

		for (int i = 0; i < S.length(); i++) {
			
			int c = S.charAt(i) - 'a';
			int b = 1<<c;
			
			seg.update(i, b);
		}

		for (int q = 0; q < Q; q++) {
			int t = sc.nextInt();

			if (t == 1) {
				int i = sc.nextInt() - 1;
				char c = sc.next().charAt(0);

				int b = 1 << (c - 'a');
				

				seg.update(i, b);

			} else {
				int l = sc.nextInt() - 1;
				int r = sc.nextInt();

				int ans = seg.query(l, r);
				out.println(Integer.bitCount(ans));
			}
		}

		sc.close();

	}

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


Measured memory_bytes: 123972
a = int(input())
#a = list(map(int, input().split()))
#x,y = map(int, input().split())

#x,n = map(int, input().split())
#p = input().split()
#for i in range(len(p)):
#    p[i] = int(p[i])
money = 0
while True:
    if money >= a:
        print(money-a)
        break
    else :
        money += 1000

Measured memory_bytes: 9152
#include <bits/stdc++.h>
#include <iostream>
//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
 
int main(){
    bool ans=true;
    string s;
    cin>>s;
    if(s.size()%2==0){
     for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s.at(i)=='h'){
                
            }
            else ans=false;
        }
        else{
            if(s.at(i)=='i'){
                
            }
            else ans =false;
        }
        }
    }
    else ans=false;
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
  



Measured memory_bytes: 256
numbers=gets.split(" ").map{|a| a.to_i}
N=numbers[0]
K=numbers[1]

number_list=gets.split(" ")[0...N].map{|a| a.to_i}
number_histogram = Hash.new

number_list.each{|a|
  if nil == number_histogram[a] 
    number_histogram[a] = 1
  else
    number_histogram[a] += 1
  end
}
if number_histogram.size <= K
  print 0
  exit
end
number_histogram = number_histogram.to_a
number_histogram.sort_by!{|a| -a[1]}
print number_histogram[K...N].inject(0){|amount, a| amount += a[1]}


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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt=0;
    rep(i,s.size()){
        if(s[i]=='R')cnt++;
        else cnt--;
    }
    cout << (cnt>0 ? "Yes" : "No");
}

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

vector<bool> seen;
vector<vector<int>> g;
int n, m;   
void dfs(int x, int &cnt){
    bool f=true;
    for(int i=0; i<n; i++)
        if(!seen[i] && i!=x) f=false;
    if(f){
        cnt+=1; return;
    }
    seen[x] = true;
    
    for(auto next: g.at(x)){
        if(seen[next]) continue;
        dfs(next, cnt);
    }
    seen[x] = false;

}


int main(){
    cin >> n >> m;
    g.assign(n, vector<int>());
    seen.assign(n, false);

    for(int i=0; i<m; i++){
        int a, b;   cin >> a >> b;
        a--;    b--;
        g.at(a).push_back(b);
        g.at(b).push_back(a);
    }
    int cnt=0;
    dfs(0, cnt);
    cout << cnt << endl;
}

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


int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(c-a) <= d || (abs(b-a) <=d  && abs(c-b) <= d)){
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
    
    cout << endl;
}


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

N = int(input().strip())
A_list = list(map(int, input().rstrip().split()))
#-----

plus_h = {}
minus_h = {}

for i in range(N):
    p = (i+1) + A_list[i]
    m = (i+1) - A_list[i]
    
    plus_h.setdefault(p, 0)
    plus_h[p] += 1
    
    minus_h.setdefault(m, 0)
    minus_h[m] += 1


cnt = 0

for k in plus_h:
    if k in minus_h:
        cnt += (plus_h[k] * minus_h[k])


print(cnt)


Measured memory_bytes: 56464
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll n, m, s[10], c[10];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
	
	cin >> n >> m;
	for(ll i = 1; i <= m; i++){
		cin >> s[i] >> c[i];
	}
	if(n == 1){
		for(ll i = 0; i <= 9; i++){
			bool bl = 1;
			for(ll g = 1; g <= m; g++){
				if(i != c[g]){
					bl = 0;
					break;
				}
			}
			if(bl){
				cout << i << '\n';
				return 0;
			}
		}
	}
	
	for(ll i = 1; i <= 9; i++){
		for(ll j = 0; j <= 9; j++){
			for(ll k = 0; k <= 9; k++){
				bool bl = 1;
				for(ll g = 1; g <= m; g++){
					if(s[g] == 1){
						if(i != c[g]){
							bl = 0;
							break;
						}
					}
					else if (s[g] == 2){
						if(j != c[g]){
							bl = 0;
							break;
						}
					}
					else{
						if(k != c[g]){
							bl = 0;
							break;
						}
					}
				}
				if(bl){
					if(n == 2){
						cout << i << j << '\n';
					}
					if(n == 3){
						cout << i << j << k << '\n';
					}
					return 0;
				}
			}
		}
	}
	cout << -1 << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include <iomanip>
#include<map>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FORB(i,s,e,st) for (int i = int(s); i < int(e); i+=(int(st)))
#define FOR(i,s,e) FORB(i,s,e,1)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))


const int MOD = 1e+9+7;
const double PI  = acos(-1.0);

int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0) cout<<"0\n";
	else cout<<min(min(a*b,b*c),c*a)<<"\n";
}


Measured memory_bytes: 256
#include <stdio.h>
int search(int *A,int n, int x){
  int i=0;
  A[n]=x;
  while(A[i]!=x) i++;
  return i !=n;
}

int main(int argc, char const *argv[]) {
  /* code */
  int i,n1,n2,sum=0,x;
  int A[10000];

  scanf("%d",&n1);
  for(i=0;i<n1;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&n2);
  for(i=0;i<n2;i++){
    scanf("%d",&x);
    if(search(A,n1,x)) sum++;
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 640
N = gets.to_i
p = gets.split.map(&:to_i)
q = p.sort
c = Array.new(N, true)
p.each_with_index do |d,i|
    if d == q[i] then
        c[i] = true
    else
        c[i] = false
    end
end
if c.count(false) <= 2 then
    puts 'YES'
else
    puts 'NO'
end

Measured memory_bytes: 1788
#include<iostream>

int a = 0 , b = 0 , c = 0 , i = 0 , j = 0 ;

int main()
{
	std::cin >> a >> b >> c ;
	for(;i == 0;)
	{
		i = 1 ;
		if(a > b)
		{
			j = a ;
			a = b ;
			b = j ;
			i = 0 ;
		}
		if(b > c)
		{
			j = b ;
			b = c ;
			c = j ;
			i = 0 ;
		}
	}
	std::cout << a << " " << b << " " << c << std::endl ;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

vll dx = {1, 0, -1, 0};
vll dy = {0, 1, 0, -1};

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

    ll a, b, m;
    cin >> a >> b >> m;
    vll x(a), y(b);
    REP(i, a) cin >> x[i];
    REP(i, b) cin >> y[i];
    
    ll p, q, c, res = 1e15;
    REP(i, m) {
        cin >> p >> q >> c;
        p--, q--;
        res = min(res, x[p] + y[q] - c);
    }
    VSORT(x);
    VSORT(y);
    res = min(res, x[0] + y[0]);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define LEN(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
using ll = long long;
using llu = long long unsigned;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vpii = vector<pii>;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod(ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

////////////////////////// Solution starts below. //////////////////////////////

ll n;

int main () {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

	cin >> n;
	if(n%2 == 0) {
		n/=2;
		ll ans = 0;
		ll fiv = 5;
		while(fiv <=
		 n) {
			ans += n/fiv;
			fiv*=5;
		}
		cout << ans << '\n';
	}
	else
		cout << 0 << '\n';

	return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int, vector<int>, greater<int>> que;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
    //que.push(a.at(i));
  }
  vector<ll> sum(n + 1, 0);
  
  sort(a.begin(), a.end());
  for(int i = 0; i < n; i++) {
    sum.at(i + 1) = sum.at(i) + a.at(i);
  }

  vector<vector<int>> b(m, vector<int>(2));
  for(int i = 0; i < m; i++) {
    cin >> b.at(i).at(1) >> b.at(i).at(0);
  }
  sort(b.rbegin(), b.rend());
  int flag = 0;
  ll ans = 0;
  int cnt = 0;
  /*
  for(int i = 0; i < n; i++){
    cout << a.at(i) << " ";
  }
  cout << '\n';
  for(int i = 0; i <= n; i++){
    cout << sum.at(i) << " ";
  }
  cout << '\n';
  */
  for(int i = 0; i < m; i++) {
    if(cnt >= n || a.at(cnt) > b.at(i).at(0)){
      break;
    }
    int lmt = min(n - cnt, b.at(i).at(1)) + cnt;
    if(a.at(lmt - 1) < b.at(i).at(0)) {
      ans += (ll)b.at(i).at(0) * min(n - cnt, b.at(i).at(1));
      ans -= sum[lmt] - sum[cnt];
      //cout << cnt << " " << lmt << " ";
      cnt = lmt;
    } else {
      int border = distance(a.begin(), lower_bound(a.begin(), a.end(), b.at(i).at(0)));
      ans += (ll)b.at(i).at(0) * (border - cnt);
      ans -= sum[border] - sum[cnt];
      //cout << cnt << " " << border << " ";
      cnt = border;
    }
    }
  for(int i = 0; i < n; i++){
    ans += a.at(i);
  }

  /*
  for(int i = 0; i < m; i++) {
    while(b.at(i).at(1) > 0) {
      b.at(i).at(1)--;
      if(que.top() > b.at(i).at(0)) {
        break;
      }
      que.pop();
      //que.push(b.at(i).at(0));
      ans += b.at(i).at(0);
    }
  }

  while(!que.empty()){
    ans += que.top();
    que.pop();
  }
  */

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 6912
#!/usr/bin/python3
# -*- coding: utf-8 -*-



N = int(input())
Hn = list(map(int, input().split()))
dp = [0 for _ in range(N)]
for i in range(1,N):
  if Hn[i-1] >= Hn[i]:
    dp[i] = dp[i-1]+1
print(max(dp))


Measured memory_bytes: 63856
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,ans=1e18;
    scanf("%lld",&n);
    for(int i=1;i<=floor(sqrt(n)+0.5);i++)
        if(n%i==0)
            ans=min(ans,i+n/i);
    printf("%lld",ans-2);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;

int main(void)
{
  int N=0;
  int k=0;
  cin >> N >> k;
  vector<int> A;
  A.resize(N,0);
  int count;
  for(int i=0;i<N;i++)
  {
    cin >> A[i];

  }

  int t=0;
  if(N!=k)
  {
    t =ceil(double(N-1)/(k-1));
  }
  else if(N==k)
  {
    t = 1;
  }
  cout << t;

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N;
	string s;
	cin >> N >> s;
	int x[N+1];
	x[0] = 0;
	for (int i = 0; i < N; i++)
	{
		if(s[i] == 'I')
			x[i + 1] = x[i] + 1;
		else
			x[i + 1] = x[i] - 1;
	}

	cout << *max_element(x, x + N + 1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint k;
    cin >> k;
    lint x, y;
    cin >> x >> y;
    bool flipx = false;
    bool flipy = false;
    if (x < 0) {
        flipx = true;
        x *= -1;
    }
    if (y < 0) {
        flipy = true;
        y *= -1;
    }
    bool sw = false;
    if (x > y) {
        sw = true;
        swap(x, y);
    }
    if (k % 2 == 0 && (x + y) % 2 == 1) {
        cout << -1 << "\n";
        return 0;
    }
    vector<lint> retx, rety;
    lint currx = 0, curry = 0;
    lint nk = ((x + y + k - 1) / k);
    if ((x + y) % 2 == 1 || (k % 2 == 0 && (x + y) % 2 == 0 && nk % 2 == 1 && nk != 1)) {
        lint xadd = min(x, k);
        currx += xadd;
        curry += k - xadd;
        retx.push_back(currx);
        rety.push_back(curry);
        if (curry > y) {
            lint rem = 2 * k - abs(x - currx) - abs(y - curry);
            lint pls = rem / 2;
            retx.push_back(x + pls);
            rety.push_back(curry - (k - (x + pls - currx)));
            retx.push_back(x);
            rety.push_back(y);
            currx = x;
            curry = y;
        }
    }
    while (currx != x || curry != y) {
        if ((abs(x - currx) + abs(y - curry) + k - 1) / k <= 2) {
            lint rem = 2 * k - abs(x - currx) - abs(y - curry);
            lint pls = rem / 2;
            retx.push_back(x + pls);
            rety.push_back(curry + (k - (x + pls - currx)));
            retx.push_back(x);
            rety.push_back(y);
            currx = x;
            curry = y;
        } else {
            lint xadd = min(x - currx, k);
            currx += xadd;
            curry += (k - xadd);
            retx.push_back(currx);
            rety.push_back(curry);

            xadd = min(x - currx, k);
            currx += xadd;
            curry += (k - xadd);
            retx.push_back(currx);
            rety.push_back(curry);
        }
    }

    int s = retx.size();
    for (int i = 0; i < s; ++i) {
        if (sw)
            swap(retx[i], rety[i]);
        if (flipx)
            retx[i] *= -1;
        if (flipy)
            rety[i] *= -1;
    }
    cout << s << "\n";
    // currx = 0, curry = 0;
    for (int i = 0; i < s; ++i) {
        cout << retx[i] << " " << rety[i] << "\n";
        // cout << abs(retx[i] - currx) + abs(rety[i] - curry) << "\n";
        // currx = retx[i];
        // curry = rety[i];
    }
    return 0;
}

Measured memory_bytes: 5604
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)
from collections import deque

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

def delicious(nums, param, m):
    res = 0
    cand = []
    for num in nums:
        tmp = 0
        for nu, pa in zip(num, param):
            # print(((-1)**int(pa)))
            tmp += nu *((-1)**int(pa))
        cand.append(tmp)

    return sum(sorted(cand, reverse=True)[:m])


n, m = getList()

nums = []
for i in range(n):
    nums.append(getList())

ans = 0
for i in range(8):
    param = format(i, "b").zfill(3)
    tmp = delicious(nums, param, m)
    # print(i, param, tmp)
    if ans < tmp:
        ans = tmp

print(ans)

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

using namespace std;

typedef long long int ll;

const ll inf = 1e9;
const ll MAXN = 2e5 + 5;

vector < vector < ll > > adj(MAXN, vector < ll > ());
vector < ll > d(MAXN, inf), a(MAXN);
vector < ll > ans(MAXN, 1);

void dfs(ll u, ll p){
  for(auto to : adj[u]){
    if(to != p){
      ll tmp = -1;
      int j = upper_bound(d.begin(), d.end(), a[to]) - d.begin();
      if(a[to] > d[j - 1] && a[to] < d[j]){
        tmp = d[j];
        d[j] = a[to];
      }
      ll it = lower_bound(d.begin(), d.end(), inf) - d.begin();
      ans[to] = it - 1;
      dfs(to, u);
      if(tmp != -1) d[j] = tmp;
    }
  }
}

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

  ll n;
  cin >> n;
  for(int i = 1; i <= n; i++) cin >> a[i];
  for(int i = 0; i < n - 1; i++){
    ll u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  d[0] = -inf;
  d[1] = a[1];
  dfs(1, -1);

  for(int i = 1; i <= n; i++) cout << ans[i] << endl;
}


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

int main (){
	char s[10];
	cin >> s;
	if(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3]) cout << "No" << endl;
	else if(s[0]==s[1]&&s[2]==s[3]) cout << "Yes" << endl;
	else if(s[0]==s[2]&&s[1]==s[3]) cout << "Yes" << endl;
	else if(s[0]==s[3]&&s[1]==s[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
    return 0;
}

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

class Progaram
{
    static void Main(string[] args)
    {
        var cs = new bool[8].Select(x => false).ToArray();
        int e = 0;
        var n = int.Parse(Console.ReadLine());
        var l = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        foreach (var i in l)
        {
            if (399 >= i) cs[0] = true;
            if (400 <= i && 799 >= i) cs[1] = true;
            if (800 <= i && 1199 >= i) cs[2] = true;
            if (1200 <= i && 1599 >= i) cs[3] = true;
            if (1600 <= i && 1999 >= i) cs[4] = true;
            if (2000 <= i && 2399 >= i) cs[5] = true;
            if (2400 <= i && 2799 >= i) cs[6] = true;
            if (2800 <= i && 3199 >= i) cs[7] = true;
            if (3200 <= i) e++;
        }

        int max, min;
        var ca = cs.Where(x => x).ToArray().Length;
        max = ca + e;
        min = (ca != 0) ? ca : 1;
        Console.WriteLine($"{min} {max}");
    }
}

Measured memory_bytes: 13396
H, W = map(int, input().split())
a = [list(input()) for i in range(H)]

flag_row = [True] * H
flag_col = [True] * W

for i in range(H):
    cnt = 0
    for j in range(W):
        if a[i][j] == '.':
            cnt += 1
    if cnt == W:
        flag_row[i] = False

for j in range(W):
    cnt = 0
    for i in range(H):
        if a[i][j] == '.':
            cnt += 1
    if cnt == H:
        flag_col[j] = False

for i in range(H):
    for j in range(W):
        if flag_row[i] == True and flag_col[j] == True:
            print(a[i][j], end='')
    if flag_row[i] == True:
        print()

Measured memory_bytes: 43756
#include<bits/stdc++.h>
using namespace std;
string s[100000],m;
int main()
{
	long long n,a,b,c,b1,b2;
	cin>>n>>a>>b>>c;
	for(int t=0;t<n;t++)
	{
		cin>>s[t];
	}
	for(int t=0;t<n;t++)
	{
		b1=0;
		b2=0;
		if(s[t]=="AB")
		{
		    if(a<b)
			{
				m+='A';
				a++; 
				b--;
			}
		    else if(a==b)
		    {
		    	if(a==1&&c==0)
		    	{
		    		if(s[t+1]=="AC")
		    		{
		    			m+='A';
		    			a++;
		    			b--;
		    		}
		    		else
		    		{
		    			m+='B';
		    			b++;
						a--;
					}
				}
				else
				{
					m+='A';
					a++;
					b--;
				}
			}
			else
			{
				m+='B';
				b++;
				a--;
			}
		}
		else if(s[t]=="AC")
		{
			b1=0;
			b2=0;
			if(a<c)
			{
				m+='A';
				a++;
				c--;
			}
			else if(a==c)
			{
				if(a==1&&b==0)
				{
					if(s[t+1]=="AB")
					{
						m+='A';
						a++;
						c--;
					}
					else
					{
						m+='C';
						c++;
						a--;
					}
				}
				else
				{
					m+='A';
					a++;
					c--;
				}
			}
			else
			{
				m+='C';
				c++;
				a--;
			}
		}
		else
		{
			b1=0;
			b2=0;
			if(c<b)
			{
				m+='C';
				c++;
				b--;
			}
			else if(b==c)
			{
				if(b==1&&a==0)
				{
					if(s[t+1]=="AB")
					{
						m+='B';
						b++;
						c--;
					}
					else
					{
						m+='C';
						c++;
						b--;
					}
				}
				else
				{
					m+='B';
					b++;
					c--;
				}
			}
			else
			{
				m+='B';
				b++;
				c--;
			}
		}
		if(a<0||b<0||c<0)
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	for(int t=0;t<n;t++)
	{
		cout<<m[t]<<endl;
	}
	return 0;
}

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

int main()
{
	deque<char> dq;
	string s;
	cin >> s;

	rep(i, s.length()) {
		dq.push_back(s[i]);
	}

	int q;
	cin >> q;
	bool flg = true;

	rep(i, q) {
		int x;
		cin >> x;

		if (x == 1) {
			flg = !flg;
		}
		else {
			int y;
			char z;
			cin >> y >> z;

			if (flg)
			{
				if (y == 1) {
					dq.push_front(z);
				}
				else {
					dq.push_back(z);
				}
			}
			else {
				if (y == 1) {
					dq.push_back(z);
				}
				else {
					dq.push_front(z);
				}
			}
		}
	}

	if (!flg) reverse(dq.begin(), dq.end());

	for (char c : dq) {
		cout << c;
	}

	cout << endl;
}


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

#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define rrange(v) v.rbegin(), v.rend()
#define mod (int)(998244353)
#define inf (int)(5e18)
#define N (int)(2e5 + 10)

using namespace std;

void solve() {
#define ff first
#define ss second

	int n, k;
	cin >> n >> k;
	vector<int> p(n + 1);
	vector<pair<int, int>> seg(k);

	for (auto &it : seg) cin >> it.ff >> it.ss;

	int cur = 0;
	p[0]++, p[1]--;
	for (int i = 0; i < n; i++) {
		cur += p[i];
		cur = (cur + mod) % mod;
		for (auto &it : seg) {
			if (i + it.ff < n) {
				int &st = p[i + it.ff];
				int &en = p[min(n, i + it.ss + 1)];
				st += cur;
				st = (st + mod) % mod;
				en -= cur;
				en = (en + mod) % mod;
			}
		}
	}

	cout << cur << endl;
}
// Remember to clear the global containers

// Got stuck and want to leave ? look at the bottom once..
int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
	// cin >> t_c;
	while (t_c--)
		solve();
}
/* Come on Dude .. Dont get up until u get the solution
 * Giving up not gonna help ryt ? So get ur lazy ass to code already
 * You can do it ... Stay Calm and Dont Panic :)
 */


Measured memory_bytes: 4756
#include <iostream>
//using namespace std;
 //Compiler version g++ 6.3.0

using namespace std;

 int main()
 {
 	int a,b;
 	cin >> a>>b;
 
 	cout << a/b <<" "<<a%b<< " "<<fixed<< (double)a/(double)b;
 	
 	return 0;
 }



Measured memory_bytes: 3296
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	cout << a / b << endl;
	cout << a % b << endl;
	double c, d; c = a; d = b;
	cout << fixed << setprecision(6) << c / d << endl;
	return 0;
}


Measured memory_bytes: 3300
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int en[120];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); ++i)
		en[s[i] - 'a'] = 1;
	if (s.size() < 26) {
		for (int j = 0; j < 26; ++j)
			if (!en[j]) {
				s += (char)('a' + j);
				break;
			}
		cout << s << "\n";
	}
	else {
		int now = s.size() - 1;
		while (now > 0 && s[now - 1] > s[now])
			--now;
		if (now == 0) {
			cout << -1 << "\n";
		}
		else {
			for (int j = now; j < s.size(); ++j)
				en[s[j] - 'a'] = 0;
			s.resize(now);
			int cur = s.back() + 1 - 'a';
			while (en[cur])
				++cur;
			s.back() = 'a' + cur;
			cout << s << "\n";
		}
	}
	return 0;
}




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

n, c = [int(x) for x in input().split()]

d_list = [[int(x) for x in input().split()] for _ in range(c)]
c_ = [[int(x) for x in input().split()] for _ in range(n)]

mod_0 = [0] * c
mod_1 = [0] * c
mod_2 = [0] * c

for i in range(n):
    for j in range(n):
        if (i + j) % 3 == 0:
            m = mod_0
        elif (i + j) % 3 == 1:
            m = mod_1
        else:
            m = mod_2
        for k in range(c):
            m[k] += d_list[c_[i][j] - 1][k]

ans = 10 ** 18

for i in range(c):
    for j in range(i + 1, c):
        for k in range(j + 1, c):
            a = mod_0[i] + mod_1[j] + mod_2[k]
            b = mod_0[i] + mod_1[k] + mod_2[j]
            c__ = mod_0[j] + mod_1[i] + mod_2[k]
            d = mod_0[j] + mod_1[k] + mod_2[i]
            e = mod_0[k] + mod_1[i] + mod_2[j]
            f = mod_0[k] + mod_1[j] + mod_2[i]
            ans = min(ans, a, b, c__, d, e, f)

print(ans)

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

int main(){
  long long A,B,r,x,tmp;
  cin >> A >> B;
  if(A<B){
    tmp=A;
    A=B;
    B=tmp;
  }
  x=A*B;
  r=A%B;
  while(r!=0){
    A=B;
    B=r;
    r=A%B;
  }
  cout << x/B << endl;
}

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

int main()
{
int N;cin>>N;
vector<int> a(3*N);
for (int i = 0; i < 3*N; i++)
{
    cin >> a.at(i);
}

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

long long sum=0;
for (int i = 3*N-2; i >=N; i -=2)
{
    sum += a.at(i);
}

cout << sum << endl;

}


Measured memory_bytes: 1408