akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define ad(x,y) (x=(x+(y))%M)
#define mu(x,y) (x=x*(y)%M)
#define fi first
#define se second
#define pq priority_queue
#define br putchar('\n')
#define pb push_back
#define isinf(x) (x>=INF?-1:x)

using namespace std;

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

template<class T> void ckmin(T &a, T b) { return a>b?a=b:0; }
template<class T> void ckmax(T &a, T b) { return a<b?a=b:0; }

inline ll read()
{
    char c;ll out=0,f=1;
    for (c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());if (c=='-'){f=-1;c=getchar();}
    for (;c>='0'&&c<='9';c=getchar()){out=(out<<3)+(out<<1)+c-'0';}return out*f;
}
void write(ll x)
{
	if (x<0){putchar('-');write(-x);return;}
    if (x>9){write(x/10);}putchar(x%10+'0');
}

int n,ans,a[200010];
multiset<int> b;

int main()
{
	int i,j;
	
	n=read();
	
	for (i=1;i<=n;++i)
	{
		a[i]=read();
		b.insert(a[i]);
	}
	
	sort(a+1,a+n+1);
	
	for (i=n;i>=1;--i)
	{
		auto del=b.find(a[i]);
		if (del!=b.end())
		{
			b.erase(del);
		}
		else
		{
			continue;
		}
		for (j=(1<<30);j>a[i];j>>=1)
		{
			if (j-a[i]<=a[i])
			{
				auto k=b.find(j-a[i]);
				if (k!=b.end())
				{
					b.erase(k);
					++ans;
					break;
				}
			}
		}
	}
	
	cout<<ans;
	
	return 0;
}

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

int main(){
  int k,x;
  scanf("%d %d", &k,&x);
  if(500*k >= x) printf("Yes\n");
  else printf("No\n");
}


Measured memory_bytes: 256
package main

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

