akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N;
vector<double> A, B, C;

// 1-indexed BIT (i : [1, len])
template<typename T, int len>
struct BIT
{
    array<T, len + 1> val;
    BIT() { val.fill(0); }
    void add(int pos, T v)
    {
        while (pos > 0 && pos <= len)
        {
            val[pos] += v;
            pos += pos & -pos;
        }
    }
    T sum(int pos)
    {
        T res = 0;
        while (pos > 0)
        {
            res += val[pos];
            pos -= pos & -pos;
        }
        return res;
    }
};


int cnt(const vector<double> &vec)
{
    vector<double> vec_sorted = vec;
    sort(vec_sorted.begin(), vec_sorted.end());
    
    map<double, int> ma;
    REP(i, vec_sorted.size()) ma[vec_sorted[i]] = i + 1;
    
    BIT<int, 40001> bit;
    int ans = 0;
    for (auto v : vec)
    {
        ans += bit.sum(ma[v]);
        bit.add(ma[v], 1);
    }
    return ans;
}

double solve(const vector<double> &A, const vector<double> &B, const vector<double> &C)
{
    using p = pair<double, double>;
    vector<p> info(N);
    REP(i, N) info[i] = p((double)A[i] / B[i], (double)C[i] / B[i]);
    sort(info.begin(), info.end());

    double l = -2E8, r = 2E8;
    while (r - l > 1E-10 and (r - l) > (abs(l) + abs(r)) * 1E-10)
    {
        double c = (l + r) / 2;
        vector<double> vec(N);
        REP(i, N) vec[i] = info[i].second - info[i].first * c;
        if (cnt(vec) > N * (N - 1) / 2 / 2) l = c;
        else r = c;
    }
    return l;
}

int main()
{
    cin >> N;
    A.resize(N);
    B.resize(N);
    C.resize(N);
    REP(i, N) cin >> A[i] >> B[i] >> C[i];

    cout << solve(A, B, C) << " " << solve(B, A, C) << endl;
}


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

int main(){
  int X, Y, Z, n;
  cin >> X >> Y >> Z;
  
  n = X;
  X = Y;
  Y = n;
  
  n = X;
  X = Z;
  Z = n;
  
  cout << X << " " << Y << " " << Z << endl;
}

Measured memory_bytes: 3600
S = input()

tmp = S

def check_rotate(tmp):
  a = tmp[0:len(tmp) // 2]
  b = tmp[len(tmp) // 2:]
  #print(a, b)
  if a == b:
    return len(a) * 2
  else:
    return 0

  
ans = 0
for i in range(1, len(S)-1):
  tmp = S[0:-i]
  if len(tmp) % 2 == 1:
    continue
  check_rotate(tmp)
  ans = max(ans, check_rotate(tmp))
print(ans)

Measured memory_bytes: 3064
M=99;main(n,i,j,k,a,b,c){
	double p=atan(1)*4,X[100],Y[100],x,y;
	for(;scanf("%d",&n),n;printf("%d\n",a)){
		for(i=0;i<n;i++)scanf("%lf,%lf",X+i,Y+i);
		for(a=i=0;i<n;i++){
			for(b=k=0;k<M;k++){
				x=X[i]+cos(p*k/M),y=Y[i]+sin(p*k/M);
				for(c=j=0;j<n;j++){
					if((X[j]-x)*(X[j]-x)+(Y[j]-y)*(Y[j]-y)<1+1e-7)c++;
				}
				if(b<c)b=c;
			}
			if(a<b)a=b;
		}
	}
exit(0);}

Measured memory_bytes: 644
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int mod = 1000000007;

int N,dp[100][3];
char s[2][100];

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

    int i,k;
    for (i=1; i<=N; i++) cin >> s[0][i];
    for (i=1; i<=N; i++) cin >> s[1][i];

    for (i=0; i<3; i++)
        dp[0][i]=1;

    for (i=1; i<=N; i++){
        if (s[0][i]==s[1][i]){
            for (k=0; k<3; k++)
                dp[i][k]=1LL*(3-k)*dp[i-1][1]%mod;
        }
        else{
            if (s[0][i]==s[0][i+1]) continue;
            dp[i][2]=3LL*dp[i-2][2]%mod;
            dp[i][1]=2LL*dp[i-2][2]%mod;
            dp[i][0]=6LL*dp[i-2][2]%mod;
        }
    }

    cout << dp[N][0] << "\n";
    return 0;
}


Measured memory_bytes: 256
import sys
n=1000000
p=[1]*n
p[0]=p[1]=0
for i in range(n):
  if p[i]:
    for j in range(i*2,n,i):
      p[j]=0
for i in range(1,n):
  p[i]+=p[i-1]

for l in sys.stdin:
  print(p[int(l)])



Measured memory_bytes: 44848
#include<stdio.h>
int main()
{
	int a[102]={0},x,n;
	int i,t;
	scanf("%d%d",&x,&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&t);
		a[t]=1;
	}
	i=0;
	while(1)
	{
		if(x-i>=0 && a[x-i]==0)
		{
			printf("%d",x-i);
			break;
		}
		if(x+i<=101 && a[x+i]==0)
		{
			printf("%d",x+i);
			break;
		}
		i++;
	}
	return 0;
}

Measured memory_bytes: 1712
import bisect

