akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

struct edge{
    int to;
    long long int cost;
};

struct Node{
    int point;
    long long int cost;
};

long long int cost[100001]={0};
vector<edge> tree[100001];

int main(){
    int n;
    cin >> n;
    for(int i=0;i<=n;++i)cost[i] = LLONG_MAX;
    for(int i=0;i<n-1;++i){
        int a,b,c;
        cin >> a >> b >> c;
        tree[a].push_back((edge){b,c});
        tree[b].push_back((edge){a,c});
    }
    int q, k;
    cin >> q >> k;
    queue<Node> que;
    que.push((Node){k, 0});
    cost[k] = 0;
    while(!que.empty()){
        Node now = que.front(); que.pop();
        for(int i=0;i<tree[now.point].size();++i){
            if(cost[tree[now.point][i].to] == LLONG_MAX){
                long long int newcost = now.cost + tree[now.point][i].cost;
                cost[tree[now.point][i].to] = newcost;
                que.push((Node){tree[now.point][i].to, newcost});
            }
        }
    }
    for(int i=0;i<q;++i){
        int x, y;
        cin >> x >> y;
        cout << cost[x] + cost[y] << endl;
    }

    return 0;
}


Measured memory_bytes: 11008
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<bitset>
#define Fail puts("NO"),exit(0);
#define eps 1e-10
#define maxn 100010
#define maxm 150010
#define inf 1000000007 
//#define mod 1000000009
#define inv 500000005
#define G 3
#define pi acos(-1)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll,int>pii;
typedef bitset<maxn> bit;
typedef long double ld;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
int head[maxn],nxt[maxn*2],to[maxn*2],tot;
void add(int u,int v)
{
    tot++;
    nxt[tot]=head[u];
    head[u]=tot;
    to[tot]=v;
}
int dep[maxn],rt;
void dfs(int x,int las)
{
    for(int i=head[x];i;i=nxt[i])
    {
        if(to[i]==las)  continue;
        dep[to[i]]=dep[x]+1;
        dfs(to[i],x);
    }
}
int fa[maxn],deg[maxn],bot,bott;
void dfs2(int x,int las)
{
    deg[x]=0;
    for(int i=head[x];i;i=nxt[i])
    {
        if(to[i]==las)  continue;
        fa[to[i]]=x;
        deg[x]++;
        dep[to[i]]=dep[x]+1;
        dfs2(to[i],x);
    }
}
int a[maxn],top,ans[maxn],ansx[maxn];
int main()
{
    n=read();
    for(int i=1;i<n;i++)
    {
        int q=read(),w=read();
        add(q,w);add(w,q);
    }
    dfs(1,0);
    rt=1;
    for(int i=1;i<=n;i++)  if(dep[i]>dep[rt])  rt=i;
    dep[rt]=0;
    dfs2(rt,0);
    bot=rt;
    for(int i=1;i<=n;i++)
      if(dep[i]>dep[bot])  bot=i;
    a[top=1]=bot;bott=bot;
    while(fa[bot])  bot=fa[bot],a[++top]=bot;
    int sum=1;
    for(int i=1;i<=top;i++)  sum+=deg[a[i]];
    if(sum!=n)
    {
        puts("-1");
        return 0;
    }
    for(int i=2;i<=top;i++)  deg[a[i]]--;
    int cnt=0,now=0;
    for(int i=1;i<=top;i++)
    {
        ans[now+deg[a[i]]+1]=++cnt;
        for(int j=1;j<=deg[a[i]];j++)  ans[now+j]=++cnt;
        now+=deg[a[i]]+1;
    }
    dfs2(bott,0);
    reverse(a+1,a+top+1);
    for(int i=2;i<=top;i++)  deg[a[i]]--;
    cnt=0;now=0;
    for(int i=1;i<=top;i++)
    {
        ansx[now+deg[a[i]]+1]=++cnt;
        for(int j=1;j<=deg[a[i]];j++)  ansx[now+j]=++cnt;
        now+=deg[a[i]]+1;
    }
    int flag=0;
    for(int i=1;i<=n;i++)
    {
        if(ans[i]==ansx[i])  continue;
        if(ans[i]>ansx[i])  flag=1;
        break;
    }
    if(!flag)
    {
        for(int i=1;i<=n;i++)  printf("%d ",ans[i]);
        puts("");
    }
    else{
        for(int i=1;i<=n;i++)  printf("%d ",ansx[i]);
        puts("");
    }
    return 0; 
}

Measured memory_bytes: 15660
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  if ( 90<= N && N <= 99){
    cout << "Yes" << endl;
  } else if ( N % 10 == 9){
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  }
}

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

#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define inf (long long int) 1e18
#define vi vector<ll> 
#define pii pair<ll, ll>
#define mii map<ll, ll> 
#define mod 1000000007

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

ll palindrome(string s){
    ll l = 0;
    ll h = s.length() - 1;
    while (h > l){
        if (s[l++] != s[h--]){
            return 0;
        }
    }
    return 1;
}

