akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(){
    int a, b, c, d;
    int total = 0;
    cin >> a >> b >> c >> d;
    total = a + b + c + d;
    int m, s;
    s = total % 60;
    m = total / 60;

    cout << m << endl << s << endl;
    return 0;
}

Measured memory_bytes: 1164
K = int(input())
ls = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(ls[K-1])


Measured memory_bytes: 2940
import itertools as it

num = int(input())

item_number = num//100
temp_val = num%100

times = temp_val //15
temp_val = temp_val % 15

if temp_val <= 5:
    temp_val = 1
elif temp_val <= 10:
    temp_val = 2
else:
    temp_val =3

need_item_number = 3*times + temp_val

# print(item_number)
# print(times)
# print(need_item_number)

if item_number >= need_item_number:
    print(1)
else:
    print(0)

Measured memory_bytes: 3060
#include<stdio.h>                                                                                                     2
#define min(a,b) (a < b ? a : b)
typedef unsigned long int ul;
int main(void){
    ul L, R;
    int m = 2019;
    scanf("%lld %lld", &L, &R);
    ul ans = 1000000000;
    int cnt[2] = {0, 0};
    int t = 0;
    for(ul i = L; (i < R) && (cnt[0] < 5000); i++, cnt[0]++){
        cnt[0] = 0;
        for(ul j = i + 1; (j <= R) && (cnt[1] < 5000); j++, cnt[1]++){
            ans = min( (i * j) % m, ans);
        }
    }
    printf("%lu", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
const ll INF = 1LL<<60;

template <typename T>
struct RMQ {
    //const T INF = numeric_limits<T>::max();
    ll n;         // 葉の数
    vector<T> dat; // 完全二分木の配列
    RMQ(ll n_) : n(), dat(n_ * 4, 0) { // 葉の数は 2^x の形
        ll x = 1;
        while (n_ > x) {
            x *= 2;
        }
        n = x;
    }
    void update(ll i, T x) {
        i += n - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;  // parent
            dat[i] = max(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }
    // the maximum element of [a,b)
    T query(ll a, ll b) { return query_sub(a, b, 0, 0, n); }
    T query_sub(ll a, ll b, ll k, ll l, ll r) {
        if (r <= a || b <= l) {
            return 0;
        } else if (a <= l && r <= b) {
            return dat[k];
        } else {
            T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return max(vl, vr);
        }
    }
};


const ll MOM=300000;
//D
int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll> A(N+1,0);
  ll a,b;
  rep(i,N){
    cin>>A[i];
  }

  RMQ<ll> rmq(MOM+2);
  
  rep(i,N){
    rmq.update(A[i],rmq.query(A[i]-K,A[i]+K+1)+1);
  }
  

  cout<<rmq.query(0,MOM+1)<<endl;
  
}


Measured memory_bytes: 14844
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var abc={A:1,B:0,C:0};

Arr.forEach(function(v){
var arr=v.split(",");
var m=abc[arr[0]];
abc[arr[0]]=abc[arr[1]];
abc[arr[1]]=m;
});

for (var i in abc){
if(abc[i]==1)console.log(i);
}

Measured memory_bytes: 7380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}



// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    ll r,D,x;
    cin >> r >> D >> x;

    for (int i = 0; i < 10; i++)
    {
        x = r*x - D;
        cout << x << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#a, b = gets.chomp.split(" ").map(&:to_i);
s = gets.chomp

count_e = 0
count_o = 0
i=0

s.each_char do |c|
  count_e += 1 if i%2 == 0 && c == '0'
  count_o += 1 if i%2 == 0 && c == '1'
  count_e += 1 if i%2 == 1 && c == '1'
  count_o += 1 if i%2 == 1 && c == '0'
  i+=1
end

puts [count_e, count_o].min

Measured memory_bytes: 1916
<?php

$N = fgets(STDIN);
for ($i = 0; $i < intval($N); $i++) {
    $n = intval(fgets(STDIN));
    if ($i === 0) {
        $min = $n;
        continue;
    } elseif ($i === 1) {
        $profit = $n - $min;
        $prev = $n;
        continue;
    }

    if ($prev < $min) {
        $min = $prev;
    }

    $result = $n - $min;
    $prev = $n;

    if ($result > $profit) {
        $profit = $result;
    }
}

echo $profit, PHP_EOL;



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

#define FOR(i, s, e)   for(int i = (s); i < (e); i++)
#define FOR64(i, s, e) for(ll  i = (s); i < (e); i++)
#define ALL(x)         (x).begin(), (x).end()
#define SORT(b, e)     sort((b), (e))
#define REV(b, e)      reverse((b), (e))
#define VSORT(v)       sort((v).begin(), (v).end())
#define VREV(v)        reverse((v).begin(), (v).end())
#define pb(a)          push_back(a)
#define INF            999999999

typedef long long ll;

vector<ll> a, p;

ll f(ll N, ll X)
{
	if(N == 0){
		if(X == 0)
			return 0;
		return 1;
	}

	if(X == 1){
		return 0;
	}
	else if(X <= 1 + a[N-1]){
		return f(N-1, X-1);
	}
	else if(X == 2 + a[N-1]){
		return p[N-1] + 1;
	}
	else if(X <= 2 + 2 * a[N-1]){
		return p[N-1] + 1 + f(N-1, X - 2 - a[N-1]);
	}
	else if(X == 3 + 2 * a[N-1]){
		return p[N-1] + 1 + p[N-1];
	}
}

int main()
{
	ll N, X;
	cin >> N >> X;
	a.resize(N + 1);
	p.resize(N + 1);
	a[0] = 1;
	p[0] = 1;
	FOR(i, 1, N+1){
		a[i] = 2 * a[i-1] + 3;
		p[i] = 2 * p[i-1] + 1;
	}

	cout <<  f(N, X) << endl;

	return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    a,b = map(int, input().split())

    print(math.ceil((a+b)/2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62708
package main

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

var sc = bufio.NewScanner(os.Stdin)

const initBufSize, maxBufSize = 10000, 1000000

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInts(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = nextInt()
	}
	return res
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func pow(r, n int) int {
	return int(math.Pow(float64(r), float64(n)))
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initBufSize), maxBufSize)
	s := nextStr()
	t := nextStr()
	if s == t[:len(t)-1] && (len(t)-len(s) == 1) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1752
#include<iostream>
#include<queue>

using namespace std;

int main(){

	int n, m;
	int a[1000], b[1000], c[1000], d[1000];
	int x1, x2, y1, y2;
	int ed[21];
	char gav;
	queue<int> q;

	cin >> n;
	cin >> m;

	for (int i = 0; i < m; i++){
		cin >> a[i] >> gav >> b[i] >> gav >> c[i] >> gav >> d[i];
	}

	cin >> x1 >> gav >> x2 >> gav >> y1 >> gav >> y2;

	for (int i = 0; i < 21; i++){
		ed[i] = -1;
	}

	ed[x1] = y1;
	q.push(x1);
	while (!q.empty()){
		int no = q.front();
		q.pop();
		for (int i = 0; i < m; i++){
			if (a[i] == no){
				if (ed[b[i]] < ed[a[i]] - c[i]){
					ed[b[i]] = ed[a[i]] - c[i];
					q.push(b[i]);
				}
			}
			if (b[i] == no){
				if (ed[a[i]] < ed[b[i]] - d[i]){
					ed[a[i]] = ed[b[i]] - d[i];
					q.push(a[i]);
				}
			}
		}

	}

	ed[x2] -= y2;

	for (int i = 0; i < 21; i++){
		if (i != x2) ed[i] = -1;
	}

	q.push(x2);
	while (!q.empty()){
		int no = q.front();
		q.pop();
		for (int i = 0; i < m; i++){
			if (a[i] == no){
				if (ed[b[i]] < ed[a[i]] - c[i]){
					ed[b[i]] = ed[a[i]] - c[i];
					q.push(b[i]);
				}
			}
			if (b[i] == no){
				if (ed[a[i]] < ed[b[i]] - d[i]){
					ed[a[i]] = ed[b[i]] - d[i];
					q.push(a[i]);
				}
			}
		}

	}

	cout << ed[x1] << endl;

	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int K;
    string S;
    cin >> K >> S;
    if (S.size() > K) {
        for (int i = 0; i<K; ++i){
            cout << S[i];
        }
        cout << "...";
    }
    else {
        cout << S;
    }
}

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

int x, ans, p;

int main() {
  cin >> x;
  vector<int> num(100004);
  vector<int> temp;
  vector<int> prime;
  rep (i, 100004) {
    num.at(i) = i;
  }
  num.erase(num.begin(), num.begin() + 2);
  p = 0;
  while (p < 330) {
    p = num.at(0);
    temp = {};
    rep (i, num.size()) {
      if (num.at(i) % p == 0) temp.push_back(i);
    }
    rep (i, temp.size()) {
      num.erase(num.begin() + temp.at(i) - i);
    }
    prime.push_back(p);
  }
  rep (i, num.size()) {
    prime.push_back(num.at(i));
  }
  rep (i, prime.size()) {
    if (prime.at(i) >= x) {
      ans = prime.at(i);
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <string>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#define pie 3.141592653589793238
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long x, ans;
  cin >> x;
  long long m1 = 100;
  long long m2 = 0;
  for(int i=1; i<3762; i++){
    m2=m1*0.01+m1;
    if(m2>=x) {
      ans = i;
      break;
    }
    m1=m2;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        InputStream inputStream;
        OutputStream outputStream;
        inputStream = System.in;
        outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {

        public void solve(InputReader in, PrintWriter out) {
            int n;
            n = in.nextInt();
            long ans = 0;
            for(int i = 1;i <= n;++i){
                ans += (long)i * (long)(n - i + 1);
            }
            for(int i = 1;i < n;++i){
                int u,v;
                u = in.nextInt();
                v = in.nextInt();
                if(u > v){
                    int tmp = u;
                    u = v;
                    v = tmp;
                }
                ans -= (long)u * (long)(n - v + 1);
            }
            out.println(ans);
        }

    }
    
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}




Measured memory_bytes: 55768
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k, x = 1e9, t = 0;
	cin >> n;
	while (n--) {
		cin >> k;
		if (x > k) t++;
		x = min(x, k);
	}
	cout << t << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <vector>
#define X real()
#define Y imag()
#define EPS 1e-10
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
typedef pair<P,double> C;

double dot(P a, P b){
  return a.X*b.X + a.Y*b.Y;
}

double cross(P a, P b){
  return a.X*b.Y - a.Y*b.X;
}

vector<P> sort_comp(vector<P> a){
  int l = a.size();
  vector< pair<double, double> > t(l);
  for(int i = 0; i < l; ++i){
    t[i].first = a[i].X;
    t[i].second = a[i].Y;
  }
  sort(t.begin(),t.end());
  for(int i = 0; i < l; ++i){
    a[i] = P(t[i].first,t[i].second);
  }
  return a;
}

P n_vector(P a){
  double l = abs(a);
  return P(-a.Y,a.X)/l;
}

vector<P> cpcc(C a, C b){
  double d = abs(a.first-b.first), ra = a.second, rb = b.second;
  double t = (ra*ra-rb*rb+d*d)/2/d, h = sqrt(ra*ra-t*t);
  P m = t/abs(b.first-a.first)*(b.first-a.first)+a.first;
  vector<P> cp(2,m);
  P n = n_vector(a.first-b.first);
  cp[0] -= h*n;
  cp[1] += h*n;
  return sort_comp(cp);
}

int main(){
  double x, y, r;
  vector<C> Cs(2);
  for(int i = 0; i < 2; ++i){
    cin >> x >> y >> r;
    Cs[i] = C(P(x,y),r);
  }
  vector<P> cp = cpcc(Cs[0],Cs[1]);
  printf("%.10lf %.10lf %.10lf %.10lf\n",cp[0].X,cp[0].Y,cp[1].X,cp[1].Y);
  return 0;
}

Measured memory_bytes: 3340
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int

using namespace std;



int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    ll N;

    cin>>N;
    ll arr[N];
    ll mx=0;
    for(ll i=0;i<N;i++){
        cin>>arr[i];
        mx=max(mx,arr[i]);
    }
    ll dummy[N];
    std::copy(arr,arr+N,dummy);
    sort(arr,arr+N);
    bool first=true;
    for(ll i=0;i<N;i++){
        if(mx==dummy[i] && first){
            cout<<arr[N-2]<<"\n";
            first=false;
        }
        else
            cout<<mx<<"\n";
    }




    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    string S, T; cin >> S >> T;
    int ans = 0;
    rep(i, S.size()-T.size()+1){
        int tmp = 0;
        for(int j = i; j < i + T.size(); ++j){
            if(S.at(j) == T.at(j-i)) tmp++;
        }
        if(tmp>ans) ans = tmp;
    }
    cout << T.size()-ans << endl;
}

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

int main() {
    int n, h;
    cin >> n;
    int maxh = 0;
    int ans = 0;
    for (int i=0; i<n; i++) {
        cin >> h;
        if (maxh <= h) ans++;
        maxh = max(maxh, h);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;

typedef long long ll;

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n + 1);
    rep(i, n + 1) cin >> a[i];
    combination comb(1e6);

    // 長さが足りるかの判定
    // 2個目のidx
    map<ll, ll> mp;
    int second_idx = -1; 
    rep(i, n + 1) {
        if (mp.count(a[i])) {
            second_idx = i;
            break;
        } 
        mp[a[i]]++;
    }
    int first_idx = find(a.begin(), a.end(), a[second_idx]) - a.begin();

    for (int k = 1; k <= n + 1; k++) {
        mint ans = comb(n + 1, k);
        if (k == 1) {
            ans -= 1;
        } else if (k != n + 1) {
            // // 左側
            // if (first_idx >= k - 1) ans -= comb(first_idx, k - 1);
            // // 右側
            // // 0 1 2 3 4 5
            // if (n - second_idx >= k - 1) ans -= comb(n - second_idx, k - 1);

            // 中側
            if (first_idx + n - second_idx >= k - 1) {
                ans -= comb(first_idx + n - second_idx, k - 1);
            }
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 23936
#include <iostream>                                             
using namespace std;                                            
                                                                
int main() {                                                    
  int a, b, c;                                                  
  cin >> a >> b >> c;                                           
  if (a<b && b<c) {                                             
    cout << "Yes" << endl;                                      
  } else {                                                      
    cout << "No" << endl;                                       
  }                                                             
  return 0;                                                     
}                                                               
                                  

Measured memory_bytes: 3008
import java.util.Scanner;
import java.util.ArrayList;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		String T;
		int count = 0;
		ArrayList<String> lowerT = new ArrayList<String>();
		while (true) {
			T = sc.next();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			lowerT.add(T.toLowerCase());
		}
		for (int i = 0; i < lowerT.size(); i++) {
			if (W.equals(lowerT.get(i))) {
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	}
}


Measured memory_bytes: 26328
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			
			System.out.println((A - 1) * (B - 1));
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 20308
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <climits>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int x = 0, max = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'I') {
            x++;
        }else if (s[i] == 'D'){
            x--;
        }
        if (max < x) {
            max = x;
        }
    }
    cout << max << endl;
}


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

int main(){
	ll N, T;
    cin >> N >> T;
    vector<ll> t(N);
    ll sum = T;

    for(int i = 0; i < N; i++)
    {
        cin >> t[i];
    }
    sum += t[N-1];

    for(int i = 1; i < N; i++)
    {
        if(t[i]-t[i-1] > T) sum -= t[i]-t[i-1] - T;
    }
    
    cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1792
from collections import deque
S = input()
q = deque()
for s in S:
    q.append(s)

Q = int(input())
flag = True
cnt = 0
for _ in range(Q):
    query = list(map(str, input().split()))
    if len(query) == 1:
        # 反転するクエリ
        cnt += 1
        if flag:
            flag = False
        else:
            flag = True
    else:
        f, c = query[1], query[2]
        if f == "1":  # 先頭に追加する命令
            if flag:  # 反転していない状態であれば前に追加する
                q.appendleft(c)
            else:  # 反転している状態であれば、後ろに追加する
                q.append(c)
        elif f == "2":  # 末尾に追加する命令
            if flag:  # 反転していない状態であれば末尾に追加する
                q.append(c)
            else:
                q.appendleft(c)
ans = "".join(list(q))
if cnt % 2 == 1:
    ans = ans[::-1]
print(ans)


Measured memory_bytes: 8948
#include<stdio.h>
int main(void){
	int a, b;
	char N[2];
      scanf("%s", N);
  char O[2];
  scanf("%s", O);
    char P[2];
    scanf("%s", P);

	printf("%c", N[0]);
	printf("%c", O[1]);
	printf("%c", P[2]);
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#include <cmath>
#include <cassert>
#define SIZE 155

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

ll dp1[2][SIZE];
ll dp[2][SIZE][SIZE][SIZE];

int main()
{
	int n,K,MOD;
	scanf("%d %d %d",&n,&K,&MOD);
	if(K%2==0)
	{
		ll ret=1;
		for(int t=0;t<2;t++)
		{
			int len=(n-t+1)/2;
			int pos=0;
			memset(dp1,0,sizeof(dp1));
			dp1[pos][0]=1;
			for(int i=0;i<len;i++)
			{
				pos=1-pos;
				memset(dp1[pos],0,sizeof(dp1[pos]));
				for(int j=0;j<=i;j++)
				{
					dp1[pos][j+1]+=dp1[1-pos][j];
					if(dp1[pos][j+1]>=MOD) dp1[pos][j+1]-=MOD;
					dp1[pos][0]+=dp1[1-pos][j];
					if(dp1[pos][0]>=MOD) dp1[pos][0]-=MOD;
				}
				for(int j=K/2+1;j<=i+1;j++) dp1[pos][j]=0;
			}
			ll sum=0;
			for(int j=0;j<=len;j++)
			{
				sum+=dp1[pos][j];
				if(sum>=MOD) sum-=MOD;
			}
			ret=ret*sum%MOD;
		}
		printf("%lld\n",ret);
	}
	else
	{
		int pos=0;
		memset(dp,0,sizeof(dp));
		dp[pos][0][0][n]=1;
		for(int i=0;i<n;i++)
		{
			pos=1-pos;
			int even=i/2+1,odd=(i+1)/2;
			for(int j=0;j<=even;j++)
			{
				for(int k=0;k<=odd;k++)
				{
					for(int t=i;t<=n;t++)
					{
						dp[pos][j][k][t]=0;
					}
				}
			}
			for(int j=0;j<=even;j++)
			{
				for(int k=0;k<=odd;k++)
				{
					for(int t=i;t<=n;t++)
					{
						if(dp[1-pos][j][k][t]==0) continue;
						//unset i
						//int to=((t==n||t%2==i%2)?n:t);
						int to=(t%2==i%2?n:t);
						dp[pos][0][j][to]+=dp[1-pos][j][k][t];
						if(dp[pos][0][j][to]>=MOD) dp[pos][0][j][to]-=MOD;
						//set i
						if(t!=i)
						{
							if(j>=K/2+1) to=min(t,i-2*k+K);
							else to=t;
							dp[pos][k+1][j][to]+=dp[1-pos][j][k][t];
							if(dp[pos][k+1][j][to]>=MOD) dp[pos][k+1][j][to]-=MOD;
						}
					}
				}
			}/*
			printf("+ %d\n",i);
			for(int j=0;j<=even;j++)
			{
				for(int k=0;k<=odd;k++)
				{
					for(int t=i;t<=n;t++)
					{
						if(dp[pos][j][k][t]!=0)
						{
							printf("[%d %d %d] %lld\n",j,k,t,dp[pos][j][k][t]);
						}
					}
				}
			}puts("");*/
		}
		ll ret=0;
		for(int j=0;j<=n;j++)
		{
			for(int k=0;k<=n;k++)
			{
				ret+=dp[pos][j][k][n];
				if(ret>=MOD) ret-=MOD;
			}
		}
		printf("%lld\n",ret);
	}
	return 0;
}


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll n,i,ans = 0,k1,k2;
	cin >> n;
	for(i = 1; i <= n ;i++){
		k1 = i;
		k2 = (n/i) * i ;
		k1 = k2/k1;
		ans += i * ((k1 *(k1 + 1))/2);
	}
	cout << ans << nl;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t = 1;
	// cin >> t;
	for(ll i = 1; i <= t; i++){
		doit();
	}
}


Measured memory_bytes: 3596
N = int(input())
P = list(map(int, input().split()))

ans = 0

for i in range(N):
    if P[i] != i+1:
        continue
    if i+1 < N and P[i] != i+2 or i == 0:
        P[i], P[i+1] = P[i+1], P[i]
        ans += 1
    else:
        P[i], P[i-1] = P[i-1], P[i]
        ans += 1

print(ans)

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

int main() {
  int N=0, Si=0, Sj=0, Sk=0, Sl=0;
  string S;
  cin >> N;

  for(int m=0; m<N; m++){
    cin >> S;
    if( S == "P"){
      Si++;
    }
    else if( S == "W"){
      Sj++;
    }
    else if( S == "G"){
      Sk++;
    }
    else {
      Sl++;
    }
  }
  
  if(Si>0 && Sj>0 && Sk>0 && Sl>0){
    cout << "Four" << endl;
  }
  else{
   cout << "Three" << endl;
  } 
}

Measured memory_bytes: 3592
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AServalVsMonster solver = new AServalVsMonster();
        solver.solve(1, in, out);
        out.close();
    }

    static class AServalVsMonster {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int h = s.nextInt();
            int a = s.nextInt();
            if (h % a == 0) {
                out.println(h / a);
            } else {
                out.println(h / a + 1);
            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n;
int d[105];
int ans=1;;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    sort(d,d+n);
    for(int i=0;i<n-1;i++){
        if(d[i]!=d[i+1]) ans++;
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3640
from math import log2

N = int(input())
a = list(map(int, input().split()))

ans = 0

for i in range(len(a)):
    tmp = a[i]
    while a[i]%2 != 1:
        if a[i]%2 == 0:
            ans += 1
            a[i] /= 2
print(ans)


Measured memory_bytes: 4148
#include <bits/stdc++.h>
#define fr(a, b, c) for(int a = b, __ = c; a < __; ++a)
#define dbg(x) cerr << ">>>> " << x << endl;
#define _ << " , " <<

using namespace std;

string dic[4] = {"dream", "dreamer",  "erase", "eraser"};
string str;

const int mv = 1e5 + 10;
int memo[mv], n;

int dp(int p){
	if(p == n)
		return 1;

	if(memo[p] != -1)
		return memo[p];

	int ans = 0;
	fr(i, 0, 4){
		bool can = 1;
		fr(j, 0, dic[i].size()){
			if(p+j >= n || str[p+j] != dic[i][j]){
				can = 0;
			}


			if(!can)
				break;
		}

		if(can)
			ans = max(ans, dp(p+dic[i].size()));
	}

	return memo[p] = ans;
}


int main(){
	ios::sync_with_stdio(0);
	cin >> str;
	n = str.size();

	memset(memo, -1, sizeof memo);
	puts(dp(0) ? "YES" : "NO");
	return 0;
}


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int n; cin >> n;
	vector<int> e(1e5 + 1, 0), o(1e5 + 1, 0);
	REP(i, n) {
		int v; cin >> v;
		if (i % 2) o[v]++;
		else e[v]++;
	}

	int maxE = max_element(e.begin(), e.end()) - e.begin();
	int maxO = max_element(o.begin(), o.end()) - o.begin();
	int res = 0;
	if (maxE != maxO) res = n - e[maxE] - o[maxO];
	else {
		sort(e.rbegin(), e.rend());
		sort(o.rbegin(), o.rend());
		res = min(n - o[0] - o[1], n - e[1] - e[0]);
	}

	cout << res << '\n';
    return 0;
}


Measured memory_bytes: 3972
N,M = map(int, input().split())
List = []
for i in range(N):
    List.append([int(a) for a in input().split()])

ans_list = []

for i in range(2):
    for j in range(2):
        for k in range(2):
            temp_list = [0 for a in range(N)]
            for a in range(N):
                temp_list[a] = (-1)**i*List[a][0] + (-1)**j*List[a][1] + (-1)**k*List[a][2]
            temp_list.sort(reverse=True)
            num = 0
            for b in range(M):
                num += temp_list[b]
            ans_list.append(num)

ans_list.sort()
print(ans_list[-1])

Measured memory_bytes: 41968
n, k=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)

if k>a.max
  puts 'IMPOSSIBLE'
  exit 0
end

a=a.uniq.sort
m=10**10
(a.size-1).times{|i| m=[m, (a[i]-a[i+1]).abs].min}
b=a.map{|e| (e-k).abs}
b.each do |e|
  if e==0
    puts 'POSSIBLE'
    exit 0
  elsif e%m==0
    puts 'POSSIBLE'
    exit 0
  end
end

puts 'IMPOSSIBLE'


Measured memory_bytes: 15756
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vecl = vector<ll>;
using Graph = vector<vector<int>>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, K;
  cin >> N >> K;
  cout << min(N % K, K - N % K) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
#define MOD 1000000007
int main()
{   
    ll H , W ;
    cin >> H >> W ;
    ll N ;
    cin >> N ;

    ll a[N] ;
    for(ll i = 0 ; i < N ; i++){//ok
        cin >> a[i] ;
    }
     
    int now = 0 ;
    int count = 0 ;
    int map[H][W] ;
    for(int j = 0 ; j < H ; j++){
        for(int  k = 0 ; k < W ; k++){
           if(j % 2 == 0){
              map[j][k] = now + 1 ;
              //cout << j << " " << k << endl;
           }else{
              map[j][W-1-k] = now + 1 ;
               //cout << j << " " << W-1-k << endl;
           }
           
           count++ ;//ok
           if(a[now] <= count){
               now++ ;
               count = 0 ;
           }
        }
        
    }


    for(ll j = 0 ; j < H ; j++){
        for(ll k= 0 ; k < W ; k++){
            cout << map[j][k] << " " ;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3504
from collections import deque

def main(N, A):
    # 席順
    l = A[:2]
    # 心地よさ合計
    ans = A[0]

    d = deque([A[1], A[1]])

    for a in A[2:]:
        ans += d.popleft()
        d.extend([a, a])
    print(ans)



if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse = True)
    main(N, A)

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll N;
    cin >> N;
    vec d(N);
    REP(i,0,N) cin >> d[i];

    sort(ALL(d));
    PR(d[N/2]-d[N/2-1]);

    return 0;
}

/*

*/

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

using namespace std;

typedef long long ll;

int main(void) {
    ll N, M;
    cin >> N >> M;
    vector<vector<ll>> xyz(N, vector<ll>(3));
    for (int i = 0; i < N; i++) {
        cin >> xyz[i][0] >> xyz[i][1] >> xyz[i][2];
    }

    vector<ll> a(N);
    ll ans = 0;
    ll t;
    for (int xs : {-1, 1}) {
        for (int ys : {-1, 1}) {
            for (int zs : {-1, 1}) {
                for (int i = 0; i < N; i++) {
                    a[i] = xyz[i][0] * xs + xyz[i][1] * ys + xyz[i][2] * zs;
                }
                sort(a.begin(), a.end(), greater<ll>());
                t = 0;
                for (int i = 0; i < M; i++) {
                    t += a[i];
                }
                ans = max(ans, t);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ctype.h>
using namespace std;
 
 
int main(){
  int a,b,c,ans;
  cin >>a>>b>>c;
  
  if(a==b&&b==c)ans=1;
  else if(a==b||b==c||a==c)ans=2;
  else ans=3;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N,K; cin >> N >> K;
    vector<ll> a(N),b(N);
    for (int i=0;i<N;i++) cin >> a[i];
    ll res = 1e11;
    for (int bit=0;bit<(1<<N);bit++){
        b = a; 
        ll s = 0;
        ll max_h = 0;
        ll num_color = 0;
        for (int i=0;i<N;i++){
            if (!(bit & (1<<i))) {
                if (max_h < b[i]) num_color++;
            }
            else {
                if (max_h >= b[i]) {
                    s += max_h + 1 - b[i];
                    b[i] = max_h + 1;
                }
                num_color++;
            }
            max_h = max(max_h, b[i]);
        }
        if (num_color >= K) res = min(res,s);
    }
    cout << res << endl;
    return 0;
}

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

int main()
{
    string s,t;
    cin>>s>>t;
    int len=t.length();
    for(int i=0;i<len;i++)
    {
        cout<<s[i]<<t[i];
    }
    if(s.length()>len)
        cout<<s[s.length()-1]<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
long long MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll N;
        cin>>N;
        ll count=0;
        vvc G(N,vc(N));
        rep(i,N)rep(j,N)cin>>G[j][i];
        rep(i,N){
            vvc NG(N,vc(N));
            rep(j,N){
                rep(k,N){
                    ll nx=k+i;
                    if(nx>=N)nx-=N;
                    NG[nx][j]=G[k][j];
                }
            }
            bool end=false;
            rep(j,N){
                rep(k,N){
                    if(NG[k][j]!=NG[j][k]){
                        end=true;
                        break;
                    }
                }
                if(end)break;
            }
            if(!end)count++;
        }
        cout<<count*N<<endl;
    }

Measured memory_bytes: 512
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
from re import split
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy
import re

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

x = I()
print(x // 500 * 1000 + x % 500 // 5 * 5)

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

int main()
{
    int n, m, a, b;
    vector<int> l, r;

    cin >> n >> m;

    for(int i = 0; i < m; i++){
        cin >> a >> b;
        l.push_back(a);
        r.push_back(b);
    }

    a = *max_element(l.begin(), l.end());
    b = *min_element(r.begin(), r.end());

    if(a > b) cout << 0 << endl;
    else if(n < a) cout << 0 << endl;
    else cout << b - a + 1 << endl;;

    return 0;
}

Measured memory_bytes: 1276
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int D = sc.nextInt();
    	int N = sc.nextInt();
    	if (N <= 99) {
    		switch (D) {
    		case 0:
    			System.out.println(N);
    			break;
    		case 1:
    			System.out.println(100*N);
    			break;
    		case 2:
    			System.out.println(10000*N);
    			break;
    		}
    	} else {
    		switch (D) {
    		case 0:
    			System.out.println(101);
    			break;
    		case 1:
    			System.out.println(10100);
    			break;
    		case 2:
    			System.out.println(1010000);
    			break;
    		}
    	}
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll n,x;
    cin >> n >> x;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = 0;
    Rep(i,1,n){
        ll t = a[i] + a[i-1] - x;
        if(t > 0){
            ans += t;
            a[i] -= t;
            if(a[i] < 0){
                a[i-1] += a[i];
                a[i] = 0;
            }
        }
    }
    pr(ans);
}

Measured memory_bytes: 1024
from collections import deque

#inp = list(map(lambda x: int(x), input().split()))
#n,k = map(lambda x: int(x), input().split())
#p_n = list(map(lambda x:int(x),input().split()))


s = deque(input())
q = int(input())


cnt = 0
for i in range(q):
    inp = input().split()
    if inp[0] == "1":
        cnt += 1
    else:
        if inp[1] == "1":
            if cnt % 2 == 0:
                s.appendleft(inp[2])
            else:
                s.append(inp[2])
        else:
            if cnt % 2 == 0:
                s.append(inp[2])
            else:
                s.appendleft(inp[2])

ans = list(s)

if cnt % 2 == 1:
    ans = ans[::-1]

print(''.join(ans))




Measured memory_bytes: 10100
def main():
    n,k=map(int,input().split())
    d=set(map(str,input().split()))

    while True:
        s=set(str(n))
        flag=True
        for i in s:
            if i in d:
                flag=False
                break
        if flag:
            break
        else:
            n+=1       
    print(n)               
if __name__=='__main__':
    main()

Measured memory_bytes: 3060