def main():    
    n = int(input())
    L = list(int(x) for x in input().split())
    ans = 0
    c = 0
    L.sort()

    for i in range(n-2):
        for j in range(i+1, n-1):
            c = L[i]+L[j]
            l = j
            r = bisect.bisect_left(L, c, lo=l) -1
            ans += (r-l)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).ok();
    let split: Vec<&str> = input.split(' ').collect();

    let w: i32 = split[0].trim().parse().unwrap();
    let h: i32 = split[1].trim().parse().unwrap();

    if 1 <= w && w <= 100 && 1 <= h && h <= 100 {
        println!("{} {}", w * h, 2 * w + 2 * h);
    }
}


Measured memory_bytes: 5032
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int ans=pow(3,n),a[n];
  int f=1;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]%2==0){
      f*=2;
    }
  }
  cout << ans-f << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
int n, m, pre[100001], dis[100001];
vector<int> adj[100001];
priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> q;
bool vis[100001], flag = false;
int main()
{
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        adj[a].pb(b); adj[b].pb(a);
    }
    memset(dis,0x3f,sizeof(dis));
    dis[1] = 0;
    q.push({0,1}); vis[1] = 1;
    while(!q.empty()){
        int cur = q.top().second; q.pop();
        for(int i = 0; i < adj[cur].size(); i++){
            int to = adj[cur][i];
            if(dis[cur]+1 < dis[to]){
                vis[to] = 1;
                pre[to] = cur;
                dis[to] = dis[cur]+1;
                q.push({dis[to],to});
            }
        }
    }
    for(int i = 2; i <= n; i++){
        if(!vis[i])flag = true;
    }
    if(flag){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
        for(int i = 2; i <= n; i++){
            cout << pre[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 11248
N = int(input())
an = list(map(int, input().split()))
four = 0
odd = 0
for a in an:
    if a % 2 == 1:
        odd += 1
    elif a % 4 == 0:
        four += 1
print('Yes' if odd <= four or N//2 == four and -(-N//2) == odd else 'No')


Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define re register
#define inc(i,j,k) for(re int i=j;i<=k;i++)
#define mod 1000000007
#define inv2 500000004
#define int long long
using namespace std;
const int MAXN=200005;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){x=x*10+ch-'0',ch=getchar();}
	return f*x;
}
int x[MAXN],y[MAXN],n,ans;
int dp[4005][4005],fac[8005],inv[8005];
int c(int n,int m){
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
signed main(){
	n=read();
	inc(i,1,n){
		x[i]=read(),y[i]=read();
		dp[2001-x[i]][2001-y[i]]++;
	}
	inc(i,1,4002) inc(j,1,4002) dp[i][j]=(dp[i][j]+dp[i][j-1]+dp[i-1][j])%mod;
	inc(i,1,n) ans=(ans+dp[2001+x[i]][2001+y[i]])%mod;
	fac[0]=1;
	inc(i,1,8000) fac[i]=fac[i-1]*i%mod;
	inv[0]=inv[1]=1;
	inc(i,2,8000) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	inc(i,2,8000) inv[i]=inv[i]*inv[i-1]%mod;
	inc(i,1,n) ans=(ans+mod-c(2*x[i]+2*y[i],2*x[i]))%mod; 
	ans=1LL*ans*inv2%mod;
	printf("%lld",ans);
}

Measured memory_bytes: 128768
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <iomanip>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <cassert>
#include <stack>
#include <climits>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <memory>
#include <functional>
#include <cfloat>
#include <numeric>

#include <atcoder/dsu>
int main() {
	int n, m; std::cin >> n >> m;
	atcoder::dsu dsu(n + 1);
	for (auto i = 0; i < m; ++i) {
		int a, b; std::cin >> a >> b;
		dsu.merge(a, b);
	}
	int count{ 0 };
	for (auto i = 1; i <= n; ++i) {
		if (!dsu.same(i, 0)) {
			dsu.merge(i, 0);
			++count;
		}
	}
	std::cout << count - 1 << '\n';
}

Measured memory_bytes: 3788
#include<iostream>

using namespace std;

int ara[200000];

int main(void)

{
    int n, i, a;
    cin>>n;
    for(i = 2; i <= n; i++){
        cin>>a;
        if(a == i){
            ara[i]++;
        }
        else{
            ara[a]++;
        }
    }
    for(i = 1; i <= n; i++)
        cout<<ara[i]<<"\n";
    return 0;
}

Measured memory_bytes: 3948
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int h, w;
	string s[30][30];
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> s[i][j];
			if (s[i][j] =="snuke") {
				cout << (char)(j + 65) << i + 1 << endl;
			}
		}
	}
}

Measured memory_bytes: 256
s = ["A","T","G","C"]
a = input()
max_size = 0
size = 0
for t in a:
	if t in s:
		size += 1
	else:
		if max_size < size:
			max_size = size
		size = 0
if max_size < size:
	max_size = size

print(max_size)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>


using namespace std;