ll modexp(ll a, ll b, ll m){
    if (b==0)
        return 1;
    ll temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/

    int r;
    cin>>r;
    if(r<1200) cout<<"ABC"<<endl;
    else if(r>=1200 && r<2800) cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <deque>
#include <map>
using namespace std;
int main() {
	int n, m;
	int p[1000000];
	string s[1000000];
	int ans[1000000] = {}, wa[1000000] = {},ac[1000000] = {};
	int ans1 = 0, wa1 = 0;
	cin >> n >> m;
	for (int a = 0; a < m; a++) {
		cin >> p[a] >> s[a];
		if (s[a] == "WA" && ac[p[a] - 1] == 0) {
			wa[p[a] - 1]++;
			continue;
		}
		else if (s[a] == "AC" && ac[p[a] - 1] == 0) {
			ans[p[a] - 1]++;
			ac[p[a] - 1]++;
			continue;
		}
	}
	for (int i = 0; i < n; i++) {
		ans1 += ans[i];
	}
	for (int j = 0; j < n; j++) {
		if (ac[j] == 0) {
			continue;
		}
		wa1 += wa[j];
	}
	cout << ans1 << " " << wa1 << endl;
	return 0;
}

Measured memory_bytes: 28416
n,m,x,y = map(int,input().split())
xi = list(map(int,input().split()))
yi = list(map(int,input().split()))

xi.append(x)
yi.append(y)

xi.sort()
xi.reverse()
yi.sort()

if xi[0]<yi[0]:
    print("No War")
else:
    print("War")


Measured memory_bytes: 3060
def comb_mod(n,r,mod):
    a,b=1,1
    r = min(r,n-r)
    for i in range(r):
        a = a*(n-i) % mod
        b = b*(r-i) % mod
    return a * pow(b, mod-2, mod) % mod

def prime_factor(x):
    
    prime_factor=[]
    
    for i in range(2,int(x**0.5)+1):
        if x==1: break

        count = 0
        while x%i == 0:
            x //= i
            count += 1
        if count>0:
            prime_factor.append((i,count))
    
    if x>1: prime_factor.append((x,1))
    
    return prime_factor

MOD = 10**9 + 7

n,m=map(int,input().split())

m_fac = prime_factor(m)

ans = 1
for value,count in m_fac:
    ans = (ans * comb_mod(count+n-1,count,MOD)) %MOD
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

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

	string ans;
	rep(i, 3) {
		ans += s[i];
	}
	cout << ans << endl;
}

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

