akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>

using namespace std;

static const string DREAM = "dream";
static const string DREAMER = "dreamer";
static const string ERASE = "erase";
static const string ERASER = "eraser";
string S;


bool check(int i, string s) {
  bool rst = false;
  int j = 0;
  //cout << s << endl;

  while (i < S.size() && j < s.size()) {
    if (S[i] == s[j]) {
      i++;
      j++;
    } else {
      break;
    }
  }

  if (s.size() != j)
    return false;
  
  if (i >= S.size()) {
    return true;
  }

  if (S[i] == 'd') {
    rst = check(i, DREAMER);
    if (!rst) { 
      rst = check(i, DREAM);
    }
  } else if (S[i] == 'e') {
    rst = check(i, ERASER);
    if (!rst) {
      rst = check(i, ERASE);
    }
  } else {
    return false;
  }


  return rst;
}

int main() {
  bool rst = false;

  cin >> S;
  
  int i = 0;
  if (S[i] == 'd') {
    rst = check(i, DREAMER);
    if (!rst) { 
      rst = check(i, DREAM);
    }
  } else if (S[i] == 'e') {
    rst = check(i, ERASER);
    if (!rst) {
      rst = check(i, ERASE);
    }
  } else {
    rst = false;
  }
  string srst = (rst) ? "YES" : "NO";

  cout << srst << endl;

  return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int ans = max(a + b, max(2 * a - 1, 2 * b - 1));
    cout << ans << endl;
}


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