int main()
{
	int x, y;

	cin >> x >> y;

	int ans = INT_MAX;


	int wayx[4] = { 1,1,-1,-1 };
	int wayy[4] = { 1,-1,1,-1 };
	int cost[4] = { 0,1,1,2 };
	int wx, wy;
	int wkans;

	for (int i = 0; i < 4; i++) {
		wx = x * wayx[i];
		wy = y * wayy[i];

		if (wy - wx < 0)continue;

		wkans = wy - wx;

		wkans += cost[i];

		if (wkans < ans)ans = wkans;




	}

	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int 
 
int main() {
  ll n;
  cin >> n;
  
  vector<ll>v1(n);
  vector<ll>v2(n);
  for(ll i=0;i<n;i++) cin >> v1[i];
  for(ll i=0;i<n;i++) cin >> v2[i];
  
  vector<ll>v;
  for(ll i=1;i<=n;i++) v.push_back(i);
  
  ll ct=1 , a , b;
  
  do{
      if(v==v1) a=ct;
      if(v==v2) b=ct;
      
      ct++;
  }while(next_permutation(v.begin() , v.begin()+n));
  
  cout << abs(a-b);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <iomanip>

using namespace std;

int main() 
{
	double a = 0;
	double b = 0;
	int c = 0;
	double pi = acos(-1);      //円周率を定義
	double S = 0;              //面積
	double L = 0;              //周囲の長さ
	double h = 0;

	cin >> a >> b >> c;

	S = a * b * sin(c * pi / 180) / 2;
	L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(c * pi / 180));
	h = 2 * S / a;

	cout << fixed << setprecision(8) << S << endl;
	cout << fixed << setprecision(8) << L << endl;
	cout << fixed << setprecision(8) << h << endl;

	return 0;
}


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

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

using namespace std;

using ll = long long;

struct UnionFind {
  vector<int> p;
  vector<int> sz;
  UnionFind(int n) {
    p.resize(n, -1);
    sz.resize(n, 1);
  }

  int find(int x) {
    if (p[x] == -1)
      return x;
    else
      return p[x] = find(p[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sz[x] > sz[y]) swap(x, y);
    sz[y] += sz[x];
    p[x] = y;
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x) {
    return sz[find(x)];
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    uf.unite(a, b);
  }
  int ans = 0;
  rep(i, n) {
    ans = max(ans, uf.size(i));
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 4740
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() { // Possible  Impossible 
    input! {
        n: usize, l: i64,
        a: [i64; n]
    }

    let pos = a.iter().tuple_windows().position(|(a, b)| a + b >= l);
    if pos.is_none() {
        println!("Impossible");
        return;
    }
    let pos = pos.unwrap();

    let mut ans = Vec::new();
    for i in 0..pos {
        ans.push(i+1);
    }
    for i in (pos+1..n-1).rev() {
        ans.push(i+1);
    }
    ans.push(pos+1);

    println!("Possible");
    for v in ans {
        println!("{}", v);
    }
}


Measured memory_bytes: 4700
from math import log2
import sys
N, K = [int(x) for x in input().split()]
a = [int(y) for y in input().split()]


def nketame(a, n):
    return (a & (1 << n)) >> n


def f(x):
    return sum([y ^ x for y in a])


if K == 0:
    print(f(0))
else:
    ans = []
    b = 0
    for i in range(int(log2(K))+1, 0, -1):
        # print("i", i)
        c = [nketame(x, i-1) for x in a].count(1)
        if c < N-c:
            bb = b + (1 << (i-1))
        else:
            bb = b
        if bb <= K:
            b = bb
            ans.append(b)
    # print(ans)
    print(f(max(ans)))

    # 全列挙
    # print("true ", max([(x, f(x)) for x in range(K+1)], key=lambda x: x[1]))


Measured memory_bytes: 14620
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<iterator>
#include<math.h>
#include<cstring>
using namespace std;
void lets_play()

{
    char s[1000][1000],temp[1000];
    int i,j,n,l;
    cin>>n>>l;
   for(i=0;i<n;i++)
   {
            cin>>s[i];
   }

    for(i=0;i<n;i++)
   {
       for(j=i+1;j<n;j++)
          {
              if(strcmp(s[i],s[j])>0)
              {
                  strcpy(temp,s[i]);
                  strcpy(s[i],s[j]);
                  strcpy(s[j],temp);
              }
          }
   }

   for(i=0;i<n;i++)
   {
            cout<<s[i];
   }
}

int main()
{
        lets_play();

}


Measured memory_bytes: 3704
#include<stdio.h>
#include<ctype.h>


int main(){
	char str[210];

	fgets(str,sizeof(str),stdin);

	int i;

	for(i=0;i<strlen(str);i++){
		if(islower(str[i]))str[i]=toupper(str[i]);
	}

	for(i=0;i<strlen(str);i++)printf("%c",str[i]);


	return 0;
}

Measured memory_bytes: 524
A,B,C_AB,X,Y = map(int, input().split())
if A+B >= 2*C_AB:
  print(2*C_AB*(min(X,Y)) + min(A,2*C_AB)*(X-min(X,Y)) + min(B,2*C_AB)*(Y-min(X,Y)))
else:
  print(A*X+ B*Y)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s1, s2;
	cin >> s1 >> s2;
	int a1, a2;
	cin >> a1 >> a2;
	string s3;
	cin >> s3;
	if (s3 == s1) {
		a1--;
	}
	else {
		a2--;
	}
	cout << a1 << " " << a2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int selection_sort(int *seq, int length) {
  int temp, mini, count = 0;
  for (int i = 0; i < length - 1; i ++) {
    mini = i;
    for (int j = i + 1; j < length; j ++) {
      if (seq[j] < seq[mini]) {
        mini = j;
      }
    }
    if (mini != i) {
      temp = seq[i];
      seq[i] = seq[mini];
      seq[mini] = temp;
      count ++;
    }
  }
  return count;
}


int main(){
  int N, count;
  int seq[100];
  cin >> N;
  for (int i = 0; i < N; i ++)
    cin >> seq[i];
  count = selection_sort(seq, N);
  for (int k = 0; k < N; k ++)
    cout << seq[k] << ((k == N-1) ? "" : " ");
  cout << endl;
  cout << count << endl;
}



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

typedef long long ll;
using namespace std;

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

	while(true){
		int m,w; cin >> m >> w;
		if(m == 0) break;

		int bm[m],bw[w];
		for (int i = 0;i < m;i++){
			cin >> bm[i];
		}
		for (int i = 0;i < w;i++){
			cin >> bw[i];
		}

		int dp[w+1][1<<m];
		memset(dp,-1,sizeof(dp));
		dp[0][0] = 0;

		for (int i = 0;i < w;i++){
			for (int j = 0;j < (1<<m);j++){
				if(dp[i][j] == -1) continue;
				dp[i+1][j] = max(dp[i][j],dp[i+1][j]);
				for (int k = 0;k < m;k++){
					if(j & (1<<k)) continue;
					int e = abs(bm[k]-bw[i]);
					e = e*e*e - 60*e*e + 900*e;
					int ni = i+1;
					int nj = (j | (1<<k));
					dp[ni][nj] = max(dp[ni][nj],dp[i][j]+e);
				}
			}
		}
		int ans = -1;
		for (int i = 0;i < (1<<m);i++){
			ans = max(ans,dp[w][i]);
		}

		cout << ans << endl;
	}

	return 0;

}



Measured memory_bytes: 3272
n = int(input(''))
s=0
for i in range(1,n+1):
    if i%3==0 and i%5==0:
        s+=0
    elif i%3==0 and i%5!=0:
        s+=0
    elif i%5==0 and i%3!=0:
        s+=0
    else:
        s+=i
 
print(s)

Measured memory_bytes: 9208
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

void In(vvb& a){
	for(int i=0;i<a.size();i++) for(int j=0;j<a.size();j++){
		char c;
		cin>>c;
		if(c=='#') a[i][j]=1;
	}
}

int n,m;
vvb a,b;

int main(){
	cin>>n>>m;
	a=vvb(n,vb(n,0));
	b=vvb(m,vb(m,0));
	In(a);In(b);
	bool ans=0;
	for(int i=0;i<n-m+1;i++) for(int j=0;j<n-m+1;j++){
		bool flag=1;
		for(int I=i;I<i+m;I++) for(int J=j;J<j+m;J++) if(a[I][J]!=b[I-i][J-j]) flag=0;
		if(flag) ans=1;
	}
	if(ans) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a, b := nextInt(), nextInt()
	if a < b {
		fmt.Printf("a < b\n")
	} else if a == b {
		fmt.Printf("a == b\n")
	} else {
		fmt.Printf("a > b\n")
	}

}



Measured memory_bytes: 1080
hito, ame = map(int, input().split())
NeedAme = list(map(int, input().split()))
NeedAme.sort()

ans = 0
total = 0
for i in range(0, hito):
    if ((i != hito - 1) and (total + NeedAme[i] <= ame)) or ((i == hito - 1) and (total + NeedAme[i] == ame )):
        ans += 1
        total += NeedAme[i]
    else:
        break

print(ans)


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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

bool X[N][N];

void init()
{
	for(int i=0;i<N;i++)
	{
		col[i]=FREE;row[i]=FREE;
	}
	for(int i=0;i<N*2-1;i++)
	{
		dpos[i]=FREE;dneg[i]=FREE;
	}
} 

void printBoard()
{
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<N;j++)
		{
			if(X[i][j])
			{
				if(row[i]!=j)return;
			}
		}
	}
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<N;j++)
		{
			cout<<((row[i]==j)?"Q":".");
		}
		cout<<endl;
	}
}

