akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define inf 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

/* 
 * * stuff you should look for
 * * int overflow, array bounds
 * * special cases (n=1?), set tle
 * */

int n, d, a;
vector<pii> mon;

struct SegTree{
    vector<ll> st, lazy;

    SegTree(){
        st.resize(4 * n + 4, 0);
        lazy.resize(4 * n + 4, 0);
    }

    void build(int p, int l, int r){
        if(l == r) st[p] = mon[l - 1].se;
        else {
            int mid = (l + r)/2;
            build(p + p, l, mid);
            build(p + p + 1, mid + 1, r);
            st[p] = st[p + p] + st[p + p + 1];
        }
    }

    void prop(int p, int l, int r){
        if(lazy[p]){
            st[p] += lazy[p] * (r - l + 1);
            if(l != r){
                lazy[p+p] += lazy[p];
                lazy[p+p+1] += lazy[p];
            }
            lazy[p] = 0;
        }
    }

    void upd(int p, int l, int r, int a, int b, ll x){
        prop(p, l, r);
        if(l > b or r < a) return;
        if(l >= a and r <= b){
            lazy[p] += x;
            prop(p, l, r);
        }
        else {
            int mid = (l + r)/2;
            upd(p + p, l, mid, a, b, x);
            upd(p + p + 1, mid + 1, r, a, b, x);
            st[p] = st[p + p] + st[p + p + 1];
        }
    }

    ll query(int p, int l, int r, int a, int b){
        prop(p, l, r);
        if(l > b or r < a) return 0;
        if(l >= a and r <= b) return st[p];
        else {
            int mid = (l + r)/2;
            ll x = query(p + p, l, mid, a, b);
            ll y = query(p + p + 1, mid + 1, r, a, b);
            return x + y;
        }
    }
};

int main(){
    fcin;

    cin >> n >> d >> a;

    for(int i = 0; i < n; i++){
        int x, h;   cin >> x >> h;

        h = (h + a - 1) / a;

        mon.eb(x, h);
    }

    sort(all(mon));

    SegTree s;
    s.build(1, 1, n);

    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll hp = s.query(1, 1, n, i + 1, i + 1);
        if(hp <= 0) continue;

        int x = mon[i].fi;
        int lo = i, hi = n - 1;

        int last = -1;
        while(lo <= hi){
            int mid = (lo + hi) / 2;

            if(x + (ll) 2 * d >= mon[mid].fi){
                last = mid;
                lo = mid + 1;
            } else hi = mid - 1;
        }

        assert(last != -1);

        ans += hp;
        s.upd(1, 1, n, i + 1, last + 1, -hp);
    }

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



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

using namespace std;


template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s)
{
    return '"' + s + '"';
}

