akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[52][52][3000] ;
int arr[52];
int n , a;
ll recur(int pos , int nisi , int sum ){
  if(pos==n){
    if((double)sum/nisi==a){
      return 1;
    }
    else
     return 0;
  }
  if(dp[pos][nisi][sum]!=-1){
    return dp[pos][nisi][sum];
  }
  ll way1 =0,way2= 0;
  way1=recur(pos+1,nisi+1,sum+arr[pos]);
  way2=recur(pos+1,nisi,sum);
  dp[pos][nisi][sum]=way1+way2;
  return dp[pos][nisi][sum];
}
int main(){
 cin >> n >> a ;
 for(int i=0;i<n;i++){
    cin >> arr[i];
 }
 memset(dp,-1,sizeof(dp));
 ll res = recur(0,0,0);
 cout << res <<endl;
 return 0;
}

Measured memory_bytes: 66956
n = int(input())
p = [float(x) for x in input().strip().split()]
dp = [[None for i in range(n//2+2)] for j in range(n)]
for i in range(n):
    dp[i][0] =1

for j in range(n//2+2):
    dp[n-1][j] = 0
dp[n-1][0] = 1
dp[n-1][1] = p[n-1]

for i in range(n-2,-1,-1):
    for j in range(1,n//2+2):
        dp[i][j] = p[i]*dp[i+1][j-1]+(1-p[i])*dp[i+1][j]

print(dp[0][-1])

"""
Recursive top down

# def solve(i,k):
#     # print(i,k)
#     if i<=n-1 and k>0 and dp[i][k]:
#         return dp[i][k]
#     if k<=0:
#         # if i not in dp:
#         #     dp[i] ={}
#         # dp[i][k] = 1
#         return 1

#     elif i>n-1:
#         # if i not in dp:
#         #     dp[i] ={}
#         # dp[i][k] = 0
#         return 0
#     elif k>n-i:
#         # if i not in dp:
#         #     dp[i] ={}
#         dp[i][k] = 0

#     else:
#         # if i not in dp:
#         #     dp[i] ={}
#         dp[i][k] = p[i]*solve(i+1,k-1)+(1-p[i])*solve(i+1,k)
#     return dp[i][k]


# print(solve(0,n//2+1))


"""

Measured memory_bytes: 144604
#import sys
#input = sys.stdin.readline
from math import factorial, sqrt
from itertools import permutations
def main():
    N = int( input())
    V = [ tuple( map( int, input().split())) for _ in range(N)]
    ans = 0
    for P in permutations( range(N)):
        for i in range(N-1):
            ans += sqrt( (V[P[i]][0] - V[P[i+1]][0])**2 + (V[P[i]][1] - V[P[i+1]][1])**2)

    print( ans/ factorial(N))
if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main(){
    int n,b,c,d;
    int a[100];
    b = 1;
    d = 0;
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    for(int i = 0;i < n - 1;i++){
        for(int j = 0;j < n - b;j++){
            if(a[j] > a[j+1]){
                c = a[j];
                a[j] = a[j+1];
                a[j+1] = c;
                d = d + 1;
            }
            
        }
        b=b+1;
    }
    for (int i = 0;i < n;i++){
        cout << a[i];
        if(i<n-1){
            cout<<" ";
        }
    }
    cout << endl;
    cout << d<<endl;
}



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

int main(){
    string S;
    cin >> S;

    if ((S[0]==S[1]) || (S[1]==S[2]) || (S[2]==S[3])){
        cout << "Bad" << endl;
    }

    else{
        cout << "Good" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
s_list = []
for i in range(H):
    s = list(input())
    s_list.append(s)

dp = [[0 for _ in range(W)] for _ in range(H)]
dp[0][0] = 1
mod = 10 ** 9 + 7
for i in range(H):
    for j in range(W):
        if s_list[i][j] == "#":
            continue
        if i + 1 < H and s_list[i + 1][j] == ".":
            dp[i + 1][j] += dp[i][j] % mod
        if j + 1 < W and s_list[i][j + 1] == ".":
            dp[i][j + 1] += dp[i][j] % mod
print(dp[H - 1][W - 1] % mod)


Measured memory_bytes: 52384
import sys
import copy
import math
import itertools
import numpy as np
import re

R,G,B,N = [int(c) for c in input().split()]
cnt = 0
for r in range(N//R+1):
    for g in range((N-r*R)//G+1):
        if r*R+g*G <= N and (N-r*R-g*G)%B == 0:
            cnt += 1
print(cnt)

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

typedef long long int LL;
#define REP(n) for(LL i = 0; i < (n); i++)
#define COUT(val) cout << (val) << endl
#define CIN(val) cin >> (val)
#define SORT(vec) sort(vec.begin(), vec.end())
#define SORT_GRE(vec) sort(vec.begin(), vec.end(), greater<LL>())

int main(){
    LL n, h, w;
    cin >> n >> h >> w;
    vector<LL> a(n), b(n);
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        if(a[i] >= h && b[i] >= w) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// This code wrote by chtholly_micromaker(MicroMaker)
#pragma GCC optimize("Ofast,O3,inline")
#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>
#define reg register
#define int long long
#define ALL(x) (x).begin(),(x).end()
#define mem(x,y) memset(x,y,sizeof x)
#define sz(x) (int)(x).size()
#define ln puts("")
#define lsp putchar(32)
#define pb push_back
#define MP make_pair
#define dbg(x) cerr<<">"<<__func__<<"\tLine: "<<__LINE__<<' '<<#x<<": "<<x<<endl
using namespace std;
template <class t> inline void read(t &s){s=0;
reg int f=1;reg char c=getchar();while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c))s=(s<<3)+(s<<1)+(c^48),c=getchar();s*=f;return;}
template<class t,class ...A> inline void read(t &x,A &...a){read(x);read(a...);}
template <class t> inline void write(t x){if(x<0)putchar('-'),x=-x;
int buf[21],top=0;while(x)buf[++top]=x%10,x/=10;if(!top)buf[++top]=0;
while(top)putchar(buf[top--]^'0');return;}
inline void setIn(string s){freopen(s.c_str(),"r",stdin);return;}
inline void setOut(string s){freopen(s.c_str(),"w",stdout);return;}
inline void setIO(string s=""){setIn(s+".in");setOut(s+".out");return;}
template <class t>inline bool checkmin(t&x,t y){if(x>y){x=y;return 1;}return 0;}
template <class t>inline bool checkmax(t&x,t y){if(x<y){x=y;return 1;}return 0;}
inline int lowbit(int x){return x&(-x);}
int f[15];
int w[150][150];
inline void Init()
{
	map<int,int> dr;
	dr[3];
	f[1]=1,f[2]=2;
	for(int i=3;i<=11;++i)
	{
		for(int j=dr[i-1]+1;;++j)
		{
			if(dr.count(j))
				continue;
			reg bool flg=true;
			for(int k=1;k<i;++k)
				if(dr.count(j+f[k]))
				{
					flg=false;
					break;
				}
			if(!flg)
				continue;
			f[i]=j;
			for(int k=1;k<i;++k)
				dr[j+f[k]];
			break;
		}
	}
	return;
}
int idx[15];
signed main(void)
{
	Init();
	int n;read(n);
	for(int i=2;i<=n;++i)
	{
		reg int maxi=0;
		for(int j=1;j<i;++j)
			idx[j]=j;
		do
		{
			reg int sum=0;
			for(int j=1;j<i-1;++j)
				sum+=w[idx[j]][idx[j+1]];
			checkmax(maxi,sum);
		}while(next_permutation(idx+1,idx+i));
		for(int j=1;j<i;++j)
			w[i][j]=w[j][i]=(maxi+1)*f[j];
	}
	for(int i=1;i<=n;++i,ln)
		for(int j=1;j<=n;++j)
			write(w[i][j]),lsp;
	return 0;
}

/*
 * Check List:
 * 1. Input / Output File (USACO and OI and UVa)
 * 2. long long 
 * 3. Special Test such as n=1
 * 4. Array Size
 * 5. Memory Limit (OI) int is 4 and longlong is 8
 * 6. Mod (a*b%p*c%p not a*b*c%p  ,  (a-b+p)%p not a-b )
 * 7. Name ( int k; for(int k...))
 * 8. more tests , (T=2 .. more)
 * 9. blank \n after a case
*/






Measured memory_bytes: 3612
#include <iostream>
using namespace std;
bool isP(int x){
    for(int i=2; i*i<=x; ++i){
        if(x%i == 0) return false;
    }
    return true;
}
int main(){
    int n;
    cin >> n;
    int res = 0;
    for(int i=0; i<n; ++i){
        int x; cin >> x;
        if(isP(x)) res++;
    }
    cout << res << endl;
    return 0;
}


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

using lld = long long int;

lld sqrt(lld x) {
    if (x == 0 || x == 1)
    return x;

    lld i = 1, result = 1;
    while (result <= x) {
      i++;
      result = i * i;
    }

    return i - 1;
}

lld quadratic_equation(lld a, lld b, lld c) {
  lld d = b * b - 4LL * a * c;
  assert(d > 0);

  return (-b + sqrt(d)) / (2 * a);
}

int32_t main() {
  lld n;
  scanf("%lld", &n);

  std::map<lld, int> factors;

  for (lld i = 2; i*i <= n; i++) {
    while (n % i == 0) {
      factors[i]++;
      n /= i;
    }
  }

  if (n > 1) {
    factors[n]++;
  }

  int ans = 0;
  for (auto pair : factors) {
    int qty = pair.second;
    ans += quadratic_equation(1LL, 1LL, qty * -2LL);
  }

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

  return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <math.h>

#define nl '\n'

using namespace std;

char c;

int main(){

    cin >> c;
    c++;
    cout << c;




}

//g++ -std=c++14 comp.cpp -o b; ./b.exe

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007

int main() {
  int N, L;
  cin >> N >> L;
  int taste = N * L + N * (N + 1) / 2 - N;
  int eat;
  if ( L >= 0) {
    eat = L;
  }
  else if (N + L > 0) {
    eat = 0;
  }
  else {
    eat = L + N - 1;
  }

  cout << taste - eat << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
const int MOD = 1000000007;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;

int main(){
    int n;cin >> n;
    int a[1001];for(int i= 2;i<=n;i++){a[i] = 0;}
    //含まれる素数の個数を数えたい
    for(int i = 2;i<=n;i++){
        int b = i;
        for(int j = 2;j<=i;j++){
            while(b % j == 0){
                b/=j;
                a[j] +=1;
            }
        }
    }
    ll sum = 1;
     for(int i =2;i<=n;i++){
        if(a[i]>0) sum *= (a[i]+1);
        sum = sum % MOD;
    }/*for(int i = 1;i<=n;i++){
        cout << a[i] <<" ";
    } cout << endl;*/
    cout << sum << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int64_t> a(n);
    for (auto &it : a) cin >> it;
    
    int64_t ans = 0, x = 0;
    
    for (int i = 0; i < n; i++) {
        ans = (ans + a[i] * x) % mod;
        x = (x + a[i]) % mod;
    }
    cout << ans << "\n";
    return 0;
}


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

typedef long long ll;
ll m = 998244353;
ll n,s;

vector<ll> a;
vector<vector<ll>> dph;
vector<vector<ll>> dpf;

ll h(int x, int s){
	if (s<0||x<0){
		return 0;
	}
	if (dph[x][s]!=-1){return dph[x][s];}
	return dph[x][s]=((h(x-1,s-a[x])+h(x-1,s))+((a[x]==s)?(1):0))%m;;
}

ll f(int x, int s){
	if (s<0||x<0){
		return 0;
	}
	if (dpf[x][s]!=-1){return dpf[x][s];}
	return dpf[x][s]=(f(x-1,s-a[x])+f(x-1,s)+((a[x]==s)?(x+1):0))%m;
}

int main(){
	cin>>n>>s;
	a.resize(n);
	for (int i = 0; i<n; i++){
		cin>>a[i];
	}
	dph.resize(n,vector<ll>(s+1,-1));
	dpf.resize(n,vector<ll>(s+1,-1));
	//h(n-1,s);
	f(n-1,s);
	ll sum = 0;
	for (int i = 0; i<n; i++){
		sum+=f(i,s);
		//cout<<h(i,s)<<endl;
		sum%=m;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 141440
#include <stdio.h>
#define N 200000
#define NIL -1
typedef struct Node {
  int parent;
  int left;
  int right;
} node;

node tree[N];

void preOrder(int u) {
  if (u == NIL) {
    return; 
  }
  printf(" %d", u);
  preOrder(tree[u].left);
  preOrder(tree[u].right);
}
void inOrder(int u) {
  if (u == NIL) {
    return;
  }
  inOrder(tree[u].left);
  printf(" %d", u);
  inOrder(tree[u].right);
  return;
}
void postOrder(int u) {
  if (u == NIL) {
    return;
  }
  postOrder(tree[u].left);
  postOrder(tree[u].right);
  printf(" %d", u);
  return;
}
int main() {
  int n, i, j, left, right, node, rooti;
  for (i = 0; i < N; i++) {
    tree[i].parent = NIL;
    tree[i].left = NIL;
    tree[i].right = NIL;
  }
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &node, &left, &right);
    tree[node].left = left;
    tree[node].right = right;
    if (left != NIL) {
      tree[left].parent = node;
    }
    if (right != NIL) {
      tree[right].parent = node;
    }
  }
  for (i = 0; i < n; i++) {
    if( tree[i].parent ==  NIL ) {
      rooti = i;
    }
  }
  printf("Preorder\n");
  preOrder(rooti);
  printf("\nInorder\n");
  inOrder(rooti);
  printf("\nPostorder\n");
  postOrder(rooti);
  printf("\n");
  return 0;
}

Measured memory_bytes: 2960
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, L;
    cin >> N >> L;
    vector<int> a(N);
    for (int i = 0; i < N; i++) { a[i] = L + i; }
    int sum = accumulate(a.begin(), a.end(), 0);
    int minE = INF;
    int minus = INF;
    for (int ai : a) {
        if (abs(ai) < minE) {
            minE = abs(ai);
            minus = ai;
        }
    }
    sum -= minus;
    cout << sum << '\n';
}


Measured memory_bytes: 256
N,A[999][1000],id[1000],used[1000];
i,j;day;flag=2;
main(){
	for(scanf("%d",&N);i<N;++i)for(j=0;j<N-1;)scanf("%d",A[j++]+i);
	for(;flag&2;)
		for(flag=1,i=!++day;i<N;++i)
			used[i]<day&&id[i]<N-1&&used[flag&=2,j=A[id[i]][i]-1]<day&&id[j]<N-1&&A[id[j]][j]==i+1&&++id[used[i]=used[j]=day,++id[i],flag=2,j];
	printf("%d",flag*day-1);
}

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

int N, A[105], dp[105][10005];

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d", &A[i]);
	dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= 10000; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j - A[i - 1] >= 0) dp[i][j] = max(dp[i][j], dp[i - 1][j - A[i - 1]]);
		}
	}
	int ans = 0;
	for (int i = 0; i <= 10000; i++) if (dp[N][i] && i % 10 != 0) ans = max(ans, i);
	printf("%d\n", ans);
}


Measured memory_bytes: 4352
package main

import (
        "fmt"
)

func solution(n, m int, ab [][]int) []int {
        out := make([]int, n)

        for i := range ab {
                out[ab[i][0]-1]++
                out[ab[i][1]-1]++
        }
        return out
}

func main() {
        var n, m int
        fmt.Scan(&n, &m)
        ab := make([][]int, m)
        for i := range ab {
                ab[i] = make([]int, 2)
                fmt.Scan(&ab[i][0], &ab[i][1])
        }
        for _, v := range solution(n, m, ab) {
                fmt.Println(v)
        }
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<set>
using namespace std;
int main(){
  int n;
  string a,b;
  set<string> st;
  cin>>n;
  while(n--){
    cin>>a>>b;
    if(a=="insert")st.insert(b);
    if(a=="find"){
      if(st.find(b)==st.end())cout<<"no"<<endl;
      else cout<<"yes"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 32452
#include <iostream>
#include <set>
#include <utility>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    using ll = long long;

    int n;
    cin >> n;

    vector<int> h(n);

    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    
    vector<ll> a(n);

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

    set<pair<int, ll>> s;

    s.insert({0, 0});

    for (int i = 0; i < n; i++) {
        auto it = s.lower_bound({h[i], 0});
        --it;

        it = s.insert({h[i], a[i] + it->second}).first;

        while (true) {
            auto nxt = next(it);

            if (nxt == s.end()) {
                break;
            }

            if (it->second > nxt->second) {
                s.erase(nxt);
            } else {
                break;
            }
        }
    }

    cout << s.rbegin()->second << endl;
}


Measured memory_bytes: 15104
#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) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}


int main(){
    int n;cin >> n;
    set<int> d;
    rep(i,n){
        int tmp;
        cin >> tmp;
        d.insert(tmp);
    }

    cout << d.size() << endl;
    return 0;
}

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



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }

    ll mod = 1e9+7;
    ll cnt[3]={};
    ll ans = 1;
    for(int i=0;i<n;i++){
        ll now = 0;
        for(int j=0;j<3;j++){
            if(cnt[j]==a[i]) now++;
        }
        ans *= now;
        ans %= mod;
        for(int j=0;j<3;j++){
            if(cnt[j]==a[i]){
                cnt[j]++;
                break;
            }
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    int M, K;
    cin >> M >> K;
    if (K > (1 << M) - 1) {
        cout << -1 << "\n";
        return 0;
    }
    else if (M == 1 && K >= 1) {
        cout << -1 << "\n";
        return 0;
    }

    if (M == 1 && K == 0) {
        vec<int> ans = {1, 1, 0, 0};
        range(i, 0, 3) {
            cout << ans.at(i) << " ";
        }
        cout << ans.at(3) << "\n";
        return 0;
    }
    else if (K == 0) {
        range(i, 0, 1 << M) {
            cout << i << " " << i << " ";
        }
        cout << "\n";
        return 0;
    }
    else {
        int p1, p2;  //p1 ^ p2 = K
        range(i, 1, 1 << M) {
            if (i != K) {
                p1 = i;
                p2 = K ^ i;
                break;
            }
        }
        deque<int> ans = {0, p1, p2, 0};
        range(i, 1, 1 << M) {
            if (i != K && i != p1  & i != p2) {
                ans.emplace_front(i);
                ans.emplace_back(i);
            }
        }
        ans.emplace_front(K);
        ans.emplace_back(K);
        ans.emplace_front(p1);
        ans.emplace_back(p2);
        for (auto item : ans) {
            cout << item << " ";
        }
        cout << "\n";
        return 0;
    }
}

Measured memory_bytes: 2944
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
using namespace std;

int A[1000000], n;

int binarySearch(int key) {
    int left = 0;
    int right = n;
    int mid = 0;
    while (left < right) {
        mid = (left + right) / 2;
        if (key == A[mid]) return 1;
        if (key > A[mid]) left = mid + 1;
        else if (key < A[mid]) right = mid;
    }
    return 0;
}

int main()
{
    int i, q, k, sum = 0;

    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);
    
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &k);
        if (binarySearch(k)) sum++;
    }
    printf("%d\n", sum);
}


Measured memory_bytes: 3524
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <cstring>
#include <fstream>

using namespace std;

vector <int> idx[10];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	string s;
	set <string> S;
	

	cin >> n;
	cin >> s;

	for (int i = 0; i < n; i++)
	{
		idx[s[i] - '0'].push_back(i);
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				int pos1 = upper_bound(idx[j].begin(), idx[j].end(), i) - idx[j].begin();
				if (pos1 == idx[j].size())
				{
					continue;
				}
				int idx1 = idx[j][pos1];
				int pos2 = upper_bound(idx[k].begin(), idx[k].end(), idx1) - idx[k].begin();
				if (pos2 == idx[k].size())
				{
					continue;
				}
				int idx2 = idx[k][pos2];
				//cout << s[i] << ' ' << char(j + '0') << ' ' << char(k + '0') << ' ' << i << ' ' << idx1 << ' ' << idx2 << '\n';
				string str;
				str += s[i];
				str += (char)(j + '0');
				str += (char)(k + '0');
				S.insert(str);
			}
		}
	}

	cout << S.size() << '\n';

	return 0;
}

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

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(x-a)>abs(x-b)){
    cout << 'B' << endl;
    return 0;
  }
  cout << 'A' << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  for(int i=0;i<=w+1;i++){
    cout<<'#';
  }
  cout<<endl;
  for(int i=0;i<h;i++){
    string a;
    cin>>a;
    cout<<'#'<<a<<'#'<<endl;
  }
    for(int i=0;i<=w+1;i++){
    cout<<'#';
  }
  cout<<endl;
}