int main(void)
{
	unsigned long long a, b, x;
	cin >> a >> b >> x;

	unsigned long long l, r;
	r = b / x + 1;

	l = a / x + 1;
	if(a%x == 0)
		l--;

	cout << r - l << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

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

int main() {
  int a, b, c; cin >> a >> b >> c;
  string ans = "No";
  if (c >= a && c <= b) ans = "Yes";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s,s1;
int main()
{
	cin>>s;
	for(int i=s.size()-1;i>=0;i--)s1+=s[i];
	for(int i=0;i<s1.size();i++)if(s1[i]=='b')s1[i]='d';else if(s1[i]=='d')s1[i]='b';else if(s1[i]=='p')s1[i]='q';else s1[i]='p';
	if(s==s1)cout<<"Yes";else cout<<"No";
}

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

Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

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

func main() {
	scanner.Split(bufio.ScanWords)

	l := nextInt()
	r := nextInt()

	if r-l >= 2018 {
		fmt.Println(0)
	} else {
		min := math.MaxInt32

		for i := l; i < r; i++ {
			if i%2019 == 0 {
				fmt.Println(0)
				return
			}

			for j := l + 1; j <= r; j++ {
				tmp := (i * j) % 2019
				if tmp < min {
					min = tmp
				}
			}
		}

		fmt.Println(min)
	}
}


Measured memory_bytes: 640
def main():
    from sys import stdin
    input = stdin.readline
    from collections import Counter as ct
    from bisect import bisect_left as bl

    n = int(input())
    max_a = sorted(ct(list(map(int, input().split()))).values())
    now_a = [i for i in max_a]
    m = len(max_a)
    cnt = m
    ans = 0
    ans_list = [0]*(n-m)

    for use in range(m, 1, -1):
        rest = ans
        nex = now_a[0]
        while rest:
            val = nex
            start = bl(now_a, val+1)
            nex += 1
            q = max(-1, start-1-rest, bl(max_a, now_a[start-1]+1)-1)
            for i in range(start-1, q, -1):
                now_a[i] += 1
            if now_a[start-1] == 1:
                cnt += start-1-q
            rest -= start-1-q
            if start != m:
                nex = now_a[start]
        while cnt >= use:
            ans += 1
            rest = use
            nex = now_a[-1]
            end = m
            while rest:
                val = nex
                start = bl(now_a, val)
                if start != 0:
                    nex = now_a[start-1]
                end = min(end, bl(now_a, val+1), start+rest)
                for i in range(start, end):
                    now_a[i] -= 1
                if now_a[start] == 0:
                    cnt -= end-start
                rest -= end-start
                end = start
        ans_list.append(ans)
    print(n)
    for i in ans_list[::-1]:
        print(i)


main()

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

int main(){
    int s,w;
    cin >> s >> w;
    if(s > w) cout << "safe" << endl;
    else cout << "unsafe" << endl;
    return 0;
}


Measured memory_bytes: 3592
H = int(input())
count = 0

def attack(h):
    global count
    count += 1
    if h ==1:
        return 0
    if h > 1:
        attack(h // 2)

attack(H)
if H == 1:
    print(1)
else:
    # 完全二分木の接点数
    print(2 ** (count) - 1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
signed main()
{
	int n,d;
	cin>>n>>d;
	int ans=0;
	while (n--){
		int a1,a2;
		cin>>a1>>a2;
		if (a1*a1+a2*a2<=d*d)  ans++;
	}
	cout<<ans;
	re 0;
}


Measured memory_bytes: 3632
/* ex 5_4
   Graku */
#include <stdio.h>
#include <string.h>

int main(void){
    char str[11];
    int ans = 0; //initialized
    scanf("%s", &str); //input

    int temp = 0;
    for (int i = 0; i < strlen(str); ++i) {
        if (str[i] == 'A' || str[i] == 'C' || str[i] == 'G' || str[i] == 'T') {
            temp++;
        }
        else { //reset
            temp = 0;
        }
        if (temp > ans) { //update "ans"
            ans = temp;
        }
    }

    printf("%d\n", ans); //output

    return 0;
}

Measured memory_bytes: 1708
#include<iostream>
#include<math.h>

int a, b, n;
int ans = 0;

int main()
{
	while( std::cin >> a >> b >> n ){
		ans = 0;
		
		a %= b;
		
		while( n-- ){
			ans += ( a * 10 ) / b;
			a = ( a * 10 ) % b;
		}
		
		std::cout << ans << std::endl;
	}

 	return 0;
}

Measured memory_bytes: 1160
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if((a<=c)&&(c<=b)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}


}


Measured memory_bytes: 21716
#include<iostream>
#include<string>
using namespace std;
int main(){
	string str;
	int i,ans=0;
	cin>>str;
	for(i=0;i<str.size();i++)
     {
     	if(str[i]=='C'){
     		ans=1;
		 }
		 if(str[i]=='F'&&ans==1)
		 {cout<<"Yes";
		  return 0;
	 }
}
	 cout<<"No";
	return 0;
}

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

int main()
{
    int H, W, N;
    cin >> H >> W >> N;
    if(H > W) {
        cout << (N/H)+((N%H==0)? 0 : 1) << endl;
    } else {
        cout << (N/W)+((N%W==0)? 0 : 1) << endl;
    }
    return 0;
}

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

#define MAX_N 2000

int N;
int A[MAX_N],B[MAX_N];
int ans[MAX_N],dp[MAX_N][MAX_N];

int main(){
  cin>>N;
  for(int i=1;i<=N;i++){
    cin>>A[i]>>B[i];
    dp[i][i]=A[i];
    ans[i]=ans[i-1]+1;
    int suma=B[i],sumb=B[i-1];
    for(int j=i-1;j>=1;j--){
      int a=min(dp[j+1][i],A[j]-suma);
      int b=min(dp[j][i-1],A[i]-sumb);
      suma+=B[j];
      sumb+=B[j-1];
      dp[j][i]=max(a,b);
      if(dp[j][i]<0)break;
      ans[i]=ans[j-1]+1;
    }
  }
  cout<<ans[N]<<endl;
  return 0;
}

Measured memory_bytes: 8496
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int main(){
    string o,e;
    cin >> o >> e;
    for(int i=0;i < (int)max(o.size(), e.size()); i++){
        if(i < (int)o.size()){
            cout << o[i];
        }
        if(i < (int)e.size()){
            cout << e[i];
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	vector<ll>so;
	for(ll i=2;;i++){
		bool ch=true;
		for(auto itr=so.begin();itr!=so.end();itr++){
			if(i%*itr==0){
				ch=false;
			}
			if(*itr>sqrt(i)){
				break;
			}
		}
		if(ch){		if(i>=n){
			cout << i<<endl;
			return 0;
		}
			so.push_back(i);
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << 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) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int mod=1e9+7,N=100005;
int add(int x,int y)
{
  x+=y;
  if(x>=mod) x-=mod;
  if(x<0) x+=mod;
  return x;
}
int mult(int x,int y)
{
  ll tmp=(ll)x*y;
  if(tmp>=mod) tmp%=mod;
  return tmp;
}
int pow1(int x,int y)
{
  int ans=1;
  while(y)
    {
      if(y&1) ans=mult(ans,x);
      x=mult(x,x);
      y>>=1;
    }
  return ans;
}
int inv(int x)
{
  if(x==0) return 1;
  return pow1(x,mod-2);
}
int f[N],n;
map<int,int> dp[40][100005];
vi v;
int fun(int done,int ind,int m)
{
  if(m==1)
    {
      if(done>n+1) return 0;
      return inv(f[n-done+1]);
    }
  if(done>=n+1) return 0;
  if(ind<0) return 0;
  if(dp[done][ind].count(m)) return dp[done][ind][m];
  int ans=fun(done,ind-1,m);
  int curr=v[ind],cnt=0;
  while(true)
    {
      if(m%curr) break;
      cnt++;
      ans=add(ans,mult(fun(done+cnt,ind-1,m/curr),inv(f[cnt])));
      if(curr>m/v[ind]) break;
      curr*=v[ind];
    }
  return dp[done][ind][m]=ans;
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  f[0]=1;
  rep(i,1,N) f[i]=mult(f[i-1],i);
  int m;
  cin>>n>>m;
  int sq=sqrt(m);
  rep(i,1,sq+1)
    {
      if(m%i==0)
	{
	  if(i!=1) v.pb(i);
	  if(i*i!=m) v.pb(m/i);
	}
    }
  sort(all(v));
  cout<<mult(f[n],fun(1,sz(v)-1,m))<<endl;
  return 0 ;
}


Measured memory_bytes: 216192
N=int(input())

C=[list(map(int,input().split())) for i in range(N)]

C.sort(lambda x:x[1])

S = 0
flag=True
for i in range(N):
    S+=C[i][0]
    if S>C[i][1]:
        flag=False
        break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 90328
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n, m;
  scanf("%d%d",&n,&m);
  int q;
  scanf("%d",&q);
  vi a(q);
  rep(i,q) {
    scanf("%d",&a[i]);
    --a[i];
  }
  reverse(rng(a));
  vvi p(m);
  rep(i,q) {
    p[a[i]].pb(i);
  }
  vi used(m);
  vi r(n);
  int fr = 0;
  bool ok = true; 
  rep(i,q) {
    if (used[a[i]]) continue;
    int k = 0;
    rep(j,sz(p[a[i]])) {
      if (r[k] > p[a[i]][j]) continue;
      r[k] = p[a[i]][j]; ++k;
      if (k >= n) break;
    }
    if (ok && k == n) {
    } else {
      if (fr == a[i]) {
        ok = false;
      } else {
        puts("No");
        return 0;
      }
    }
    used[a[i]] = 1;
    while (fr < m && used[fr]) ++fr;
  }
  puts("Yes");
  return 0;
}







Measured memory_bytes: 6912
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <stack>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

void print_vec(std::vector<int> v) {
    for(auto i : v) {
        cout << i;
    }
    cout << endl;
}

int main() {
    string s;
    cin >> s;
    int i, j;
    i = s.find('C');
    if(i == string::npos) {
        cout << "No" << endl;
        return 0;
    }
    i = s.find('F', i);
    if(i == string::npos) {
        cout << "No" << endl;
        return 0;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    string S;
    cin >> S;

    ll res = 0;

    rep (i, N) {
        if (S[i] == '(') {
            res++;
        } else {
            if (res == 0) {
                cout << "(";
            } else {
                res--;
            }
        }
    }

    cout << S;

    rep (i, res) {
        cout << ")";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10

ll GCD(ll a, ll b) {
	if (b == 0)return a;
	else return GCD(b, a%b);
}


int main() {
	int N, X; cin >> N >> X;
	vector<int>x(N);
	ll D;
	REP(i, N) {
		cin >> x[i];
		x[i] -= X;
		if (x[i] < 0) x[i] = -x[i];
		if (i == 0) {
			D = x[i];
		}
		else D = GCD(D, x[i]);
	}
	print(D);



	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<string.h>
using namespace std;
int main(){
	char b[11];
	char c[11];
	char d[22];
	int n,i,j,m,ans=0,s,check=0;
	cin>>b;
	int cut=strlen(b);
	cin>>n;
	for(i=0;i<n;i++){
		check=0;
		s=0;
		cin>>c;
		strcpy(d,c);
		strcat(d,c);
		for(j=0;j<20;j++){
			if(d[j]==b[s]){
				check=1;
				s++;
				if(s==cut){
					ans++;
					break;
				}
			}
			else{
				check=0;
				s=0;
				if(d[j]==b[s])s++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3076
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    private static int[][] KUMIAWASE = new int[10][3];
    static {
        KUMIAWASE[0] = new int[] {0, 1};
        KUMIAWASE[1] = new int[] {0, 1, 2};
        KUMIAWASE[2] = new int[] {1, 2, 3};
        KUMIAWASE[3] = new int[] {2, 3, 4};
        KUMIAWASE[4] = new int[] {3, 4, 5};
        KUMIAWASE[5] = new int[] {4, 5, 6};
        KUMIAWASE[6] = new int[] {5, 6, 7};
        KUMIAWASE[7] = new int[] {6, 7, 8};
        KUMIAWASE[8] = new int[] {7, 8, 9};
        KUMIAWASE[9] = new int[] {8, 9};
    }

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int K = scanner.nextInt();

        Queue<Long> queue = new ArrayDeque<>();
        queue.add(1L);
        queue.add(2L);
        queue.add(3L);
        queue.add(4L);
        queue.add(5L);
        queue.add(6L);
        queue.add(7L);
        queue.add(8L);
        queue.add(9L);

        for (long i = 1; i <= K; i++) {
            long poll = queue.poll();
            if (i == K) {
                System.out.println(poll);
                return;
            }
            int value = (int) (poll % 10);
            for (int j : KUMIAWASE[value]) {
                queue.add(poll * 10 + (long)j);
            }
        }
    }
}

Measured memory_bytes: 30420
#include<stdio.h>


int main(void){
	int m,n;
	
	for(m = 1; m < 10; ++m){
		for(n = 1; n < 10; ++n){
			printf("%dx%d=%d\n" ,m ,n ,m * n);
		}
	}
	return 0;
}
	

Measured memory_bytes: 524
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [n, m, c] <- readInts
  bs <- readInts
  inputs <- readNInts n
  print $ solve n m c bs inputs

solve n m c bs inputs = sum $ map decide inputs
  where
    decide as = if ((sum $ zipWith (*) as bs) + c) > 0 then 1 else 0

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
// #define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main(){
    int n; cin>>n;
    int crown_cnt=0;
    map<int,int> rating;
    rep(i,0,n){
        int rate; cin>>rate;
        rep(j,0,8){
            if(j*400<=rate and rate<=(j+1)*400-1){
                rating[j]++;
            }
        }
        if(rate>=3200) crown_cnt++;
    }
    cout<<max(1,(int)rating.size())<<" "<<crown_cnt+(int)rating.size()<<endl;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if((a + b + c) < 22)
    {
        cout << "win" << endl;
    }
    else
    {
        cout << "bust" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<queue>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int i,j,k,h,w,dp[12][12],c[210][210];
  scanf("%d %d\n",&h,&w);
  for(i=0;i<10;i++){
    for(j=0;j<10;j++){
      scanf("%d ",&dp[i][j]);
    }
    scanf("\n");
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      scanf("%d ",&c[i][j]);
    }
    scanf("\n");
  }
  for(k=0;k<10;k++){
    for(i=0;i<10;i++){
      for(j=0;j<10;j++){
        dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
      }
    }
  }
  int ans=0;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(c[i][j]==-1 || c[i][j]==1){
        continue;
      }
      ans+=dp[c[i][j]][1];
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int wh[105][105],w,h,dx[2][6]={{0,1,0,-1,-1,-1},{1,1,1,0,-1,0},},
	dy[2][6]={{-1,0,1,1,0,-1},{-1,0,1,1,0,-1},},cnt;
void func(int x,int y){
	int xx,yy,i;
	wh[y][x]=-1;
//	cout<<x<<' '<<y<<endl;
	for(i=0;i<6;i++){
		xx=x+dx[y%2][i]; yy=y+dy[y%2][i];
		if(xx>=0&&yy>=0&&xx<=w+1&&yy<=h+1&&wh[yy][xx]==1) cnt++;
		if(xx>=0&&yy>=0&&xx<=w+1&&yy<=h+1&&wh[yy][xx]==0){
			func(xx,yy);
		}
	}
}
int main(void){
	int i,j;
	cin>>w>>h;
	for(i=0;i<h+2;i++){
		for(j=0;j<w+2;j++) wh[i][j]=0;
	}
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++) cin>>wh[i][j];
	}
	cnt=0;
	func(0,0);
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3416
#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(void){
  int x, a;
  cin >> x >> a;
  if(x < a) cout << 0 << endl;
  else cout << 10 << endl;
  return 0;
}

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

int main() {
    int n, count=0;
    cin >> n;
    vector<int> vec(n);

    for(int i=0; i<n; i++) {
        cin >> vec.at(i);
        
        while(true) {
            if(vec.at(i)%2 != 0) break;
            else {
                vec.at(i) /= 2;
                count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
typedef unsigned long long ull;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	ll f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=350+10,inf=0x3f3f3f3f,mod=1e9+7;
int n;
ll K;
struct Hash_Table{
	static const int mod1=1e4+7;
	int Begin[mod1],Next[maxn*100],e;
	ull to1[maxn*100],to2[maxn*100];
	ull Pw1[maxn],Pw2[maxn];
	vector<pair<ll,ll> > vc[maxn*100];
	void init(){
		memset(Begin,0,sizeof(Begin));
		e=0;
		Pw1[0]=Pw2[0]=1;
		REP(i,1,n) Pw1[i]=Pw1[i-1]*11ull,Pw2[i]=Pw2[i-1]*29ull;
	}
	void insert(ll *a,ll l,ll r){
		ull x=0,y=0;
		REP(i,1,n) x=x*Pw1[1]+a[i],y=y*Pw2[1]+a[i];
		int i=0;
		for(i=Begin[x%mod1];i;i=Next[i])
			if(to1[i]==x && to2[i]==y){
//				cout<<x<<' '<<y<<' '<<to1[i]<<' '<<to2[i]<<endl;
				break;
			}
		if(!i){
			to1[++e]=x;to2[e]=y;
			Next[e]=Begin[x%mod1];
			Begin[x%mod1]=e;
			i=e;
		}
//		cout<<x<<' '<<y<<endl;
//		cout<<i<<' '<<l<<' '<<r<<endl;
		vc[i].push_back(make_pair(l,r));
	}
	int findans(){
		int ans=0;
		for(int l=0;l<mod1;++l)
			for(int i=Begin[l];i;i=Next[i]){
				ll L=0,R=-1;
				sort(vc[i].begin(),vc[i].end());
				REP(j,0,vc[i].size()-1)
					if(vc[i][j].first>R){
						ans=(ans+(R-L+1)%mod)%mod;
						L=vc[i][j].first,R=vc[i][j].second;
//						cout<<ans<<endl;
//						cout<<vc[i][j].first<<' '<<vc[i][j].second<<endl;
//						cout<<L<<' '<<R<<endl;
					}
					else R=max(R,vc[i][j].second);
//				cout<<L<<' '<<R<<endl;
				ans=(ans+(R-L+1)%mod)%mod;
//						cout<<ans<<endl;
				vc[i].clear();
			}
		return ans;
	}
}Hash;
ll a[maxn];
struct point{
	ll b,c;
	bool operator <(const point &rhs) const{
		return c<rhs.c;
	}
}tmp[maxn];
int Minnum(ll x,ll y){
	if(x>y) return inf;
	int num=0;
	DREP(i,59,0){
		if((x&(1ll<<i))!=(y&(1ll<<i))){
			if(x&((1ll<<i)-1)) num++;
			break;
		}
		else num+=(x>>i)&1;
	}
	return num;
}
ll r[maxn];
void add(int p,ll res){
	if(res<0) return; 
	ll Min=tmp[1].b-(1<p);
	REP(i,1,n){
		r[i]=tmp[i].b-(i<p);
		Min=min(Min,r[i]);
	}
	if(Min<0) return;
	REP(i,1,n) r[i]-=Min;
	sort(r+1,r+n+1);
//	REP(i,1,n) printf("%lld%c",r[i],i==iend?'\n':' ');
//	cout<<Min<<' '<<res<<endl;
//	cout<<Min<<' '<<res<<endl;
	Hash.insert(r,max(Min-res,0ll),Min);
}
int main(){
	int T=1;
	while(T--){
		n=read(),K=readll();
		Hash.init();
		REP(i,1,n) a[i]=readll();
		REP(k,0,60){
			REP(i,1,n)
				tmp[i]=(point){a[i]>>k,a[i]&((1ll<<k)-1)};
			sort(tmp+1,tmp+n+1);
			ll l=0;
			for(int i=1,nxt;i<=n;l=tmp[i].c+1,i=nxt+1){
				nxt=i;
				while(nxt<n && tmp[nxt+1].c==tmp[i].c) ++nxt;
				add(i,K-Minnum(l,tmp[i].c)-k);
			}
		}
		printf("%d\n",Hash.findans());
	}
	return 0;
}

Measured memory_bytes: 1664
#include<iostream> 

 using namespace std; 
int main() 
{ 
  int x[5],i,b; 
   for(i=0;i<5;i++){ 
    cin>>x[i]; 
   }
   for(i=0;i<5;i++)
   { 
      if(x[i]==0) 
      { 
        b=i+1; 
        break; 
      } 
    } 
    cout<<b<<endl; 
   return 0;  
}

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


void solve(long long N, long long Y){
    int ans=0;
for(int x=0; x<=N; x++){
for(int y=0; y<=N-x; y++){
    int z=N-x-y;
    if(z<0)continue;
    if(Y==(10000*x+5000*y+1000*z)){
        cout<<x<<" "<<y<<" "<<z<<endl;
        ans++;
}
if(ans==1)break; 
}
if(ans==1)break;
}
if(ans==0)cout<< "-1 -1 -1" <<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long Y;
    scanf("%lld",&Y);
    solve(N, Y);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int mod = 1e9+7;
const int N = 1e6+5;
int a[N];

int main()

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

    int n;

    cin >> n;

	a[n]++;

    for (int i = 2;; i++) {

        if (n%2) n = n*3+1;
        else n/=2;

        if (a[n]) {

            cout << i;
            break;
        }
        else a[n]++;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

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

int main(){
    ll n;
    cin >> n;
    vector<ll> A(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    vector<ll> GCD(n),RGCD(n);
    GCD[0] = A[0];
    for (int i = 1; i < n; i++) {
        GCD[i] = gcd(A[i], GCD[i-1]);
    }
    RGCD[n-1] = A[n-1];
    for (int i = n-2; i >= 0; i--) {
        RGCD[i] = gcd(A[i], RGCD[i+1]);
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if(i==0) ans = max(ans, RGCD[1]);
        else if(i==n-1) ans = max(ans, GCD[n-2]);
        else ans = max(ans, gcd(GCD[i-1], RGCD[i+1]));
    }
    ans = max(ans, GCD[n-1]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<String>();
    println!("{}",if a=="a"||a=="i"||a=="u"||a=="e"||a=="o"{"vowel"}else{"consonant"})
}

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

int main(){
	char ch,ch2;
	cin >> ch >> ch2;
	if(ch=='H') cout << ch2 << endl;
	else{
		if(ch2=='H') cout << 'D' << endl;
		else cout << 'H' << endl;
	}
	return 0;
}

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

int main() {
  vector<vector<int>> vec(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> vec.at(i).at(j);
    }
  }
  int N;
  cin >> N;
  vector<int> bec(N);
  for(int i=0;i<N;i++){
    cin >> bec.at(i);
  }
  bool bingo = false;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<N;k++){
        if(vec.at(i).at(j)==bec.at(k))
          vec.at(i).at(j)=0;
        }
      }
    }
    for(int i=0;i<3;i++){
      if(vec.at(i).at(0)==0&&vec.at(i).at(1)==0&&vec.at(i).at(2)==0)
        bingo = true;
    }
    for(int i=0;i<3;i++){
      if(vec.at(0).at(i)==0&&vec.at(1).at(i)==0&&vec.at(2).at(i)==0)
        bingo = true;
    }
    if(vec.at(0).at(0)==0&&vec.at(1).at(1)==0&&vec.at(2).at(2)==0)
      bingo = true;
    if(vec.at(0).at(2)==0&&vec.at(1).at(1)==0&&vec.at(2).at(0)==0)
      bingo = true;
    
    if(bingo)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;

}


Measured memory_bytes: 768
#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() {
  string s;
  cin >> s;

  bool twoExists = true;
  if (s.find('A') == string::npos) {
    twoExists = false;
  }
  if (s.find('B') == string::npos) {
    twoExists = false;
  }
  cout << (twoExists ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
from sys import stdin


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


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

d = make_divisors(n)
m = len(d)//2

start = [1, 1]
goal = []

if len(d) % 2 == 0:
    goal = [d[m-1], d[m]]
else:
    goal = [d[m], d[m]]

ans = goal[0] + goal[1] - 2

print(ans)


Measured memory_bytes: 3268
package main

import "fmt"

func main() {
	// Code for B - Kagami Mochi
	var N int
	fmt.Scanf("%d", &N)

	answer := make(map[int]int, N)
	var d int
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &d)
		answer[d]++
	}

	fmt.Println(len(answer))
}


Measured memory_bytes: 1840
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        sc.close();
        int r = 0, g = 0, b = 0, ans = 0;
        for (int i = 0; i < n; i++) {
            if (s.substring(i, i + 1).equals("R")) {
                r++;
            } else if (s.substring(i, i + 1).equals("G")) {
                g++;
            } else {
                b++;
            }
            for (int j = i + 1; j < n; j++) {
                int k = j + j - i;
                if (k < n && !s.substring(i, i + 1).equals(s.substring(j, j + 1))
                        && !s.substring(i, i + 1).equals(s.substring(k, k + 1))
                        && !s.substring(j, j + 1).equals(s.substring(k, k + 1))) {
                    ans++;
                }
            }
        }
        System.out.println((long)r * g * b - ans);
    }
}

Measured memory_bytes: 56576
#include <iostream>
 
#define rep(i, b) for(int i = 0; i < b; i++)
 
using namespace std;
 
bool smprm[300001];
 
int main(){
    rep(i,300001){
        if((i%7==1)||(i%7==6))smprm[i] = true;
        else smprm[i] = false;
    }
    smprm[1] = false;
    rep(i,300001){
        if(smprm[i]){
            for(int j = i*2; j < 300001;j += i){
                smprm[j] = false;
            }
        }
    }
    int n;
    while(cin >> n, n != 1){
        cout << n << ':';
        rep(i,n+1){
            if(smprm[i] && n % i == 0) cout << ' ' << i;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1452
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n,x,t;
    cin>>n>>x>>t;
    int z=0;
    while(n>0)
    {
        if(x<n)
        {
            z+=t;
            n=n-x;
        }
        else
        {
            z+=t;
            n=0;
        }
    }
	cout<<z;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

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

  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());

  if(s<t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <map>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;


int main() {

    int X;
    cin >> X;
    int num = X % 100;
    int digit = X / 100;
    int count = 0;
    while(digit>count){
        if(num>5){
            num = num -5;
        }else{
            cout << 1;
            return 0;
        }
        count++;
    }
    cout << 0;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD (1LL<<55)
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


Int n, m, u, v;
Int a,b;
vector<P> edge[55];
Int in[55];
Int pow2_table[55];
Int bitcnt[1 << 22];
Int pow2(Int x){
    if(x == 0)return 1;
    if(pow2_table[x] == 0){
        pow2_table[x] = pow2(x-1) * 2 % MOD;
    }
    return pow2_table[x];
}

bool dfs(int now, int goal, int i, int last = -1){
    if(now == goal){
        return true;
    }
    for(auto p: edge[now]){
        Int to = p.first;
        Int eid = p.second;
        if(to == last)continue;
        if(dfs(to, goal, i, now)){
            in[eid] |= 1 << i;
            return true;
        }
    }
    return false;
}

int main(){
    cin >> n;
    for(int i =0;i < n-1;i++){
        cin >> a >> b;a--,b--;
        edge[a].push_back(P(b, i));
        edge[b].push_back(P(a, i));
    }
    cin >> m;
    for(int i = 0;i < m;i++){
        cin >> u >> v;u--,v--;
        dfs(u, v, i);
    }
    Int ans = pow2(n-1);
    for(int bit = 1;bit < (1 << m);bit++){
        bitcnt[bit] = bitcnt[bit / 2] + bit % 2;
        Int free = n-1;
        for(int eid = 0;eid < n-1;eid++){
            if(in[eid] & bit){
                free--;
            }
        }
        if(bitcnt[bit] % 2 == 1)ans -= pow2(free);
        else ans += pow2(free);
        ans %= MOD;
    }
    if(ans < 0)ans += MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10496
import sys

read = sys.stdin.buffer.read


def main():
    N, M, Q, *LRPQ = map(int, read().split())
    LR = LRPQ[: 2 * M]
    PQ = LRPQ[2 * M :]
    
    A = [[0] * (N + 1) for _ in range(N + 1)]
    for l, r in zip(LR[::2], LR[1::2]):
        A[l][r] += 1

    for i in range(N):
        for j in range(N):
            A[i + 1][j + 1] += A[i][j + 1] + A[i + 1][j] - A[i][j]

    ans = [0] * Q
    for i, (p, q) in enumerate(zip(PQ[::2], PQ[1::2])):
        ans[i] = A[q][q] - A[q][p - 1] - A[p - 1][q] + A[p - 1][p - 1]

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 48548
#include <bits/stdc++.h>
#define nmax 10005
using namespace std;
ifstream f("aranjare3.in");
ofstream g("aranjare3.out");
int a,b,c;
int main()
{
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int n;
vint a(10);
ll sum(int i,ll x){
  if(i==n){
    return (x%2==0);
  }
  return(sum(i+1,x*(a[i]+1))+sum(i+1,x*(a[i]-1))+sum(i+1,x*a[i]));
}
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }
  ll count=0;
  count=sum(0,1);
  cout<<count<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm> 
using namespace std;
int main()
{
	char a[500];
	scanf("%s",a);
	int flag=1;
	if(strcmp(a,"AKIHABARA")==0) 
	{
		printf("YES\n");
		flag=0;
	}
	if(strcmp(a,"AKIHABAR")==0) 
	{
		printf("YES\n");
		flag=0;
	}
	if(strcmp(a,"AKIHABRA")==0) 
	{
		printf("YES\n");
		flag=0;
	}
	if(strcmp(a,"AKIHABR")==0) 
	{
		printf("YES\n");
		flag=0;
	}
	if(strcmp(a,"AKIHBARA")==0) 
	{
		printf("YES\n");
		flag=0;
	}
	if(strcmp(a,"AKIHBAR")==0) 
	{
		printf("YES\n");
		flag=0;
	}
	if(strcmp(a,"AKIHBRA")==0) 
	{
		printf("YES\n");
		flag=0;
	}
	if(strcmp(a,"AKIHBR")==0) 
	{
		printf("YES\n");
		flag=0;
	}
	if(strcmp(a,"KIHABARA")==0) 
	{
		printf("YES\n");
		flag=0;
	}
	if(strcmp(a,"KIHABAR")==0) 
	{
		printf("YES\n");
		flag=0;
	}
	if(strcmp(a,"KIHABRA")==0) 
	{
		printf("YES\n");
		flag=0;
	}
	if(strcmp(a,"KIHABR")==0) 
	{
		printf("YES\n");
		flag=0;
	}
	if(strcmp(a,"KIHBARA")==0) 
	{
		printf("YES\n");
		flag=0;
	}
	if(strcmp(a,"KIHBAR")==0) 
	{
		printf("YES\n");
		flag=0;
	}
	if(strcmp(a,"KIHBRA")==0) 
	{
		printf("YES\n");
		flag=0;
	}
	if(strcmp(a,"KIHBR")==0) 
	{
		printf("YES\n");
		flag=0;
	}
	
	
	if(flag)
	printf("NO\n");
	return 0;
}

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

int main(void){
	int N, ans;
	while(cin >> N){
		for(int i = 0; i < 10; i++){
			if(N & 1){
				ans = 1 << i;
				cout << ans;
				if(N >> 1)
					cout << ' ';
			}
			N >>= 1;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int main() {
	int a, b, c, d;
	
	int e;
	cin >> e;
	a = e / 1000;
	b = (e / 100)%10;
	c = (e / 10)%10;
	d = e % 10;
	
	if (a + b + c + d == 7) {
		cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
	}
	else if (a + b + c - d == 7) {
		cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
	}
	else if (a + b - c + d == 7) {
		cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
	}
	else if (a + b - c - d == 7) {
		cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
	}
	else if (a - b + c + d == 7) {
		cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
	}
	else if (a - b + c - d == 7) {
		cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
	}
	else if (a - b - c + d == 7) {
		cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
	}
	else {
		cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(Void){
  char predict[4];
  char fact[4];
  scanf("%s", predict);
  scanf("%s", fact);
  int count = 0;
  for(int i = 0; i < 3; i++){
    if(predict[i] == fact[i])count++;
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 128
A, B, C, D = map(int, input().split())


def gcd(x, y):
    while y:
        x, y = y, x % y
    return x


def lcm(x, y):
    return x * y // gcd(x, y)


E = lcm(C, D)

res_b = B // C + B // D - B // E
res_a = (A - 1) // C + (A - 1) // D - (A - 1) // E

print((B - res_b) - (A - 1 - res_a))


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

int main() {
  int N;
  cin >> N;
  
  vector<int> point(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> point[i];
    sum += point[i];
  }
  
  sort(point.begin(), point.end());
  
  if (sum % 10) {
    cout << sum << endl;
  } else {
    int i = 0;
    while (i < N) {
      if (point[i] % 10) {
        sum -= point[i];
        break;
      }
      i++;
    }
    if (i == N) {
      cout << 0 << endl;
    } else {
      cout << sum << endl;
    }
  }
  
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>

using lint = int64_t;
using namespace std;

#define rep(i, n) for (lint i = 0; i < (n); ++i)
#define rep1(i, n) for (lint i = 1; i < (n); ++i)
#define repn(i, a, b) for(lint i = (a); i < (b); ++i)
#define Rep(i, n) for (lint i = (n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define cend printf("\n")

using P = pair<int, int>;
using D = pair<double, double>;
//constexpr lint mod = 998'244'353LL;
constexpr lint mod = 1000'000'007LL;
constexpr lint inf = 3LL * mod * mod;
const double Pi = 2.0 * acos(0.0);

template<class T> using prique     = priority_queue<T>;
template<class T> using prique_inv = priority_queue<T, vector<T>, greater<T>>;
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& rhs) { return is >> rhs.first >> rhs.second; }
template<class T, class U>inline ostream& operator<<(ostream& os, const pair<T, U>& rhs) { return os << rhs.first << " " << rhs.second << "\n"; }

constexpr bool pri(lint x) { for (lint i = 2; i * i <= x; ++i) if (x % i == 0) return false; return 1 < x; }

double dis(D a, D b) { return hypot(a.first - b.first, a.second - b.second); }

lint fact[3000000];
void fact_init(lint n) {
	if (3000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
}

lint modpow(lint x, lint n, lint m = mod) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) {
			res *= x;
			if (m <= res) res %= m;
		}
		x *= x;
		if (m <= x) x %= m;
		n >>= 1;
	}
	return res;
}

lint intpow(lint x, lint n) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res *= x;
		x *= x;
		n >>= 1;
	}
	return res;
}

lint comb(lint n, lint r) {
	if (r == 0 || r == n) return 1;
	lint res = fact[n] * modpow(fact[n - r], mod - 2, mod) % mod * modpow(fact[r], mod - 2, mod) % mod;
	return res < 0 ? res + mod : res;
}

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

int main() {
	int l, r, d, cnt = 0;
	cin >> l >> r >> d;
	repn(i, l, r + 1) if (i % d == 0) ++cnt;
	cout << cnt << endl;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("F:/cpp/input.txt", "r", stdin);
    // freopen("F:/cpp/output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N, W;
    cin >> N >> W;
    ll w[N+1], v[N+1], i, j;
    vector < vector <ll> > dp(N+1, vector <ll> (W+1, 0));
    for (i=1;i<=N;i++)
    {
        cin >> w[i] >> v[i];
    }
    for (i=1;i<=N;i++)
    {
        for (j=1;j<=W;j++)
        {
            if (w[i] <= j)
            dp[i][j] = max(dp[i-1][j-w[i]] + v[i], dp[i-1][j]);
            else
            dp[i][j] = dp[i-1][j];
        }
    }
    // for (i=0;i<=N;i++)
    // {
    //     for (j=0;j<=W;j++)
    //     {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[N][W];
    return 0;
}

Measured memory_bytes: 80256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,i,j,sum=0,Min=0x7ffffff;
struct node{
	int a,id;
}d[100100];
long long ans[100100];
bool cmp(node a,node b){
	return a.a==b.a?a.id<b.id:a.a>b.a;
}
int min(int x,int y){
	return x<y?x:y;
}
int main(){scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&d[i].a),d[i].id=i;
	sort(d+1,d+n+1,cmp);
	for(i=1;i<=n;i++){
		j=i+1;
		while(j<=n&&d[j].a==d[i].a) j++;
		j--;
		sum+=j-i+1;
		Min=min(Min,d[i].id);
		ans[Min]+=(long long)(d[i].a-d[j+1].a)*(long long)sum;
		i=j;
	}
	for(i=1;i<=n;i++) printf("%lld\n",ans[i]);
	return 0;
 }

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    
    vector<vector<char>> c(h, vector<char>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> c[i][j];
        }
    }

    int ans = INF;
    for(int i=0; i<(1<<(h-1)); i++){
        //cout << "i = " << i << ", initial cut = ";
        int cut = 0;
        for(int x=0; x<h; x++){
            if((i >> x) & 1) cut += 1;
        }
        //cout << cut << endl;

        // ------
        vector<int> count(h);
        int check = 0, sum = 0, columns = 0;
        for(int y=0; y<w; y++){
            for(int x=0; x<h; x++){
                count[x] += c[x][y] - '0';
                sum += count[x];

                if((i >> x) & 1){
                    check = max(check, sum);
                    sum = 0;
                }
            }
            check = max(check, sum);
            sum = 0;

            if(check > k){
                if(columns == 0){
                    cut = INF;// INF
                    break;
                }

                cut += 1;
                for(int x=0; x<h; x++){
                    //cout << count[x] << " ";
                    count[x] = c[x][y] - '0';
                }
                //cout << endl;
            }

            columns += 1;
            check = 0;
        }
        // ------
        ans = min(ans, cut);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256