string to_string(const char* s)
{
    return to_string((string) s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out()
{
    cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (s == "RRR")
    {
        cout << 3;
    }
    else
    {
        int num = 0;
        for (int i = 0; i < 3; i++)
        {
            if (s[i] == 'R')
            {
                num++;
            }
        }
        if (num == 0)
        {
            cout << 0;
            return 0;
        }
        if (num == 1)
        {
            cout << 1;
            return 0;
        }
        if (num == 2)
        {
            if (s[1] == 'R')
            {
                cout << 2;
            }
            else
            {
                cout << 1;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3648
S = input()

a, b = S[:2], S[2:]

a_can_month = (1 <= int(a) <= 12)
b_can_month = (1 <= int(b) <= 12)

print([["NA", "YYMM"], ["MMYY", "AMBIGUOUS"]][a_can_month][b_can_month])

Measured memory_bytes: 3060
#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<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int n;
	cin >> n;
	vector<int>vec(n);
	vecin(vec);
	if (n % 2 == 0) {
		rep(i, n / 2) {
			cout << vec[n - 1 - i * 2]<<" ";
		}
		rep(i, n / 2) {
			cout << vec[i * 2] << " ";
		}
		cout << endl;
	}
	else {
		rep(i, n / 2 + 1) {
			cout << vec[n - 1 - i * 2] << " ";
		}
		rep(i, n / 2) {
			cout << vec[1 + i * 2] << " ";
		}
		cout << endl;
	}
}



Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(){

	list<char>li;
	string s;
	cin>>s;
	char ch;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='1' || s[i]=='0')
			{
			  ch=s[i];	
				li.push_back(ch);
					}
       else { if(li.size()>0)
       	 li.pop_back();
       }

	}
	
	for(auto i:li)
		cout<<i<<"";
	return 0;	
}

Measured memory_bytes: 256
n, l = map(int,input().split())
A = list(map(int,input().split()))

last = -1
for i in range(n-1):
    if A[i] + A[i+1] >= l:
        last = i
        break

if last == -1:
    print("Impossible")
else:
    print("Possible")
    for i in range(last):
        print(i+1)
    for i in range(n-2, last-1, -1):
        print(i+1)


Measured memory_bytes: 63984
import math
X = int(input())

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

    divisors.sort()
    return divisors
    
divisors = make_divisors(X)
ans_A = 0
ans_B = 0
break_loop = False
for n in divisors:
    if X % 5 == n % 5:
        if X - n ** 5 != 0:
            B_cand = make_divisors(abs(X - n ** 5))
            for B in B_cand:
                A = B + n
                if A ** 5 - B ** 5 == X:
                    ans_A = A
                    ans_B = B
                    break_loop = True
                    break
                B = -B
                A = B + n
                if A ** 5 - B ** 5 == X:
                    ans_A = A
                    ans_B = B
                    break_loop = True
                    break
        else:
            ans_A = 0
            ans_B = -n
            break_loop = True
            break
    if break_loop:
        break

print(ans_A, ans_B)

Measured memory_bytes: 64360
n = int(input())
a = list(map(int,input().split()))
flag = True
counter = 0
while flag:
  flag = False
  for j in range(1,n):
    if a[j] < a[j-1]:
      temp = a[j]
      a[j] = a[j-1]
      a[j-1] = temp
      flag = True
      counter += 1
print(" ".join(map(str,a)))
print(counter)


Measured memory_bytes: 5596
#include <stdio.h>

int main()
{
    int  h1, s1, h2, s2, i;
    scanf("%d %d %d %d", &h1, &s1, &h2, &s2);
    for (i=0; ; i++) {
        h2=h2-s1;
        h1=h1-s2;
        if (h2<=0 || h1<=0) break;
    }
    if (h2<=0) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 1656
#include<stdio.h>

struct Card{
  char suit;
  char value;
};

void bubble(struct Card A[], int n){
  int i, j;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    for ( j = n-1; j >= i+1; j-- ){
      if ( A[j].value < A[j-1].value ){
	t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(struct Card A[], int n){
  int i, j, mini;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    mini = i;
    for ( j = i; j < n; j++ ){
      if ( A[j].value < A[mini].value ) mini = j;
    }
    t = A[i]; A[i] = A[mini]; A[mini] = t;
  }
}

void print(struct Card A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i ) printf(" ");
    printf("%c%c", A[i].suit, A[i].value);
  }
  printf("\n");
}

int isStable(struct Card C1[], struct Card C2[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( C1[i].suit != C2[i].suit ) return 0;
  }
  return 1;
}

int main(){
  struct Card C1[101], C2[101];
  int n, i;
  char ch;

  scanf("%d\n", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%c%c ", &C1[i].suit, &C1[i].value);
  }

  for ( i = 0; i < n; i++ ) C2[i] = C1[i];

  bubble(C1, n);
  selection(C2, n);

  print(C1, n);
  printf("Stable\n");
  print(C2, n);
  if ( isStable(C1, C2, n) ){
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }
}


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

int main(){
    int m,a,x,A,B,c=0;
    cin >> m >> A >> B;
    rep(i,0,m+1){
        x = i;
        a = 0;
        while (x != 0){
            a+= x % 10;
            x /= 10;
        }
        if(a>=A&&a<=B){
            c += i;
          //  cout << i << endl;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())
x = sorted(map(int, input().split()))
y = sorted(map(int, input().split()))
for Z in range(X+1, Y+1):
    if x[-1] < Z and y[0] >= Z:
        print("No War")
        break
else:
    print("War")


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

using namespace std;

long a[200005],b[200005];

int main(){
    int n,m;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a,a+n);
    cin >> m;
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    sort(b,b+m);
    int j = 0;
    bool f = false;
    for(int i = 0; i < n; i++){
        if(a[i] == b[j]){
            j++;
            if(j == m)break;
        }else if(a[i] > b[j]){
            f = true;
            break;
        }
    }
    if(f){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//----------------------------------------------------------------

int main()
{
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll m = min({a, b, c, d, e});
    ll t;
    if (n % m)
    {
        t = n / m + 1;
    }
    else
    {
        t = n / m;
    }
    cout << 4 + t << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;

class unionFind {
public:
  vector<ll> data;
  
  unionFind(ll size) {
    data.assign(size, -1);
  }
  
  bool same(ll x, ll y) {
    return find(x)==find(y);
  }
  
  void unite(ll x, ll y) {
    x=find(x);
    y=find(y);
    if(x==y) return;
    if(data[x]>data[y]) swap(x, y);
    data[x]+=data[y];
    data[y]=x;
  }
  
  ll find(ll k) {
    if(data[k]<0) return k;
    return data[k]=find(data[k]);
  }
  
  ll size(ll k) {
    return -data[find(k)];
  }
  
};


int main(void) {
  ll N, M;
  cin >> N >> M;
  P e[MAX];
  ll i;
  
  unionFind uf=unionFind(N);
  for(i=0; i<M; i++) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    e[i]={a, b};
  }
  
  vector<ll> v;
  ll t=N*(N-1)/2;
  for(i=M-1; i>=0; i--) {
    v.push_back(t);
    ll a=e[i].first, b=e[i].second;
    
    if(!uf.same(a, b)) {
      t-=uf.size(a)*uf.size(b);
      uf.unite(a, b);
    }
    
  }
  reverse(v.begin(), v.end());
  
  for(i=0; i<M; i++) pt(v[i]);
  
}






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

using namespace std;

int main()
{
  string ch, ch1;
  getline(cin, ch);
  getline(cin, ch1);
  bool f = 1;
  int i = 0;
  for(int j = 2; i < 3; j--, i++){
    if(ch[i] != ch1[j]){
      f = 0;
      break;
    }
  }
  printf("%s\n", f ? "YES" : "NO");
  
  return 0;
}

Measured memory_bytes: 384
#input
N, M = map(int, input().split())
A = [0] * M
B = [0] * M
C = [0] * M
for i in range(M):
    A[i], B[i] = map(int, input().split())
    C[i] = list(map(int, input().split()))

#output
dp = [9**9]* (1<<N)

def list_to_bin(my_list):
    my_bin = 0
    for l in my_list:
        my_bin += 1<<(l-1)
    return my_bin

for i in range(M):
    C[i] = list_to_bin(C[i])

dp[0] = 0
for i in range(M):
    for s in range(1<<N):
        dp[s|C[i]] = min(dp[s|C[i]], dp[s] + A[i])

if dp[-1] == 9**9:
    print(-1)
else:
    print(dp[-1])

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

P = [int(x) for x in input().split()]

count = 0
for i in range(1, N - 1):
    if P[i - 1] < P[i] and P[i] < P[i + 1]:
        count += 1
    if P[i + 1] < P[i] and P[i] < P[i - 1]:
        count += 1

print(count)


Measured memory_bytes: 3060
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, k, c; cin >> n >> k >> c;
	string s; cin >> s;
	vector<int> p(n + 1), l(n + 1), q(n + 1), r(n + 1);
	p[0] = -1e9;
	q[n] = 1e9;
	rep(i, n)
	{
		if (s[i] == 'o'&&p[i] + c < i)
		{
			p[i + 1] = i;
			l[i + 1] = l[i] + 1;
		}
		else
		{
			p[i + 1] = p[i];
			l[i + 1] = l[i];
		}
	}
	rrep(i, n)
	{
		if (s[i] == 'o'&&q[i + 1] - c > i)
		{
			q[i] = i;
			r[i] = r[i + 1] + 1;
		}
		else
		{
			q[i] = q[i + 1];
			r[i] = r[i + 1];
		}
	}
	vector<int> res;
	rep(i, n)
	{
		int tmp = l[i];
		int x = max(i + 1, p[i] + c + 1);
		if (x <= n)tmp += r[x];
		if (tmp < k)res.push_back(i + 1);
	}
	for (int x : res)cout << x << endl;
}

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

int main(){
	int n,m;
	cin>>n>>m;
	vector<bool> red(n+1,false);
	vector<int> balls(n+1,1);
	red[1]=true;
	for(int i=0;i<m;++i){
		int from,to;
		cin>>from>>to;
		if(red[from])
			red[to]=true;
		--balls[from];
		++balls[to];
		if(balls[from]==0)
			red[from]=false;
	}
	int cnt=0;
	for(int i=1;i<=n;++i)
		if(red[i])
			++cnt;
	cout<<cnt<<"\n";
	return 0;
}


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

int main() {
 int N,X;
 cin >> N >> X;
 int m[N];
 int h = X;
 int min = 1000;
 for(int i =0;i<N;i++) {
 	cin >> m[i];
 	if(m[i] < min) min = m[i];
            h = h - m[i];
}
 cout << N + (h/min) << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	S := map[string]bool{}
	for i := 0; i < n; i++ {
		sc.Scan()
		key := sc.Text()
		if _, ok := S[key]; !ok {
			S[key] = true
		}
	}

	sc.Scan()
	result := 0
	for sc.Scan() {
		key := sc.Text()
		if _, ok := S[key]; ok {
			result++
		}
	}
	fmt.Println(result)
}



Measured memory_bytes: 4548
package main

import (
	"fmt"
	"math"
)

func main() {
	var x1, x2, y1, y2 float64
	fmt.Scan(&x1, &y1, &x2, &y2)
	fmt.Println(math.Sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)))
}



Measured memory_bytes: 1196
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        //入力値を設定する
        String sentence = sc.next();
        
        //1文字ずつ分割する
        List<String> chars = Arrays.asList(sentence.split(""));
        
        //反転した文字列を取得する
        List<String> revChars = Arrays.asList(sentence.split(""));
        Collections.reverse(revChars);
        
        
        //回文にするかの判定：1文字ずつ比較する回数を取得する
        Integer comparisonCnt = 0;
        //文字数が奇数の場合は(chars-1)/2回比較する
        //文字列が偶数の場合はchars/2回比較する
        if(sentence.length() % 2 == 1) {
            comparisonCnt = (sentence.length() - 1) / 2;
        } else {
            comparisonCnt = sentence.length() / 2;
        }
        
        Integer cnt = 0;
        
        for (int i = 0; i < comparisonCnt; i++) {
            if(!(chars.get(i).equals(revChars.get(i)))) {
                cnt++;
            }
        }
        
        //出力する
        System.out.println(cnt);
    
    }    
}

Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

template<typename T>
inline bool chmin(T& x, T a) {
	if (x >= a) { x = a; return true; }
	return false;
}

template<typename T>
inline bool chmax(T& x, T a) {
	if (x <= a) { x = a; return true; }
	return false;
}

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


	ll N, M; cin >> N >> M;
	for (int i = 0; i < M; i++) {
		ll a; cin >> a;
		N -= a;
	}

	if (N < 0) { cout << "-1" << endl; }
	else { cout << N << endl; }

	return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N=scan.nextInt();
        int p=0;
      for(int i=0;i<N;i++){
           int s=scan.nextInt();
          if ((i+1)%2==1&&s%2==1){p++;}
      }

System.out.println(p);
    }
}


Measured memory_bytes: 27180
s = gets.chomp.split("")[0...-1]
ctn = []

(0..(s.count-2)).each do |i|
    (0..(s[0..(-(1+i))].count/2)).each do |i2|
       if s[0..(-(1+i))] == (s[0..i2]*2)
         ctn << s[0..(-(1+i))].count
       end
    end
end

puts ctn.max


Measured memory_bytes: 2428
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
typedef pair<LL, LL> P;
typedef pair<P, P> PP;
template<typename A, typename B>inline void chmin(A &a, B b) { if (a>b)a = b; }
template<typename A, typename B>inline void chmax(A &a, B b) { if (a<b)a = b; }

list<int>E[5000], out;
bool V[5000], flag;
int indeg[5000];

void tsort(int s) {
	queue<int>que;
	que.push(s);
	V[s] = true;
	while (!que.empty()) {
		if (que.size() >= 2)flag = true;
		int u = que.front(); que.pop();
		out.push_back(u);
		for (int v : E[u]) {
			indeg[v]--;
			if (!indeg[v] && !V[v]) {
				V[v] = true;
				que.push(v);
			}
		}
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	for (int t = 0; t < m; t++) {
		int i, j;
		cin >> i >> j;
		i--, j--;
		E[i].emplace_back(j);
		indeg[j]++;
	}
	for (int i = 0; i < n; i++) {
		if (!indeg[i] && !V[i])tsort(i);
	}
	for (int i : out)cout << i + 1 << endl;
	cout << flag << endl;
}

Measured memory_bytes: 6404
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
n = ii()
l = li()

l.sort()
from bisect import bisect_left as bl

ans = 0
for i in reversed(range(2,n)):
    for k in range(1 ,i):
        ng = l[i] - l[k] + 1
        tmp = bl(l[:k],ng)
        ans += max(0,k-tmp)
print(ans)



Measured memory_bytes: 51292
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

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

  int result = (A == B) * C + (B == C) * A + (C == A) * B;
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;



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

	cin >> N >> L >> R >> K;
	vector<int>ay(1000001, -1);
	vector<int>ax(1000001, -1);
	vector<int>by(1000001, -1);
	vector<int>bx(1000001, -1);
	vector<int>axnum(N);
	vector<int>aynum(N);
	vector<int>bxnum(N);
	vector<int>bynum(N);
	int aldnum = 0;
	int alunum = 0;
	int bldnum = 0;
	int blunum = 0;
	if (N == 1) {
		L += 3, R += 3;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> M;
			ay[M] = i, ax[M] = j;
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> M;
			by[M] = i, bx[M] = j;
		}
	}
	int a = 0, b = 0;
	while (K--) {
		cin >> M;
		if (ay[M] != -1) {
			aynum[ay[M]]++;
			if (aynum[ay[M]] == N)a++;
			axnum[ax[M]]++;
			if (axnum[ax[M]] == N)a++;
			if (ay[M] == ax[M]) {
				aldnum++;
				if (aldnum == N)a++;
			}
			if (ay[M] + ax[M] == N - 1) {
				alunum++;
				if (alunum == N)a++;
			}
		}
		if (by[M] != -1) {
			bynum[by[M]]++;
			if (bynum[by[M]] == N)b++;
			bxnum[bx[M]]++;
			if (bxnum[bx[M]] == N)b++;
			if (by[M] == bx[M]) {
				bldnum++;
				if (bldnum == N)b++;
			}
			if (by[M] + bx[M] == N - 1) {
				blunum++;
				if (blunum == N)b++;
			}
		}
		if (a >= L && b >= R) {
			cout << "DRAW" << endl;
			return 0;
		}
		if (a >= L) {
			cout << "USAGI" << endl;
			return 0;
		}
		if (b >= R) {
			cout << "NEKO" << endl;
			return 0;
		}
	}
	cout << "DRAW" << endl;
}


