akhauriyash/Code-Regression huggingface dataset:
// Math = ♥️

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

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>

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

    string str;
    cin >> str;

    for (int i = 0; i < sz(str); i++) {
        if (str[i] == '?') {
            str[i] = 'D';
        }
    }

    cout << str << "\n";
}


Measured memory_bytes: 3748
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<list>
#include<set>
using namespace std;

int main(){
  int n,r[200011];
  cin >> n ;
  for(int i=0;i<n;i++){
    cin >> r[i];
  }
  int max_a=-2000000000;
  int min_a=r[0];
  for(int i=1;i<n;i++){
    max_a=max(max_a,r[i]-min_a);
    min_a=min(min_a,r[i]);
  }
  cout << max_a << endl;
  return (0);
}



Measured memory_bytes: 3868
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; ++i) cin >> a[i];

    vector<int> v;
    for(int i = N-1; i >= 0; --i){
        auto itr = upper_bound(v.begin(), v.end(), a[i]);
        if(itr == v.end()){
            v.push_back(a[i]);
        }else{
            *itr = a[i];
        }
    }
    cout << v.size() << endl;
    return 0;
}



Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()

ll cal(ll x) {
  ll a=1;
  for(ll i=0;i<x;i++) {
    a*=26;
  }
  return a;
}

 
int main() {
ll N;
  cin>>N;
  
  ll t=0;
  ll i=0;
  while(N>t) {
    i++;
    t+=cal(i);
  }
  t-=cal(i);
  ll mozisu=i;
  string S="abcdefghijklmnopqrstuvwxyz";
  for(ll j=0;j<mozisu;j++) {
    ll a=0;
while(N>t) {
t+=cal(i-1);
a++;
}
    cout<<S[a-1];
    t-=cal(i-1);
    i--;
  }
  
  cout<<endl;
}
 
  


Measured memory_bytes: 3636
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	var ans int
	if n%2 == 1 {
		ans = n * 2
	} else {
		ans = n
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#ifdef Rahul
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define error(...) 42;
#endif
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/

int32_t main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  i64 n, k;
  cin >> n >> k;
  i64 zer = 0;
  vector<i64> pos, neg;
  for (int i = 0; i < n; ++i) {
    int x; cin >> x;
    zer += x == 0;
    if (x > 0) pos.push_back(x);
    if (x < 0) neg.push_back(-x);
  }
  sort(ALL(pos));
  sort(ALL(neg));
  auto cnt = [&] (i64 x) {
    if (x == 0) {
      return (i64) SZ(pos) * SZ(neg);
    }
    i64 res = 0;
    if (x > 0) {
      res = (i64) SZ(pos) * SZ(neg);
      res += (i64) zer * (n - zer);
      res += (i64) zer * (zer - 1) / 2;
      int r = 0;
      for (int i = SZ(pos) - 1; i >= 0; --i) {
        while (r < i && pos[r] * pos[i] < x) {
          ++r;
        }
        res += min(i, r);
      }
      r = 0;
      for (int i = SZ(neg) - 1; i >= 0; --i) {
        while (r < i && neg[r] * neg[i] < x) {
          ++r;
        }
        res += min(i, r);
      }
    } else {
      int r = SZ(neg) - 1;
      for (int i = 0; i < SZ(pos); ++i) {
        while (r >= 0 && pos[i] * neg[r] > -x) {
          --r;
        }
        res += SZ(neg) - r - 1;
      }
    }
    return res;
  }; 
  i64 lo = -INF, hi = INF;
  while (lo < hi) {
    i64 md = lo + (hi - lo + 1) / 2;
    if (cnt(md) >= k) hi = md - 1;
    else lo = md;
  }
  cout << lo << '\n';
}


Measured memory_bytes: 2420
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int n;
int a[123456];

int main(void)
{
	cin >> n;
	if (n == 1)
	{
		cout << 1 << endl;
		return 0;
	}
	for (int i = 0; i < n; ++i)cin >> a[i];
	int cnt = 0;
	vector<int>p;
	int tilt = 0;
	for (int i = 0; i < n; ++i)
	{
		if (p.empty())p.push_back(a[i]);
		else
		{
			int las = p.back();
			p.push_back(a[i]);
			if (tilt == 1)
			{
				if (las > a[i])
				{
					p.clear(); cnt++; tilt = 0;
					p.push_back(a[i]);
					continue;
				}
			}
			else if (tilt == -1)
			{
				if (las < a[i])
				{
					p.clear(); cnt++; tilt = 0;
					p.push_back(a[i]);
					continue;
				}
			}
			else
			{
				if (las > a[i])
				{
					tilt = -1;
				}
				if (las < a[i])
				{
					tilt = 1;
				}
				p.push_back(a[i]);
			}
		}
	}
	cout << cnt + 1 << endl;
	return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    
    int N;
    string S;
    cin>>N>>S;
    vector<long long int> T(26,1);
    for(int i=0;i<N;i++){
        T[S[i]-'a']++;
    }
    long long int ans=1;
    for(int i=0;i<26;i++){
        ans*=T[i];
        ans=ans%1000000007;
    }
    cout<<(ans-1)%1000000007<<endl;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class Program
{
  void Solve()
  {
    int N = int.Parse(Console.ReadLine());
    int ret = 0;
    int A = 0;
    int B = 0;
    int BA = 0;
    for (int i=0;i<N;i++ )
    {
      var s = Console.ReadLine();

      for(int ii=0;ii<s.Length-2 ;ii++)
      {
        if (s[ii] == 'A' && s[ii + 1] == 'B')
          ret++;
      }
      if (s[0] == 'B' && s[s.Length - 1] == 'A')
        BA++;

      if (s[0] == 'B' )
        B++;
      if (s[s.Length - 1] == 'A')
        A++;

    }

    ret += Math.Min(A, B);

    if (BA>0&&BA == A && BA == B)
      ret -= 1;

    Console.WriteLine(ret);
  }

  static void Main(string[] args)
  {
    new Program().Solve();
  }
}



Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
#define ld long double
#define ff first
#define ss second

const long long MOD7 = 1000000007;

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    string s, t;
    cin >> s >> t;
    int i, dif = 0;

    for(i = 0; i < s.size(); i++)
        if(s[i] != t[i]) dif++;

    cout << dif << endl;

    return 0;
}