void recursive(int i)
{
	if(i==N)
	{
		printBoard();
		return;
	}
	
	for(int j=0;j<N;j++)
	{
		if(col[j]==NOT_FREE||dpos[i+j]==NOT_FREE||dneg[i-j+N-1]==NOT_FREE)continue;
		
		row[i]=j;col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
		recursive(i+1);
		row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
	}
} 

int main()
{
	init();
	
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<N;j++)X[i][j]=false;
	} 
	
	int k;cin>>k;

	for(int i=0;i<k;i++)
	{
		int r,c;cin>>r>>c;
		X[r][c]=true;
	}
	recursive(0);

}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

	ll a, b, c, d, ans;
	cin >> a >> b >> c >> d;
	ans=max({(ll)a*c, (ll)a*d, (ll)b*c, (ll)b*d});
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3676
while True :
    h, w = map(int, input().split())
    if h == 0 and w == 0 : break
    for j in range(h) :
        for i in range(w) :
            if j % 2 == 0 :
                if i % 2 == 0 :
                    print ('#', end = '')
                else :
                    print ('.', end = '')
            else :
                if i % 2 == 0 :
                    print ('.', end = '')
                else :
                    print ('#', end = '')
            if i == w - 1 :
                print()
    print()



Measured memory_bytes: 7008
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
// C 81
int main(){
    int n, y; cin >> n >> y;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            int c = n-i-j;
            int total = 10000*i + 5000*j + 1000* c;
            if(total==y && c >= 0){
                cout << i << ' ' << j << ' ' << c << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<queue>
#include <cmath>
using namespace std;

int main()
{
  string s;
  cin >>s;
  
  int count =0;
  if (s[0]=='1')count++;
  if (s[1]=='1')count++;
  if (s[2]=='1')count++;
  
  cout << count;
    
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<pair<int,int>>A(N);
  vector<int>p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
    A[i]=make_pair(p[i],i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  for(int i=0;i<N;i++){
	if(i==A[0].second) cout<<A[1].first<<endl;
    else cout<<A[0].first<<endl;
  }
}
  

Measured memory_bytes: 3968
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rep2(i,s,t) for(int i = s; i <= t; ++i)
#define rev(i,n) for(int i = n-1; i >= 0; --i)
#define rev1(i,n) for(int i = n; i > 0; --i)
#define rev2(i,s,t) for(int i = s; i >= t; --i)
#define F first
#define S second
using namespace std;
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 ll = long long;
using pi = pair<int,int>;
using vi = vector<ll>;
using vii = vector<vi>;
int main()
{
  int n; cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];

  vii dp1(n+1, vi(200, 0));
  vi dp2(n+1, 0);
  dp2[0] = 1000;
  rep(i,n) {
    rep(j,200) {
      chmax(dp1[i+1][j], dp1[i][j]);
      chmax(dp2[i+1], j + dp1[i][j] * a[i]);
    }
    chmax(dp1[i+1][dp2[i]%a[i]], dp2[i]/a[i]);
    chmax(dp2[i+1], dp2[i]);
  }
  cout << dp2[n] << "\n";
  return 0;
}


Measured memory_bytes: 3728
N,A,B = map(int,input().split())
X = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    x = X[i]
    y = X[i+1]
    a = (y-x)*A
    if a <= B:
        ans += a
    else:
        ans += B
print(ans)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
#define f(i,j,k) for(int i=j;i<k;i++)
int main(){
    long long n,k,sum=0,j;
    cin>>n;
    cin>>k;
    f(i,0,n){
        cin>>j;
        sum+=min(j*2,(k-j)*2);
    }
    cout<<sum<<endl;
    return 0;
}

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

using ll = long long;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, d; cin >> n >> d;
	double rng = d + d + 1;
	cout << ceil((double)n / rng) << "\n";
	return 0;
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void go(vector<string>& ans)
{
	FOR(i, 0, SZ(ans)) cout << ans[i] << endl;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	if (n == 2)
	{
		cout << -1 << endl;
		return 0;
	}
	
	if (n % 3 == 0)
	{
		vector<string> ans(n, string(n, '.'));
		
		vector<string> three(3);
		three[0] = "a..";
		three[1] = "a..";
		three[2] = ".bb";
		
		for(int i = 0; i < n; i += 3)
			FOR(j, 0, 3) FOR(k, 0, 3)
				ans[i + j][i + k] = three[j][k];
		
		go(ans);
		return 0;
	}
	
	vector<string> four(4);
	four[0] = "aacd";
	four[1] = "bbcd";
	four[2] = "efgg";
	four[3] = "efhh";
	
	vector<string> five(5);
	five[0] = "abb.c";
	five[1] = "a.d.c";
	five[2] = "eedii";
	five[3] = "fjgg.";
	five[4] = "fj.hh";
	
	vector<string> seven(7);
	seven[0] = ".aabcc.";
	seven[1] = "d..b..f";
	seven[2] = "dee...f";
	seven[3] = "...nngh";
	seven[4] = "kk...gh";
	seven[5] = "j.lmm..";
	seven[6] = "j.l..ii";
	
	if (n == 7)
	{
		go(seven);
		return 0;
	}
	
	if (n == 11)
	{
		vector<string> ans(n, string(n, '.'));
		FOR(i, 0, 7) FOR(j, 0, 7)
			ans[i][j] = seven[i][j];
		FOR(i, 0, 4) FOR(j, 0, 4)
			ans[i + 7][j + 7] = four[i][j];
		go(ans);
		return 0;
	}
	
	vector<string> ans(n, string(n, '.'));
	
	FOR(cnt4, 0, n + 1)
	{
		if ((n - cnt4 * 4) % 5 == 0)
		{
			int x = cnt4;
			int y = (n - cnt4 * 4) / 5;
			
			int old_x = x;
			for(int i = 0; i < n && x > 0; i += 4, x--)
				FOR(j, 0, 4) FOR(k, 0, 4)
					ans[i + j][i + k] = four[j][k];
			
			for(int i = 4 * old_x; i < n && y > 0; i += 5, y--)
				FOR(j, 0, 5) FOR(k, 0, 5)
					ans[i + j][i + k] = five[j][k];
			
			go(ans);
			return 0;
		}
	}	
	
	assert(0);
	return 0;
}


Measured memory_bytes: 2304
# include <iostream>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;

    if(a>b)
    {
        cout << "a > b" << '\n';
    }
    else if (a<b)
    {
        cout << "a < b" << '\n';
    }
    else
    {
        cout << "a == b" << '\n';
    }

}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

template<typename T, T mod>
struct modint {
private:
  T x;

public:
  modint(): x((T)0) {}
  modint(T y): x(y >= 0? y % mod: (mod - (-y) % mod) % mod) {}

  T get() {
    return x;
  }

  modint &operator+=(const modint &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }

  modint &operator-=(const modint &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  modint &operator*=(const modint &p) {
    x = x * p.x % mod;
    return *this;
  }

  modint &operator/=(const modint &p) {
    *this *= p.inverse();
    return *this;
  }

  modint operator-() const { return modint(-x); }
  modint operator+(const modint &p) const {return modint(*this) += p; }
  modint operator-(const modint &p) const {return modint(*this) -= p; }
  modint operator*(const modint &p) const {return modint(*this) *= p; }
  modint operator/(const modint &p) const {return modint(*this) /= p; }

  bool operator==(const modint &p) const { return x == p.x; }
  bool operator!=(const modint &p) const { return x != p.x; }

  modint inverse() const {
    T a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    return modint(u);
  }

  modint pow(int e) const {
    T a = 1, p = x;
    while(e > 0) {
      if (e % 2 == 0) {
	p = (p * p) % mod;
	e /= 2;
      } else {
	a = (a * p) % mod;
	e--;
      }
    }
    return modint(a);
  }
};

const long long MOD = 1000000007;

using mi = modint<long long, MOD>;
typedef pair<ll, ll> P;

ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}

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

  int n_zeros = 0;
  map<P, int> mp;
  for (int i = 0; i < n; ++i) {
    ll a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) {
      n_zeros++;
      continue;
    }
    ll g = gcd(a, b);
    a /= g;
    b /= g;
    if (a < 0) {
      a *= -1;
      b *= -1;
    }
    mp[P(a, b)]++;
  }

  mi ans = 1;
  for (auto e: mp) {
    P left = e.first;
    P right = P(-e.first.second, e.first.first);
    if (right.first < 0) {
      right.first *= -1;
      right.second *= -1;
    }
    
    if (mp[left] != -1) {
      mi tmp = 1;
      if (mp[left] > 0) {
	mi one = 2;
	one = one.pow(mp[left]) - 1;
	tmp += one;
      }
      if (mp[right] > 0) {
	mi two = 2;
	two = two.pow(mp[right]) - 1;
	tmp += two;
      }
      mp[left] = -1;
      mp[right] = -1;
      ans *= tmp;
    }
  }
  ans -= 1;
  ans += n_zeros;

  cout << ans.get() << '\n';
  return 0;
}