Measured memory_bytes: 18416
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; cout << "i=  ";for(ll i=0; i<num; i++) cout << i << "   ";cout << endl;  
  cout << "    ";
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<"   ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<"   ";}
  cout << endl;
}

// template <typename T>
// void print_pairvec(const vector<T> &v, ll num=0){
//   if(num == 0) num = (ll)v.size();
//   cout << endl; for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
// }
template <typename T>
void print_pairvec(const T &_pair, ll num=0){
  cout << endl; for(pair<ll, int> x: _pair){ cout << x.first << " " << x.second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}


int main(){
  
  int A, B;
  cin >> A >> B;
  if(A%2 == 1 && B%2 == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
  // cout << fixed;//小数点を確実に10桁で表示するためのもの
  // cout << setprecision(10); 
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <cmath>
#include <list>
#include <map>
#include <algorithm>
#include <string>
#include <queue>

using namespace std;
typedef long long ll;

ll N,K;
ll N_MAX = 100100;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
Graph G;
ll inf = 1LL<<60;
vector<ll> res(N_MAX);

void dijkstra(){
    priority_queue<Edge,vector<Edge>,greater<Edge>> Q;
    res[K]=0;
    Q.push(Edge(0,K));
    while(!Q.empty()){
        Edge u = Q.top();Q.pop();
        ll v = u.second;
        if(res[v]<u.first) continue;
        for(auto e : G[v]){
            if(res[e.second] < res[v]+e.first) continue;
            else{
                res[e.second]=res[v]+e.first;
                Q.push(Edge(res[e.second],e.second));
            }
        }
    }
}

int main() {
    cin >> N;
    G.assign(N_MAX,vector<Edge>());
    fill(res.begin(),res.end(),inf);
    for(int i=0;i<N-1;i++){
        ll a,b,c;
        cin >> a >> b >> c;
        G[a].push_back(Edge(c,b));
        G[b].push_back(Edge(c,a));
    }
    ll Q;
    cin >> Q >> K;
    vector<ll> X(Q),Y(Q);
    for(int i=0;i<Q;i++){
        cin >> X[i] >> Y[i];
    }
    dijkstra();
    for(int i=0;i<Q;i++){
        cout << res[X[i]] + res[Y[i]] << endl;
    }
}

Measured memory_bytes: 12656
#include<cstdio>
#include<algorithm>
static const int kMax_sequence_length = 100010;
using namespace std;

int A[kMax_sequence_length];
int N;

void Solve(int a, int *current){
	static int remove = 0;
	if(current == A + N) {
		printf("%d\n", remove);
		return;
	} else {
		int *next = upper_bound(A, A + N, a);
		int nmbr_of_a = distance(current, next);
		remove += nmbr_of_a < a ? nmbr_of_a : nmbr_of_a - a;
		Solve(*next, next);
	}
}

int main(){
	scanf("%d", &N);
	for (int i = 0; i < N; ++i)
		scanf("%d", &A[i]);
	sort(A, A + N);
	Solve(A[0], A);
	return 0;
}

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

int main() {
    const vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
    const vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};
    int h, w;
    cin >> h >> w;
    vector<string> grid(h);
    for (int i = 0; i < h; ++i) {
        cin >> grid[i];
    }
    vector<vector<int>> ans(h, vector<int>(w, 0));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (grid[i][j] == '#') ans[i][j] = -1;
            else continue;
            for (int k = 0; k < 8; ++k) {
                int nx = i + dx[k];
                int ny = j + dy[k];
                if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
                if (grid[nx][ny] == '#') continue;
                ans[nx][ny]++;
            }
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (ans[i][j] == -1) cout << '#';
            else cout << ans[i][j];
        }
        cout << endl;
    }
}


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