Measured memory_bytes: 764
#include <iostream>

using namespace std;

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

	long long result = 0;
	for(int n = 1; n <= N; n++) {
		const long long num = N / n;
		result += (long long)n * (num * (num + 1) / 2);
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<iostream>
#include<map>
#include<cstdlib>
using namespace std;

map<pair<int,int>,int> mp;
int x[55],y[55];

int N;
int main (){
    cin >> N;
    for(int i=0; i<N; i++) cin >> x[i] >> y[i];
    int ans = 0;
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
            if(i==j) continue;
            int a = x[i] - x[j];
            int b = y[i] - y[j];
            pair<int,int> P = make_pair(a,b);
            ans = max(ans,mp[P]++);
        }
    }
    if(N==1) cout << 1 << endl;
    else cout << N - ans - 1<< endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>
#include <map>
#include <time.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n;
  int t[101];
  cin >> n;
  int r = 0;
  rep(i, 0, n) cin >> t[i], r += t[i];

  int l = t[0];
  r -= t[0];
  int ans = abs(l - r);

  rep(i, 1, n) {
    l += t[i];
    r -= t[i];
    ans = min(ans, abs(l - r));
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<double>vec(n);
  for(int i = 0;i<n;i++) cin >> vec[i];
  double total = 0;
  for(int i = 0;i< n;i++){
    vec[i] = 1/vec[i];
    total += vec[i];
  }
  cout << 1/total << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

void selectionSort(int* mat,int n);

int main(void){
	int* mat;
	int i,n;

	scanf("%d",&n);
	mat=(int* )malloc(n*sizeof(int));

	for(i=0;i<n;i++) scanf("%d",&mat[i]);
	
	selectionSort(mat,n);

	free(mat);
	return 0;
}

void selectionSort(int* mat,int n){
   	int i,j,minj;
   	int temp,count=0;

   	for(i=0;i<n-1;i++){
   		minj=i;
   		for(j=i;j<n;j++){
   			if(mat[j]<mat[minj])	minj=j;
   		}
   		
   		if(mat[i]==mat[minj]) continue;
   		temp=mat[i];
   		mat[i]=mat[minj];
   		mat[minj]=temp;
   		count++;
   	}


    printf("%d",mat[0]);
	for(i=1;i<n;i++)  printf(" %d",mat[i]);
	printf("\n");
    printf("%d\n",count);

}

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

using namespace std;

int main(int argc, char *argv[]) {
    string s;
    cin >> s;

    stack<char> st; 
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (!st.empty()) {
            char top = st.top();
            if (top != s[i]) {
                st.pop();
                ans += 2;
            } else {
                st.push(s[i]);
            }   
        } else {
            st.push(s[i]);
        }   
    }   
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int dis[2005][2005],num[2005],vis[2005],n;
vector<int> edge[2005];
void bfs(int u){
    queue<int> q;
    dis[u][u]=0;
    memset(vis,0,sizeof(vis));
    vis[u]=1;
    q.push(u);
    while(!q.empty()){
        int x=q.front();
        q.pop();
        for(int i=0;i<edge[x].size();i++){
            int v=edge[x][i];
            dis[u][v]=min(dis[u][x]+1,dis[u][v]);
            if(!vis[v]) q.push(v),vis[v]=1;
        }
    }
}
int main(){
    int x,y;
    cin>>n>>x>>y;
    edge[x].push_back(y);
    edge[y].push_back(x);
    for(int i=1;i<n;i++){
        edge[i].push_back(i+1);
        edge[i+1].push_back(i);
    }
    memset(dis,0x3f,sizeof(dis));
    for(int i=1;i<=n;i++){
        bfs(i);
    }
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            num[dis[i][j]]++;
        }
    }
    for(int i=1;i<n;i++){
        cout<<num[i]<<endl;
    }
}

