akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==================================================================
    public void solve() {
    	char[] S = nc();
    	int A = Integer.valueOf(String.valueOf(S[0]));
    	int B = Integer.valueOf(String.valueOf(S[1]));
    	int C = Integer.valueOf(String.valueOf(S[2]));
    	int D = Integer.valueOf(String.valueOf(S[3]));
    	int wk;
    	for (int i = 0; i < 2; i++) {
    		for (int j = 0; j < 2; j++) {
				for (int j2 = 0; j2 < 2; j2++) {
					wk = A;
					if(i == 0)	wk += B;
					else		wk -= B;
					if(j == 0)	wk += C;
					else		wk -= C;
					if(j2 == 0)	wk += D;
					else		wk -= D;
					if(wk == 7) {
						out.println(A + (i==0?"+":"-") 
								+ B + (j==0?"+":"-")
								+ C + (j2==0?"+":"-")
								+ D + "=7");
						return;
					}
				}
			}
		}
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return Integer.parseInt(sc.next());
    }
    public long nl() {
    	return Long.parseLong(sc.next());
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] ndii(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 23892
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll s,w;
    std::cin >> s>>w;
    
    if(w>=s){
        std::cout << "unsafe" << std::endl;
    }else{
        std::cout << "safe" << std::endl;
    }
}