public class Main{
  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] s = br.readLine().split("/");
    
    if(Integer.parseInt(s[1]) <= 4){
      System.out.println("Heisei");
    }else{
      System.out.println("TBD");
    }
  }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll a,b,k;

int main(){
  cin >> a >> b >> k;
  if(a<=k){
    cout << 0 << " " << max(0LL,b-(k-a)) << endl;
  }else{
    cout << a-k << " " << b << endl;
  }

  return 0;
}


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

Int power(Int n, Int m) {
    Int ans = 1;
    rep(i,m) {
        ans *= n;
    }
    return ans;
}

int main(){ 
    Int INF = 1e10;
    Int N, M, X, all, ans = INF;
    cin >> N >> M >> X;

    vector<Int> C(N);
    vector<vector<Int>> A(N, vector<Int>(M));

    rep(i,N) {
        cin >> C[i];
        rep(j,M) cin >> A[i][j];
    }

    all = power(2,N);

    bool flag = false;

    rep(k,all) {
        Int cost = 0;
        vector<Int> rikaido(M,0);

        rep(i,N) {
            if ((k % power(2,i+1))/power(2,i)) {
                cost += C[i];
                rep(j,M) {
                    rikaido[j] += A[i][j];
                }
            }
        }
        
        bool tassei = true;
        rep(j,M) {
            if (rikaido[j] < X) tassei = false;
        }

        if(tassei) {
            ans = min(ans, cost);
            flag = true;
        }
    }

    if (!flag) ans = -1;

    cout << ans << endl;

}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define $$ long long int
#define pb push_back
#define db pop_back
#define q2(n) (n%2)==0
#define loop(i,m,p) for ($$ i = m; i < p; ++i)
#define loopn(i,m,p) for ($$ i = p-1; i >=m; --i)