Measured memory_bytes: 16128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s  =new Scanner(System.in);
        int n = s.nextInt(), k = s.nextInt();
        String line = s.next();

        List<Integer> list = new ArrayList<>();

        {
            String line2 = line + "$";
            char c = line2.charAt(0);
            int cnt = 1;
            for (int i = 1; i < line2.length(); ++i) {
                if (c != line2.charAt(i)) {
                    list.add(cnt);
                    cnt = 1;
                    c = line2.charAt(i);
                } else {
                    ++cnt;
                }
            }
        }

        if (line.charAt(0) == '0') {
            list.add(0, 0);

        }
        if (line.charAt(line.length() - 1) == '0') {
            list.add(0);
        }

        int max = 0, cnt = 0;
        for (int i = 0; i < list.size(); ++i) {
            if (i  < k * 2 + 1) {
                cnt += list.get(i);
            } else if (i % 2 != 0) {
                cnt -= list.get(i - k * 2 - 1);
                cnt -= list.get(i - k * 2);
                cnt += list.get(i);
                cnt += list.get(i + 1);
            }
            max = Math.max(max, cnt);
        }
        System.out.println(max);
    }
}


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

int main(){
  int n,m;
  cin >> n >> m;
  int a[m];
  for(int i=0;i<m;i++){
    cin >> a[i];
  }
  sort(a,a+m);
  int b[m-1];
  for(int i=0;i<m-1;i++){
    b[i]=a[i+1]-a[i];
  }
  sort(b,b+m-1);
  int t=max(0,m-n);
  int ans=0;
  for(int i=0;i<t;i++){
    ans=ans+b[i];
  }
  cout << ans << endl;
}
  