Measured memory_bytes: 3948
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
const int N=2e5+3;
ll M=1e9+7;
ll BM(ll a,ll b)
{
    ll k=1;
    a%=M;
    while(b!=0)
    {
        if(b%2==1)
        {
            k=(k*a)%M;
        }
        a=(a*a)%M;
        b/=2;
    }
    return k;
}
ll MI(ll x)
{
    return BM(x,M-2);
}
ll ncr(ll n,ll r)
{
    ll m=max(n-r,r);
    ll s=1,p=1;
    for(ll i=m+1;i<=n;i++)
    {
        s=(s*i)%M;
    }
    m=min(n-r,r);
    for(ll i=1;i<=m;i++)
    {
        p*=MI(i);
        p%=M;
    }
    return (s*p);
}
int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m>>l;
    r=BM(2ll,n)-1;
    m=ncr(n,m);
    l=ncr(n,l);
    ll ans=((r+M)%M - (m+M)%M - (l+M)%M + 5*M)%M;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(void)
{
    int K;
    std::string S;
    std::cin >> K;
    std::cin >> S;

    for (int i = 0; i < K && S[i] != '\0'; i++)
    {
        std::cout << S[i];
    }

    if (S.size() > K)
    {
        std::cout << "..." << std::endl;
    }

    return 0;

}

Measured memory_bytes: 3596
N=int(input())
A=[0]*N
maxN=0
secondN=0
for i in range(N):
  A[i]=int(input())
  if A[i]>=maxN:
    secondN=maxN
    maxN=A[i]
  elif A[i] > secondN:
    secondN=A[i]
for i in range(N):
  if A[i]==maxN:
    print(secondN)
  else:
    print(maxN)

Measured memory_bytes: 12788
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,total;
	scanf("%d%d",&n,&total);
	total/=1000;
	int tp=total;
	int a=tp/10;
	tp%=10;
	int b=tp/5;
	tp%=5;
	int c=tp;
	if(a+b+c>n) {
		puts("-1 -1 -1");
		return 0;
	} else if(a+b+c==n) {
		printf("%d %d %d\n",a,b,c);
		return 0;
	} else {
		a=0;
		b=0;
		c=total;
		while(c>=5&&a+b+c>=n) {
			if(a+b+c==n) {
				printf("%d %d %d\n",a,b,c);
				return 0;
			}
			c-=5;
			b++;
			if(a+b+c<n) {
				c+=5;
				b--;
				break;
			}
		}
		while(b>=2&&a+b+c>=n) {
			if(a+b+c==n) {
				printf("%d %d %d\n",a,b,c);
				return 0;
			}
			b-=2;
			a++;
		}
	}
	puts("-1 -1 -1");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define MIN(x, y) x<y?x:y
#define ABS(x, y) x<y?(y-x):(x-y)

typedef long long Long;

