akhauriyash/Code-Regression huggingface dataset:
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// solution 
const MOD: i64 = 1_000_000_007;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: i64,
        M: i64,
    }

    match (N-M).abs() {
        0 => println!("{}", (2 * factorial(N) * factorial(M))%MOD ),
        1 => println!("{}", (factorial(N) * factorial(M))%MOD ),
        _ => println!("0"),
    }
}

fn factorial(n: i64) -> i64 {
    if n == 0 {
        return 1
    } else {
        (n * factorial(n-1))%MOD
    }
}


Measured memory_bytes: 5884
import qualified Data.ByteString.Char8 as B
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  n <- readLn
  as <- getInts
  print $ solve n as

solve :: Int -> [Int] -> Int
solve _ = maximum . calcGCDs

calcGCDs :: [Int] -> [Int]
calcGCDs as = map (uncurry gcd') $ zip ls (tail rs) where
  ls = scanl gcd 0 as
  rs = scanr gcd 0 as

gcd' :: Int -> Int -> Int
gcd' 0 b = b
gcd' a 0 = a
gcd' a b = gcd a b

readInts :: B.ByteString -> [Int]
readInts = map (fst . fromJust . B.readInt) . B.words

getInts :: IO [Int]
getInts = readInts <$> B.getLine


Measured memory_bytes: 27900
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;

const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };
struct aa
{
	int y;
	int x;
	int turn;
};
int main() {
	while (1) {
		int W, H; cin >> W >> H;
		if (!W)break;
		vector<vector<int>>field(H + 2, vector<int>(W+2));
		int sx, sy;
		vector<pair<int, int>>dirtys;
		for (size_t i = 0; i < H; i++)
		{
			string st; cin >> st;
			for (size_t j = 0; j < W; j++)
			{
				if (st[j] == 'o') {
					field[i + 1][j + 1] = true;
					sx = j + 1;
					sy = i + 1;
				}
				else if (st[j] == '*') {
					field[i + 1][j + 1] = true;
					dirtys.push_back(make_pair(i + 1, j + 1));
				}
				else if (st[j] == 'x') {
				}
				else {
					field[i + 1][j + 1] = true;
				}
			}
		}
		dirtys.push_back(make_pair(sy, sx));
		vector<vector<int>>times(dirtys.size(), vector<int>(dirtys.size(),99999999));
		for (int from = 0; from  < dirtys.size(); ++from) {
			queue<aa>que;
			vector<vector<int>>memo(H + 2, vector<int>(W + 2,9999999));
			que.push(aa{ dirtys[from].first,dirtys[from].second,0 });
			while (!que.empty()) {
				aa atop(que.front());
				que.pop();
				for (size_t i = 0; i < 4; i++)
				{
					const int nx = atop.x + dx[i];
					const int ny = atop.y + dy[i];
					if (field[ny][nx] && memo[ny][nx]>atop.turn + 1) {
						memo[ny][nx] = atop.turn + 1;
						que.push(aa{ ny,nx,atop.turn + 1 });
						auto it = find(dirtys.begin(), dirtys.end(), make_pair(ny, nx));
						if (it != dirtys.end()) {
							times[from][it - dirtys.begin()] = atop.turn + 1;
						}
					}
				}
			}
		}
		vector<int>perms(dirtys.size() - 1);
		iota(perms.begin(), perms.end(), 0);
		long long int ans = 9999999;
		do
		{
			long long int ntime = 0;
			ntime += times[dirtys.size() - 1][perms[0]];
			for (size_t i = 0; i < perms.size()-1; i++)
			{
				ntime += times[perms[i]][perms[i + 1]];
			}
			ans = min(ans, ntime);
		} while (next_permutation(perms.begin(),perms.end()));
		if (ans > 9999998) {
			ans = -1;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)
#define rep(i, n) repi(i, 0, n)
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
// using P = pair<int, int>;
struct Vec{
    double x, y;
};
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;
}
using namespace std;
int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    int n;
    cin >> n;
    vector<ll> l(n);
    rep(i, n) cin >> l[i];
    int ans = 0;
    rep(i, n) repi(k, i, n) repi(m, k, n){
        if (l[i] == l[k] || l[k] == l[m] || l[m] == l[i]) continue;
        vector<ll> ed{l[i], l[k], l[m]};
        sort(ed.begin(), ed.end());
        if (ed[2] < (ed[0] + ed[1])) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int T=10000000;
int main()
{
    int cnt=0,a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    while(T--)
    {
        int ta,tb,tc;
        if(a%2==0&&b%2==0&&c%2==0)
        {
            ta=b/2+c/2;
            tb=a/2+c/2;
            tc=a/2+b/2;
        }
        else
        {
            printf("%d\n",cnt);
            return 0;
        }
        a=ta;
        b=tb;
        c=tc;
        cnt++;
    }
    printf("-1\n");
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 310

int h,w;
int a[SIZE][SIZE];
ll dp[SIZE][SIZE][SIZE];

int main(){
  
  scanf("%d%d",&h,&w);
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      scanf("%d",a[i]+j);
      for(int k=0;k<w;k++) dp[i][j][k] = -LLINF;
    }
  }

  dp[0][0][0] = a[0][0];
  
  for(int i=0;i<h;i++){
    if(i > 0)
      for(int j=0;j<w;j++){
        for(int k=0;k<w;k++){
          if(j==k) dp[i][j][k] = dp[i-1][j][k] + a[i][j];
          else dp[i][j][k] = dp[i-1][j][k] + a[i][j] + a[i][k];
        }
      }
    
    for(int j=0;j<w-1;j++){
      for(int k=0;k<w;k++){
        if(j+1 != k)
          dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k] + a[i][j+1]);
        else
          dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);          
      }
    }
    for(int j=0;j<w;j++){
      for(int k=0;k<w-1;k++){
        if(j < k+1)
          dp[i][j][k+1] = max(dp[i][j][k+1], dp[i][j][k] + a[i][k+1]);
        else
          dp[i][j][k+1] = max(dp[i][j][k+1], dp[i][j][k]);
      }
    }
  }

  printf("%lld\n",dp[h-1][w-1][w-1]);
  
  return 0;
}