Measured memory_bytes: 1024
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    int x=sc.nextInt();
    int[] a=new int[n+1];
    for(int i=0;i<m;i++){
      a[sc.nextInt()]=1;
    }
    for(int i=0;i<n;i++){
      a[i+1]+=a[i];
    }
    System.out.println(Math.min(a[x],a[n]-a[x]));
  }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    // 4(x-a) + 2a = y
    // (4x - y)/2 = a
    for(int i = 0;i<=x;i++)
    if( 4*(x-i) + 2*i == y)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3624
import string

s = input()
n = len(s)
ans = n

for chara in set(s):
    left_max = 0
    right_max = 0
    ri = 0
    temp = 0
    for index, c in enumerate(s):
        if c == chara:
            left_max = max(temp, left_max)
            temp = 0
            ri = index
        else:
            temp += 1
    right_max = n - ri - 1
    ans = min(max(right_max, left_max), ans)
print(ans)


Measured memory_bytes: 3772
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	
	
	while(true)
	    {
		String str=input.readLine();
		if(str.equals("-"))break;
		int n=Integer.parseInt(input.readLine());
		for(int i=0;i<n;i++)
		    {
			int h=Integer.parseInt(input.readLine());
			 str=str.substring(h,str.length())+str.substring(0,h);

		    }
			System.out.println(str);
	    }
    }
}

