akhauriyash/Code-Regression huggingface dataset:
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


template <class T>
void print(vector<T> arr)
{
	cout << "start printing the vector\n";
	for (auto u : arr)
		cout << u << " ";
	cout << "\n";
}

template <class T>
void print_mat(vector<vector<T>> a)
{
	cout << "start printing the matrix\n";
	for (auto v : a)
	{
		for (auto e : v)
		{
			cout << e << " ";
		}
		cout << "\n";
	}
}

/******************************************
* NUMBER THEORY ;) *
******************************************/



ll powermod(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}
ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i)
			res = (res * i) % mod;
		n /= mod;
	}
	res %= mod;
	return res;
}



void solve()
{
	set<ll> st;
	ll n, temp;
	cin >> n;
	for (ll i = 0; i < n; i++)
	{
		cin >> temp;
		st.insert(temp);
	}
	if (st.size() == n)
	{
		cout << "YES\n";
	}
	else
		cout << "NO\n";
}

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);
	cout.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
	solve();
	// }

	return 0;
}

Measured memory_bytes: 13016
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int l = sc.nextInt();
		int r = sc.nextInt();
		
		for(int i = l; i <= r; i++)
		{
			if(i%n == 0)
			{
				System.out.println("OK");
				return;
			}
		}
		System.out.println("NG");
	}

}


Measured memory_bytes: 26988
#include <bits/stdc++.h>
using namespace std;
bool z[100011];
int ans[100011];
int n,m;
int main()
{
	cin >>n>>m;
	for(int i=0;i<m;i++)
	{
		int a;
		cin >>a;
		z[a]=true;
	}
	ans[0]=1;
	ans[1]=(int)(!z[1])*1;
	for(int i=2;i<=n;i++)
	if(!z[i])
	ans[i]=(ans[i-1]+ans[i-2])%1000000007;
	cout <<ans[n]<<endl;
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <math.h>
using namespace std;

int main()
{
	int A, B, C, D, E;
	cin >> A >> B >> C >> D >> E;
	int a = A % 10, b = B % 10, c = C % 10, d = D % 10, e = E % 10;
	int m = min(a ? a : 10, min(b ? b : 10, min(c ? c : 10, min(d ? d : 10, e ? e : 10))));
	int ret;

	A += (10 - a) * (a ? 1 : 0);
	B += (10 - b) * (b ? 1 : 0);
	C += (10 - c) * (c ? 1 : 0);
	D += (10 - d) * (d ? 1 : 0);
	E += (10 - e) * (e ? 1 : 0);

	ret = A + B + C + D + E;

	if (m != 0)
		ret = ret - 10 + m;

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, i, tmp;
	int debt = 100000;
	
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		debt = debt * 1.05;
		if (tmp = debt % 1000) {
			debt += 1000;
			debt -= tmp;
		}
	}
	printf("%d\n", debt);
	
	return 0;
}
	

Measured memory_bytes: 592
n = gets.chop.to_i
a1 = gets.chop.split.map(&:to_i)
a2 = gets.chop.split.map(&:to_i)

def ruiseki(array)
  result = []
  array.length.times do |i|
    if i == 0
      result << array[i]
    else
      result << result[i-1] + array[i]
    end
  end
  result
end

ans = 0

sum_a1 = ruiseki(a1)
sum_a2 = ruiseki(a2)


n.times do |i|
    tmp_a1_sum = sum_a1[i]
  if i == 0
    tmp_a2_sum = sum_a2[n-1]
  else
    tmp_a2_sum = sum_a2[n-1]-sum_a2[i-1]
  end

  ans = [tmp_a1_sum + tmp_a2_sum, ans].max
end

puts ans


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

int main() {
  ll X, K, D;
  cin >> X >> K >> D;
  X = llabs(X);
  ll need = X / D;
  ll mini = LLONG_MAX;
  if( need <= K ) {
    X -= ( need * D );
    K -= need;
    if( K % 2LL == 0 ) mini = min(mini,llabs(X));
    rep(_,10) {
      if( K >= 1 ) {
	--K;
	X -= D;
	if( K % 2LL == 0 ) mini = min(mini,llabs(X));
      } else break;
    }
  } else {
    X -= ( K * D );
    mini = X;
  }
  cout << mini << endl;
  return 0;
}


Measured memory_bytes: 3636
while True:
    n=int(input())
    if n==0:
        break
    
    a=[]

    for i in range(n):
        x=input()
        a.append(x)

    for i in range(10):
        x=a.count(str(i))
        if x==0:
            print("-")
    
        else :
            print("*"*x)


