akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

template<class T> inline bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int get_digit(ll n){
    int digit = 0;
    if(n == 0){
        return 1;
    }
    while(n != 0){
        digit++;
        n /= 10;
    }
    return digit;
}
bool is_junretu(ll n){
    int digit = get_digit(n);
    string s;
    s = to_string(n);
    bool flg= true;
    for(int i = 1; i <= digit; i++){
        if(s.find(i) == string::npos){
            flg = false;
            break;
        }
    }
    return flg;
}

ll gcd(ll x, ll y){
    return y != 0 ? gcd(y, x % y) : x;
}
ll lcm(ll x, ll y){
    return x * y / gcd(x, y);
}
int main(){

    ll n, m;
    cin >> n >> m;
    vector<ll> H(n+1);
    for(int i = 1; i <= n; i++){
        cin >> H[i];
    }
    vector<vector<ll>> path(n+1);
    for(int i = 0; i < m; i++){
        ll a, b;
        cin >> a >> b;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        if(path[i].size() == 0){
            ans++;
            continue;
        }
        bool flg = true;
        for(ll next : path[i]){
            if(H[i] <= H[next]) flg = false;
        }
        if(flg) ans++;
    }

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

Measured memory_bytes: 9860
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
//#define co(x) cout << (x) << "\n"
//#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int dm = 1 << 22;
char dn[dm], * di = dn;
inline void cosp(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = ' ';
}
inline void co(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}


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


	int N;
	cin >> N;

	if (N == 1) * di++='N', * di++ = 'o', * di++ = '\n';
	else {
		bool dame = false;
		int k = 1;
		rep(i, 20) {
			k *= 2;
			if (N == k) dame = true;
		}
		if (dame)* di++ = 'N', * di++ = 'o', * di++ = '\n';
		else if (N % 2 == 0) {
			*di++ = 'Y';
			*di++ = 'e';
			*di++ = 's';
			*di++ = '\n';
			int xs = 0;
			rep1(i, N) {
				xs ^= i;
			}
			int a = N - 1;
			int b = xs ^ a;
			int c = a ^ 1;
			int d = b ^ 1;

			cosp(c);
			co(1);
			cosp(a);
			co(c);
			cosp(1);
			co(a + N);

			cosp(1);
			co(d);
			cosp(b);
			co(d);
			cosp(1);
			co(b + N);

			int mae = d;
			rep1(i, N) {
				if (i != a && i != b && i != c && i != d && i != 1) {
					cosp(mae);
					co(i);
					mae = i;
				}
			}
			cosp(mae);
			co(c + N);
			mae = c + N;
			cosp(mae);
			co(1 + N);
			mae = 1 + N;
			cosp(mae);
			co(d + N);
			mae = d + N;
			rep1(i, N) {
				if (i != a && i != b && i != c && i != d && i != 1) {
					cosp(mae);
					co(i + N);
					mae = i + N;
				}
			}
		}
		else {
			*di++ = 'Y';
			*di++ = 'e';
			*di++ = 's';
			*di++ = '\n';
			rep1(i, N / 2) {
				int k = i * 2;
				cosp(1);
				co(k);
				cosp(k);
				co(k + 1);
				cosp(1);
				co(k + N + 1);
				cosp(k + N);
				co(k + N + 1);
			}
			cosp(1 + N);
			co(2 + N);
		}
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);
	Would you please return 0;
}

Measured memory_bytes: 6912
/**
 *    author:  FromDihPout
 *    created: 2020-08-25
**/

#include <bits/stdc++.h>
using namespace std;

const int INF = 1e9;
const int N = 1e3 + 10;
queue<pair<int,int>> q, q2;
int dist[N][N], h, w, sh, sw, eh, ew;
vector<pair<int,int>> ADJ = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
vector<string> a;

void dfs(int r, int c) {
    q2.emplace(r, c);
    for (auto neigh : ADJ) {
        int nr = r + neigh.first, nc = c + neigh.second;
        if (nr < 0 || nr >= h || nc < 0 || nc >= w || a[nr][nc] == '#') continue;
        if (dist[r][c] < dist[nr][nc]) {
            dist[nr][nc] = dist[r][c];
            dfs(nr, nc);
        }
    }
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> h >> w >> sh >> sw >> eh >> ew;
    sh--, sw--, eh--, ew--;
    a.resize(h);
    for (int i = 0; i < h; i++) {
        cin >> a[i];
    }
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            dist[i][j] = INF;
        }
    }
    q.emplace(sh, sw);
    dist[sh][sw] = 0;
    while (1) {
        bool ok = false;
        while (!q.empty()) {
            auto pos = q.front();
            q.pop();
            int r = pos.first, c = pos.second;
            if (r == eh && c == ew) {
                ok = true;
                break;
            }
            dfs(r, c);
        }
        if (ok) break;
        
        while (!q2.empty()) {
            auto pos = q2.front();
            q2.pop();
            int r = pos.first, c = pos.second;
            if (r == eh && c == ew) {
                ok = true;
                break;
            }
            
            for (int nr = max(0, r-2); nr <= min(h-1, r+2); nr++) {
                for (int nc = max(0, c-2); nc <= min(w-1, c+2); nc++) {
                    if (nr == r && nc == c) continue;
                    if (nr < 0 || nr >= h || nc < 0 || nc >= w || a[nr][nc] == '#') continue;
                    if (dist[r][c] + 1 < dist[nr][nc]) {
                        dist[nr][nc] = dist[r][c] + 1;
                        q.emplace(nr, nc);
                    }
                }
            }
        }
        if (ok) break;
        if (q.empty()) break;
    }
    
    if (dist[eh][ew] < INF) {
        cout << dist[eh][ew] << '\n';
    }
    else {
        cout << -1 << '\n';
    }
    return 0;
}

