akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
using System.Runtime.InteropServices.ComTypes;

class Program
{
    static char[] abc = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
    static long mod = 1000000007;
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());

        var low = 0;
        var high = N - 1;
        var cont = true;

        Console.WriteLine(0);
        var now = Console.ReadLine();
        var now2 = now;
        if (now == "Vacant")
        {
            cont = false;
        }

        if (cont)
        {
            Console.WriteLine(N - 1);
            now2 = Console.ReadLine();
        }
        if (now2 == "Vacant")
        {
            cont = false;
        }

        while (now != "Vacant" && cont)
        {
            var mid = (low + high) / 2;
            Console.WriteLine(mid);

            var tmp = Console.ReadLine();
            if (tmp == "Vacant")
            {
                break;
            }

            if ((mid - low) % 2 == 0 && tmp == now)
            {
                low = mid + 1;
                now = (tmp == "Male") ? "Female" : "Male";
            }else if ((mid - low) % 2 == 0 && tmp != now)
            {
                high = mid - 1;
            }
            else if ((mid - low) % 2 == 1 && tmp != now)
            {
                low = mid + 1;
                now = (tmp == "Male") ? "Female" : "Male";
            }
            else
            {
                high = mid - 1;
            }
        }
    }



}


Measured memory_bytes: 27448
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
//const ll mod = 1000 * 1000 * 1000 + 7;




void solve() {
    string s;
    cin >> s;
    int n = s.size();
    if ((s[0] != s[s.size() - 1]) ^ (n & 1))
        cout << "Second\n";
    else
        cout << "First\n";
}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


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

int n,k,mod=1e9+7,ans;
int a[100005],jc[100005];

int quick_power(int a,int b)
{
	int res=1;
	for (;b;b=b>>1,a=(a*a)%mod)
	{
		if (b&1)  res=(res*a)%mod;
	}
	return res;
}

int ny(int k)
{
	return quick_power(k,mod-2);
}

int C(int n,int k)
{
	if (n<=0||k<0||n<k)  return 0;
	if (n==k||k==0)  return 1;
	if (2*k>n)  k=n-k;
	
	return ((jc[n]*ny(jc[n-k]))%mod*ny(jc[k]))%mod;
}

int init()
{
	jc[0]=1;
	for (int i=1;i<=100000;i++)  jc[i]=(jc[i-1]*i)%mod;
}

signed main()
{
	cin>>n>>k;
	init();
	for (int i=1;i<=n;i++)  cin>>a[i];
	
	sort(a+1,a+n+1);
	
	for (int i=1;i<=n;i++)  ans=((ans+a[i]*(C(i-1,k-1)-C(n-i,k-1)))%mod+mod)%mod;
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
N = gets.to_i
 array = gets.split.map(&:to_i)
 count = 0
 array.combination(3).each do |a, b, c|
   if a != b && b != c && a != c && a + b > c && b + c > a && c + a > b
     count += 1
   end
 end

 puts count


Measured memory_bytes: 14328
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    string s;
    int ans1=0,ans2=0,len;
    cin>>s;
    len=s.length();
    for(int i=0;i<len;i++){
        if(i%2){
            if(s[i]=='1')ans1++;
            else ans2++;
        }
        else {
            if(s[i]=='1') ans2++;
            else ans1++;
        }
    }
    if(ans1<=ans2)cout<<ans1<<endl;
    else cout<<ans2<<endl;
    return 0;
}

Measured memory_bytes: 512
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	var s, t string
	fmt.Scan(&n, &s, &t)
	var ans []string
	sa := strings.Split(s, "")
	ta := strings.Split(t, "")
	for i := 0; i < n; i++ {
		ans = append(ans, sa[i]+ta[i])
	}
	a := strings.Join(ans, "")
	fmt.Println(a)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int num[4];