Measured memory_bytes: 17036
s = input()
q = int(input())
query_list = [list(input().split()) for _ in range(q)]
reverse_flag = False
concat = ''
initial = 0
for query in query_list:
    if query[0] == '1':
        reverse_flag = not reverse_flag
    elif query[0] == '2':
        if (query[1] == '1' and not reverse_flag) or (query[1] == '2' and reverse_flag):
            concat = query[2] + concat
            initial += 1
        elif (query[1] == '2' and not reverse_flag) or (query[1] == '1' and reverse_flag):
            concat = concat + query[2]
ans = ''
if reverse_flag:
    s = s[::-1]
    concat = concat[::-1]
    ans = concat[:-initial]+s+concat[-initial:]
else:
    ans = concat[:initial]+s+concat[initial:]
print(ans)

Measured memory_bytes: 31732
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        a: [i64; n],
        b: [i64; n],
    }
    let mut b = b;
    let mut h = std::collections::BinaryHeap::new();
    for i in 0..n {
        h.push((b[i], i));
    }
    let mut cnt = 0;
    while let Some((_, i)) = h.pop() {
        if b[i] <= a[i] {
            continue;
        }
        let l = (i + n - 1) % n;
        let r = (i + 1) % n;
        let v = b[r] + b[l];
        let max = std::cmp::max;
        let k = (b[i] - max(a[i], max(b[l], b[r])) + v - 1) / v;
        cnt += k;
        b[i] -= k * v;
        if b[i] < a[i] {
            break;
        }
        h.push((b[i], i));
    }
    for i in 0..n {
        if a[i] != b[i] {
            println!("-1");
            return;
        }
    }
    println!("{}", cnt);
}