using namespace std;

int main()
{
    $$ n,cn=0;
    cin>>n;
    for ($$ i = n; i >0 ;i/=10)
    {
       $$ k=i%10;
       if (k==2)
       {
         cn++;
       }

    }
    cout<<cn<<endl;


    return 0;

}



Measured memory_bytes: 256
let N = stdin.ReadLine() |> int64
let A = stdin.ReadLine().Split() |> Array.map int64
let P = 1_000_000_007L            

let cache: int64[] =
    Array.unfold 
        (fun (i, total) ->
            if i >= A.Length then None
            else Some((total + A.[i]) % P , (i + 1, (total + A.[i]) % P)))
        (0, 0L)

let sumAt (i: int): int64 =
    if i < 0 then 0L
    elif A.Length <= i then cache.[A.Length-1]
    else cache.[i]

{2L..N} |> Seq.fold (fun acc i -> ((acc + A.[int i - 1] * sumAt(int i - 2) % P)) % P) 0L |> stdout.WriteLine


Measured memory_bytes: 71288
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int):
    S = str(N)
    if S[0] == "7" or S[1] == "7" or S[2] == "7":
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9128
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;

	vector<string> S(N);
	VI P(N),L(N);
	REP(i, N) {
		string s;
		cin >> S[i] >> P[i];
		L[i] = i + 1;
	}
	REP(i, N - 1) {
		FOR(j, i + 1, N) {
			int k = 0;
			string tmp;
			while (k < S[i].size() && k < S[j].size()) {
				if (S[i][k] - 'a' > S[j][k] - 'a') {
					swap(L[i], L[j]);
					tmp = S[i];
					S[i] = S[j];
					S[j] = tmp;
			
					break;
				}
				else if (S[i][k] == S[j][k]) {
					k++;
					if (S[j].size() == k && S[j].size() < S[i].size()) {
						//cout << "K" << endl;
						swap(L[i], L[j]);
						tmp = S[i];
						S[i] = S[j];
						S[j] = tmp;

						break;
					}
					continue;					
				}
				else {
					break;
				}
				k++;
				if (S[j].size() == k && S[j].size() < S[i].size()) {
					//cout << "K" << endl;
					swap(L[i], L[j]);
					tmp = S[i];
					S[i] = S[j];
					S[j] = tmp;

					break;
				}
			}
		}
	}
	
	REP(i, N - 1) {
		FOR(j, i + 1, N) {
			if (S[i] == S[j] && P[L[i] - 1] < P[L[j] - 1]) {
				swap(L[i], L[j]);
			}
		}
	}
	REP(i, N) {
		//cout << S[i] << " " << P[L[i]-1] << endl;
		cout << L[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int r, D, x;
  scanf("%d%d%d", &r, &D, &x);

  int i;
  for(i=1; i<=10; i++){
    x = r*x-D;
    printf("%d\n", x);
  }
  
  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

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

    if (x < 1200) {
        cout << "ABC" << endl;

    } else {
        cout << "ARC" << endl;
    };
}



Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        boolean ans = false;
        
        if ((a < c && c < b) || (a > c && c > b)) {ans = true;}
        
        System.out.println(ans?"Yes":"No");
    }
}


