akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main()
{
    int S[13], H[13], C[13], D[13];

    int s = 0, h = 0, c = 0,d =0, counter =0;
    int num;
    cin>>num;

    char ch[num];
    int n[num];

    for(int i =0; i<num; i++)
    {
        cin>>ch[i]>>n[i];
    }

    for(int i = 0; i<num; i++)
    {
        if(ch[i]=='S')
        {
            S[s]=n[i];
            s++;
        }
        else if(ch[i]=='H')
        {
            H[h]=n[i];
            h++;
        }
        else if(ch[i]=='C')
        {
            C[c]=n[i];
            c++;
        }
        else if(ch[i]=='D')
        {
            D[d]=n[i];
            d++;
        }
    }

///S

    for(int j = 1; j<=13; j++)
    {
        for(int i = 0; i<s; i++)
        {
            if(j!=S[i])
            {
                counter++;
            }
        }

        if(counter == s)
        {
            cout<<"S "<<j<<endl;
            counter =0;
        }
        else
            counter = 0;
    }

///H

    for(int j = 1; j<=13; j++)
    {
        for(int i = 0; i<h; i++)
        {
            if(j!=H[i])
            {
                counter++;
            }
        }

        if(counter == h)
        {
            cout<<"H "<<j<<endl;
            counter =0;
        }
        else
            counter = 0;
    }


///C

    for(int j = 1; j<=13; j++)
    {
        for(int i = 0; i<c; i++)
        {
            if(j!=C[i])
            {
                counter++;
            }
        }

        if(counter == c)
        {
            cout<<"C "<<j<<endl;
            counter =0;
        }
        else
            counter = 0;
    }

///D

    for(int j = 1; j<=13; j++)
    {
        for(int i = 0; i<d; i++)
        {
            if(j!=D[i])
            {
                counter++;
            }
        }

        if(counter == d)
        {
            cout<<"D "<<j<<endl;
            counter =0;
        }
        else
            counter = 0;
    }


    return 0;
}








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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    map<char, ll> m;
    string w;
    cin >> w;
    for(auto &c: w) m[c]++;
    for(auto &i: m) {
        if(i.second % 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
time=[]
for i in range(n):
    a,b=map(int,input().split())
    time.append([a,b])
timesort=sorted(time,key=lambda x:(x[1]))
s=0
for i in range(n):
    s+=timesort[i][0]
    if s>timesort[i][1]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 39712
let rec f () =
  let n, x = Scanf.scanf "%d %d\n" (fun a b -> a, b) in
  let ns =
    let rec f n =
      if n = 0 then []
      else n :: f (n-1)
    in
    f n |> Array.of_list
  in
  let res = ref 0 in
  if not (n = 0 && x = 0) then
    begin
      for i = 0 to (n-3) do
        for j = (i + 1) to (n-2) do
          for k = (j + 1) to (n-1) do
            if (ns.(i) + ns.(j) + ns.(k)) = x
            then res := !res + 1
          done
        done
      done;
      print_int !res;
      print_newline();
      f()
    end ;;

f();;


Measured memory_bytes: 2488
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(X):
    return 'Yes' if X >= 30 else 'No'


def main():
    X = read_int()
    print(slv(X))


if __name__ == '__main__':
    main()


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

int main()
{
	vector<bool> ex(52, true);
	char v;
	int n, c;
	cin >> n;
	while (n--) {
		cin >> v >> c;
		switch (v)
		{
		case 'H':
			c += 13;
			break;
		case 'C':
			c += 26;
			break;
		case 'D':
			c += 39;
			break;
		default:
			break;
		}
		ex[c - 1] = false;
	}
	for (int i = 0; i < 52; i++) {
		if (ex[i]) {
			switch (i / 13)
			{
			case 0:
				cout << "S " << i % 13 + 1 << endl;
				break;
			case 1:
				cout << "H " << i % 13 + 1 << endl;
				break;
			case 2:
				cout << "C " << i % 13 + 1 << endl;
				break;
			case 3:
				cout << "D " << i % 13 + 1 << endl;
				break;
			default:
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3064
/*
 * @Author: Wa_King 
 * @Date: 2019-11-23 19:58:12 
 * @Last Modified by: Wa_King
 * @Last Modified time: 2019-11-23 20:26:43
 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define fi first
#define se second
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;
const int inf = 0x3f3f3f3f;
string a[305];
bool vis[305];
int ans[305][305];
int h,w,k;
void dfs(int x,int y)
{
    for(int i=y-1;i>=0;i--)
    {
        if(ans[x][i]==0&&a[x][i]=='.') ans[x][i]=ans[x][y];
        else break;
    }
    for(int i=y+1;i<w;i++)
    {
        if(ans[x][i]==0&&a[x][i]=='.') ans[x][i]=ans[x][y];
        else break;
    }
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>h>>w>>k;
    rep(i,0,h-1) cin>>a[i];
    int now=1;
    rep(i,0,h-1) rep(j,0,w-1) if(a[i][j]=='#') ans[i][j]=now++;
    rep(i,0,h-1) rep(j,0,w-1) if(a[i][j]=='#') dfs(i,j),vis[i]=true;
    now=-1;
    rep(i,0,h-1)
    {
        if(vis[i])
        {
            now=i;
            continue;
        }
        if(now==-1)
        {
            now++;
            while(!vis[now])now++;
        }
        rep(j,0,w-1) ans[i][j]=ans[now][j];
    }
    rep(i,0,h-1)
    {
        rep(j,0,w-1) cout<<ans[i][j]<<' ';
        cout<<'\n';
    }
    return 0;
}

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

int main() {
    int n, k; cin >> n >> k;
    vector<bool> sunuke(n, true);
    for (int i = 0; i < k; i++) {
        int d; cin >> d;
        for (int j = 0; j < d; j++) {
            int a; cin >> a;
            sunuke.at(a-1) = false;
        }
    }
    int cnt = 0;
    for (bool s: sunuke) {
        if (s) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

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


int N, A, B, C;
int l[8];
vector<int> a, b, c;
const int INF = 1e7;

int min_cost(vector<int>& v, int V) {
	if (v.empty()) return INF;
	int s = v[0];
	int ret = 0;
	for(int i=1;i<v.size();i++) {
		s += v[i];
		ret += 10;
	}
	ret += abs(s - V);
	return ret;
}

int dfs(int p) {
	if(p == N) {
		return min_cost(a, A) + min_cost(b, B) + min_cost(c, C);
	}
	int ret = dfs(p + 1);
	a.push_back(l[p]);
	ret = min(ret, dfs(p + 1));
	a.pop_back();
	b.push_back(l[p]);
	ret = min(ret, dfs(p + 1));
	b.pop_back();
	c.push_back(l[p]);
	ret = min(ret, dfs(p + 1));
	c.pop_back();
	return ret;
}

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

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

	cout << dfs(0) << endl;

	return 0;
}


Measured memory_bytes: 256
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))


(defun bit-full-serarch (n)
  (let ((result nil))
    (do ((bit 0 (1+ bit)))
        ((> bit (ash 1 n)))
      (let ((tmp nil))
        (do ((i 0 (1+ i)))
            ((> i n))
          (when (/= 0 (logand  bit (ash 1 i)))
            (push i tmp)))
        (when tmp
          (push tmp result))))
    result))

(defmacro char-list-to-string-to-number (l)
  `(parse-integer (coerce ,l 'string)))

(defun calc (target pos-list &optional (count 0) tmp result)
  (cond ((null target)
         (when tmp
           (let ((tmp-l (char-list-to-string-to-number (reverse tmp))))
             (if (null (listp tmp-l))
                 (push tmp-l result)
                 (push (reduce #'+ tmp-l) result))))
         (reverse result))
        ((and pos-list (= count (car pos-list)))
         (let ((tmp-l (char-list-to-string-to-number (reverse tmp))))
           (if (null (listp tmp-l))
               (push tmp-l result)
               (push (reduce #'+ tmp-l) result))
           (setq tmp nil))
         (push (car target) tmp)
         (calc (cdr target) (cdr pos-list) (- count 1) tmp result))
        (t
         (push (car target) tmp)
         (calc (cdr target) pos-list (- count 1) tmp result))))

(defun main ()
  (let* ((target (coerce (read-line) 'list))
         (pos-list (bit-full-serarch (- (length target) 1)))
         (result 0)
         (size (- (length target) 1)))
    (dolist (x pos-list)
      (if (= size (car x))
          (let ((tmp (parse-integer (coerce target 'string))))
            (setq result (+ result tmp)))
          (let ((tmp (calc target x (- (length target) 1))))
            (setq result (+ result (reduce #'+ tmp))))))
    (format t "~A~%" result)))

(main)


Measured memory_bytes: 21688
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

ll dp[600][600];
int dist[600][600];

int main(){
  int w, h, sx, sy, gx, gy;

  cin >> w >> h >> sx >> sy >> gx >> gy;

  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      dist[i][j] = INF;

  queue<pair<pair<int,int>,pair<int,int> > > q1;

  q1.push({{sy, sx}, {h, w}});
  dp[h][w] = 1;
  
  for(int i=0;q1.size();i++){
    queue<pair<pair<int,int>,pair<int,int> > > q2;

    while(q1.size()){
      auto p = q1.front(); q1.pop();
      int y = p.first.first;
      int x = p.first.second;
      ll cost = dp[p.second.first][p.second.second];

      if(y < 0 || h <= y || x < 0 || w <= x) continue;
      if(dist[y][x] < i) continue;
      
      if(dist[y][x] == i){
        dp[y][x] = (dp[y][x] + cost)%mod;
        continue;
      }

      dp[y][x] = cost;
      dist[y][x] = i;

      int dx[8] = {0,0,1,-1,1,1,-1,-1};
      int dy[8] = {1,-1,0,0,1,-1,1,-1};
      for(int i=0;i<4;i++){
        q2.push({{y+dy[i], x+dx[i]},{y,x}});
      }
      q2.push({{0,x},{y,x}});
      q2.push({{y,0},{y,x}});
      q2.push({{h-1,x},{y,x}});
      q2.push({{y,w-1},{y,x}});
    }

    q1 = q2;
  }

  cout << dist[gy][gx] << " " << dp[gy][gx] << endl;
  
  return 0;
}



Measured memory_bytes: 6380
import java.util.Scanner;

public class Main {

	public static void main(String... nui) {
		
		Scanner sc = new Scanner(System.in);
		
		String a = sc.next();
		String b = sc.next();
		
		a += b;
		
		int s = Integer.parseInt(a);
		
		System.out.println((Math.sqrt(s) == (int)Math.sqrt(s)) ? "Yes" : "No");
		
	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include<map>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<typeinfo>
#include<queue>
#include<iomanip>
using namespace std;
int main() {
	int N,K;
	cin >> N>>K;
	vector<int> h(N);
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	
	vector<long long int> dp(N,0);
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for (int i = 1; i < N-1; i++) {
		long long int min = 1000000000;
		for (int j = 0; j < K; j++) {
			if ( i-j >= 0&&abs(h[i-j]-h[i+1])+dp[i-j]<min) {
				min = abs(h[i - j] - h[i + 1])+dp[i-j];
			}
		}
		dp[i + 1] = min;
	}
	cout << dp[N-1]<<endl;
}

Measured memory_bytes: 1408
'''input
4
1 1 1 1
'''
N = int(input())

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

lyg = {}
nel = {}

for i in range(N):
	if i & 1:
		if sk[i] in nel:
			nel[sk[i]] += 1
		else:
			nel[sk[i]] = 1
	else:
		if sk[i] in lyg:
			lyg[sk[i]] += 1
		else:
			lyg[sk[i]] = 1


nel = sorted(nel.items(), key=lambda kv: kv[1]);
lyg = sorted(lyg.items(), key=lambda kv: kv[1]);

nel.reverse();
lyg.reverse();

nel.append((-12, 0))
lyg.append((-12, 0))

if nel[0][0] != lyg[0][0]:
	ats = (N+1)//2 - nel[0][1] + N//2 - lyg[0][1];
else:
	if N <= 3:
		ats = 1
	else:
		ats = min((N+1)//2 - nel[0][1] + N//2 - lyg[1][1], (N+1)//2 - nel[1][1] + N//2 - lyg[0][1])

print(ats)


Measured memory_bytes: 17688
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    ll n,a,b;
    string s;
    cin >> n >> a >> b >> s;
    ll jp = 0;
    ll fo = 0;
    rep(i,s.length()){
        if(s[i] == 'a'){
            if(jp + fo < a+b){
                cout << "Yes\n";
                jp++;
            }else{
                cout << "No\n";
            }
        }else if(s[i] == 'b'){
            if(fo < b && jp + fo < a+b){
                cout << "Yes\n";
                fo++;
            }else{
                cout << "No\n";
            }
        }else{
            cout << "No\n";
        }
    }
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
using namespace std;

int main() {
    
    int t;
    t=1;
   // cin >> t;
    while(t--){
        int h,w;
        cin >> h >> w;
        char arr[h][w];
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin >> arr[i][j];
            }
        }
        
        ll dp[h][w];
        memset(dp,0,sizeof(dp));
        for(int i=0;i<h;i++){
            if(arr[i][0]=='.'){
                dp[i][0] = 1;
            }else{
                break;
            }
        }
        for(int j=0;j<w;j++){
            if(arr[0][j]=='.'){
                dp[0][j] = 1;
            }else{
                break;
            }
        }
        for(int i=1;i<h;i++){
            for(int j=1;j<w;j++){
                if(arr[i][j]=='.'){
                    dp[i][j] = (dp[i-1][j]+dp[i][j-1])%MOD;
                }
            }
        }
        cout << dp[h-1][w-1] << endl;
    }
    return 0;

}

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

int main(){
    int N, K;
    int h[100002];
    long mincost[100002];

    cin >> N >> K;
    for(int n=0;n<N;n++){
        cin >> h[n];
        mincost[n] = 1e9;
    }
    mincost[0] = 0;
    for(int n=0;n<N;n++){
        for(int k=1;k<=K;k++){
            if(n+k < N){
                mincost[n+k] = min(mincost[n+k], mincost[n] + abs(h[n] - h[n+k]));
            }
        }
    }
    cout << mincost[N-1] << "\n";
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>

using namespace std;

int mod5(int a);

int main()
{
    int n;

    while (cin >> n, n) {
        int ans = 0;
        for (int i = 5; i <= n; i++) {
            ans += mod5(i);
        }
        cout << ans << endl;
    }

    return 0;
}

int mod5(int a)
{
    int ret = 0;

    while (!(a % 5)) {
        ret++;
        a /= 5;
    }

    return ret;
}

Measured memory_bytes: 3056
s = str(input())
q = int(input())
cnt = 0
L = []
R = []
for _ in range(q):
    query = list(input().split())
    if query[0] == '1':
        cnt += 1
    else:
        if query[1] == '1':
            if cnt % 2:
                R.append(query[2])
            else:
                L.append(query[2])
        else:
            if cnt % 2:
                L.append(query[2])
            else:
                R.append(query[2])
s = (''.join(L[::-1]) + s + ''.join(R))
if cnt % 2:
    s = s[::-1]
print(s)


Measured memory_bytes: 6256
from collections import defaultdict
import sys

N = int(input())
A = map(int, input().split())

counts = defaultdict(int)
mod = N % 2

for a in A:
    if a % 2 == mod:
        print(0)
        sys.exit()
    counts[a] += 1
    if a == 0 and counts[a] > 1:
        print(0)
        sys.exit()
    if a > 0 and counts[a] > 2:
        print(0)
        sys.exit()

total = 2**(N // 2)
print(total % (10**9+7))

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    for (int &p: P) cin >> p;
    for (int &q: Q) cin >> q;

    if (P > Q) swap(P, Q);

    int ans = 0;
    while (P < Q && ++ans) next_permutation(P.begin(), P.end());

    cout << ans << endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]
for i in range(H):
  S[i].append('#')
  S[i].insert(0,'#')
a = ['#' for i in range(W+2)]
S.append(a)
S.insert(0,a)

for i in range(H+2):
  for j in range(W+2):
    if j<W+1: print(S[i][j],end='')
    else: print(S[i][j])

Measured memory_bytes: 42840
#include<iostream>
#include<cmath>
#include<vector>
#include<climits>

void print(std::vector<unsigned long long>m,int N,int W){
    for(int i=0;i<N;++i){
        for(int j=0;j<W;++j){
            std::cout<<m[i*W+j]<<",";
        }
        std::cout<<std::endl;
    }
}

int main(){
    int N,W;
    std::cin>>N>>W;
    std::vector<unsigned long long>w(N);
    std::vector<int>cost(N);
    w.shrink_to_fit();
    int sumCost=0;
    for(int i=0;i<N;++i){
        std::cin>>w[i]>>cost[i];
        sumCost+=cost[i];
    }
    std::vector<unsigned long long>dp(N*(sumCost+1),ULLONG_MAX);
    int ans=0;
    dp.shrink_to_fit();
    for(int i=1;i<=cost[0];++i){
        dp[0*(sumCost+1)+i]=w[0];
    }
    for(int i=0;i<N;++i){
        dp[i*(sumCost+1)+0]=0;
    }
    if(w[0]<=W){
        ans=cost[0];
    }
    for(int i=1;i<N;++i){
        for(int j=1;j<sumCost+1;++j){
            if(j<=cost[i]){
                if(dp[(i-1)*(sumCost+1)+j]==ULLONG_MAX){
                    dp[i*(sumCost+1)+j]=w[i];
                }else{
                    dp[i*(sumCost+1)+j]=std::min(w[i],dp[(i-1)*(sumCost+1)+j]);
                }
            }else{
                if(dp[(i-1)*(sumCost+1)+(j-cost[i])]!=ULLONG_MAX)
                    dp[i*(sumCost+1)+j]=std::min(dp[(i-1)*(sumCost+1)+j],dp[(i-1)*(sumCost+1)+(j-cost[i])]+w[i]);
            }
            if(j>ans && dp[i*(sumCost+1)+j]<=W){
                ans=j;
            }
        }
    }
    // print(dp,N,sumCost+1);
    std::cout<<ans<<std::endl;
}

Measured memory_bytes: 81248
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
string s[1000010];
int a[1000010],ad[1000010];
char str[1000010];
int sum=0;
priority_queue<PII> pq;
priority_queue<int> pqi;
vector< pair<int,PII> > v;
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		scanf("%s",&str);
		s[i]=str;
		int t=0,mn=0;
		for (int j=0;j<s[i].size();j++)
			t+=(s[i][j]=='(' ? 1 : -1),mn=min(mn,t);
		sum+=t,a[i]=mn,ad[i]=t;
	}
	if (sum)
	{
		printf("No");
		return 0;
	}
	for (int i=0;i<n;i++)
	{
		if (ad[i]>=0) pq.push(MP(a[i],ad[i]));
		else ad[i]*=-1,a[i]*=-1,v.push_back(MP(-(a[i]-ad[i]),MP(-a[i],ad[i])));
	}
	while (!pq.empty() && pq.top().Fst>=0)
		pqi.push(pq.top().Snd),pq.pop();
	while (!pqi.empty())
	{
		sum+=pqi.top(),pqi.pop();
		while (!pq.empty() && pq.top().Fst+sum>=0)
			pqi.push(pq.top().Snd),pq.pop();
	}
	if (!pq.empty())
	{
		printf("No");
		return 0;
	}
	sort(v.begin(),v.end());
	for (int i=0;i<v.size();i++)
	{
		//cout <<sum<<" "<<v[i].Fst<<" ##\n"; 
		if (sum<-v[i].Snd.Fst)
		{
			printf("No");
			return 0;
		}
		sum-=v[i].Snd.Snd;
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 55896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
std::vector<int> data{
    1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;

void solve(){
    cout<<data.at(k-1)<<endl;
}

int main(){
    cin>>k;

    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#define rep(i, a, n) for(int i = int(a);i < int(n);++i)
#define repe(i, a, n) for(int i = int(a);i <= int(n);++i)
#define repr(i, a, n) for(int i = int(a);i > int(n);--i)
#define reper(i, a, n) for(int i = int(a);i >= int(n);--i)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using namespace std;


string s;
int K;
set<string> sub;


void enumrate(){
	string subs;
	for(int i = 1;i <= SIZE(s);i++){
		for(int j = 0;j <= SIZE(s)-i;j++){
			for(int k = 0;k < i;k++){
				subs.pb(s[j+k]);
			}
			sub.insert(subs);
			subs = "";
		}
	}
}


string solve(){
	if(SIZE(s) <= 5){
		enumrate();
		int i = 0;
		for(auto it = sub.begin();;it++, i++)
			if(i == K-1) return *it;
		return "aaa";
	}
	else {
		set<char> setc;
		rep(i, 0, SIZE(s)) setc.insert(s[i]);
		for(auto c : setc){
			rep(i, 0, SIZE(s)){
				if(s[i] == c){
					string subs;
					rep(j, 0, 5){
						if(i+j >= SIZE(s)) break;
						subs.pb(s[i+j]);
						sub.insert(subs);
					}
					
				}
			}
		}
		int i = 0;
		for(auto it = sub.begin();;it++, i++)
			if(i == K-1) return *it;
		return "aaa";
	}
}


int main(){
	cin >> s;
	cin >> K;
	
	cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main(){
  int n;
  int k;
  cin >> n;
  int card[2*n];
  int mem[2*n];
  int h;
  int m;
  cin >> m;
  for(int i=0;i<2*n;i++) card[i] = i+1;
  for(int i=0;i<m;i++){
    cin >> k;
    if(k==0){
      for(int i=0;i<2*n;i++) mem[i] = card[i];
      for(int i=0;i<=2*n;i+=2){
	card[i] = mem[i/2];
	card[i+1] = mem[i/2+n];
      }
    }
    else if(k>=1&&k<=2*n-1){
      h = k;
      for(int i=0;i<k;i++) mem[i] = card[i];
      for(int i=0;i<2*n-k;i++){
	card[i] = card[h];
	h++;
    }
      h = 0;
      for(int i=2*n-k;i<2*n;i++){
	card[i] = mem[h];
	h++;
      }
    }
  }
  for(int i=0;i<2*n;i++) cout << card[i] << endl;
  return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    x, y = LI()
    a = [1, 3, 5, 7, 8, 10, 12]
    b = [4, 6, 9, 11]
    c = [2]
    if x in a and y in a:
        print("Yes")
        return
    if x in b and y in b:
        print("Yes")
        return
    if x in c and y in c:
        print("Yes")
        return
    print("No")
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 39152
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	ll k, x;
	cin >> k >> x;
	if (k * 500 >= x) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
typedef long long ll;
typedef long double ld;
const int MAXP = 13;
char S[5005];
int N;
pair<pair<int, int>, int> T[5005];
int sufrank[MAXP + 1][5005];
int P[5005];
// rank[i] is the rank of i-th suffix
void getSuffixArray() {
	for (int i = 0; i < N; ++i) sufrank[0][i] = S[i];
	for (int l = 1; l <= MAXP; ++l) {
		int len = 1 << (l - 1);
		for (int i = 0; i < N; ++i) {
			int nex = i + len < N ? sufrank[l - 1][i + len] : -1;
			T[i] = {{sufrank[l - 1][i], nex}, i};
		}
		sort(T, T + N);
		for (int i = 0; i < N; ++i) {
			if (i && T[i].first == T[i - 1].first)
				sufrank[l][T[i].second] = sufrank[l][T[i - 1].second];
			else sufrank[l][T[i].second] = i;
		}
	}
}
int main() {
	int K;
	scanf("%s%d", S, &K);
	N = strlen(S);
	getSuffixArray();
	for (int i = 0; i < N; ++i) {
		P[sufrank[MAXP][i]] = i;
	}
	set<string> has;
	for (int i = 0; i < N; ++i) {
		int p = P[i];
		string cur;
		for (int j = p; j < N; ++j) {
			cur += S[j];
			if (!has.count(cur)) {
				has.insert(cur);
			}
			if (has.size() == K) {
				printf("%s\n", cur.c_str());
				return 0;
			}
		}
	}
}


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

int main(){
  int x;
  cin>>x;
  if(x < 100){
  	cout<<0; return 0;
  }
  else if(x < 106){
  	cout<<1; return 0;
  }
  bool dp[x+1];
  fill(dp, dp+x+1, 0);
  for(int i = 100; i <= 105; i++)dp[i] = 1;
  
  for(int i = 106; i <= x; i++){
  	dp[i] = dp[i-100] || dp[i-101] || dp[i-102] || dp[i-103] || dp[i-104] || dp[i-105];
  }
  
  cout<< dp[x] << endl;
  
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair
typedef long long ll;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll p)
{
    if (p == 0)
        return 1;
    if (!(p % 2))
    {
        ll halfP = p / 2;
        ll half = modpow(a, halfP);
        return half * half % mod;
    }
    else
    {
        return a * modpow(a, p - 1) % mod;
    }
}

ll comb(int a, int b)
{
    if (b > a - b)
        return comb(a, a - b);
    ll ansMul = 1;
    ll ansDiv = 1;
    for (int i = 0; i < b; i++)
    {
        ansMul *= a - i;
        ansDiv *= i + 1;
        ansMul %= mod;
        ansDiv %= mod;
    }
    ll ans = ansMul * modpow(ansDiv, mod - 2) % mod;
    return ans;
}

/*
int num = 200010;
vector<ll> fact(num), ifact(num);
fact[0] = 1;
fact[1] = 1;
for (int i = 2; i < num; i++) {
    fact[i] = fact[i-1] * i;
    fact[i] %= mod;
}
for (int i = 0; i < num; i++) {
    ifact[i] = modpow(ifact[i], mod-2);
    ifact[i] %= mod;
}
*/

int main() {
    int N, M; cin >> N >> M;
    vector<int> a(N);
    rep(i, 2*M) {
        int x; cin >> x;
        a[x-1]++;
    }
    rep(i, N) {
        if (a[i] % 2) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int GCD(int a, int b) {
	if (!b) return a;
	else {
		return GCD(b, a % b);
	}
}

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

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

	vector<int> A(N), B(N);
	for (int i = 1; i < N; i++) {
		A[i] = GCD(A[i - 1], v[i - 1]);
	}
	for (int i = N - 2; i >= 0; i--) {
		B[i] = GCD(B[i + 1], v[i + 1]);
	}

	vector<int> C(N);
	for (int i = 0; i < N; i++) {
		C[i] = GCD(A[i], B[i]);
	}
	sort(C.begin(), C.end());

	cout << C[N - 1] << endl;
}

Measured memory_bytes: 4820
package main

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

func main() {
	s := IOInitialize()
	s.Buffer([]byte{}, math.MaxInt64)
	N := Int(s)
	M := Int(s)
	S := String(s)
	T := String(s)
	sstr := strings.Split(S, "")
	tstr := strings.Split(T, "")
	longNum := 0
	longStr := []string{}
	shortNum := 0
	shortStr := []string{}
	if M > N {
		longNum = M
		longStr = tstr
		shortNum = N
		shortStr = sstr
	} else {
		longNum = N
		longStr = sstr
		shortNum = M
		shortStr = tstr
	}

	if sstr[0] != tstr[0] {
		fmt.Println(-1)
		return
	}
	L := M * N / gcd(M, N)
	strMap := map[int]string{}
	/*
		strs := make([]string, L)
			for i := 0; i < L; i++ {
				strs[i] = "1"
			}
	*/
	for i := 0; i < longNum; i++ {
		strCnt := L/longNum*i + 1
		//strs[strCnt-1] = longStr[i]
		strMap[strCnt-1] = longStr[i]
	}
	for i := 0; i < shortNum; i++ {
		strCnt := L/shortNum*i + 1
		if _, ok := strMap[strCnt-1]; ok {
			if strMap[strCnt-1] != shortStr[i] {
				fmt.Println(-1)
				return
			}
		}
		/*
			if strs[strCnt-1] == "1" {
				strs[strCnt-1] = shortStr[i]
			} else {
				if strs[strCnt-1] != shortStr[i] {
					fmt.Println(-1)
					return
				}
			}
		*/
	}
	fmt.Println(L)

	/*
			for {
				cnt++
				if cnt%N != 0 {
					continue
				}
				if cnt%M != 0 {
					continue
				}
				L := cnt
				strs := make([]string, L)
				for i := 0; i < L; i++ {
					strs[i] = "1"
				}
				for i := 0; i < longNum; i++ {
					strCnt := L/longNum*i + 1
					strs[strCnt-1] = longStr[i]
				}
				for i := 0; i < shortNum; i++ {
					strCnt := L/shortNum*i + 1
					if strs[strCnt-1] == "1" {
						strs[strCnt-1] = shortStr[i]
					} else {
						if strs[strCnt-1] != shortStr[i] {
							fmt.Println(-1)
							return
						}
					}
				}
				break
			}
		fmt.Println(cnt)
	*/
}

func gcd(m int, n int) int {
	temp := 0
	for m%n != 0 {
		temp = n
		n = m % n
		m = temp
	}
	return n
}

func max(nums ...int) int {
	res := nums[0]
	for _, num := range nums {
		if res < num {
			res = num
		}
	}
	return res
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}

func scanNums(s *bufio.Scanner, len int) (nums []int) {
	for i := 0; i < len; i++ {
		num := Int(s)
		nums = append(nums, num)
	}
	return
}

func scanstrings(s *bufio.Scanner, len int) (strs []string) {
	for i := 0; i < len; i++ {
		str := String(s)
		strs = append(strs, str)
	}
	return
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, m;
  cin >> n >> m;
  set <ll> s;
  vector <ll> v;
  ll a;
  rep(i, n) {
    cin >> a;
    s.insert(a);
  }
  rep(i, m) {
    cin >> a;
    if (s.count(a)) {
      v.push_back(a);
    } else {
      s.insert(a);
    }
  }
  sort(v.begin(), v.end());
  cout << v.size() << ' ' << s.size() << endl;
  rep(i, v.size()) {
    cout << v.at(i) << endl;
  }
  for (auto value : s) {
    cout << value << endl;
  }
}


Measured memory_bytes: 13240
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int n,ans = 0;
int now = -2e9;
vector<pair<int,int>> v;

int main(){
 cin >> n;
 rep(i,n){
   ll x,l = 0; cin >> x >> l;
   v.push_back(make_pair(x+l,x-l));
 }

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

 rep(i,n){
   if(v[i].second < now){
     continue;
   }
   else{
     now = v[i].first;
     ans++;
   }
 }
 cout << ans;
}

Measured memory_bytes: 1400
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] map = new int[N+1];
        for (int i = 0; i < N; i++) {
        	map[i] = sc.nextInt();
        }
        
        map[N] = 0;
        
        int ans = 0;
        int now = map[0];
        for (int i = 1; i < N+1; i++) {
        	if (now > map[i]) {
        		ans += now - map[i];
        	}
        	now = map[i];
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int M=sc.nextInt();
    int m=sc.nextInt();
    int N=sc.nextInt();
    if(!(M==N)){System.out.println(1);}
    else{System.out.println(0);}
  }
}

Measured memory_bytes: 23888
N = int(input())
M = list(map(int, input().split()))
M = sorted(M)
count = 0
for i in range(N):
  a = M[i]
  for j in range(i+1, N):
    b = M[j]
    upper = a+b
    l, r = j, N
    while (r - l) > 1:
      c = (l + r) // 2
      if M[c] < upper:
        l = c
      else:
        r = c  
    #print(count, j, l, r)
    count += l - j
      
print(count)

Measured memory_bytes: 42732
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#include <iomanip>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;

LL dp[2005][2005];
LL sum[2005][2005];
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> A(n),B(m);
    for(int i = 0; i < n; i++)
        cin >> A[i];
    for(int i = 0; i < m; i++)
        cin >> B[i];
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
        {
            if(A[i-1] == B[j-1])
                dp[i][j] = sum[i-1][j-1]+1;
            else    dp[i][j] = 0;
            sum[i][j] = (sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j]) % Mod;
            if(sum[i][j] < 0) 
                sum[i][j] += Mod;
        }
    cout << sum[n][m]+1 << endl;
    return 0;
}

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


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

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//C++14 (GCC 5.4.1)
int main() {
    string S;
    cin >>S;

    
    //-----------------------------------
    int ans=0,tmp=0;
    rep(i,S.size()){
        if(S[i]=='A' || S[i]=='T' || S[i]=='G' || S[i]=='C'){
            tmp++;
            chmax(ans,tmp);
        }else{
            tmp=0;
        }
    }

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

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

char s[405][405];
int  r, c, ans = 0,has,cnt ; 
int dx[4] = {0, 0, 1, -1} ; 
int dy[4] = {1, -1, 0, 0} ; 
bool vis[405][405];

bool ok(int i,int j){
    if ( i<1 or i>r or j<1 or j>c or vis[i][j] ) return  false ; 
    return  true ; 
}

void dfs( int x, int y, int cur ){ 
    if (vis[x][y])  return ; 
    vis[x][y] = true ; 
    char comp =  cur ? '#' : '.' ; 
    if (comp == '#') cnt++ ; 
    else has++;
    for (int c=0;c<4;c++){
        int  i = x + dx[c] ; 
        int  j = y + dy[c] ; 
        if (ok(i,j) and s[i][j] == comp) dfs(i,j,!cur); 
    }
}

signed main()
{
    cin >> r >> c ; 
    for (int i=1;i<=r;i++) cin >> s[i]+1;
    for (int i=1;i<=r;i++){
        for (int j=1;j<=c;j++){
            cnt = 0, has = 0;
            if (s[i][j] == '#' and !vis[i][j]) dfs(i,j,0); 
            ans += cnt*has;
        }
    }
    cout << ans << endl;
    return 0; 
}


Measured memory_bytes: 16332
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int h, n;
  scanf("%d %d\n", &h, &n);
  int a = 0;
  int b;
  for (int i = 0; i < n; i++) {
    scanf("%d\n", &b);
    a += b;
  }
  if (h <= a) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  string s,t;
  cin >> s >> t;
  int ans = 0;
  rep(i,s.size()) {
    if(s[i] != t[i]) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3856
while True:
    try:
        s=list(str(input()))
        j=0
        i=0
        for n in range(len(s)-2):
            if s[n]=='J' and s[n+1]=='O' and s[n+2]=='I':
                j+=1
            if s[n]=='I' and s[n+1]=='O' and s[n+2]=='I':
                i+=1
        print(j)
        print(i)
    except:
        break


Measured memory_bytes: 5596
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    std::ios::sync_with_stdio(false);
    ll n, m ,k;
    cin >> n >> m >> k;
    cout << max((ll)0, (n - 2) * (k - m) + 1) << "\n";
    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  1234
//
//  Created by Moha Jain on 14/04/20.
//  Copyright © 2020 Moha Jain. All rights reserved.
//
 
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<math.h>
#include <iomanip>
#include <numeric>
#define _USE_MATH_DEFINES

using namespace std;


int main()
{
    unordered_map<long long int,long long int>mp;
    
    long long int n;cin>>n;
    
    long long int start = 7;
    long long int count = 1;
    long long int ans=0;
    while(1)
    {
        if(start%n==0) {ans=count;break;}
        if(mp[start%n]==0)mp[start%n]=1;
        else {ans=-1;break;}
        
        start=(start*10+7)%n;
        count++;
    }
    
    cout<<ans<<endl;
}




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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).bigin(), (c).end())

int main()
{
    int x, y, z;
    cin >> x >> y >> z;

    cout << (x - z) / (y + z) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define int long long 
#define pii pair<int,int>
#define ub upper_bound
#define lb lower_bound
#define all(x) x.begin(),x.end()
#define ld long double
#define fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
signed main(){
    fast;
    int a;
    cin>>a;
    int b;
    cin>>b;
    char ch;
    cin>>ch;
    int f;
    cin>>f;
    b = b*100;
    b+=f;
    int ans = a * b;
    ans/=(100ll);
    cout<<ans;
}

Measured memory_bytes: 3652
X = int(input())
if X % 7 == 0:
  print('thu')
if X % 7 == 1:
  print('fri')
if X % 7 == 2:
  print('sat')
if X % 7 == 3:
  print('sun')
if X % 7 == 4:
  print('mon')
if X % 7 == 5:
  print('tue')
if X % 7 == 6:
  print('wed')



Measured memory_bytes: 5592
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int x;
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	int c = 0;
	sort(a, a + 3);
	c += (a[1] - a[0]);
	c += (a[2] - a[1]);
	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
const double PI=3.14159265358979323846;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long R;
    cin >> R;
    cout << fixed << setprecision(10) << 2*PI*R << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N, M; cin >> N >> M;
  queue<int> A[N];
  rep(i,N) rep(j,M) { int tmp; cin >> tmp; tmp--; A[i].push(tmp);}

  int result = INF;
  set<int> used;
  rep(i,M) {
    int count[M] = {};
    rep(i,N) {
      while(used.find(A[i].front())!=used.end()) A[i].pop();
      count[A[i].front()]++;
    }
    int m = 0, num = 0;
    for (auto i: used) count[i] = 0;
    rep(i,M) if (count[i]>m) { m = count[i]; num = i; }
    used.insert(num);
    result = min(result, m);
    rep(i,N) if (A[i].front()==num) A[i].pop();
    // rep(i,M) cout << count[i] << " "; cout << "->" << m ; cout << endl;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QUEUE_SIZE 1000000  /* キューデータ数の最大値 */

struct qq {
    char name[100];
    int t;
};

int head, tail;
struct qq Q[QUEUE_SIZE];
 
void enqueue(char *a, int b){
    strcpy(Q[tail].name, a);
    //Q[tail].name = a;
    Q[tail++].t = b;
}   
 
struct qq dequeue(){
    head++;
    return Q[head - 1];
}

int main(void)
{
    head = 0;
    tail = 0;

    int n, q, input_time;
    int i = 0;
    int sum_t = 0;
    char input_name[100];

    scanf("%d %d", &n, &q);

    while(i < n) {
        scanf("%s %d", &input_name, &input_time);
        enqueue(input_name, input_time);
        i++;
    }

    while(head != tail) {
        struct qq head_element = dequeue();
        if (head_element.t > q) {
            enqueue(head_element.name, head_element.t - q);
            sum_t += q;
        } else {
            printf("%s %d\n", head_element.name, head_element.t + sum_t);
            sum_t += head_element.t;
        }
    }
 
    return 0;
}


Measured memory_bytes: 20944
while True:
    n, m, a = map(int, raw_input().split())

    if n == 0 and m == 0 and a == 0:
        break

    hl = [map(int, raw_input().split()) for _ in range(m)]
    hl.sort(reverse=True)

    ans = a

    for i in range(m):
        if ans == hl[i][1]:
            ans = hl[i][2]
        elif ans == hl[i][2]:
            ans = hl[i][1]

    print ans



Measured memory_bytes: 4908
#include <stdio.h>

int MAX(int a,int b){return a<b?b:a;}

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

  scanf("%d %d %d\n", &a, &b, &c);
  scanf("%d", &k);

  max = MAX(MAX(a, b), c);
  if(a == max){
    count += b + c;
  }
  else if(b == max){
    count += a + c;
  }
  else if(c == max){
    count += a + b;
  }

  for(i = 1; i <= k; i++){
    max = max * 2;
  }
  count += max;

  printf("%d", count);
}


Measured memory_bytes: 128