Measured memory_bytes: 3636
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k;
  int a[10000][10],m,n;
  int r,s,t;
  while(cin>>n>>m&&n+m){
    for(i=0;i<n;i++)
      for(j=0;j<m;j++)
	cin>>a[j][i];
    r=0;
    for(i=0;i<(1<<(n-1));i++){
      s=0;
      for(j=0;j<m;j++){
	t=0;
	for(k=0;k<n;k++)
	  t+=(a[j][k]+!!(i&(1<<k)))&1;
	s+=max(t,n-t);
      }
      r=max(r,s);
    }
    cout<<r<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
sed 1d |
  sed 's/AC/1 AC/' |
  sed 's/WA/2 WA/' |
  sed 's/TLE/3 TLE/' |
  sed 's/RE/4 RE/' |
  awk '{a[$1" "$2]++}END{for(k in a){print k" x "a[k]}}' |
  sed -e '$i2 WA x 0' -e '$i3 TLE x 0' -e '$i4 RE x 0' -e '$i1 AC x 0' |
  sort | cut -c 3- | tac | uniq -w3 | tac

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll K, X;
    cin >> K >> X;
    cout << (K*500>=X ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
using namespace std;

int array[1000000];

int main()
{
  int N;
  while (scanf("%d", &N), N) {
    for (int i = 0; i < N; ++i) {
      scanf("%d", &array[i]);
    }
    nth_element(array, array + N/2, array + N);
    if (count(array, array + N, array[N/2]) > N/2) {
      printf("%d\n", array[N/2]);
    } else {
      puts("NO COLOR");
    }
  }
}

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

int main() {
	int h, a;

	cin >> h >> a;

	int result;
	if (h % a == 0) {
		result = h / a;
	}
	else {
		result = h / a + 1;
	}

	cout << result << "\n";

	return 0;
}


Measured memory_bytes: 256
/**
 * Created by hiramekun at 17:22 on 2020-02-19.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n, m;
    cin >> n >> m;
    vector<bool> aced(n);
    vector<int> pen(n);

    rep(i, m) {
        ll p;
        string s;
        cin >> p >> s;
        p--;

        if (s == "AC") aced[p] = true;
        else {
            if (!aced[p]) pen[p]++;
        }
    }
    ll ac = 0, pe = 0;
    rep(i, n) {
        if (aced[i]) {
            pe += pen[i];
            ac++;
        }
    }
    cout << ac << ' ' << pe << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int main() {
    int a,b;
    cin>>a>>b;

    if((a+b)%3==0||a%3==0||b%3==0){
        cout<<"Possible"<<endl;
    }
    else{
        cout<<"Impossible"<<endl;
    }
}


Measured memory_bytes: 256
import math
A,B,H,M= map(int,input().split())

theta = abs(30*H+(M/2)-6*M)
theta = min(theta, 360-theta)
theta = math.radians(theta)

X2 = pow(A,2)+pow(B,2)-2*A*B*math.cos(theta)
print(math.sqrt(X2))



Measured memory_bytes: 9504
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
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;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ProblemD solver = new ProblemD();
		solver.solve(1, in, out);
		out.close();
	}

	static class ProblemD {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int k = in.nextInt();
			int[][] sb = new int[2 * k + 1][2 * k + 1];
			int[][] sw = new int[2 * k + 1][2 * k + 1];
			for (int i = 0; i < n; i++) {
				int x = in.nextInt();
				int y = in.nextInt();
				char c = in.next().charAt(0);
				x %= 2 * k;
				y %= 2 * k;
				++x;
				++y;
				if (c == 'B') {
					++sb[x][y];
				} else {
					++sw[x][y];
				}
			}

			for (int[][] s : new int[][][]{sb, sw}) {
				for (int i = 1; i <= 2 * k; i++) {
					for (int j = 1; j <= 2 * k; j++) {
						s[i][j] += s[i - 1][j];
						s[i][j] += s[i][j - 1];
						s[i][j] -= s[i - 1][j - 1];
					}
				}
			}

			int ans = 0;
			for (int di = 0; di <= 2 * k; di++) {
				for (int dj = 0; dj <= 2 * k; dj++) {
					int cur = 0;
					for (int bigI = -2; bigI <= 2; bigI++) {
						for (int bigJ = -2; bigJ <= 2; bigJ++) {
							int i1 = bigI * k + di + 1;
							int i2 = i1 + k - 1;
							int j1 = bigJ * k + dj + 1;
							int j2 = j1 + k - 1;
							int[][] s;
							if ((bigI + bigJ) % 2 == 0) {
								s = sb;
							} else {
								s = sw;
							}
							if (i1 > 2 * k) {
								continue;
							}
							i1 = Math.max(i1, 1);
							if (i2 < 1) {
								continue;
							}
							i2 = Math.min(i2, 2 * k);
							if (j1 > 2 * k) {
								continue;
							}
							j1 = Math.max(j1, 1);
							if (j2 < 1) {
								continue;
							}
							j2 = Math.min(j2, 2 * k);
							if (i1 <= i2 && j1 <= j2) {
								--i1;
								--j1;
								cur += s[i2][j2];
								cur -= s[i2][j1];
								cur -= s[i1][j2];
								cur += s[i1][j1];
							}
						}
					}
					ans = Math.max(ans, cur);
				}
			}
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

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

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

	}
}



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

using namespace std;

int main(){
    vector<int> a(5), b(5);
    vector<pair<int,int>> AB(5);
    for(int i = 0; i< 5; ++i){
        cin >> a[i];
        b[i] = a[i] % 10;
        if(b[i] == 0) b[i]  = 10;
        AB[i] = make_pair(b[i], a[i]);
    }

    sort(AB.begin(),AB.end());
    int time = 0;
    for(int i = 0; i < 5; ++i){
        if(i == 0 || AB[i].first == 10) time += AB[i].second;
        else time += (AB[i].second/10 + 1) * 10;
    }

    cout << time << endl; 
}

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

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

  vector<double> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }

  vector<vector<double>> dp(N+1, vector<double>(N+1));
  dp.at(0).at(0)= 1.0;
  for(int n=1; n<= N; n++){
    dp.at(n).at(0)= (1.0- data.at(n-1))* dp.at(n-1).at(0);
    for(int head=1; head<n; head++){
      dp.at(n).at(head)= (1.0- data.at(n-1))*dp.at(n-1).at(head) + data.at(n-1)*dp.at(n-1).at(head-1);
    }
    dp.at(n).at(n)= data.at(n-1)* dp.at(n-1).at(n-1);
  }

  double ans= 0.0;
  for(int head=(N+1)/2; head<= N; head++){
    ans+= dp.at(N).at(head);
  }

  cout << fixed;
  cout << setprecision(9) << ans << endl;
}

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

using int64 = long long;

int main() {
    string s, t;
    cin >> s;
    cin >> t;

    map<char, vector<int>> positions_list;
    for (int i = 0; i < s.size(); i++) {
        positions_list[s[i]].push_back(i);
        positions_list[s[i]].push_back(i + s.size());
    }

    for (char c = 'a'; c <= 'z'; c++) {
        sort(positions_list[c].begin(), positions_list[c].end());
    }

    int64 ans = 0;
    int cur_pos = 0;
    for (char c : t) {
        // sから直近のcを探す
        auto ptr = lower_bound(positions_list[c].begin(),
                                 positions_list[c].end(),
                                 cur_pos);
        
        // tを作れない
        if (ptr == positions_list[c].end()) {
            ans = -1;
            break;
        }

        int nxt_pos = *ptr + 1;
        ans += nxt_pos - cur_pos;
        cur_pos = nxt_pos % s.size();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1728
n = int(input())
s = input()

# 累積和を求めておく
cumsum_e = 0
cumsum_w = 0
for i in range(n):
    if s[i] == 'E':
        cumsum_e += 1
    else:
        cumsum_w += 1

min_change = n + 1
current_e = 0
current_w = 0
for i in range(n):
    temp_change = 0
    migi_e = cumsum_e - current_e
    if s[i] == 'E':
        migi_e -= 1
    temp_change = current_w + migi_e

    if temp_change < min_change:
        min_change = temp_change

    if s[i] == 'E':
        current_e += 1
    else:
        current_w += 1

print(min_change)

Measured memory_bytes: 3704
#include<stdio.h>
int min(int n_1,int n_2){
if(n_1<=n_2){
return n_1;
}else{
return n_2;
}
}
int main(void){
int N,i,j,sum=0;
scanf("%d",&N);
int B[N];
for(i=0;i<N-1;i++)scanf("%d",&B[i]);

for(j=1;j<N-1;j++){
sum+=min(B[j-1],B[j]);
}
sum+=B[0];
sum+=B[N-2];
printf("%d",sum);
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
const long long int mod = 1e9 + 7;
int main()
{
    string S;
    cin >> S;
    bool flag = false;
    rep(i, 0, S.size())
    {
        if(i%2==1){
            if(S[i]=='R')
                flag = true;
        }else{
            if(S[i]=='L')
                flag = true;
        }
    }
    if(flag)
        cout << "No" << endl;
        else
            cout << "Yes" << endl;

}

Measured memory_bytes: 256
class BinaryIndexedTree:
    def __init__(self, size):
        self.data = [0] * (size+1)
        self.size = size+1
        self.msb = 1 << (size.bit_length()-1)
    
    def _add(self, i, w):
        i += 1
        while i < self.size:
            self.data[i] += w
            i += i & -i
    
    def _get_sum(self, i):
        res = 0
        while i > 0:
            res += self.data[i]
            i -= i & -i
        return res

    def __getitem__(self, i):
        """
        [0,i)
        """
        if isinstance(i, slice):
            if i.start is None:
                return self._get_sum(i.stop)
            else:
                return self._get_sum(i.stop) - self._get_sum(i.start)
        else:
            return 0 # fake value
    
    __setitem__ = _add
    
    def bisect_left(self, v):
        """
        return smallest i s.t v <= sum[:i]
        """
        i = 0
        k = self.msb
        while k > 0:
            i += k
            if i < len(self.data) and self.data[i] < v:
                v -= self.data[i]
            else:
                i -= k
            k >>= 1
        return i
    
    def bisect_right(self, v):
        """
        return smallest i s.t v < sum[:i]
        """
        i = 0
        k = self.msb
        while k > 0:
            i += k
            if i < len(self.data) and self.data[i] <= v:
                v -= self.data[i]
            else:
                i -= k
            k >>= 1
        return i
    
    bisect = bisect_right



def solve(C, queries):
    N = len(C)
    Q = len(queries)
    bit = BinaryIndexedTree(N)

    last_ind = [None]*(N + 1)
    sorted_qi = sorted(range(Q), key=lambda i:queries[i][1])

    res = [None]*Q
    pr = 0
    temp = 0
    for qi in sorted_qi:
        l,r = queries[qi]
        for j,c in enumerate(C[pr:r],start=pr):
            if last_ind[c] is not None:
                bit._add(last_ind[c], -1)
            else:
                temp += 1
            last_ind[c] = j
            bit._add(j, 1)

        pr = r
        res[qi] = temp - bit._get_sum(l-1)

    return res

# from random import randrange, seed
# from time import perf_counter

# def test():
#     seed(1234)
#     N = 5*10**5
#     C = [randrange(N) for _ in range(N)]
#     queries = [tuple(sorted((randrange(1,N+1),randrange(1,N+1)))) for _ in range(N)]
#     start = perf_counter()
#     solve(C,queries)
#     stop = perf_counter()
#     print(stop-start)

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

if __name__ == '__main__':
    N,Q = map(int,readline().split())
    C = list(map(int,readline().split()))

    m = map(int,read().split())
    queries = list(zip(m,m))

    print(*solve(C,queries), sep='\n')
    # test()


Measured memory_bytes: 202988
n = int(input())
a = list(map(int,input().split()))
a.sort()
dp = [0]*(a[-1]+1)
k = 2
while k*a[0] <= a[-1]:
    dp[k*a[0]] += 1
    k += 1

for i in range(1,n):
    if a[i] == a[i-1]:
        dp[a[i]] += 1
    else:
        k = 2
        while k*a[i] <= a[-1]:
            dp[k*a[i]] += 1
            k += 1
ans = 0
for elem in a:
    if dp[elem] == 0:
        ans += 1
print(ans)
    


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

void solve() {
    //const i64 mod = 1'000'000'007;
    i64 N;
    cin >> N;

    using ii=pair<i64,i64>;
    priority_queue<ii,vector<ii>> a,b;
    vector<bool> used(N);
    vector<i64> A(N),B(N);
    rep(i,0,N){
        cin >> A[i] >> B[i];
        a.push(make_pair(A[i]+B[i],i));
        b.push(make_pair(B[i]+A[i],i));
    }

    i64 ans=0;
    rep(i,0,N){
        ii p;
        while(true){
            if(i%2==0){
                auto tmp=a.top();
                a.pop();
                if(used[tmp.second]) continue;
                p=tmp;
                break;
            }else{
                auto tmp=b.top();
                b.pop();
                if(used[tmp.second]) continue;
                p=tmp;
                break;
            }
        }
        if(i%2==0){
            ans+=A[p.second];
        }else{
            ans-=B[p.second];
        }
        used[p.second]=true;
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main()
{
	SPEED
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> arr[i];
	}

	
	int destroy = 0;
	int search = 1;


	for (int i = 0; i < n; ++i)
	{
		if (arr[i]==search)
		{
			search++;
		}
		else
		{
			destroy++;
		}
	}


	if (destroy<=n-1)
	{
		cout << destroy;
	}
	else
	{
		cout << -1;
	}
}


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

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  

int n, m;
string s;

bool f(int curr, vector<int>& ans)
{
    if(curr == 0) return true;
    if(s[curr] == '1') return false;
    for(int i=m;i>0;i--)
    {
        if(curr-i<0) continue;
      	if(s[curr-i] == '1') continue;
        bool check = f(curr-i, ans);
    
        if(check) 
        {
            ans.pb(i);
            return true;
        }
      else break;
    }
    return false;
}
        

int32_t main()
{
    fastio;
    cin >> n >> m;
    cin >> s;
    vector<int> ans;
    bool check = f(n, ans);
    if(!check) cout << "-1";
    else for(int i:ans) cout << i << " ";
    cout << "\n";
    return 0;
}



Measured memory_bytes: 6216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    int ans = 0;
    
    rep(i, n) {
        if (h[i] >= k) {
            ans ++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    string inp;

    while (cin >> inp) {
        string ans;

        for (int i = 0; i < inp.size(); i++) {
            int n;
            char ch;

            if (inp[i] == '@') {
                n = inp[++i] - '0';
                ch = inp[++i];
                for (int j = 0; j < n; j++)
                    ans.push_back(ch);
            }
            else
                ans.push_back(inp[i]);
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1188
def mod_com(n, k, mod):
    def ext_gcd(a, b):
        if b == 0:
            return a, 1, 0
        else:
            d, x, y = ext_gcd(b, a % b)
            x -= (a // b)*y
        return d, y, x
    p, q = 1, 1
    for i in range(n - k + 1, n + 1):
        p = (p * i) % mod
    for i in range(2, k+1):
        q = (q * i) % mod
    return int(p * (ext_gcd(q, mod)[1] % mod) % mod)


x, y = map(int, input().split())
mod = 10 ** 9 + 7
dif = abs(x - y)
num = min([x, y]) - dif
if num % 3 != 0:
    print(0)
    exit()
num_1 = num / 3 + dif
num_2 = num / 3
print(mod_com(int(num_1 + num_2), int(num_1), mod))

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

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

    int n, k;
    cin >> n >> k;
    int arr[n];
    for (int &i : arr) cin >> i;

    sort(arr, arr + n);
    int sum = 0;
    for (int i = 0; i < k; i++) sum += arr[i];
    cout << sum;
}

Measured memory_bytes: 3668
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

ll cnt[100050];
char in[105];
int main() {
	int N, i, j, k;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%s", in);
		cnt[in[0]]++;
	}

	char str[10] = "MARCH";
	
	ll ans = 0;
	for (i = 0; i < 5; i++) {
		for (j = 0; j < i; j++) {
			for (k = 0; k < j; k++) {
				ans += cnt[str[i]] * cnt[str[j]] * cnt[str[k]];
			}
		}
	}
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll A, B, Q;
  cin >> A >> B >> Q;
  vector<ll> ss(A), ts(B), xs(Q);
  ll inf = tenq * 1000;
  for (auto i = 0; i < A; i++) {
    ll x;
    cin >> x;
//    ss[i] = (i == 0 ? 0 : ss[i-1]) + x;
    ss[i] = x;
  }
  for (auto i = 0; i < B; i++) {
    ll x;
    cin >> x;
//    ts[i] = (i == 0 ? 0 : ts[i-1]) + x;
    ts[i] = x;
  }
  for (auto i = 0; i < Q; i++) cin >> xs[i];
  for (auto i = 0; i < Q; i++) {
    ll x = xs[i];
    auto ls = lower_bound(ss.begin(), ss.end(), x);
    auto lt = lower_bound(ts.begin(), ts.end(), x);

    ll lefts = ls == ss.begin() ? inf : *(ls - 1);
    ll leftt = lt == ts.begin() ? inf : *(lt - 1);
    ll rights = ls == ss.end() ? inf : *ls;
    ll rightt = lt == ts.end() ? inf : *lt;

    ll res = (lefts == inf || leftt == inf) ? inf : abs(min(lefts, leftt) - x);
    res = min(res, abs(max(rights, rightt) - x));
    res = min(res, abs(lefts - x) * 2 + abs(rightt - x));
    res = min(res, abs(lefts - x) + abs(rightt - x) * 2);
    res = min(res, abs(rights - x) * 2 + abs(leftt - x));
    res = min(res, abs(rights - x) + abs(leftt - x) * 2);
    cout << res << endl;
  }

  return 0;
}


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

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define      TEST    ll t ; cin >> t ; while( t -- )


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

#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)

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


const ll big = 10e10 + 11 ;


int  main (  ) {

    FASTIO ;

    ll a , b, n , ans ;
    cin >> a >> b >> n ;

    ans = min( b - 1 , n ) ;

    ans = ( a * ans ) / b ;

    cout << ans  ;


    return  0 ;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <tuple>
#include <map>
#include <numeric>

using namespace std;
#define PI 3.14159265359
#define ll long long int

int main(void)
{
    ll a, b, k;
    cin >> a >> b >> k;
    if(a < k) k -= a, a = 0;
    else a -= k, k = 0;
 	
    if(b < k) b = 0;
    else b -= k;

    printf("%lli %lli\n", a, b);
}

Measured memory_bytes: 256
#include<stdio.h>

int IsPrime(int n)
{
  int i;

  if(n < 2)
    return 0;
  else if(n == 2)
    return 1;

  if(n % 2 == 0)
    return 0;

  for(i = 3 ; i <= n / i ; i += 2)
    {
      if(n % i == 0)
        return 0;
    }
  return 1;
}

int main()
{
  int a,b,i,count = 0;

  scanf("%d",&a);

  for(i = 0 ; i < a ; i++)
    {
      scanf("%d",&b);
      if(IsPrime(b) == 1)
        {
          count += 1;
        }
    }

  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#include<ext/pb_ds/priority_queue.hpp>
const int maxn = 100100;
std::set<int> to[maxn];
int n,rt;
char c[maxn];
int vis[maxn],v[maxn];
std::queue<int> q; 
int ans = -2,mx;
std::pair<int,int> find(int x,int f = 0){
	std::pair<int,int> ret(-v[x],x);
	for(int i : to[x]) if(i != f) ret = std::max(ret,find(i,x));
	return ret.first += v[x],ret;
}
void dfs1(int x,int f = 0){
	vis[x] = 1;
	for(int i : to[x]) if(i != f) dfs1(i,x);
	for(std::set<int>::iterator it = to[x].begin();it != to[x].end();) {
		if(to[*it].size() == 1 && c[*it] == 'B' && *it != f){
			vis[*it] = 0; to[*it].clear(); it = to[x].erase(it);
		} else ++ it;
	}
}

int main(){
	std::ios::sync_with_stdio(false),std::cin.tie(0);
	std::cin >> n;
	for(int i = 1,x,y;i < n;++i) std::cin >> x >> y,to[x].insert(y),to[y].insert(x);
	std::cin >> c + 1;
	for(int i = 1;i <= n;++i){
		vis[i] = 1;
		if(to[i].size() <= 1 && c[i] == 'B') q.push(i);
	}
	for(;!q.empty();){
		int t = q.front(); vis[t] = 0; q.pop();
		const int x = *to[t].begin();
		to[x].erase(t); if(to[x].size() <= 1 && c[x] == 'B') q.push(x);
	}
	ans = std::count(vis + 1,vis + n + 1,1) - 1 << 1;
	for(int i = 1;i <= n;++i) if(vis[i]) {
		if((c[i] == 'W') ^ to[i].size() & 1) {
			v[i] = 2; ++ ans;
		}
	} 
	for(int i = 1;i <= n;++i) if(vis[i]) {
		std::cout << ans - find(find(i).second).first << '\n';
		return 0;
	}
	std::cout << 0 << '\n';
}

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

int main()
{
    int a, b;
    while (1) {
        cin >> a >> b;
        if (a == 0 && b == 0) break;
        for (int i = 0; i < a; i++) {
            for (int j = 0; j < b; j++) {
                if (i % 2 == 0) {
                    if (j % 2) cout << ".";
                    else cout << "#";
                }
                else {
                    if (j % 2) cout << "#";
                    else cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3112
from collections import deque
INFTY = 10**6
N,u,v = map(int,input().split())
G = {i:[] for i in range(1,N+1)}
for _ in range(N-1):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
du = [INFTY for _ in range(N+1)]
du[u] = 0
que = deque([(0,u)])
hist = [0 for _ in range(N+1)]
hist[u] = 1
while que:
    c,i = que.popleft()
    for j in G[i]:
        if hist[j]==0:
            que.append((c+1,j))
            du[j] = c+1
            hist[j] = 1
dv = [INFTY for _ in range(N+1)]
dv[v] = 0
que = deque([(0,v)])
hist = [0 for _ in range(N+1)]
hist[v] = 1
while que:
    c,i = que.popleft()
    for j in G[i]:
        if hist[j]==0:
            que.append((c+1,j))
            dv[j] = c+1
            hist[j] = 1
cmax = 0
for i in range(1,N+1):
    if du[i]<dv[i]:
        cmax = max(cmax,dv[i])
print(cmax-1)

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

int main()
{
	int nNum=0;
	cin>>nNum;
	int nIn[3]={0};
	while(nNum--)
	{
		cin>>nIn[0]>>nIn[1]>>nIn[2];
		int nMax=max(max(nIn[0],nIn[1]),nIn[2]);
		if(nMax*nMax*2==nIn[0]*nIn[0]+nIn[1]*nIn[1]+nIn[2]*nIn[2])
		{
			cout<<"YES"<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3092
def main():
    N = int(input())
    *A, = map(int, input().split())

    tot = sum(A)

    ans = 1
    tot -= 1
    v = 1
    for x in A:
        v -= x
        if v < 0:
            print(-1)
            return
        make_v = min(v, tot)
        tot -= make_v
        v += make_v
        ans += v

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 83896
import sys
rline = sys.stdin.readline


def solve():
    N, C = map(int, rline().split())
    schedule = [[0] * 100001 for _ in range(C)]
    for _ in range(N):
        s, t, c = map(lambda x: int(x) - 1, rline().split())
        schedule[c][s] += 1
        schedule[c][t] -= 1
    
    imos = [0] * 100001
    for ch_i in schedule:
        for i in range(100001):
            if ch_i[i] == 1:
                imos[i] += 1
            elif ch_i[i] == -1:
                imos[i + 1] -= 1
    for i in range(1, 100001):
        imos[i] += imos[i - 1]
    print(max(imos))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 65756
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repin(Array,n) for(int i=0;i<n;i++){cin>>Array[i];}
using namespace std;

using ll = long long;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;
using Graph = vector<vector<int>>;

int main() {

	int H, W;
	cin >> H >> W;

	vector<string>S(H);

	repin(S, H);

	rep(i, H) {
		cout << S[i] << endl << S[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    string s, t;
    cin >> s >> t;
    vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1, 0));
    rep(i, 0, s.size())
    {
        rep(j, 0, t.size())
        {
            if (s[i] == t[j])
            {
                chmax(dp[i + 1][j + 1], dp[i][j] + 1);
            }
            else
            {
                chmax(dp[i + 1][j + 1], dp[i][j + 1]);
                chmax(dp[i + 1][j + 1], dp[i + 1][j]);
            }
        }
    }
    string ans;
    int i = s.size(), j = t.size();
    while (i > 0 && j > 0)
    {
        if (dp[i][j] == dp[i - 1][j])
        {
            --i;
        }
        else if (dp[i][j] == dp[i][j - 1])
        {
            --j;
        }
        else
        {
            ans += s[i - 1];
            --i;
            --j;
        }
    }
    reverse(all(ans));
    cout << ans << endl;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク

    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }

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

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  COMinit();
  ll n;
  cin >> n;
  vector<ll>vec(MAX);
  rep(i,n){
    int l,r;
    cin >> l >> r;
    l--;
    r--;
    vec[l]++;
    vec[r+1]--;
  }
  rep(i,MAX-1){
    vec[i+1]+=vec[i];
  }
  int cnt=0;
  rep(i,100000){
    if(vec[i])cnt++;
  }
  cout << cnt << endl;
    
}


Measured memory_bytes: 16256
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N, K = list(map(int, input().split()))
for i in range(K):
  n = N-K+1
  r = i+1
  if n-r<0:
    print (0)
  else:
    res = combinations_count(n,r)*combinations_count(K-1,r-1)
    print(res%(10**9+7))


Measured memory_bytes: 3316
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int cntOdd = 0;
	int A = Integer.parseInt(sc.next());
	int B = Integer.parseInt(sc.next());
	int C = Integer.parseInt(sc.next());
	int max = B;
	if(A>B) max = A;
	if(max<C) max = C;

	if((max-A)%2!=0 && A!=max) cntOdd++;
	if((max-B)%2!=0 && B!=max) cntOdd++;
	if((max-C)%2!=0 && C!=max) cntOdd++;

	if(cntOdd==0) {
	    System.out.println((max-A)/2 + (max-B)/2 + (max-C)/2);
	}else if(cntOdd == 1) {
	    max++;
	    System.out.println((max-A)/2 + (max-B)/2 + (max-C)/2 + 1);
	}else if(cntOdd == 2) {
	    System.out.println((max-A)/2 + (max-B)/2 + (max-C)/2 + 1);
	}

    }
}

Measured memory_bytes: 23124
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextssort(n,a){return a?cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>b-a):cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>a-b);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}
var streams=[];function print(s){streams.push(s);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));
if(streams.length)console.log(streams.join("\n"));

function main(){
  var [n,x,m] = nexts(3);
  var set = new Set();
  var ans = 0, xx;
  for(var i = 0; i < n; i++){
    if(set.has(x))break;
    ans += x;
    set.add(x);
    x = x*x%m;
  }
  var sum = 0, xx = x, j = 0;
  for(;i < n;){
    ans += x;
    sum += x;
    x = x*x%m;
    i++,j++;
    if(xx === x)break;
  }
  if(i === n || x === 0)return ans;
  ans += Math.floor((n-i)/j) * sum;
  i += Math.floor((n-i)/j) * j;
  for(;i < n; i++){
    ans += x;
    x = x*x%m;
  }
  return ans;
}

Measured memory_bytes: 37956
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

int main( )
{
	string w, p;
	int i;
	
	cin>>w;
	
	int cnt = 0;
	while( cin>>p ) {
		if( "END_OF_TEXT" == p ) { break; }
		
		for( i=0; i<p.length(); i++ ) {
            p[i] = tolower( p[i] );
        }
		if( p == w ) {
			cnt++;
		}
	}
	
	cout<<cnt<<endl;
	
	return 0;
}

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

long long n;

int main() {
  cin >> n;
  long long cnt = 0;
  for (int i = 0; i < n; ++i) {
    long long a;
    cin >> a;
    cnt += a & 1;
  }
  if (cnt & 1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int N,Q,X[10005],i,t,r=0;
int main()
{
    scanf("%d",&N);
    for(i=0;i<N;i++)
        scanf("%d",X+i);
    for(scanf("%d",&Q);Q--;)
    {
        scanf("%d",&t);
        for(i=0;i<N;i++)
            if(X[i]==t)
            {
                r++;
                break;
            }
    }
    return !printf("%d\n",r);
}


Measured memory_bytes: 2088
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (int)a; ++i)
#define REP(i, a, b) for (int i = (a); i < (int)b; ++i)

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

// auto mod int
const int mod = 1000000007;
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 {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= 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 {
    mint res(*this);
    return res /= a;
  }
};

void Main() {
  string s;
  cin >> s;

  int s_size = s.size();
  int tens = 1, tot = 0;
  vector<int> q;
  for(int i = s_size-1; i>=0; --i) {
    if (s[i]=='?') q.emplace_back(tens);
    else (tot += tens*(int)(s[i] - '0')) %= 13;
    (tens *= 10) %= 13;
  }
  int q_size = q.size();
  vector<vector<mint>> dp(q_size+1, vector<mint>(13, 0));
  dp[0][tot] = 1;
  rep(i, q_size) {
    rep(k, 10) {
      int x = q[i] * k;
      rep(m, 13) {
        dp[i+1][(x+m)%13] += dp[i][m];
      }
    }
  }
  cout << dp[q_size][5].x << endl;
}

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


Measured memory_bytes: 14024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long C = sc.nextLong();
        long K = sc.nextLong();
        long sum = 0;
        
        if(K<A){
            sum = K;
        }
        else if(K<=A+B){
            sum = A;
        }
        
        else{
            sum = A - (K-A-B);
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 35472
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long n, q, t, f;
    deque<char> dq;
    string s, rs, ans, last;
    char c;
    cin >> s;
    cin >> q;
    bool reversed = false;
    for (int i = 0; i < s.size(); i++) {
        dq.push_back(s[i]);
    }
    for (int i = 0; i < q; i++) {
        cin >> t;
        if (t == 2) {
            cin >> f >> c;
            if (f == 1) {
                if (reversed) {
                    dq.push_back(c);
                } else {
                    dq.push_front(c);
                }
            } else {
                if (reversed) {
                    dq.push_front(c);
                } else {
                    dq.push_back(c);
                }
            }
        } else {
            reversed = !reversed;
        }
    }
    if (reversed) {
        reverse(dq.begin(), dq.end());
        for (auto c : dq) {
            cout << c;
        }
    } else {
        for (auto c : dq) {
            cout << c;
        }
    }
}

Measured memory_bytes: 976
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
#define endl        	"\n"
#define int         	long long int  
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define pll         	pair<ll,ll>
#define vec     		vector<ll>
#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007

ll mod_pow(ll a,ll b)
{
    ll res = 1;
    while(b)
    {
        if(b&1) res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a)
{
	return mod_pow(a,mod-2);
}

void solve()
{
	ll k;
	
	string s;
	
	cin >> k >> s;
	
	if(k >= s.size())
	{
		cout<<s;
	}
	else
	{
		cout<<s.substr(0,k)<<"...";
	}
}

signed main()
{
    fast;
	
    ll t;
    
    t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 3656