Measured memory_bytes: 28608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PB push_back
struct out{
    int a,b,c;
};
int q,k,n;
char st[105];
vector<out>ans;
void query(vector<int>x){
    int w=0;
    vector<int>r;
    r.clear();
    n=x.size();
    if(n<=2)return;
    for(int i=0;i<n;i++)w+=x[i];
    if(w==n){
        for(int i=0;i<n;i+=2){
            ans.PB(out{0,k,1});
            k+=2;
        }
        return;
    }
    if(x[0]!=x[1]){
        ans.PB(out{0,k,1});
        k+=2;
        for(int i=2;i<n;i++)r.PB(x[i]);
        query(r);
        return;
    }
    if(x[0]==1){
        ans.PB(out{0,k,0});
        k+=2;
        for(int i=1;i<n;i++)r.PB(x[i]);
        ans.PB(out{1,k,k-1});
        k++;
        r.PB(x[0]);
        query(r);
        return;
    }
    int y=0;
    for(int i=n-1;i>0;i--){
        y+=x[i];
        if(x[i]==1&&n-i<=y*2&&i<=(w-y)*2){
            ans.PB(out{0,k,i-1});
            k+=2;
            ans.PB(out{1,k,k-1});
            k++;
            for(int j=i;j<n;j++)r.PB(x[j]);
            for(int j=0;j<i;j++)r.PB(x[j]);
            query(r);
            break;
        }
    }
}
int main(void){
    scanf("%d",&q);
    while(q--){
        k=0;
        ans.clear();
        vector<int>p;
        scanf(" %s",st);
        n=strlen(st);
        int s=0;
        for(int i=0;i<n;i++){
            if(st[i]=='o'){
                p.PB(1);
                s++;
            }else{
                p.PB(0);
                s--;
            }
        }
        if(s<0){
            printf("-1\n");
            continue;
        }else if(s==0){
            bool t=true;
            for(int i=0;i<n;i+=2){
                if(p[i]==p[i+1])t=false;
                else{
                    ans.PB(out{0,k,1});
                    k+=2;
                }
            }
            if(t==false){
                printf("-1\n");
                continue;
            }
        }else{
            query(p);
        }
        printf("%zd\n",ans.size());
        for(int i=0;i<ans.size();i++){
            if(ans[i].a==0)printf("sprit ");
            else printf("join ");
            printf("%d %d\n",ans[i].b,ans[i].c);
        }
    }
}




