akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 998244353;
const int MAX = 3100;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	int N, X; cin >> N >> X;
	COMinit();
	ll ans = 0;
	for(int i=0; i<=N; i++){
		for(int j=i; j<=2*i; j++){
			ll cnt = 0;
			if(j < X){
				cnt = (cnt + COM(i, j-i)) % MOD;
			}else{
				int two = (j-X+2)/2;
				if(4*two < j){
					int midsum = j - 4*two;
					int midnum = i - 2*two;
					if(midsum % 2 != X % 2){
						cnt = (cnt + COM(midnum, midsum-midnum)) % MOD;
					}
				}else{
					if(2*two >= i && j == 2*i && X % 2 != 0){ cnt++; cnt %= MOD; }
				}
			}
			ans = (ans + cnt * COM(N, i) % MOD) % MOD;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
S=input()
b=len(S)
a=[]
a=list(S)
if a[0]=='k'and a[1]=='e'and a[2]=='y'and a[3]=='e'and a[4]=='n'and a[5]=='c'and a[6]=='e':
    print("YES")
elif a[0]=='k'and a[1]=='e'and a[2]=='y'and a[3]=='e'and a[4]=='n'and a[5]=='c'and a[b-1]=='e':
    print("YES")
elif a[0]=='k'and a[1]=='e'and a[2]=='y'and a[3]=='e'and a[4]=='n'and a[b-2]=='c'and a[b-1]=='e':
        print("YES")
elif a[0]=='k'and a[1]=='e'and a[2]=='y'and a[3]=='e'and a[b-3]=='n'and a[b-2]=='c'and a[b-1]=='e':
        print("YES")
elif a[0]=='k'and a[1]=='e'and a[2]=='y'and a[b-4]=='e'and a[b-3]=='n'and a[b-2]=='c'and a[b-1]=='e':
        print("YES")
elif a[0]=='k'and a[1]=='e'and a[b-5]=='y'and a[b-4]=='e'and a[b-3]=='n'and a[b-2]=='c'and a[b-1]=='e':
        print("YES")
elif a[0]=='k'and a[b-6]=='e'and a[b-5]=='y'and a[b-4]=='e'and a[b-3]=='n'and a[b-2]=='c'and a[b-1]=='e':
        print("YES")
elif a[b-7]=='k'and a[b-6]=='e'and a[b-5]=='y'and a[b-4]=='e'and a[b-3]=='n'and a[b-2]=='c'and a[b-1]=='e':
        print("YES")
else:
    print("NO")


Measured memory_bytes: 3192
import bisect
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

A, B, Q = map(int, input().split())
S = [-float('inf')]+[int(input()) for _ in range(A)]+[float('inf')]
T = [-float('inf')] + [int(input()) for _ in range(B)]+[float('inf')]


def dist(x):
    pS = bisect.bisect_right(S, x)
    pT = bisect.bisect_right(T, x)

    d1 = max(S[pS], T[pT])-x  # x ->s->t or x->t->s
    d2 = x - min(S[pS-1], T[pT-1])  # s->t->x or t->s->x
    d3 = min(x-T[pT-1], S[pS]-x) + S[pS]-T[pT-1]  # t->x->s
    d4 = min(x-S[pS-1], T[pT]-x)+T[pT]-S[pS-1]  # s->x->t]
    return min(d1, d2, d3, d4)


ans = []
for _ in range(Q):
    x = int(input())
    ans.append(dist(x))

print("\n".join(map(str, ans)))


Measured memory_bytes: 23864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




using P = complex<double>;
double dot(P a, P b) { return real(conj(a) * b); }
double cross(P a, P b) { return imag(conj(a) * b); }
const double eps = 1e-8;


P intersection(P a, P b, P p1) {
    return p1 + dot(a, b) / real(conj(a) * a) * a;
}
int main() {
    double p1x, p1y, p2x, p2y;
    cin >> p1x >> p1y >> p2x >> p2y;
    P p1 = P(p1x, p1y), p2 = P(p2x, p2y);
    
    int query;
    cin >> query;
    while (query--) {
        double xx, xy;
        cin >> xx >> xy;
        P x = P(xx, xy);
        
        P r = intersection(p2 - p1, x - p1, p1);
        // cout << real(r) << " " << imag(r) << endl;
        P p = x + (r - x) + (r - x);
        
        cout << fixed << setprecision(10);
        cout << real(p) << " " << imag(p) << endl;
    }
}



Measured memory_bytes: 3272
#include<bits/stdc++.h>
#define mo 1000000007
#define N 100010
using namespace std;
string s;
int n,a[N],ne[N][4],dp[N],ans;
void add(int &x,int y){x+=y;if (x>=mo)x-=mo;}
int main(){
	cin>>s;n=s.length();
	for (int i=1;i<=n;i++)a[i]=(a[i-1]+s[i-1]-'a'+1)%3;
	ne[n+1][0]=ne[n+1][1]=ne[n+1][2]=ne[n+1][3]=n+1;
	for (int i=n;i>=1;i--){
		for (int j=0;j<=3;j++)ne[i][j]=ne[i+1][j];ne[i][a[i]]=i;
		if (i!=1&&s[i-1]==s[i-2])ne[i][3]=i;
	}
	if (ne[1][3]==n+1){puts("1");return 0;}
	dp[0]=1;
	for (int i=0;i<n;i++){
		add(dp[i+1],dp[i]);
		add(dp[ne[ne[i+2][3]][(a[i]+(3-s[i]+'a'-1))%3]],dp[i]);
	}
	for (int i=1;i<=n;i++)if (a[i]==a[n])add(ans,dp[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	ll a = 0, b = 0, c = 0, a_ = 0, b_ = 0, c_ = 0;
	string s; cin >> s;
	ll cnt = 1;
	for( char t : s ){
		if( t == 'A' ){
			a = a+cnt;
		} else if( t == 'B' ){
			b = a+b;
		} else if( t == 'C' ){
			c = b+c;
		} else {
			a_ = 3*a; b_ = 3*b; c_ = 3*c;
			c_ += b;
			b_ += a;			
			a_ += cnt;
			a = a_; b = b_; c = c_;
			cnt *= 3;
		}
		a %= mod; b %= mod; c %= mod; cnt %= mod;
		// cout << a << ' ' << b << ' ' << c << endl;
	}
	cout << c << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;

#define FOR(x) for(int i = 0; i < x; i++)


stack<short> x, y;
short a[10], n, j, i;

bool solve(short c, bool judge){
	if(c == 10) return true;
	if(x.top() < a[c]){
		x.push(a[c]);
		if(solve(c + 1, true)) return true;
	}
	if(y.top() < a[c]){
		y.push(a[c]);
		if(solve(c + 1, false)) return true;
	}
	if(judge) x.pop();
	else y.pop();
	return false;
}

int main(){
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		x.push(0);
		y.push(0);
		for(j = 0; j < 10; j++)
			scanf("%d", &a[j]);
		if(solve(0, true)) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1020
#include <iostream>

using namespace std;

int main()
{
    int A, B, C;

    cin >> A >> B >> C;

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  ren(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) ren(i,0,(n))
#define  all(a) begin(a),end(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;
 
int main()
{
    string o,e;
    cin>>o>>e;
    int a=o.size();
    e+='\n';
    rep(i,a) cout<<o[i]<<e[i];
    cout<<"\n";
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define AC ios::sync_with_stdio(false);cin.tie(0);
#define ll long long

int main(){
    AC
    int n,k,d,p,c=0;
    cin>>n>>k;
    int a[n];
    memset(a,0,sizeof(a));
    while(k--){
        cin>>d;
        while(d--){
            cin>>p;
            a[p-1]++;
        }
    }
    for(int i=0; i<n; i++) if(a[i]==0) c++;
    cout<<c;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int n;
vector<vector<pair<int,int>>> a;

bool search(int bits){
  for(int i=0; i<n; ++i){
    if(!(bits&(1<<i))) continue;
    for(auto& j:a[i]){
      int x=j.first,y=j.second;
      if((bits>>x)&1^y) return false;
    }
  }
  return true;
}

int main(void){
  cin>>n;
  a.resize(n);
  for(int i=0; i<n; ++i){
    int b; cin>>b;
    a[i].resize(b);
    for(auto& j:a[i]){ cin>>j.first>>j.second; --j.first;}
  }
  int res=0;
  for(int bits=0; bits<(1<<n); ++bits){
    if(search(bits)){
      int i=bits,cnt=0;
      while(i) ++cnt,i&=i-1;
      res=max(res,cnt);
    }
  }
  cout<<res;
  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1.0)
#define pb push_back
#define vi vector<int>
#define mapii map<int , int>
#define mapci map<char, int>
#define mapsi map<string,int>
#define FOR(i,n) for(int i = 0;i<n;i++)
#define CP(n) cout<<"Case "<<n<<": "
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
#define MAX 1000007
#define all(x)(x.begin(),x.end())
#define debug(x,c) cout<<x<<": "<<c<<" ";
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
int main()
{
	double a , b , h ,m;
	cin>>a>>b>>h>>m;
	double ha = (30.0 * (h + (m / 60.0)));
	double ma = (m * 6.0);
	double angle = fabs(ha - ma);
	angle = angle * (pi / 180.0);
	double ans = sqrt((a*a + b*b - 2*a*b*cos(angle)));
	cout.precision(20);
	cout<<fixed;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4144
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 998244353;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
struct Sushi {
	ll x, v;
};
int p = 1e8;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	ll C;
	cin >> n >> C;
	//~ C /= p;
	vector<Sushi> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i].x >> a[i].v;
		//~ a[i].x /= p;
		//~ a[i].v /= p;
	}
	vector<ll> pref1(n + 1), pref2(n + 1), max_pref1(n + 1), max_pref2(n + 1);
	for (int i = 1; i <= n; ++i) {
		ll minus = i - 2 >= 0 ? a[i - 2].x : 0;
		pref1[i] = pref1[i - 1] + a[i - 1].v - (a[i - 1].x - minus);
		max_pref1[i] = max(max_pref1[i - 1], pref1[i]);
	}
	vector<Sushi> b(n);
	for (int i = 0; i < n; ++i) {
		b[i].x = C - a[i].x;
		b[i].v = a[i].v;
	}
	reverse(b.begin(), b.end());
	for (int i = 1; i <= n; ++i) {
		ll minus = i - 2 >= 0 ? b[i - 2].x : 0;
		pref2[i] = pref2[i - 1] + b[i - 1].v - (b[i - 1].x - minus);
		max_pref2[i] = max(max_pref2[i - 1], pref2[i]);
	}
	
	//~ debug(pref1, pref2);
	//~ for (int i = 0; i < n; ++i) {
		//~ cout << a[i].x << ' ';
	//~ }
	//~ cout << '\n';
	//~ for (int i = 0; i < n; ++i) {
		//~ cout << b[i].x << ' ';
	//~ }
	//~ cout << '\n';
	ll answer = 0;
	for (int cnt1 = 0; cnt1 <= n; ++cnt1) {
		ll minus = cnt1 == 0 ? 0 : a[cnt1 - 1].x;
		ll cur = pref1[cnt1];
		cur += max_pref2[n - cnt1];
		answer = max(answer, cur - minus);
	}
	for (int cnt1 = 0; cnt1 <= n; ++cnt1) {
		ll minus = cnt1 == 0 ? 0 : b[cnt1 - 1].x;
		ll cur = pref2[cnt1];
		cur += max_pref1[n - cnt1];
		answer = max(answer, cur - minus);
	}
	cout << answer << '\n';
 	return 0;
}


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

int main() {
	string s;
	cin >> s;
	cout << s[0] <<  s[1] <<  s[2] << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}
//xとyのビットごとの排他的論理和
template<class T> T XOR(T x, T y)
{
	T n = 0;
	while (max(x, y) > pow(2, n)) n++;
	T ans=0;
	for (int i = 0; i <= n; i++)
	{
		T x1 = (x % (T)pow(2, i + 1)) / (T)pow(2, i);
		T y1 = (y % (T)pow(2, i + 1)) / (T)pow(2, i);
		if (x1 != y1) ans += (T)pow(2, i);
	}
	return ans;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	long long N, A, B;
	cin >> N >> A >> B;

	long long x = N / (A + B);
	long long y = N % (A + B);
	long long ans = x * A;
	if (y > A) ans += A;
	else ans += y;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    private static int MAX_XY = 10000;
    private static int MIN_XY = 0;
    private static int MAX_LENGTH = 3000;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            int i = 1;
            while (sc.hasNext()) {
                if (i > MAX_LENGTH) {
                    throw new InvalidTestCaseException("Condition is invalid.");
                }
                int[] x_y = Stream.of(sc.nextLine().split(" "))
                        .mapToInt(Integer::parseInt)
                        .toArray();
                if (x_y.length != 2) {
                    throw new InvalidTestCaseException("Condition is invalid.");
                }
                int x = x_y[0];
                int y = x_y[1];
                if (x > MAX_XY || x < MIN_XY
                    || y > MAX_XY || y < MIN_XY) {
                    throw new InvalidTestCaseException("Condition is invalid.");
                }
                if (x == 0 && y == 0) {
                    break;
                }
                System.out.printf("%d %d\n", Integer.min(x, y), Integer.max(x, y));
                i++;
            }
        } catch (InvalidTestCaseException
                | NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    }
}

class InvalidTestCaseException extends RuntimeException {
    InvalidTestCaseException(String message) {
        super(message);
    }
}



Measured memory_bytes: 45768
#include <stdio.h>

int main(){
  double xa,ya,xb,yb,xc,yc,xd,yd,ans;
  while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)!=EOF){
    ans=(xd-xc)*(xb-xa)+(yd-yc)*(yb-ya);
    ans*=(ans<0?-1:1);
    if(ans<=1.0e-11 || 
       (xa==xb && yc==yd) || (xc==xd && ya==yb)) printf("YES\n");
    else printf("NO\n");
  }
  
  return 0;
}

Measured memory_bytes: 612
a = list(map(int,input().split()))
b = list(list(map(int,input().split())) for i in range(a[0]))
c = 1001

for i in range(a[0]):
  if b[i][1]<=a[1]:
    c = min(c,b[i][0])
else:
  if c==1001:
    print("TLE")
  else:
    print(c)


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    long long a, b, c, ans = 0;
    std::cin >> a >> b >> c;
    ans += b;
    long long dokukeshi = a + b;
    
    while (c != 0 && dokukeshi != 0)
    {
        --c;
        --dokukeshi;
        ++ans;
    }
    
    if (c != 0) { ++ans; }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

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

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

    for (int i = 0; i < m; i++)
    {
        cin >> b[i + 1];
        b[i + 1] += b[i];
    }

    int ans = 0;
    for (int i = 0; i <= n; i++)
    {
        if (a[i] > k)
            break;
        int num = upper_bound(b.begin(), b.end(), k - a[i]) - b.begin() - 1;
        ans = max(ans, num + i);
    }

    cout << ans << endl;
}


Measured memory_bytes: 5980
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int>> get() {
  vector<vector<int>> res(33);
  for (int i = 0; i < n; i++) {
    int m;
    cin >> m;
    for (int j = 0; j < m; j++) {
      int a;
      cin >> a;
      res[a - 1].push_back(i);
    }
  }
  return res;
}
int solve() {
  vector<vector<int>> in = get();
  vector<set<int>> st(n);
  for (int i = 0; i < n; i++) st[i].insert(i);
  for (int d = 0; d < 33; d++) {
    set<int> s;
    for (int i : in[d]) {
      for (int j : st[i]) {
        s.insert(j);
      }
    }
    for (int i : in[d]) {
      st[i] = s;
    }
    if ((int) s.size() == n) return d + 1;
  }
  return -1;
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  while (cin >> n, n) {
    if (n == 1) cout << 0 << '\n';
    else cout << solve() << '\n';
  }  
  return 0;
}


Measured memory_bytes: 3244
#include <stdio.h>
#include <string.h>

int main(void)
{
	float h;
	int l[6];
	int i, n;
	
	memset(l, 0, sizeof(l));
	for (scanf("%d", &n); n--;){
		scanf("%f", &h);
		
		if (h >= 185){
			l[5]++;
		}
		else if (h >= 180){
			l[4]++;
		}
		else if (h >= 175){
			l[3]++;
		}
		else if (h >= 170){
			l[2]++;
		}
		else if (h >= 165){
			l[1]++;
		}
		else {
			l[0]++;
		}
		
	}
	
	for (i = 0; i < 6; i++){
		printf("%d:", i + 1);
		for (; l[i]--;)printf("*");
		puts("");
	}
	
	return (0);
}

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

signed main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++) cin >> L[i];

  int ans = 1;
  int now = 0;
  for (int i = 0; i < N; i++) {
    now += L[i];
    if (now <= X) ans++;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <utility>
using namespace std;
//_____
#define pb push_back
#define fi first
#define se second
#define mkp make_pair
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define err(...) fprintf(stderr, __VA_ARGS__)
#define show(x) cerr << #x << ':' << x << endl
#define outl(x) cout << (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
inline bool inside(int y, int x, int H, int W){return(y>=0 && x>=0 && y<H && x<W);}
const int INF = 1 << 29;
const int dx[] = {1, 0, -1, 0,  1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1,  -1, 1, 1, -1};
#define LEN 1000011
#define NIL -1
//_______

int dp[1005][1005];

int slv(string &a, string &b)
{
   const int alen = a.size();
   const int blen = b.size();
   a = ' ' + a;
   b = ' ' + b;
   int ret = 0;
   reps(i, 0, alen)dp[0][i] = 0;
   reps(i, 0, blen)dp[i][0] = 0;

   reps(i, 1, alen){
      reps(j, 1, blen){
         if(a[i] == b[j]){
            dp[i][j] = dp[i-1][j-1] + 1;
         } else {
            dp[i][j] = max(dp[i-1][j] , dp[i][j-1] );
         }
         chmax(ret, dp[i][j]);
      }
   }
   return(ret);
}

signed main()
{
   FAST();
   int N;
   cin >> N;
   rep(i, N){
      string a,b;
      cin >> a >> b;
      outl( slv(a, b) );
   }
}




Measured memory_bytes: 7120
package main

import "fmt"

const (
	A = 0
	B = 1
	C = 2
)

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	var v [3][100000]int
	var dp [3][100000]int

	var N int
	fmt.Scan(&N)
	for i := 0; i < N; i++ {
		fmt.Scan(&v[A][i], &v[B][i], &v[C][i])
	}
	dp[A][0] = v[A][0]
	dp[B][0] = v[B][0]
	dp[C][0] = v[C][0]
	for i := 1; i < N; i++ {
		dp[A][i] = max(dp[B][i-1], dp[C][i-1]) + v[A][i]
		dp[B][i] = max(dp[A][i-1], dp[C][i-1]) + v[B][i]
		dp[C][i] = max(dp[A][i-1], dp[B][i-1]) + v[C][i]
	}
	ans := max(max(dp[A][N-1], dp[B][N-1]), dp[C][N-1])
	fmt.Println(ans)
}


Measured memory_bytes: 9200
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readInts >>= print . foldl (*) 1 . map pred

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

int main() {
    int n;
    cin>>n;
    vector<int>ans(n);
    for(int i=0;i<n;i++)
        cin>>ans[i];
    sort(ans.begin(),ans.end());
    for(int i=0;i<n-1;i++){
        if(ans[i]==ans[i+1]){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
	return 0;
}

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

void ti(){
  #ifndef ONLINE_JUDGE
    freopen("in.txt", "r+", stdin);
    freopen("out.txt", "w", stdout);
  #endif
}

typedef long long ll;

int main(){

  // ti();
  int n; cin>>n;
  map<string, int> m;
  while(n--){
    string a; cin>>a;
    m[a]++;
  }

  cout<<"AC x "<<m["AC"]<<endl;
  cout<<"WA x "<<m["WA"]<<endl;
  cout<<"TLE x "<<m["TLE"]<<endl;
  cout<<"RE x "<<m["RE"]<<endl;

  return 0;
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  int d = a / b;
  int r = a % b;
  double f = (double)a / b;
  printf("%d %d %.5f\n", d, r, f);
  return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<algorithm>
using namespace std;
struct puke
{
    char Suit;
    int Value;
};
void selectionSort(puke a[],int N)
{
    for(int i=0;i<N;i++)
    {
        int s=i;
        for(int j=i;j<N;j++)
        {
            if(a[j].Value<a[s].Value)
               {
                   s=j;
               }


        }
          swap(a[i].Value,a[s].Value);
             char k;
             k=a[i].Suit;
             a[i].Suit=a[s].Suit;
             a[s].Suit=k;
    }
}
void BubbleSort(puke a[],int N)
{
    for(int i=0;i<N-1;i++)
        for(int j=0;j<N-i-1;j++)
    {
        if(a[j].Value>a[j+1].Value){
             swap(a[j].Value,a[j+1].Value);
             char s;
             s=a[j].Suit;
             a[j].Suit=a[j+1].Suit;
             a[j+1].Suit=s;
        }

    }
}
bool isStable(puke a1[],puke a2[],int N)
{
    for(int i=0;i<N;i++)
    {
         if(a1[i].Suit!=a2[i].Suit)
        return false;
    }

    return true;
}
int main()
{
    puke a1[36],a2[36];
    int N;
    cin>>N;
    for(int i=0;i<N;i++)
     {
         cin>>a1[i].Suit>>a1[i].Value;

     }
     for(int i=0;i<N;i++)
        a2[i]=a1[i];

     BubbleSort(a1,N);
     for(int i=0;i<N;i++)
     {
         if(i)
            cout<<" ";
         cout<<a1[i].Suit<<a1[i].Value;
     }
     cout<<endl;
     cout<<"Stable"<<endl;

        selectionSort( a2,N);
         for(int i=0;i<N;i++)
     {
         if(i)
            cout<<" ";
         cout<<a2[i].Suit<<a2[i].Value;
     }
     cout<<endl;
     if( isStable( a1,a2, N))
        cout<<"Stable"<<endl;
     else
        cout<<"Not stable"<<endl;


     return 0;


}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}





int main(){

  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  while(a>=b){
    b*=2;
    k--;
  }
  while(b>=c){
    c*=2;
    k--;
  }
  if(k>=0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N,M;
  cin >> N >> M;
  vector<int> p(M);
  vector<string> S(M);
  for (int i = 0; i < M; i++){
    cin >> p[i] >> S[i];
    p[i]--;
  }
  vector<int> WA(N,0);
  vector<bool> AC(N,false);
  for (int i = 0; i < M; i++){
    if (S[i] == "AC"){
      AC[p[i]] = true;
    } else {
      if (!AC[p[i]]) WA[p[i]]++;
    }
  }
  int cr = 0;
  int pn = 0;
  for (int i = 0; i < N; i++){
    if (AC[i]){
      cr++;
      pn += WA[i];
    }
  }
  cout << cr << ' ' << pn;
}

Measured memory_bytes: 6528
#include<stdio.h>

int main(void){
    int a,b;
    scanf("%d %d", &a, &b);
    if (a*b >= a+b && a*b >= a-b)
        printf("%d", a*b);
    else if (a+b >= a*b && a+b >= a-b)
        printf("%d", a+b);
    else
        printf("%d",a-b);  
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int a = sc1.nextInt();
		int b = sc1.nextInt();
		int c = sc1.nextInt();

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

		sc1.close();

	}

}


Measured memory_bytes: 26332
#include <iostream>
#include <set>
#include <algorithm>

int LIMIT = 100000 + 1;


int main(){

    int n = 0;
    std::cin >> n;
    int min_count = 1000000;
    

    for(int i = 0; i <= n; ++i){
        int array[] = {i, n-i};
        int sn[] = {6, 9};
        auto count = 0;
        
        for(int j = 0; j < 2; ++j){
           
           while(array[j]>0){
            count += array[j]%sn[j];
            array[j] /= sn[j];
           }
        }

        min_count = std::min(count, min_count);
     }



    std::cout << min_count  << std::endl;

    return 0;

}



Measured memory_bytes: 256
"""
input(): 入力を文字列として1行取ってくる
"文字列".split(): 文字列をパースする（空白などで分割する）
    例："2 3 4 5"　をsplitしたら、[2, 3, 4, 5] に分割する
map(型, list): list の中身をそれぞれ指定した型で変数に入れる
"""
N, M = map(int, input().split())

if N == M:
    print("Yes")
else:
    print("No")


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

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

  vector<int> Aji(N);
  int Sum = 0;
  int AjiMin = INT_MAX;
  int EatApple = 0;
  rep( i, 0, N ) {
    if ( i==0 ) Aji.at(i) = L;
    else Aji.at(i) += Aji.at( i-1 ) + 1;
    Sum += Aji.at(i);
    int AbsVal = abs( Aji.at(i) );
    if ( AbsVal < AjiMin ) {
      AjiMin = AbsVal;
      EatApple = Aji.at(i);
    }
  }
  cout << Sum - EatApple <<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

/** https://atcoder.jp/contests/aising2020/tasks/aising2020_d */
public class Main {

  private static void solve(String X, int N) {
    char[] A = X.toCharArray();
    int bitCnt = 0;
    for (char c : A) {
      if (c == '1') {
        bitCnt++;
      }
    }
    if (bitCnt == 0) {
      for (int i = 0; i < N; i++) {
        System.out.println(1);
      }
    } else {
      int[] pow1 = new int[N];
      int[] pow0 = new int[N];
      pow1[0] = 1;
      pow0[0] = 1;
      for (int i = 1; i < N; i++) {
        pow1[i] = (2 * pow1[i - 1]) % (bitCnt + 1);
        if (bitCnt == 1) continue;
        pow0[i] = (2 * pow0[i - 1]) % (bitCnt - 1);
      }
      int sum1 = 0;
      int sum0 = 0;
      for (int i = 0; i < N; i++) {
        if (A[i] == '1') {
          sum1 = (sum1 + pow1[N - 1 - i]) % (bitCnt + 1);
          if (bitCnt == 1) continue;
          sum0 = (sum0 + pow0[N - 1 - i]) % (bitCnt - 1);
        }
      }
      for (int i = 0; i < N; i++) {
        if (A[i] == '1') {
          if (bitCnt == 1) {
            System.out.println(0); // val % 1 = 0
            continue;
          }
          int val = Math.floorMod(sum0 - pow0[N - 1 - i], bitCnt - 1);
          System.out.println(getStepsCnt(val));
        } else {
          int val = (sum1 + pow1[N - 1 - i]) % (bitCnt + 1);
          System.out.println(getStepsCnt(val));
        }
      }
    }
  }

  private static int getStepsCnt(int val) {
    int cnt = 1;
    while (val > 0) {
      val = val % Integer.bitCount(val);
      cnt++;
    }
    return cnt;
  }

  public static void main(String[] args) {
    int N = scanner.nextInt();
    String X = scanner.next();
    solve(X, N);
  }

  private static final Scanner scanner = new Scanner(System.in);
}


Measured memory_bytes: 60884
#include<bits/stdc++.h>
using namespace std;
int main()
{
  char ch;
  cin>>ch;
  
  if(ch=='a')
  cout<<"b"<<endl;
  else if(ch=='b')
  cout<<"c"<<endl;
  else if(ch=='c')
  cout<<"d"<<endl;
  else if(ch=='d')
  cout<<"e"<<endl;
  else if(ch=='e')
  cout<<"f"<<endl;
  else if(ch=='f')
  cout<<"g"<<endl;
  else if(ch=='g')
  cout<<"h"<<endl;
  else if(ch=='h')
  cout<<"i"<<endl;
  else if(ch=='i')
  cout<<"j"<<endl;
  else if(ch=='j')
  cout<<"k"<<endl;
  else if(ch=='k')
  cout<<"l"<<endl;
  else if(ch=='l')
  cout<<"m"<<endl;
  else if(ch=='m')
  cout<<"n"<<endl;
  else if(ch=='n')
  cout<<"o"<<endl;
  else if(ch=='o')
  cout<<"p"<<endl;
  else if(ch=='p')
  cout<<"q"<<endl;
  else if(ch=='q')
  cout<<"r"<<endl;
  else if(ch=='r')
  cout<<"s"<<endl;
  else if(ch=='s')
  cout<<"t"<<endl;
  else if(ch=='t')
  cout<<"u"<<endl;
  else if(ch=='u')
  cout<<"v"<<endl;
  else if(ch=='v')
  cout<<"w"<<endl;
  else if(ch=='w')
  cout<<"x"<<endl;
  else if(ch=='x')
  cout<<"y"<<endl;
  else if(ch=='y')
  cout<<"z"<<endl;
  else if(ch=='z')
  cout<<"a"<<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=5e3+5,M=5e3+5,INF=1e9,mod=998244353;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
int a[N][N],s[N][N],s1[N][N],s2[N][N],n,m,q;
char st[N];
int sum(int s[N][N],int x1,int y1,int x2,int y2){return s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1];}
int main(){
	read(n,m,q);rep(i,1,n){
		scanf("%s",st+1);
		rep(j,1,m){
			a[i][j]=st[j]=='1';
			s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+a[i][j];
		}
	}
	rep(i,1,n)rep(j,1,m){
		s1[i][j]=s1[i-1][j]+s1[i][j-1]-s1[i-1][j-1]+(a[i][j]&&a[i+1][j]);
		s2[i][j]=s2[i-1][j]+s2[i][j-1]-s2[i-1][j-1]+(a[i][j]&&a[i][j+1]);
	}
	while(q--){
		int x1,y1,x2,y2;read(x1,y1);read(x2,y2);
		printf("%d\n",sum(s,x1,y1,x2,y2)-sum(s1,x1,y1,x2-1,y2)-sum(s2,x1,y1,x2,y2-1));
	}
}

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

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
#include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int main() {
	int n;
	while (1) {
		cin >> n;
		if (n == 0) {
			break;
		}
		int count = 0;
		vector<int> vec(n, 0);
		for (int i = 0; i < n; i++) {
			cin >> vec[i];
		}
		double mean = accumulate(vec.begin(), vec.end(), 0.0) / vec.size();
		sort(vec.begin(), vec.end());
		for (auto itr = vec.begin(); itr < vec.end(); itr++) {
			if (*itr <= mean) {
				count++;
			} else {
				break;
			}
		}
		cout << count << endl;
	}
	// std::cout << "\e[38;5;0m\e[48;5;40m --- end ---  \e[m" << std::endl; // debug
	return 0;
}



Measured memory_bytes: 3156
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
const int INF = 1001001001;
const ll MOD = 1e9+7;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill((T*)array, (T*)(array+N),val);}

class CompareDist
{
public:
    bool operator()(PLL n1,PLL n2) {
				if(n1.first!=n2.first) return n1.first<n2.first;
				else return n1.second<n2.second;
    }
};


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n; cin>>n;
  int k = n/100; int t = n%100;
  if(0<=t&&t<=5*k) cout << 1 << endl;
  else cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
S = [1 if(_ =="B") else 0 for _ in input()]+[1]
ans = 0
if(S.index(1) == len(S)-1):
    print(0)
else:
    S.pop(-1)
    first = S.index(1)
    count = first
    start = first
    for s in S[start:]:
        if(s == 0):
            ans += count -first
            first += 1
        count += 1
    print(ans)

Measured memory_bytes: 6560
#include <iostream>
using namespace std;
int main() {
  int N; cin >> N;
  int ans = -1000000010;
  int min, r;
  cin >> min;

  for (int i = 1; i < N; i++) {
    cin >> r;
    ans = (ans < r-min) ? r-min : ans;
    min = (r < min) ? r : min;
  }
  cout << ans << endl;
}




Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define Fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20)
#define endl '\n'
#define pb push_back
#define N 1000009
#define ff first
#define ss second
#define all(x) x.begin(),x.end() 
int main()
{
	Fast;
	ll n,a,b;
	cin>>n>>a>>b;
	ll x=n/(a+b);
	ll y=n%(a+b);
	cout<<x*a+min(y,a)<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#ifdef LOCAL
  #include "helper_funcs.hpp"
#else
  #include <bits/stdc++.h>
#endif
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define frn(i,a,b) for(ll i=a;i<b;i++)
#define rfrn(i,a,b) for(ll i=a;i>b;--i)
#define forn(i,a,b) for(ll i=a;i<=b;i++)
#define rforn(i,a,b) for(ll i=a;i>=b;--i)
#define sqfrn(i,a,b) for(ll i=a;i*i<b;i++)
#define sqforn(i,a,b) for(ll i=a;i*i<=b;i++)
#define frt(it,v) for(auto &it:v)
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define SQR(a) (a)*(a)
#define SUM(n) ((n)*(n+1))/2
// #define SqSUM(n) ((n)*(n+1)*(2*n+1))/2
// #define GMSUM(a,r,n) (a*pow(r,n)-a)/(r-1)
#define ciel(x, y) (((x) / (y)) + ((x) % (y) != 0))
#define input(v,a,b) for(ll i = a ; i<b ; i++) cin>>v[i]
#define output(v,a,b) cout<<"["<<#v<<"]: "; for(ll i = a ; i<b ; i++) cout<<v[i]<<" "; cout<<ln
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl
#define dbg(x) cerr << #x << "is" << (x) << endl
#define leadzero(a) __builtin_clz(a)      // count leading zeroes
#define trailzero(a) __builtin_ctz(a)     // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln "\n"
const long long int md = 998244353;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
typedef vector<ll> v1;
typedef vector<vector<ll > > vv2;
#define M 32
#ifndef M_PI
  #define M_PI 3.14159265358979323846
#endif
typedef bitset<M> btst;
typedef priority_queue<int, vector<int>, greater<int>> min_heap;
typedef priority_queue<int, vector<int>> max_heap;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
//     indexed_set;
const ll MAX = LONG_MAX;
const ll lrg = 1000000007;

void solve()
{
    string st;
    cin>>st;
    cout<<st.substr(0,3);
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); 
  int t=1,cp;
  // cin>>t;
  cp=t;
  while(t--){
   // cout<<"Case #"<<cp-t<<": ";
   solve();
   cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3604
N, A, B = map(int,input().split());
X = list(map(int,input().split()));

dist =[X[i+1]-X[i] for i in range(N-1)];

fatigue = 0;
for i in dist:
    if i*A<B:
        fatigue += i*A;
    else:
        fatigue += B;

print(fatigue);

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

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

    string s, t;
    cin >> s >> t;

    char x, y;
    string result;

    for (int i = 0; i < N; i++) {
        x = s.at(i);
        result.push_back(x);
        y = t.at(i);
        result.push_back(y);
    }
    cout << result << endl;
}

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

using namespace std;

int main(void){
    int n = 0;
    int m = 0;
    int broken[100001] = {0};

    cin >> n ;
    cin >> m ;
    for(int i=0; i<m; i++){
        int brokenstep = 0;
        cin >> brokenstep;
        broken[brokenstep] = -1;
//       cout << "bs:" << brokenstep << endl;
    }

    int dp[100002] = {0};
    dp[n]=1;
    for(int i=n-1; i>=0; i--){
        if(broken[i] == -1){
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i+1] + dp[i+2])%1000000007;
//        cout << "i:" << i << "  dp[i]:" << dp[i] << endl;
    }

    cout << dp[0];

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int k;

	cin >> k;

	if (k % 2 == 0) Out((k / 2) * (k / 2));
	else Out((k / 2) * (k / 2 + 1));
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int alice=0;
    int bob= 0;
    for (int i = n-1; 0 <= i; i=i-2)
    {
        alice = alice + a[i];
    }
    for (int i = n-2; 0 <= i; i = i-2)
    {
        bob = bob + a[i];
    }
    cout << alice - bob << endl;
    
}

Measured memory_bytes: 3612
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()

int N,M;
LL c[100005] = {};
vector<int> edge[100005];
int st;
bool ok = false;
void dfs(int now, int moto){
	if(now != st && c[now] == 4) return;
	for(int i=0; i<edge[now].size(); i++){
		if(edge[now][i] == moto) continue;
		if(edge[now][i] == st){
			ok = true;
			return;
		}
		dfs(edge[now][i],now);
		if(ok) return;
	}
}
int main(){
	cin >> N >> M;
	for(int i=0; i<M; i++){
		int A,B;
		cin >> A >> B;
		A--; B--;
		edge[A].PB(B);
		edge[B].PB(A);
		c[A]++;
		c[B]++;
	}

	LL f = 0;
	bool only = true;
	for(int i=0; i<N; i++){
		if(c[i] > 0 && c[i]%2 == 0){
			f += c[i]/2-1;
			if(c[i] != 2 && c[i] != 4) only = false;
		}
		else{
			cout << "No" << endl;
			return 0;
		}
	}
	if(f < 2){
		cout << "No" << endl;
		return 0;
	}
	if(only && f==2){
		for(int i=0; i<N; i++){
			if(c[i] == 4){
				st = i;
				dfs(i,-1);
				if(ok) cout << "Yes" << endl;
				else cout << "No" << endl;
				return 0;
			}
		}
		
	}

	
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 7680
#agc026a

n=int(raw_input())
a=map(int,raw_input().split())
a.append(0)
cnt=0
temp=1
for i in xrange(1,n+1):
 if a[i]==a[i-1]:
  temp+=1
 else:
  cnt+=temp/2
  temp=1
print cnt


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

typedef long long ll;

int main(){
  int N, C;
  cin >> N >> C;
  vector<vector<int> > color_cost_list(C, vector<int>(C));
  for (int i = 0; i < C; i++) {
    for (int j = 0; j < C; j++) {
      cin >> color_cost_list[i][j];
    }
  }

  vector<vector<int> > grid(N, vector<int>(N));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> grid[i][j];
      grid[i][j]--;
    }
  }
  
  // グリッドを3つに塗り分ける。その際の各カラー毎のコスト
  vector<vector<int> > grid_color(3, vector<int>(C));
  for (int c = 0; c < C; c++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        grid_color[(i + j) % 3][c] += color_cost_list[grid[i][j]][c];
      }
    }
  }

  int ans = INT_MAX;
  for (int i = 0; i < C; i++) {
    for (int j = 0; j < C; j++) {
      for (int k = 0; k < C; k++) {
        // 色がかぶる場合
        if (i == j || j == k || i == k) {
          continue;
        }
        ans = min(ans, grid_color[0][i] + grid_color[1][j] + grid_color[2][k]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1280
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

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

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

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

	h,w := scanInt(), scanInt()
	a := make([][]int, h)

	for i := 0; i < h; i++ {
		a[i] = scanInts(w)
	}

	ans := make([]act, 0)

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if a[i][j]%2 == 1 {
				if i == h-1 {
					if j == w-1 {
						continue
					}
					a[i][j+1]++
					ans = append(ans, act{i+1,j+1,i+1,j+2})
					continue
				}
				a[i+1][j]++
				ans = append(ans, act{i+1,j+1,i+2,j+1})
			}
		}
	}

	fmt.Println(len(ans))

	for i := 0; i < len(ans); i++ {
		fmt.Fprintln(wr, ans[i].y,ans[i].x,ans[i].nexty,ans[i].nextx)
	}
	wr.Flush()
}

type act struct {
	y int
	x int
	nexty int
	nextx int
}


Measured memory_bytes: 21120