fn main() {
    run();
}


Measured memory_bytes: 17648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e;
  a=0;
  d=0;
  cin >> a;
  b=a/10;
  b=b%10;
  c=a/100;
  c=c%10;
    a=a%10;
  if(a==7){d=1;}
  if(b==7){d=1;}
  if(c==7){d=1;}
  if(d==1){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
}

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

using namespace std;

long long xorxor(long long val){
	long long ret=((val+1)/2)%2;
	for (int i=0;i<=59;i++) 
	    if ((val>>i)%2) 
		    ret|=(1^(val%2))<<i;
	return ret;
}

int main(){
	long long a,b;
    cin>>a>>b;
	long long ans=xorxor(b);
	if (a)
		ans^=xorxor(a-1);

	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto N = RD!long;
	auto M = RD!long;
	auto X = RDR.split.to!(long[]);
	X.sort();
	
	auto interval = new long[](M-1);
	foreach (i; 0..M-1)
	{
		interval[i] = abs(X[i+1] - X[i]);
	}
	interval.sort();

	auto cnt = max(0, M - N);

	writeln(interval[0..cnt].sum);
	stdout.flush();
}

Measured memory_bytes: 4232
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...) 42
#endif
#define y0 y12345
#define y1 y54321
typedef unsigned long ul;
typedef long long ll;
//typedef pair<int, int> mpair;
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(a>b){a=b;return 1;}return 0;}
using namespace std;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n,m;cin>>n;
	if(n<=2){
		cout << 1 << endl;
		return 0;
	}
	int x[n], y[n];
	vector<pair<int, int>> p;
	rep(i, n){
		cin>>x[i]>>y[i];
	}
	rep(i, n-1){
		for(int j = i+1; j < n;j++){
			int a=x[i]-x[j], b=y[i]-y[j];
			if(a > 0){
				p.push_back(make_pair(a, b));
			}else if(a < 0){
				p.push_back(make_pair(-1*a, -1*b));
			}else{
				p.push_back(make_pair(0, abs(b)));
			}
		}
	}
	sort(p.begin(), p.end());
	int ma = 0;
	int tx=p[0].first, ty=p[0].second;
	int counter = 0;
	rep(i, p.size()){
		cerr<<p[i].first << p[i].second << endl;
	}
	for(int i = 1;i < p.size(); i++){
		if(p[i].first==tx&&p[i].second==ty){
			counter++;
		}else{
			chmax(ma, counter);
			tx=p[i].first;ty=p[i].second;
			counter=0;
		}
	}chmax(ma, counter);
	cout<<n-ma-1<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.function.BiConsumer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			String s = in.next();
			int count = 1;
			for (int i = 1; i < n; i++) {
				if (s.charAt(i) != s.charAt(i - 1)) {
					count++;
				}
			}
			out.println(count);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 25172