Measured memory_bytes: 5700
n, l = map(int, input().split())

k = []

for i in range(1,n+1):
    k.append([abs(l+i-1),l+i-1])

k = sorted(k,key = lambda x:x[0])

ans = 0
for i in range(1,n):
    ans += k[i][1]
print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long long a, b, l;
int main() {
	scanf("%lld %lld %lld", &a, &b, &l);
	if (a == 0) printf("%lld\n", b / l + 1);
	else printf("%lld\n", b / l - (a - 1) / l);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
int a[200000], vs[200000],b[203][220], co[200200];
vector<int>v[300000];
string s;
int main()
{
    IO;
    long long i, j, m, k, n, l=0;
    cin>>n;
    for(i=1; i<=n; i++){
        for(j=1; j<=n; j++){
            b[i][j]=__gcd(i,j);
            b[j][i]=__gcd(i,j);
        }
    }
    for(i=1; i<=n; i++){
        for(j=1; j<=n; j++)
            for(k=1; k<=n; k++){
                    m=b[i][j];
                l+=b[m][k];
            }
    }
    cout<<l<<endl;
    return 0;

}


Measured memory_bytes: 10844
import java.io.*;
import java.util.*;

public class Main{
	static void main() throws Exception{
		int n=sc.nextInt();
		int[]ans=new int[1000000];
		for(int x=1;x<=100;x++) {
			for(int y=1;y<=100;y++) {
				for(int z=1;z<=100;z++) {
					int idx=x*x+y*y+z*z+x*y+y*z+z*x;
					if(idx>=ans.length)continue;
					ans[idx]++;
				}
			}
		}
		for(int i=1;i<=n;i++) {
			pw.println(ans[i]);
		}
	}
	public static void main(String[] args) throws Exception{
		pw=new PrintWriter(System.out);
		sc = new MScanner(System.in);
		int tc=1;
//		tc=sc.nextInt();
		while(tc-->0)
			main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}


Measured memory_bytes: 37592
chomp (my $n = <STDIN>);
chomp (my @h = split / /, <STDIN>);
my ($ans, $f) = (0, 1);
while ($f) {
  $f = 0;
  my $e = 1;
  for my $i (0..$n-1) {
    if ($h[$i] > 0) {
      $h[$i]--;
      $ans++ if $e;
      $f = 1;
      $e = 0;
    } else {
      $e = 1;
    }
  }
}
print "$ans\n";

Measured memory_bytes: 512
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int keta(int a, int k) {
  for (int i = 0; i < k; i++)
    a /= 10;
  return a % 10;
}

int s(int a) {
  int ret = 0;
  for (int i = 0; i < 7; i++) {
    ret += keta(a, i);
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  int ans = 100000000;
  for (int i = 1; i < n; i++) {
    ans = min(ans, s(i) + s(n - i));
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    map<int64_t, int> stick;
    rep(i, N)
    {
        int64_t A;
        cin >> A;
        stick[A]++;
    }
    int64_t tate = 0, yoko = 0;
    for (auto x : stick)
    {
        if (x.second >= 4)
        {
            tate = x.first;
            yoko = x.first;
        }
        else if (x.second >= 2)
        {
            tate = yoko;
            yoko = x.first;
        }
    }
    cout << tate * yoko << endl;
}

Measured memory_bytes: 6528
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int num=n;
		int sum = 0;
		while(n >= 1) {
			sum += n % 10;
			n /= 10;
		}
		
		if(num % sum == 0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}

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

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define pb push_back
#define inf 1e+18L
#define MOD 1000000007

int main()
{
    FastIO 
    int x, y, z;
    cin >> x >> y >> z;
    swap(x,y);
    swap(x,z);
    cout << x << " " << y << " " << z;
    return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<cctype>
#include<string>
#include<bitset>
#include<vector>
#include<cstdio>
#include<ctime>
#include<cmath>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<set>
#include<map>
#define INF 1000000000
#define ll long long
#define mod 10007
#define pb push_back
using namespace std;
char *fs,*ft,buf[1<<15];
inline char getc()
{
	return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline ll read()
{
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
const int MAXN=200010;
int n,k;
char a[MAXN];
int main()
{
	//freopen("1.in","r",stdin);
	scanf("%s",a+1);
	n=strlen(a+1);
	for(int i=1;i<=n;++i)printf("x");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N;
    cin >> N;
    cout << (1000-N%1000)%1000 << "\n";
    return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 9223372036854775807;

int main(){

    ll R, G, B, N;
    cin >> R >> G >> B >> N;

    ll cn = 0;
    for(ll i = 0; i <= 3000; i++){
        for(ll j = 0; j <= 3000; j++){
            if(N - R*i - G*j < 0) continue;
            if((N - R*i - G*j) % B == 0) cn++;
        }        
    }

    cout << cn << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 998244353;
constexpr int inf = 3e18;

int N,S;
int A[3005];
int dp[3005][3005];
signed main(){
	cin>>N>>S;
	rep(i,N)cin>>A[i];
	dp[0][0]=1;
	rep(i,N){
		rep(j,S+1){
			dp[i][j]%=mod;
			dp[i+1][j]+=dp[i][j]*2;
			if(j+A[i]<=S){
				dp[i+1][j+A[i]]+=dp[i][j];
			}
		}
	}
	cout<<dp[N][S]%mod<<endl;
}


Measured memory_bytes: 74116
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        long now = 100;
        int ans = 0;
        while (now < X) {
            if (now >= 10_000_000_000_000_000L) {
                now = now/100*101;
            } else {
                now = now*101/100;
            }
            ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35960
import sys
pattern = ["dream", "dreamer", "erase", "eraser"]
split_pattern = ["dream", "er", "ase", "r"]
grammer = {
        "ase": ["er"],
        "r": ["ase", "er"],
        "er": ["dream"],
        "dream": [],
        }
s = input()

splited = []
while s:
    for spl in split_pattern:
        if s.startswith(spl):
            splited.insert(0, spl)
            s = s[len(spl):]
            break
    else:
        print("NO")
        sys.exit()

pred = []
for word in splited:
    if not pred:
        pred = grammer[word][:]
    else:
        if word != pred[0]:
            print("NO")
            break
        else:
            del pred[0]
else:
    print("YES")


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


void main() {
    int n;
    scan(n);

    int ans;

    foreach (i ; 0 .. n + 1) {
        if (i*i <= n) {
            ans = i*i;
        }
        else {
            break;
        }
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> n(5);
    string s, cs = "MARCH";
    for ( int i = 0; i < N; i++ ) {
        cin >> s;
        for (  int j = 0; j < 5; j++ ) {
            if ( s[0] == cs[j] ) {
                n[j]++;
            }
        }
    }
    ll ans = 0;
    for ( int i1 = 0; i1 < 5; i1++ ) {
        for ( int i2 = i1+1; i2 < 5; i2++ ) {
            for ( int i3 = i2+1; i3 < 5; i3++ ) {
                ans += n[i1] * n[i2] * n[i3];
            }
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K,ans;
  cin>>N>>K;
  vector<int> h(N);
  for(int i=0; i<N; i++)
    cin>>h.at(i);
  sort(h.begin(),h.end());
  for(int i=0; i<N-K+1; i++){
    int x=h.at(i+K-1)-h.at(i);
    if(i==0)ans=x;
    else if(ans>x)ans=x;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
a = int(input())
b = []
for i in range(1,a+1):
    if i%3 == 0:
        b.append(i)
    elif i%10 == 3:
        b.append(i)
    elif (i//10)%10 == 3:
        b.append(i)
    elif((i//10)//10)%10 == 3:
        b.append(i)
    elif((i//10)//10)//10%10 == 3:
        b.append(i)
    elif((i//10)//10)//10//10%10 == 3:
        b.append(i)
    elif((i//10)//10)//10//10//10%10 == 3:
        b.append(i)
    else:
        continue
for i in b:
    print(" "+str(i),end="")
print("\n",end="")


Measured memory_bytes: 6108
using System;

namespace AtCoder02
{
    public class ABC116_A
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            Console.WriteLine(a * b / 2);
        }
    }
}

Measured memory_bytes: 11092
#include<cctype>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<algorithm>
#include<numeric>
#include<vector>
using std::vector;
#include<string>
using std::string;
#include<set>
using std::set;
#include<map>
using std::map;
#include<unordered_map>
#include<queue>
#include<tuple>
using std::get;
using std::pair;
using std::tuple;
#include<iostream>
#include<sstream>
#include<iomanip>
using lnt = long long int;
using unt = unsigned long long int;
using ust = unsigned;
using dou = double;
using P = std::pair<int,int>;
#define FZ(i,n)       for(int i=0;i<(n);++i)
#define FB(i,n)       for(int i=(n)-1;i>=0;--i)
#define FV(i,st,ed)   for(int i=st;i<(ed);++i)
#define FC(i,n)       for(int i=n;i;--i)
#define FZU(i,n)      for(ust i=0;i!=(n);++i)
#define FVU(i,st,ed)  for(ust i=st;i<(ed);++i)
#define FCU(i,n)      for(ust i=n;i;--i)
#define ALL(x)        std::begin(x),std::end(x)
#define DTRL(x,y)     do{auto&x_(x),&y_(y);if(x_!=y_)return x_<y_;}while(0)

#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d %d",&(x),&(y))
#define RS(x) scanf("%s",x)
#define RI64(x) scanf("%lld",&(x))
#define RII64(x,y) scanf("%lld%lld",&(x),&(y))

#define FIR first
#define SEC second
#define pritnf printf
constexpr ust N = 100514u;

int main(){
    std::string s;
    std::cin >> s;
    int ans = 1<<30;
    for(int i=0;i<2;++i){
        int tans = 0;
        for(int j=0;j<int(s.size());++j){
            tans+= s[j]!=('0'+(i+j)%2);
        }
        ans = std::min(ans,tans);
    }
    std::cout << ans << '\n';
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main(){
    int N,A,B,C,D;
    string S;
    cin >> N >> A >> B >> C >> D >> S;
    for(int i = A-1; i < C-1; i++) {
        if(S[i] == '#' && S[i+1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i = B-1; i < D-1; i++) {
        if(S[i] == '#' && S[i+1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }
    if((A < B && C < D) || (B < A && C < D)) {
        cout << "Yes" << endl;
    }
    else {
        for(int i = max(A,B)-2; i < min(C,D)-1; i++) {
            if(S[i] == '.' && S[i+1] == '.' && S[i+2] == '.') {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

struct StronglyConnectedComponents
{
  int n;
  vector<vector<int>> oG, rG;
  vector<int> comp, order, used;
  vector<pair<int, int>> edges;

  StronglyConnectedComponents (int n) : n(n), oG(n), rG(n), comp(n, -1), used(n, 0) {}

  int operator[] (int k)
  {
    return comp[k];
  }

  void add_edge(int u, int v)
  {
    oG[u].push_back(v);
    rG[v].push_back(u);
    edges.emplace_back(u, v);
  }

  void dfs(int v)
  {
    if (used[v]) return;
    used[v] = true;
    for (int to : oG[v]) dfs(to);
    order.push_back(v);
  }

  void rdfs(int v, int k)
  {
    if (~comp[v]) return;
    comp[v] = k;
    for (int to : rG[v]) rdfs(to, k);
  }

  void build(vector<vector<int>> &t)
  {
    for (int i = 0; i < n; ++i) dfs(i);

    reverse(order.begin(), order.end());
    int k = 0;
    for (int i : order) if (comp[i] == -1) rdfs(i, k++);

    t.resize(k);
    set<pair<int, int>> connect;
    for (auto &e : edges) {
      int u = comp[e.first], v = comp[e.second];
      if (u == v || connect.count({u, v})) continue;
      t[u].push_back(v);
      connect.emplace(u, v);
    }
  }
};

/*
StronglyConnectedComponents(g):= グラフ g で初期化する。
build(t):= 強連結成分分解をする。強連結成分の番号はトポロジカル順に昇順にふられる。
tには強連結成分ごとに縮約したグラフが格納される(多重辺が生えるので注意)。
[k] := 頂点 k が属する強連結成分の番号を返す。

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

  StronglyConnectedComponents scc(n);
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    scc.add_edge(u, v);
  }

  vector<vector<int>> G;
  scc.build(G);

  int q;
  cin >> q;
  while (q--) {
    int s, t;
    cin >> s >> t;
    cout << (scc[s] == scc[t]) << endl;
  }
}
*/
void solve(int n){
  double a[n];
  StronglyConnectedComponents scc(n);

  rep(i,n){
    cin >> a[i];
    int x;
    cin >> x;
    rep(j,x){
      int y;
      cin >> y;
      y--;
      scc.add_edge(i,y);
    }
  }

  VVI G;
  scc.build(G);
  // rep(i,scc.comp.size()) cout << i << ": " << scc.comp[i] << endl;
  vector<double> p(G.size(),1.);
  rep(i,scc.comp.size()){
    p[scc.comp[i]] *= a[i];
  }
  double ans = 1.;
  bool up[G.size()];
  memset(up,true,sizeof(up));
  rep(i,G.size()){
    rep(j,G[i].size()){
      up[G[i][j]] = false;
    }
  }

  rep(i,G.size()) if(up[i]) ans *= (1. - p[i]);
  printf("%0.9lf\n",ans);
}
int main(){

  int n;
  while(cin >> n, n){
    solve(n);
  }
  return 0;
}



Measured memory_bytes: 3364
from itertools import accumulate
N, C = map(int, input().split())
STC = [list(map(int, input().split())) for _ in range(N)]

M = 10**5+1
merge = [[0]*(M+1) for _ in range(31)]
for i in range(N):
    s, t, c = STC[i]
    #merge[c][s] += 1
    #merge[c][t+1] -= 1
    merge[c][s:t+1] = [1]*(t-s+1)
#for c in range(31):
#    merge[c] = list(map(lambda x: int(bool(x)), accumulate(merge[c])))
print(max(map(sum, zip(*merge))))

#ans = []
#for i in range(M+1):
#    res = 0
#    for j in range(31):
#        res += merge[j][i]
#    ans.append(res)
#print(max(ans))


Measured memory_bytes: 51860
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll a, b, c;
  cin >> a >> b >> c;

  if(b >= a*c) cout << c << endl;
  else cout << b / a << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];
vi B[200];
ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v;
	// PROCESS IN HERE
	string s,t;
	sc2(s,t);
	
	fs(i,s)B[s[i]].pb(i);
	
	ll ind=-1;
	v=0;
	fs(i,t){
		ll p=upper_bound(all(B[t[i]]),ind)-B[t[i]].begin();
		if(sz(B[t[i]])==0)re pr(-1),0;
		if(p>=sz(B[t[i]])){
			if(sz(B[t[i]]))p=0,v+=le(s);
			else re pr(-1),0;
		}
		ind=B[t[i]][p];
		mxz(ans,v+ind);
//			debug(ind);
	}
	pr(ans+1);
	re 0;
	// Hack it if you can :)
}

int main(){
//	INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

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

using namespace std;

int n, m, X, Y, a[105], b[105], l, r;

int main() {
	cin >> n >> m >> X >> Y;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	for(int i = 1; i <= m; ++i) cin >> b[i];
	sort(a+1, a+n+1);
	sort(b+1, b+m+1);
	if(b[1] <= a[n]) {
		cout << "War" << endl;
		return 0;
	}
	l = a[n]+1, r = b[1];
	if((l > X && l <= Y) || (r <= Y && r > X) || (l < X && r >= Y)) {
		cout << "No War" << endl;
	}
	else cout << "War" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
   
public class Main{
    public void solve(){
        Scanner sc=new Scanner(System.in);
        int a = 0;
        int kaisu = 1;
        int n = sc.nextInt();
         
        while(n != 0){
        for(int i=1; i <= n; i++){
            int k = sc.nextInt();
             
            if(k >= 2){
                 kaisu ++;
            }else if(k == 1){
                 a ++;
            }
        }
             
            if(kaisu >= 2){
                System.out.println(kaisu+a);
            }else{
                System.out.println("NA");
            }
                 
             kaisu = 1;
             a = 0;
             n = sc.nextInt();
        }
         
       }
        public static void main(String[]args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 158764
/*------------------------------------------------,
|  __                                       __    |
| |  |--.-----.---.-.----.----.-----.-----.|  |_  |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _| |
| |_____|_____|___._|____|____|_____|   __||____| |
|                                   |__|          |
`------------------------------------------------*/
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;
using namespace std;
#define INF 2147483647
#define MOD 10000007
#define REP(count_ver, lower, upper) for (long long count_ver = lower; count_ver < upper; count_ver++)

int gcd(int a, int b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool isPrime(int a) {
  if (a == 1)     return false;
  if (a == 2)     return true;
  if (a % 2 == 0) return false;
  for (int i = 3; i < sqrt(a) + 1; i += 2) if (a != i and a%i==0) return false;
  return true;
}

void execute(){

  int n,k;
  cin>>n>>k;
  vector<int> p(n);
  REP(i,0,n)cin>>p[i];

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

  int sum=0;
  REP(i,0,k){
    sum+=p[i];
  }
  cout<<sum<<endl;

}
int main() {

  cin.tie(0);
  ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);

  execute();

  return 0;
}


Measured memory_bytes: 3680
S = list(input())
L = len(S)

def change():
    global kk
    if kk == "1":
        kk = "0"
    else:
        kk = "1"

# case 1
count_1 = 0
kk = "1"
for c in range(L):
    if kk == S[c]:
        pass
    else:
        count_1 += 1
    change()
    

# case 2
count_2 = 0
kk = "0"
for c in range(L):
    if kk == S[c]:
        pass
    else:
        count_2 += 1
    change()

if count_1 < count_2:
    print(count_1)
else:
    print(count_2)


Measured memory_bytes: 3956
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        _n: usize, m: usize,
        cards: [(Usize1, Usize1); m],
    }
    let mut min = 0;
    let mut max = std::usize::MAX;
    for (l, r) in cards {
        if l > min {
            min = l;
        }
        if r < max {
            max = r;
        }
    }
    if min <= max {
        println!("{}", max - min + 1);
    } else {
        println!("0");
    }
}


Measured memory_bytes: 4740
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
vector<bool> isprime;
vector<int> prime;

void Prime_Sequence(int n){//nまでの素数列を形成
    isprime.resize(n+1,true);
    isprime[0]=false;
    isprime[1]=false;
    int p=0;
    for(int j=2;j<=n;j++){
        if(isprime[j]){
            prime.push_back(j);
            p++;
            for(int k=2;j*k<=n;k++){
                isprime[j*k]=false;
            }
        }
    }
}
int main()
{ 
    int n;
    cin>>n;
    Prime_Sequence(n*10);
    int i=0;
    while(prime[i]<n){i++;}
    cout<<prime[i]<<endl;
    return 0;
}

Measured memory_bytes: 1020
N,W=map(int,input().split())

w=[0]
v=[0]
for i in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)
    
dp=[[0 for j in range(W+1)]for i in range(N+1)]

for i in range(1,N+1):
    for j in range(1,W+1):
        if W+1-j-w[i]<0:
            dp[i][W+1-j]=dp[i-1][W+1-j]
        else:
            dp[i][W+1-j]=max(dp[i-1][W+1-j],dp[i-1][W+1-j-w[i]]+v[i])

print(dp[i][W])

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol h; cin >> h;
    lol count{0};
    while(h != 1)
    {
        h /= 2;
        result += pow(2, count);
        count++;
    }
    result += pow(2, count);

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 4028
k,n=map(int,input().split())
a=list(map(int,input().split()))
s=0
b=[0]*(n-1)
for i in range(n-1):
  b[i]=a[i+1]-a[i]
  
b.append(k+a[0]-a[n-1])

c=sorted(b,reverse=True)
for i in range(1,n):
  s+=c[i]
print(s)

Measured memory_bytes: 25836
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto tt = readln.split.to!(long[]);
    auto T1 = tt[0];
    auto T2 = tt[1];
    auto aa = readln.split.to!(long[]);
    auto A1 = aa[0];
    auto A2 = aa[1];
    auto bb = readln.split.to!(long[]);
    auto B1 = bb[0];
    auto B2 = bb[1];

    if (B1 < A1) {
        swap(A1, B1);
        swap(A2, B2);
    }

    auto x = (A1 - B1) * T1;
    auto y = (A2 - B2) * T2;

    if (x+y < 0) {
        writeln(0);
    } else if (x+y == 0) {
        writeln("infinity");
    } else {
        auto d = x+y;
        writeln(-x/d * 2 + (-x%d == 0 ? 0 : 1));
    }
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)

n,m = [int(i) for i in input().split()]

#ko = [[] for _ in range(n)]
oya = [[] for _ in range(n)]
for _ in range(m):
    x,y = [int(i)-1 for i in input().split()]
#    ko[x].append(y)
    oya[y].append(x)

memo = [-1]*n

def longest(v): #nを終点とするlongest
    if memo[v] >= 0:
        return memo[v]
    else:
        c=0
        for j in oya[v]:
            c = max(c,longest(j)+1)
        memo[v] = c
        return c

for i in range(n):
    longest(i)

print(max(memo))    
#print(memo)


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

#define MAX 1024

char *tolowerstr(char *s){
    int i;
    
    for(i = 0; s[i] != '\0'; ++i){
        s[i] = tolower(s[i]);
    }
    
    return s;
}

int main(){
    char w[MAX], t[MAX];
    int c = 0;
    
    scanf("%s", w);
    tolowerstr(w);
    
    while(scanf("%s", t), strcmp(t, "END_OF_TEXT") != 0){
        if(strcmp(w, tolowerstr(t)) == 0){
            ++c;
        }
    }
    
    printf("%d\n", c);
    
    return 0;
}

Measured memory_bytes: 552
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	if(n>=1800)printf("1");
	else if(n>=1600)printf("2");
	else if(n>=1400)printf("3");
	else if(n>=1200)printf("4");
	else if(n>=1000)printf("5");
	else if(n>=800)printf("6");
	else if(n>=600)printf("7");
	else if(n>=400)printf("8");
} 

Measured memory_bytes: 3764
import java.util.*;

public class Main {
  
  public static void main(String args[]){
    
    Scanner sc = new Scanner(System.in);
    
    long x = sc.nextLong();
    long year = 0;
    
    double kingaku = 100;
    
    do{
      
      kingaku = kingaku * 1.01;
      kingaku = Math.floor(kingaku);
      year++;
    }while(kingaku < x);
    
    System.out.println(year);
    
  }
  
}

Measured memory_bytes: 35840
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    map<string,int> t;
    int n;
    cin >> n;
    rep(i,n){
        string s; cin >> s;
        t[s]++;
    }

    int ans = 0;
    for(auto e:t){
        if(e.second>=1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	ll n, x, t;
	cin >> n >> x >> t;
	cout << (n + x - 1) / x*t << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}



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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	int ma=100001,cnt=0;
	vector<int> a(ma);
	rep(i,n){
		int x;cin >> x;
		a.at(x)++;
	}
	rep(i,ma){
		if(a.at(i) && a.at(i)%2==1) a.at(i)=1;
		else if(a.at(i) && a.at(i)%2==0){
			cnt++;
			a.at(i)=0;
		}
	}
	if(cnt%2==1) cnt--;
	int ans=cnt;
	rep(i,ma) ans+=a.at(i);
	cout << ans << endl;
}

Measured memory_bytes: 640
using System;

namespace Test06
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			for (int i = 1; i < 10; i++)
			{
				for (int j = 1; j < 10; j++)
				{
					Console.WriteLine("{0}x{1}={2}", i, j, i * j);
				}
			}
		}
	}
}

Measured memory_bytes: 8920
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 100000;
long long cnt[NMAX];
int coins[] = {100, 101, 102, 103, 104, 105};
void solve(int n){
  cnt[0] = 1;
  for (int x = 1; x <=n; x++)
    for (auto c: coins)
      if (x-c >= 0)
        cnt[x] += cnt[x-c];
}
int main()
{
  int n;
  cin >> n;
  solve(n);
  cout << (cnt[n] ? 1 : 0) << '\n';

}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  string S;
  cin >> S;
  string ans = "NO";
  // 0
  if (S == "AKIHABARA")
    ans = "YES";
  // 1
  if (S == "KIHABARA" || S == "AKIHBARA" || S == "AKIHABRA" || S == "AKIHABAR")
    ans = "YES";
  // 2
  if (S == "KIHBARA" || S == "KIHABRA" || S == "KIHABAR" || S == "AKIHBRA" || S == "AKIHBAR" || S == "AKIHABR")
    ans = "YES";
  // 3
  if (S == "KIHBRA" || S == "KIHBAR" || S == "KIHABR" || S == "AKIHBR")
    ans = "YES";
  // 4
  if (S == "KIHBR")
    ans = "YES";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
a1,b1,c1=gets.split.map &:to_i
k=gets.to_i
ans = false
com=[0,1,2].repeated_permutation(k).to_a
com.each do |i|
  a=Marshal.load(Marshal.dump(a1))
  b=Marshal.load(Marshal.dump(b1))
  c=Marshal.load(Marshal.dump(c1))
  i.each do |j|
    if 0 == j
      a *= 2
    elsif 1 == j
      b *= 2
    elsif 2 == j
      c *= 2
    end
  end
  if b > a && c > b
    ans = true
    break
  end
end
puts ans ? 'Yes' : 'No'
  

Measured memory_bytes: 14572
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define ll long long
#define endl "\n"
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define hell 1000000007
#define ff first
#define ss second
#define pii pair<ll,ll>
#define upd upper_bound
#define lbd lower_bound
#define vi vector<ll>
#define vii vector<pii>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)

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

#define N 200005

ll i=0,j=0;

ll powr(ll a,ll b)
{
    ll i=0;
    ll ans=1;
    for(i=1;i<=b;i++)
    {
        ans*=a;
    }
    return ans;
}

ll n,m;
ll dp[N];
vi adj[N];

ll dfs(ll v)
{
    if(dp[v]>=0)
    {
        return dp[v];
    }
    dp[v]=0;
    if(adj[v].size()==0)
        return dp[v];
    for(auto it : adj[v])
    {
        dp[v]=max(dp[v],dfs(it));
    }
    dp[v]+=1;
    return dp[v];
}

int main()
{
    IOS;
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
        ll a,b;
        cin>>a>>b;
        adj[a].pb(b);
    }
    for(i=1;i<=n;i++)
        dp[i]=-1;
    for(i=1;i<=n;i++)
    {
        if(dp[i]==-1)
        {
            dfs(i);
        }
    }
    ll ans=0;
   /* for(i=1;i<=n;i++)
    {
        cout<<dp[i]<<" ";
    }
    cout<<endl;*/
    for(i=1;i<=n;i++)
    {
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
}



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

int main() {
  int n, m;
  cin >> n >> m;
  
  vector<int> homework(m);
  for (int i=0; i<m; i++){
    cin >> homework.at(i);
  }
  int sum = 0;
  for (int i=0; i<m; i++){
    sum += homework.at(i);
  }
  if(sum>n){
    cout<< -1 <<endl;
  }else{
    cout<< n- sum<<endl;
  }
}

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

int main(){
	int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
	int dx=x2-x1,dy=y2-y1,vx=-dy,vy=dx;
	int x3=x2+vx,y3=y2+vy,x4=x1+vx,y4=y1+vy;
	cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;

}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	week := []string{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}
	var s string
	fmt.Scan(&s)
	for i := 0; i < len(week); i++ {
		if s == week[i] {
			fmt.Println(len(week) - i)
			return
		}
	}
}


Measured memory_bytes: 512
using System;
using System.Linq;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


            var result = 0;

            for (var i = inputLongArray[0]; i <= inputLongArray[1]; i++)
            {
                if (i % inputLongArray[2] == 0)
                {
                    result += 1;
                }
            }


            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 19140
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
struct Combination{
private:
    ll N;
    vector<ll> fac, facinv;

public:
    Combination(ll n){
        N = n;
        fac.push_back(1); fac.push_back(1);
        rep(i,2,N+1) fac.push_back(fac[i-1] * i % MOD);
        rep(i,0,N+1) facinv.push_back(power(fac[i], MOD-2));
    }
    ll power(ll x, ll n){
        if(n == 0) return 1LL;
        ll res = power(x * x % MOD, n/2);
        if(n % 2 == 1) res = res * x % MOD;
        return res;
    }
    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }
    ll npk(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[n-k] % MOD;
    }
    ll get(ll x){return fac[x];};
    ll getinv(ll x){return facinv[x];};
};

void solve(){
    ll N;
    cin >> N;
    ll u[200010], v[200010];
    vector<ll> tree[200010];
    Combination cb(200010);
    ll ans = 0;
    rep(i,0,N){
        ll lv = i+1;
        ll rv = N-i;
        ans += lv * rv;
    }

    rep(i,0,N-1){
        cin >> u[i] >> v[i];
        u[i]--; v[i]--; 
        if(u[i] > v[i]) swap(u[i], v[i]);
        ll val = (u[i] + 1) * (N - v[i]);
        ans -= val;

    }
    print(ans);


    

}

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

Measured memory_bytes: 14208
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h> 
 
using namespace std;
 
#define len(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second	
#define int long long
#define double long double       
#define vec vector            
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double> 
#define beg begin
#define print(x) cout << x << endl;
 
#ifdef LOCAL
    #define dbg(x) cerr << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 

template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(2);
    solve();    
    return 0;
}
 
const int INF = 1e18, MAXN = 1e6, MOD = 998244353, BASE = 37;	

int bin_pow(int val, int n) {
	if (n == 0) {
		return 1; 
	}
	if (n % 2 == 0) {
		int tmp = bin_pow(val, n / 2) % MOD;
		return tmp * tmp % MOD;
	}
	else {
		return (bin_pow(val, n - 1) % MOD) * val % MOD;
	}
}

void solve() {
	int n;
	cin >> n;
	map<int, int> d;
	vec<int> a(n);
	for (int i = 0; i < n; ++i) {
		int cur; cin >> cur;
		a[i] = cur;
		d[cur]++;
	}

	if (d[0] != 1 || a[0] != 0) {
		print(0);
		return;
	}
	int k = 0, ans = 1, pcnt = 1;
	for (auto it : d) {
		int dist = it.x, cnt = it.y;
		if (dist == 0) continue;
		if (dist != k + 1) {
			print(0);
			return;	
		}
		ans = (ans * bin_pow(pcnt, cnt)) % MOD;
		pcnt = cnt;
		k++;
	}

	print(ans);
}

Measured memory_bytes: 7296