Measured memory_bytes: 8560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
const int MOD = 1000000007;

template <typename T>
void __dump__(std::ostream &os, const T &first) {
    os << first;
}
template <typename First, typename... Rest>
void __dump__(std::ostream &os, const First &first, const Rest &... rest) {
    os << first << ", ";
    __dump__(os, rest...);
}
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __dump__(os, __VA_ARGS__);                        \
        std::cerr << os.str() << std::endl;               \
    } while (0)

vector<vector<int>> bfs(char start, const vector<string> &g) {
    const int INF = 1000000000;
    using pii = pair<int, int>;

    int h = g.size(), w = g[0].size();
    static const auto is_valid = [&](int i, int j) {
        if (i < 0 || i >= h || j < 0 || j >= w) return false;
        if (g[i][j] == '#') return false;
        return true;
    };

    static const pii dir[] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
    queue<pii> q;
    vector<vector<int>> d(h, vector<int>(w, INF));
    rep(i, h) rep(j, w) {
        if (g[i][j] == start) {
            d[i][j] = 0;
            q.emplace(i, j);
        }
    }

    while (q.size()) {
        int ci, cj;
        tie(ci, cj) = q.front();
        q.pop();
        for (auto &v : dir) {
            int ni = ci + v.first;
            int nj = cj + v.second;
            if (is_valid(ni, nj)) {
                int nd = d[ci][cj] + 1;
                if (d[ni][nj] > nd) {
                    d[ni][nj] = nd;
                    q.emplace(ni, nj);
                }
            }
        }
    }

    return d;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int h, w, k;
    while (cin >> h >> w >> k) {
        vector<string> g(h);
        rep(i, h) cin >> g[i];
        auto d = bfs('S', g);
        int ans = 1e9;
        rep(i, h) rep(j, w) {
            if (d[i][j] <= k) {
                int cd = 1e9;
                cd = min(cd, i);
                cd = min(cd, w - j - 1);
                cd = min(cd, j);
                cd = min(cd, h - i - 1);
                ans = min(ans, (cd + k - 1) / k);
            }
        }
        cout << ans + 1 << endl;
    }
}


Measured memory_bytes: 3456
def mips():
    return map(int,input().split())
def msps():
    return map(str,input().split())

import sys
import itertools
N,M,X = mips()
know = dict()
price = [[] for _ in range(N)]
L = []
C = []
for i in range(M):
    know[i] = 0
for i in range(N):
    L.append([i for i in mips()])
    C.append(L[i][0])
    L[i].remove(L[i][0])
Money = []
paid = 0 
K = []
No = 0
P = []
Q = [i for i in range(N)]
for i in range(N+1):
    P.append(list(itertools.combinations(Q,i)))
for k in range(N+1):
    for el in P[k]:
        for book in el:
            K = L[book] 
            paid += C[book]
            for i in range(M):
                know[i] += K[i]
        for i in range(M):
            if know[i] < X:
                No = 1
                break
        if No == 0:
            Money.append(paid)
        paid = 0
        No = 0
        for i in range(M):
            know[i] = 0
if Money == []:
    print("-1")
else:
    print(min(Money))

Measured memory_bytes: 9352
import java.util.Scanner;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        double A = sc.nextDouble();
        double B = sc.nextDouble();
        double c = sc.nextDouble();
        double H, L, Ar,C;
        c = (c*Math.PI)/180;
        H = B* Math.sin(c);
        Ar = (A* H)/2;
        double A1 = B * Math.cos(c);
        C = Math.sqrt(Math.pow(A-A1, 2)+Math.pow(H, 2));
        L = A+B+C;
       System.out.printf("%.4f\n%.4f\n%.4f\n",Ar,L,H);
    }
}


Measured memory_bytes: 28260
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin>>A[i];
    vector<ll> B(N+1), C(N+1);
    REP(i, N){
        B[i+1] = max(B[i], A[i]);
    }
    for(ll i=N-1; i>=0; i--){
        C[i] = max(C[i+1], A[i]);
    }
    REP(i, N){
        cout << max(B[i], C[i+1]) << endl;
    }
    return 0;
}

