akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    };
    let q="keyence";
    if (0..7).any(|i| s.starts_with(&q[0..i]) && s.ends_with(&q[i..7])) { println!("YES") }
    else { println!("NO") }
}


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

ll n, m, q;
vector<ll> a, b, c, d;

ll dfs(vector<ll> &A) {
  if(A.size() == n) {
    ll ret = 0;
    rep(i, 0, q) {
      if(A[b[i]-1]-A[a[i]-1] == c[i]) ret += d[i];
    }
    return ret;
  }
  
  ll ret = 0;
  ll left = (A.empty() ?1 :A.back());
  for(ll i = left; i <= m; i++) {
    A.push_back(i);
    ret = max(ret, dfs(A));
    A.pop_back();
  }
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  cin >> n >> m >> q;
  a.resize(q); b.resize(q); c.resize(q); d.resize(q);
  rep(i, 0, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
  
  vector<ll> A;
  cout << dfs(A) << "\n";
}

Measured memory_bytes: 3588
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)


template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }

int main(){
    ll X, Y, Z;

    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int H, W, N;
    cin >> H >> W >> N;
    cout << min((N + (H - 1)) / H, (N + (W - 1)) / W) << endl;
}

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

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

typedef long long ll;

int main(int argc, char const *argv[]) {
    char S[12];
    scanf("%s",S);
    int len=strlen(S);
    int c=0,flag=0;
    if(S[0]!='A'){
        printf("WA");
        return 0;
    }
    for(int i=2;i<len-1;i++){
        if(S[i]=='C'){
            c++;
            flag=i;
        }
    }
    if(c!=1){
        printf("WA");
        return 0;
    }
    for(int i=1;i<len;i++){
        if((S[i]<'a' || S[i]>'z') && i!=flag){
            printf("WA");
            return 0;
        }
    }
    printf("AC");
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
cnt = 0
for s1 in range(10):
    s1_ind = s.find(str(s1))
    if s1_ind == -1 or s1_ind >= len(s)-2 : continue
    for s2 in range(10):
        s2_ind = s[s1_ind+1: ].find(str(s2)) + s1_ind + 1
        if s2_ind <= s1_ind or s2_ind >= len(s)-1: continue
        for s3 in range(10):
            s3_ind = s[s2_ind+1: ].find(str(s3)) + s2_ind + 1
            if s3_ind > s2_ind: 
                cnt+=1

print(cnt)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    long long N; cin >> N;
    vector<long long> A;
    rep (i, 0, 5) {
        long long in; cin >> in;
        A.push_back(in);
    }

    sort(A.begin(), A.end());
    cout << (N + A[0] - 1) / A[0] + 4 << endl;
}

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

int main(){
  char b;
  cin >> b;
  if(b == 'A'){
    cout << 'T';
  }
  if(b == 'T'){
    cout << 'A';
  }
  if(b == 'C'){
    cout << 'G';
  }
  if(b == 'G'){
    cout << 'C';
  }
  cout << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <deque>
#include <functional>
#include <initializer_list>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <queue>
#include <vector>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define SORT(A) std::sort((A).begin(), (A).end())
#define ALL(A) (A).begin(), (A).end()
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())

using lli = long long int;
using pii = std::pair<int, int>;

void VintOut(std::vector<int>& A){
    const int n = A.size();
    if(n == 0){putchar('\n'); return;}
    printf("%d", A[0]);
    for(int i = 1; i < n; ++i) printf(" %d", A[i]);
    putchar('\n');
}
void VintOut(std::vector<long long int>& A){
    const int n = A.size();
    if(n == 0){ putchar('\n'); return;}
    printf("%lld", A[0]);
    for(int i = 1; i < n; ++i) printf(" %lld", A[i]);
    putchar('\n');
}

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

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


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

constexpr int N = 22;
constexpr int NN = 1 << N;
constexpr int mod = 1e9 + 7;
std::array<std::vector<int>, N> States;
std::bitset<N> P;
std::array<int, NN> A;

inline bool bitUP(int state, int k){
    return (state >> k) & 1;
}

int main(void){
    int n; scanf("%d", &n);
    int m = 1 << n;
    REP(state, m) States[__builtin_popcount(state)].push_back(state);
    A[0] = 1;
    REP(i, n){
        char c;
        REP(j, n){
            scanf("%*c%c", &c);
            P[j] = c - '0';
        }
        for(int state : States[i]){
            REP(j, n) if(P[j] and (not bitUP(state, j))){
                if((A[state | (1 << j)] += A[state]) >= mod) A[state | (1 << j)] -= mod;
            }
        }
    }
    printf("%d\n", A[m - 1]);
    


    

    
    
    return 0;
}