int main()
{
	int x, n, p[102];
	int tmp;
	int diff, prev_diff = 1000;
	int ans=0;

	cin>>x>>n;

	for (int i = 0; i <= 101; i++)
	{
		p[i]=0;
	}

	for (int i = 0; i < n; i++)
	{
		cin>>tmp;
		p[tmp]=1;
	}

	for (int i = 0; i <= 101; i++)
	{
		if(p[i]==0) {
			diff = ABS(x, i);
			// cout<<i<<" "<<diff<<endl;
			if(prev_diff > diff) {
				ans = i;
				prev_diff = diff;
			} else if(prev_diff == diff) {
				ans = MIN(ans, i);
			}
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3636
use std::io::stdin;

fn main() {
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let (a, b, q) = {
        let ab:Vec<_> = st.trim().split(" ").map(|x| x.parse::<i64>().unwrap()).collect();
        (ab[0], ab[1], ab[2])
    };
    let mut s:Vec<i64> = Vec::new();
    let mut t:Vec<i64> = Vec::new();
    let f:i64 = -100000000001;
    let e:i64 = 100000000001;
    s.push(f);
    t.push(f);
    for _i in 0..a {
        let mut st = String::new();
        stdin().read_line(&mut st).unwrap();
        s.push(st.trim().parse::<i64>().unwrap());
    };
    s.push(e);

    for _i in 0..b {
        let mut st = String::new();
        stdin().read_line(&mut st).unwrap();
        t.push(st.trim().parse::<i64>().unwrap());
    };
    t.push(e);

    let mut x:Vec<_> = Vec::new();
    for _i in 0..q {
        let mut st = String::new();
        stdin().read_line(&mut st).unwrap();
        x.push(st.trim().parse::<i64>().unwrap());
    };

    for i in &x {
        let n = bisec(&mut s, &i);
        let m = bisec(&mut t, &i);
        let mut result:Vec<i64> = Vec::new();
        result.push(max(s[n], t[m])-i);
        result.push(i-min(s[n-1], t[m-1]));
        result.push(min((i-s[n]).abs(), (i-t[m-1]).abs())+(s[n]-t[m-1]).abs());
        result.push(min((i-s[n-1]).abs(), (i-t[m]).abs())+(s[n-1]-t[m]).abs());
        println!("{}", result.iter().min().unwrap());
    };
}

fn bisec(v:&Vec<i64>, num:&i64) -> usize {
    let mut l:usize = 0;
    let mut r = v.len() as usize;
    let mut m = (l+r)/2 as usize;
    while l < r {
        if num <= &v[m] {
            r = m;
        } else {
            l = m+1;
        };
        m = (l+r)/2 as usize;
    };
    l
}

fn max (a:i64, b:i64) -> i64 {
    if a < b {
        b
    } else {
        a
    }
}

fn min (a:i64, b:i64) -> i64 {
    if a > b {
        b
    } else {
        a
    }
}

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

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

int main() {
	int n; cin >> n;
	int X; cin >> X;
	vector<int> x(n);
	rep(i, n) cin >> x[i];
	x.emplace_back(X);
	sort(x.begin(), x.end());
	vector<int> res;
	res.emplace_back(x.back() - x.front());
	rep(i, n - 1) res.emplace_back(x[i + 1] - x[i]);
	int ans = res.front();
	for (auto& c : res) ans = gcd(ans, c);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1528
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {
  int fc = 10000000, lf = -1;
  string str; cin >> str;
  for (int i = 0; i < str.size(); ++i) {
	if (str[i] == 'C') fc = min(fc, i);
	if (str[i] == 'F') lf = max(lf, i);
  }
  if (fc < lf) puts("Yes");
  else puts("No");
}


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

const double pi = 3.14159265358979323846;

int main(){
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double angle_h = (pi / 360) * (h*60 + m);
    double angle_m = (pi / 30) * (h*60 + m);
    double delta = angle_h - angle_m;
    if(delta < 0) delta *= -1;
    double ans = sqrt(a*a + b*b - 2*a*b*cos(delta));
    printf("%0.9lf\n", ans);
}



Measured memory_bytes: 4224
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
#include <tuple>
#include <cassert>
using namespace std;

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

template<typename T>
struct Combination {
private:
  int sz;
  vector<T> F, F_;
public:
  Combination(int sz) : sz(sz), F(sz+1), F_(sz+1) {
    F[0] = 1;
    for(int i = 0; i < sz; ++i) F[i+1] = F[i]*(i+1);
    F_.back() = (T)1/F.back();
    for(int i = sz-1; i >= 0; --i) F_[i] = F_[i+1]*(i+1);
  }
  T C(int n, int k){
    assert(n <= sz);
    if(n < 0 or k > n) return (T)0;
    return F[n]*F_[k]*F_[n-k];
  }
};

int main(){
  using mint = modint<(int)1e9+7>;
  int H, W, N;
  cin >> H >> W >> N;
  vector<pair<int,int>> V;
  for(int i = 0; i < N; ++i){
    int r, c;
    cin >> r >> c;
    V.emplace_back(r,c);
  }
  V.emplace_back(H,W);
  sort(V.begin(), V.end(),
       [](const pair<int,int> &A, const pair<int,int> &B){
         return A.first+A.second < B.first+B.second;
       });
  Combination<mint> comb(H+W);
  vector<mint> dp(N+1);
  for(int i = 0; i <= N; ++i){
    int r, c;
    tie(r,c) = V[i];
    dp[i] = comb.C(r-1+c-1,r-1);
    for(int j = 0; j < i; ++j){
      int r_, c_;
      tie(r_,c_) = V[j];
      if(r_ > r or c_ > c) continue;
      dp[i] -= dp[j]*comb.C(r-r_+c-c_,r-r_);
    }
  }
  cout << dp.back() << endl;
}


Measured memory_bytes: 3456
function Main(input) {
	var len = parseInt(input.split("\n")[0]);
  var list = input.split("\n")[1].split(" ");
   var output = 0;
  list.sort(function(a,b){
  	return parseInt(b) - parseInt(a);
  });
  
  var count = 0;
  while(count < len){
    output += parseInt(list[(count * 2) + 1]);
    count++
  }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
  int n;
  cin >> n;
  while (n--) {
    int a, b = 0, c = 0;
    bool f = true;
    for (int i = 0; i < 10; ++i) {
      cin >> a;
      if (b < a) b = a;
      else if (c < a) c = a;
      else f = false;
    }
    if (f) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}


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

int n, d, q, l[500001], x[500001];
bool an[500001];

int main(){
	scanf("%d%d", &n, &d);
	l[0] = d;
	f(i, 1, n + 1){
		scanf("%d", x + i);
		if (x[i] < l[i - 1] << 1)l[i] = abs(l[i - 1] - x[i]);
		else l[i] = l[i - 1];
	}
	int z = 1;
	for (int i = n; i > 0; --i){
		if (l[i - 1] >= z)an[i] = true;
		if (x[i] < z << 1)z += x[i];
	}
	scanf("%d", &q);
	while (q--){
		int x;
		scanf("%d", &x);
		printf("%s\n", an[x] ? "YES" : "NO");
	}
}

Measured memory_bytes: 6400
N, A, B = map(int, input().split())

if (B - A) % 2 == 0:
  ret = (B - A) // 2
    
else:
  ret = min(N - A, B - 1)
  if (N - (A + (N - B + 1))) % 2 == 0:
    ret = min(ret, N - B + 1 + (N - (A + (N - B + 1)))  // 2)
  if (B - A - 1) % 2 == 0:
    ret = min(ret, A + (B - A - 1) // 2)
            
print(ret)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main ()
{
    int A,B, result;
    scanf ("%d %d", &A, &B);
    if (B%A== 0)
        result = A+B;
    else
       result = B-A;
       cout<<result<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

int main()
{
    int n;cin >> n;
    vector<int> a(n);
    for (int i=0;i<n;i++) {
        cin >> a[i];
    }
    vector<int> b(n);
    for (int i=0;i<n;i++) {
        b[i] = a[i] - (i+1);
    }
    sort(b.begin(),b.end());
    int med;
    if (b.size()%2 == 0) {
        med = ((long)b[b.size()/2-1] + b[b.size()/2])/2;
    } else {
        med = b[b.size()/2];
    }
    long acc = 0;
    for (int i=0;i<n;i++) {
        acc += abs(a[i] - (med + i+1));
    }
    cout << acc << endl;
    return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from collections import defaultdict,deque


class Graph:

  def __init__(self,N,uv,S,T):
    self.graph = uv
    self.start = S
    self.goal = T
    self.states  = [[-3 for _ in range(3)] for _ in range(N)]
    self.states[self.start][0] = 0

  def solve(self):
    nxt = deque([self.start])
    ## update
    while len(nxt) > 0:
      p = nxt.popleft()
      for q in self.graph[p]:
        for ps in range(3):
          if self.states[p][ps] >= 0:
            qs = (ps+1)%3
            if self.states[q][qs] < 0:
              self.states[q][qs] = self.states[p][ps]+1
              nxt.append(q)
            else:
              self.states[q][qs] = min(self.states[q][qs],self.states[p][ps]+1)
    ## return
    return self.states[self.goal][0]


def main():
  ## input
  N,M = map(int, input().split())
  uv = defaultdict(set)
  for _ in range(M):
    u,v = map(int, input().split())
    uv[u-1].add(v-1)
  S,T = map(int, input().split())

  ## solve
  graph = Graph(N,uv,S-1,T-1)
  print(graph.solve()//3)


if __name__ == "__main__":
  main()

Measured memory_bytes: 59356
#include <complex>
#include <vector>
#include <set>
#include <cstdio>
using namespace std;
 
const double EPS = 1e-12;
typedef complex<long double> P;

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}
 
long long pow_binary_mod(long long x,long long y,long long M){
	long long z=1;
	for(;y;y>>=1){
		if((y&1)!=0)z=z*x%M;
		x=x*x%M;
	}
	return z;
}
 
int main(){
	int M=998244353;
	int N,x,y;
	scanf("%d",&N);
	vector<P>v(N);
	int r=pow_binary_mod(2,N,M);
	set<L>se;
	for(int i=0;i<N;i++)scanf("%d%d",&x,&y),v[i]={(double)x,(double)y};
	for(int i=0;i<N;i++)for(int j=i+1;j<N;j++){
		L l(v[i],v[j]);
		int n=0;
		for(int k=0;k<N;k++)if(k!=i&&k!=j&&intersectSP(l,v[k]))n++;
		r=(r-pow_binary_mod(2,n,M))%M;
	}
	printf("%d\n",((r-N-1)%M+M)%M);
}

Measured memory_bytes: 512
#include <cstdio>
#include <vector>
using namespace std;

vector<long long int> divisor(long long int m) {
    vector<long long int> divs;
    for (long long int i = 1; i*i <= m; i++) {
        if (m % i == 0) {
            divs.push_back(i);
            if (m != i*i) {
                divs.push_back(m / i);
            }
        }
    }
    sort(divs.begin(), divs.end());

    return divs;
}

int main() {
    long long int n, m;

    scanf("%lld%lld", &n, &m);
    vector<long long int> divs = divisor(m);

    for (long long int i = divs.size()-1; i >= 0; i--) {
        if (divs[i] * n <= m) {
            printf("%lld\n", divs[i]);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
using System;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] l = Console.ReadLine().Split();
            string A = l[0]; string B = l[1];
            int a = int.Parse(A); int b = int.Parse(B);
            int an;
            if(a<=9&&b<=9){
                an = a * b;
            }
            else{
                an = -1;
            }
            Console.Write(an);
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int h[n];for(int i=0;i<n;i++)cin>>h[i];
  int dp[n];
  fill(dp,dp+n,2000000000);
  dp[0]=0;
  for(int i=0;i<n-2;i++){
    dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
    dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
  }
  dp[n-1]=min(dp[n-1],dp[n-2]+abs(h[n-1]-h[n-2]));
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
// https://atcoder.jp/contests/dp/tasks/dp_k
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define infinity (ll)4e18
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

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

    ll n, k;
    cin >> n >> k;
    ll a[n];
    for (ll i = 0; i < n; i++)
        cin >> a[i];
    bool dp[k + 1];
    fill(dp, dp + k + 1, false);
    for (ll i = 1; i <= k; i++)
        for (ll j = 0; j < n; j++)
            if (i - a[j] >= 0)
                dp[i] = dp[i] | !dp[i - a[j]];
    if (dp[k])
        cout << "First\n";
    else
        cout << "Second\n";
    return 0;
}

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

vector<int> table[9] = {
  {},
  { 6 },
  { 2, 4 },
  { 2, 4, 6 },
  { 2, 4, 6, 12 },
  { 2, 3, 4, 6, 9 },
  { 2, 3, 4, 6, 9, 12 },
  { 2, 3, 4, 6, 8, 9, 10 },
  { 2, 3, 4, 6, 8, 9, 10, 12 }
};

int main() {
  int n;
  cin >> n;
  vector<int> ans;
  
  if (n == 3) {
    ans = { 2, 5, 63 };
  } else if (n == 4) {
    ans = { 2, 5, 20, 63 };
  } else {
    int offset = 0;
    while (n > 0) {
      int k = min(n, 8);
      for (int i : table[k]) {
        ans.push_back(offset + i);
      }
      n -= 8;
      offset += 12;
    }
  }
  
  for (int i : ans) {
    cout << i << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);
    
    ll x;
    cin >> x;

    ll ans = x / 11 * 2;
    ll a = x % 11;
    if (0 < a && a <= 6) ans++;
    else if (a != 0) ans += 2;
        
    cout << ans << endl;
}

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

char grade(int m,int f,int r){
    if(m == -1 || f == -1) return 'F';
    int mf = m+f;
    if(mf >= 80) return 'A';
    if(mf >= 65) return 'B';
    if(mf >= 50) return 'C';
    if(mf >= 30) return r >= 50 ? 'C':'D';
    return 'F'; 
}

int main(){
    int m,f,r;
    while(true){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;
        cout << grade(m,f,r) << endl;
    }
    return 0;
}



Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {
  static int n, t;
  static int[] a;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    n = sc.nextInt(); t = sc.nextInt();
    a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }

    int min = a[0], diff = 0;
    for(int i = 1; i < n; i++){
      min = Math.min(min, a[i]);
      diff = Math.max(diff, a[i] - min);
    }

    int count = 0;
    min = a[0];
    for(int i = 0; i < n; i++){
      min = Math.min(min, a[i]);
      if(a[i] - min == diff){
        ++count;
      }
    }

    System.out.println(count);
  }
}


Measured memory_bytes: 33684
# include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;
typedef long long ll;

bool is_prime(int num) {

  for (int i = 2; i <= int(sqrt(num)); i++) {
    if (num % i == 0) return false;
  }

  return true;
}

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

  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int ans = 0;

  rep(i, n) {
    if (is_prime(a[i])) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1232
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
int main()
{
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }
    cout << sum << endl;
           
    return 0;
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<ll> A(n);
    vector<ll> ans(n);
    ans[0] = 0;
    REP(i, n) {
        cin >> A[i];
        ans[0] += A[i];
    }
    for(int i=1; i<n; i+=2) ans[0] -= 2*A[i];
    for(int i=1; i<n; i++) {
        ans[i] = 2*A[i-1] - ans[i-1];
    }
    REP(i, n) printf("%lld ", ans[i]);
    printf("\n");
    return 0;
}



Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
const int N=210;
int n,m,cnt[N],one,four;char s[N];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++){
		scanf("%s",s+1);
		for (int j=1;j<=m;j++) cnt[s[j]]++;
	}
	for (int i='a';i<='z';i++){
		if (cnt[i]&1) cnt[i]--,one++;
		four+=(cnt[i]>>2);
	}
	if ((n&1)&&(m&1)){if (one!=1) return puts("No"),0;}
		else if (one>0) return puts("No"),0;
	if (four<(n>>1)*(m>>1)) return puts("No"),0;
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,S,R=0,s=0;
    scanf("%d%d",&N,&S);
    vector<int>v(N);
    for(int i=0;i<N;i++)scanf("%d",&v[i]);
    int start=0,stop=0;
    for(;;){
        for(;stop<N&&s<S;stop++)s+=v[stop];
        if(s<S)break;
        for(;start<N&&s>=S;start++)s-=v[start];
        R=R?min(R,stop-start+1):stop-start+1;
    }
    printf("%d\n",R);
}

Measured memory_bytes: 3404
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<bitset>
using namespace std;

typedef long long ll;	

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

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = LLONG_MAX;
const ll N =(3e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;

int a[N];
int pre[N];
int suf[N];
void solve(){
	int n;
	cin >> n;
	for(int i =1;i<=3*n;i++){
		cin >> a[i];
	}
	priority_queue < ll, std::vector<ll>, std::greater<ll> > mnheap;	// mnheap.push(), mnheap.top(), mnheap.pop()
	priority_queue<int> mxheap;
	for(int i =1;i<=3*n;i++){
		if(i <= n){
			pre[i] = pre[i-1] + a[i];
			mnheap.push(a[i]);
			continue;
		}
		pre[i] = pre[i-1];
		if(a[i] > mnheap.top()){
			pre[i] -= mnheap.top();
			pre[i] += a[i];
			mnheap.pop();
			mnheap.push(a[i]);
		}
	}

	for(int i = 3*n,j = 1;i>=1;i--,j++){
		assert((3*n - i + 1) == j);
		if((3 * n - i + 1) <= n){
			mxheap.push(a[i]);
			suf[i] = suf[i+1] + a[i];
			continue;
		}
		suf[i] = suf[i+1];
		if(a[i] < mxheap.top()){
			suf[i] -= mxheap.top();
			suf[i] += a[i];
			// auto it = se.end();
			// it--;
			// se.erase(it);
			// se.in(a[i]);
			mxheap.pop();
			mxheap.push(a[i]);
		}
	}
	int ans = -INF;
	for(int i =n;i<=2*n;i++){
		ans= max(ans,pre[i]- suf[i+1]);
	}
	assert(ans != -INF);
	cout << ans << endl;

}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 11812
from collections import defaultdict
from itertools import product
 
H,W,K = map(int,input().split())
S = [input() for i in range(H)]

C = [[int(S[i][k]) for i in range(H)] for k in range(W)]
answer = H*W #出力がこれを超えることはない
for X in product([True,False],repeat = H-1):
  M = [[0]]
  ans = sum(X)
  if ans > answer:#初期値がanswerよりも大きかったら考える必要がない
    continue
  for i,x in enumerate(X):#配列Mの作成
    if x:
      M.append([])
    M[-1].append(i+1)
  D = [0]*len(M)
  for c in C:
    for k,m in enumerate(M):
      D[k] += sum(c[i] for i in m)#k番目の要素に足していく
      #Dにどんどん代入することによってどの列まで足すことができるか算出することができる
    if any(d>K for d in D):#一つでもKを超えていたら
      ans += 1
      if ans >answer:
        break
      D = [sum(c[i] for i in m) for m in M]#超えた行について再び調査
      if any(d>K for d in D):
        ans = answer + 1
        #デフォルトanswerの結果より高い値にしてこの結果が出力にならないように設定する
        break
  answer = min(answer,ans)#あるXに対してanswerを算出(更新)
print(answer)

Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main() {
    long long a,b;
    cin >> a >> b;
    long long d = 0;
    for (long long i = b; i < a+2; i++){
        d -= i * (i - 1) / 2;
        d += i * a - i * (i - 1) / 2;
        d += 1;
        d %= 1000000007;
    }

    cout << d << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,e[10],r[10];
  int x[10],y[10];
  int com1=0,com2=0;
  int num1=0,num2=0;

  cin>>n;
  for(int i=0;i<n;i++) cin>>e[i];
  for(int i=0;i<n;i++) cin>>r[i];
  for(int i=1;i<n+1;i++){ x[i-1]=i; y[i-1]=i; }

  do{
    for(int i=0;i<n;i++){
      if(x[i]==e[i]) com1++;
    }
    num1++;
    if(com1==n) break;
    com1=0;
  }while(next_permutation(x,x+n));

  do{
    for(int i=0;i<n;i++){
      if(y[i]==r[i]) com2++;
    }
    num2++;
    if(com2==n) break;
    com2=0;
  }while(next_permutation(y,y+n));

  cout<<abs(num1-num2)<<endl;
  return 0;
}


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

#define F first
#define S second
#define pb push_back
#define ld  double
#define ll long long
#define int long long


using namespace std;

const int MAXN = 1111 , MOD = 1e9 + 7  ;

ld dis[MAXN] ;

bool mark[MAXN] ;

ld adj[MAXN][MAXN] ;

int x[MAXN] , y[MAXN] , r[MAXN] ;

ld diss(int x1 , int y1 ,int x2 , int y2)
{
    return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)) ;
}

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

    int x1 , y1 , x2 , y2 , n;
    cin >> x1 >> y1 >> x2 >> y2 >> n ;
    for(int i = 0 ; i < n ; i ++)
        cin >> x[i]>>y[i]>>r[i] ;
    x[n] = x1 , y[n] = y1 , r[n] = 0 ;
    x[n+1] = x2 , y[n+1] = y2 , r[n+1] = 0 ;
    n += 2 ;
    for(int i = 0 ; i < n ; i ++ )
        for(int j = 0 ; j < n ; j ++ )
            adj[i][j] = max(0.0,diss(x[i],y[i],x[j],y[j])-r[i]-r[j]);
    for(int i = 0 ; i < n ; i ++ )
        dis[i] = 1e18 ;
    dis[n-2] = 0 ;
    for(int i = 0 ; i < n ; i ++ )
    {
        pair<ld,int> mn= {1e18,-1};
        for(int j = 0 ; j < n ; j ++ )
            if(!mark[j])
                mn = min(mn,{dis[j],j});
        mark[mn.S] = 1 ;
        int ind = mn.S ;
        for(int j = 0 ; j < n ; j ++ )
            dis[j] = min(dis[j],dis[ind]+adj[ind][j]);
    }
    cout<<fixed<<setprecision(9)<<dis[n-1];
}


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

string s;
int l;
vector<int> cl, cr, sl, sr;

int main(){
	cin >> s;
	l = s.size();
	cl.resize(l+1);
	cr.resize(l+1);
	sl.resize(l);
	sr.resize(l);
	cl[0] = cr[l] = 0;
	for (int i = 0; i < l; ++i){
		if (s[i] == 'R'){
			cl[i+1] = cl[i] + 1;
		}
		else if (cl[i] != 0){
			sl[i-1] = cl[i]/2 + cl[i]%2;
			sl[i] = cl[i]/2;
		}
		if (s[l-i-1] == 'L'){
			cr[l-i-1] = cr[l-i] + 1;
		}
		else if (cr[l-i] != 0){
			sr[l-i-1] = cr[l-i]/2;
			sr[l-i] = cr[l-i]/2 + cr[l-i]%2;
		}
	}
	for (int i = 0; i < l; ++i){
		printf("%d ", sl[i] + sr[i]);
	}
}

Measured memory_bytes: 2176
#include <iostream>
using namespace std;
#define ll long long int
int main(){
  int n,k;
  ll ans=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    if(a>(k-a))
      ans+=2*(k-a);
    else
      ans+=2*a;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto xy = reads!string;

    auto x = xy[0], y = xy[1];
    if (x == y) writeln('=');
    else if (x < y) writeln('<');
    else writeln('>');
}


Measured memory_bytes: 256
/**
*    author:  y_takano
*    created: 22.06.2020 15:03:41
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

using namespace std;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  string w, t;
  int cnt = 0;

  getline(cin, w);

  while (cin >> t)
  {
    if (t == "END_OF_TEXT")
    {
      break;
    }

    transform(t.begin(), t.end(), t.begin(), ::tolower);

    if (t == w) 
    {
      cnt++;
    }
  }
  
  cout << cnt <<'\n';

  return 0;
}


Measured memory_bytes: 3220
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;

bool ok[80][80][80*165];//ok[i][j][k]は[i][j]マスに偏り[k]で到達できるかどうか

int main()
{
    int H,W;
    cin >> H >> W;
    vector< vector<int> > A(H, vector<int>(W)), var(H, vector<int>(W));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> A[i][j];
        }
    }
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            int tmp;
            cin >> tmp;
            var[i][j]=abs(A[i][j]-tmp);
        }
    }

    int upper=80;
    ok[0][0][var[0][0]]=true;
    for(int cnt=1; cnt<=H+W-2; cnt++){
        upper+=80;
        for(int w=max(0, cnt+1-H); w<min(W, cnt+1); w++){
            int h=cnt-w;
            //cout << h << w << endl;
            for(int i=0; i<=upper; i++){
                if(h>0){
                    ok[h][w][i]|=ok[h-1][w][abs(i-var[h][w])];
                    ok[h][w][i]|=ok[h-1][w][i+var[h][w]];
                }
                if(w>0){
                    ok[h][w][i]|=ok[h][w-1][abs(i-var[h][w])];
                    ok[h][w][i]|=ok[h][w-1][i+var[h][w]];
                }
            }
        }
    }
    for(int i=0; i<80*165; i++){
        if(ok[H-1][W-1][i]){
            cout << i << endl;
            break;
        }
    }

    

    return 0;
}

Measured memory_bytes: 81920
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define ll long long
//map<key,value>

int main(){
  int n;
  cin >> n;
  vector<int> a(n,0);
  vector<int> ans;
  for(int i=0;i<n;i++)cin >> a[i];

  while(a.size() >= 1 ){
    for(int i=a.size()-1;i>=0;i--){
      if(a[i] == i+1){
        //cout << a[i] << "\n";
        ans.insert(ans.begin(),a[i]);
        a.erase(a.begin()+i);
        goto fin;
      }
    }
    cout << "-1";
    return 0;
    fin:;
  }
  for(int i=0;i<ans.size();i++)cout << ans[i] << "\n"; 
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> X(N), Y;
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }
  Y = X;
  sort(Y.begin(), Y.end());
  ll mid = Y[N / 2 - 1];
  ll mid_p = Y[N / 2];
  for (int i = 0; i < N; i++) {
    if (X[i] <= mid) {
      cout << mid_p << endl;
    } else {
      cout << mid << endl;
    }
  }
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;
using tTree = __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

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

#define FACSIZE 200002

ll invfac[FACSIZE];
ll fac[FACSIZE];

template <class T>
bool chmax(T &, const T &);
template <class T>
bool chmin(T &, const T &);
ll gcd(ll, ll);
ll powLL(ll x, ll y);

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
ll comb(ll, ll);
void make_fact(ll);
void make_invfact(ll);
void fact_init();

int main(void)
{
  string s, t;
  cin >> s;
  cin >> t;
  cout << t << s << endl;
  return 0;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return mod_mul(t, t);
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = mod_mul(t, t);
    return (k % mod) * (x % mod);
  }
}
ll mod_add(ll a, ll b)
{
  return ((a % mod) + (b % mod)) % mod;
}

ll mod_mul(ll a, ll b)
{
  return ((a % mod) * (b % mod)) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void fact_init()
{
  make_fact(FACSIZE - 1);
  make_invfact(FACSIZE);
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

ll comb(ll n, ll r)
{

  return mod_mul(mod_mul(fac[n], invfac[r]), invfac[n - r]);
}
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;
}

ll qp(ll a, ll b)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * mod_mul(ans, a) % mod;
    a = 1LL * mod_mul(a, a) % mod;
  } while (b >>= 1LL);
  return ans;
}
ll qp(ll a, ll b, ll mo)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * (ans % mo) * (a % mo);
    a = 1LL * (a % mo) * (a % mo);
  } while (b >>= 1LL);
  return ans;
}
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}
ll powLL(ll x, ll y)
{
  ll ans = 1LL;
  for (ll i = 0LL; i < y; i++)
    ans *= x;
  return ans;
}

Measured memory_bytes: 256
#include<cstdio>
#define N 110
using namespace std;

bool f[N][N*N];
int n,s[N];

int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&s[i]);
  f[0][0]=1;
  for(int i=1;i<=n;i++){
    for(int j=0;j<=10000;j++){
      if(j>=s[i]){
        f[i][j]=f[i-1][j]||f[i-1][j-s[i]];
      }else{
        f[i][j]=f[i-1][j];
      }
    }
  }
  int ans=-1;
  for(int i=0;i<=10000;i++){
    if(f[n][i]){
      int score=i;
      if(score%10==0) score=0;
      if(score>ans) ans=score;
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>

int main(){
    int A[4],i;
    char s[4];
    scanf("%s",s);
    for(i=0;i<4;i++){
        A[i] = s[i] - '0';
    }

    int j,sum;
    char op[3];
    for(i=0;i<8;i++){
        sum = A[0];
        for(j=0;j<3;j++){
            if( i & ( 1 << j ) ){
                op[j] = '+';
                sum += A[j+1];
            }else{
                op[j] = '-';
                sum -= A[j+1];
            }
        }
        if( sum == 7 ){
            break;
        }
    }

    for(i=0;i<3;i++){
        printf("%d%c",A[i],op[i]);
    }
    printf("%d=7\n",A[3]);

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>

using namespace std;
typedef long long ll;

ll comb[61][61];
int n;

void getMth(int num, ll pos)
{
	for (int i = 1; i <= n; i++){
		if (num == 0) printf("0");
		else if (comb[n - i][num] >= pos) printf("0");
		else {
			printf("1");
			pos -= comb[n - i][num];
			num--;
		}
	}
	printf("\n");
}

int main()
{
	for (int i = 0; i <= 60; i++){
		comb[i][0] = comb[i][i] = 1;
		for (int j = 1; j < i; j++){
			comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
		}
	}
	
	ll m;
	while (scanf("%d %lld", &n, &m) && n){
		int i = 0;
		while (m - comb[n][i] > 0){
			m -= comb[n][i++];
		}
		getMth(i, m);
	}

	return (0);
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a > b) {
    for (int i = 0; i < a; i++) {
      cout << b;
    }
    cout << endl;
  }
  
  else {
    for (int i = 0; i < b; i++) {
      cout << a;
    }
    cout << endl;
  }
}

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

int main(){
	int N;
	int A[100000] = {0};
	int B;
	int flag = 0;

	cin >> N;
	for(int i=0;i<N;i++){
		cin >> B;
		A[B]++;
		if(A[B]>2 || A[0]>1)
			flag = 1;
	}

	if(flag == 1){
		cout << 0 << endl;
		return 0;
	}
	int per=1;
	for(int i=0;i<N/2;i++){
		per*=2;
		per%=1000000007;
	}
	cout << per << endl;
	return 0;
}

Measured memory_bytes: 640