akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder2020Ned
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());

            int joy1 = 0;
            int joy2 = 0;

            while(true)
            {
                if(x <= 499)
                { break; }
                x -= 500;
                joy1++;
            }
            while(true)
            {
                if (x <= 4)
                { break; }
                x -= 5;
                joy2++;
            }
            Console.Write(joy1*1000+joy2*5);
            Console.Read();
        }
    }
}


Measured memory_bytes: 11092
/*

参考にした提出
https://agc023.contest.atcoder.jp/submissions/2435072

*/


#include<cstddef>
#include<cstdint>
#include<cstdio>

using uint64 = std::uint_fast64_t;

constexpr uint64 M = 1000000007;

template<std::size_t N>
struct Fact {
	uint64 val[N], v2[N];
	constexpr Fact() :val(), v2() {
		val[0] = 1;
		for (std::size_t i = 1; i < N; ++i) val[i] = val[i - 1] * i % M;
		for (std::size_t i = 1; i < N; ++i) v2[i] = val[i - 1] * val[i] % M;
		for (std::size_t i = 1; i < N; ++i) val[i] = val[i] * i % M;
	}
};

template<std::size_t N, uint64 F>
struct IFact {
	uint64 val[N];
	constexpr IFact() : val() {
		val[N - 1] = F;
		for (std::size_t i = N - 1; i; --i) val[i - 1] = val[i] * i % M;
	}
};

constexpr auto fact = Fact<1000000>();
constexpr auto ifact = IFact<1000000, 498215386>();

int main() {
	unsigned int n;
	uint64 ans=0;
	scanf("%u", &n);
	const std::size_t N = n;
	for (std::size_t i = (N + 1) >> 1; i < N - 1; ++i) {
		ans += fact.v2[i] * ifact.val[(i << 1) - N] % M;
	}
	ans %= M;
	long long unsigned int o = fact.val[N - 1] < ans ? fact.val[N - 1] + M - ans : fact.val[N - 1] - ans;
	printf("%llu\n", o);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define im 2147483647
#define lm 9223372036854775807
#define ll long long
#define ii pair<int, int>
#define debug(index, num) cerr << "Case #" << index << ": " << num << endl
#define be(x) x.begin(), x.end()
#define rbe(x) x.rbegin(), x.rend()
#define pb push_back
const ll MOD = 1000000007;
int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    vector<vector<char>> g(n+2, vector<char> (m+2, '#'));
    vector<vector<ll>> dp(n+2, vector<ll> (m+2, 0));
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            cin >> g[i][j];
        }
    }
    dp[1][1] = 1;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(g[i][j] == '#') dp[i][j] = 0;
            else dp[i][j] += dp[i-1][j] + dp[i][j-1];
            if(dp[i][j] >= MOD) dp[i][j] -= MOD;
        }
    }
    cout << dp[n][m];
}

Measured memory_bytes: 9216
#include<iostream>
#include<utility>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<int> P(N);
	vector<pair<pair<string, int>,int>> SP(N);
	vector<string> S(N);
	for (int i = 0; i < N; i++){
		cin >> S[i] >> P[i];
		SP[i]=make_pair(make_pair(S[i], -P[i]),i+1);
	}
	sort(SP.begin(), SP.end());
	for (int i = 0; i < N; i++){
		cout << SP[i].second << endl;
	}
	return 0;
}

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

ll go(vector<int> const &v){
	ll an = 0, sml = v[0], smr = 0, csm, smr2 = 0;
	f(i, 1, v.size())smr += v[i];
	smr2 = smr;
	csm = smr;
	an = csm;
	f(i, 1, v.size() - 1){
		int nv = (i + 1 << 1) - 1;
		if (nv > (int)v.size())break;
		csm += sml << 1;
		sml += v[i];
		csm -= v[i];
		smr -= v[i];
		if (nv > 1)smr2 -= v[nv - 2];
		csm -= smr - smr2 << 1;
		smr2 -= v[nv - 1];
		csm += smr2 << 1;
		an = max(an, csm);
	}
	sml = v[0], smr = 0;
	f(i, 1, v.size())smr += v[i];
	smr2 = smr - v[1];
	csm = sml + (smr - v[1] << 1);
	an = max(an, csm);
	f(i, 1, v.size() - 1){
		int nv = i + 1 << 1;
		if (nv > (int)v.size())break;
		csm += sml << 1;
		sml += v[i];
		csm += v[i];
		smr -= v[i];
		if (nv > 1)smr2 -= v[nv - 2];
		csm -= smr - smr2 << 1;
		smr2 -= v[nv - 1];
		csm += smr2 << 1;
		an = max(an, csm);
	}
	return an;
}