Measured memory_bytes: 19900
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int N, M, D;

	while (true)
	{
		scanf("%d", &N);
		scanf("%d", &M);

		if (N == 0 && M == 0) { break; }

		vector<int> C; C.push_back(0);

		for (int i = 0; i < N; i++)
		{
			scanf("%d", &D);

			if (D <= M)
			{
				C.push_back(D);
			}
		}

		vector<int> r1, r;

		for (int i = 0; i < C.size(); i++)
		{
			for (int j = i; j < C.size(); j++)
			{
				if (C[i] + C[j] <= M)
				{
					r1.push_back(C[i] + C[j]);
				}
			}
		}

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

		r.push_back(r1[0]);

		for (int i = 0; i < r1.size(); i++)
		{
			if (r1[i - 1] != r1[i])
			{
				r.push_back(r1[i]);
			}
		}

		int ret = 0;

		for (int i = 0; i < r.size(); i++)
		{
			int ptr = upper_bound(r.begin(), r.end(), M - r[i]) - r.begin() - 1;
			
			if (ptr >= 0)
			{
				ret = max(ret, r[i] + r[ptr]);
			}
		}

		printf("%d\n", ret);
	}

	return 0;
}

Measured memory_bytes: 9020
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <set>
#include <map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

int h, w, n, md;
bool g[51][51] = {};

void answer() {
    ll res = 0;
    ll base = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (g[i][j]) res = (res+base) % md;
            base = 2*base % md;
        }
    }
    cout << "! " << res << endl;
}

using T = tuple<int, int, int, int>;
map<T, int> buf;
int que(int ax, int ay, int bx, int by) {
    bx--; by--;
    if (buf.count(T(ax, ay, bx, by))) return buf[T(ax, ay, bx, by)];
    cout << "? " << ay << " " << ax << " " << by << " " << bx << endl;
    int p;
    cin >> p;
    return buf[T(ax, ay, bx, by)] = p;
}


int dfs(int d, int u, int l, int r, int nm = -1) {
    if (nm == -1) {
        nm = que(l, d, r, u);
    }
    if (nm == 0) return 0;
    if (l+1 == r && d+1 == u) {
        g[d][l] = true;
        return 1;
    }
    int mdy = (d+u)/2;
    int mdx = (l+r)/2;
    if (u-d < r-l) {
        int buf = dfs(d, u, l, mdx);
        dfs(d, u, mdx, r, nm-buf);
    } else {
        int buf = dfs(d, mdy, l, r);
        dfs(mdy, u, l, r, nm-buf);
    }
    return nm;
}

int main() {
    ios::sync_with_stdio(0);
    cin >> h >> w >> n >> md;
//    for (int i = 0; i < h; i++) {
/*        for (int j = 0; j < w; j++) {
            g[i][j] = (que(j, i, j+1, i+1) != 0);
        }*/
//        dfs(i, 0, w);
//    }
    dfs(0, h, 0, w);
    answer();
    return 0;
}



Measured memory_bytes: 848
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

int c[3][3];

int main() {
  REP(i, 3) REP(j, 3) cin >> c[i][j];
  if(c[0][0]+c[1][1]+c[2][2]==c[0][1]+c[1][2]+c[2][0]&&c[0][1]+c[1][2]+c[2][0]==c[0][2]+c[1][0]+c[2][1]) {
    cout << "Yes" << endl;
  }else cout << "No" << endl;

  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);

        String n = sc.next();
        sc.close();

        int fx = 0;

        for (int i = 0; i < n.length(); i++) {
            fx += Integer.parseInt(String.valueOf(n.charAt(i)));
        }

        if (Integer.parseInt(n) % fx == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
typedef long long ll;
#define min(a, b) ((a) < (b) ? (a) : (b))
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)




int main() {
	int N;
	long W;
	long long weight[110];
	long long value[110];

	long long dp[110][100010] = {0};

	cin >> N >> W;
	for (int i = 0; i < N; i++) cin >> weight[i] >> value[i];

	for (int i = 0; i < N; ++i) {
		for (int sum_w = 0; sum_w <= W; ++sum_w) {

			if (sum_w >= weight[i]) {
				chmax(dp[i + 1][sum_w], value[i] + dp[i][sum_w - weight[i]]);
			}

			chmax(dp[i + 1][sum_w], dp[i][sum_w]);
		}
	}

	cout << dp[N][W] << endl;
}


Measured memory_bytes: 86144
import sys
from itertools import permutations, combinations
  
def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [[int(a) for a in input().split()] for _ in range(N)]

    length = 0
    possible = True
    for a, b in combinations(range(N), 2):
        Lab = A[a][b]
        for k in range(N):
            if k != a and k != b:
                if Lab >  A[a][k] + A[k][b]:
                    possible = False
                    break
                elif Lab ==  A[a][k] + A[k][b]:
                    break
        else: length += Lab
        if not possible:
            print(-1)
            break
    else: print(length)
    
    return 0
  
if __name__ == "__main__":
    solve()

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