Measured memory_bytes: 3248
#include<cstdio>
#include<cstring>
#include<algorithm>
using std::max;
const int MAXN=100010;

struct node{
	int w,s,v;
	bool operator<(const node &rhs)const{
		return w+s<rhs.w+rhs.s;
	}
}a[MAXN];
long long f[MAXN];

int main(){
	int n;scanf("%d",&n);
	int mx=0;
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&a[i].w,&a[i].s,&a[i].v);
		mx=max(a[i].s+a[i].w,mx);
	}
	std::sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		for(int j=a[i].s;j>=0;j--)
			f[a[i].w+j]=max(f[a[i].w+j],f[j]+a[i].v);
	long long ans=0;
	for(int i=0;i<=mx;i++)
		ans=max(ans,f[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
public class Main{
  static int top = 0;
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    int[] stack;

    stack = new int[20];
    for(;sc.hasNext();){
      n = sc.nextInt();
      if(n != 0){
        push(stack, n);
      }else{
        System.out.println(pop(stack));
      }
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }

  private static int pop(int[] stack){
    return stack[--top];
  }

  private static void push(int[] stack, int a){
    stack[top++] = a;
    return;
  }

}

Measured memory_bytes: 17200
// #[proconio::fastout]
fn main() {
    let n: usize = read();
    let mut p: Vec<i64> = (0..n).map(|_| read::<i64>()).collect();
    p.sort();
    let mut resk = HashMap::new();
    let mut not = HashSet::new();
    for &e in &p {
        if not.contains(&e) {
            continue;
        } else {
            match resk.get(&e) {
                Some(_) => {
                    resk.remove(&e);
                    not.insert(e);
                }
                None => {
                    resk.insert(e, 1);
                }
            }
            let mut tmp = e * 2;
            while tmp <= p[n - 1] {
                not.insert(tmp);
                tmp += e;
            }
        }
    }
    println!("{}", resk.len());
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: i64 = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


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

using namespace std;

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))

template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
}

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif



vector<long long> res;
vector<vector<long long>> items;

long long color[200005];

long long dfs(int root,long long  cnt){
    debug(root,cnt);
    res[root]=cnt;
    color[root]=1;

    for(int i=0;i<items[root].size();i++){

        long long item=items[root][i];

        if(color[item]==0){

            dfs(item,cnt+res[item]);
        }
    }

}

void solve()
{
  int n,q;
  cin>>n>>q;

  res.resize(n+1);
  items.resize(n+1);



  for(int i=1;i<=n-1;i++){
    long long u,v;
    cin>>u>>v;
    items[u].push_back(v);
    items[v].push_back(u);
  }


  while(q--){

    long long u,point;
    cin>>u>>point;
    res[u]+=point;
  }

  dfs(1,res[1]);

  for(int i=1;i<=n;i++){
    cout<<res[i]<<" ";
  }

}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 22784
#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() {
  ll n, total = 0, tmp;
  cin >> n;
  vector<ll> a(n + 2), dist(n + 1);
  a[0] = 0;
  rep(i, n) {
    cin >> a[i + 1];
    dist[i] = abs(a[i] - a[i + 1]);
    total += dist[i];
  }
  a[n + 1] = 0;
  dist[n] = abs(a[n] - a[n + 1]);
  total += dist[n];
  // cerr << total << endl;

  rep(i, n) {
    cout << total - (dist[i] + dist[i + 1]) + abs(a[i] - a[i + 2]) << endl;
  }
  return 0;
}


Measured memory_bytes: 2816
#include <iostream>
 
using namespace std;
 
int main() {
    int x,y,i,z;
    cin >> x >> y;
     
    for(i=1;i<=10000;i++){
        if(x==0 && y==0){
            break;
        }
        if(x>y){
        cout << y <<" "<< x<<endl;
        cin >> x >> y;
        
        }
        else{
          cout << x <<" "<< y<<endl;
          cin >> x >> y;
        }
    }
     
}


Measured memory_bytes: 3076
import numpy as np
N, M = map(int, input().split())
list_x = list(map(int, input().split()))
list_x.sort()
list_d = np.diff(list_x)
list_data = list_d.tolist()
if len(list_data) != 0:
    if N >= 2:
        list_data.sort()
        del list_data[-(N-1):]
        print(sum(list_data))
    if N == 1:
        print(sum(list_data))
else:
    print(0)


Measured memory_bytes: 23024
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

using namespace std;

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

	for (int bit = 0; bit < (1 << 4); ++bit) {
		
		string buf="";

		if (bit & 1)buf += 'A';

		buf += "KIH";

		if (bit & 2)buf += 'A';

		buf += "B";

		if (bit & 4)buf += 'A';

		buf += "R";

		if (bit & 8)buf += 'A';

		if (s == buf) {
			cout << "YES" << endl;
			return 0;
		}

	}

	cout << "NO" << endl;

}


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

using namespace std;