Measured memory_bytes: 6272
s = input()
for i in reversed(range(len(s)-1)):
  if (i + 1) % 2 == 0:
    ss = s[:i+1]
#    print(ss)
#    print(ss[:int((i+1)/2)], ss[int((i+1)/2):])
    if ss[:int((i+1)/2)] == ss[int((i+1)/2):]:
      print(i+1)
      exit()

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

S = []
C = []
for i in range(m):
  s, c = map(int, input().split())
  S.append(s)
  C.append(c)

if n == 1:
  start_num = 0
  end_num = 10
if n == 2:
  start_num = 10
  end_num = 100
if n == 3:
  start_num = 100
  end_num = 1000
  
for num in range(start_num, end_num):
  for i in range(m):
    if str(num)[S[i] - 1] != str(C[i]):
      break
  else:
    print(num)
    break
else:
  print(-1)


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

int gcd(int ia, int ib){
    int a, b, r, x, tmp;
    a=ia;
    b=ib;
    x = a * b;
    /* 自然数 a > b を確認・入替 */
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
/* ユークリッドの互除法 */
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return (b);
}

int imc(int ia, int ib){
    int a, b;
    b=ib;
    a=ia;
 /* 最小公倍数を出力 */
    return (a*b/gcd(a,b));
}
int main(){
    int n,xi;
    cin >> n>>xi;
    vector<int> x;
    x.push_back(xi);
    int bef;
    for(int i=0;i<n;i++){
        cin >>bef;
        x.push_back(bef);
    }
    sort(x.begin(),x.end());

    int ans=x[1]-x[0];
    for (int i = 2; i <= n; i++)
    {
        ans = gcd(ans,x[i]-x[i-1]);
    }

    cout<<ans;

}

Measured memory_bytes: 892
// B - Shiritori
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t, v, x, y, z;
  cin >> n;
  vs d(n);
  set<string> g;
  rep(i, 0, n)
  {
    cin >> d[i];
    // cout << d[i] << endl;
    g.insert(d[i]);
    if (i != 0)
    {
      x = d[i];
      y = x[d[i].size() - 1];
      z = x[0];
      // cout << "z: " << z << endl;
      if (z != t)
      {
        cout << "No" << endl;
        return 0;
      }
      else
      {
        t = y;
      }
    }
    else
    {
      s = d[i];
      t = s[d[i].size() - 1];
      // v = s[0];
      // cout << "t: " << t << endl;
    }
  }
  if (g.size() != n)
  {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  // cout << d << endl;
}

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

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

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