Measured memory_bytes: 23892
import bisect
N=int(input())
A=sorted(list(map(int,input().split())))
B=list(map(int,input().split()))
C=sorted(list(map(int,input().split())))
ans=0
for val in B:
  val1=bisect.bisect_left(A,val)
  val2=N-bisect.bisect_right(C,val)
  ans+=val1*val2
print(ans)

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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;


int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int n, l; cin >> n >> l;
   vector<string> v;
   for(int i =0; i < n; i++)
   {
      string s; cin >> s;
      v.push_back(s);
   }
   sort(all(v));
   for(auto s : v) cout << s;



	return 0;
}


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

int main(){
  int n;
  cin >> n;
  int t[n];
  for(int i=0;i<n;i++) cin >> t[i];
  int x[100000],y[100000];
  for(int i=0;i<100000;i++){
    x[i]=0,y[i]=0;
  }
  for(int i=0;i<n;i+=2){
    x[t[i]-1]++;
  }
  for(int i=1;i<n;i+=2){
    y[t[i]-1]++;
  }
  int a=0,b=0,c=-1,d=-1;
  for(int i=0;i<100000;i++){
    if(a<x[i]){
      a=x[i];
      c=i;
    }
    if(b<y[i]){
      b=y[i];
      d=i;
    }
  }
  if(c!=d){
    cout << n-a-b << endl;
  }
  else{
    int f=0,g=0,ff=-1,gg=-1;
    for(int i=0;i<100000;i++){
      if(f<x[i]&&i!=c){
        f=x[i];
        ff=i;
      }
      if(g<y[i]&&i!=d){
        g=y[i];
        gg=i;
      }
    }
    cout << min(n-a-f,n-b-g) << endl;
  }
}

