akhauriyash/Code-Regression huggingface dataset:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
s = list(input())
k = I() - 1
p = s[k]
for i in range(n):
    if p != s[i]:
        s[i] = '*'
print(*s,sep='')


Measured memory_bytes: 5212
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
int main()
{
    int h,n,w;
    int max,sum;
    scanf("%d %d %d",&h,&n,&w);
    if(h>n)
        max=h;
    else
        max=n;
    if(w%max==0)
        sum=w/max;
    else
        sum=w/max+1;
    printf("%d\n",sum);
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var R = l[0]; var G = l[1]; var B = l[2]; var n = l[3];

        var res = 0;
        for (var r = 0; 3001 > r; r++)
            for (var g = 0; 3001 > g; g++)
            {
                var b = ((n - (r * R + g * G)) % B == 0 && n - (r * R + g * G) >= 0 || n - (r * R + g * G) == 0) ? (n - (r * R + g * G)) / B : -1;
                if (b == -1) continue;
                res++;
            }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 28176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>
#include <cstring>


#line 1 "lib/modint.hpp"



#include <iostream>

// Modint
struct Mint {
    static const long long mod = 998244353;
    long long val;

    Mint() { val = 0; }
    Mint(long long a) { val = a; verify_value(); }

    void verify_value() {
        if (val >= mod) val %= mod;
        if (val < 0) val %= mod, val += mod;
    }

    Mint pow(long long p) const {
        Mint cur = Mint(val), ret = 1;
        while (p > 0) {
            if (p & 1) ret *= cur;
            cur *= cur;
            p >>= 1LL;
        }
        return ret;
    }
    Mint inv() const {
        if (val == 0)
            std::cerr << "WARNING: inv() is called with 0." << std::endl;
        return pow(mod - 2);
    }

    Mint operator+() const { return *this; }
    Mint operator-() const { return Mint(mod - val); }

    Mint operator+=(const Mint &a) {
        val += a.val;
        if (val >= mod) val -= mod;
        return Mint(val);
    }
    Mint operator*=(const Mint &a) {
        val *= a.val;
        if (val >= mod) val %= mod;
        return Mint(val);
    }
    Mint operator-=(const Mint &a) { return *this += -a; }
    Mint operator/=(const Mint &a) { return *this *= a.inv(); }

    Mint operator++() { return *this += Mint(1); }
    Mint operator--() { return *this -= Mint(1); }
    Mint operator++(int) {
        Mint ret = *this;
        ++(*this);
        return ret;
    }
    Mint operator--(int) {
        Mint ret = *this;
        --(*this);
        return ret;
    }

    operator long long() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
    long long ret = a.val + b.val;
    if (ret >= Mint::mod) ret -= Mint::mod;
    return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
    long long ret = a.val * b.val;
    if (ret >= Mint::mod) ret %= Mint::mod;
    return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

std::ostream &operator<<(std::ostream &out, const Mint &a) { return out << a.val; }
std::istream &operator>>(std::istream &in, Mint &a) {
    in >> a.val;
    a.verify_value();
    return in;
}

Mint pow(Mint a, long long b) {
    return a.pow(b);
}


int main() {
    int n, s; std::cin >> n >> s;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    std::vector<Mint> dp(s + 2);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = s - 1; j >= 0; j--) {
            if (j + a[i] > s) continue;
            Mint c = 1;
            if (j + a[i] == s) c *= n - i;
            if (j == 0) c *= i + 1;
            dp[j + a[i]] += c*dp[j];
        }
    }
    std::cout << dp[s] << std::endl;
    return 0;
}

Measured memory_bytes: 256
n,x,y = map(int,input().split())
x,y = x-1,y-1
ans = [0]*(n)

for i in range(n):    
  for j in range(i+1,n):
    sp = min(abs(j-i), abs(x-i)+abs(j-y)+1, abs(y-i)+1+abs(j-x))
    ans[sp]+=1
    
for a in ans[1:]:
  print(a)

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

    divisors.sort(reverse=True)
    return divisors

N,X=map(int,input().split())
x=[abs(X-int(_)) for _ in input().split()]
x.sort()
divisor = make_divisors(x[0])
result=1
for d in divisor:
    for elem in x:
        if elem%d!=0:
            break
        if elem==x[-1]:
            result=d
            break
    if result!=1:
        break
print(result)
     