int main()
{
	int N;
	cin >> N;
	if (N % 10 == 9 || N / 10 == 9) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pl;


int main()
{
	int ans = 0;
	for (int i = 0; i < 10; i++) {
		int s; cin >> s;
		ans += s;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3088
# -*- coding: utf-8 -*-
N, a, b = map(int, input().split())

def get_combi_mod(n, k, MOD):
    if n < k:
        return 0
    if n-k < k:
        k = n-k
    comb = 1
    for x in range(n-k+1, n+1):
        comb = (comb * x) % MOD
    d = 1
    for x in range(1, k+1):
        d = (d * x) % MOD
    comb *= pow(d, MOD-2, MOD)
    return comb % MOD

ans = 1
div_num = 10 ** 9 + 7
two_thou = (2 ** 1000) % div_num
for i in range(N // 1000):
    ans = (ans * two_thou) % div_num

ans = (ans * (2 ** (N % 1000))) % div_num
print((ans - 1 - get_combi_mod(N, a, div_num) - get_combi_mod(N, b, div_num)) % (10 ** 9 + 7))

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

string substrBack(string str, size_t pos, size_t len) {
    const size_t strLen = str.length();
 
    return str.substr(strLen - pos, len);
}

int main(){
  string S;
  cin >> S;
  string T = S;
  int64_t sum = 0;
  int k = 1;
  for (int tmp = 0; tmp < (1 << S.size()-1); tmp++) {
    bitset<9> s(tmp);
    rep(i, S.size()-1){
      if(s.test(i)){
        sum += stoll(substrBack(T, k, k));
        T.erase(T.size()-k);
        k = 0;
      }
      k++;
    }
    sum += stoll(T);
    k = 1;
    T = S;
  }
  cout << sum << endl;
}

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

int main()
{
    double a, b;
    int d;
    double r, f;
    cin >>a >>b;

    d = a/b;
    r = fmod(a,b);
    f = a/b;

    printf("%d %.0f %f\n",d,r,f );
 
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using namespace std;

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

    cout << t << s << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
input = sys.stdin.readline # 文字列の入力のとき'/n'まで受け取るので注意!!!
sys.setrecursionlimit(500000)
ans = 0
for i in range(N):
    a = bisect.bisect_left(A,B[i])
    c = bisect.bisect_right(C,B[i])

    ans += (N-c)*a
print(ans)

Measured memory_bytes: 108260
#include<iostream>
#include<queue>
using namespace std;
int H,W;
string s[1000];
int dis[1000][1000];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
main()
{
	cin>>H>>W;
	for(int i=0;i<H;i++)cin>>s[i];
	queue<pair<int,int> >P;
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			if(s[i][j]=='#')
			{
				dis[i][j]=1;
				P.push(make_pair(i,j));
			}
		}
	}
	while(!P.empty())
	{
		int x=P.front().first,y=P.front().second;
		P.pop();
		for(int r=0;r<4;r++)
		{
			int tx=x+dx[r],ty=y+dy[r];
			if(tx<0||ty<0||tx>=H||ty>=W||dis[tx][ty]>0)continue;
			dis[tx][ty]=dis[x][y]+1;
			P.push(make_pair(tx,ty));
		}
	}
	int ans=0;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)
	{
		if(ans<dis[i][j])ans=dis[i][j];
	}
	cout<<ans-1<<endl;
}


Measured memory_bytes: 13456
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n,W;
    cin>>n>>W;
    long long int dp[W+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++){
        long long int val;
        int wt;
        cin>>wt>>val;
        for(int w=W-wt;w>=0;w--){
            dp[w+wt]=max(dp[w+wt],dp[w]+val);
        }
    }
    long long int ans=*max_element(dp,dp+W+1);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4288
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

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

    if(K > (N-1)*(N-2) / 2){
        cout << -1 << endl;
        return 0;
    } else {
        vector<pair<int, int>> pairs;
        for(int i=2; i<=N; i++) pairs.push_back(make_pair(1, i));
        int edges_to_append = (N-1)*(N-2)/2 - K, counter = 0;
        for(int i=2; i<=N; i++) {
            if(counter == edges_to_append) break;
            for(int j=i+1; j<=N; j++) {
                if(counter == edges_to_append) break;
                pairs.push_back(make_pair(i, j));
                counter++;
            }
        }
        cout << pairs.size() << endl;
        for(auto x: pairs)
            cout << x.first << " " << x.second << endl;

    }
    
    return 0;
}

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

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

    int N;
    cin >> N;

    long long dp[110][4][4][4] = {};

    for (int i=0; i<4; ++i) {
        for (int j=0; j<4; ++j) {
            for (int k=0; k<4; ++k) {
                int t = 1;
                if (i == 0 && j == 2 && k == 1) t = 0;
                if (i == 2 && j == 0 && k == 1) t = 0;
                if (i == 0 && j == 1 && k == 2) t = 0;
                dp[3][i][j][k] = t;
            }   
        }        
    }

    for (int n=3; n<N; ++n) {
        for (int i=0; i<4; ++i) {
            for (int j=0; j<4; ++j) {
                for (int k=0; k<4; ++k) {
                    for (int l=0; l<4; ++l) {
                        if (j == 0 && k == 2 && l == 1) continue;
                        if (i == 0 && k == 2 && l == 1) continue;
                        if (j == 2 && k == 0 && l == 1) continue;
                        if (j == 0 && k == 1 && l == 2) continue;
                        if (i == 0 && j == 2 && l == 1) continue;
                        dp[n+1][j][k][l] += dp[n][i][j][k];
                        dp[n+1][j][k][l] %= 1000000007;
                    }
                }
            }
        }
    }

    long long ans = 0;
    for (int i=0; i<4; ++i) {
        for (int j=0; j<4; ++j) {
            for (int k=0; k<4; ++k) {
                ans += dp[N][i][j][k];
                ans %= 1000000007;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# import bisect
# from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = int(input())
    p = list(map(int,ipti().split()))

    for i in range(n):
        if p[i] == (i+1):
            p[i] = 1
        else:
            p[i] = 0

    p_groupby = itertools.groupby(p)

    ans = 0

    for key, group in p_groupby:
        if key == 1:
            len_group = len(list(group))
            ans += (len_group + 1) // 2

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 56028
#include<iostream>
using namespace std;
int main(){
    int x,y,z;
    cin >> x >> y >> z;
    if(x < y){
        if(y < z){
            cout << x << " " << y << " " << z << endl;
        }else {
            cout << x << " " << z << " " << y << endl;
        }
    }else {
        if(y < z){
            if(x < z) {
                cout << y << " " << x << " " << z << endl;
            }else {
                cout << y << " " << z << " " << x << endl;
            }
        }else{
            cout << z << " " << y << " " << x << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3116
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque> 
#include <algorithm>
 
using namespace std;
 
#define     lli                 long long int
#define     ulli                unsigned long long int

#define     ifor(st,lim)        for(int i=st;i<lim;i++)
#define     jfor(stt,llim)      for(int j=stt;j<llim;j++)
#define		Test(tt)			for(int test=1;test<=tt;test++)
#define		For(var,srt,nnd)	for(var=srt;var<nnd;var++)
#define		Rfor(var,srt,nnd)	for(var=srt;var>=nnd;var--)
 
#define     pb                  push_back
#define     mkp                 make_pair
 
#define     pi                  acos(-1)
#define     mod                 100000007
 
#define     Clear(var,val)      memset(var,val,sizeof(var))
#define     len(var)            (int)(var.length())
#define     vlen(vect)          (int)(vect.size())
#define     line(ss)            getline(cin,ss)

#define		FIO					ios_base::sync_with_stdio(false);cin.tie(NULL)

#define		sclock				int start_s=clock()
#define		eclock				int end_s=clock()
#define		pclock				printf("\nRuntime :: %.2lf\n", (double)(end_s-start_s)/CLOCKS_PER_SEC)
 
/****************************** IO ************************************/
#define		ina(a)				scanf("%d",&a)
#define		inb(a,b)			scanf("%d %d",&a,&b)
#define		inc(a,b,c)			scanf("%d %d %d",&a,&b,&c)
#define		ins(chr)			scanf("%s",s)
#define		inlla(a)			scanf("%lld",&a)
#define		inllb(a,b)			scanf("%lld %lld",&a,&b)
#define		inllc(a,b,c)		scanf("%lld %lld %lld",&a,&b,&c)
 
#define		outa(a)				printf("%d",a)
#define		outlla(a)			printf("%lld",a)

#define		yn(b)				puts(b ? "YES" : "NO") 

#define		outar(ar,ln,c)		for(int i=0;i<ln;i++){printf("%d%c",ar[i],c);}

#define		outCase()			printf("Case %d:",test)
 
#define		blank				printf("\n")
/**********************************************************************/


int main()
{
    FIO;
/******************************* B ************************************/
	
	int n,k,total=0,take=0;
	
	inb(n,k);
	int ar[n];
	ifor(0,n)
	{
		ina(ar[i]);
		total+=ar[i];
	}
	
	double d=total*(1.0/(4.0*k));
	
	ifor(0,n)
	{
		if(ar[i]<d) continue;
		take++;
	}
	
	if(take>=k) printf("Yes\n");
	else printf("No\n");
	
	
/**********************************************************************/
    return 0;
}


Measured memory_bytes: 256
# AtCoder
N = int(input())


def make_divisor_list(num):
    divisor_list = []
    divisor_list.append(1)
    for i in range(2, num//2+1):
        if num % i == 0:
            divisor_list.append(i)
    divisor_list.append(num)
    return divisor_list


l = 0
for i in range(1, N+1):
    divisor_list = make_divisor_list(i)
    if len(divisor_list) == 8 and i % 2 != 0:
        l += 1

print(l)


Measured memory_bytes: 3060
#include <stdio.h>

int
main(void)
{
    char ch;
    while ((ch = getchar()) != EOF)
        if (ch >= 'A' && ch <= 'Z')
            putchar(ch - 'A' + 'a');
        else if (ch >= 'a' && ch <= 'z')
            putchar(ch - 'a' + 'A');
        else
            putchar(ch);
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
void get_unique(vector<T>& x) {
    x.erase(unique(x.begin(), x.end()), x.end());
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n;
    cin >> n;
    vector<int> a(n), cnta(200200);
    rep(i, n) cin >> a[i], cnta[a[i]]++;
    vector<int> b(n), cntb(200200);
    rep(i, n) cin >> b[i], cntb[b[i]]++;

    vector<int> s, t, l(200200, INF), r(200200);
    rep(x, 200200) rep(i, cnta[x]) s.push_back(x);
    rep(x, 200200) rep(i, cntb[x]) t.push_back(x);

    rep(i, sz(s)) chmax(r[s[i]], i + 1);
    rep(i, sz(t)) chmin(l[t[i]], i);
    int d = 0;
    rep(x, 200200) chmax(d, r[x] - l[x]);

    vector<int> tt;
    rrep(i, d) tt.push_back(t[n - 1 - i]);
    rep(i, n - d) tt.push_back(t[i]);
    vector<pair<int, int>> ans(n);
    rep(i, n) {
        ans[i] = make_pair(s[i], tt[i]);
        if (s[i] == tt[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    sort(all(ans));
    rep(i, n) cout << ans[i].second << " \n"[i == n - 1];
}

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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

int q;
int l[100001], r[100001];

vector<bool> Primes(100001, true);
vector<int> accPrimes(100001, 0);

void solve()
{
    cin >> q;
    Primes[1] = false;
    for(int i = 2; i <= 100000; i++){
        if(!Primes[i]) continue;
        for(int j = 2; i*j <= 100000; j++) Primes[i*j] = false;
    }
    for(int i = 3; i <= 100000; i+=2){
        if(Primes[i] && Primes[(i+1)/2]){
            accPrimes[i] = accPrimes[i-2]+1;
        }
        else{
            accPrimes[i] = accPrimes[i-2];
        }
    }
    for(int i = 1; i <= q; i++) cin >> l[i] >> r[i];
    for(int i = 1; i <= q; i++){
        cout << accPrimes[r[i]] - accPrimes[l[i] - 2] << "\n";
    }
}

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

Measured memory_bytes: 1792
let () =
  let buf = Buffer.create 128 in
  let rec loop () =
    let m,f,r = Scanf.sscanf (read_line ()) "%d %d %d" (fun m f r -> m,f,r) in
    let p = m+f in
    if (p,r) = (-2,-1) then print_string (Buffer.contents buf)
    else
      (Buffer.add_string buf
         (if p >= 80 then "A"^"\n"
          else if p >= 65 then "B"^"\n"
          else if p >= 50 then "C"^"\n"
          else if p < 30 || m = -1 || f = -1 then "F"^"\n"
          else (if r >= 50 then "C" else "D")^"\n");
       loop ())
  in
  loop ()

Measured memory_bytes: 2180
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<deque>
#include<set>
using namespace std;

using ll = long long;
const int INF = 1001001001;

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

#define MOD (1000000007)

int main(void)
{
  ll n, k;
  cin >> n >> k;

  ll total = 0;

  vector<ll> rui(n+1);
  rui[0] = 0;
  for (int i = 1; i < n+1; i++) {
    rui[i] = rui[i-1] + i;
  }

  for (int i = k; i < n + 1; i++) {
    total += (rui[n] - rui[n-i]) - rui[i-1] + 1;
    //cout << total << endl;
  }
  total++; // i == n

  cout << total % MOD << endl;
}


Measured memory_bytes: 4840
def main():
    n = int(input())
    d, x = map(int, input().split())
    num_list = [int(input()) for _ in range(n)]

    count = 0
    for num in num_list:
        if d // num > 0 and d % num == 0:
            count += d // num
        elif d //num >0:
            count += d // num + 1
        else:
            count += 1

    ans = count + x

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main(void)
{
    int n, a_i;
    map<int, int> a_map;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a_i;
        a_map[a_i] = i;
    }
    for (int i = 1; i <= n; i++)
    {
        cout << a_map[i];
      	if(i==n) cout << endl;
        else cout << " ";
    }
}

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

int main(){
  int H, W;
  int h, w;
  cin >> H >> W >> h >> w;
  cout << H*W - H*w - W*h + h*w << endl;
}

Measured memory_bytes: 256
//Think simple yet elegant.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const ll maxn=2e5+10;
const ll mod=1e9+7;
 
int main() {
  	fast;
  	int k,a,b,c,x,f=0;
  	cin>>k>>a>>b;
  	
  	if(b-b%k>=a || b%k==0 || a%k==0)
  		f=1;
  		
	  if(f)
	  	cout<<"OK";
		else
			cout<<"NG";
}
  	


Measured memory_bytes: 3636
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
std::vector<int> v(1e6,0);
int A=pw(2,18);
int sum(int i){
  int s=0;
  while(i){
    s+=v[i];s%=MOD;
    i-=i&-i;
  }
  return s;
}
void add(int i,int a){
  while(i<=A){
    v[i]+=a;v[i]%=MOD;
    i+=i&-i;
  }
}
//main
signed main(){
  int N,M;cin>>N>>M;
  std::vector<int> s(N),t(M);
  for(int i=0;i<N;i++)cin>>s[i];
  for(int i=0;i<M;i++)cin>>t[i];
  int ans=1;
  std::vector<int> po[123456];
  for(int i=0;i<M;i++)po[t[i]].push_back(i);
  for(int i=N-1;i>=0;i--){
    int a=s[i];
    for(int p:po[a]){
      int res=sum(A-1)-sum(p+1);
      res%=MOD;res+=MOD;res%=MOD;
      res++;res%=MOD;
      ans+=res;ans%=MOD;
      add(p+1,res);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 11008
import java.util.*;
import java.io.*;

class Main {

  

  public static void main(String[] args) {
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int INF = (int) 1e9 + 7;

    int N = in.nextInt();
    int K = in.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = in.nextInt();
    }

    int[][] dp = new int[N + 1][K + 1];
    dp[0][0] = 1;
    Arrays.fill(dp[0], 1);
    for (int i = 1; i <= N; i++) {
      for (int j = 0; j <= K; j++) {
        // int cur = 0;

        // pre + (j - a[i - 1] ... j)
        int pre = (dp[i - 1][j] - (j - a[i - 1] <= 0 ? 0 : dp[i - 1][j - a[i - 1] - 1]));
        if (pre < 0) {pre += INF;}
        dp[i][j] = (j == 0 ? 0 : dp[i][j - 1]) + pre;
        if (dp[i][j] >= INF) {dp[i][j] -= INF;}
        // for (int take = Math.min(a[i - 1], j); take >= 0; take--) {
        //   cur += dp[i - 1][j - take];
        //   if (cur > INF) {cur -= INF;}
        // }
        // dp[i][j] = cur;
      }
    }
    
    int res = dp[N][K] - (K == 0 ? 0 : dp[N][K - 1]);
    System.out.println(res < 0 ? res + INF : res);
  }

}


Measured memory_bytes: 80976
using System;

namespace ConsoleApp_ITP1_2_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] value = input.Split(' ');

            int a = Int32.Parse(value[0]);
            int b = Int32.Parse(value[1]);

            if (a < b)
            {
                Console.WriteLine("a < b");
            }
            else if (a > b)
            {
                Console.WriteLine("a > b");
            }
            else
            {
                Console.WriteLine("a == b");
            }
        }
    }
}



Measured memory_bytes: 9012
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline double toDouble(string s) {double v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

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

stack<double> st;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    while(getline(cin, s)) {
        vector<string> str = split(s, ' ');

        for(auto const& v: str){
            if (v == "+") {
                double a = st.top();
                st.pop();
                double b = st.top();
                st.pop();
                st.push(a + b);
                continue;
            } else if (v == "-") {
                double a = st.top();
                st.pop();
                double b = st.top();
                st.pop();
                st.push(b - a);
                continue;
            } else if (v == "/") {
                double a = st.top();
                st.pop();
                double b = st.top();
                st.pop();
                st.push(b / a);
                continue;
            } else if (v == "*") {
                double a = st.top();
                st.pop();
                double b = st.top();
                st.pop();
                st.push(a * b);
                continue;
            }
            st.push(toDouble(v));
        }

        printf("%.6f\n", st.top());
        st.pop();
    }

    return 0;
}

Measured memory_bytes: 3400
#include<bits/stdc++.h>
#define lli unsigned long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

void solve(){
    int a[3]; cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]==a[1] && a[0]!=a[2]) cout<<"Yes";
	else if(a[1]==a[2] && a[2]!=a[0]) cout<<"Yes";
	else cout<<"No"; 
    return;
}
int main(){
    fastIO;
    solve();
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int x,y;
    
    cin>>x>>y;
    
    int a[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
    

    if(a[x]==a[y]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 256
import bisect
from operator import itemgetter
N, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(N)]

XY.sort(key=itemgetter(0))
x, y = list(zip(*XY))

ans = 10**19
for l in range(N):
    for r in range(l, N):
        n = bisect.bisect_right(x, x[r]) - bisect.bisect_left(x, x[l])
        if n >= K:
            dx = x[r]-x[l]
            tmp = sorted(y[l:r+1])
            for i in range(n-K+1):
                dy = tmp[i+K-1] - tmp[i]
                ans = min(ans, dx*dy)
print(ans)


Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;

vvi g;
vi p;

int main() {
  int n;
  cin >> n;
  g.resize(n);
  p.assign(n, -1);
  for (int i = 0; i < n-1; ++i) {
    int a,b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int k;
  cin >> k;
  set<pii> q;
  for (int i = 0; i < k; ++i) {
    int v; cin >> v; --v;
    cin >> p[v];
    q.insert(pii(p[v], v));
  }
  while (!q.empty()) {
    int v = q.begin()->second;
    q.erase(q.begin());
    for (int i : g[v]) if (p[i] == -1) {
      p[i] = p[v] + 1;
      q.insert(pii(p[i], i));
    }
  }
  bool ok = 1;
  for (int i = 0; i < n; ++i) for (int j : g[i]) if (abs(p[i] - p[j]) != 1) ok = 0;
  if (ok) {
    cout << "Yes\n";
    for (int i = 0; i < n; ++i) cout << p[i] << endl;
  } else {
    cout << "No\n";
  }
  return 0;
}



Measured memory_bytes: 11648
N = int(input())

answer = [(97, 'a')]
for _ in range(N - 1):
    new_answer = []
    for i, j in answer:
        for k in range(97, i + 2):
            new_answer.append((max(k, i), j + chr(k)))
    answer = new_answer[:]

answer = [j for _, j in answer]
answer.sort()
print('\n'.join(answer))


Measured memory_bytes: 24040
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N,A,B;
    cin>>N>>A>>B;
    cout<<min(N*A,B)<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
void read(int&a) {
	a = 0; char k = getchar(); int f = 1;
	for(;!isdigit(k); k = getchar()) if (k == '-') f = -1;
	for(; isdigit(k); k = getchar()) a = a * 10 + k - '0';
	a *= f;
}
const int N = 200000 + 5, inf = 0x3f3f3f3f3f3f3f3fLL;
int n, q, A, B, x[N];
struct Seg {
	int ch[N << 1][2], mins[N << 1], tag[N << 1], tot;
	int build(int u, int v) {
		int now = ++tot; mins[now] = inf;
		if(u == v) return now;
		int mid = (u + v) >> 1;
		ch[now][0] = build(u, mid);
		ch[now][1] = build(mid + 1, v);
		return now;
	}
	void push_down(int p) {
		tag[ch[p][0]] += tag[p], tag[ch[p][1]] += tag[p];
		mins[ch[p][0]] += tag[p], mins[ch[p][1]] += tag[p];
		tag[p] = 0;
	}
	void push_up(int p) {
		mins[p] = min(mins[ch[p][0]], mins[ch[p][1]]);
	}
	void add(int p, int l, int r, int u, int v, int k) {
		if(u <= l && v >= r) {
			tag[p] += k, mins[p] += k;
			return ;
		}
		push_down(p);
		int mid = (l + r) >> 1;
		if(u <= mid) add(ch[p][0], l, mid, u, v, k);
		if(v > mid) add(ch[p][1], mid + 1, r, u, v, k);
		push_up(p);
	}
	void change(int p, int l, int r, int u, int v, int k) {
		if(u != v) debug("XXXXXXXX");//强制相等
		if(u <= l && v >= r) {
			tag[p] = 0, mins[p] = k;
			return ;
		}
		push_down(p);
		int mid = (l + r) >> 1;
		if(u <= mid) change(ch[p][0], l, mid, u, v, k);
		if(v > mid) change(ch[p][1], mid + 1, r, u, v, k);
		push_up(p);
	}
	int query(int p, int l, int r, int u, int v) {
		if(u <= l && v >= r) return mins[p];
		int mid = (l + r) >> 1, res = inf;
		push_down(p);
		if(u <= mid) res = min(res, query(ch[p][0], l, mid, u, v));
		if(v > mid) res = min(res, query(ch[p][1], mid + 1, r, u, v));
		return res;
	}
}s1, s2;
signed main()
{
	read(n); read(q); read(A); read(B);
	for(int i = 1; i <= q; ++i) read(x[i]);
	x[0] = A;
	s1.build(1, n), s2.build(1, n);
	s1.change(1, 1, n, B, B, -B);
	s2.change(1, 1, n, B, B, B);
	for(int i = 1; i <= q; ++i) {
		int res1 = s1.query(1, 1, n, 1, x[i]) + x[i];
		int res2 = s2.query(1, 1, n, x[i] + 1, n) - x[i];
		s1.add(1, 1, n, 1, n, abs(x[i - 1] - x[i]));
		s2.add(1, 1, n, 1, n, abs(x[i - 1] - x[i]));
		s1.change(1, 1, n, x[i], x[i], inf);
		s2.change(1, 1, n, x[i], x[i], inf);
		s1.change(1, 1, n, x[i - 1], x[i - 1], min(res1, res2) - x[i - 1]);
		s2.change(1, 1, n, x[i - 1], x[i - 1], min(res1, res2) + x[i - 1]);
		// for(int j = 1; j <= n; ++j) printf("%lld%c", s1.query(1, 1, n, j, j) + j, " \n"[j == n]);
		// exit(0);
	}
	int ans = inf;
	for(int i = 1; i <= n; ++i) if(i != x[q]) ans = min(ans, s1.query(1, 1, n, i, i) + i);
	printf("%lld\n", ans);
	return 0;
}








































Measured memory_bytes: 26752
#include <stdio.h>
#include <string.h>

int main(int argc, char *args[])
{
    char s[10];
    scanf("%s", s);
    //文字列の長さを調べる
    int n;
    n = strlen(s);
    int ans = 0;
    int cnt = 0;
    for(int i=0;i < n;i++){
        if(s[i] == 'A' || s[i] == 'C' ||s[i] == 'G' ||s[i] == 'T' ){
            cnt++;
        }
        else{
            cnt = 0;
        }
        if(ans < cnt){
            ans = cnt;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
typedef vector<ll> vll;
typedef vector<int> vi;
const ll N = 1e7 + 10;
const int M = 1e9 + 7;
const double eps = 1e-9;


int main() {
    int n, m, k;
    cin >> n >> m >> k;
    int a[n][m];
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < m; ++j) {
            a[i][j] = (s[j] == '#');
        }
    }
    int ans = 0;
    for (int i = 0; i < (1 << (m + n)); ++i) {
        map<int, int> r, c;
        for (int j = 0; j < (m + n); ++j) {
            if (j < n && (i & (1 << j)))
                r[j] = 1;
            else if (j >= n && (i & (1 << j)))
                c[j - n] = 1;
        }
        int cnt = 0;
        for (int j = 0; j < n; ++j) {
            for (int kk = 0; kk < m; ++kk) {
                if (r[j] || c[kk])
                    continue;
                cnt += a[j][kk];
            }
        }
        ans += (cnt == k);
    }
    cout << ans << endl;

}


Measured memory_bytes: 3620