Measured memory_bytes: 1408
using System.Collections.Generic;
    using System.Collections;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System;

    namespace cysharp_test
    {
        class Program
        {
            static void Main (string[] args)
            {
                new Program ().solve ();
            }

            void solve ()
            {
            var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int thp = a[0];
            int ahp = a[2];
            int turn = 0;
            while(true){
                if (thp <= 0) { Console.WriteLine("No"); break; }
                else if (ahp <= 0) { Console.WriteLine("Yes"); break; }
                if (turn == 0) { ahp -= a[1];turn = 1; }
                else if (turn == 1) { thp -= a[3]; turn = 0; }
            }
            Console.ReadKey();
        }

        }

        struct Vector2
        {
            public Vector2 (long x, long y)
            {
                this.x = x;
                this.y = y;
            }

            public long x, y;

            public string ToString ()
            {
                return "(" + this.x + "," + this.y + ")";
            }

            public static Vector2 operator + (Vector2 a, Vector2 b)
            {
                return new Vector2 (a.x + b.x, a.y + b.y);
            }

            public static Vector2 operator - (Vector2 a, Vector2 b)
            {
                return new Vector2 (a.x - b.x, a.y - b.y);
            }

            public static Vector2 operator * (Vector2 a, long scala)
            {
                return new Vector2 (a.x * scala, a.y + scala);
            }

            public static bool operator == (Vector2 a, Vector2 b)
            {
                return a.x == b.x && a.y == b.y;
            }

            public static bool operator != (Vector2 a, Vector2 b)
            {
                return !(a.x == b.x && a.y == b.y);
            }
        }
    }