Measured memory_bytes: 151424
n, m = map(int, input().split())
a = [[] for _ in range(n)]
 
for i in range(n):
  a[i] = list(map(int, input().split()))
 
b = [0 for _ in range(m)]
for i in range(m):
  b[i] = int(input())
 
for i in range(n):
  c = 0
 
  for j in range(m):
    c += a[i][j]*b[j]
 
  print(c)


Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=2e5+10;
//const int MOD=1e9+7;

template <typename T>
struct SegmentTree{
  using F = function<T(T,T)>;
  int n;
  F f;
  T ti;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(F f,T ti):f(f),ti(ti){}
  void init(int n_){    
    n=1;
    while(n<n_) n<<=1;
    dat.assign(n<<1,ti);
  }
  void build(const vector<T> &v){
    int n_=v.size();
    init(n_);
    for(int i=0;i<n_;i++) dat[n+i]=v[i];
    for(int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
  }
  void set_val(int k,T x){
    dat[k+=n]=x;
    while(k>>=1)
      dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);    
  }
  T query(int a,int b){
    T vl=ti,vr=ti;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[l++]);
      if(r&1) vr=f(dat[--r],vr);
    }
    return f(vl,vr);
  }
  template<typename C>
  int find(int a,int b,C &check,int k,int l,int r){
    if(!check(dat[k])||r<=a||b<=l) return -1;
    if(k>=n) return k-n;
    int m=(l+r)>>1;
    int vl=find(a,b,check,(k<<1)|0,l,m);
    if(~vl) return vl;
    return find(a,b,check,(k<<1)|1,m,r);
  }
  template<typename C>
  int find(int a,int b,C &check){
    return find(a,b,check,1,0,n);
  }
};

int N;
int h[MAX];
ll a[MAX];
ll ans;
void solve(){
    cin>>N;
    rep(i,N){cin>>h[i];h[i]--;}
    rep(i,N)cin>>a[i];

	auto f=[](ll a,ll b){
		return max(a,b);
	};
    ll ti=0ull;
    SegmentTree<ll> seg(f,ti);
    seg.init(N);

    rep(i,N){
        ll tmp=seg.query(0,h[i]);
        seg.set_val(h[i], tmp+a[i]);
    }
    ans=seg.query(0,N);
    cout<<ans<<endl;
}

int main(){
    solve();
}

Measured memory_bytes: 6656
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(long long N, std::vector<long long> A);

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
}

void solve(long long N, std::vector<long long> A){
    ll ans = 1;
    REP(i, N){
        if(A[i] == 0){
            cout << 0 << el;
            return;
        }
    }
    REP(i, N){
        double n = log10(ans) + log10(A[i]);
        if(n>18.0){
            cout << -1 << el;
            return;
        }
        ans *= A[i];
    }
    if(ans>1000000000000000000ll){
        cout << -1 << el;
    }else{
        cout << ans << el;
    }
}