#include <iostream>
#include <cmath>

const int nax = 1e5+5;
int arr[nax];
int dp[nax];

int main() {

	std::ios_base::sync_with_stdio(false);

	int N;
	std::cin >> N;

	for (int i=1; i<=N; i++) {
		std::cin >> arr[i];
	}

	dp[1] = 0;
	dp[2] = abs(arr[2]-arr[1]);

	for (int i=3; i<=N; i++) {
		dp[i] = std::min(
			dp[i-2]+abs(arr[i]-arr[i-2]),
			dp[i-1]+abs(arr[i]-arr[i-1])
		);
	}

	std::cout << dp[N] << "\n";

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int r = N%10;
  if ( r==3){
    cout << "bon" << endl;
  }
  else if ( r==0 || r==1 || r==6 || r==8){
    cout << "pon" << endl;
  }
  else {
    cout << "hon" << endl;
  }
}

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

vector<int> to[200005];
vector<int> ans;

void def(int v, int p=-1) {
    for (int u : to[v]) {
        if (u == p) continue;
        ans[u] += ans[v];
        def(u,v);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    rep(i,q) {
        int p, x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
    def(0);
    rep(i,n) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 23552
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef gp_hash_table < int, int > fast;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

void test();

int main() {
    fast_io();
    cout << fixed << setprecision(15);
    test();
    return 0;
}

void test() {
    string s;
    cin >> s;
    map < char, int > cnt;
    for (auto &x: s) {
        ++cnt[x];
    }
    if (cnt.size() == 2) {
        for (auto &x: cnt) {
            if (x.S != 2) {
                cout << "No\n";
                return;
            }
        }
        cout << "Yes\n";
        return;
    }
    cout << "No\n";
}


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

string S; int c1 = 0, c2 = 0, n;

int main() {
	cin >> n >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'R') c1++;
		else c2++;
	}
	if (c1 > c2) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<string.h>

using namespace std;




int main()
{
	long int n,m,l,a[105][105],b[105][105];//n*m,m*l,????????????,n*l
	while(cin>>n>>m>>l)
	{//?????\?¬¬????????°???
		for(int i=1;i<=n;i++)
			for(int k=1;k<=m;k++)
				cin>>a[i][k];
			
		//?????\?¬¬????????°???
		for(int i=1;i<=m;i++)
			for(int k=1;k<=l;k++)
				cin>>b[i][k];
		//????????????
		long int c[105][105];//?????????0
		memset(c,0,105*105*sizeof(int));
		for(int i=1;i<=n;i++)
			{
				
				for(int j=1;j<=l;j++)
			
			for(int k=1;k<=m;k++)
				c[i][j]+=a[i][k]*b[k][j];
		
		
		
		
		
		
		}
	
	for(int i=1;i<=n;i++)
		for(int k=1;k<=l;k++)
			{
				cout<<c[i][k];
				if(k!=l)
		cout<<" ";
				if(k==l)
					cout<<endl;
		
		
		}
	




	
	
	
	
	
	
	
	}



}

Measured memory_bytes: 3372
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Reflection.Emit;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var k = int.Parse(spl[1]);
        var aa = ToIntArray(input.ReadLine(), n);

        int kk = 0;

        var sb = new StringBuilder();

        for(int i=0; i<n; i++) {
            if(kk >= k) {
                if(aa[i-k] < aa[i]) {
                    sb.AppendLine(Yes);
                } else {
                    sb.AppendLine(No);
                }
            }
            kk++;
        }

        return sb;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        if (n == 0) return ret;
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int H, W; scanf("%d %d", &H, &W);
  int N = 10;
  vector<vector<int>> C(N, vector<int>(N, 0));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      scanf("%d", &C[i][j]);
    }
  }
  for (int k = 0; k < N; ++k) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
      }
    }
  }

  int ans = 0, a = 0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      scanf("%d", &a);
      if (a == -1) { continue; }
      ans += C[a][1];
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]
x = True
c = 0
for i in range(n):
    if i > 0 and h[i - 1] - h[i] >= 2:
        x = False
        break
    elif i > 0 and h[i - 1] - h[i] == 1:
        c += 1
    elif i > 0 and h[i] > h[i - 1] and c == 1:
        c = 0
    if c == 2:
        x = False
        break