Measured memory_bytes: 19104
import Data.List

splitRec _ [] = []
splitRec n xs = let (h, t) = splitAt n xs in h : splitRec n t

counting = (++[(0, 0)]) . sortBy (flip compare) . map (\es -> (length es, head es)) . group . sort 

calc n [os, es]
  | ov /= ev = n - oc - ec
  | otherwise = min (n - oc - secondc es) (n - ec - secondc os)
  where
    (oc, ov) = head os
    (ec, ev) = head es
    secondc = fst . head . tail

main = calc <$> readLn <*> (map counting . transpose . splitRec 2 . map (read :: String -> Int) . words <$> getLine) >>= print

Measured memory_bytes: 52604
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef pair<int, int> P;

bool v[2005][2005];

int bfs (int x, int y, int W, int H )
{
	const int dir[][2] = { { 0, -1 }, { 1, 0 }, { 0, 1 } , { -1, 0 } }; 
	queue<P> que;
	que.push (P(x, y ) );

	while (!que.empty() ){
		P curr = que.front(); que.pop();
		int cx = curr.first, cy = curr.second;
		for (int k = 0; k < 4; k++ ){
			int nx = cx + dir[k][0];
			int ny = cy + dir[k][1];
			if (nx < 0 || nx >= W - 1 || ny < 0 || ny >= H - 1 || v[nx][ny] )
				continue;
			v[nx][ny] = 1;
			que.push (P (nx, ny ) );
		} // end for
	} // end while
}

int main()
{
//	cut here before submit 
//	freopen ("input.txt", "r", stdin );
	int w, h;

	while (cin >> w >> h && w && h ){
		memset (v, false, sizeof (v ) );
		int n;
		cin >> n;
		vector <int> sx (n, 0), ex (n, 0 ), sy (n, 0 ), ey (n, 0 );
		vector <int> x,y; 
		for (int i = 0; i < n; i++ ){
			cin >> sx[i] >> sy[i] >> ex[i] >> ey[i];
			x.push_back (sx[i] ); x.push_back (ex[i] );
			y.push_back (sy[i] ); y.push_back (ey[i] );
		} // end for
		x.push_back (0 ); x.push_back (w );
		y.push_back (0 ); y.push_back (h );
		sort (ALL(x ) ); sort (ALL(y ) );
		x.erase (unique (ALL (x ) ), x.end() );
		y.erase (unique (ALL (y ) ), y.end() );
		int W = x.size(), H = y.size();
		rep (i, n ){
			sx[i] = lower_bound (ALL (x), sx[i] ) - x.begin();
			ex[i] = lower_bound (ALL (x), ex[i] ) - x.begin();
			sy[i] = lower_bound (ALL (y), sy[i] ) - y.begin();
			ey[i] = lower_bound (ALL (y), ey[i] ) - y.begin();
		} // end rep

		for (int i = 0; i < W; i++ ){
			v[i][H-1] = true;
		} // end for
		for (int j = 0; j < H; j++ ){
			v[W-1][j] = true;
		} // end for

		rep (i, n ){
			for (int x = sx[i]; x < ex[i]; x++ ){
				for (int y = sy[i]; y < ey[i]; y++ ){
					v[x][y] = true;
				} // end for
			} // end for
		} // end for
		int res = 0;
		for (int i = 0; i < W; i++ ){
			for (int j = 0; j < H; j++ ){
				if (!v[i][j] ){
					v[i][j] = true;
					++res;
					bfs (i, j, W, H );				
				} // end if
			} // end for
		} // end for
		cout << res << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

ll N;
vector<ll> P,M;

int main(){
  cin>>N;
  ll mx=INF;
  FOR(i,1,N+1){
    ll p;
    cin>>p;
    mx=min(mx,p);
    P.emplace_back(p);
    M.emplace_back(mx);
  }
  ll cnt=0;
  REP(i,N){
    if(P[i]<=M[i]){
      cnt++;
    }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3564
import java.util.Scanner;

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

        int X=sc.nextInt();

        int gohyaku=0;
        int go=0;

        gohyaku=X/500;
        go=(X%500)/5;

        System.out.println((gohyaku*1000+go*5));
    }
}

Measured memory_bytes: 24788