Measured memory_bytes: 4032
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n, T, H, L;
  scanf("%d %d %d %d", &n, &T, &H, &L);
  vector<int> t(n), h(n);

  REP(i,n){
    scanf("%d %d", &t[i], &h[i]);
  }

  int sum = 0;
  while(true){

    REP(i,n){
      if(t[i] == 0 && h[i] == 0){
        printf("%d\n", i + 1);
        return 0;
      }

      if(t[i] > 0){
        t[i]--;
        sum++;
        T++;
        if(T > L){
          printf("%d\n", i + 1);
          return 0;
        }
        if(sum == 9){
          sum = 0;
        }
      }else{
        h[i]--;
        sum += 10;
        int oturi = sum - 9;
        sum = 0;
        //oturi 払えないとき
        if(T < oturi){
          //cout << oturi << endl;
          printf("%d\n", i + 1);
          return 0;
        }
        T -= oturi;
        t[i] += oturi;
      }
    }
  }
  return 0;
}




Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int a[20][20],n;
bool ch(int b){
  return 0<=b&&b<n;
}
int main(){
  while(cin>>n,n){
    memset(a,0,sizeof(a));
    int t=0,x=n/2,y=n/2+1;
    while(t!=n*n){
      if(ch(y)&&ch(x)&&!a[y][x])a[y++][x++]=++t;
      else 
	{
	  if(ch(y)&&ch(x))x--,y++;
	  else{
	    if(y==n)y=0;
	    if(y==-1)y=n-1;
	    if(x==n)x=0;
	    if(x==-1)x=n-1;
	  }
	}
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++)
	printf("%4d",a[i][j]);
      cout<<endl;
    }
  }
  return 0;
}

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

vector<vector<int>> G(100010);
vector<int> dp(100010, -1);

int solve(int start){
  if(dp.at(start) == -1){
    dp.at(start) = 0;
    for(int v : G.at(start)){
      dp.at(start) = max(dp.at(start), solve(v) + 1);
    }
  }
  return dp.at(start);
}

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

  rep(i,M){
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    G.at(x).push_back(y);
  }

  int res = -1;
  rep(i,N){
    res = max(res,solve(i));
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define res register int
#define mod 1000000007
#define N 8005
#define M 200005
#define ll long long
using namespace std;
int n,a[M],b[M],jie[N],inv[N];
int f[N][N];
inline int read()
{
  int X=0,w=0;
  char ch=0;
  while(!isdigit(ch))
  {
    w|=ch=='-';
    ch=getchar();
  }
  while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
  return w?-X:X;
}
inline int &F(res x,res y)
{
  return f[x+2001][y+2001];
}
inline void init()
{
  jie[0]=1;
  for(res i=1; i<=8000; i++)
    jie[i]=1LL*jie[i-1]*i%mod;
  inv[1]=1;
  for(res i=2; i<=8000; i++)
    inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
  inv[0]=1;
  for(res i=1; i<=8000; i++)
    inv[i]=1LL*inv[i]*inv[i-1]%mod;
}
inline int C(int x,int y)
{
  return 1LL*jie[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
  n=read();
  init();
  for(res i=1; i<=n; i++) F(-(a[i]=read()),-(b[i]=read()))++;
  for(res i=-2000; i<=2000; i++)
    for(res j=-2000; j<=2000; j++)
      F(i,j)=((ll)F(i,j)+F(i-1,j)+F(i,j-1))%mod;
  int ans=0;
  for(res i=1; i<=n; i++) ans=((ll)ans+F(a[i],b[i])-C(a[i]+a[i]+b[i]+b[i],b[i]+b[i]))%mod;
  ans=1LL*ans*(mod+1>>1)%mod;
  printf("%d\n",(ans+mod)%mod);
  return 0;
}

Measured memory_bytes: 128512
#include <bits/stdc++.h>
using namespace std;
int n;
string s="hello world!",pre;
int main() 
{
    cin>>n;
    int a=0,b=n,c=n/2;
    cout<<0<<endl;
    cin>>pre;
    s=pre;
    while(s!="Vacant") 
	{
        cout<<c<<endl;
        cin>>s;
        if((pre==s)xor(a%2==c%2)) 
		{
            b=a; a=c;
        } else a=c;
        c=(a+b)/2;
        pre=s;
    }
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){ cin.sync_with_stdio(0);
    ll N; cin >> N;

    ll twos = 0;
    ll fours = 0;
    ll primes = 0;

    FOR(i, 0, N) {
	ll tmp; cin >> tmp;
	if (tmp % 4 == 0) fours ++;
	else if (tmp % 2 == 0) twos ++;
	else primes ++;
    }

    bool possible = false;

    if (fours >= primes) {
	possible = true;
    } else if (primes == fours + 1 && twos == 0) {
	possible = true;
    } else {
	possible = false;
    }

    if (possible) {
	cout << "Yes" << endl;
    } else {
	cout << "No" << endl;
    }
} //cin.tie(0) bei schnellem Wechseln


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace AtCoder
{
	public class Program
	{
		// ABC105-B
		static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());

			// cake = 4;
			// donuts = 7;
			for (int cake = N / 4; cake >= 0; cake--) {
				int donuts = (N - (cake * 4)) / 7;
				if (cake * 4 + donuts * 7 == N) {
					//Console.WriteLine(cake + "*4 + " + donuts + "*7 = " + N);
					Console.WriteLine("Yes");
					return;
				}
			}
			Console.WriteLine("No");
		}
	}
}


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