if x:
    print("Yes")
else:
    print("No")

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int tmp;
  int ans = 760;
  for (int i = 0; i < (n-2); ++i){
    tmp = (s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
    ans = min(ans, abs(tmp-753));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>

int main() {
    std::string s;
    std::cin >> s;

    int b;
    int e;
    bool f1 = true;
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'A' & f1) {
            b = i;
            f1 = false;
        }

        if(s[i] == 'Z') {
            e = i;
        }
    }

    std::cout << e - b + 1 << "\n";
}

Measured memory_bytes: 3688
<?php
  
$s = trim(fgets(STDIN));
$ans = 'AC';

if ($s[0] !== 'A') $ans = 'WA';
if ($s[1] == 'C') $ans = 'WA';
if ($s[strlen($s)-1] == 'C') $ans = 'WA';

$n = str_split($s);
$count = 0;
for($i=2; $i<strlen($s)-1; $i++){
  if ($s[$i] == 'C') {
    $count++;
    $num = $i;
  }
}
if ($count !== 1) {
  $ans = 'WA';
} else {
  unset($n[0]);
  unset($n[$num]);
  array_values($n);
}

if (ctype_lower(implode($n)) == false) 	$ans = 'WA';

echo $ans;
  
?>
  


Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
int j;
int main()
{
  int n;
  cin >>n;
  string s;
  cin >>s;
  int c=0;
  char ch;
  for(int i=0;i<n;i++)
  {
      ch=s[i];
      while(ch==s[i]&&i<n)
      {
          i=i+1;
      }
      i--;
      c=c+1;
  }
cout <<c<<endl;
}


Measured memory_bytes: 512