int main(void) {
	int n, k; cin >> n >> k;
	int x[n], i, sum = 0;
	for (i = 0; i < n; i++) {
		cin >> x[i];
		sum += min(x[i], k - x[i]) * 2;
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
X, K, D =map(int,input().split())
X = abs(X)

if X > K*D:
  print(X-K*D)
else:
  greed = X//D
  if (K - greed)%2 == 0:
    print(X-greed*D)
  else:
    print((1+greed)*D -X)

Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> vec;
    for (int i = 1; i * i <= m; i++) {
        if (m % i == 0) {
            vec.push_back (i);
            vec.push_back (m / i);
        }
    }
    int ans = 1;
    sort (vec.begin(), vec.end());
    rep (i, vec.size()) {
        int b = m / vec[i];
        //cout << vec[i] << " : " << b << "\n";
        if (b < n) break;
        ans = vec[i];
    }
    cout << ans << "\n";
}

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

string transform_for_char(const string& in, const char ch){
    string rez(in.size()-1, '0');
    for(int i = 0; i < rez.size(); ++i){
        if(in[i] == ch || in[i+1] == ch) rez[i] = ch;
        else rez[i] = in[i]; }
    return rez; }

int count_nr_for_char(string in, const char ch){
    int rez = 0;
    while(!all_of(begin(in), end(in), [&](const char x){ return x == ch; }))
        ++rez,
        in = transform_for_char(in, ch);
    return rez; }

int main(){
    string str;
    int rez = 1e9;
    cin >> str;
    for(char ch = 'a'; ch <= 'z';  ++ch)
        rez = min(rez, count_nr_for_char(str, ch));
    cout << rez << endl; }



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

ans = 0
ans += b[a[0]-1]
for ii in range(n-1):
  i = ii+1
  ans += b[a[i]-1]
  if(a[i] == a[i-1]+1):
    ans+=c[a[i-1]-1]
print(ans)

Measured memory_bytes: 38256
import sys
n = int(sys.stdin.readline())
points = [0, 0]
for i in range(n):
    (taro, hanako) = sys.stdin.readline().split()
    if taro < hanako:
        points[1] += 3
    elif taro > hanako:
        points[0] += 3
    else:
        points[0] += 1
        points[1] += 1
print(points[0], points[1])

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

typedef long long int lli;
#define N_MAX 100
#define W_MAX 100000

lli N, W;
lli w[N_MAX];
lli v[N_MAX];

// 重さi以下での最大値とそのときの重さの余裕
lli dp[W_MAX+1];


lli max(lli a, lli b){
    if (a < b) return b;
    return a;
}

int main(void){
    // Your code here!
    cin >> N;
    cin >> W;
    for(int i = 0; i < N; i ++){
        cin >> w[i];
        cin >> v[i];
    }
   for(int i = 0; i <= W; i ++) dp[i] = 0;
    
    for(int i = 0; i < N; i ++){
        for(int j = W; j >= w[i]; j --){
            // 入れない場合の価値
            lli v0 = dp[j];
            // 入れる場合の価値
            lli v1 = dp[j - w[i]] + v[i];
            dp[j] = max(v0, v1);
        }
    }
    cout << dp[W];
}

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

int main(void) {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	n-=1,a -= 1;b -= 1;c -= 1;d -= 1;
	char s[200100];
	for (int i = 0;i < n;i++)cin >> s[i];
	if (c < d) {
		if (c > a + 1) {
			for (int i = a;i <= c - 1;i++) {
				if (s[i] == '#') {
					if (s[i + 1] == '#') {
						cout << "No"<<endl;
						return 0;
					}
				}
			}
		}
		if (d > b + 1) {
			for (int i = b;i <= d - 1;i++) {
				if (s[i] == '#') {
					if (s[i + 1] == '#') {
						cout << "No"<<endl;
						return 0;
					}
				}
			}
		}
		cout << "Yes"<<endl;
	}
	if (c > d) {
		for (int i = a;i <= c - 1;i++) {
			if (s[i] == '#') {
				if (s[i + 1] == '#') {
					cout << "No"<<endl;
					return 0;
				}
			}
		}
		bool flag1 = false,flag2 = false;
		if (s[b - 1] == '.'&&s[b + 1] == '.')flag1 = true;
		for (int i = b;i < d;i++) {
			if (s[i] == '.') {
				if (s[i + 1] == '.') {
					if (s[i + 2] == '.') {
						flag2 = true;
						break;
					}
				}
			}
		}
		if (flag1 || flag2) cout << "Yes" <<endl;
		else cout << "No" <<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
        string s;
        cin>>s;
        if(s.size()<6)
                cout<<"No"<<endl;
        else{
                if(s[2]==s[3] && s[4]==s[5])
                        cout<<"Yes"<<endl;
                else
                        cout<<"No"<<endl;
        }
}


Measured memory_bytes: 256
// LNU_Algotesters
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <fstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
const int MAX = 1 * 1000 + 47;

int a[MAX][MAX];

int common(string a, string b)
{
    //reverse(ALL(a));
    FOR(i, 0, SZ(a))
    {
        bool ok = 1;
        FOR(j, i, SZ(a))
        {
          //  cout << a[j] << " " << b[j-i] << endl;
            if (a[j] != b[j-i])
                ok = 0;
        }
        
       // cout << i << " "<< ok << endl;
        if (ok)return SZ(a) - i;
    }
    return 0;
}

int main()
{
    int n;
    string a, b;
    cin >> n >> a >> b;
    int ans = n + n - max(common(a, b), common(b, a));
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=10200,M=5000;
inline int read(int x=0,bool f=0,char ch=getchar()){
	for(;!isdigit(ch);ch=getchar()) f=ch=='-';
	for(; isdigit(ch);ch=getchar()) x=(x<<3)+(x<<1)+(ch^48);
	return f?-x:x;
}
int n,h;
int f[N],*fa=f+5000,o[N],*outdu=o+M;
int in[N],*indu=in+M,sz[N],*siz=sz+M;
int c[N],*cnt=c+M;
bool v[N],*vis=v+M;
inline int get(int x){
	return fa[x]==x?x:fa[x]=get(fa[x]);
}
int main(){
	n=read(),h=read();
	for(int i=-h;i<=h;++i) fa[i]=i,siz[i]=1;
	for(int i=1;i<=n;++i){
		int a=read(),b=read(),c=read(),d=read();
		int x=c?c:-a,y=d?-d:b;
		indu[y]++; outdu[x]++;
		if(get(x)!=get(y)) fa[fa[x]]=fa[y],siz[fa[y]]+=siz[fa[x]];
		cnt[get(y)]++;
	}
	bool f=0;
	for(int i=1;i<=h;++i) if(outdu[i]>indu[i]) f=1;
	for(int i=-h;i;++i) if(indu[i]>outdu[i]) f=1;
	for(int i=-h;i<=h;++i) if(cnt[get(i)]&&indu[i]!=outdu[i]) vis[get(i)]=true;
	for(int i=-h;i<=h;++i) if(get(i)==i&&!vis[i]&&cnt[i]) f=1;
	puts(f?"NO":"YES");
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>

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

using namespace std;

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

	int64_t x=n;
	if(n>=b)n=b-1;
	cout << int64_t((a*n)/b);


	return 0;
}

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

int main() {
    int n,t;
    long ans = 0;
    cin >> n >> t;
    vector<int> time(n);
    vector<int> d(n);
    for(int i=0;i<n;i++)cin >> time[i];
    d[0]=0;
    for(int i=1;i<n;i++){
        d[i]=time[i]-time[i-1];
    }
    for(int i=0;i<n-1;i++){
        if(d[i+1]<t)ans += d[i+1];
        else ans += t;
    }
    ans += t;

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){

	long long int a,b,c;
	cin >> a >> b >> c;

	if( a%2 == 0 || b%2 == 0 || c%2 == 0 ) cout << 0 << endl;
	else{
		if( a == max( a, max(b, c) ) ) cout << b*c << endl;
		else if( b == max( a, max(b, c) ) ) cout << a*c << endl;
		else if( c == max( a, max(b, c) ) ) cout << a*b << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N, H = map(int,input().split())
L = []
maxi = 0
for _ in range(N):
    a,b = map(int,input().split())
    maxi = max(maxi, a)
    L.append(b)
 
L = sorted([x for x in L if x > maxi])[::-1]
throw = 0
for i in range(len(L)):
    throw += L[i]
    if throw >= H:
        print(i + 1)
        quit()
from math import ceil
print(ceil((H - throw) / maxi) + len(L))
    


Measured memory_bytes: 9052
import sys
input = sys.stdin.buffer.readline

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort(key = lambda x: x[1])

sum_a = 0
for a, b in AB:
  sum_a += a
  if sum_a > b:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 80732
#ABC170C.rb
x,n = gets.split.map(&:to_i)
ar = gets.split.map(&:to_i).sort

if n == 0
  puts x
  exit
end

tmp = (x - 0).abs
ans = 0

(1..101).each do |i|
  unless ar.include?(i)
    #puts "i:#{i} tmp:#{tmp} tmp_new:#{(x-i).abs}" 
    if tmp > (x-i).abs
      ans = i
      tmp = (x-i).abs
    elsif tmp == (x-i).abs
      if i < ans
        ans = i
      end
    end
  end
end
puts ans


Measured memory_bytes: 14280
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Here your code !
process.stdin.on('data', function(chunk){
    var lines = chunk.toString().split(" ");
    var r = parseInt(lines[0]);
    var g = parseInt(lines[1]);
    var b = parseInt(lines[2]);

    
    var N =r*100 + g*10 + b;
 //   console.log(N);

    var rest = N % 4; 
 

   if(rest == 0){
        console.log("YES");
    }else{
        console.log("NO");
    
    }

});

Measured memory_bytes: 21320
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int[] time = new int[n+1];
    int[] x = new int[n+1];
    int[] y = new int[n+1];
    time[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for(int i = 1; i <= n; i++) {
      time[i] = Integer.parseInt(sc.next());
      x[i] = Integer.parseInt(sc.next());
      y[i] = Integer.parseInt(sc.next());
    }
    int dis, dtime;
    boolean flag = true;
    for(int i = 1; i <= n; i++) {
      dis = Math.abs(x[i] - x[i-1]) + Math.abs(y[i] - y[i-1]);
      dtime = time[i] - time[i-1];
      if(!(dis <= dtime && dis % 2 == dtime % 2)) flag = false;
      if(!flag) break;
    }
    System.out.println((flag)? "Yes" : "No");
  }
}


Measured memory_bytes: 62192
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(b-a<0&&c-b<0&&c-a<0)
    cout<<"No";
    else if(b-a<=d&&c-b<=d||c-a<=d)
    cout<<"Yes";
    else
    cout<<"No";


   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

pair<int, int> solve(string s) {
	int tot = 0;
	int mn = 0;
	for (auto x : s) {
		if (x == '(') tot++;
		else tot--;
		mn = min(mn, tot);
	}
	return {tot, mn};
}

string rp(string s) {
	reverse(s.begin(), s.end());
	for (auto &t : s) {
		if (t == '(') t = ')';
		else t = '(';
	}
	return s;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
		
	int n;
	cin >> n;
	vector<string> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	vector<pair<pair<int, int>, string>> pb;
	vector<pair<pair<int, int>, string>> nb;
	for (int i = 0; i < n; i++) {
		int tot, mn;
		tie(tot, mn) = solve(a[i]);
		if (tot >= 0) {
			pb.push_back({{mn, tot}, a[i]});
		} else {
			string s = rp(a[i]);
			tie(tot, mn) = solve(s);
			nb.push_back({{mn, tot}, s});
		}
	}
	sort(pb.rbegin(), pb.rend());
	sort(nb.rbegin(), nb.rend());
	string res;
	for (auto t : pb) {
		res += t.second;
		// cerr << t.second << endl;
	}
	reverse(nb.begin(), nb.end());
	for (auto t : nb) {
		res += rp(t.second);
		// cerr << t.second << endl;
	}
	{
		int tot, mn;
		tie(tot, mn) = solve(res);
		if (tot == 0 && mn >= 0) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
	}
}


Measured memory_bytes: 60040
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
  while (true) {
    int h, w;
    cin >> h >> w;
    if (h == 0 && w == 0)
      break;
    vector<string> r(h);
    for (int i = 0; i < h; ++i)
      cin >> r[i];
    string s;
    cin >> s;

    map<char, pair<int, int>> m;
    for (int i = 0; i < h; ++i)
      for (int j = 0; j < w; ++j)
        if (r[i][j] != '_')
          m[r[i][j]] = make_pair(i, j);

    int pi = 0, pj = 0, ans = 0;
    for (int k = 0; k < s.size(); ++k) {
      ans += abs(m[s[k]].first - pi) + abs(m[s[k]].second - pj) + 1;
      pi = m[s[k]].first, pj = m[s[k]].second;
    }

    cout << ans << endl;
  }
}


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

int main() {
    int c[3][3];
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }
    int a[3];
    int b[3];
    for(int i = 0; i < 3; i++) {
        a[i] = c[i][0];
        b[i] = c[0][i] - a[0];
    }
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            if(c[i][j] != a[i] + b[j]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    n,q = LI()

    n0 = 2**((n-1).bit_length())
    st = [2**31-1] * (n0*2)

    def find(s,t):
        s += n0; t += n0
        ret = 2**31 - 1
        while s < t:
            if s % 2:
                ret = min(ret,st[s-1])
                s += 1
            if t % 2:
                t -= 1
                ret = min(ret,st[t-1])
            s >>= 1; t >>= 1
        return ret

    def update(i,x):
        i += n0 - 1
        st[i] = x
        while i > 0:
            i = (i-1) // 2
            st[i] = min(st[i*2+1],st[i*2+2])

    for _ in range(q):
        c,x,y = LI()
        if c == 0:
            update(x,y)
        else:
            print(find(x,y+1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9532
//2018.09.23

#include <iostream>

using namespace std;

int main() {

    int a,b;
    cin >> a >> b;

    string s;
    cin >> s;

    int i;
    for(i=0;i<a;i++){
        if(s[i]=='-'){
            cout << "No" << endl;
            return 0;
        }
    }

    for(i=a+1;i<a+b+1;i++){
        if(s[i]=='-'){
            cout << "No" << endl;
            return 0;
        }
    }

    if(s[a]=='-') cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

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

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int n, p; cin >> n >> p;
    int odd = 0, even = 0;
    rep(i, n) {
        int a; cin >> a;
        if (a % 2) odd++;
        else even++;
    }

    ll ans = 0;
    if (even == n) ans = (1LL << n);
    else ans = (1LL << (n-1));

    if (p) ans = (1LL << n) - ans;

    cout << ans << endl;

}

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

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 1e9+7;
    static vector<modint> factorial;

    modint(): num(0) {};
    modint(ll _n): num((_n + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return (num+MOD)%MOD; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
    modint operator+(const modint &r) const { return modint(num + r.num); }
    modint operator-(const modint &r) const { return modint(num - r.num); }
    modint operator*(const modint &r) const { return modint(num * r.num); }

    template<typename T>
    modint operator^(const T &r) const {
        if(r == 0) return 1;
        return (((*this)*(*this)) ^ (r/2)) * modint(r&1 ? num : 1);
    }
    modint operator/(const modint &r) const { return num * (r^(MOD-2)); }

    modint operator+=(const modint &r) { return *this = *this + r; }
    modint operator-=(const modint &r) { return *this = *this - r; }
    modint operator*=(const modint &r) { return *this = *this * r; }
    modint operator/=(const modint &r) { return *this = *this / r; }

    template<typename T>
    modint operator^=(const T &r) { return *this = *this ^ r; }

    static modint fact(int n){
        if((int)factorial.size() <= n) factorial.resize(n+1);
        if(factorial[n]) return factorial[n];
        if(n == 0) return 1;
        return factorial[n] = modint(n) * fact(n-1);
    }

    static modint C(ll n,ll r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial;
#define fact(n) modint::fact(n)
#define C(n,r) modint::C(n,r)
#define H(a,b) C(a+b, a)


int main(void){
    int n;
    cin >> n;
    vector<int> c(n);
    rep(i,n) {
        cin >> c[i];
        c[i]--;
    }
    vector<modint> dp(n);
    map<int,int> last, nxt;
    rep(i,n) {
        if (last.count(c[i])) {
            nxt[last[c[i]]] = i;
        }
        last[c[i]] = i;
    }
    dp[0] = 1;
    rep(i,n-1) {
        if (nxt.count(i) && i+1 < nxt[i]) {
            dp[nxt[i]] += dp[i];
        }
        dp[i+1] += dp[i];
    }
    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 12032
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cout<<setprecision(14);
#define randomINIT mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define gcj cout<<"Case #"<<tc<<": "
#define ld long double
#define pll pair<ll,ll>
#define vll vector<pll>
#define vl vector<ll>
#define f first
#define s second
#define pb push_back
#define MAP map<ll,ll>
#define MAPs map<ll,sl>
#define MAPv map<ll,vl>
#define mset1(x,val,n) foo(i,0,n+5) x[i]=val;
#define mset2(x,val,n,m) foo(i,0,n+5) {foo(j,0,n+5) x[i][j]=val;}
#define mod 1000000007
#define foo(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,a,b) for(ll i=(a);i>=(b);i--)
#define FOR(i,v) for(auto &(i):(v))
#define OUTv(v) for(auto &i:(v)) cout<<i<<" ";
#define deb1(a) cout<<a<<"\n";
#define deb2(a,b) cout<<a<<" "<<b<<"\n";
#define deb3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define deb4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define sl set<ll> 
#define sll set<pll>
#define ub upper_bound
#define lb lower_bound
using namespace std;

const ll   INF = 0x7f7f7f7f7f7f7f7f;
const ll NINF = -INF;
const ll MAXN  = 1e+6+8;

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

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

#define UMAP unordered_map<ll,ll,custom_hash>

ll t=1;randomINIT;
//<<-----Declare Variable Here------->>//
ll n,a[310];ld dp[310][310][310];
 
//<<-----Implement Functions Here---->>//
ld f(ll x,ll y,ll z){
	if(x<0 or  y<0 or z<0) return 0;
	if(x==0 and y==0 and z==0) return 0;
	if(dp[x][y][z]!=0) return dp[x][y][z];
	ld &ans=dp[x][y][z];
	ld p1=(ld)x/n,p2=(ld)y/n,p3=(ld)z/n,p0=(ld)(n-(x+y+z))/n;
	ld x2=p1*f(x-1,y,z),y2=p2*f(x+1,y-1,z),z2=p3*f(x,y+1,z-1);
	return ans=(ld)(1+x2+y2+z2)/(1-p0);
}

 
//<<-----Start of Main--------------->>//
void MAIN(ll tc){
	cin>>n;
	MAP cnt;
	foo(i,0,n-1) cin>>a[i],cnt[a[i]]++;
	ld x=-1;
	// mset2(dp,x,n,n);
	memset(dp,0,sizeof(dp));
	cout<<f(cnt[1],cnt[2],cnt[3])<<"\n";

}

int main(){
	fastio;
	// cin>>t;
	foo(i,1,t){
		MAIN(i);
	}
 
    // #ifndef ONLINE_JUDGE
    // cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    // #endif
}

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

int queen[9];

void output(){
    for(int i=1;i<=8;i++){
        int t=queen[i];t--;
        while(t--) cout<<".";
        cout<<"Q";
        t=8-queen[i];
        while(t--) cout<<".";
        cout<<endl;
    }
}
void dfs(int cur){
    int flag,i,j;

    if(cur==9){ 
        output();
    }
    else if(queen[cur]){
        dfs(cur+1);
    }
    else{
        for(i=1;i<=8;i++){
            flag=1;
            for(j=1;j<=8;j++){
                if(queen[j]&&(queen[j]==i || i+cur==queen[j]+j || i-cur==queen[j]-j)){
                    flag=0;
                    break;
                }
            }
            if(flag){
                queen[cur]=i;
                dfs(cur+1);
                queen[cur]=0;
            }
        }
    }
}
int main(){
    int n;cin>>n;
    while(n--){
        int x,y;
        cin>>x>>y;
        queen[x+1]=y+1;
    }
    dfs(1);
}


Measured memory_bytes: 3116
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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

const int MAX = 1 << 30;


int main(void){

	int N, K; cin >> N >> K;
	vector<int> h(N,0);
	REP(i,N){
		cin >> h[i];
	}
	vector<int> dp(N, 0);

	dp[0] = 0;

	FOR(i,1,N+1){
		int m = 1 << 30;
		FOR(j,1,K+1){
			if(i-j >= 0){
				m = min(dp[i-j] + abs(h[i-j] - h[i]), m);
			}
			dp[i] = m;
		}
	}

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

	return 0;

}


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

#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second

int main(void) 
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 

	string s="0";
	string t; 
	cin >> t; 
	s += t; 
	for (int i=1; i<s.size(); i++) 
	{
		if (i%2==0) 
		{
			if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') 
			{
				//cout << "i:"<<i<<"s[i]:"<<s[i]<<'\n';
				cout << "No\n"; 
				return false; 
			}
		}
		else
		{
			if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') 
			{
				//<cout << "i:"<<i<<"s[i]:"<<s[i]<<'\n';
				cout << "No\n";
				return false; 
			}
		}
	}
	cout << "Yes\n";

	
	return false; 
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N;
  cin >> N;
  int ans = 0;
  rep(i,N){
    int l,r;
    cin >> l >> r;
    ans += r-l+1;
  }
  cout << ans << endl;
  return 0;
}


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

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

  if (s[0] != s[1] || s[1] != s[2]){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (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> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

constexpr int MOD = 1000000007;

// + - * / ^
int mod(int a)
{
    int res = a % MOD;
    if(res < 0) {
        return res + MOD;
    }
    return res;
}
int mul_mod(int a, int b)
{
    ll res = ((ll)a * (ll)b) % MOD;
    return mod((int)res);
}
int pow_mod(int a, int b)
{
    ll res = 1;
    while (b > 0) {
        if(b & 1) {
            res = res * (ll)a % (ll)MOD;
        }
        a = mul_mod(a, a);
        b >>= 1;
    }
    return (int)res;
}
int inv_mod(int a)
{
    return pow_mod(a, MOD - 2);
}
int div_mod(int a, int b)
{
    return mul_mod(a, inv_mod(b));
}

// ! C
constexpr int FAC_MAX = 3000001;
ll fac[FAC_MAX], finv[FAC_MAX], inv[FAC_MAX];
void com_init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < FAC_MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll com_mod(int a, int b){
    if (a < b) return 0;
    if (a < 0 || b < 0) return 0;
    return fac[a] * (finv[b] * finv[a - b] % MOD) % MOD;
}


int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    com_init();
    int k; string s; cin >> k >> s;
    int n = s.size();
    // vector<int> table(n + 1);
    // table[0] = -1;
    // int j = -1;
    // rep (i, n) {
    //     while (j >= 0 && s[i] != s[j]) j = table[j];
    //     j++;
    //     table[i + 1] = j;
    // }
    // rep (i, n) eprintf("%d%c", table[i], " \n"[i == i_len - 1]);
    ll ans = 0;
    ll tmp = pow_mod(25, k + n), tmp_div = inv_mod(25);
    eprintf("%d %d %d\n", k, n, tmp);
    rep (i, n) {
        ans = mod(ans + mul_mod(com_mod(k + n, i), tmp));
        tmp = mul_mod(tmp, tmp_div);
    }
    cout << mod(pow_mod(26,k+n)-ans) << "\n";
    return 0;
}

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

int main() {
   int N;
   cin >> N;
   vector<int> a(N,0);
   rep(i,N) cin >> a.at(i);
   int sum = 0;
   rep(i,N) sum += a[i];
   cout << sum - N << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  int a, b;
  char op;
  cin >> a >> op >> b;

  if (op == '+') cout << a + b << '\n';
  else cout << a - b << '\n';

  return (0);
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  int p2 = 1;
  while (p2*2 <= n) p2 *= 2;
  if (n == p2) {
    cout << "No" << endl;
    return 0;
  }
  vector<int> a, b;
  if (n%4 == 0) {
    a = {n};
    b = {p2,n-p2};
  } else if (n%4 == 1) {
    a = {2,3};
    b = {1};
  } else if (n%4 == 2) {
    a = {1,n};
    b = {p2,n+1-p2};
  } else {
    a = {};
    b = {};
  }
  vector<int> c = b;
  for (int i = 1; i <= n; i++)
    if (!count(a.begin(),a.end(),i) && !count(b.begin(),b.end(),i))
      c.push_back(i);
  int csz = c.size();
  for (int i = 0; i < csz; i++)
    c.push_back(c[i]+n);

  assert(a.size()*2+c.size() == 2*n);

  cout << "Yes" << endl;
  for (int i = 1; i < c.size(); i++) {
    cout << c[i-1] << ' ' << c[i] << '\n';
  }
  for (int i = 0; i < a.size(); i++) {
    cout << (i ? a[i-1] : c[0]) << ' ' << a[i] << '\n';
    cout << (i+1 < a.size() ? n+a[i+1] : b.back()) << ' ' << n+a[i] << '\n';
  }
}


Measured memory_bytes: 3700
#!/usr/bin/env python3
def main():
    N = int(input())
    S = input()

    seen = set()
    ans = 0
    for i in range(N - 2):
        if S[i] in seen:
            continue
        seen.add(S[i])
        for j in range(i + 1, N - 1):
            if S[i] + S[j] in seen:
                continue
            seen.add(S[i] + S[j])
            for k in range(j + 1, N):
                if S[i] + S[j] + S[k] in seen:
                    continue
                seen.add(S[i] + S[j] + S[k])
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
  int n;
  string s,t,u = "";
  cin >> n>> s >> t;
  for(int i = 0;i < n;i++){
    u += s[i];
    u += t[i];
  }
  cout << u;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var n int
	var pi = math.Acos(-1.0)
	var res float64
	fmt.Scanf("%d", &n)

	x := make([]float64, n)
	y := make([]float64, n)

	for i := 0; i < n; i++ {
		fmt.Scanf("%f %f", &x[i], &y[i])
	}

	for i := 0; i < n; i++ {
		res = 0.0
		var angles []float64
		for j := 0; j < n; j++ {
			if i != j {
				angles = append(angles, math.Atan2(y[j]-y[i], x[j]-x[i]))
			}
		}

		sort.Float64s(angles)
		var max float64
		for j := 0; j < len(angles)-1; j++ {
			max = math.Max(max, angles[j+1]-angles[j])
		}
		max = math.Max(max, angles[0]-angles[len(angles)-1]+2*pi)

		if max > pi {
			res = (max - pi) / (2 * pi)
		}
		fmt.Printf("%f\n", res)
	}

	return
}


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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,start,end) for(int i=(start);i<=(end);i++)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	int a, b;
	cin >> a >> b;
	if((a*b)%2 == 0) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");

    const a = parseInt(input[0].split(" ")[0]);
    const b = parseInt(input[0].split(" ")[1]);
    console.log(a * b)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

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

int main() {
  int N, M;
  cin>>N>>M;
  vector<vector<int> > L(N);
  int K;
  int tmp;
  vector<vector<int> > O(M);
  for(int i=0;i<N;++i) {
    cin>>K;
    for(int j=0;j<K;++j) {
      cin>>tmp;
      tmp--;
      L[i].push_back(tmp);
      O[tmp].push_back(i);
    }
  }
  map<int, int> Lmap, Pmap;
  queue<int> que;
  que.push(0);
  int state;
  while(!que.empty()) {
    state = que.front();que.pop();
    if(Pmap[state]>0) continue;
    Pmap[state]++;
    for(int i=0;i<L[state].size();++i) {
      if(Lmap[L[state][i]]>0) continue;
      Lmap[L[state][i]]++;
      for(int j=0;j<O[L[state][i]].size();++j) {
        if(Pmap[O[L[state][i]][j]]>0) continue;
        que.push(O[L[state][i]][j]);
      }
    }
  }
  bool can = true;
  for(int i=0;i<N;++i) {
    if(Pmap[i]==0) can = false;
  }
  if(can) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}



Measured memory_bytes: 16332
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <sstream>

using namespace std;

bool a[8000000];
int ans[101][500001];

int main(){
	
	for(int m = 2; m <= 100; m++){
		
		int N = 8000000;
		
		for(int i = 0; i < N; i++){
			a[i] = true;
		}
		
		a[0] = false;
		a[1] = false;
		int count = 0;
		
		for(int i = m; i < N; i++){
			if(a[i]){
				ans[m][count] = i;
				count++;
				if(count > 500000){
					break;
				}
				for(int j = i * 2; j < N; j += i){
					a[j] = false;
				}
			}
		}
	}
	
	//cout << "end" << endl;
	
	int m, n;
	
	while(true){
		cin >> m >> n;
		if(m == 0){
			break;
		}
		cout << ans[m][n] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 204184