int main()
{
    int n;
    cin>>n;
    string s[]={"AC","WA","TLE","RE"};
    string str;
    while(n--)
    {
        cin>>str;
        for(int i=0;i<4;i++)
        {
            if(s[i]==str) num[i]++;
        }
    }
    for(int i=0;i<4;i++)
    {
        cout<<s[i]<<" x "<<num[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3576
N=int(input())
p=list(map(int, input().split()))
B=sorted(p)
for i in range(N):
    if i+1==p[i]:
        pass
    else:
        index=p.index(i+1)
        p[i], p[index]=p[index], p[i]
        break
if p==B:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;

int main(){
	int n; cin >> n;
	string s; cin >> s;
	rep(i, s.length()){
		s[i] = s[i] + n;
		if(s[i] > 'Z') s[i] -= 26;
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main()
{
  int i, j, n, q, C, *S, *T;
  C = 0;
  
  scanf("%d", &n);
  S = malloc( n * sizeof(int));
  for( i=0; i<n; i++ ) scanf("%d", &S[i]); 

  scanf("%d", &q);
  T = malloc( q * sizeof(int));

  for( i=0; i<q; i++ )
    {
      scanf("%d", &T[i]);
      
      for( j=0; j<n; j++ )
	{
	  if( T[i] == S[j] )
	    {
	      C++;
	      break;
	    }
	}
    }
	  
  printf("%d\n", C);

  return 0;
}
  
  



Measured memory_bytes: 2108
#!/usr/bin/env python3
#ABC134 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = [I() for _ in range(n)]
b = sorted(a)
for i in range(n):
    if a[i] == b[-1]:
        print(b[-2])
    else:
        print(b[-1])


Measured memory_bytes: 60496
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    vector<int> v;
    for(int i = 0; i <3 ; i++){
        int in;
        cin >> in;
        v.push_back(in);
    }
    sort(v.begin(), v.end());
    int k;
    cin >> k;
    for(int i = 0; i < k; i++){
        v.back() = v.back() * 2;
    }
    cout << v[0] + v[1] + v[2] << endl;

        return 0;
}

Measured memory_bytes: 256
import sys

A,B,C,K = map(int,input().split())

if not ( 0 <= A and 0 <= B and 0 <= C ): sys.exit()
if not ( 1 <= K <= A+B+C and A+B+C <= 2 * 10**9 ): sys.exit()

sum = 0
if A >= 1 and K <= A:
    print(K)
    sys.exit()
elif A >= 1 and K > A:
    sum += A
    K -= A
    A = 0

if B >= 1 and K <= B:
    print(sum)
    sys.exit()
elif B >= 1 and K > B:
    K -= B
    B = 0

if C >= 1 and K <= C:
    sum -= K
    C = 0
elif C >= 1 and K > C:
    sum -= C
    print(sum)
    sys.exit()

print(sum)

Measured memory_bytes: 9108
#include <iostream>
#include <vector>

using namespace std;

int count_ones(int num) {
    int val = 0;
    while (num > 0) {
        num &= (num - 1);
        val++;
    }

    return val;
}

bool check(int test, vector <vector <int> > &ts, int n) {
    vector <int> honest_mask(n, -1);
    for (int mask = 0; mask < n; mask++) {
        // if the current person is considered as being honest
        if (test & (1 << mask)) {

            for (int i = 0; i < n; i++) {
                if (honest_mask[i] == -1) {
                    honest_mask[i] = ts[mask][i];
                }
                else if (ts[mask][i] != -1 && honest_mask[i] != ts[mask][i])
                    return false;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        if (honest_mask[i] == -1)
            continue;
        if (honest_mask[i] == ((test & (1 << i)) > 0))
            continue;
        return false;
    }

    return true;
}

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

    vector <vector <int> > testimonies(n, vector <int> (n, -1));

    for (int i = 0; i < n; i++) {
        cin >> m;
        for (int j = 0; j < m; j++) {
            cin >> a >> b;
            testimonies[i][a - 1] = b;
        }
    }

    int sol = 0, num_honest;

    for (int test = 1; test < (1 << n); test++) {
        num_honest = count_ones(test);
        if (sol < num_honest && check(test, testimonies, n)) {
            sol = num_honest;
        }
    }
    
    cout << sol;
    return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pi acos(-1)
#define pb push_back
#define lowbit(x) x&(-x)
#define PII  pair<int, int> 
#define FAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;
using namespace std;

int a[105];

int main()
{
	int n, x; scanf("%d %d", &n, &x);
	for(int i = 1; i <= n; i++){
		scanf("%d", a + i);
	}
	sort(a + 1, a + n + 1);
	a[n+1] = inf;
	ll sum = 0;
	int cnt = 0;
	while(sum < x){
		sum += a[++cnt];
	}
	if(cnt == n + 1) cnt--;
	if(sum != x) cnt--;
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 256
s = input()
begin = 0
last = len(s)-1
for i in range(len(s)):
  if s[i] == 'A':
    begin = i
    break
for i in range(len(s)-1, -1, -1):
  if s[i] == 'Z':
    last = i
    break
print(last-begin+1)

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9+1)
#define MAXX (int)1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (ll)(1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
//ceil(a/(double)b)=(a+b-1)/b
//printf("myco\n");//for debug
/*--------------------------------------------*/
int main(){
    int n;cin>>n;
    V a(n+1);
    V b(n);
    rep(i,n+1)cin>>a[i];
    rep(i,n)cin>>b[i];
    ll cnt=0;
    rep(i,n){
        if(a[i]+a[i+1]<=b[i]){
            cnt+=a[i]+a[i+1];
            a[i]=0;
            a[i+1]=0;
        }
        else{
            if(a[i]>=b[i]){
                cnt+=b[i];
                a[i]-=b[i];
            }
            else{
                cnt+=a[i];
                if(a[i+1]-(b[i]-a[i])){
                    cnt+=b[i]-a[i];
                    a[i+1]-=b[i]-a[i];
                }else{
                    cnt+=a[i+1];
                    a[i+1]=0;
                }
                a[i]=0;                   
            }
        }
        //printf("cnt=%d\n",cnt);
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 1024
w=input()
w_count=0
T=[]
t=list(map(str,input().split()))

while t!=['END_OF_TEXT']:
    for i in range(len(t)):
        t[i]=t[i].lower()
    T.append(t)
    t=list(map(str,input().split()))

for i in range(len(T)):
    for j in range(len(T[i])):
        if T[i][j]==w:
            w_count=w_count+1
print(w_count)



Measured memory_bytes: 5560
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
	int H,W,A,B; cin >> H >> W >> A >> B;
	rep(i,H){
		rep(j,W){
			if(i <= B-1 && j <= A-1){
				cout << 1;
			}
			if(i <= B-1 && j >= A){
				cout << 0;
			}
			if(i >= B && j <= A-1){
				cout << 0;
			}
			if(i >= B && j >= A){
				cout << 1;
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1280
#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;

int l, r, d;
int cnt;

int main() {
    cin >> l >> r >> d;
    int i = l / d;
    for (; i * d <= r; i++) {
        if (i * d <= r && i * d >= l) {
            cnt++;
      }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3196
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func main() {
	sc.Split(bufio.ScanWords)
	L, R := getInt(), getInt()

	const r = 2019
	s := L
	e := min(s+r*2, R)

	ans := r
	for i := s; i < e; i++ {
		for j := s + 1; j <= e; j++ {
			ans = min(ans, (i*j)%r)
		}
	}

	out(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin, (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
typedef pair<int, int> P;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
	  fac[i] = fac[i-1] * i % MOD;
	  inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
	  finv[i] = finv[i-1] * inv[i] % MOD;
	}
}
//組み合わせ
long long COM (int n, int k) {
	if(n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
void solve() {
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep (i, h) {
		cin >> s[i];
	}	
	int ans = 0;
	rep (si, h) {
		rep (sj, w) {
			if (s[si][sj] == '#') continue;
			vector<vector<int>> dist(h, vector<int>(w, INF));
			queue<P> q;
			auto update = [&](int i, int j, int x) {
				if (dist[i][j] != INF) return;
				dist[i][j] = x;
				q.push(P(i, j)); //.emplace(i, j)
			};
			update(si, sj, 0);
			while(!q.empty()) {
				int i = q.front().first;
				int j = q.front().second; q.pop();
				rep (dir, 4) {
					int ni = i+di[dir], nj = j+dj[dir];
					if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
					if (s[ni][nj] == '#') continue;
					update(ni, nj, dist[i][j] + 1);
				}
			}
			rep (i, h) {
				rep (j, w) {
					if (dist[i][j] == INF) continue;
					ans = max(ans, dist[i][j]);
				}
			}
		}
	}
	cout << ans << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define INF 1LL<<62

int main() {
	ll l,r;
	cin>>l>>r;
	ll ans=INF;
	for(ll i=l;i<=min(l+3000,r);i++){
		for(ll j=i+1;j<=min(i+1+3000,r);j++){
			ll now=i*j;
			now%=2019;
			ans=min(ans,now);
		}
	}
	cout <<ans;
	return 0;
}

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

int a[100005];
int main() {
	int n;
	cin>>n;
	int maxx = 0, minn = n + 1;
	for (int i = 1; i <= n; i++) {
		cin>>a[i];
		maxx = max(maxx, a[i]);
		minn = min(minn, a[i]);
	}
	if (maxx > minn + 1)
		return puts("No"), 0;
	if (maxx == minn) {
		if (minn == n - 1)
			return puts("Yes"), 0;
		if ( (minn << 1) <= n)
			return puts("Yes"), 0;
		else
			return puts("No"), 0;
	} else {
		int cnt = 0;
		for (int i = 1; i <= n; i++)
			cnt += (a[i] == minn);
		if (minn < cnt)
			return puts("No"), 0;
		if (n - cnt < ((maxx - cnt) << 1) )
			return puts("No"), 0;
		else
			return puts("Yes"), 0;
	}
}

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

int main() {
    int N, tmp, A[100000];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        A[i] = tmp - 1; //配列のインデックスに調整
    }
    int index = 0, res = -1;
    for (int i = 0; i < N; i++) {
        index = A[index];
        if (index == 1) {
            res = i + 1;
            break;
        }
    }
    cout << res << endl;
    return 0;
}

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

#define MOD 1000000007LL
#define ll long long

using namespace std;

int main(void){
    ll L, R, d;
    cin >> L >> R >> d;
    ll ans = 0;
    for(ll n = 1; n <= 100; n++){
        if(L <= n * d && n * d <= R) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int k;
  string s;
  cin >> k >> s;
  if(s.length() <= k) cout << s << endl;
  else{
    string ans;
    ans = s.substr(0,k);
    ans += "...";
    cout << ans << endl;
  }
  return 0;
}


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

const int mod = 1000000007;

// K の桁数
int N;
int D;

// K の上から n 桁目 (0-indexed)
int K[10009];

int dp[10009][2][109];

int main() {
    string s;
    cin >> s;
    N = s.size();
    for(int i = 0; i < N; i++)
        K[i] = s[i] - '0';

    cin >> D;

    dp[0][0][0] = 1;

    for(int i = 0; i < N; i++) {
        for(int d = 0; d < D; d++) {
            // j = 1 -> j = 1
            for(int k = 0; k <= 9; k++) {
                dp[i + 1][1][(d + k) % D] += dp[i][1][d];
                dp[i + 1][1][(d + k) % D] %= mod;
            }
            // j = 0 -> j = 1
            for(int k = 0; k < K[i]; k++) {
                dp[i + 1][1][(d + k) % D] += dp[i][0][d];
                dp[i + 1][1][(d + k) % D] %= mod;
            }
            // j = 0 -> j = 0
            dp[i + 1][0][(d + K[i]) % D] += dp[i][0][d];
            dp[i + 1][0][(d + K[i]) % D] %= mod;
        }
    }

    // 0 が含まれているので、1 引く
    int res = (dp[N][0][0] + dp[N][1][0] - 1 + mod) % mod;
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*b);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}



class UnionFind{
	vector<int> par,siz;
	//0-indexed
	void init(int n){
		component = n;
		par.resize(n);
		for(int i=0;i<n;++i)par[i]=i;
		siz.resize(n,1);
		msiz = 1;
	}
public:
	int msiz,component;
	UnionFind(int n_){init(n_);}
	int root(int x){
		if(par[x]==x)return x;
		return par[x] = root(par[x]);
	}
	void unite(int x,int y){
		x = root(x);
		y = root(y);
		if(x==y)return;
		siz[y] += siz[x];
		siz[x] = 0;
		par[x] = y;
		msiz = max(msiz,siz[y]);
		component--;
	}
	int size(int x){
		return siz[root(x)];
	}
	bool same(int x,int y){
		return root(x)==root(y);
	}
};

int main(){

	ll N,M;
	cin >> N >> M;

	UnionFind uf(N);
	FOR(i,0,M){
		ll a,b;
		cin >> a >> b;
		uf.unite(a-1,b-1);
	}

	cout << uf.component-1 << endl;

}


Measured memory_bytes: 3976
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
#define clr0(a) memset(a,0,sizeof(a))
#define clr1(a) memset(a,-1,sizeof(a))
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
int main()
{
    timesave;
    double n;
    cin>>n;
    double ans=2*acos(-1)*n;
    printf("%.12lf\n",ans);
    return 0;
}






Measured memory_bytes: 3832
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<iterator>
#include<iostream>
#include<sstream>
#include<cctype>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<stack>
#include<functional>
#include<utility>
#include<numeric>
#include<bitset>
#include<iterator>
#define INF (int)1e9
#define MOD 1000000007
#define tr(c, it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define debug(x) cout<<#x" = "<<(x)<<endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz size
#define ll long long
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MEM(a, b) memset(a, (b), sizeof(a))
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?"\n":" ")
#define printv(a) printa(a,0,a.size())
#define print2d(a,r,c) for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?"\n":" ")
#define PRE(i, m, n, in) for(int (i)=(m);(i)<(n);i+=in)
#define RFOR(i, n) for(int i=n ; i>=0 ; i--)
#define RPRE(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define ERS(A, P) A.erase(A.begin() + P)
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<int>())
#define mnv(v) *min_element(v.begin(),v.end())
#define mxv(v) *max_element(v.begin(),v.end())
#define countv(v,a) count(v.begin(),v.end(),a)
#define toint(a) atoi(a.c_str())
using namespace std;
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
typedef vector <int> VI;
typedef vector <ll> VL;
typedef vector<string> VS;
typedef vector <VS> VSS;
typedef vector <II> VII;
typedef vector <LL> VLL;
typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VII> VVII;
typedef vector <VLL> VVLL;
typedef map<int,int> MPII;
typedef map<ll,ll> MPLL;
typedef map<string, int>MPSI;
typedef map<string, ll>MPSL;
typedef map<int, string>MPIS;
typedef map<ll, string> MPLS;
typedef map<string, string> MPSS;
typedef set<int> SETI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// freopen("input.txt", "r", stdin);
  int n; cin >> n; int k; cin >> k;
  VI h(n); FOR(i, n) {
    cin >> h[i];
  }
  VI dis(n);
  dis[1] = dis[0] + abs(h[1] - h[0]);
  PRE(i, 2, n, 1) {
    dis[i] = dis[i - 1] + abs(h[i - 1] - h[i]);
    for(int j = 2; i - j >= 0 && j <= k; j += 1) {
        dis[i] = min(dis[i], dis[i - j] + abs(h[i - j] - h[i]));
    }
    // printv(dis);
  }
  cout << dis[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 1024
k,a,b = gets.split.map(&:to_i)

if b - a <= 2 || k-(a+1) < 0
  puts k+1
  exit
end

ans = 0
k = k-(a+1)
cnt = 1
cnt += k/2

ans = cnt * (b-a) + a + (k%2)

puts ans

Measured memory_bytes: 1788
package main

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

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

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	x := scanInt()
	if x < 600 {
		fmt.Fprintln(wr, 8)
	} else if x < 800 {
		fmt.Fprintln(wr, 7)
	} else if x < 1000 {
		fmt.Fprintln(wr, 6)
	} else if x < 1200 {
		fmt.Fprintln(wr, 5)
	} else if x < 1400 {
		fmt.Fprintln(wr, 4)
	} else if x < 1600 {
		fmt.Fprintln(wr, 3)
	} else if x < 1800 {
		fmt.Fprintln(wr, 2)
	} else {
		fmt.Fprintln(wr, 1)
	}
}


Measured memory_bytes: 1780
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5
5
1
3
2
4

or

3
1
1
1

output:
3

or

1
"""

import sys
from bisect import bisect_left


def solve():
    dis_rec = [float('inf')] * array_length
    dis_rec[0] = array[0]
    length = 1
 
    for i, ele in enumerate(array, 1):
        if dis_rec[length - 1] < ele:
            dis_rec[length] = ele
            length += 1
        else:
            position = bisect_left(dis_rec, ele)
            dis_rec[position] = ele

    return length


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(int, _input[1:]))
    print(solve())

Measured memory_bytes: 19504
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)

using namespace std;

int calc(vector<int> cup, int m)
{
    int cnt = 0;
    while (1) {
        int i = cnt%2, j = i+1;
        int p = 1;
        while (p <= max(cup[i], cup[j])) p <<= 1;
        p >>= 1;
        if (!p) break;
        cup[i] ^= p;
        cup[j] ^= p;
        cnt++;
        if (cnt > m) return cnt;
    }

    return cnt;
}

int main()
{
    while (1) {
        int n, m; cin >> n >> m;
        if (n == 0 && m == 0) break;
        vector<int> cup(3);
        loop (3, i) {
            int c; cin >> c;
            while (c--) {
                int v; cin >> v;
                cup[i] |= 1 << v--;
            }
        }
        int ans = calc(cup, m);
        swap(cup[0], cup[2]);
        ans = min(ans, calc(cup, m));
        cout << (ans <= m ? ans : -1) << endl;
    }
    return 0;
}

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

  int findsum(int N){
    int sumx =0;
    while(N>0){
      sumx += N%10;
      N /=10;
    }
    return sumx;
  }

int main () {

  int n,a,b;
  cin >>n>>a>>b;
  int cnt =0;
  for (int i=1;i<=n;i++){
    int sum = findsum(i);
    if(sum >=a && sum <=b){
      cnt += i;
    }
  }

  cout <<cnt <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main(){
  int A, B, K;
  int i,idx=0,res[100];
  cin >> A >> B >> K;
  
  if(B>A){
    A=A+B;
    B=A-B;
    A=A-B;
  }
  
  for(i=B;i>=1;i--){
    if(A%i==0 && B%i==0){
      res[idx]=i;
      idx++;
    }
  }
  
  cout << res[K-1] << endl;
  
  
  return 0;
}

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

using ll = long long;
using ld  = long double;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define p_b push_back
#define SZ(x) ((ll)(x).size()) //size()がunsignedなのでエラー避けに
#define endk '\n'


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //




// --------- library end - //


int main(){


  string S = is();
  ll ans = 0;
  for (char c : S) ans += c - '0';

  if (ans % 9 == 0) cout << "Yes" << endk;
  else cout << "No" << endk;




  
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using PP = tuple<lint, int, int>;
using vec = vector<lint>;
using mat = vector<vector<lint>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const lint INF = 1LL << 60;

const lint COST = 100000000;

int ddx[] = {1, 0, -1, 0};
int ddy[] = {0, 1, 0, -1};

int main() {
    int h, w;
    cin >> h >> w;
    int sy, sx;
    int gy, gx;
    cin >> sy >> sx >> gy >> gx;
    sy--; sx--; gy--; gx--;
    vector<string> grid(h);
    rep(i, h) cin >> grid[i];

    mat dist(h, vec(w, INF));
    dist[sy][sx] = 0;

    priority_queue<PP, vector<PP>, greater<PP>> que;
    que.push({0, sy, sx});

    while (!que.empty()) {
        auto pos = que.top();
        int t_dist = get<0>(pos);
        int y = get<1>(pos);
        int x = get<2>(pos);
        que.pop();

        if (dist[y][x] < t_dist) continue;

        rep(i, 4) {
            int ty = y + ddy[i];
            int tx = x + ddx[i];

            if (ty >= 0 && ty < h && tx >= 0 && tx < w) {
                if (grid[ty][tx] == '.' && dist[ty][tx] > dist[y][x] + 1) {
                    dist[ty][tx] = dist[y][x] + 1;
                    que.push({dist[ty][tx], ty, tx});
                }
            }
        }

        for (int dx = -2; dx <= 2; dx++) {
            for (int dy = -2; dy <= 2; dy++) {
                int ty = y + dy;
                int tx = x + dx;

                if (ty >= 0 && ty < h && tx >= 0 && tx < w) {
                    if (grid[ty][tx] == '.' && dist[ty][tx] > dist[y][x] + COST) {
                        dist[ty][tx] = dist[y][x] + COST;
                        que.push({dist[ty][tx], ty, tx});
                    }
                }
            }
        }
    }

    if (dist[gy][gx] == INF) cout << "-1" << endl;
    else cout << dist[gy][gx] / COST << endl;
    return 0;
}

Measured memory_bytes: 13444
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,st,en) for(i=st;i<=en;i++)
#define repv(i,en,st) for(i=en;i>=st;i--)
#define fout cout<<fixed<<setprecision(7)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)


typedef long long ll;
typedef pair<int,int> pii;
const int N = 100010;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}



int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1,n,i,j;
    int a,b;
    cin>>a>>b;
    if(a!=2 && b!=2)cout<<"Yes\n";
    else cout<<"No\n";
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using namespace std;
map <string,int> cost;
multimap <string,string>  rule;
set <string> his,his2;
int flg;

void update(string a){
  his2.insert(a);
  multimap<string,string>::iterator it=rule.find(a);
  while(it != rule.end() && it->first == a) {
    if(his2.count(it->second)==0&&cost[it->second]>cost[a])cost[it->second] =cost[a],update(it->second);
    it++;
  }
}
int  mk_rule(string a){
  if(his.count(a) == 0){
    his.insert(a);    
    multimap<string,string>::iterator it=rule.find(a);
    while(it != rule.end() && it->first == a) {
      cost[a] = min(cost[a],mk_rule(it->second));
      it++;
    }
    his2.clear() , update(a);
  }
  return cost[a];
}

int main(){
  int n,m,b;
  cin >> n;
  string a,c,ls[5002];
  for(int i=0;i<n;i++) {
    cin >> a >> b;
    cost[a] = b , ls[i] = a;
  }
  cin >> m;
  for(int i=0;i<m;i++){
    cin >> a >> c;
    rule.insert(pair<string,string>(a,c));
    rule.insert(pair<string,string>(c,a));
  }
  int ans=0;
  for(int i=0;i<n;i++) ans += mk_rule(ls[i]);
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 2244
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  unordered_map<long, long> foo;
  long N;
  cin >> N;
  rep (i, N) { long tmp; cin >> tmp; foo[tmp]++; }
  long M;
  cin >> M;
  rep (i, M) { long tmp; cin >> tmp; foo[tmp]--; }
  for (auto it: foo) {
    if (it.second < 0) {
      cout << "NO" << endl;
      return;
    }
  }
  cout << "YES" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int main(){
  int n,x,t;
  std::cin >> n>>x>>t;

  int cnt=n/x;
  if(n%x!=0)cnt++;
  std::cout << cnt*t << '\n';
  



  return 0;
}


Measured memory_bytes: 3568
N, A, B, C = map(int, input().split())
lst = [int(input()) for _ in range(N)]

def dfs(i, a, b, c):
    if i == N:
        if min(a, b, c) == 0:
            return 1000000000
        else:
            return sum([abs(A - a), abs(B - b), abs(C - c)]) - 30

    n = i + 1
    x = lst[i]
    ret1 = dfs(n, a, b, c)
    ret2 = dfs(n, a + x, b, c) + 10
    ret3 = dfs(n, a, b + x, c ) + 10
    ret4 = dfs(n, a, b, c + x) + 10
    return min(ret1, ret2, ret3, ret4)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000007
#define int long long
#define ll long long
#define EPS 0.00000000000001
#define ld long double
#define inf 20000000
#define N 100001


int32_t main()
{
    IOS;

    int n;
    cin >> n;
    vector<pair<int,int>> v(n);
    for(int i = 0;i < n;i++)
    {
        cin >> v[i].first;
        v[i].second = i + 1;
    }
    sort(v.begin(),v.end());
    for(int i = 0;i < n;i++)
        cout << v[i].second << " " ;

    return 0;
}
 
 

Measured memory_bytes: 2432
import math
a,b,x=map(int,input().split())
if x <=b*(a**2)/2:
  k=math.degrees(math.atan(a*(b**2)/(2*x)))
  print(k)
else:
  k=math.degrees(math.atan(2*b/a-2*x/a**3))
  print(k)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
bool v[100005];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	while(m--)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		v[a]^=1;v[b]^=1;
	}
	for(int i=1;i<=n;i++)if(v[i]){puts("NO");return 0;}
	puts("YES");
	return 0;
}

Measured memory_bytes: 384
#pragma hdrstop
#pragma argsused

#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int main()
{
	int n, q, query, x, t;
	cin >> n >> q;
	vector<queue<int> > Q(n);
    for (int i = 0; i < q; ++i)
	{
		cin >> query;
		switch (query)
        {
		case 0:
            cin >> t >> x;
			Q[t].push(x);
			break;
		case 1:
			cin >> t;
			if (!Q[t].empty()) //S[t]が空でなければ
			{
				cout << Q[t].front() << endl;
			}
			break;
		case 2:
			cin >> t;
			if (!Q[t].empty())
			{
				Q[t].pop();
			}
			break;
		}
	}
}


Measured memory_bytes: 4292
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<unsigned char, unsigned char> pcc;
typedef pair<double, double> pdd;
typedef vector<vector<ll>> matrix;

vector<int> edges[100005];
int dp[100005][3];
bool present[100005];

void solve() {
  int n, m;
  cin >> n >> m;
  while(m--) {
    int a, b;
    cin >> a >> b;
    edges[a].push_back(b);
  }
  int s, t;
  cin >> s >> t;
  for(int i = 1; i <= n; i++) {
    dp[i][0] = 1 << 25;
    dp[i][1] = 1 << 25;
    dp[i][2] = 1 << 25;
  }
  dp[s][0] = 0;
  queue<int> q;
  q.push(s);
  while(!q.empty()) {
    int curr = q.front(); q.pop();
    present[curr] = false;
    for(int out: edges[curr]) {
      for(int a = 0; a < 3; a++) {
        if(dp[out][(a+1)%3] > dp[curr][a] + 1) {
          dp[out][(a+1)%3] = dp[curr][a] + 1;
          if(!present[out]) {
            present[out] = true;
            q.push(out);
          }
        }
      }
    }
  }
  if(dp[t][0] == 1 << 25) cout << "-1\n";
  else cout << dp[t][0] / 3 << "\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ":" << "\n";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 7040
v = [0]*9
n = int(input())
a = list(map(int,input().split()))
for i in a:
  idx = i//400
  if idx >= 8: idx = 8
  v[idx] += 1
r = 0
for i in range(8):
  if v[i] >= 1: r+= 1
print(max(1,r), r+v[8])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod


const ll MaxN=2010001;

ll f[MaxN], rf[MaxN];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    REP(i, 1, MaxN) f[i] = (f[i - 1] * i) % mod;
    REP(i, 0, MaxN) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll C(ll n, ll k) {
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}

ll ruijou(ll n, ll k){
    if(!k) return 1;
    ll a=ruijou(n,k/2);
    a=(a*a)%mod;
    return k%2 ? (a*n)%mod : a;
}

int main(){
    init();
    ll K,S; string s; cin>>K>>s;
    S=s.size();
    ll ans=0;
    rep(i,K+1) ADD(ans,ruijou(25,i)*C(K+S,i)%mod);
    cout<<ans<<endl;
}

Measured memory_bytes: 36708
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main(void){
  int N, input, L, R;
  int sum = 0;
  vector<int> X, ans;

  cin >> N;
  for(int i=0; i<N; i++){
    cin >> input;
    X.push_back(input);
  }
  sort(X.begin(), X.end());
  L = X[0];
  R = X[X.size() - 1];
  for(int i=L; i<=R; i++){
    sum = 0;
    for(int j=0; j<X.size(); j++){
      sum += pow(X[j] - i, 2);
    }
    ans.push_back(sum);
  }
  sort(ans.begin(), ans.end());
  cout << ans[0] << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int K,S;
    cin >> K >> S;
    int X,Y,Z;
    int count = 0;
    for(int i = 0;i<=K;i++){
        for(int j = 0;j<=K;j++){
            if(K>= S-i-j&&S-i-j >= 0 )count++;
        }
    }
    cout << count << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<double> p(n);
    for (int i = 0; i < n; i++) std::cin >> p[i];

    std::vector<std::vector<double>> dp(n, std::vector<double>(n + 1));
    dp[0][1] = p[0];
    dp[0][0] = 1 - p[0];
    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= i + 1; j++) {
            dp[i][j] = dp[i - 1][j] * (1 - p[i]) + (j ? dp[i - 1][j - 1] : 0) * p[i];
        }
    }

    double ret = 0;
    for (int i = (n + 1) / 2; i <= n; i++) {
        ret += dp[n - 1][i];
    }
    printf("%.10lf\n", ret);

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

struct Edge {
  int to, id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c = -1, int p = -1) {
  int k = 1;
  rep(i, g[v].size()) {
    int u = g[v][i].to, ei = g[v][i].id;
    if (u == p) continue;
    if (k == c) k++;
    ans[ei] = k;
    k++;
    dfs(u, ans[ei], v);
  }
}

int main() {
  int n;
  cin >> n;
  g.resize(n);
  ans.resize(n - 1);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].emplace_back((Edge){b, i});
    g[b].emplace_back((Edge){a, i});
  }
  dfs(0);
  int mx = 0;
  rep(i, n) mx = max(mx, int(g[i].size()));
  cout << mx << endl;
  rep(i, n - 1) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 8320