using namespace std;

#define ll long long
#define ld long double
#define ff first
#define ss second
#define rsz resize
#define ins insert 
#define mp make_pair
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define ft front() 
#define bk back()
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define deb(x) cout<<#x<<" "<<x<<'\n';
#define rep(i,a,b) for (int i = (a); i < (b); ++i)

const ll mod = 1e9+7; // 998244353;
const ll inf = 1e18; 
const ld pie = acos((ld)-1);

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

template<typename T>
vector<T> factor(T n) {
    vector<T> factorization;
    while (n%2==0) {
        factorization.push_back(2);
        n/= 2;
    }
    for (T d=3; d*d<=n; d+= 2) {
        while (n%d==0) {
            factorization.push_back(d);
            n/= d;
        }
    }
    if (n>1)
        factorization.push_back(n);
    factorization.pb(1);
    return factorization;
}

int main(){
    
	int n;
	scanf("%d",&n);
	ll ans=0;
	for(int i=1;i<n;++i){
		ans+=(n-1)/i;
	}
	
	printf("%lld\n",ans);

	return 0;

	/*STUFF TO LOOK:	
		1. Check the constraints
		2. Corner cases(n==0||n==1)
		3. Variables in loops
		4. Make sure two ints aren’t multiplied to get a long long
		5. Don't use scanf or printf while using ios_base
		6. using the local variable of the same name when global variable was required to be used
	*/
}


Measured memory_bytes: 3868
#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 _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))
#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 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 repit(x, y) for ((x) = (y).begin(); (x) != (y).end(); (x)++)
#define all(x) (x).begin(),(x).end()
#define _end '\n'
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 vvec = vector<vector<T> >;

#define pb push_back
#define mp make_pair

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

static const int N = 1e5 + 5;
static int prime[N + 1];

template <typename T>
class SegmentTree {
private:
	T *_data;
	int _size;

public:
	SegmentTree(int n) {
		_data = new T[n * 2];
		_size = n;
	}

	~SegmentTree() {
		delete[] _data;
	}

	int size() {
		return _size * 2;
	}

	void set(int index, T value) {
	    int x = prime[value] == 1 && prime[(value + 1) / 2] == 1 ? 1 : 0;

		for (_data[index += _size] = x; index > 1; index >>= 1) _data[index >> 1] = _data[index] + _data[index ^ 1];
	}

	// l inclusive
	// r exclusive
	void add(int l, int r, T value) {
		for (l += _size, r += _size; l < r; l >>= 1, r >>= 1) {
			if (l & 1) _data[l++] += value;
			if (r & 1) _data[--r] += value;
		}
	}

	// l inclusive
	// r exclusive
	T get(int l, int r) {
		T ret = 0;

		for (l += _size, r += _size; l < r; l >>= 1, r >>= 1) {
			if (l & 1) ret += _data[l++];
			if (r & 1) ret += _data[--r];
		}

		return ret;
	}
};

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    memset(prime, 0, sizeof(prime));

    prime[0] = -1;
    prime[1] = -1;

    int i, j;

    repiin(i, N, 2) {
        if (prime[i] == 0) prime[i] = 1;

        for (j = i + i; j <= N; j += i) prime[j] = -1;
    }

    SegmentTree<int> st(N);

    repin(i, N) st.set(i, i);

    int q, l, r;

    cin >> q;

    rep(i, q) {
        cin >> l >> r;

        r++;

        cout << st.get(l, r) << _end;
    }

    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(ll i = (ll)(n)-1;i >= 0;--i)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int m;
  cin >> m;
  cin.ignore();
  cin >> m;
  cout << (m<5?"Heisei":"TBD") << endl;
}