int main(){
  	int a,b;
  	cin>>a>>b;
  	if(b%a)cout<<b-a;
  	else cout<<a+b;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

template<int mod=1000000007>
class ModInt {
  int x;
public:
  ModInt() : x(0) {}
  ModInt(const ModInt &y): x(y.x) {}
  ModInt(int64_t y){ x = y % mod; if(x < 0) x += mod; }
  ModInt &operator += (const ModInt &p){ x += p.x; if(x >= mod) x -= mod; return *this; }
  ModInt &operator -= (const ModInt &p){ x -= p.x; if(x < 0) x += mod; return *this; }
  ModInt &operator *= (const ModInt &p){ x = (int) (1LL * x * p.x % mod); return *this; }
  ModInt &operator /= (const ModInt &p){ *this *= p.inverse(); return *this; }
  ModInt operator -() const { return ModInt(-x); }
  ModInt operator + (const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator - (const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator * (const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator / (const ModInt &p) const { return ModInt(*this) /= p; }
  ModInt operator ^ (const int64_t y) const { return pow(y); }
  bool operator == (const ModInt &p) const { return x == p.x; }
  bool operator != (const ModInt &p) const { return x != p.x; }
  ModInt operator = (const int64_t y) { return *this = ModInt(y); }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0){
      t = a/b; a -= t*b; swap(a, b);
      u -= t*v; swap(u, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t y) const {
    if(x==0) return ModInt(0);
    int64_t r = 1, t = x;
    while(y > 0){
      if(y&1) r = r*t%mod;
      t = t*t%mod; y >>= 1;
    }
    return ModInt(r);
  }
  friend ostream &operator << (ostream &os, const ModInt<mod> &p) { return os<<p.x; }
  friend istream &operator >> (istream &is, ModInt<mod> &a) { int64_t x; is>>x; a = ModInt<mod>(x); return is; }
};
using Int = ModInt<>;

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];

  a.erase(unique(all(a)), a.end());
  n = a.size();

  map<int,Int> pre;
  vector<Int> dp(n+1, 0);
  dp[0] = 1;
  rep(i,n){
    dp[i+1] = dp[i] + pre[a[i]];
    pre[a[i]] += dp[i];
  }

  cout <<dp[n] << endl;

  return 0;
}


Measured memory_bytes: 11136
import heapq
N, M=map(int, input().split())
A=list(map(int, input().split()))
A=list(map(lambda x: -x, A))
heapq.heapify(A)
for i in range(M):
  heapq.heappush(A, (heapq.heappop(A)+1)//2)
print(-sum(A))

Measured memory_bytes: 73068
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

bool comp(const std::string& lh, const std::string& rh) {
     
    return lh.length() < rh.length();
}

int main(){
  int n;
  cin >> n;
  vector<int> ans(26, 100);
  rep(i, n){
    vector<int> vec(26, 0);
    string str;
    cin >> str;
    rep(j, str.length()) vec[str[j]-'a']++;
    rep(j, 26) ans[j] = min(ans[j], vec[j]);
  }
  string str = "";
  rep(i, 26){
    rep(j, ans[i]){
      str += 'a'+i;
    }
  }
  cout << str << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int M, D, result = 0;
    cin >> M >> D;
    REP(i, M) {
        REP(j, D) {
            if ((j+1)/10 >= 2 && (j+1)%10 >= 2) {
                if (((j+1)/10) * ((j+1)%10) == (i+1)) {
                    result++;
                }
            }
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)
#define AAA (1000000007)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;



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

ll lcm(ll a,ll b) {
	return a / gcd(a, b) * b;
}


int main() {
	int i, j, k;
	ll N, M, K;
	ll ans = 0;

	ll H;
	
	cin >> H;

	int p = log2(H);
	
	ans = pow(2, p+1) - 1;
	cout << ans;
	return 0;


}


Measured memory_bytes: 256
n, m, k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

a_sum = [0]
for i in range(len(a)):
    a_sum.append(a_sum[len(a_sum)-1]+a[i])

b_sum = [0]
for i in range(len(b)):
    b_sum.append(b_sum[len(b_sum)-1]+b[i])

ans = 0
b_i = len(b_sum)-1

for i in range(len(a_sum)):
    if a_sum[i] > k:
        break
    else:
        if b_i > -1:
            while b_sum[b_i] + a_sum[i] > k and b_i > -1:
                b_i -= 1
            if b_i > -1 and ans < i+b_i:
                ans = i+b_i
        else:
            if a_i > ans:
                ans = a_i

print(ans)


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

typedef long long ll;

ll vector_finder(vector<ll> vec, ll number);

int main() {
    ll N, L;

    cin >> N >> L;

    // a: apples
    vector<ll> a(N);

    ll i;
    // 各りんごの味
    for(i = 1; i <= N; i++) {
        a[i - 1] = L + i - 1;
    }

    // りんごを全て使った時の味
    ll sum = 0;
    for(i = 0; i < N; i++) {
        sum += a[i];
    }

    // 0 が含まれていた場合
    if(vector_finder(a, 0)) {
        cout << sum << endl;
        return 0;
    }

    // 絶対値が一番小さい値を探す
    ll min = 10000;
    ll min_idx = 0;
    for(i = 0; i < N; i++) {
        if(abs(a[i]) < min) {
            min_idx = i;
            min = abs(a[i]);
        }
    }
    // cout << sum << endl;
    // cout << a[min_idx] << endl;
    cout << sum - a[min_idx] << endl;

    return 0;
}

ll vector_finder(vector<ll> vec, ll number) {
    auto itr = find(vec.begin(), vec.end(), number);
    size_t index = distance(vec.begin(), itr);
    if(index != vec.size()) { // 発見できたとき
        return 1;
    } else { // 発見できなかったとき
        return 0;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int aa=sc.nextInt();
		int bb= sc.nextInt();

		int a=Math.min(aa, bb);
		int b=Math.max(aa, bb);
		int c;

		while(b%a!=0){
			c=a;
			a=b%a;
			b=c;
		}

		System.out.println(a);

	}
}


Measured memory_bytes: 26244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(v) v.begin(),v.end()
#define PI acos(-1)
#define EPS 1e-15
#define f first
#define s second
 

 
int main(){
	ll x, t;
	cin >> x >> t;
	cout << (x-t > 0? x-t: 0) << endl;
	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())

d={}
for i in range(m):
    p,s=map(str,input().split())
    p=int(p)
    if p in d:
        d[p].append(s)
    else:
        d[p]=[s]

a,b=0,0
for i in d:
    x=d[i]
    temp=0
    flag=1
    for j in range(len(x)):
        if x[j]=="WA":
            b+=1
            temp+=1
        else:
            a+=1
            flag=0
            break

    if flag:
        b-=temp
        
print(a,b)

Measured memory_bytes: 64728
S = input()

new_S = "".join(list(reversed(S)))
string_list = ["dream", "dreamer", "erase", "eraser"]
reverse_string_list = []
for i in range(len(string_list)):
    reverse_string_list.append("".join(list(reversed(string_list[i]))))

can = True
index = 0
for i in range(len(new_S)):
    if index >= len(new_S):
        break
    can2 = False
    for each_string in reverse_string_list:
        if new_S[index:index + len(each_string)] == each_string:
            index += len(each_string) - 1
            can2 = True
    if can2 is False:
        can = False
        break
    index += 1

if can is True:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 45040
s = input()
t = input()

len_s = len(s)
len_t = len(t)

ans = 1000
max_cnt = 0
for i in range(len_s - len_t + 1):
    cnt = 0
    l = []
    for j in range(len_t):
        if s[i : i + len_t][j] == t[j]:
            cnt += 1
        if s[i : i + len_t][j] != t[j]:
            cnt += 0
    max_cnt = max(max_cnt, cnt)

ans = min(ans, len_t - max_cnt)

print(ans)

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> f(n+1, 0);
    int p, ac = 0, pen = 0;
    string s;
    for (int i = 0; i < m; i++) {
        cin >> p >> s;
        if (s == "AC" && f[p]!=-1) {
            ac++;
            pen += f[p];
            f[p] = -1;
        }
        else if (s == "WA" && f[p]!=-1) f[p]++;
    }
    printf ("%d %d\n",ac,pen);
}

Measured memory_bytes: 3712
N = int(input())
H = list(map(int,input().split()))

ans = 0
tmp = 0
for i in range(N-1):
  if H[i]-1 > tmp:
    tmp = H[i]-1
  if H[i] > H[i+1]:
    H[i] = H[i]-1
    if H[i] > H[i+1]:
      ans = 1
  if tmp > H[i]:
    ans = 1
    
if ans == 1 :
  print("No")
else :
  print("Yes")

Measured memory_bytes: 14396
#include<cstdio>
#include<algorithm>
int a[200007],v[2];
int main()
{
    int n,ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%d",a+i);
    for(int i=1,now=0;i<=n+1;++i)
    {
	int p[2]{0,a[i]-now},next[3]{1000000000,1000000000,0},d;
	if(p[0]<p[1]) std::swap(p[0],p[1]);
	for(int j=0;j<2;++j) for(int k=0;k<2;++k) next[j+k]=std::min(std::max(v[j]+p[k],0),next[j+k]);
	d=next[0]>a[i],ans+=d,now=a[i];
	for(int j=0;j<2;++j) v[j]=next[j+d];
    }
    printf("%d",ans);
}


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

// #define int         long long 
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(v)      v.begin(),v.end()
#define ff          first
#define ss          second
#define endl        "\n"
#define mod         1000000007
#define PI          3.14159265 
#define FIO         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define print(x)    for(auto el: x) cout<<el<<" ";cout<<endl;





void solve(){
    
    int n, k;
    cin >> n >> k;

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

    int dp[n] = {0};

    for(int i=1; i<n; i++){
        dp[i] = INT_MAX;
        for(int j= i-1; j >= max(0, i-k); j--)
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
    }

    cout<<dp[n-1]<<endl;

    return;    
}




int32_t main() 
{
    
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    FIO;
    int test;

    // cin>>test;
    test = 1;
    
    while(test--)
        solve();

    return 0;
}

Measured memory_bytes: 4296
#include<string>
#include<stdio.h>
#define foreach(i, c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define rep(i, n) for(int i = 0; i < n; i++)
//#define DEB2(a, i, j) rep(DBi, i){rep(DBj, j){cout<<a[DBi][DBj];}cout<<endl;}
//#define DEBUG
using namespace std;

int W, H;
string matrix[70][70];
string field[70][70];

bool bg(string a, string b){//a > b?
	if(a.length() != b.length())return a.length() > b.length();
	return a > b;
}

int main(){
	while(cin>>W>>H, W||H){
		rep(j, H)rep(i, W){
			string s;
			s = "";
			char c;
			scanf(" %c", &c);
			if(0 <= c-'0' && c-'0' <= 9)s += c;
			else s = ".";
			matrix[i][j] = s;
			field[i][j] = "";
		}
		#ifdef DEBUG
		cout<< (string("9930")>string("940037")) <<endl;
		cout<< bg(string("9930"),string("940037")) <<endl;
		rep(j, H){
			rep(i, W){
				cout<<matrix[i][j];
			}
			cout<<endl;
		}
		#endif
		string mx = "";
		rep(j, H)rep(i, W){
			if(matrix[i][j] == ".")continue;
			string up, left, tmp;
			up = left = "";
			if(0 <= j-1 && j-1 < H && matrix[i][j-1] != "." && field[i][j-1] != "0")up = field[i][j-1];
			if(0 <= i-1 && i-1 < W && matrix[i-1][j] != "." && field[i-1][j] != "0")left = field[i-1][j];
			tmp = bg(up, left)?up:left;
			field[i][j] += tmp+matrix[i][j];
			if(bg(field[i][j], mx))mx = field[i][j];
			#ifdef DEBUG
			cout<<i<<","<<j<<":"<<field[i][j]<<endl;
			#endif
		}
		cout<<mx<<endl;
	}
	return 0;
}

Measured memory_bytes: 1108
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int main(){
    int n=in(),m=in();
    vector<vec> chi(n);
    rep(i,m){
        int x=in()-1,y=in()-1;
        chi[x].pb(y);
        chi[y].pb(x);
    }
    vector<bool> done(n,false);
    priority_queue<pair<int,pii>,vector<pair<int,pii>>,greater<pair<int,pii>>> que;
    que.push(mp(0,mp(-1,0)));
    vec ans(n);
    while(!que.empty()){
        int size=que.top().first;
        int g=que.top().second.first;
        int m=que.top().second.second;
        que.pop();
        if(done[m])continue;
        if(g!=-1)ans[m]=g;
        done[m]=true;
        REP(e,chi[m]){
            if(!done[e]){
                que.push(mp(size+1,mp(m,e)));
            }
        }
    }
    cout<<"Yes"<<endl;
    rep2(i,1,n-1){
        cout<<ans[i]+1<<endl;
    }
}


Measured memory_bytes: 11768
def p_c():
    n = int(input())

    def primes(n):
        is_prime = [True] * (n + 1)
        is_prime[0] = False
        is_prime[1] = False
        for i in range(2, int(n ** 0.5) + 1):
            if not is_prime[i]:
                continue
            for j in range(i * 2, n + 1, i):
                is_prime[j] = False
        return [i for i in range(n + 1) if is_prime[i]]

    li = primes(n*2)

    for i in range(n, n*2):
        if i in li:
            print(i)
            exit()
            
p_c()

Measured memory_bytes: 41072
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){ cin.sync_with_stdio(0);
	ll N, K; cin >> N >> K;

	vl As(N);
	FOR(i, 0, N) cin >> As[i];

	ll cnt = 0;
	ll num = 0;
	FOR(i, 0, N) {
		FOR(j, 0, N) {
			if (As[i] > As[j]) num++;
		}
		FOR(j, i+1, N) {
			if (As[i] > As[j]) cnt++;
		}
	}

	const ll MOD = 1e9 + 7;
	ll ans = (cnt * K) % MOD;

	ans += (((K * (K-1))/2)%MOD) * num;
	ans %= MOD;


	cout << ans << endl;

} //cin.tie(0) bei schnellem Wechseln


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

int main() {
    int a, b, d, r;
    double f;
    cin >> a >> b;
    d = a/b;
    r = a%b;
    f = (double)a/(double)b;
    printf("%d %d %f\n", d,r,f);
    return 0;
}

Measured memory_bytes: 1184
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
  ll N,D,ans = 0, watched = 0;
  cin >> N >> D;
  while (watched < N) {
    watched += 2*D+1;
    ans +=1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import math

def insertion(a, n, g, cnt):
    for i in range(g, n):
        v = a[i]
        j  = i - g
        while v < a[j] and j >= 0:
            a[j+g] = a[j]
            j -= g
            cnt += 1
        else:
            a[j+g] = v
    else:
        return cnt

def shell(a, n):
    cnt = 0
    m = 9
    G = [100000, 11000, 1017, 107, 48, 25, 12, 7, 3, 1]
    for g in G:
        cnt = insertion(a, n, g, cnt)
    else:
        return cnt, m, G

def print_space(li, n):
    m = 0
    for i in range(len(li)-1):
        if li[i] <= n:
            print(li[i], end=' ')
            m += 1
    else:
        print(li[-1])
        m += 1
        return m

n = int(input())
a = [int(input()) for i in range(n)]


res = shell(a, n)

cnt = res[0]
G = res[2]

m = 0

for i in range(len(G)):
    if G[i] <= n:
        m += 1


print(m)
print_space(G, n)
print(cnt)
for i in a:
    print(i)





Measured memory_bytes: 45588
fn main() {
    let n: i32 = read();
    let ans = ((1..(n + 1)).filter(|x| x % 2 == 1).count() as f32) / (n as f32);

    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
///c. greedy takahashi
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <cmath>

using namespace std;
int main()
{
    long long int a,b,k;
    scanf("%lld%lld%lld",&a,&b,&k);
    if(k>=a){
        k=k-a;
        a=0;
    }
    else{
        a=a-k;
        k=0;
    }
    if(k>=b) b=0;
    else b=b-k;

    printf("%lld %lld",a,b);
    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int N,Ma,Mb;
    cin >> N >> Ma >> Mb;
    vi A(N),B(N),C(N);
    rep(i,N) cin >> A[i] >> B[i] >> C[i];
    
    ve<vvi> dp(N+1,vvi(405,vi(405,infi)));
    dp[0][0][0] = 0;
    
    
    rep(i,N){
        
        rep(a,405) rep(b,405){
            
            dp[i+1][a][b] = dp[i][a][b];
            if(a-A[i] >= 0 && b - B[i] >= 0){
                chmin(dp[i+1][a][b],dp[i][a-A[i]][b-B[i]]+C[i]);
            }
            
        }
    }
    
    int ans = infi;
    
    reps(i,1,N+1){
        reps(a,1,405) reps(b,1,405){
            if(dp[i][a][b] == infi) continue;
            
            if(a % Ma == 0){
                int aa = a/Ma;
                if(b == aa*Mb){
                    chmin(ans,dp[i][a][b]);
                }
            }
            
        }
    }
    
    if(ans == infi) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}


Measured memory_bytes: 27776
#include<stdio.h>
#include<string.h>
unsigned short d[4000][4000];
char a[4001],b[4001];
int i,j;

int max(int a,int b){
	if(a>=b)return a;
	else return b;
}

int main(){
	while(scanf("%s",a)!=EOF){
		scanf("%s",b);
		int al=strlen(a);
		int bl=strlen(b);
		for(i=0;i<al;i++)for(j=0;j<bl;j++)d[i][j]=0;
		for(i=0;i<al;i++)for(j=0;j<bl;j++){
			if(a[i]==b[j]){
				if(i>0&&j>0)d[i][j]=d[i-1][j-1]+1;
				else d[i][j]=1;
			}
			else{
				d[i][j]=0;
			}
		}
		/*for(i=0;i<strlen(a);i++){
			for(j=0;j<strlen(b);j++)printf("%d ",d[i][j]);
			printf("\n");
		}
		printf("\n");*/
		int ans=0;
		for(i=0;i<al;i++)for(j=0;j<bl;j++)ans=max(ans,d[i][j]);
		printf("%d\n",ans);
	}
	return 0;
}

		

Measured memory_bytes: 32228
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;

int main() {
  double l;
  cin >> l;
  l /= 3;
  cout << fixed << setprecision(10);
  cout << l * l * l << endl;
  return 0;
}

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

n = input()
n = int(n)

an = input().split()
an = [int(a) for a in an]

field = [[0 for _ in range(w)] for _ in range(h)]

k = 0
for i in range(h):
    for j in range(w):
        if i % 2 != 0:
            j = -j - 1
        if an[k] > 0:
            pass
        else:
            k += 1
        an[k] -= 1
        field[i][j] = k+1

for i in range(h):
    output = [str(c) for c in field[i]]
    print(" ".join(output))



Measured memory_bytes: 3568
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	public void run() {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		int M = sc.nextInt();
		String str = sc.next();
		int[] col = new int[N];
		for (int i = 0; i < N; ++i) {
			col[i] = str.charAt(i) - 'A';
		}
		ArrayList<Integer>[] g = new ArrayList[N];
		for (int i = 0; i < N; ++i) {
			g[i] = new ArrayList<>();
		}
		int[][] deg = new int[N][2];
		for (int i = 0; i < M; ++i) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			g[a].add(b);
			g[b].add(a);
			++deg[a][col[b]];
			++deg[b][col[a]];
		}
		ArrayDeque<Integer> dq = new ArrayDeque<>();
		for (int i = 0; i < N; ++i) {
			if (deg[i][0] == 0 || deg[i][1] == 0) {
				dq.add(i);
			}
		}
		boolean[] delete = new boolean[N];
		Arrays.fill(delete, false);
		while (!dq.isEmpty()) {
			int cur = dq.pollFirst();
			if (delete[cur])
				continue;
			delete[cur] = true;
			--N;
			for (int dst : g[cur]) {
				if (delete[dst])
					continue;
				--deg[dst][col[cur]];
				if (deg[dst][1] == 0 || deg[dst][0] == 0) {
					dq.addLast(dst);
				}
			}
		}
		System.out.println(N > 0 ? "Yes" : "No");
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		int nextInt() {
			return (int) nextLong();
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 79612
package main

import "fmt"

func is_square(n int) bool {
	for i := 0; i*i <= n; i++ {
		if i*i == n {
			return true
		}
	}
	return false
}

func concat(a, b int) int {
	ofs := 10
	for ofs <= b {
		ofs *= 10
	}
	return a*ofs + b
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	n := concat(a, b)

	if is_square(n) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;
	cin>>N;
	vector<bool> colors(8);
	int additional = 0;
	rep(i,N){
		int rate;
		cin>>rate;
		if(rate>=3200){
			additional++;
			continue;
		}
		colors[rate/400] = true;
	}
	int ans = 0;
	rep(i,8)if(colors[i])ans++;
	cout<<ans+((ans==0)?1:0)<<' '<<ans+additional<<endl;
	return 0;
}

Measured memory_bytes: 256
import math

def prime_factorize(n):
    ret = []
    # 小さい素数から順に試し割りしていく
    for i in range(2, int(math.sqrt(n))+1):
        if n % i != 0:
            continue
        e = 0
        while n % i == 0:
            e += 1
            n //= i
        ret += [(i, e)]

    if n != 1:
        ret += [(n, 1)]

    return ret


def extgcd(a, b):
    x,y, u,v = 0,1, 1,0
    while a != 0:
        q, r = b//a, b%a
        m, n = x-u*q, y-v*q
        b,a, x,y, u,v = a,r, u,v, m,n
        g = b
    return x, y, g


def modinv(a, m):
    x, y, g = extgcd(a, m)
    if g != 1:
        print ("[+]Inverse does not exist.")
    else:
        return ((m + x) % m) % m


def mod_comb(n, r, mod):
    ans_mul, ans_div = 1, 1

    for i in range(r):
        ans_mul *= (n-i)
        ans_div *= (i+1)
        ans_mul %= mod
        ans_div %= mod

    return ans_mul * modinv(ans_div, mod) % mod


def main():
    N, M = map(int, input().split())
    v = prime_factorize(M)
    MOD = int(10**9+7)
    ans = 1

    for i in v:
        ans *= mod_comb(N+i[1]-1, i[1], MOD)
        ans %= MOD
    print (ans)

main()


Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
int main(void)
{
	int i,j,k,m,x;
    char n[200],n1[200];
	while(1){
		//while(scanf("%s",n)!=EOF);
		scanf("%s",n);
		if(n[0]=='-')break;
		x=strlen(n);
		scanf("%d",&k);
		for(m=0;m<k;m++){
			scanf("%d",&i);
			strncpy(n1,n,i);
			n1[i] = '\0'; 
			for(j=0;j<x-i;j++)n[j]=n[i+j];
			n[j] = '\0'; 
			strcat(n,n1);
		}
		printf("%s\n",n);
	}
	return 0;
}

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

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

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

const int INF = 1e18;
const int MOD = 1e9 + 7;

signed main(){
    int a, b; cin >> a >> b;
    if( ( a + b ) % 2 == 0 ){
        cout << ( a + b ) / 2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
}


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

const int MAXH = 50;
const int MAXW = 50;
const int di[] = {0,1,0,-1};
const int dj[] = {1,0,-1,0};

int W, H, li, lj, ri, rj;
string L[MAXH], R[MAXH];
bool vis[MAXH][MAXW][MAXH][MAXW];

struct State {
  int a, b, c, d;
};

bool bfs() {
  memset(vis, 0, sizeof(vis));
  queue<State> que;
  vis[li][lj][ri][rj] = true;
  que.push((State){li, lj, ri, rj});
  while(que.size()) {
    const State s = que.front(); que.pop();
    for(int k = 0; k < 4; ++k) {
      int na = s.a + di[k];
      int nb = s.b + dj[k];
      int nc = s.c + di[k];
      int nd = s.d - dj[k];
      if(na < 0 || na >= H) na = s.a;
      if(nb < 0 || nb >= W) nb = s.b;
      if(nc < 0 || nc >= H) nc = s.c;
      if(nd < 0 || nd >= W) nd = s.d;
      if(L[na][nb] == '#') na = s.a, nb = s.b;
      if(R[nc][nd] == '#') nc = s.c, nd = s.d;
      if(L[na][nb] == '%' && R[nc][nd] == '%') return true;
      if(L[na][nb] == '%' || R[nc][nd] == '%') continue;
      if(vis[na][nb][nc][nd]) continue;
      vis[na][nb][nc][nd] = true;
      que.push((State){na, nb, nc, nd});
    }
  }
  return false;
}

int main() {
  while(cin >> W >> H && (W|H)) {
    for(int i = 0; i < H; ++i) {
      cin >> L[i] >> R[i];
      int l = L[i].find('L');
      int r = R[i].find('R');
      if(l != string::npos) {
        li = i; lj = l;
      }
      if(r != string::npos) {
        ri = i; rj = r;
      }
    }
    cout << (bfs() ? "Yes" : "No") << endl;
  }
  return 0;
}

Measured memory_bytes: 8260
#include<stdio.h>
const int maxn=100000+10;
const long long big=2000000000;
struct card
{
    int shu;
    char fu;
};
card L[maxn/2+2],R[maxn/2+2];
void zhenghe(card a[],int left,int mid,int right)
{
    int n1=mid-left;
    int n2=right-mid;
    for (int i=0;i<n1;i++) L[i]=a[left+i];
    for (int i=0;i<n2;i++) R[i]=a[mid+i];
    L[n1].shu=R[n2].shu=big;
    int i=0,j=0;
    for (int k=left;k<right;k++)
    {
        if(L[i].shu<=R[j].shu)
            a[k]=L[i++];
        else a[k]=R[j++];
    }
}
void guibing(card a[],int left,int right)
{
    if(left+1<right)
    {
        int mid=(left+right)/2;
        guibing(a,mid,right);
        guibing(a,left,mid);
        zhenghe(a,left,mid,right);
    }
}
int fenge(card a[],int left,int right)
{
    card x,t;
    x=a[right];
    int i=left-1;
    for (int j=left;j<right;j++)
    {
        if(a[j].shu<=x.shu)
        {
         i++;
         t=a[i];a[i]=a[j];a[j]=t;
        }
    }
    t=a[i+1];a[i+1]=a[right];a[right]=t;
    return i+1;
}
void quicksort(card a[],int left,int right)
{
    int q;
    if(left<right)
    {
        q=fenge(a,left,right);
        quicksort(a,left,q-1);
        quicksort(a,q+1,right);
    }
}
int main()
{
    int n,huan,biao=1;
    card a[maxn],b[maxn];
    char c[10];
    scanf("%d",&n);
    for (int i=0;i<n;i++)
    {
        scanf("%s %d",c,&huan);
        a[i].shu=b[i].shu=huan;
        a[i].fu=b[i].fu=c[0];
    }
    quicksort(b,0,n-1);
    guibing(a,0,n);
    for (int i=0;i<n;i++)
    {
        if(a[i].fu!=b[i].fu)
         biao=0;
    }
    if(biao==0) printf("Not stable\n");
    else printf("Stable\n");
    for (int i=0;i<n;i++)
    {
        printf("%c %d\n",b[i].fu,b[i].shu);
    }
    return 0;
}

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

signed main(){
    ios::sync_with_stdio(false);
    int n , k;

    cin >> n >> k;
    int a[n];
    for(int i =0;i<n;i++){
        cin >> a[i];
       
    }
    sort(a,a+n,greater<>());
   
    int e=0;
    while(e<n&&a[e]>=k)e++;
    if(e==n)cout << 0;
    else{
    int b[n-e][k];
    int c[n-e];
    c[n-e-1]=a[n-1];
    
    for(int i= n-e-2;i>=0;i--){c[i]=c[i+1]+a[i+e];}
   int t;
   int mine = e-1;
   for(int i=0;i<k;i++)b[0][i]=0;
    for(int p=1;p<n-e;p++){
        for(int i=0;i<a[e+p-1];i++)b[p][i]=b[p-1][i];
        for(int i=a[e+p-1];i<k;i++){
            
            b[p][i]=max(b[p-1][i],b[p-1][i-a[e+p-1]]+a[e+p-1]);
        }
        

    }
    int ans=0;
    int u=0;
    if(b[0][k-1]+c[0]<k){
        u=1;
        ans++;
    }
    //for(int i=0;i<n-e;i++)cout << b[i][k-1]<<' ';
     //cout << b[0]<<' '<< c[0]<< ' '<<ans<<endl;
    for(int i=1;i<n-e;i++){
        if(a[i-1+e]==a[i+e]){
            if(u==1)ans++;
        }else{
            if(b[i][k-1]+c[i]<k){
                ans++;
                u=1;
            }else{
                u=0;
            }
        }
        
       // cout << b[i-1]<<' '<<a[i+e]<<' '<< c[i]<<' '<<ans<< endl;

    }
    cout << ans;
    }
    return 0;
}

Measured memory_bytes: 97920
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	int n,t1,t2=0;
	cin>>t1>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		t2+=x;
	}
	if(t2>=t1) puts("Yes");
	else puts("No");
	
	return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Atcoder_Answer
{
    class Program
    {
        const Int32 mod = 1000000007;

        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            string[] Ss = new string[N];

            for (int loop = 0; loop < N; loop++) 
            {
                Ss[loop] = ReadLine();
            }

            WriteLine(Ss.Distinct().ToArray().Length);
        }
    }

    public static class Extension
    {
        #region 拡張:bool
        #region キャスト関連
        public static int ToInt(this bool Bool)
        {
            if (Bool) return 1;
            else return 0;
        }

        public static string ToString(this bool Bool, string TrueStr, string FalseStr)
        {
            if (Bool) return TrueStr;
            else return FalseStr;
        }
        #endregion
        #endregion

        #region 拡張:int
        #region キャスト関連
        public static char ToAlphaBets(this int Base) => (char)Base;
        #endregion
        #endregion

        #region 拡張:char
        #region 変換関連
        public static char NextAlpha(this char Char) => (char)((Char) + 1); //次の文字を取得
        #endregion
        #endregion

        #region 拡張:int[]
        public static long Sum(this int[] Array)
        {
            int Ret = 0;
            for (int loop = 0; loop < Array.Length; loop++) Ret += Array[loop];
            return Ret;
        }
        #endregion

        #region 拡張: string
        public static string Multi(this string THIS, int Value)
        {
            string RetValue = "";

            for (int loop = 0; loop < Value; loop++) RetValue += THIS;

            return RetValue;
        }
        #endregion

        #region 拡張: List<string>
        public static string Sum(this List<string> THIS, string Split)
        {
            string RetValue = "";

            for (int loop = 0; loop < THIS.Count; loop++)
            {
                RetValue += THIS[loop];
            }

            return RetValue;
        }
        #endregion
    }
}


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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 2e5;
vl adj[N + 1];
ll dp[N + 1], dp2[N + 1], f[N + 1], b[N + 1], f_inv[N + 1], SIZE[N + 1];
bool vis[N + 1];

ll power (ll n, ll k) {
	if (k == 0) return 1;
	ll t = power(n, k / 2);
	if (k % 2 == 0) return (t * t) % mod;
	return (((t * t) % mod) * n) % mod;
}

ll C (ll n, ll k) {
	ll temp = (((f[n] * f_inv[k]) % mod) * f_inv[n - k]) % mod;
	return temp;
}

void dfs (ll n) {
	vis[n] = true;
	dp[n] = 1;
	ll temp = 0;
	for (ll i : adj[n]) {
		if (!vis[i]) {
			dfs(i);
			temp += SIZE[i];
			dp[n] = (dp[n] * ((dp[i] * C(temp, SIZE[i])) % mod)) % mod;
		}
	}
	SIZE[n] = temp + 1;
	//cout << n << " " << SIZE[n] << "\n";
}

void dfs2 (ll n, ll p) {
	vis[n] = true; 
	for (ll i : adj[n]) {
		if (!vis[i]) {
			dp2[i] = (((dp2[n] * SIZE[i]) % mod) * power(p - SIZE[i], mod - 2)) % mod; 
			dfs2(i, p);
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	f[0] = b[0] = f_inv[0] = 1;
	for (ll i = 1; i <= N; i++) {
		f[i] = (i * f[i - 1]) % mod;
		b[i] = (b[i - 1] * f[i]) % mod;
	}
	ll x = power (b[N], mod - 2);
	for (ll i = N; i > 0; i--) {
		f_inv[i] = (x * b[i - 1]) % mod;
		x = (x * f[i]) % mod;
	}
	ll n, y;
	cin >> n;
	for (ll i = 0; i < n - 1; i++) {
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	for (ll i = 1; i <= n; i++) {
		vis[i] = false;
	}
	dfs(1);
	dp2[1] = dp[1];
	for (ll i = 1; i <= n; i++) {
		vis[i] = false;
	}
	dfs2(1, n);
	for (int i = 1; i <= n; i++) {
		cout << dp2[i] << "\n";
	}
 	return 0;
}

Measured memory_bytes: 24304
import sys
from collections import defaultdict
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, M, Q, = map(int, input().split())
# L = [int(v) * -1 for v in input().split()]
L = [int(input()) for _ in range(Q)]

c = [0] * (N + 1)
for v in L:
    c[0] -= 1
    c[v - 1] += 1
    c[v] -= 1
    c[N] -= 1

for i in range(N - 1):
    c[i + 1] += c[i]

for i in range(N):
    c[i] += M
    if c[i] <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 12120
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

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

	vector<int> L(2 * N);
	rep(i, 2 * N) cin >> L[i];
	sort(RALL(L));
	
	int ans = 0;
	for (int i = 1; i < 2 * N; i += 2) {
		ans += L[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    unordered_set<int> s;
    ll n,x;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        s.insert(x);
    }
    if(s.size()==n){
        cout<< "YES"<<endl;
    }else{cout<< "NO"<<endl;}
    return 0;


}



Measured memory_bytes: 8520
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt(), K = sc.nextInt();   //N_max = 100000, K_max = 100, h_max = 10000
        int[] h = new int[N];
        for(int i=0;i<N;i++){
            h[i] = sc.nextInt();
        }
        int[] minCost = new int[N];
        minCost[0] = 0;
        for(int i=1;i<N;i++){
            int costK = 999999999;
            for(int k=1;k<=K;k++) {
                if(k > i){
                    break;
                }else {
                    costK = Math.min(costK, minCost[i - k] + Math.max(h[i] - h[i - k], h[i - k] - h[i]));
                }
            }
            minCost[i] = costK;
        }
        System.out.println(minCost[N-1]);
    }
}


Measured memory_bytes: 48840