int n, x;
int main(){
	while(cin >> n, n){
		int mi = 1 << 30, ma = -1 << 30, res = 0;
		for(int i = 0;i < n;i++){
			cin >> x;
			res += x;
			mi = min(mi, x);
			ma = max(ma, x);
		}
		cout << (res - mi -ma) / (n - 2) << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
  char a[200010],b;
  ll n=0,c[26]={},d;
  for(;cin>>b;){
    a[n++]=b;
    c[b-'a']++;
  }
  d=(n*(n-1))/2+1;
  fr(i,26) d-=(c[i]*(c[i]-1))/2;
  cout<<d<<endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	sum := 0
	for i := 1; i <= n; i++ {
		if i%3 != 0 && i%5 != 0 {
			sum += i
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1760
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Pair> pairs = new ArrayList<>();
		for(int i=0;i<N;i++) {
			Pair pair = new Pair();
			pair.count=i+1;
			pair.value=sc.nextInt();
			pairs.add(pair);
		}
		int tmp=1;
		int count=0;
		for(Pair pair:pairs) {
			if(pair.value==tmp) {
				tmp++;
			}else {
				count++;
			}
		}
		if(tmp==1) {
			System.out.println(-1);
		}else {
			System.out.println(count);
		}
	}

}
class Pair{
	public Integer count;
	public Integer value;
}

Measured memory_bytes: 103336
import Data.List


main = do
  n <- read <$> getLine::IO Int
  xs <- map read . words <$> getLine ::IO [Int]
  let xs_ = sort xs 
  let (m1,m2) = (xs_!!(div n 2-1),xs_!!(div n 2)) 
  mapM_ print $ solve m1 m2 xs

--solve :: Int -> Int -> [Int] -> Int -> [Int] -> [Int]
solve _ _ [] = []
solve m1 m2 (x:xs)  =
  (if x<=m1 then m2 else m1) : solve m1 m2 xs





Measured memory_bytes: 105852
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        scaffold : [isize; n],
    }

    let mut dp = vec![isize::max_value(); n];
    dp[0] = 0;
    for i in 0..n-1 {
        if dp[i] + (scaffold[i+1]-scaffold[i]).abs() < dp[i+1] {
            dp[i+1] = (scaffold[i+1]-scaffold[i]).abs() + dp[i];
        }
        if i != n-2{
            if dp[i] + (scaffold[i+2]-scaffold[i]).abs() < dp[i+2] {
                dp[i+2] = (scaffold[i+2]-scaffold[i]).abs() + dp[i];
            }
        }
    }
    println!("{}", dp[n-1]);
}


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

int main(){
	
    int a, b; cin >> a >> b;
    
    for(int i = max(-1000000, b-a+1); i <= min(1000000,a+b-1); i++) cout << i << " ";
    cout << endl;
    
	return 0;
}


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

int main() {
    long long k,a,b;
    cin>>k>>a>>b;
    
    if(a+2>=b)
        cout<<k+1;
    else {
        long long ans = 1;
        long long movesToA = a-1;
        long long remMoves = k;
        if(movesToA >=remMoves)
            cout<<remMoves + 1<<"\n";
        else {
            ans += movesToA;
            remMoves -= movesToA;
            ans += (b-a)*(remMoves/2);
            ans += remMoves%2;
            cout<<ans<<"\n";
            
        }
            
        
        
        
    }
    
	return 0;
}

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

int main() {
  int N;
  int p = 0;
  int w = 0;
  int g = 0;
  int y = 0;
  cin >> N;
  string s;
  for(int i = 0;i < N;i++){
    cin >> s;
    if(s == "P"){
      p++;
    }
    else if(s == "W"){
      w++;
    }
    else if(s == "G"){
      g++;
    }
    else {
      y++;
    }
  }
  if(p == 0||w == 0||g == 0||y == 0){
    cout << "Three" <<endl;
  }
  else{
    cout << "Four" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define clz 1000000007
#define ll long long
char s[5010];
int f[5010][5010];
int n;
int Max(int p,int q){
	return p>q?p:q;
}
ll qsm(ll x,int k){
	ll ans=1ll;
	while(k){
		if(k&1) ans=ans*x%clz;
		x=x*x%clz;
		k>>=1;
	}
	return ans;
}
int main(){
	scanf("%d%s",&n,s);
	f[0][0]=1;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=i;j++){
			f[i+1][j+1]+=f[i][j]*2;
			f[i+1][j+1]%=clz;
			f[i+1][Max(j-1,0)]+=f[i][j];
			f[i+1][Max(j-1,0)]%=clz;
		}
	}
	int m=strlen(s);
	printf("%lld",qsm(qsm(2,m),clz-2)*f[n][m]%clz);
	return 0;
}

Measured memory_bytes: 96512
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
int n,m,a,b,dist[10000];vector<int>x[10000];
queue<int>Q;
int main(){
	while(true){
		cin>>n>>m;if(n==0 && m==0)break;
		for(int i=0;i<10000;i++)x[i].clear();
		for(int i=0;i<m;i++){cin>>a>>b;x[a].push_back(b);x[b].push_back(a);}
		for(int i=0;i<10000;i++)dist[i]=1000000007;dist[1]=0;Q.push(1);
		while(!Q.empty()){
			int a1=Q.front();Q.pop();
			for(int i=0;i<x[a1].size();i++){
				if(dist[x[a1][i]]>dist[a1]+1){
					dist[x[a1][i]]=dist[a1]+1;
					Q.push(x[a1][i]);
				}
			}
		}
		int cnt=0;for(int i=2;i<=n;i++){if(dist[i]<=2)cnt++;}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 3440
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d, e, k int

	fmt.Scan(&a, &b, &c, &d, &e, &k)

	if a < b && b < c && c < d && d < e {
		if k >= b-a && k >= c-a && k >= d-a && k >= e-a && k >= c-b && k >= d-b && k >= e-b && k >= d-c && k >= e-c && k >= e-d {
			fmt.Print("Yay!")
		} else {
			fmt.Print(":(")
		}
	}

}


Measured memory_bytes: 1828
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

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

int main() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	cout << (-1)*(t - 1);
}


Measured memory_bytes: 3608