Measured memory_bytes: 764
#include<iostream>
#include<cmath>
#define pb push_back
#define en "\n"
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int t=1;
	//cin >> t;
	while (t--) {
		float n;
		cin>>n;
		cout<<2*M_PI*n<<endl;;	
	}
	return 0;
}

Measured memory_bytes: 3256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 998244353;

using namespace std;

int main() {

  int n;
  cin >> n;
  int ALL = (1 << n);
  ll dp[ALL] = {};
  ll a[n][n] = {};

  REP(i, n) {
    REP(j, n) { cin >> a[i][j]; }
  }

  REP(T, ALL) {
    // 切らない場合の計算
    REP(i, n) {
      int now = (T >> i) & 1;
      if (now == 0)
        continue;
      FOR(j, i, n) {
        int po = (T >> j) & 1;
        if (po == 1) {
          dp[T] += a[i][j];
        }
      }
    }

    for (int U = (1 << n) - 2; U > 0; --U) {
      U &= T;
      dp[T] = max(dp[T], dp[U] + dp[(~U) & T]);
    }
  }

  cout << dp[ALL - 1] << endl;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		int N = Integer.parseInt(input());

		for (int i = 0; i < N; i++) {

			double x1 = Double.parseDouble(input());
			double y1 = Double.parseDouble(input());
			double x2 = Double.parseDouble(input());
			double y2 = Double.parseDouble(input());
			double x3 = Double.parseDouble(input());
			double y3 = Double.parseDouble(input());

			double a1 = 2 * (x2 - x1);
			double b1 = 2 * (y2 - y1);
			double c1 = Math.pow(x1, 2) - Math.pow(x2, 2) + Math.pow(y1, 2) - Math.pow(y2, 2);
			double a2 = 2 * (x3 - x1);
			double b2 = 2 * (y3 - y1);
			double c2 = Math.pow(x1, 2) - Math.pow(x3, 2) + Math.pow(y1, 2) - Math.pow(y3, 2);

			double px = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
			double py = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
			double r = Math.sqrt(Math.pow((px - x1), 2) + Math.pow((py - y1), 2));

			System.out.println(String.format("%.3f %.3f %.3f", px, py, r));

		}

		close();

	}

	public static String input() {

		return scanner.next();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

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

void solve(std::string A, std::string B, std::string C) {
  if( A.back() == B.front() && B.back() == C.front()) cout << YES << endl;
  else cout << NO << endl;
}

int main() {
  std::string A;
  std::cin >> A;
  std::string B;
  std::cin >> B;
  std::string C;
  std::cin >> C;
  solve(A, B, C);
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n,t,x,y,i,lastx,lasty,lastt,p;
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d%d%d",&t,&x,&y);
		p=abs(x-lastx)+abs(y-lasty);
		if(p>t-lastt||(p-t+lastt)&1)
		{
			puts("No");
			return 0;
		}
		lastx=x;
		lasty=y;
		lastt=t;
	}
	puts("Yes");
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = getInt(sc);
		int[] b = getIntArray(sc);

		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			if (i == 0) {
				a[i] = b[i];
				continue;
			}
			if (i == n - 1) {
				a[i] = b[i - 1];
				continue;
			}
			a[i] = Math.min(b[i - 1], b[i]);
		}
		System.out.println(Arrays.stream(a).sum());

	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


Measured memory_bytes: 27220
#include <iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;