func cmb(x int) int {
	return (x * (x - 1)) / 2
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	a := make([]int, n)
	m := map[int]int{}
	for i := range a {
		a[i] = nextInt()
		m[a[i]]++
	}

	sum := 0
	for _, v := range m {
		sum += cmb(v)
	}

	for i := range a {
		ans := sum
		ans = ans - cmb(m[a[i]]) + cmb(m[a[i]]-1)
		puts(ans)
	}
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


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

using namespace std;
#define NMAX 200045
vector<int> g[NMAX];
int a[NMAX][2];
bool s[NMAX];
signed main(){
	int n, m; cin>>n>>m;
	for(int i= 0; i < n; i++){
		char t; cin>>t;
		s[i] = (t == 'B');
	}
	
	for(int i = 0; i < m; i++){
		int a, b; cin>>a>>b; a--,b --;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	queue<int> q;
	vector<bool> alive(n);
	for(int i = 0; i < n; i++){
		//cout<<i<<endl;
		for(int adj: g[i]){
			a[i][s[adj]]++;
		}
		if(a[i][0] == 0 || a[i][1] == 0){
			q.push(i);
			alive[i] = true;
		}
	}
	while(!q.empty()){
		int cur = q.front(); q.pop();
		
		for(int adj: g[cur]){
			if(!alive[adj]){
				a[adj][s[cur]]--;
				if(a[adj][0] <= 0 || a[adj][1] <= 0){
					alive[adj] = true;
					q.push(adj);
				}
			}
		}
	}
	int count = 0;
	for(int i = 0; i < n; i++){
		if(alive[i] == false){
			count++;
		}
	}
	if(count) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 12416
process.stdin.resume();
process.stdin.setEncoding('utf8'); 
var lines = [];
var reader = require('readline').createInterface({
	input: process.stdin,
	output: process.stdout
});
 
reader.on('line', (line) => {
	lines.push(line);
});

reader.on('close', () => {
	"use strict"
	const S=lines[0];
	const T=lines[1];
	
	var ans=0;
	for(var i=0; i<3; i++){
		ans += S[i]==T[i];
	}
	
	console.log(ans);
});

Measured memory_bytes: 7628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string s;
	bool pd=true;
	cin>>n>>s;
	if(n%2==0)
	{
		int first=0,last=n/2;
		while(first<n/2&&last<n)
		{
			if(s[first]!=s[last])pd=false;
			first++;last++;
		}
		if(pd)cout<<"Yes";
		else cout<<"No";
	}
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
l = 0
r = n - 1
diff = a[l] - a[r]
while l + 1 < r do
  if diff < 0
    l += 1
    diff += a[l]
  else
    r -= 1
    diff -= a[r]
  end
end
if diff < 0
  diff2 = diff + a[l + 1] * 2
elsif diff > 0
  diff2 = diff - a[l] * 2
else
  diff2 = 0
end
puts [diff.abs, diff2.abs].min


Measured memory_bytes: 18052
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(n-2):
    if p[i] > p[i+1] and p[i+1] > p[i+2]:
        ans += 1
    elif p[i] < p[i+1] and p[i+1] < p[i+2]:
        ans += 1

print(ans)

Measured memory_bytes: 38256
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int L = (60 * H2 + M2) - (60 * H1 + M1);
    cout << L - K << '\n';
}


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

using namespace std;

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

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define all(v) (v).begin(), (v).end()
#define dbg(a) cerr << #a << " = " << a << endl

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll n;
    cin >> n;
    int cnt = 0, sum = 0;
    while(n >= 10) {
        cnt++;
        sum += n % 10;
        n /= 10;
    }
    cout << max(cnt * 9 + n - 1, sum + n);

    return 0;
}

Measured memory_bytes: 256
a,b = map(int,input().split())
OK = 1
if a<0:
    if b<0:
        if (abs(b-a)+1)%2==1:
            OK = -1
    else:
        OK = 0
print('Positive' if OK==1 else 'Negative' if OK==-1 else 'Zero')


Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <string>

struct dpoint{
  public:
  int pos;
  int rcount;
  int lcount;
  dpoint():pos(0),rcount(1),lcount(0){}
};

int main(){
  using namespace std;
  string s;
  cin >> s;
  vector<dpoint> dps;
  bool is_l = false;
  dpoint buf_dp;
  for(int i = 1;i < s.size();i++){
    if(s[i-1] == 'R' && s[i] == 'L'){
      buf_dp.pos = i;
      is_l = true;
    }
    if(is_l && s[i] == 'R'){
      dps.push_back(buf_dp);
      buf_dp = dpoint();
      is_l = false;
    }else if(is_l){
      buf_dp.lcount++;
    }else{
      buf_dp.rcount++;
    }
  }
  dps.push_back(buf_dp);
  int pi = 0;
  if(dps[pi].pos - 1 == 0){
    int res = dps[pi].rcount / 2 + dps[pi].lcount / 2 + dps[pi].rcount % 2;
    cout << res << " ";
  }else{
    cout << 0 << " ";
  }
  for(int i = 1;i < s.size();i++){
    if(pi >= dps.size()){
      cout << 0 << " ";
    }else if(dps[pi].pos - 1 == i){
      int res = dps[pi].rcount / 2 + dps[pi].lcount / 2 + dps[pi].rcount % 2;
      cout << res << " ";
    }else if(dps[pi].pos == i){
      int res = dps[pi].rcount / 2 + dps[pi].lcount / 2 + dps[pi].lcount % 2;
      cout << res << " ";
      pi++;
    }else{
      cout << 0 << " ";
    }
  }
  cout << endl;
  return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __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(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

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;

// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    REP(i, n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

// 頂点a, bをつなぐコストcostの（無向）辺
struct Edge
{
  int a, b;
  double cost;

  // コストの大小で順序定義
  bool operator<(const Edge& o) const {
    return cost < o.cost;
  }
};

// 頂点数と辺集合の組として定義したグラフ
struct Graph
{
  int n;  // 頂点数
  vector<Edge> es;  // 辺集合
  double sum;

  // クラスカル法で無向最小全域木のコストの和を計算する
  // グラフが非連結のときは最小全域森のコストの和となる
  double kruskal() {
    // コストが小さい順にソート
    sort(es.rbegin(), es.rend());

    UnionFind uf(n);
    double min_cost = 0;

    REP(ei, es.size()) {
      Edge& e = es[ei];
      if (!uf.same(e.a, e.b)) {
        // 辺を追加しても閉路ができないなら、その辺を採用する
        min_cost += e.cost;
        uf.unite(e.a, e.b);
      }
    }

    return min_cost;
  }
};

// 標準入力からグラフを読み込む
Graph input_graph() {
  Graph g;
  int n, m;
  cin >> n >> m;
  g.n = n;
  vi x(n), y(n);
  REP(i, n) {
    cin >> x[i] >> y[i];
  }
  REP(i, m) {
    Edge e;
    cin >> e.a >> e.b;
    e.a--;
    e.b--;
    e.cost = hypot(x[e.a] - x[e.b], y[e.a] - y[e.b]);
    g.sum += e.cost;
    g.es.push_back(e);
  }
  return g;
}

int main(){
  Graph g = input_graph();
  printf("%.3lf\n", g.sum - g.kruskal());
}

Measured memory_bytes: 3692
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}

#define MAX 1000000

long long fac[MAX], finv[MAX], inv[MAX];

void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long ncr(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long npr(int n, int k){
    return fac[n] * finv[n-k] % MOD;
}


signed main(void) {
    int n,m;
    cin >> n >> m;
    init();
    int ans = 0;
    rep(i,n+1){
        //ai=biが少なくともi個ある
        int tmp = ncr(n,i);
        tmp *= npr(m-i,n-i);
        tmp %= MOD;
        if(i%2)tmp *= -1, tmp += MOD, tmp %= MOD;
        ans += tmp;
        ans %= MOD;
    }
    ans *= npr(m,n);
    ans %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 27052
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const ll MOD=1000000007;
const ll LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};




struct UnionFind{
    vector<int> data;

    UnionFind(int sz){
        data.assign(sz, -1);
    }

    int find(int k){
        if(data[k] < 0) return k;
        return data[k] = find(data[k]);
    }

    bool unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y) return false;
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

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

    int size(int k){
        return -data[find(k)];
    }

};


int main(){
    int n,m;cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        int a,b;cin >> a >> b;
        a--,b--;
        uf.unite(a,b);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if(uf.find(i) == i) ans++;
    }
    cout << ans - 1 << endl;
    return 0;
}


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

int main() {
  
  int N, K;

  cin >> N >> K;
  
  int cnt = 0;
  int current_cnt = 0;
  vector<int> a(N);
  vector<int> cnt_num(N);
  
  for (int i = 0; i < N; i++) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  
  int current_num = a.at(0);
  
  for (int i = 0; i < N; i++) {
    if (a.at(i) != current_num) {
      cnt_num.at(current_cnt) = cnt;
      current_cnt++;
      cnt = 0;
      current_num = a.at(i);
    }
    cnt++;
  }
  
  cnt_num.at(current_cnt) = cnt;  
      
  int sum = 0;
  
  sort(cnt_num.begin(), cnt_num.end());
  reverse(cnt_num.begin(), cnt_num.end());
  
  for (int i = K; i < current_cnt + 1; i++) sum += cnt_num.at(i);
  
  //for (int i = 0; i < current_cnt + 1; i++) cout << cnt_num.at(i) << endl;
  
  cout << sum << endl;
  
}

Measured memory_bytes: 1792
h, w, k  = map(int, input().split())

puyo_orig = [[0]*w for _ in range(h+1)]
for i in range(1,h+1):
    puyo_orig[i] = list(map(int, list(input())))

import copy
mx = 0
for i1 in range(2,h+1):
    for i2 in range(w):
        puyo = copy.deepcopy(puyo_orig)
        for l in range(i1,0,-1):
            puyo[l][i2] = puyo[l-1][i2]
        p = 0
        fin = 0
        turn = 0
        while fin==0:
            fin = 1
            for i in range(2,h+1):
                cnt = 1
                for j in range(w-1):
                    if puyo[i][j+1] == puyo[i][j] and puyo[i][j]>0:
                        cnt += 1
                    else:
                        if cnt>=k:
                            p += cnt * puyo[i][j] * 2**turn
                            for l in range(i,0,-1):
                                puyo[l][j-cnt+1:j+1] = puyo[l-1][j-cnt+1:j+1]
                            fin = 0
                        cnt = 1
                    if j==w-2:
                        if cnt>=k:
                            p += cnt * puyo[i][j] * 2**turn
                            for l in range(i,0,-1):
                                puyo[l][j-cnt+2:j+2] = puyo[l-1][j-cnt+2:j+2]
                            fin = 0
            turn += 1
        if p>mx:
            mx=p
            
print(mx)

Measured memory_bytes: 57180
if __name__ == "__main__":
    k = int(input())
    count = 0
    for i in range(1, k+1):
        for j in range(1, k+1):
            if (i % 2 == 0 and j % 2 == 1 and i != j):
                count += 1


    print(count)
    

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
// cd test ; rm -R ./*; cd ..


int main(void) {
  int n;
  cin >> n;
  string s;
  cin >> s;

  char cc[53];
  int l = 0;
  for (char c = 'A'; c <= 'Z'; c++) {
    cc[l] = c;
    cc[l + 26] = c; 
    l++;
  }
  
  rep (i, s.size()) {
    char c = s[i];
    int a = s[i] - 'A';
    cout << cc[a + n];
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int N=2e5+5;
pair<int,int>a[N];
int n,Maxs,Mins=1e9+5;
long long ans;
int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d%d",&a[i].first,&a[i].second);
	rep(i,1,n){
		if(a[i].first>a[i].second) swap(a[i].first,a[i].second);
		Maxs=max(Maxs,a[i].second);
		Mins=min(Mins,a[i].second);
	}
	sort(a+1,a+n+1);
	ans=1LL*(Maxs-Mins)*(a[n].first-a[1].first);
	Mins=a[1].first;
	int Max=max(a[1].second,a[n].first),Min=min(a[1].second,a[n].first);
	rep(i,2,n){
		Max=max(Max,a[i].second);
		Min=min(Min,a[i].second);
		if(i!=n) ans=min(ans,1LL*(Max-min(Min,a[i+1].first))*(Maxs-Mins));
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1792
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nr = readln.split.to!(int[]);
    auto N = nr[0];
    auto R = nr[1];
    if (N >= 10) {
        writeln(R);
    } else {
        writeln(R + 100 * (10-N));
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
   char s[100005];
   cin>>s;
   int N;
   N=strlen(s);
   int count=0; 
   for(int i=0;i<N-1;i++){
       if(s[i]!=s[i+1]) {count++;}
   }
   cout<<count;
   return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
//#include<queue>
#include<algorithm>
using namespace std;
static const int N = 100;

int main() {
	int i, n, m[N + 1][N + 1], p[N + 1];
	//priority_queue<int> PQ;

	scanf("%d", &n);

	for (i = 1; i <= n; i++)scanf("%d %d", &p[i - 1], &p[i]);

	for (i = 1; i <= n; i++) {
		m[i][i] = 0;
	}

	for (int l = 2; l <= n; l++) {
		for (i = 1; i <= n - l + 1; i++) {
			int j = i + l - 1;
			m[i][j] = (1 << 21);
			for (int k = i; k <= j - 1; k++) {
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}

	printf("%d\n", m[1][n]);

	return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int N;
	cin>>N;
	for (int i = 0; i < N; i++) {
		int len[3];
		for (int j = 0; j < 3; j++) {
			cin>>len[j];
		}
		sort(len,len+3);
		if(pow(len[2],2)==pow(len[1],2)+pow(len[0],2)){
			puts("YES");
		}else{
			puts("NO");
		}
	}
	return 0;
}

Measured memory_bytes: 1124
#include<iostream>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
#include <algorithm>
#include <strstream>
#include<vector>
using namespace std;

int main(){
	int n;
	while(cin>>n && n)
	{
		bool flag=true;
		int k,p,q,r;
		int t[1002],s[1002],tan[1002];
		vector<pair<int,int> >cal;
		for(int i=0; i<n; i++)
		{
			int kari;
			cin>>k>>p>>q>>r;
			t[i]=p;s[i]=q;tan[i]=r;
			kari=p*4+9*q+4*r;
			cal.push_back ( make_pair(k,kari) );
		}
		int P,Q,R,C;
		cin>>P>>Q>>R>>C;
		int i=0;
		for(vector< pair<int,int> >::iterator it=cal.begin(); it != cal.end(); it++)
		{
			if(t[i]<=P && s[i]<=Q && tan[i]<=R && (*it).second<=C)
			{
				cout << (*it).first <<endl;
				flag=false;
			}
			i++;
		}
		if(flag)puts("NA");
	}
	
	return 0;
}

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((a + b) > (c + d))
    {
        std::cout << "Left" << std::endl;
    }
    else if ((a + b) < (c + d))
    {
        std::cout << "Right" << std::endl;
    }
    else
    {
        std::cout << "Balanced" << std::endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(){
  int n,k;
  cin>>n>>k;
  map<int,int> mp;
  int a;
  REP(i,n){
    cin>>a;
    mp[a]++;
  }
  vector<pair<int,int>> cnts;
  int num,cnt;
  for(auto p:mp){
    num = p.first;
    cnt = p.second;
    cnts.push_back(make_pair(cnt,num));
  }
  
  sort(cnts.begin(),cnts.end());
  int ans=0;
  int change=cnts.size()-k;
  change = max(0,change);
  REP(i,change){
    ans += cnts[i].first;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 11768
// C - Guess The Number
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,M; cin>>N>>M;
	string T(N,'-');
	while(M--){
		int s; char c; cin>>s>>c; s--;
		if(T[s]!='-' && T[s]!=c || N!=1 && s==0 && c=='0'){
			puts("-1"); return 0;
		}
		T[s] = c;
	}
	while(N--) if(T[N]=='-') T[N] = T.size()==1? '0': N!=0? '0': '1';
	cout<< stoi(T) <<endl;
}

Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]

l=1
k=0
while k<=n-1:
    for i in range(k,n):
        if a[i]==l:
            l+=1
            k=i+1
            break
    else:
        k=n
if l==1:
    print(-1)
else:
    print(n-l+1)


Measured memory_bytes: 26140
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <cmath>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    vector<int> A(N);

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

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

    cout << A[N-1] - A[0] << endl;

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val sLine = readLine()!!.split(" ").map(String::toInt)
    val n = sLine[0]
    val m = sLine[1]
    val aList = readLine()!!.split(" ").map(String::toInt).toMutableList()

    val hwDays = aList.sum()

    val result = if(n - hwDays >= 0) n - hwDays else -1

    println(result)
}

Measured memory_bytes: 39576
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <climits>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    vector<int> As(N);
    ll sum = 0;
    REP(n,N) {
        cin >> As[n];
        if (As[n] > 0) sum += As[n];
    }

    ll ans = 0;
    ll ans_w = sum;
    ll ans_b = sum;
    REP(i, N-K+1) {
        if (i == 0) {
            REP(j, K) {
                if (As[j] > 0) ans_w -= As[j];
                if (As[j] < 0) ans_b += As[j];
            }
        }
        else {
            if (As[i-1] > 0) ans_w += As[i-1];
            if (As[i-1] < 0) ans_b -= As[i-1];
            if (As[i+K-1] > 0) ans_w -= As[i+K-1];
            if (As[i+K-1] < 0) ans_b += As[i+K-1];
        }

        ans = max(ans, max(ans_w, ans_b));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <set>
#include <algorithm>

int main() {
  long N;
  std::string S;

  std::cin >> N;
  std::cin >> S;

  std::set<char> chars;

  for (auto const& c : S) chars.insert(c);

  size_t ans = 0;

  for (auto i = S.begin(); i != S.end(); i++) {
    size_t kinds=0;
    for (auto const& c: chars) {
      if (std::count(S.begin(), i, c) > 0 &&
          std::count(i, S.end(), c) > 0) {
        kinds++;
      }
    }
    if (kinds > ans) ans = kinds;
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint a[1010],b[1010],c[1010];
vector<lint> v,w;
int main()
{
	int x,y,z,K;
	cin>>x>>y>>z>>K;
	rep(i,x) cin>>a[i];
	rep(i,y) cin>>b[i];
	rep(i,z) cin>>c[i];
	rep(i,y) rep(j,z) v.pb(b[i]+c[j]);//v.pb(123456789012345678LL);
	sort(All(v));
	/*rep(i,K){
		lint lo=0,hi=123456789012345678LL;
		while(hi>lo){
			lint mi=(hi+lo+1)/2;
			int sum=0;
			rep(j,x){
				sum+=y*z-(lower_bound(All(v),mi-a[j])-v.begin());
			}
			if(sum>i) lo=mi;else hi=mi-1;
		}
		cout<<lo<<endl;
	}*/
	reverse(All(v));
	rep(i,x) rep(j,min(K,y*z)) w.pb(a[i]+v[j]);
	sort(All(w));reverse(All(w));
	rep(i,K) cout<<w[i]<<endl;
}


Measured memory_bytes: 42980
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define rep2(i,start,end) for(ll i = start; i < end; i++)
#define dwn(i,n) for(int i = n; i >= 0; i--)
#define dwn2(i,start,end) for(ll i = start; i >= end; i--)
#define pll pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define pdl pair<double, ll>
const ll N = 200;
const ll INF = 9999999999;
const ll mod = 1e9 + 7;

int g2[N][N];
ll rst[N][N];
ll gox[] = {-1,1,0,0};
ll goy[] = {0,0,1,-1};

typedef struct{
	int x,y,stp;
}nods;
int main(){
	ll n,m;
	cin>>n>>m;

	rep(i,n){
		getchar();
		rep(j,m){
			char c;
			scanf("%c",&c);
			if(c == '.'){
				g2[i][j] = 0;
			}else{
				g2[i][j] = 1;
			}
		}
	}
	ll mx = 0;
	rep(i,n){
		rep(j,m){
			if(g2[i][j] == 0){
				ll g[N][N];
				rep(k1,n){
					rep(k2,m){
						g[k1][k2] = g2[k1][k2];
					}
				}
				queue<nods> q;
				nods p;
				p.x = i; p.y = j; p.stp = 0;
				g[i][j] = 1;
				q.push(p);
				while(!q.empty()){
					p = q.front();
					q.pop();
					rep(k,4){
						ll x2 = p.x+gox[k];
						ll y2 = p.y+goy[k];
						// cout<<g[x2][y2]<<endl;
						if(x2 >= 0 && x2 <n && y2 >= 0 && y2 < m && g[x2][y2] == 0) {
							
							g[x2][y2] = 1;
							nods p2;
							p2.x = x2; p2.y = y2; p2.stp = p.stp+1;
							if(p2.stp > mx) mx = p2.stp;
							q.push(p2);
						}
						
					}
				}
			}
			// cout<<mx<<endl;
		}
	}
	cout<<mx<<endl;

	return 0;
}





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

int main()
{
	int N, M;
	scanf("%d%d", &N, &M);
	
	if(N % 2 == 1)
	{
		int start = 1;
		for(int i = 0; i < M; i++)
		{
			if(start > N - start)
				break;
				
			printf("%d %d\n", start, N - start);
			start++;
		}
	}
	
	else
	{
		int leftStartIndex = 1, rightStartIndex = N / 2 + 1;
		int leftEndIndex = N / 2, rightEndIndex = N - 1;
		
		for(int i = 1; i <= M; i++)
		{
			if(i % 2 == 1)
			{
				printf("%d %d\n", leftStartIndex, leftEndIndex);
				leftStartIndex++;
				leftEndIndex--;
			}
			
			else
			{
				printf("%d %d\n", rightStartIndex, rightEndIndex);
				rightStartIndex++;
				rightEndIndex--;
			}
		}
	}
}


Measured memory_bytes: 3736
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#define mod (long long int)(2019)
#define pb push_back
#define ll long long int 
using namespace std;
typedef pair<int,int> pii;
 
int main(){
  ll l,r;
 
  cin>>l>>r;
 
  ll res=(l*(l+1))%mod;
 
  for(ll i=l;i<r;i++){
    for(ll j=i+1;j<=r;j++){
      if(res==0) break;
      res=min(res,(i*j)%mod);
    }
  }
  
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

void print_26ry(long long n, int level)
{
	if (n == 0)
	{
		return;
	}
	print_26ry((n - 1) / 26, level + 1);
	//if (level == 1)
	//{
	//	cout << char(n % 26 + 'a');
	//}
	//else
	//{
	//	cout << char(n % 26 + 'a' - 1);
	//}
	cout << char((n - 1) % 26 + 'a');
}

int main()
{
	long long n;
	cin >> n;
	print_26ry(n, 1);

	return 0;
}

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

#define ll long long
ll fnc(ll a,ll b){
	if(b==0) return 0;
	else{
		if(a%b==0) return 2*(a/b)*b-b;
		else return 2*b*(a/b)+fnc(b,a%b);
	}
}

int main(){
	ll n,m,ans=0;
	cin>>n>>m;
	ans=n+fnc(n-m,m);
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t
#define tos(x) to_string(x)


int main() {
	int n;
	cin >> n;
	int ans = 0;
	ff(i, 0, n) {
		int a;
		cin >> a;
		ans += a - 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    int N;
    cin >> N;
    vector<int> vec(8);
    int op = 0;

    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        if (a < 400)
            vec.at(0) = 1;
        else if (a < 800)
            vec.at(1) = 1;
        else if (a < 1200)
            vec.at(2) = 1;
        else if (a < 1600)
            vec.at(3) = 1;
        else if (a < 2000)
            vec.at(4) = 1;
        else if (a < 2400)
            vec.at(5) = 1;
        else if (a < 2800)
            vec.at(6) = 1;
        else if (a < 3200)
            vec.at(7) = 1;
        else
            op++;
    }
    int cnt = 0;
    for (int i = 0; i < 8; i++)
    {
        if (vec.at(i) == 1)
            cnt++;
    }
    if (cnt == 0)
    {
        cout << 1 << " " << op << endl;
        return 0;
    }
    cout << cnt << " " << cnt + op << endl;

    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x) for (auto&& v : (x))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))

ll h[200100];
int main() {
  ll n, k;
  cin >> n >> k;
  rep(i, n) cin >> h[i];
  sort(h, h + n);
  ll result = 0;
  rep(i, max(n - k, 0ll)) result += h[i];
  cout << result << endl;
}


Measured memory_bytes: 5188
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

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

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

  int ans = 0;
  for (int a=0; a<=A; ++a) {
    for (int b=0; b<=B; ++b) {
      for (int c=0; c<=C; ++c) {
        int sum = 500*a + 100*b + 50*c;
        if (X == sum) ++ans;
      }
    }
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define ff fflush(stdout)
#define IN(a) freopen(a, "r", stdin)
#define OUT(a) freopen(a, "w", stdout) 
#define eps 1e-6
#define PI atan(1) * 4
#define mod 1000000007
using namespace std;
int main () {
	ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
	scanf("%lld", &a);
	c = 1e18; d = 0;
	for (i = 1; i <= a; i++) {
		scanf("%lld", &b);
		d += b;
		if (b < c && b % 10 != 0) c = b;
	}
	if (d % 10 == 0) d -= c;
	if (c == 1e18) printf("0\n");
	else printf("%lld\n", d);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<fstream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
   while(true){
        int n;
        cin >> n;
        if(n==0)break;
        vector <int> l(n);
        int a=0;
        for(int i = 0; i < n/4; i++){
            cin >> l[i];
        }
        for(int i = 0; i < n/4; i++){
            a=l[i]+a; 
        }
    cout << a << endl;
   }
}



Measured memory_bytes: 3096
#include <stdio.h>
int main(void){
    int a,i,max,mini,n;
    long long int sum; 
    
    max=-1000000; 
    mini=1000000; 
    sum=0; 
    
    scanf("%d",&n); 
    
    for (i=1 ; i<=n ; i=i+1){
        scanf("%d",&a);
        
        if(mini>a) 
            mini=a; 
            
        if(max<a) 
            max=a; 
            sum=sum+a; 
        
    } 
    
    printf("%d %d %lld\n",mini,max,sum);
    
    return 0; 
    
} 


Measured memory_bytes: 2108
#include <iostream>
#include <queue>
#include <string>
#include <cstring>

using namespace std;
queue<pair<string, int> > Q;
int main(){
	int n, q; cin >> n >> q;
	for (int i = 0; i < n; ++i){
		string str; int tmp; cin >> str >> tmp;
		Q.push(pair<string, int>(str,tmp));
	}
	long t = 0;
	while (!Q.empty()){
		pair<string, int> tmp; tmp = Q.front();
		Q.pop();
		if (tmp.second > q){
			tmp.second -= q;
			Q.push(tmp);
			t += q;
		}
		else{
			t += tmp.second;
			cout << tmp.first << ' ' << t << '\n';
		}
	}
}

Measured memory_bytes: 4404
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n,k,t=0,a;

	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&a);
		if(a<k-a)
			t+=a*2;
		else
			t+=(k-a)*2;
	}
	printf("%d",t);
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:268435456")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#ifndef _MSC_VER
#pragma GCC target ("sse4.2")
#endif
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <random>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ll n, k;
	cin >> n >> k;
	vi a(n);
	for (auto& x : a)
		cin >> x;
	vector<bool> visited(n, false);
	int cur = 0;
	ll count1 = 0;
	while (true)
	{
		if (visited[cur])
			break;
		visited[cur] = true;
		count1++;
		cur = a[cur] - 1;
	}
	visited.assign(n, false);
	ll count2 = 0;
	while (true)
	{
		if (visited[cur])
			break;
		visited[cur] = true;
		count2++;
		cur = a[cur] - 1;
	}
	if (k > n)
	{
		k -= (count1 - count2);
		k %= count2;
		k += (count1 - count2);
	}
	cur = 0;
	while (k)
	{
		cur = a[cur] - 1;
		k--;
	}
	cout << cur + 1;
	return 0;
}


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

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int ans = min(a*n,b);
    cout << ans << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

const int N = 500100;
const int oo = 1e9;

int n,a,m;
map<int,int> freq;

int main() {
	scanf("%d",&n);
	for (int i = 0; i < n; ++i){
		scanf("%d",&a);
		freq[a]++;
	}
	scanf("%d",&m);
	for (int i = 0; i < m; ++i){
		scanf("%d",&a);
		if(freq[a]==0){
			puts("NO");
			return 0;
		}
		freq[a]--;
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define rep(i, n) for(int i=0;i<n;i++)

int main() {
  int n;
  cin >> n;
  VI h(n);
  rep(i,n) cin >> h.at(i);
  int count=0;
  rep(i,n){
    bool high=true;
    rep(j,i){
      if(h.at(j)>h.at(i)){
        high=0;
        break;
      }
    }
      if(high) count++;
  }
  cout << count <<endl;
    
}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> point(3); // rock:0,scissors:1,paper:2
    rep(i,3) cin >> point[i];
    vector<int> t(n);
    string s;
    cin >> s;
    rep(i,n){    
        if(s[i]=='r') t[i] = 0;
        if(s[i]=='s') t[i] = 1;
        if(s[i]=='p') t[i] = 2;
    }
    //rep(i,n) cout << t[i] << " ";
    //cout << endl;
    vector<vector<int>> dp(n,vector<int>(3));
    auto victory = [&](int i,int j){
        if(j==0&&t[i]==1) return true;
        if(j==1&&t[i]==2) return true;
        if(j==2&&t[i]==0) return true;
        return false;
    };
    vector<int> mx(n+1);
    rep(i,n){
        rep(j,3){
            dp[i][j] = mx[i];
            if(i-k>=0 && victory(i-k,j) && dp[i-k][j]-mx[i-k]>0) continue;
            if(victory(i,j)) dp[i][j] += point[j];
        }       
        rep(j,3) mx[i+1] = max(mx[i+1],dp[i][j]);
    }
	/*
    rep(i,n){
        rep(j,3){
            cout << dp[i][j] << endl;
        }
        cout <<endl;
    }
	*/
    int ans = 0;
    rep(i,3) ans = max(ans,dp[n-1][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
// lint mod = 1000000007;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void app() {
  int n;
  cin>>n;

  map<int,int> a;
  lint s=0;
  rep(i,n){
    int ai;
    cin>>ai;
    a[ai]++;
    s+=ai;
  }

  int q;
  cin>>q;
  rep(t,q){
    int b,c;
    cin>>b>>c;

    s+=(c-b)*a[b];
    a[c]+=a[b];
    a[b]=0;

    cout<<s<<endl;
  }
}

int main(){app();return 0;}


Measured memory_bytes: 8004
while n = gets.to_i
  break if n == 0
  table = [0] * (3600 * 24)
  n.times do
    sh, sm, ss, th, tm, ts = gets.split(/\s|:/).map(&:to_i)
    p = sh * 3600 + sm * 60 + ss
    q = th * 3600 + tm * 60 + ts
    table[p] += 1; table[q] -= 1
  end
  (1...3600 * 24).each{ |i| table[i] += table[i-1]}
  p table.max
end

Measured memory_bytes: 18040
import sys
input=sys.stdin.readline
n=int(input())
cnt=[]
for i in range(n):
	s=input().rstrip()
	l=s.count("(")
	r=s.count(")")
	minus=0
	now=0
	for j in range(len(s)):
		if s[j]=="(":
			now+=1
		else:
			now-=1
			minus=min(minus,now)
	cnt.append((l,r,s,minus))
cnt.sort(key=lambda x:x[1]-x[0])
plus=[]
minus=[]
first=[]
for x in cnt:
	if x[3]>=0:
		first.append(x)
	elif x[0]-x[1]>0:
		plus.append(x)
	else:
		minus.append(x)
plus.sort(key=lambda x:-x[3])
minus.sort(key=lambda x:-(x[0]-x[1]-x[3]))
l=r=0
for x in first+plus+minus:
	for i in range(len(x[2])):
		if x[2][i]=="(":
			l+=1
		else:
			r+=1
		if l<r:
			print("No")
			exit()
if l==r:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 349608
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

const int mod = 2019;
int main() {
	int l, r;
	cin >> l >> r;

	r = min(r, l + mod * 3);
	long long ans = mod;
	for (long long i = l; i <= r; i++) {
		for (long long j = i + 1; j <= r; j++) {
			ans = min(ans, i * j % mod);
		}
	}

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


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

string s;

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

    cin >> s;

    for(int i = 0; i < s.size(); ++i) {
        if(s[i] == '7') {
            cout << "Yes\n";
            return 0;
        }
    }

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


Measured memory_bytes: 3608
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    string w;
    cin >> w;

    map<char, int> mp;

    for(auto c : w){
        ++mp[c];
    }

    for(auto x : mp){
        if(x.second & 1){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
// D - String Equivalence
// DFS version
#include <bits/stdc++.h>
using namespace std;

int N;

void dfs(string pre, char cmax){
	if(pre.size() >= N) cout<< pre <<endl;
	else for(char c='a'; c<=cmax; ++c) dfs(pre + c, (c<cmax? cmax: cmax + 1));
}

int main(){
	cin>>N;
	dfs("", 'a');
}

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

long long Min(long long  a,long long  b){
    if(a<b )return a;
    return b;
}
int main()
{   int i,n;
    char s[100001];
    scanf("%s",s);
    int l=strlen(s),x=0,y=0;
    
    for(i=0;i<l;i++){
        if(s[i]=='1')x++;
        else y++;
    }
    printf("%d",Min(x,y)*2);
    return 0;
}


Measured memory_bytes: 256
// ABC173 B - Judge Status Summary
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  // 初期値
  int ac = 0, wa = 0, tle = 0, re = 0;
  
  int N;
  cin >> N; 
  
  vector<string> S(N);
  for (int i = 0; i < N; i++){
    cin >> S.at(i);
  }
  
  //Main loop
  for (int i = 0; i< N; i++){
    // cout << S.at(i) << endl;
    
    if (S.at(i) == "AC")
      ac++;
  	else if (S.at(i) == "WA")
      wa++;
  	else if (S.at(i) == "TLE")
      tle++;
  	else if (S.at(i) == "RE")
      re++;
  }
  
  //Output
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  
  return 0;
}


Measured memory_bytes: 6404
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
 
class Program
{
    static void Main()
    {
        var input = Console.ReadLine();
        var equal = input[0] == input[input.Length - 1];
        var even = input.Length % 2 == 0;
        Console.WriteLine(equal ^ even ? "Second" : "First");
    }
}


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

using namespace std;

const int N = 1e5 + 5;
long long n, m, arr[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    cin >> n >> m;
    bool can = true;
    set<int> st;
    for(int i = 1; i <= n; i++){
        cin >> arr[i];
        int m = arr[i];
        int cnt = 0;
        while(m % 2 == 0){
            cnt++;
            m /= 2;
        }
        st.insert(cnt);
        arr[i] /= 2;
    }

    if(st.size() == 1){
        long long ans = arr[1];
        for(int i = 2; i <= n; i++){
            long long x = ans * arr[i];
            x /= __gcd(ans, arr[i]);
            ans = x;
        }
        long long te = (m + ans) / (2 * ans);
        cout << te << '\n';
    } else {
        cout << 0 << '\n';
    }
    return 0;
}

Measured memory_bytes: 1024