int main(){
	int l, n;
	scanf("%d%d", &l, &n);
	vector<int> v(n + 1);
	int bf = 0;
	f(i, 0, n){
		int t;
		scanf("%d", &t);
		v[i] = t - bf;
		bf = t;
	}
	v[n] = l - bf;
	ll an = go(v);
	reverse(v.begin(), v.end());
	an = max(an, go(v));
	printf("%lld\n", an);
}

Measured memory_bytes: 1024
package main

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

const (
	bufsiz = 1024 * 1024
)

func main() {
	writer := newWriter(os.Stdout)
	defer writer.Flush()

	sc := newScanner(os.Stdin)
	n := sc.scanInt()

	sides := make([]int, n)

	for i := 0; i < n; i++ {
		sides[i] = sc.scanInt()
	}

	sort.Ints(sides)

	sum := 0

	for i, v := range sides {
		if i == n-1 {
			break
		}

		sum += v
	}

	if sides[n-1] < sum {
		writer.println("Yes")
	} else {
		writer.println("No")
	}
}

func mapContains(m map[int]int, sum int) map[int]int {
	for key, value := range m {
		if value == sum {
			delete(m, key)
		}
	}

	return m
}

// contains returns:
// if s contains e, true. / if s not contains e, false.
func sliceContains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

type scanner struct {
	*bufio.Scanner
}

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &scanner{s}
}

func (s *scanner) scanStr() string {
	s.Buffer(make([]byte, bufsiz), bufsiz)
	if !s.Scan() {
		panic("scan failed")
	}
	return s.Text()
}

func (s *scanner) scanInt() int {
	if !s.Scan() {
		panic("scan failed")
	}
	i, err := strconv.Atoi(s.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func (s *scanner) scanFloat() float64 {
	if !s.Scan() {
		panic("scan failed")
	}
	i, err := strconv.ParseFloat(s.Text(), 5)
	if err != nil {
		panic(err)
	}
	return i
}

type writer struct {
	*bufio.Writer
}

func newWriter(wr io.Writer) *writer {
	w := bufio.NewWriter(wr)
	return &writer{w}
}

func (w *writer) printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(w, f, args...)
}

func (w *writer) println(args ...interface{}) (int, error) {
	return fmt.Fprintln(w, args...)
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll k;
priority_queue< ll ,vector<ll>,greater<ll>> pq;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>k;
	rep(i,9){
		pq.push(i+1);
	}
	ll ans = 0;
	rep(i,k){
		ll top = pq.top();
		if(i==k-1){
			ans = top;
			break;
		}
		pq.pop();
		ll tp = top%10;
		ll mi = tp-1;
		ll pl = tp+1;
		pq.push(top*10+tp);
		if(pl<10)pq.push(top*10+pl);
		if(mi>=0)pq.push(top*10+mi);
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 5296
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n;
  cin >> n;
  vector<ll> a(n), cp(n);
  map<ll, ll> mp;
  for(ll i = 0; i < n; i++){
    cin >> a[i]; 
    cp[i] = a[i];
    mp[a[i]]++;
  }
  sort(all(cp));
  cp.erase(unique(all(cp)), cp.end());

  ll sum = 0;
  for(ll i = 0; i < cp.size(); i++){
    sum += mp[cp[i]]*(mp[cp[i]]-1)/2;
  }
  
  for(ll i = 0; i < n; i++){
    sum -= mp[a[i]]*(mp[a[i]]-1)/2;
    sum += (mp[a[i]]-1)*(mp[a[i]]-2)/2;
    cout << sum << endl;
    sum -= (mp[a[i]]-1)*(mp[a[i]]-2)/2;
    sum += mp[a[i]]*(mp[a[i]]-1)/2;
  }
  return 0;
}

Measured memory_bytes: 12672
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace sort3
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] str = Console.ReadLine().Split(' ');
            int[] a = new int[3];
            for (int i = 0; i < str.Length; i++)
            {
                a[i] = int.Parse(str[i]);
            }
            sort(ref a[0], ref a[1]);
            sort(ref a[1], ref a[2]);
            sort(ref a[0], ref a[1]);


            Console.WriteLine("{0} {1} {2}", a[0], a[1], a[2]);
        }
        static void sort(ref int first, ref int second)
        {
            if (first > second)
            {
                int t = first;
                first = second;
                second = t;
            }

        }
    }
}

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

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

int main(){
    int D,out=0;
    cin >> D;
    int c[26],s[D][26],t[D],l[26]={};
    for(int i=0;i<26;i++) cin >> c[i];
    for(int i=0;i<D;i++){
        for(int j=0;j<26;j++) cin >> s[i][j];
    }
    for(int i=0;i<D;i++){
        cout << (i % 26) + 1 << endl;
    }

    /* for(int i=0;i<D;i++) cin >> t[i];
    for(int i=0;i<D;i++){
        l[t[i]-1] = i+1;
        out += s[i][t[i]-1];
        for(int j=0;j<26;j++){
            out -= c[j] * (i + 1 - l[j]);
        }
        cout << out << endl;
    }
    */
}