int main()
{
    int n,h=0;
    double a[60],s;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    s=a[0];
    for(int i=1;i<n;i++)
    {
        s=(s+a[i])/2.0;
    }
    cout<<s;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
const int maxn = 1e5+7;
int height[maxn];
int depth[maxn];
int fa[maxn];
vector<int> g[maxn];
bool vis[maxn];
int ans;
void dfs(int x,int d)
{
    vis[x] = true;
    depth[x] = d;
    for(int y:g[x])
    {
        if(!vis[y])
        {
            fa[y] = x;
            dfs(y,d+1);
            height[x] = max(height[x],height[y]+1) ;
        }
    }
    //ans = max(ans,d-1 + height[x] - 1);
}

int main()
{
    int n,u,v;
    cin>>n>>u>>v;
    for(int i=1;i<n;++i)
    {
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(v,0);
    int t = u;
    while(depth[t] > depth[u]/2)
    {
        ans = max(ans,depth[t]-1 + height[t]);
        t  = fa[t];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
const int maxn = 10000000 + 5;

int n;
int cnt[maxn];
void make_biao(){
    for(int i=2;i<=n;i++){
        for(int j=i;j<=n;j+=i){
            cnt[j]++;
        }
    }
}

signed main(){
    cin >> n;
    // for(int i=1;i<=n;i++){
    //     cnt[i]=i;
    // }
    make_biao();
    int ans=0;
    for(int i=1;i<=n;i++){
        ans += i*(cnt[i]+1);
    }
    cout << ans ;
    return 0;
}

Measured memory_bytes: 81736
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int len[55], cnt[55], ans = 0;

void recur(int lay, int left) {
    if (left == len[lay]) {ans += cnt[lay]; return;}
    if (left <= 1) return;
    if (left < len[lay-1] + 1) recur(lay - 1, left - 1);
    else {
        ans += cnt[lay-1] + (left >= len[lay-1] + 2);
        recur(lay - 1, left - len[lay-1] - 2);
    }
}

int32_t main() {
    fastIO();
    
    len[0] = 1, cnt[0] = 1;
    for (int i = 1; i < 55; ++i) {
        len[i] = 2 * len[i-1] + 3;
        cnt[i] = 2 * cnt[i-1] + 1;
    }
    
    int n, x;
    cin >> n >> x;
    
    recur(n, x);
    
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>

using std::cout;
using std::endl;
using std::cin;
using std::string;

int main(){
  int r;
  cin >>r;
  cout << std::setprecision(9) <<2*M_PI*r << endl;
}


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

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

void run() {
    int a, b, c;
    cin >> a >> b >> c;
    int res = a + b + c + 9 * max(a, max(b, c));
    cout << res << "\n";
}

static void run_with_stack_size(void (*func)(), size_t stackSize) {
    char *stack, *send;
    stack = (char*) malloc(stackSize);
    send = stack + stackSize - 16;
    send = (char*) ((uintptr_t) send / 16 * 16);
    asm volatile(
    "mov %%rsp, (%0)\n"
    "mov %0, %%rsp\n"
    :
    : "r" (send));
    func();
    asm volatile(
    "mov (%0), %%rsp\n"
    :
    : "r" (send));
    free(stack);
}

int main() {
#ifdef LOCAL
    freopen("input", "r", stdin);
#endif
    run_with_stack_size(run, 256*1024*1024);
#ifdef LOCAL
    fclose(stdin);
#endif
    return 0;
}

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

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    //int t=1 ; cin>>t ; while(t--)
    {
        int n;
        cin >> n;
        int a[n];
        for(int i=0;i<n;i++)
            cin >> a[i];

        if(a[0] > 1)
            a[0]--;
        for(int i=1;i<n;i++)
        {
            if(a[i] > 1 && a[i] > a[i-1])
                a[i]--;
        }

        for(int i=0;i<n-1;i++)
        {
            if(a[i] > a[i+1])
                return cout << "No\n", 0;
        }
        cout << "Yes\n";
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 1024
N, M = [int(s) for s in input().split()]
holder = ["undef" for i in range(N)]
if N == 1:
  if M == 0:
    print(0)
    exit()
  else:
    judge = True
    for i in range(M):
      si, ci = [int(s) for s in input().split()]
      if holder[si-1] != "undef":
        if holder[si-1] != ci:
          judge = False
          break
      if holder[si-1] == "undef":
         holder[si-1] = ci
    if judge:
      num_str = ""
      for i, s in enumerate(holder):
        if i == 0:
          if s == "undef":
            num_str = num_str + str(1)
          else:
            num_str = num_str + str(s)
        else:
          if s == "undef":
            num_str = num_str + str(0)
          else:
            num_str = num_str + str(s)
      print(num_str)
    else:
      print(-1)
else:
  judge = True
  for i in range(M):
    si, ci = [int(s) for s in input().split()]
    if holder[si-1] != "undef":
      if holder[si-1] != ci:
        judge = False
        break
    if holder[si-1] == "undef":
       holder[si-1] = ci
  if holder[0] == 0:
    judge = False
  
  if judge:
    num_str = ""
    for i, s in enumerate(holder):
      if i == 0:
        if s == "undef":
          num_str = num_str + str(1)
        else:
          num_str = num_str + str(s)
      else:
        if s == "undef":
          num_str = num_str + str(0)
        else:
          num_str = num_str + str(s)
    print(num_str)
  else:
    print(-1)

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

ll gcd(ll a, ll b) {
    while ( b != 0 ) {
        ll t = b;
        b = a % b;
        a = t;
    }
    return a;
}

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll CD = C / gcd(C, D) * D;

    ll bc = B / C, ac = (A-1) / C;
    ll bd = B / D, ad = (A-1) / D;
    ll bcd = B / CD, acd = (A-1) / CD;

    ll ans = B - A + 1 - (bc - ac) - (bd - ad) + (bcd - acd);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

string s1, s2, ans;
int n, m, dp[3001][3001];

int main()
{
    IOS
    //bfreopen("balalance.in", "r", stdin);
    cin >> s1 >> s2;
    n = (int) s1.size();
    m = (int) s2.size();
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (s1[i-1] == s2[j-1]) {
                dp[i][j] = 1 + dp[i-1][j-1];
            } else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    int i = n, j = m;

    while (i && j) {
        if (s1[i-1] == s2[j-1]) {
            ans.push_back(s1[i-1]);
            i--;
            j--;
        } else if (dp[i-1][j] > dp[i][j-1]) {
            i--;
        } else {
            j--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 35456
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
#define     PI          3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342
 
 
int main()
{
	double A,B,H,M;
	cin >>A>>B>>H>>M;
    
        H = H + (M/60);
        double X,res;
        X = H*30 - M*6; 
        res = sqrt(A*A + B*B - 2*A*B*cos((X*PI)/180));

       cout << showpoint<<fixed<<setprecision(20) << res << endl;

       biday;
}
 
//...............BYE BYE................

Measured memory_bytes: 4188
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int res = 0;
    for(int i = 0; i<=300;i++) {
        int h,w;
        cin >> h >> w;
        if (h == 0 && w == 0) {
            break;
        }
        for(int k = 0; k < h; k++) {
            for(int j = 0; j < w; j++) {
                if(k == 0 
                || k == h -1
                || j == 0
                || j == w -1) {
                cout << "#";
                } else {
                cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3076
import java.util.Scanner;
public class Main{
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String W = new String(sc.nextLine());
        String T = new String();
        int word=0;
         
        while(true){
            T = sc.next();
            if(T.equals("END_OF_TEXT")){
                sc.close();
                break;
            }
            if(T.equalsIgnoreCase(W)){
                word++;
            }
        }
        
        System.out.println(word);
        
        sc.close();
    }
}



Measured memory_bytes: 26168
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

const ll MOD = 1e9 + 7;

template <typename T>
map<T, int> factorize_num(T num) {
  map<T, int> result;
  T d = 2;
  while (d * d <= num) {
    if (num % d == 0) {
      num /= d;
      result[d]++;
    } else {
      d++;
    }
  }
  if (num != 1) result[num]++;
  return result;
}

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

  map<int, int> m;
  for (int i = 1; i <= n; i++) {
    auto ts = factorize_num(i);
    for (auto t : ts) m[t.first] += t.second;
  }

  ll ans = 1;
  for (auto e : m) {
    ans *= e.second + 1;
    ans %= MOD;
  }
  cout << ans << endl;
}


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

int main(){
    list<int> l;
    list<int>::iterator it=l.end();
    int q;
    cin>>q;
    while(q--){
        int y;
        cin>>y;
        if(y==0){
            int x;
            cin>>x;
            it=l.insert(it,x);
        }
        else if(y==1){
            int d;
            cin>>d;
            if(d>0){
                for(int i=0;i<d;i++){
                    it++;
                }
            }
            else{
                for(int i=d;i<0;i++){
                    it--;
                }
            }
        }
        else{
            it=l.erase(it);
        }
    }
    for(it=l.begin();it!=l.end();it++){
        cout<<*it<<endl;
    }
    return 0;
}


Measured memory_bytes: 18656
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<array>

using namespace std;

int ctoi( char& c ){
    return ( c - 48);
}

int func(int K, string N){

    int ans = 0;
    
    if(K == 1){

        if(N[0] == '0'){
            if(N.length() == 1){
                return 0;
            }else{
                return func(1, N.substr(1));
            }
        }else{
            ans = ctoi(N[0]) + (N.length() - 1) * 9;
            return ans;
        }

    }else if(K == 2){

        if(N[0] == '0'){
            if(N.length() <= 2){
                return 0;
            }else{
                return func( 2, N.substr(1));
            }        
        }else{
            if(N.length() < 2){
                return 0;
            }        

            int t = N.length() - 1; 
            ans += 81 * t * ( t - 1) / 2 ;
            ans += 9 * ( ctoi(N[0]) - 1 ) * t; 
            ans += func( 1, N.substr(1) );

            return ans;            
        }

    }else if(K == 3){

        if(N[0] == '0'){
            if(N.length() <= 3){
                return 0;
            }else{
                return func( 3, N.substr(1));
            }        
        }else{
            if(N.length() < 3){
                return 0;
            }        

            int t = N.length() - 1;
            ans += 729 * t * ( t - 1 ) * (t - 2) / 6;
            ans += 81 * ( ctoi(N[0]) - 1 ) * t * ( t - 1 ) / 2; 
            ans += func( 2, N.substr(1) );

            return ans;            
        }
        
    }
}   

int main(){

    string N;
    int K;
    cin >> N;
    cin >> K;

    cout << func( K, N ) << endl; 
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define loop(i,a,b) for(ll i=a; i<b; i++)
#define revloop(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define vl vector<ll>
#define vvl vector<vl>
#define pl pair<ll,ll>
#define vpl vector<pl>
#define all(c) (c).begin(), (c).end()
#define sz(a) ((a).size())
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i!=(c).end(); i++))
#define mp make_pair
#define ss second
#define ff first
const ll INF = 1e13;
const ll N = 200001;
const ll mod=998244353;
bool prime(ll x)
{
	if(x<2) return false;
	for(ll i=2; i*i<=x; i++) if(x%i==0) return false;
	return true;
}
vl fac(N);
void fact()
{
	fac[0]=1;
	loop(i,1,N) fac[i]=(fac[i-1]*i)%mod;
}
void solve()
{
  ll n,W;
  cin>>n>>W;
  ll w[n], v[n];
  loop(i,0,n) cin>>w[i]>>v[i];
  vl dp(W+1,0);
  loop(i,0,n)
  {
  	revloop(j,W,w[i]) dp[j] = max(dp[j], v[i]+dp[j-w[i]]);
  }
  cout<<dp[W]<<endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--) solve();
 return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,t,p;
    string s,m;
    cin>>n;
    cin>>s>>m;
    for(i=0;i<n;i++){
        cout<<s[i];cout<<m[i];
    }

    cout<<endl;


    return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;



int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	while (true) {
		if ((C - B) > 0 && (A - D) > 0) {
			C -= B;
			A -= D;
		}
		else if ((C - B) < 1) {
			cout << "Yes" << endl;
			break;
		}
		else {
			cout << "No" << endl;
			break;
		}
	}
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a;i<n;i++)
#define ve vector
#define ss second 
#define ff first
#define pf pop_front
#define pob pop_back
#define psf push_front
#define res(x) cout<<x<<'\n'
#define read(t) ll t;cin>>t

int main(){
    int n;int m;
    cin>>n>>m;
    if(n>1&&m>1){
        cout<<(n*(n-1)/2)+(m*(m-1)/2)<<endl;
    }
    else if (n>=2&&m<2){
        cout<<n*(n-1)/2<<endl;
    }
    else if(m>=2&&n<2){
        cout<<m*(m-1)/2<<endl;
    }
    else{
        cout<<0<<endl;
    }
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())

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

import itertools
ans = float("inf")
for i in itertools.product([0, 1], repeat=N):
    # print(i)
    point = [0] * M
    ans_p = 0
    for j, c in zip(i, C):

        if j == 1:
            ans_p += c[0]
            for p, a in enumerate(c[1:]):
                point[p] += a
    flag = 0
    # print(point)
    for p in point:
        if p < X:
            flag = 1
    if flag == 0:
        ans = min(ans_p, ans)
if ans == float("inf"):
    print(-1)
else:

    print(ans)

Measured memory_bytes: 68636
N, K, Q = map(int, input().split())
A = list([int(input()) for _ in range(Q)])

dicA = {}

for a in A:
    if a in dicA.keys():
        dicA[a] += 1
    else:
        dicA[a] = 1

for n in range(1, N+1):
    if K - Q > 0:
        print("Yes")
    elif n in dicA.keys() and K - Q + dicA[n] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 11772