Measured memory_bytes: 62576
#include<iostream>
using namespace std;
int main(){
  int a[5],tnum,mi=10,sum=0;
  bool f=false;
  cin >> a[0];
  tnum=a[0];
  mi=a[0]%10;
  for(int i=1;i<5;i++){
    cin >> a[i];
    if(mi>a[i]%10&&a[i]%10!=0){
      mi = a[i]%10;
      tnum=a[i];
    }
  }

  for(int i=0;i<5;i++){
    if((f==false&&a[i]==tnum)||a[i]%10==0){
      sum+=a[i];
      if(a[i]==tnum)  f=true;
    }else{
      sum += (a[i]/10)*10 + 10;
    }
  }
  cout << sum <<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
//using ll=long long;

int main(){
    int D;
    cin >> D;
    int count = 0;
    int num = D;
    for(int i = 0; i < 4; ++i){
        int tmp = num % 10;
        if(tmp == 2) count++;
        num = num / 10;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		vector<vector<int> > magi(n,vector<int>(n,0));
		int a=(n-1)/2;
		int b=(n+1)/2;
		magi[a][b]=1;
		for(int i=2;i<=n*n;i++){
			while(1){
				a++;
				b++;
				if(a>=n) a=0;
				if(b>=n) b=0;
				if(magi[a][b]==0){
					magi[a][b]=i;
					break;
				}else{
					while(magi[a][b]!=0){
						a--;
						b++;
						if(a<0) a=n-1;
						if(b>=n) b=0;
					}
					magi[a][b]=i;
					break;
				}
			}
		}

		for(int j=0;j<n;j++){
			for(int i=0;i<n;i++){
				if(magi[i][j]>=1 && magi[i][j]<=9) cout<<"   ";
				else if(magi[i][j]>=10 && magi[i][j]<100) cout<<"  ";
				else cout<<" ";
				cout<<magi[i][j];
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1220
import sys
sys.setrecursionlimit(10**9 + 7)

  
def dfs1(pos, par):
    """その頂点の部分木内で最も遠い頂点(葉)までの距離を求める""" 
    for next_pos, cost in graph[pos]:
        if next_pos == par:
            continue
        dfs1(next_pos, pos)
        distance1[pos] = max(distance1[pos], distance1[next_pos] + cost)
    return


def dfs2(pos, dist_par, par):
    """全方位木DP""" 
    tmp = [(0, -1), (0, -1)]
    for next_pos, cost in graph[pos]:
        if next_pos == par:
            tmp.append((dist_par + cost, next_pos))
        else:
            tmp.append((cost + distance1[next_pos], next_pos))
    tmp = sorted(tmp, reverse = True)
    distance2[pos] = tmp[0][0] + tmp[1][0]
    for next_pos, cost in graph[pos]: 
        if next_pos == par:
            continue
        else:
            if tmp[0][1] != next_pos:
                dfs2(next_pos, tmp[0][0], pos)
            else:
                dfs2(next_pos, tmp[1][0], pos)
    

n = int(input())
info = [list(map(int, input().split())) for i in range(n-1)]
graph = [[] for i in range(n)]
for i in range(n-1):
    a, b, cost = info[i]
    graph[a].append((b, cost))
    graph[b].append((a, cost))

distance1 = [0]*n
distance2 = [0]*n
dfs1(0, -1)
dfs2(0, 0, -1)
print(max(distance2))


Measured memory_bytes: 191956
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int W; int H;
	while(~scanf("%d%d", &W, &H)) {
		int N;
		scanf("%d", &N);
		int pos[2] = {};
		int ans = 0;
		rep(i, N) {
			int p;
			scanf("%d", &p);
			++ pos[p];
			if(pos[1] < W - 2)
				ans += pos[0] == pos[1];
			else if(pos[1] == W - 2)
				ans += pos[0] == pos[1] || pos[0] == pos[1] + 2;
			else if(pos[1] < W + H - 5)
				ans += pos[0] == pos[1] + 2;
			else if(pos[1] == W + H - 5)
				ans += pos[0] == pos[1] + 2 || pos[0] == pos[1] + 4;
			else
				ans += pos[0] == pos[1] + 4;
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;

const int MAXN = 2*1e5 + 10;

struct line{

	ll a,b;

	line(ll _a,ll _b){
		a = _a;
		b = _b;
	}

	ll get(ll x){return a*x + b;}

	ld get(ld x){return a*x + b;}

};

ld inter(line l1,line l2){

	return -(l1.b - l2.b)/ld(l1.a - l2.a);

}

bool useless(line l1,line l2,line l3){
	return inter(l1,l3) < inter(l2,l1);
}

vector<line> CHT;
ll dp[MAXN],h[MAXN],C;
int chtPtr,N;

void add(line l){

	while(CHT.size() >= 2 && useless(CHT[CHT.size()-2],CHT.back(),l) ){
		CHT.pop_back();
	}

	CHT.push_back(l);

}

ll query(ll x){

	if(chtPtr >= CHT.size()) chtPtr = CHT.size() - 1;

	while(chtPtr + 1 < CHT.size() && CHT[chtPtr].get(x) > CHT[chtPtr+1].get(x) ){
		chtPtr++;
	}

	return CHT[chtPtr].get(x);

}

int main(){

	scanf("%d %lld",&N,&C);

	for(int i = 1;i<=N;i++){
		scanf("%lld",&h[i]);
	}

	add(line(-2*h[1], h[1]*h[1] + C ));

	for(int i = 2;i<=N;i++){

		dp[i] = query(h[i]) + h[i]*h[i];
		add(line(-2*h[i], h[i]*h[i] + dp[i] + C ));

	}

	printf("%lld\n",dp[N]);

	return 0;

}

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

int main(){
	int n;
	cin >> n;
	vector<int> d(n);
	for(auto& e : d) cin >> e;
	sort(d.begin(), d.end());
	int counter = 1;
	for(int i=0; i<n-1; ++i){
		if(d[i]!=d[i+1]) counter++;
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
ps = gets.split.map(&:to_i)

exp = Array.new(1000)
sum = 0.0
(1..1000).each do |i|
  sum += i.to_f
  exp[i] = sum/i
end


ans = 0
val = 0
(0..n-1).each do |i|
  val += exp[ps[i]]
  next if i < k - 1

  if i > k - 1
    val -= exp[ps[i-k]]
  end
  ans = [ans, val].max
end

puts ans


Measured memory_bytes: 18692
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    double a, b;
    cin >> a >> b;
    if (a > b) out("GREATER");
    else if (a < b) out("LESS");
    else out("EQUAL");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;
int main(){
    string s;
    cin >> s;

    string ss = s.substr(5, 2);
    if (atoi(ss.c_str()) < 5){
        cout << "Heisei" << endl;
    } else{
        cout << "TBD" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
while True:
    a, op, b = map(str,input().split())
    if op == '+':
        print(int(a) + int(b))
    elif op == '-':
        print(int(a) - int(b))
    elif op == '*':
        print(int(a) * int(b))
    elif op == '/':
        print(int(a) // int(b))
    elif op == '?':
        break

Measured memory_bytes: 7504
N = int(input())
listA = input().split()
listA = [int(i) for i in listA]
listA.sort()
listA.reverse()
side1 = 0
side2 = 0

# print(side1, side2, listA)
if N == 1 or N == 2 or N == 3:
    pass
else:
    while len(listA) != 1:
        if listA[0] == listA[1]:
            if side1 == 0:
                side1 = listA[0]
                listA.pop(0)
                listA.pop(0)
            else:
                side2 = listA[0]
                break
        else:
            listA.pop(0)
        # print(side1, side2, listA)

print(side1 * side2)
# print(side1, side2, listA)

Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}


int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    char a,b;cin>>a>>b;
    if(a<b) cout<<'<';
    else if(a>b) cout<<'>';
    else cout<<'=';
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")

# https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/all/DSL_1_B
import sys,collections
sys.setrecursionlimit(1000000)
INF = float("inf")

N = int(sys.stdin.readline())
A = tuple(map(int,sys.stdin.readline().split())) # single line with multi param

cum = [0]*(N+1)
d = collections.defaultdict(int)
d[0]=1
ret = 0
for i in range(N):
    cum[i+1] = cum[i]+A[i]
    if cum[i+1] in d:
        ret += d[cum[i+1]]
    d[cum[i+1]] += 1
#print(cum,d)
print(ret)


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    FIO;
    ll a, b;
    cin >> a >> b;
    ll s = a;
    ll c = 0;
    for (ll i = 1; ; i++) {
        if(s > b) {
            cout << c << endl;
            return 0;
        }
        else {
            c++;
            s = s * 2;
        }
    }
}


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

const long long INF = (long long) 1e18;

bool isOverflow(long double a, long double b)
{
    return a > INF * 2 / b;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int n;
    cin >> n;

    long long ans = 1;

    while (n--)
    {
        long long x;
        cin >> x;

        if (x == 0)
        {
            cout << 0 << "\n";
            return 0;
        }

        if (ans == -1)
            continue;

        if (isOverflow(ans, x) || ans * x > INF)
            ans = -1;
        else
            ans *= x;
    }

    cout << ans << "\n";
    return 0;
}


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

using namespace std;
using ll = long long;


int main()
{
    ll n, m, k; cin >> n >> m >> k;
    vector<ll> a(n + 1), b(m + 1);
    for(ll i = 0; i < n; i++) {
        cin >> a[i + 1];
        a[i + 1] += a[i];
    }
    for(ll i = 0; i < m; i++) {
        cin >> b[i + 1];
        b[i + 1] += b[i];
    }
    b.emplace_back(1e10);
    a.emplace_back(1e18);

    ll nax = 0;
    for(ll i = 0; i <= n; i++) {
        if(k - a[i] < 0)continue;
        auto itr = upper_bound(b.begin(), b.end(), k - a[i]);
        ll cur = 0;
        cur += itr - b.begin() - 1;
        cur += i;
        nax = max(nax, cur);
    }
    cout << nax << endl;
}

Measured memory_bytes: 8012
#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 < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

ll input[404][404];

const ll MAX_N = 404*404;

struct UnionFind{
    int N;
    int par[MAX_N];

    UnionFind(int N): N(N){
        for (int i=0;i<N;i++){
            par[i] = i;
        }
    }

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

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx==ry) return;
        par[rx] = ry;
    }

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

int main(){
	ll H, W;
	cin >> H >> W;
	REP(i, H){
		string S;
		cin >> S;
		REP(j, W){
			input[i][j] = (S[j]=='#'?1:0);
		}
	}

	ll N = H*W;
	UnionFind uf(N);
	REP(i, H){
		REP(j, W-1){
			ll hidari = W*i+j;
			ll migi = W*i+j+1;
			if(input[i][j]!=input[i][j+1]){
				uf.unite(hidari, migi);
			}
		}
	}
	REP(i, H-1){
		REP(j, W){
			ll ue = W*i+j;
			ll shita = W*i+j+W;
			if(input[i][j]!=input[i+1][j]){
				uf.unite(ue, shita);
			}
		}
	}

	ll res = 0;
	//REP(i, N) uf.root(i);
	vector<ll> white(N, 0), black(N, 0);
	REP(i, N){
		if(input[i/W][i%W]==1){
			black[uf.root(i)]++;
		}else{
			white[uf.root(i)]++;
		}
	}
	//vprint(black);
	//vprint(white);
	REP(i, N) res += black[i]*white[i];
	cout << res << endl;
    return 0;
}

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

int main() {
    long long N, K;
    cin >> N >> K;
    vector<int> A(N, 0);

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

    int now_city = 0;
    long long roop_town, rest;
    bool flag = false;
    vector<int> count(N, 0);

    for(long long i = 0; i < K; i++){
        now_city = A[now_city];
        if(count[now_city] != 0){
            roop_town = i - count[now_city];
            rest = K - i - 1;
            flag = true;
            break;
        }
        count[now_city] = i;
    }
    if(flag){
        rest = rest % roop_town;
        for(int j = 0; j < rest; j++){
            now_city = A[now_city];
        }
    }

    cout << now_city + 1 << endl;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n;cin>>n;
    LL result = 0;
    REP(i,n){
        int a;cin>>a;
        if(i%2==1){
            continue;
        }
        if(a%2==0){
            continue;
        }
        //cerr<<i<<" "<<a<<endl;
        result++;
    }
    cout<<result<<endl;
    
	return;
}

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

Measured memory_bytes: 3608
ans_n = 0
ans_a = 0
ans_r = 0
ans_o = 0
while True:
    #辺の長さの入力
    a, b, c = map(int, input().split())
    #辺の長さの並び替え
    l = sorted([a, b, c])
    f = l[0]
    s = l[1]
    t = l[2]
    #ここから条件分岐
    if t >= f + s:
        break
    elif t ** 2 < f ** 2 + s ** 2:
        ans_n += 1
        ans_a += 1
    elif t ** 2 == f ** 2 + s ** 2:
        ans_n += 1
        ans_r += 1
    elif t ** 2 > f ** 2 + s ** 2:
        ans_n += 1
        ans_o += 1
print(str(ans_n) + " " + str(ans_r) + " " + str(ans_a) + " " + str(ans_o))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x,y,z;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};

vector<int> v[5555];
//bitset<4001000> b;
int a,c,i,b,k,d,n,m,e;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[5555];
int o[5400];
int dx[10]={0,1,0,-1},dy[10]={1,0,-1,0},dz[10]={0,0,0,0,1,-1};

long long x,y,z,mod=1000000007;
P u[1111];
double j[111];

stack<int> s;
queue<int> q;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int > p;
//list<int> l;
string r,r1,r2;
//char r[333][333];


bool as(P a,P b)
{
    if(a.x!=b.x) return a.x<b.x;
    return a.y>b.y;
}



int main()
{
    cin>>r>>r1>>r2;
    if(r[r.size()-1]==r1[0]&&r1[r1.size()-1]==r2[0])
        puts("YES");
    else puts("NO");
}


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a*b < c*d){cout << c*d << endl;}
    else if(a*b > c*d){cout << a*b << endl;}
    else if(a*b == c*d){cout << c*d << endl;}

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
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")

#solve
def solve():
    n = II()
    s = S()
    dpr = [0] * (n + 1)
    dpg = [0] * (n + 1)
    dpb = [0] * (n + 1)
    for i in range(n):
        dpr[i + 1] = dpr[i]
        dpg[i + 1] = dpg[i]
        dpb[i + 1] = dpb[i]
        if s[i] == "R":
            dpr[i+1] += 1
        elif s[i] == "G":
            dpg[i+1] += 1
        else:
            dpb[i + 1] += 1
    ans = 0

    for i in range(1, n - 1):
        if s[i] == "R":
            ans += dpg[i] * (dpb[-1] - dpb[i+1])
            ans += dpb[i] * (dpg[-1] - dpg[i+1])
        elif s[i] == "G":
            ans += dpb[i] * (dpr[-1] - dpr[i+1])
            ans += dpr[i] * (dpb[-1] - dpb[i+1])
        else:
            ans += dpg[i] * (dpr[-1] - dpr[i + 1])
            ans += dpr[i] * (dpg[-1] - dpg[i + 1])
    for j in range(1, n - 1):
        for i in range(1, j + 1):
            if j + i >= n:
                continue
            if s[j-i] != s[j] and s[j] != s[j + i] and s[j-i] != s[j + i]:
                ans -= 1
    print(ans)
                
    return


#main
if __name__ == '__main__':
    solve()


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

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX / 2 + 2], R[MAX / 2 + 2];

llong merge(int A[], int left, int mid, int right) {
  int i, j, k;
  llong cnt = 0;
  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ) {
    if ( L[i] <= R[j] )
      A[k] = L[i++];
    else {
      A[k] = R[j++];
      cnt += n1 - i;
    }
  }
  return cnt;
}

llong mergeSort(int A[], int left, int right) {
  int mid;
  llong v1, v2, v3;
  if ( left + 1 < right ) {
    mid = (left + right) / 2;
    v1 = mergeSort(A, left, mid);
    v2 = mergeSort(A, mid, right);
    v3 = merge(A, left, mid, right);
    return v1 + v2 + v3;
  } else return 0;
}

int main() {
  int A[MAX], n, i;

  cin >> n;
  for ( i = 0; i < n; i++ )
    cin >> A[i];

  llong ans = mergeSort(A, 0, n);
  cout << ans << endl;

  return 0;
}


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

int main() {
  string s, ans;
  cin >> s;
  for (int i=0; i < s.size(); i++){
    if (s.at(i)=='B'){
      for (int j=0; j<i; j++){
        if(s.at(i-j-1)!='B'){
          s.at(i-j-1)='B';
          break;
        }
      }
    }
  }
  for (int i=0; i<s.size();i++){
    if (s.at(i)!='B'){
      ans +=s.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
from collections import Counter, deque

N, K = map(int, input().split())
A = list(map(int, input().split()))
INF = 10**18

cnt = Counter()
cnt[0] = 1
que = deque([0])
sumR = 0
ans = 0
for right, a in enumerate(A, start=1):
    if len(que) >= K:
        cnt[que.popleft()] -= 1
    sumR = (a + sumR) % K
    D = (sumR - right) % K
    ans += cnt[D]
    cnt[D] += 1
    que.append(D)
print(ans)


Measured memory_bytes: 39084
while True:
    try:
        A = map(int,input().split())
        ls_A = list(A)
        B = map(int,input().split())
        ls_B = list(B)
        h = 0
        b = 0
        for i in range(len(ls_A)):
            if ls_A[i] == ls_B[i]:
                h += 1
        if ls_A[0] == ls_B[1]:
            b += 1
        if ls_A[0] == ls_B[2]:
            b += 1
        if ls_A[0] == ls_B[3]:
            b += 1
        if ls_A[1] == ls_B[0]:
            b += 1
        if ls_A[1] == ls_B[2]:
            b += 1
        if ls_A[1] == ls_B[3]:
            b += 1
        if ls_A[2] == ls_B[0]:
            b += 1
        if ls_A[2] == ls_B[1]:
            b += 1
        if ls_A[2] == ls_B[3]:
            b += 1
        if ls_A[3] == ls_B[0]:
            b += 1
        if ls_A[3] == ls_B[1]:
            b += 1
        if ls_A[3] == ls_B[2]:
            b += 1   
        print(h,b)
    except EOFError:
        break


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int NS = 1e5 + 100;
int N, m, a[NS];
typedef pair <int, int> cn;

int main() {
	ll sum = 0;
	cin >> N >> m;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	sort(a, a + N);
	cn z[m];
	for (int i = 0; i < m; ++i) {
		cin >> z[i].first >> z[i].second;
	}
	sort(z, z + m, [](const cn &p1, const cn &p2) {
			return p1.second < p2.second;
			});
	int i = 0;
	--m;
	for (; i < N; ++i) {
		if (a[i] >= z[m].second) { break; }
		sum += z[m].second;
		if (z[m].first == 1) {
			if (m-- == 0) {
				++i;
				break;
			}
			continue;
		}
		z[m].first -= 1;
	}
	for (;i < N; ++i) {
		sum += a[i];
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
struct man{
	int time;
	int point;
};
int main() {
	int n;
	while (cin >> n, n){
		vector<man> vm(n);
		REP(i, n){
			int m;
			cin >> m >> vm[i].point;
			REP(j, m){
				int s, e;
				cin >> s >> e;
				REP(k, e - s)
					vm[i].time |= 1 << (s - 6 + k);
			}
		}
		vector<vector<int>> dp(n, vector<int>(65536, 0));
		dp[0][0]=0;
		dp[0][vm[0].time] = vm[0].point;
		FOR(i,1, n){
			REP(j, 65536){
				if ((j & vm[i].time) == vm[i].time)
					dp[i][j] = max(dp[i - 1][j], dp[i - 1][j^vm[i].time] + vm[i].point);
				else
				dp[i][j] = dp[i - 1][j];
			}
		}
		int ans=0;
		REP(j, 65536)
			ans = max(ans,dp[n - 1][j]);
		cout<<ans<<endl;
	}
}

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

int k, s;
int ans;
int main(){
	cin >> k >> s;
	for (int i = 0; i <= k; ++i){
		for (int j = 0; j <= k; ++j){
			if (s - i - j <= k&&s - i - j >= 0)ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >>A>>B>>C>>D;
  
  int j=0;
  while(C-j*B>0){
    j++;
  }
  int i=0;
  
  while(A-i*D>0){
    i++;
    }
  if(j>i){
    cout<< "No" << endl;
  }
  if(j<=i){
    cout << "Yes" << endl;
  }}

Measured memory_bytes: 3596
K = int(input())


def dsum(n):
    return sum(list(map(int, str(n))))


def g(n):
    return n / dsum(n)

j = 1
order = 1
for i in range(K):
    print(j)
    if g(j + 10 ** (order - 1)) > g(j + 10 ** order):
        order += 1
    j += 10 ** (order - 1)


Measured memory_bytes: 3188
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        String[] s = sc.next().split("[.]");

        long b = Integer.valueOf(s[0]) * 100 + Integer.valueOf(s[1]);

        long result = (a * b) / 100;

        System.out.println(result);
    }
}


Measured memory_bytes: 35772
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <stack>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main(int argc, char *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);//incompatible with `while (cin >> ...)'
    string s;
    ll k;
    cin >> s >> k;
    int len = s.length();
    int i;

    for (i = 0; i < len; i++) {
        if (s[i] != '1') {
            break;
        }
    }
    if (i == len ) {
        cout << "1\n";
    }
    else if ( i == 0) {
        cout << s[i] << endl;
    }
    else if (k < ll(i + 1)){
        cout << "1\n";
    }
    else {
        cout << s[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
h,w,K = map(int,input().split())

mod = 10**9+7

num = 2**(w-1)

li = []

if w == 1:
    if K == 1:
        print(1)
        exit()
    else:
        print(0)
        exit()

for i in range(num):
    tmp = format(i, '0'+str(w-1)+'b')
    cnt = 0
    for j in range(w-1):
        if tmp[j] == '1':
            if cnt == 1:
                break
            else:
                cnt = 1
        else:
            cnt = 0
        if j == w-2:
            li.append(tmp)
    #print(tmp)

dp = [[0 for i in range(w)] for j in range(h+1)]

dp[0][0] = 1

for i in range(h):
    #print(i)
    for j in range(len(li)):
        for k in range(w):
            #print(li[j],li[j][0] == '1')
            if k == 0:
                if li[j][k] == '1':
                    dp[i+1][k+1] += dp[i][k]
                    dp[i+1][k+1] %= mod
                else:
                    dp[i+1][k] += dp[i][k]
                    dp[i+1][k] %= mod
            elif k == w-1:
                if li[j][k-1] == '1':
                    dp[i+1][k-1] += dp[i][k]
                    dp[i+1][k-1] %= mod
                else:
                    dp[i+1][k] += dp[i][k]
                    dp[i+1][k] %= mod
            else:
                if li[j][k-1] == '1':
                    dp[i+1][k-1] += dp[i][k]
                    dp[i+1][k-1] %= mod
                elif li[j][k] == '1':
                    #print(dp[i][k],i,k,i+1,k+1)
                    dp[i+1][k+1] += dp[i][k]
                    #print(dp[i+1][k+1],dp)
                    dp[i+1][k+1] %= mod
                else:
                    dp[i+1][k] += dp[i][k]
                    dp[i+1][k] %= mod
                    
print(dp[h][K-1])

Measured memory_bytes: 42472
#include <bits/stdc++.h>
    #define boost ios_base::sync_with_stdio(false), cin.tie(NULL);
     
    using namespace std;
    const int N = 1e6 + 4;
    const int X[] = {1,0,-1,0,1,-1,1,-1};
    const int Y[] = {0,1,0,-1,1,1,-1,-1};
    const int mod = 1e9 + 7;
    const long long INF = 1e16;
    const int inf = 1e9;
     
    int n;
     
    int a[N];
     
    int f[27][N];
     
    void upd (int j, int pos, int x = 1) {
    	for (int i = pos ; i < N ; i = (i | (i + 1))) {
    		f[j][i]+=x;
    	}
    }
     
    int get (int j, int pos) {
    	int res = 0;
    	for (int i = pos ; i >= 0 ; i = (i & (i + 1)) - 1) {
    		res += f[j][i];
    	}
    	return res;
    }
     
    int main () {
    	boost;
    	string s;
    	cin >> n;
      	cin >> s;
    	int q;
    	cin >> q;
    	for (int i = 0 ; i < n ; ++ i) {
    		a[i] = (s[i] - 'a');
    		upd (a[i], i);
    	}
    	while (q--) {
    		int type, l, r;
    		cin >> type >> l;
    		if (type == 2) {
    			cin >> r;
    			--l;
    			--r;
    			int res = 0;
    			for (int i = 0 ; i < 27 ; ++ i) {
    				res += min (1, get (i, r) - (get (i, l - 1)));
    			}
    			cout << res << "\n";
    		}
    		else {
    			--l;
    			char c;
    			cin >> c;
    			int u = c - 'a';
    			upd (a[l], l, -1);
    			a[l] = u;
    			upd (a[l], l);
    		}
    	}
    }

Measured memory_bytes: 105244
#include<iostream>
#include<utility>
#include<algorithm>
#include<vector>

int main(){
  int N,M;
  std::vector<std::pair<long long,long long>> AB;
  std::cin >> N >> M;
  using cross = std::pair<long long,long long>;
  AB.resize(N);
  for(auto& e : AB){
    std::cin>>e.first>>e.second;
  }
  std::sort(AB.begin(),AB.end(),[](cross& a,cross& b){
    return a.first < b.first;
  });
  long long int ans=0,count=0;
  for(auto& e : AB){
    if((count + e.second) > M){
      for(int i=0;i<e.second;i++){
        count++;
        ans+=e.first;
        if(count == M)
          break;
      }
    }
    else if((count + e.second) <= M){
      count+=e.second;
      ans+=(e.first*e.second);
    }
    if(count == M)
      break;
  }
  std::cout<<ans<<std::endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

  cout<<((a<b)? a:b)<<" "<<((a+b>n)? a+b-n:0)<<endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = [0]
for i in range(1, N):
    if A[i - 1] - A[i] > 0:
        B.append(A[i - 1] - A[i])
        A[i] += A[i - 1] - A[i]
print(sum(B))

Measured memory_bytes: 32100
mod = 1_000_000_007

gets

h = Hash.new{|h, k| h[k] = [0, 0] }
genten_iwashi = 0
$<.read.split.map(&:to_i).each_slice(2) do |(a,b)|

  if 0 == a | b
    genten_iwashi += 1
  else
    f = a.zero? || a * b > 0
    r = ( f ? Rational(a,b) : -Rational(b,a) )
    h[r][ f ? 0 : 1 ] += 1
  end
end

ans = h.values.reduce(1){ |r, (a, b)| r * ( 2.pow(a,mod) + 2.pow(b, mod) - 1) % mod }
ans = ( ans - 1 + genten_iwashi ) % mod

puts ans

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

int main(){
	std::string s;
	std::cin>>s;

	int y= 10*(s[0]-'0') + s[1]-'0';
	int m= 10*(s[2]-'0') + s[3]-'0';

	bool isY= (y<= 12 && y>=1);
	bool isM= (m<= 12 && m>=1);

	if(isY && isM)
		std::cout<<"AMBIGUOUS"<<std::endl;
	else if(isY)
		std::cout<<"MMYY"<<std::endl;
	else if(isM)
		std::cout<<"YYMM"<<std::endl;
	else
		std::cout<<"NA"<<std::endl;


	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()
    val a = (1..n).map{ readLine()!!.toInt()}

    val ans = mutableSetOf<Int>()
    for(i in a) {
        if (ans.contains(i)) {
            ans.remove(i)
            continue
        }
        ans.add(i)
    }

    println(ans.size)
}


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

class RollingHash{
public:
  typedef long long ll;
  ll B, mod;  //B: ハッシュ基数
  int n;
  string s;
  vector<ll> hash;
  vector<ll> k;

  RollingHash():n(-1){};
  RollingHash(string s,ll B = 1777771,ll mod = 1e9 + 7):
    B(B),mod(mod),n(s.size()),s(s),hash(n+1),k(n+1)
  {
    for(int i=0;i<n;i++) hash[i+1] = (hash[i] * B % mod + s[i]) % mod;
    k[0] = 1;
    for(int i=1;i<=n;i++) k[i] = (k[i-1] * B) % mod;
  }

  ll get(int l,int r){ //[l, r)
    assert(0<=l && r<=n && l<=r);
    return (mod + hash[r] - hash[l] * k[r-l] % mod) % mod;
  }
  
  //hash[a]とB.hash[b]からみて何文字一致してるか。
  int count(int a, RollingHash &B, int b){
    int L = 0, R = min( n - a, B.n - b ) + 1;
    while( L + 1 < R ){
      int M = ( L + R ) / 2;
      get( a, a + M ) != B.get( b, b + M ) ? R = M : L = M;
    }
    return L;
  }
};

signed main(){
  int n,mod=1e9+7;
  string s,t;
  cin>>n;
  map<int,vector<int> > mp;
  vector<int> v[1000],o;
  for(int i=0;i<n;i++){
    cin>>s;
    RollingHash tp=RollingHash(s);
    mp[s.size()].push_back(tp.get(0,0+s.size()));    
  }
  
  int m=0;
  for(auto p : mp){
    o.push_back(p.first);
    for(auto pp : p.second)v[m].push_back(pp);
    sort(v[m].begin(),v[m].end());
    m++;
  }
  cin>>t;
  RollingHash rh=RollingHash(t);
  int dp[100001]={};
  dp[0]=1;
  
  for(int i=0;i<t.size();i++){
    for(int j=0;j<m;j++){
      if(i+o[j]>t.size())break;
      int hs=rh.get(i,i+o[j]);
      auto I=lower_bound(v[j].begin(),v[j].end(),hs);
      if(I==v[j].end()||*I!=hs)continue;
      (dp[i+o[j]]+=dp[i])%=mod;
    }
  }
  cout<<dp[t.size()]<<endl;
  return 0;
}



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

using namespace std;

#define N 200000

int d[N + 1];
int t[N + 1];
map<int, int> c;

int main(){
	map<int, int>::iterator it;
	int n, m, i;

	scanf("%d", &n);

	for (i = 1; i <= n; i++){
		scanf("%d", d + i);

		c[d[i]]++;
	}

	scanf("%d", &m);

	for (i = 1; i <= m; i++){
		scanf("%d", t + i);

		c[t[i]]--;
	}

	for (it = c.begin(); it != c.end(); it++){
		if (it->second < 0){
			break;
		}
	}

	if (it != c.end()){
		printf("NO\n");
	}
	else{
		printf("YES\n");
	}

	return 0;
}

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

ab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

dict = {}
for i, ab_ in enumerate(ab[:26]):
    dict[ab_] = i
ab2 = ab[n:n+26]
new = ''
for s_ in s:
    new += ab2[dict[s_]]
print(new)

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

int main()
{
    int d;
    cin >> d;
    string s = "Christmas";
    for (int i=d; i<25; i++) {
        s += " Eve";
    }
    cout << s << endl;
    return 0;
}


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

int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i, n) rep(j, d) cin >> x[i][j];
  int ans = 0;
  for (int i=0; i<n-1; i++) {
    for (int j=i+1; j<n; j++) {
      int dis = 0;
      rep(k, d) {
        int s = x[i][k] - x[j][k];
        dis += s*s;
      }
      int s = sqrt(dis) + 0.5;
      if (s*s == dis) {
        ans++;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

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

int main() {
    rep(i, 9) {
        char tmp;
        cin >> tmp;
        if (i == 0 || i == 4 || i == 8) cout << tmp;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)
MOD = 10 **9 + 7

# N = int(input())
# S = input()
N, D = map(int, input().split())
# 横
# L = [int(x) for x in input().split()]
# 縦
# A = [int(input()) for _ in range(N)]
# 多次元
# L = [[int(x) for x in input().split()] for _ in range(N)]

print(math.ceil(N / (2 * D + 1)))



Measured memory_bytes: 38384
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from collections import defaultdict

def main():
    N, K = LI()
    A = LI_()
    edges = defaultdict(list)
    for i, a in enumerate(A[1:], 1):
        edges[a].append(i)

    global ans
    ans = 0
    if A[0] != 0:
        ans += 1
    def DFS(v, parent):
        global ans
        height = 0
        for to in edges[v]:
            height = max(height, DFS(to, v))
        if parent != 0 and height >= K - 1:
            height = -1
            ans += 1
        return height + 1
    DFS(0, 0)
    return ans

print(main())

Measured memory_bytes: 209584
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define Rep(i,s,t) for(long long i=s;i<t;i++)
#define all(x) x.begin(),x.end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  int n,d;
  cin>>n>>d;
  if(n%(2*d+1)==0){cout<<n/(2*d+1)<<endl;}
  else cout<<n/(2*d+1)+1<<endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a_sorted=sorted(a,reverse=True)
diff=0
if n%2==0:
  for i in range(n//2):
    diff+=a_sorted[2*i]-a_sorted[2*i+1]
  print(diff)
else:
  for i in range(n//2):
    diff+=a_sorted[2*i]-a_sorted[2*i+1]
  print(diff+a_sorted[-1])

Measured memory_bytes: 9144
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int n,k;
    cin >> n >> k;
    int cnt = 0;
    while(n){
        n /= k;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
N = int(input())
List = input()
List = list(List)

a = 0

for n in range(N - 2):
  if List[n] == 'A':
    if List[n + 1] == 'B':
      if List[n + 2] == 'C':
        a += 1
        
print(a)
        

Measured memory_bytes: 2940
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ){
    if ( L[i].value <= R[j].value ){
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}
 
void mergeSort(struct Card A[], int n, int left, int right ){
  int mid;
  if ( left+1 < right ){
    mid = (left + right)/2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int partition(struct Card A[], int n, int p, int r){
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ ){
    if ( A[j].value <= x.value ){
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i+1]; A[i+1] = A[r]; A[r] = t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r){
  int q;
  if ( p < r ){
    q = partition(A, n, p, r);
    quickSort(A, n, p, q - 1);
    quickSort(A, n, q + 1, r);
  }
}

main(){
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n-1);

  for ( i = 0; i < n; i++ ){
    if ( A[i].suit != B[i].suit ) stable = 0;
  }

  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for ( i = 0; i < n; i++ ) {
    printf("%c %d\n", B[i].suit, B[i].value);
  }
}




Measured memory_bytes: 4044
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll A[N+1], B[N];
  for(int i=0;i<=N;++i) cin>>A[i];
  for(int i=0;i<N;++i) cin>>B[i];
  ll ans = 0;
  for(int i=0;i<N;++i) {
    if(A[i]>B[i]) {
      ans += B[i];
      A[i] -= B[i];
    }
    else {
      ans += A[i];
      B[i] -= A[i];
      A[i] = 0;
      if(A[i+1]>B[i]) {
        ans += B[i];
        A[i+1] -= B[i];
      }
      else {
        ans += A[i+1];
        B[i] -= A[i+1];
        A[i+1] = 0;
      }
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 5080
import Data.List


main :: IO ()
main = do
    s <- getLine
    print $ solve (head s:[]) (tail s)

solve :: String -> String -> Int
solve ac []     = read (reverse ac)
solve ac (x:xs) = 2^(length xs) * (read (reverse ac)) + (solve (x:ac) xs) + (solve (x:[]) xs)





Measured memory_bytes: 1020