Measured memory_bytes: 3676
N = int(input())
a = [int(x) for x in input().split()]

c = {0: 0, 2: 0, 4: 0}
for ai in a:
    if ai % 4 == 0:
        c[4] += 1
    elif ai % 2 == 0:
        c[2] += 1
    else:
        c[0] += 1

if c[0] <= c[4]:
    print('Yes')
elif c[0] + c[2] <= c[4] + 1:
    print('Yes')
else:
    print('No')

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

const int maxn=1e5+10;
int n,m,fa[maxn],pos[maxn];

int findfa(int x){
	if(fa[x]==x)return x;
	int f=findfa(fa[x]);
	pos[x]=pos[x]+pos[fa[x]];
	fa[x]=f;
	return f;
}

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		fa[i]=i;
	for(int i=1,l,r,d;i<=m;++i){
		cin>>l>>r>>d;
		if(findfa(l)==findfa(r)){
			if(pos[l]+d!=pos[r]){
				puts("No");
				return 0;
			}
		}
		else{
			int x=findfa(l),y=findfa(r);
			fa[y]=x;
			pos[y]=pos[l]+d-pos[r];
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1024
n,k = list(map(int, input().split(" ")))
#a = list(map(int, input().split(" ")))
a = []
for i, a_i in enumerate(input().split(" ")):
    a_i = int(a_i)
    a.append(a_i)
    if i<k:
        continue
    #print(a[i-k], a_i)
    if a[i-k] < a_i:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 31872
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int N, Q;
	while (cin >> N >> Q && N && Q) {
		vector<int> date(101, 0);
		for (int i=0; i<N; ++i) {
			int M, d;
			cin >> M;
			for (int j=0; j<M; ++j) {
				cin >> d;
				date[d] ++;
			}
		}
		int k = max_element(date.begin(), date.end()) - date.begin();
		cout << (Q <= date[k] ? k : 0) << endl;
	}

	return 0;
}

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

int main(){
  string s;
  cin>>s;
  string t;
  cin>>t;
  string p;
  p=t.erase(s.size());
  if(s==p){
    cout<<"Yes"<<endl;
  }
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include <cstdio>

int main()
{
  char ch = ' ';
  int cnt = 0;
  while (ch != '\n') {
    ch = getchar();
    if (ch == 'x') {
      cnt++;
    }
  }
  if (8 <= cnt) {
    puts("NO");
  } else {
    puts("YES");
  }
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  int ans = n + 1;
  int r = 0, sum = 0;
  for (int l = 0; l < n; ++l) {
    while (r < n && sum < s) {
      sum += a[r];
      r++;
    }
    if (sum < s) break;
    ans = min(ans, r - l);
    if (l == r)
      r++;
    else
      sum -= a[l];
  }
  if (n < ans) ans = 0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3144
def alf(st):
  if st == 0:
    return "a"
  if st == 1:
    return "b"
  if st == 2:
    return "c"
  if st == 3:
    return "d"
  if st == 4:
    return "e"
  if st == 5:
    return "f"
  if st == 6:
    return "g"
  if st == 7:
    return "h"
  if st == 8:
    return "i"
  if st == 9:
    return "j"
  if st == 10:
    return "k"
  if st == 11:
    return "l"
  if st == 12:
    return "m"
  if st == 13:
    return "n"
  if st == 14:
    return "o"
  if st == 15:
    return "p"
  if st == 16:
    return "q"
  if st == 17:
    return "r"
  if st == 18:
    return "s"
  if st == 19:
    return "t"
  if st == 20:
    return "u"
  if st == 21:
    return "v"
  if st == 22:
    return "w"
  if st == 23:
    return "x"
  if st == 24:
    return "y"
  if st == 25:
    return "z"
   
def cc():
  N,=list(map(int, input().split()))
  li = [0 for i in range(100)]
  NN = N
  count=1
  for i in range(1,100):
    if NN > 26 ** i:
      NN = NN - 26 ** i
    else:
      l=i
      break; 
  NN-=1
  count=0
  while True:
    li[count]=NN%26
    count+=1
    NN //=26
    if NN <26:
      li[count]=NN%26
      break    
  re=[alf(i) for i in li[:l]]
  re.reverse()
  print("".join(re))

cc()

Measured memory_bytes: 9280
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false; cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, c;
vector<array<lli, 2>> v;
array<vector<lli>, 4> a;
int main() {
  cin >> n >> c;
  v = decltype(v)(n+1);
  v[0][0] = 0; v[0][1] = 0;
  for (lli i=1; i<=n; ++i) { cin >> v[i][0] >> v[i][1]; }
  sort(begin(v), end(v), [](auto&& x, auto&& y) { return x[0] < y[0]; });
  for (lli i=0; i<4; ++i) a[i] = vector<lli>(n + 2);
  for (lli i=0; i<4; ++i) { a[i][0] = a[i][n+1] = 0; }
  lli cal=0;
  for (lli i=1; i<=n; ++i) {
    cal += v[i][1];
    a[0][i] = max(a[0][i-1], cal - v[i][0]);
    a[1][i] = max(a[1][i-1], cal - 2 * v[i][0]);
  }
  cal = 0;
  for (lli i=n; i>0; --i) {
    cal += v[i][1];
    lli dist = c - v[i][0];
    a[2][i] = max(a[2][i+1], cal - dist);
    a[3][i] = max(a[3][i+1], cal - 2 * dist);
  }
  lli ans = max(a[0][n], a[2][1]);
  for (lli i=1; i<=n; ++i) {
    lli s, t;
    s = a[1][i] + a[2][i+1];
    t = a[3][i] + a[0][i-1];
    ans = max({ans, s, t});
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

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

const int maxn = 1e5 + 5;

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    map<int, int> mp;
    int a, b;
    REP(i, n) {
        scanf("%d", &a);
        mp[a]++;
    }
    REP(i, m) {
        scanf("%d%d", &a, &b);
        mp[b] += a;
    }
    vector<pii> v;
    for (auto& p : mp) {
        // clog << p.first << " " << p.second << endl;
        v.push_back(MP(p.first, p.second));
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    ll ans = 0, cnt = n;
    for (auto& p : v) {
        // clog << p.first << " " << p.second << endl;
        if (cnt > p.second) {
            ans += 1LL * p.first * p.second;
            cnt -= p.second;
        } else {
            ans += 1LL * p.first * cnt;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int a[3][3];
  for(int i = 0; i < 3; ++i)
    for(int j = 0; j < 3; ++j)
      cin >> a[i][j];
  bool f = true;
  for(int i = 0; i < 2; ++i){
    f &= a[i][0] - a[i+1][0] == a[i][1] - a[i+1][1];
    f &= a[i][0] - a[i+1][0] == a[i][2] - a[i+1][2];
  }
  cout << (f ? "Yes" : "No") << endl;
}














Measured memory_bytes: 3584
// C++ program to print words in a sentence 
#include <bits/stdc++.h> 
using namespace std; 




int main() 
{ 
	string str;
	
	cin>>str;
	for(int i=0; i<str.length(); i++) str[i] = tolower(str[i]);
	int c = 0;
	
	while(true){
	    string sen;
	    getline(cin,sen);
	    
	    if(sen=="END_OF_TEXT") break;
	    
	    stringstream ss(sen);
	    do{
	        string word;
	        ss >> word;
	        for(int i=0; i<word.length(); i++) word[i] = (tolower(word[i]));
	        if(word == str) c ++;
	    }while(ss);
	    
	}
	cout<<c<<endl;
	return 0; 
} 



Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 5005;

int dp1[N][N], dp2[N][N];
int a[N];

signed main()
{
	IO_OP;
	
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	dp1[0][0] = 1;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= k; j++) {
			dp1[i][j] = dp1[i - 1][j];
			if(j - a[i] >= 0 && dp1[i - 1][j - a[i]]) dp1[i][j] = 1;
		}
	}
	dp2[n + 1][0] = 1;
	for(int i = n; i >= 1; i--) {
		for(int j = 0; j <= k; j++) {
			dp2[i][j] = dp2[i + 1][j];
			if(j - a[i] >= 0 && dp2[i + 1][j - a[i]]) dp2[i][j] = 1;
		}
	}
	for(int i = 1; i <= n + 1; i++) {
		for(int j = 1; j <= k; j++)
			dp2[i][j] += dp2[i][j - 1];
	}
	int cnt = 0;
	for(int i = 1; i <= n; i++) {
		// want [k - a[i], k)
		int l = k - a[i], r = k - 1;
		bool yes = false;
		for(int j = 0; j <= k; j++) {
			if(dp1[i - 1][j] == 0) continue;
			int wl = max(l - j, 0);
			int wr = r - j;
			if(wr < 0) continue;
			if(dp2[i+1][wr] - (wl ? dp2[i+1][wl-1] : 0)) yes = true;
		}
		if(!yes) cnt++;
	}
	cout << cnt << endl;
	
}





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

int main(){
  	string s;
  	cin >> s;
  	int counter=0;
  	if(s[0] == 'o') counter++;
  	if(s[1] == 'o') counter++;
  	if(s[2] == 'o') counter++;
  	cout << 700+counter*100 << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A & a, const B & b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A & a, const B & b) { a = max(a, (A)b); };


int main() {
	ll N,K;
	cin >> N>>K;
	vector<pair<ll, ll>> V(N);
	REP(i, 0, N)cin >> V[i].first >> V[i].second;
	auto cmp = [](pair<ll, ll>a, pair<ll, ll>b) {
		return a.second > b.second;
	};
	sort(V.begin(), V.end(),cmp);
	unordered_set<ll> used;
	priority_queue<ll, vector<ll>, greater<ll>> q;
	ll sum = 0;
	ll ans = 0;
	REP(i, 0, K) {
		if (used.count(V[i].first) > 0) q.push(V[i].second);
		else used.insert(V[i].first);
		sum += V[i].second;
	}
	ans = sum + used.size() * used.size();
	REP(i, K, N) {
		if (q.empty())break;
		if (used.count(V[i].first) > 0) continue;
		else used.insert(V[i].first);
		sum -= q.top();
		q.pop();
		sum += V[i].second;
		maxs(ans, sum + used.size() * used.size());
	}
	PRI(ans);
	return 0;
}

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

using namespace std;

long long minn(long long a, long long b){
    if(a >= b) return b;
    else return a;
}
void Solve(){
    long long n, k;
    cin>>n>>k;
    if(k == 1){
        cout<<0<<endl;
        return;
    }
    long long res = n % k;
    res = minn(res, k - res);
    cout<<res<<endl;
}
int main(){
    int q = 1;
    while(q--){
        Solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

const int mx=100010;
const ll mod=1e9+7;

vector<vector<ll>> dp(100010, vector<ll>(15,0)); //[keta][mod]
string s;
int d;

int main(){
  cin >> s;
  d = s.size();
  dp[0][0]=1;										//上から-1桁まで(初期条件)
  for(int i=0; i<d; i++){ rep(j,13){
    if(s[i]=='?'){ 									//数字を決めれる場合
      rep(k,10){
        dp[i+1][(j*10+k)%13] += dp[i][j];
        dp[i+1][(j*10+k)%13] %= mod;
      }
    } else {										//数字が固定の場合
      dp[i+1][(j*10+(s[i]-'0'))%13] += dp[i][j];
      dp[i+1][(j*10+(s[i]-'0'))%13] %= mod;
    }
  }}

  cout << dp[d][5] << endl;			//上からd-1桁(0桁目から数えるのでつまりs全部)、mod5のもの
  return 0;  
}

Measured memory_bytes: 15360
#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 main(){
    int N; Int M; cin >> N >> M;

    vector<Int> A(100010), sum(100010, 0);
    map<Int, Int> rem_count; rem_count[0]++;
    rep1(i, N){
        cin >> A[i];
        sum[i] = sum[i-1] + A[i]; sum[i] %= M;
        rem_count[sum[i]]++;
    }

    Int ans = 0;
    for(pair<Int,Int> p : rem_count){
        ans += p.second * (p.second-1) / 2;
    }
    cout << ans << endl;
}

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

int main() {
  while (1)
  {
    int h, w;
    cin >> h >> w;

    for (int i = h; i > 0; i--)
    {
      for (int j = w; j > 0; j--)
      {
        if (i == 1 || i == h || j == 1 || j == w)
        {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }

    if (h == 0 && w == 0)
    {
      break;
    }

    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3116
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

x = INT()

print("ABC" if x <= 1199 else "ARC")


Measured memory_bytes: 3892
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll A, B, C;
    cin >> A >> B >> C;
    if(A <= B){
        for(ll i = A; i <= B; i++){
            if(i == C){
                cout << "Yes";
                return 0;
            }
        }
    }else{
        for(ll i = A; i >= B; i--){
            if(i == C){
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <set>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)

typedef long double db;
const int N=200005;

std:: set <db> set;

int a[N],prt1,prt2;
db fac[N],ans=-1;

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):(v),ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

void upd(int n,int m) {
	if (n<m) return ;
	if (m==0) {
		if (fac[1]>ans) {
			ans=fac[1];
			prt1=n,prt2=m;
		}
		return ;
	}
	if (fac[n]-fac[m]-fac[n-m]>ans) {
		ans=fac[n]-fac[m]-fac[n-m];
		prt1=n,prt2=m;
	}
}

void solve(int x) {
	db tmp=0.5*x;
	int wjp=-1,lxf=-1;
	set.insert(tmp);
	std:: set <db>:: iterator pos=set.find(tmp);
	if (pos!=set.begin()) {
		pos--; wjp=*pos; pos++;
	}
	pos++;
	if (pos!=set.end()) lxf=*pos;
	pos--;
	if (wjp>=0) upd(x,wjp);
	if (lxf>=0) upd(x,lxf);
	set.erase(pos);
}

int main(void) {
	// rep(i,1,N-1) fac[i]=fac[i-1]+log(i);
	int n=read();
	db mn=1000000000;
	rep(i,1,n) a[i]=read();
	std:: sort(a+1,a+n+1);
	rep(i,1,n-1) {
		if (fabs(a[i]-0.5*a[n])<mn) {
			mn=fabs(a[i]-0.5*a[n]);
			prt1=i;
		}
	}
/*	rep(i,1,n) {
		solve(a[i]);
		set.insert(a[i]);
	}
	printf("%d %d\n", prt1,prt2);*/
	printf("%d %d\n", a[n],a[prt1]);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
    STR(S);
    int ans1 = 0;
    int ans2 = 0;

    for(int i = 0; i < S.size(); ++i){
        if(i%2 != S[i] - '0'){
            ans1++;
        } else {
            ans2++;
        }
    }
    cout << min(ans1,ans2) << endl;
    
}

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

int main()
{
	string sr[200];
	int n,m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> sr[i];
	sort(sr, sr + n);
	for (int i = 0; i < n; i++)
		cout << sr[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
an, bn = [list(map(int, input().split())) for i in [0, 1]]
m = 0
for i in range(n):
    c = min(an[i], bn[i])
    m += c
    an[i] -= c
    bn[i] -= c
    n = min(an[i+1], bn[i])
    m += n
    an[i+1] -= n
    bn[i] -= n
print(m)

Measured memory_bytes: 19156
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,M = map(int, readline().split())
    H = [int(i) for i in readline().split()]
    ab = map(int, read().split())

    E = [0] * N
    for i, (a, b) in enumerate(zip(*[iter(ab)]*2)):
        if H[b-1] > E[a-1]:
            E[a-1] = H[b-1]
        if H[a-1] > E[b-1]:
            E[b-1] = H[a-1]

    ans = 0
    for i,h in enumerate(H):
        if h > E[i]:
            ans += 1
    
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 30268
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
	int c;
	while (b) {
		c = a % b;
		a = b;
		b = c;
	}
	return a;
}
int main() 
{
	int a, b, c;
	
	scanf("%d%d%d", &a, &b, &c);
	if (c % gcd(a, b)) {
		puts("NO"); 
	} else {
		puts("YES");
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){

  int d, S=0, i;

  while(scanf("%d", &d)!= EOF){

    
    S=0;
    for(i=0; d*i<=(600-d);i++){

      S += (i*d)*(i*d)*d;

    }
    
    printf("%d\n", S);
  }




  return 0;

}

Measured memory_bytes: 0
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    c = collections.Counter(s)

    return 700 + c['o'] * 100



print(main())



Measured memory_bytes: 5584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String result = "No";

		for(int i = 0; i < 26; i++) {
			if(4 * i > N) {
				break;
			}else if((N - 4 * i) % 7 == 0) {
				result = "Yes";
				break;
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 23636
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

int N,M,A[1000],i,j,k;

double R;

int main()
{
cin>> R;

R*=2.*3.14159265;

printf("%lf",R);





}

Measured memory_bytes: 3756
//ABC156 B
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
using namespace std;

int main()
{
    int n;
    vector<double> x;
    cin>>n;
    for(int i=0;i<n;i++){
        int input=0;
        cin>>input;
        x.push_back(input);
    }
    double avg=0;
    for(int i=0;i<n;i++){
        avg+=x[i]/(double)(n);
    }
    int p=round(avg);
    int score=0;
    for(int i=0;i<n;i++){
        score+=(x[i]-p)*(x[i]-p);
    }
    cout<<score;
    /*
    int p1=floor(avg);
    int score1=0;
    for(int i=0;i<n;i++){
        score1+=(i-p1)*(i-p1);
    }
    
    cout<<"\n";
    cout<<p;
    cout<<"\n";
    cout<<p1;
    cout<<"\n";
    cout<<min(score,score1);*/
    return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())
L = []
def AA(A): return [".#" * min(A, 50) + "##" * (50-min(A, 50)), "##" * 50]
def BB(B):  return [".." * 50, "#." * min(B, 50) + ".." * (50-min(B, 50))]
L += AA(max(0, A-1))
A -= 51
while A > 0:
    L += AA(A)
    A -= 50
L += BB(max(0, B-1))
B -= 51
while B > 0:
    L += BB(B)
    B -= 50
print(len(L), 100)
print(*L, sep="\n")

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

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

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

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

template <typename T>
struct fenwick_tree {
    int n, power; // min power s.t. n <= power && power = 2^k;
    vector<T> data;
    fenwick_tree(int n=0) : n(n), data(n+1) {
        power = 1;
        while (power < n) power <<= 1;
    }
    void add(int i, T x=1) {
        for (i++; i <= n; i += i&-i) data[i] += x;
    }
    // [0, i)
    T sum(int i) {
        T res = 0;
        for (; i; i -= i&-i) res += data[i];
        return res;
    }
    // [l, r)
    T sum(int l, int r) { return sum(r) - sum(l);}
    // min x s.t. v0 + v1 + v2 + ... + vx　>= w
    int lower_bound(T w) {
        if (w <= 0) return 0;
        int x = 0;
        for (int i = power; i; i >>= 1) {
            if (i+x <= n && data[i+x] < w) {
                w -= data[i+x];
                x += i;
            }
        }
        return x;
    }
};

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

    fenwick_tree<int> ft(n);

    int cnt = 0;
    int zero = 0;
    int inv = 0;

    rep(i, k) {
        inv += ft.sum(a[i] + 1, n);
        ft.add(a[i]);
    }
    if (inv > 0) {
        cnt++;
    } else {
        zero++;
    }
    for (int i = 0; i+k < n; ++i) {
        bool change = false;
        if (ft.sum(a[i]) != 0) change = true;
        inv -= ft.sum(a[i]);
        ft.add(a[i], -1);
        if (ft.sum(a[i+k] + 1, n) != 0) change = true;
        inv += ft.sum(a[i+k] + 1, n);
        ft.add(a[i+k]);
        if (inv == 0) zero++;
        else if (change) cnt++;
    }
    int ans = cnt + (zero > 0);
    cout << ans << '\n';
}


Measured memory_bytes: 4840
#include <iostream>

using namespace std;

int N, a[100];
bool memo[100010], visited[100010];

bool rec(int K) {
    if (visited[K]) return memo[K];

    visited[K] = true;
    memo[K] = false;

    for (int i = 0; i < N; ++i) {
        if (a[i] > K) break;
        if (!rec(K - a[i])) {
            memo[K] = true;
            break;
        }
    }

    return memo[K];
}

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

    cout << (rec(K) ? "First" : "Second") << endl;
    return 0;
}


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

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

    for(int i=1;i<=10000;i++){
        int t1,t2;
        t1=i*0.08;
        t2=i*0.1;

        if(t1==A&&t2==B){
            cout<<i<<endl;
            return 0;
        }
    }

    cout<<"-1"<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.lang.String.format
import java.util.*
import kotlin.math.*
import kotlin.system.exitProcess
 
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of ints
fun main(){
    val reader=Scanner(System.`in`)
    var a=readLn()
    for(i in 0 until a.length){
        if(a[i]=='?'){
            print('D')
        }
        else{
            print(a[i])
        }
    }
}

Measured memory_bytes: 59848
#include <stdio.h>
#include <string.h>
int main(){
  int N,i,j,min,flag;
  char C[36][3],T[3],D[36][3];
  scanf("%d",&N);
  for(i = 0; i < N; i++){
    scanf("%s",C[i]);
    strcpy(D[i],C[i]);
  }
  for(i = 0; i < N; i++){
    for(j = N-1; j >= i+1; j--){
      if((C[j][1] - '0') < (C[j-1][1] -'0')){
        strcpy(T,C[j]);
        strcpy(C[j],C[j-1]);
        strcpy(C[j-1],T);
      }
    }
  }
for(i = 0; i < N-1; i++){
    printf("%s ",C[i]);
  }
  printf("%s\n",C[i]);
  printf("Stable\n");

  for(i = 0; i < N; i++){
    min = i;
    for(j = i; j < N; j++){
      if((D[j][1] - '0') < (D[min][1] - '0')){
        min = j;
      }
  }
    strcpy(T,D[i]);
    strcpy(D[i],D[min]);
    strcpy(D[min],T);
  }
    for(i = 0; i < N-1; i++){
      printf("%s ",D[i]);
    }
    printf("%s\n",D[i]);
    flag = 1;
for(i = 0; i < N; i++){
      if(strcmp(C[i],D[i]) != 0) flag = 0;
    }
    if(flag)printf("Stable\n");
    else printf("Not stable\n");
    return 0;
}

Measured memory_bytes: 620
import Control.Monad
import Control.Applicative
import Data.List
import Data.Array
strToInt s = (read :: String -> Int) s

main = do
   s <- getLine
   
   let h = head s
   let l = last s
   let n = show ( (length s) - 2 )
   putStrLn $ [h] ++ n ++ [l]

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

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int x; cin >> x;
	int sum = 0, cur = 0;
	while (sum<x) {
		cur++;
		sum += cur;
	}
	cout << cur;
}

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

def cost_calc(list_x, p):
  cost = 0
  for x in list_x:
    cost += (x - p)**2
  return cost

cost = 10**20
for _ in range(min(list_x),max(list_x)+1):
  tmp = cost_calc(list_x, _)
  if tmp < cost:
    cost = tmp
print(cost)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)

signed main() {
  ll x,k,d; cin >> x >> k >> d;
  x = abs(x);

  if ( (k < x / d) || (d < x / k) ) {
    cout << x - k * d << endl;
    return 0;
  }

  k -= x / d;
  x %= d;
  if(k%2) cout << d-x << endl;
  else cout << x << endl;
}


Measured memory_bytes: 3636
import numpy as np
N, M = map(int, input().split())

A = []
B = []
for _ in range(N):
    tmp = input()
    tmp = tmp.replace("#", "1")
    tmp = tmp.replace(".", "2")
    tmp = [int(i) for i in tmp]
    A.append(tmp)

for _ in range(M):
    tmp = input()
    tmp = tmp.replace("#", "1")
    tmp = tmp.replace(".", "2")
    tmp = [int(i) for i in tmp]
    B.append(tmp)

A = np.array(A)
B = np.array(B)

ans = 0
for i in range(N-M+1):
    for j in range(N-M+1):
        if np.all(A[i:i+M, j:j+M] == B):
           ans = 1

if ans == 1:
    print("Yes")
else:       
    print("No")



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

int main(){
  int n;
  const long long k=1000000000000000000;
  cin >> n;
  vector<long long> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  long long ans=1;
  for(long long i=0;i<n;i++){
    if(ans==0) break;
    else if(k/ans<a.at(i)){
      ans=-1;
      break;
    }
    ans*=a.at(i);
  }
  cout << ans << endl;  
  return 0;
}  


Measured memory_bytes: 4052
#include <stdio.h>          // printf(), fprintf(), scanf()
#include <stdlib.h>         // exit()
#include <string.h>         // strlen(), strcpy()

#define QUE_SIZE 100000
#define L_STRINGS (11 * 100000)

typedef struct que_tbl
{
	const char* name;
	int time;
} que_t;

int que_in;
int que_out;
que_t queue[QUE_SIZE];
char strings[L_STRINGS];
int ix;

void
cleanup(int ecode)
{
	exit(ecode);
}

int
que_size()
{
	if (que_in >= que_out)
		return que_in - que_out;

	return que_in + QUE_SIZE - que_out;
}

void
que_pop()
{
	if (que_out != que_in)
	{
		que_out++;
		if (que_out >= QUE_SIZE)
			que_out = 0;
	}
}

int
main(int argc, char** argv)
{
	char name[11];
	int time;
	int q;
	int n;
	int i, j;
	int t;

	ix = 0;
	que_in = 0;
	que_out = 0;

	scanf("%d %d", &n, &q);
	for (i = 0; i < n; ++i)
	{
		scanf("%s %d", name, &t);
		queue[que_in].name = &strings[ix];
		queue[que_in].time = t;
		que_in++;
		if (que_in >= QUE_SIZE)
			que_in = 0;

		strcpy(&strings[ix], name);
		ix += strlen(name) + 1;
	}

	time = 0;
	while (que_size() != 0)
	{
		j = que_out; que_pop();
		if (queue[j].time <= q)
		{
			time += queue[j].time;
			printf("%s %d\n", queue[j].name, time);
		}
		else
		{
			queue[que_in].name = queue[j].name;
			queue[que_in].time = queue[j].time - q;
			que_in++;
			if (que_in >= QUE_SIZE)
				que_in = 0;

			time += q;
		}
	}

	return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int a, b, c, k;
  cin >> a >> b >> c >> k;

  if (a + b >= k) {
    cout << min(a, k) << '\n';
  } else {
    k -= a + b;
    cout << a - k << '\n';
  }
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<cstring>
#include<vector>

using namespace std;

typedef long long ll;

int main(){
  int n,cnt=0,ans=0;
  vector<int>num;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    num.push_back(a);
  }

  sort(num.begin(),num.end());

  for(int i=0;i<n;i++){
    cnt++;
    if(i==n-1||num[i]!=num[i+1]){
      ans=ans+(cnt%2);
      cnt=0;
    }
  }
  printf("%d\n",ans);
  
  return 0;
}


Measured memory_bytes: 892
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ice[];
		int n;
		
		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			
			ice = new int[10];
			for (int i = 0; i < n; i++) {
				ice[sc.nextInt()]++;
			}
			for (int i = 0; i < 10; i++) {
				if (ice[i] == 0) {
					System.out.print("-");
				} else {
					for (int j = 0; j < ice[i]; j++) {
						System.out.print("*");
					}
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 54016