akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mk make_pair
#define ll long long
using namespace std;
const int N = 3e5 + 5;
const int mod = 1e9 + 7;
int n, tot = 1, ch[N][2]; 
ll L, ans;
char s[N];
ll cal(ll x) {
	for (int i = 62; i >= 0; i--)	
		if (x % (1ll << i) == 0) return 1ll << i;
}
void dfs(int x, int d) {
	if (ch[x][0] == ch[x][1]) return;
	if (ch[x][0]) dfs(ch[x][0], d + 1);
	if (ch[x][1]) dfs(ch[x][1], d + 1);
	if (ch[x][0] == 0 && d < L) {
		ans ^= cal(L - d);
	}
	if (ch[x][1] == 0 && d < L) {
		ans ^= cal(L - d);
	}
}
int main() {
	cin >> n >> L;
	for (int i = 1; i <= n; i++) {
		scanf("%s", s + 1);
		int now = 1;
		for (int i = 1, l = strlen(s + 1); i <= l; i++) {
			if (ch[now][s[i] - '0'] == 0) ch[now][s[i] - '0'] = ++tot;
			now = ch[now][s[i] - '0'];
		}
	}
	dfs(1, 0);
	if (ans)
		puts("Alice");
	else 
		puts("Bob");
}

Measured memory_bytes: 4224
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, int> P;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[100100], b[100100];

vector<int> G[100100];

int calc(int v, int prev) {
    int cnt = 0;
    for (int u : G[v]) {
        if (u == prev) continue;
        int ret = calc(u, v);
        if (ret < 0)
            return -1;
        if (ret == 0)
            cnt++;
    }
    if (cnt == 0) return 0;
    if (cnt == 1) return 1;
    return -1;
}

bool solve() {
    for (int i = 0; i < n-1; i++) {
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }

    return calc(0, -1) != 1;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << (solve()?"First":"Second") << endl;
}


Measured memory_bytes: 9964
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	vi a(3);
	rep(i,3)cin>>a[i];
	sort(all(a));
	if(a[0]==5&&a[1]==5&&a[2]==7) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

	return 0;
}



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


const string YES = "YES";
const string NO = "NO";

void solve(string S){
    for(int i=0;i<=7;i++){
        string a=S.substr(0,i);
        string b=S.substr(S.size()-(7-i),7-i);
        if(a+b=="keyence"){
            goto yes;
        }
    }
    cout<<NO<<endl;
    return;
    yes:
    cout<<YES<<endl;
    return;
}

int main(){
    string S;
    cin >> S;
    solve(S);
    return 0;
}


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

#a,bの最大公約数
def gcd(a,b):
    if(b==0):
        return a
    else:
        return gcd(b, a%b)

#a,bの最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

print(lcm(a,b))

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			int n = Integer.parseInt(br.readLine());

			if (n == 0)
				break;

			ArrayList<Integer> a = new ArrayList<>();
			long ave = 0;

			String str[] = br.readLine().split(" ");
			for (int i = 0; i < n; i++) {
				a.add(Integer.parseInt(str[i]));
				ave += a.get(i);
			}
			ave /= n;

			int ans = 0;
			for (int num : a) {
				if (num <= ave)
					ans++;
			}
			System.out.println(ans);
		}
	}
}


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

int di[4] = {0, -1, 0, 1};
int dj[4] = {1, 0, -1, 0};

void game(int n, int& ans, int ni, int nj, int gi, int gj, vector<vector<int> >& table){

    if(ni == gi && nj == gj){
        if(ans == -1) ans = n;
        else ans = min(ans, n);
        return;
    }else if(n == 10){
        return;
    }else{

        for(int h = 0; h < 4; h++){
            int nexti = ni;
            int nextj = nj;
            if(table[ni + di[h]][nj + dj[h]] == 1) continue;
            while(1){
                nexti += di[h];
                nextj += dj[h];
                if(table[nexti][nextj] == 1){
                    table[nexti][nextj] = 0;
                    game(n + 1, ans, nexti - di[h], nextj - dj[h], gi, gj, table);
                    table[nexti][nextj] = 1;
                    break;
                }else if(table[nexti][nextj] == 3){
                    game(n + 1, ans, nexti, nextj, gi, gj, table);
                    break;
                }else if(table[nexti][nextj] == -1){
                    break;
                }
            }
        }
    }
    return;
}

int main(){

    while(1){
        int w, h; cin >> w >> h;
        if(!w) break;

        int si, sj, gi, gj;
        vector<vector<int> > table(h + 2, vector<int> (w + 2, -1));
        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= w; j++){
                cin >> table[i][j];
                if(table[i][j] == 2){
                    si = i;
                    sj = j;
                    table[i][j] = 0;
                }
                if(table[i][j] == 3){
                    gi = i;
                    gj = j;
                }
            }
        }

        int ans = -1;
        game(0, ans, si, sj, gi, gj, table);

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3124
from collections import deque
n = int(input())
to = [[] for _ in range(n)]
for i in range(n-1):
    u, v, w = map(int, input().split())
    u , v = u-1, v-1
    to[u].append([v, w])
    to[v].append([u, w])
color = [-1] * n
color[0] = 0
q = deque([0])
while q:
    v = q.popleft()
    for u, w in to[v]:
        if color[u] != -1:
            continue
        if w % 2 != 0:
            color[u] = color[v] ^ 1
        else:
            color[u] = color[v]
        q.append(u)
for c in color:
    print(c)

Measured memory_bytes: 46512
N = int(raw_input())
s = raw_input()
assert(3 <= N <= 1e5)
assert(len(s) == N)

res = []
sheep = 'S'
wolf = 'W'
container = [val for val in s]
o = 'o'
x = 'x'
passed = False
res0 = [sheep, sheep]
res1 = [sheep, wolf]
res2 = [wolf, sheep]
res3 = [wolf, wolf]
RES = [res0, res1, res2, res3]
for res in RES:
    passed1 = False
    passed2 = False
    for i in xrange(1, len(container) - 1):
        val = container[i]
        if res[i] == sheep:
            if val == o:
                res.append(res[i - 1])
            else:
                if res[i - 1] == sheep:
                    res.append(wolf)
                else:
                    res.append(sheep)
        else:# wolf
            if val == o:
                if res[i - 1] == sheep:
                    res.append(wolf)
                else:
                    res.append(sheep)
            else:
                res.append(res[i - 1])
    if (res[0] == sheep):
        if (container[0] == o) and (res[-1] == res[1]):
            passed1 = True
        elif (container[0] == x) and (not (res[-1] == res[1])):
            passed1 = True
    else:
        if (container[0] == o) and (not (res[-1] == res[1])):
            passed1 = True
        elif (container[0] == x) and (res[-1] == res[1]):
            passed1 = True

    if (res[-1] == sheep):
        if (container[-1] == o) and (res[-2] == res[0]):
            passed2 = True
        elif (container[-1] == x) and (not (res[-2] == res[0])):
            passed2 = True
    else:
        if (container[-1] == o) and (not (res[-2] == res[0])):
            passed2 = True
        elif (container[-1] == x) and (res[-2] == res[0]):
            passed2 = True
    if passed1 and passed2:
        passed = True
        break

if passed:
    print ''.join(res)
else:
    print -1

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

int main()
{
  int N, H, P=0, a=0, b=0;
  cin >> N;
  for (int i=0; i<N; i++){
    cin >> H;
    if(H<=P){
      a++;
    }
    else a=0;
    if (b<a) b=a;
    P = H;
  }
  cout << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N, M;
    cin >> N >> M;
    vector<vector<int>> s(M);
    REP(i, M) {
        int k;
        cin >> k;
        s[i].resize(k);
        REP(j, k) cin >> s[i][j];
    }
    vector<int> p(M);
    for (auto &i : p) {
        cin >> i;
    }

    int ans = 0;

    REP(bit, (1 << N)) {
        vector<int> cnt(M);
        REP(i, N) {
            if (bit & (1 << i)) {
                // sの全探索
                REP(ii, M) {
                    REP(jj, s[ii].size()) {
                        if (i + 1 == s[ii][jj])
                            cnt[ii]++;
                    }
                }
            }
        }
        bool f = true;
        REP(i, M) {
            if (cnt[i] % 2 != p[i])
                f = false;
        }
        if (f)
            ans++;
    }

    std::cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N,T;
    cin >> N >> T;
    vector<ll> A(N), B(N), C(N+1);
    rep(i,N){
        cin >> A[i] >> B[i];
    }
    vector<vector<ll>> dp(N+1, vector<ll>(T+1)), dp2(N+1, vector<ll>(T+1));
    rep(i,N){
        rep(j,T){
            if(j+A[i] <= T){
                cmax(dp[i+1][j+A[i]], dp[i][j] + B[i]);
            }
            cmax(dp[i+1][j+1], dp[i][j+1]);
            cmax(dp[i+1][j+1], dp[i+1][j]);
        }
    }
    for(ll i=N;i>0;i--){
        rep(j,T){
            if(j+A[i-1] <= T){
                cmax(dp2[i-1][j+A[i-1]], dp2[i][j] + B[i-1]);
            }
            cmax(dp2[i-1][j+1], dp2[i][j+1]);
            cmax(dp2[i-1][j+1], dp2[i-1][j]);
        }
    }
    //PR(dp[1], T+1);
    //PR(dp[2], T+1);
    /*
    for(ll i=N;i>0;i--){
        C[i-1] = max(C[i], B[i-1]);
    }*/
    ll ans = 0;
    REP(i,0,N){
        rep(j,T){
            cmax(ans, dp[i][j] + B[i] + dp2[i+1][T-1-j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 144200
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

vector<pair<int, int> > g[1<<20];
int ui, vi, N, wi;
int colr[1<<20];

void dfs(int s, int p, int col) {
  colr[s] = col;

  for(auto &node: g[s]) {
    if(node.first != p) {
      dfs(node.first, s, (node.second % 2) ^ col);
    }
  }
}

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  cin >> N;
  for(int i = 1;i < N;i++) {
    cin >> ui >> vi >> wi;
    g[ui].push_back({vi, wi});
    g[vi].push_back({ui, wi});
  }

  dfs(1, -1, 0);
  for(int i = 1;i <= N;i++) cout << colr[i] << endl;

  return 0;
}


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

void print_elements(int length, int elements[]) {
    cout << elements[0];
    for (int i = 1; i < length; i++)
        cout << " " << elements[i];
    cout << endl;
}

int selection_sort(int N, int elements[]) {
    int n_swapped = 0;
    for (int i = 0; i < N; i++) {
        int min_i = i;
        for (int i_unsorted = i; i_unsorted < N; i_unsorted++) {
            if (elements[i_unsorted] < elements[min_i]) {
                min_i = i_unsorted;
            }
        }
        if (i < min_i) {
            std::swap(elements[i], elements[min_i]);
            n_swapped++;
        }
    }
    return n_swapped;
}

/* ALDS1_2_B: Selection Sort */
int main() {
    int N;
    cin >> N;

    int elements[N];
    for (int i = 0; i < N; i++)
        cin >> elements[i];

    int n_swapped = selection_sort(N, elements);

    print_elements(N, elements);
    cout << n_swapped << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main()  {
// Nは札の枚数の合計、Yは金額の総和
  int N, Y;
  cin >> N >> Y;
  bool f = false;
  bool t = false;
  int x, y;
// xは10000円札の枚数、yは５０００円札の枚数,s/1000は１０００円札の枚数
  for (int x = 0; x <= N; x++) {
    for (int y = 0; y <= N; y++) {
      int s = Y - 10000*x - 5000*y;
        if (s >= 0 && s % 1000 == 0 && x + y + s/1000 == N)  {
           f = true;t = true; 
          cout << x << " " << y << " " << s/1000 << endl;    
           break;
        }
      
      }
    if (t) break;
  }
if (f == false) cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lli;
typedef long double ldb;

#define endl '\n'
#define loop(i, m, n) for (lli i = m; i < n; i++)
#define loope(i, m, n) for (lli i = m; i <= n; i++)
#define ulta(i,m,n) for(lli i=m; i>=n; i--)
#define maxe *max_element
#define mine *min_element
#define plli pair<lli, lli>
#define mod 1000000007
#define mod2 998244353
#define vt vector<lli>
#define fi first
#define se second
#define pb push_back
#define umap unordered_map
#define mmap multimap
#define mp make_pair
#define pr2(a, b) cout << a << " " << b << '\n'
#define pr3(a, b, c) cout << a << " " << b << " " << c << '\n'
#define pr4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << '\n'
#define emp emplace
#define empf emplace_front
#define empb emplace_back
//especially for deque both sides dynamic
#define pf push_front
//list doubly linked lists can insert at mid. splice fn can be used
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;

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

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

ldb mini(ldb a, ldb b){
  if(a<b) return a;
  return b;
}

lli mpow(lli base, lli exp){
    base %= mod;
    lli result = 1;
    while (exp > 0)
    {
        if (exp & 1)
            result = ((lli)result * base) % mod;
        base = ((lli)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

lli is_prime(lli a){
    lli i;
    if (a == 2 || a == 3)
        return 1;
    else
        for (i = 2; i * i <= a; i++){
            if (a % i == 0)
                return 0;
        }
        return 1;
}

int main(){
    fast_io
    lli i=0,j=0;
    lli n;
    cin >> n;
    if(n==1){
      cout << 0;
    }
    else if((n)%2==0){
      cout << (n-2)/2;
    }
    else{
      cout << (n-1)/2;
    }
}


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define LOOP(i, N) for (int i = 1; i <= (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define RLOOP(i, N) for (int i =(int)N; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define pb push_back

typedef long long ll;

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
//cout<<"Yes"<<endl;
//cout<<"No"<<endl;

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

int main(){
  ll a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  if(a<b){
    LOOP(i,t){
      if(b-a<=i*(v-w)){
        cout<<"YES"<<endl;
        return 0;
      }
    }
    cout<<"NO"<<endl;
    return 0;
  }else{
    LOOP(i,t){
      if(b-a>=i*(w-v)){
        cout<<"YES"<<endl;
        return 0;
      }
    }
    cout<<"NO"<<endl;
    return 0;
  }
}

Measured memory_bytes: 3624
H, N = list(map(int, input().split()))
A = []
for i in range(N):
    a = list(map(int, input().split()))
    A.append(a)

INF = float('INF')
# MAX_J = (10 ** 4 + 1) * 2
MAX_J = 10 ** 4 + 1

# DP[i][j]: i番目までの魔法を使って、ダメージの総和をjにする魔力の最小値
DP = [INF] * MAX_J
DP[0] = 0

for i in range(N):
    for j in range(MAX_J):
        # nj: 求める添字
        # nj: i番目の魔法を使った後のダメージの総和（Hがmax）
        nj = min(j+A[i][0], H)
        # DP[nj]はすでに入っている値か、i番目の魔法を使った場合か
        DP[nj] = min(DP[nj], DP[j] + A[i][1])
    # print(i, DP)

print(DP[H])

Measured memory_bytes: 52572
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
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()
{
    ll N;
    cin >> N;
    vector<ll> a(N);
    ll sum = 0;
    rep(0, i, N)
    {
        cin >> a.at(i);
        sum += a.at(i);
    }

    vector<ll> subsum(N);
    subsum.at(0) = sum - a.at(0);
    rep(1, i, N)
    {
        subsum.at(i) = subsum.at(i - 1) - a.at(i);
    }

    ll ans = 0;
    rep(0, i, N)
    {
        ans += a.at(i) * (subsum.at(i) % MOD);
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6372
class UnionFindTree:
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x


def main():
    n, q = map(int, input().split())
    union_find = UnionFindTree(n)
    for _ in range(q):
        com, x, y = map(int, input().split())
        if com == 0:
            union_find.union(x, y)
        else:
            x_p = union_find.find(x)
            y_p = union_find.find(y)
            if x_p == y_p:
                print(1)
            else:
                print(0)


if __name__ == "__main__":
    main()



Measured memory_bytes: 5780
//#include "stdafx.h"
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main()
{
	int n;
	cin >> n; 

	int val=0;
	int X = 0;
	val = n;
	int counter=0;
	while (val >= pow(10,counter)) {
		X += (val / int(pow(10,counter++))) %10;
	}
	if (val % X == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

#define int long

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int n, m;
std::vector<int> edge[100005];
std::set<int> parent[100005];
int ans[100005];

void bfs(int rt){
	std::queue<int> que;
	que.push(rt);
	while(!que.empty()){
		int vis = que.front();
		que.pop();
		for(int i = 0; i < edge[vis].size(); i++){
			int next = edge[vis][i];
			if(parent[next].size() > 1){
				parent[next].erase(vis);
			}else{
				ans[next] = vis;
				que.push(next);
			}
		}
	}
	return;
}

signed main(){
	scanf("%ld %ld", &n, &m);
	for(int i = 0; i < n+m-1; i++){
		int a, b;
		scanf("%ld %ld", &a, &b);
		edge[a].push_back(b);
		parent[b].insert(a);
	}
	for(int i = 1; i <= n; i++){
		if(parent[i].size() == 0){
			bfs(i);
			break;
		}
	}
	for(int i = 1; i <= n; i++){
		printf("%ld\n", ans[i]);
	}
	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

ll n, ans = 0;

bool ck(ll num)
{
    string str;
    ll tmp = num;
    while (num)
    {
        str += num % 10 + '0';
        num /= 10;
    }
    int n3 = count(all(str), '3');
    int n5 = count(all(str), '5');
    int n7 = count(all(str), '7');
    return n3 > 0 and n5 > 0 and n7 > 0 and tmp <= n;
}

void dfs(ll x)
{
    if (ck(x))
        ans++;
    if (x <= 1000000000)
    {
        dfs(10 * x + 3);
        dfs(10 * x + 5);
        dfs(10 * x + 7);
    }
}

int main()
{
    cin >> n;
    dfs(0LL);

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3640
'use strict'

const main = (input) => {
    input = input.split('\n').map(v => v.split(' ').map(v => parseInt(v)))
    const w = input[0][0]
    const h = input[0][1]
    const n = input[0][2]
    const arr = input.slice(1, n + 1)

    let first = {
        x: 0,
        y: 0,
    }

    let last = {
        x: w,
        y: h,
    }

    arr.forEach(v => {
        if(v[2] === 1){
            if(first.x < v[0]){
                first.x = v[0]
            }
        }
        if(v[2] === 2){
            if(last.x > v[0]){
                last.x = v[0]
            }
        }
        if(v[2] === 3){
            if(first.y < v[1]){
                first.y = v[1]
            }
        }
        if(v[2] === 4){
            if(last.y > v[1]){
                last.y = v[1]
            }
        }
    })
    if(first.x < last.x && first.y < last.y){
        console.log((last.x - first.x) * (last.y - first.y))
    }else{
        console.log(0)
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))


Measured memory_bytes: 22204
function Main(input) {
	var str = input;
	var ans = 0;
	str = str.split("\n")[0];
	str = str.split(" ");
	var a = Number(str[0]);
	var b = Number(str[1]);
	var c = Number(str[2]);
	var k = Number(str[3]);
	ans = Number(ans);
	if (a <= k){
	ans = a;
	k = k - a;
	k = k - b;
		if(k > 0){
			ans = ans - k;
		}
   	}else{
   		ans = k;
   	}
	   console.log(ans);
}
 //*おまじない
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

#define MAX 10000

// LCM(a[i])-1は、すべてのiに対して mod a[i] が a[i] -1 となる。
int main(int argc, char* argv[]){
	int N;
	cin >> N;

	long long ans = 0;
	for(int i=1; i<=N; i++){
		long long a;
		cin >> a;
		ans += (a - 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

bool solve(int a[], int n, int index, int num)
{
	if (index == n)
	{
		return false;
	}
	if (a[index] == num)
	{
		return true;
	}
	if (solve(a, n, index + 1, num))
	{
		return true;
	}
	if (a[index] < num)
	{
		if (solve(a, n, index + 1, num - a[index]))
		{
			return true;
		}
	}
	return false;
}

int main()
{
	int a[20];
	int b[200];

	int n, q;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	scanf("%d", &q);
	for (int i = 0; i < q; i++)
	{
		scanf("%d", &b[i]);
	}

	for (int i = 0; i < q; i++)
	{
		if (solve(a, n, 0, b[i]))
		{
			printf("yes\n");
		}
		else
		{
			printf("no\n");
		}
	}
	
	return 0;
}


Measured memory_bytes: 3140
const main = (input) => {
  const args = input.trim().split("\n");
  const [x, n] = args[0]
    .trim()
    .split(" ")
    .map((n) => parseInt(n, 10));
 
  const excluded = (() => {
    if (n === 0) {
      return [];
    } else {
      return args[1]
        .trim()
        .split(" ")
        .map((n) => parseInt(n, 10));
    }
  })();
 
  const selection = [...Array(101 + 1).keys()].filter(
    (s) => !excluded.includes(s)
  );
 
  const abs = (n) => {
    if (n < 0) return -n;
    else {
      return n;
    }
  };
  const byAsc = (a, b) => a[1] - b[1];
  const minus = (a) => x - a; 
 
  const answer = selection
    .map((s) => [s, abs(minus(s))])
    .sort(byAsc)[0][0];
 
  console.log(answer);
};
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29668
#include <cstdio>
#include <algorithm>
#include <functional>


using namespace std;

int main() {
    int k, t;
    int a[100];

    scanf("%d%d",&k,&t);

    for(int i=0;i<t;i++) {
        scanf("%d",&a[i]);
    }

    sort(a,a+t,greater<int>());

    int s = 0;
    
    for(int i=1;i<t;i++) {
        s+=a[i];
    }
    
    printf("%d\n",max(0,a[0]-s-1));
    
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
  
  int n,k,i;
  scanf("%d",&n);
  
  char s[n];
  scanf("%s",&s);
  scanf("%d",&k);
  
  for(i=0;i<n;i++){
    if(s[i]!=s[k-1]){
      s[i] = '*';
    }
  }
  
  puts(s);
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
typedef long long int ll;
int main(){
	ll H, W;
	cin >> H >> W;
	if(H == 1 && W == 1) cout << H * W << endl;
	else if(H == 1) cout << H * (W - 2) << endl;
	else if(W == 1) cout << (H - 2) * W << endl;
	else cout << (H - 2) * (W - 2) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  string s;
  cin >> s;
  int i, ans=0, tmp=0;
  for(i=0; i<s.size(); i++){
    if(s[i] == 'A') tmp++;
    else if(s[i] == 'T') tmp++;
    else if(s[i] == 'G') tmp++;
    else if(s[i] == 'C') tmp++;
    else{
      if(ans < tmp) ans = tmp;
      tmp = 0;
    }
    if(i==s.size()-1 && ans < tmp) ans = tmp;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#coding:utf-8

          
  
def main():
    n = int(input())
    sumv = 0
    for i in range(1, n+1):
        if i % 3 != 0 and i % 5 != 0:
            sumv += i
        
    print(sumv)
        
  
if __name__ == '__main__':
    main()

Measured memory_bytes: 9168
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

def ume(x):
    x = str(x)
    if len(x) < 6:
        return '0'*(6-len(x)) + x
    return x

def main():
    N, M = mi()

    l = dp2(0, 3, M)
    cnt = [0]*(N+1)
    ans = dp2(0, 2, M)
    for i in range(M):
        p, y = mi()
        l[i][0], l[i][1], l[i][2] = p-1, y, i
        cnt[p] += 1
    for i in range(N):
        cnt[i+1] += cnt[i]

    l.sort(key=lambda x: x[0])
    for i in range(N):
        ichibu = l[cnt[i]:cnt[i+1]]
        ichibu.sort(key=lambda x: x[1])
        for j in range(cnt[i+1]-cnt[i]):
            ans[ichibu[j][2]][0] =ichibu[j][0]+1
            ans[ichibu[j][2]][1] =j+1
    
    for x, y in ans:
        print(ume(x)+ume(y))


if __name__ == "__main__":
    main()

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

using namespace std;

struct SegNode
{
  int v;

  SegNode(int v) : v(v) {}

  SegNode operator*(const SegNode &r) const
  {
    return (v < r.v ? *this : r);
  }
} e(1 << 30);

struct SegmentTree
{
  int sz;
  vector< SegNode > seg;

  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz - 1, e);
  }

  void update(int k, const SegNode &x)
  {
    k += sz - 1;
    seg[k] = x;
    while(k > 0) {
      k = (k - 1) >> 1;
      seg[k] = seg[2 * k + 1] * seg[2 * k + 2];
    }
  }

  SegNode query(int a, int b, int k, int l, int r)
  {
    if(a >= r || b <= l) return (e);
    if(a <= l && r <= b) return (seg[k]);
    return (query(a, b, 2 * k + 1, l, (l + r) >> 1) * query(a, b, 2 * k + 2, (l + r) >> 1, r));
  }

  SegNode query(int a, int b)
  {
    return (query(a, b, 0, 0, sz));
  }
};

int main()
{
  int N, Q, B[200000];
  vector< int > ev[200000];

  scanf("%d", &N);
  int add = 0;
  for(int i = 0; i < N; i++) {
    scanf("%d", &B[i]);
    if(B[i] == 0) ++add, B[i] = -1;
  }
  scanf("%d", &Q);
  for(int i = 0; i < Q; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    --l;
    ev[l].emplace_back(r);
  }

  SegmentTree tree(N);
  int dp[200001]; // 区間 [0, i) を考えた時の最小コスト
  fill_n(dp, 200001, 1 << 30);
  dp[0] = 0;
  for(int i = 0; i < N; i++) {
    for(auto &j : ev[i]) {
      int v = min(dp[j], min(dp[i], tree.query(i, j).v));
      tree.update(j, v);
      dp[j] = v;
    }
    dp[i + 1] = min(dp[i + 1], dp[i] + B[i]);
  }
  printf("%d\n", dp[N] + add);
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1000000007;
int main() {
    
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        string s;cin>>s;
        int f=0;
        int q;cin>>q;
        string fro,bac;
        while(q--){
            int t;cin>>t;
            if(t==1){
                f=(f+1)%2;
            }   
            else{
                int w;cin>>w;char c;cin>>c;
                if(w==1){
                    if(f==0){
                        fro.pb(c);
                    }
                    else{
                        bac.pb(c);
                    }
                }
                else{
                    if(f==1){
                        fro.pb(c);
                    }
                    else{
                        bac.pb(c);
                    }
                }
            }
        }
        string ans;
        if(f==0){
            reverse(all(fro));
            ans=fro+s+bac;
        }
        else{
            reverse(all(bac));
            reverse(all(s));
            ans=bac+s+fro;
        }
        cout<<ans;
    }   
    return 0;   
}   

Measured memory_bytes: 1300
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)


int main()
{
	int h, w;
	char a[101][101] = {};
	cin >> h >> w;
	FOR(i, 0, h) {
		FOR(j, 0, w) {
			cin >> a[i+1][j+1];
		}
	}
	FOR(i, 1, 2*h+1) {
		FOR(j, 1, w+1) {
			cout << a[(int)((i+1)/2)][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}

int main (){
    int n;
    ll sum=0;
    ll ans;
    cin >> n;
    vector<ll>rui(n);
    rep(i,n){
        ll a;
        cin >> a;
        sum+=a;
        if(i==0) rui[i]=a;
        else{
            rui[i]=rui[i-1]+a;
        }
    }
    rep(i,n-1){
        if(i==0) ans=abs(rui[i]-(sum-rui[i]));
        else ans=min(ans,abs(rui[i]-(sum-rui[i])));
    }
    cout << ans <<endl;
    return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int ans=0;
    for(int i=1;i<n;i++)
    {
        if(n%i==0)
        {
            ans+=n/i-1;
        }
        else
        {
            ans+=n/i;
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 3812
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<cctype>
#define INF 0x3f3f3f3f
#define inf 0x3f
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back

using namespace std;
typedef pair<int,int> pa;
inline ll read()
{
	long long f=1,sum=0;
	char c=getchar();
	while (!isdigit(c)) {if (c=='-') f=-1;c=getchar();}
	while (isdigit(c)) {sum=sum*10+c-'0';c=getchar();}
	return sum*f;
}
const int MAXN=100010;
const int MAXM=200010;
const int COLSET=1000010;
/*struct edge{
	int next,to;
}e[5000010];
int head[MAXN*10],cnt;
void addedge(int u,int v)
{
	e[++cnt].next=head[u];
	e[cnt].to=v;
	head[u]=cnt;
}*/
int fa[MAXN],rk[MAXN];
int find(int x)
{
	if (fa[x]!=x) fa[x]=find(fa[x]);
	return fa[x];
}
void uni(int x,int y)
{
	int f1=find(x),f2=find(y);
	if (f1==f2) return ;
	if (rk[x]<rk[y]) fa[f1]=f2;
	else if (rk[x]==rk[y]) fa[f1]=f2,rk[f2]++;
	else fa[f2]=f1;
}
vector <pa> col[COLSET];
bool visit[MAXN];
int id[MAXN];
bool vis[MAXN*10];
queue <int> q;
int dis[MAXN*10];
vector <int> g[MAXN*10];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		int u,v,opt;
		scanf("%d%d%d",&u,&v,&opt);
		col[opt].push_back(mp(u,v));
	}
	int tot=n+1;
	for (int i=1;i<COLSET;i++)
	{
		if (col[i].empty()) continue;
		for (int j=0;j<(int)col[i].size();j++)
		{
			pa now=col[i][j];
			fa[now.first]=now.first,fa[now.second]=now.second;
			rk[now.first]=rk[now.second]=0;
			id[now.first]=id[now.second]=0;
			visit[now.first]=visit[now.second]=0;
		}
		for (int j=0;j<(int)col[i].size();j++)
		{
			pa now=col[i][j];
			uni(now.first,now.second);
		}
		for (int j=0;j<(int)col[i].size();j++)
		{
			pa now=col[i][j];
			if (!visit[now.first])
			{
				visit[now.first]=1;
				int f=find(now.first);
				if (!id[f]) id[f]=tot++;
				//addedge(now.first,id[f]),addedge(id[f],now.first);
				g[id[f]].push_back(now.first);
				g[now.first].push_back(id[f]);
			}
			if (!visit[now.second])
			{
				visit[now.second]=1;
				int f=find(now.second);
				if (!id[f]) id[f]=tot++;
				//addedge(now.second,id[f]),addedge(id[f],now.second);
				g[id[f]].push_back(now.second);
				g[now.second].push_back(id[f]);
			}
		}
	}
	q.push(1);
	vis[1]=1;
	while (!q.empty())
	{
		int x=q.front();
		q.pop();
		//for (int i=head[x];i;i=e[i].next)
		for (int i=0;i<(int)g[x].size();i++)
		{
			//int v=e[i].to;
			int v=g[x][i];
			if (vis[v]) continue;
			vis[v]=1;
			q.push(v);
			dis[v]=dis[x]+1;
		}
	}
	if (!dis[n]) cout<<-1;
	else cout<<dis[n]/2;
	return 0;
}


Measured memory_bytes: 69248
#include <stdio.h>

int main (){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if (a==b && b==c){
    printf("No");
  }
  else if (a!=b && b!=c && c != a){
    printf("No");
  }
  else {
    printf("Yes");
  }
  return 0;
}

Measured memory_bytes: 128
n = int(input())
dic = {}
for i in range(n):
    string = input()
    if string not in dic:
        dic[string] = 1
    else:
        dic[string] += 1

Mx = max(dic.values())
ans = []
for key in dic.keys():    
    if dic[key] == Mx:
        ans.append(key)
ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 32096
#include <bits/stdc++.h>
#define chmax(x, v) x = max(x, v)
#define int long long
using namespace std;
signed main()
{
   int longueurAttendue, nbTuyaux;
   cin >> nbTuyaux >> longueurAttendue;
   int longueurTuyau[nbTuyaux], capaciteTuyau[nbTuyaux];
   
   for (int idTuyau =0; idTuyau < nbTuyaux; idTuyau++ )
      cin >> longueurTuyau[idTuyau] >> capaciteTuyau[idTuyau];
      
   int dynMax[longueurAttendue+1];
   for (int i=0;i<=longueurAttendue;++i)
      dynMax[i] = 0;
   for (int i =0;i<nbTuyaux;i++)
   {
      for (int j = longueurAttendue;j>=longueurTuyau[i];--j)
      {
         if ( dynMax[j-longueurTuyau[i]] != 0)
            dynMax[j] = max(dynMax[j], dynMax[j-longueurTuyau[i]] + capaciteTuyau[i]);
         else if ( j==longueurTuyau[i])
            dynMax[j] = max(dynMax[j], capaciteTuyau[i]);
      }
   }
   int m = 0;
   for (int i=0;i<=longueurAttendue;++i)chmax(m, dynMax[i]);
   cout << m << endl;
}

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

#define int long long
#define fr(i,n) for(int i=0;i<n;i++)
#define frr(i,n) for(int i=n;i>=0;i--)
#define fra(i,a,n) for(int i=a;i<n;i++)
#define frra(i,a,n) for(int i=a;i>=n;i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define ff first
#define ss second
#define endl '\n'

typedef pair<int,int> ii;
typedef map<int,int> mii;
typedef set<int> si;
typedef unordered_map<int,int> uii;
typedef unordered_set<int> usi;
typedef vector<int> vi;
typedef vector<ii> vii;

const int mod = 1e9+7;
const int inf = 1e9;
const int MAXN = 2e5+5;
const double eps = 1e-6;

void solve(){
    //CODE BEGINS
    int n,k;
    cin>>n>>k;
    vector<vi>dp(n,vi(k));
    int d;
    fr(i,k){
		cin>>d;
		fr(j,d){
			int x;
			cin>>x;
			dp[x-1][i]=1;
		}
	}
	int cnt = 0;
	fr(i,n){
		bool ok = false;
		fr(j,k){
			if(dp[i][j]){
				ok = true;
				break;
			}
		}
		if(!ok)cnt++;
	}
	cout<<cnt<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //~ cin>>t;
    while(t--)solve();
    return 0;
}


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

#define mst(a, b) memset(a, b, sizeof(a))
#define clr(a) mst(a, 0)
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define lowbit(x) (x&(-x))
#define fi first
#define se second
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define per(i, a, b) for(int i = a; i >= b; i--)

#define pr(x) cout << #x << " = " << x << endl;

using namespace std;

const int mod = 1e9 + 7;
const int N = 1e5 + 5;

typedef long long ll;
typedef vector<int> V;
typedef pair<int, int> P;
int d[N + 100];
int main() {
	//freopen("a.in", "r", stdin);
	//freopen("a.out", "w", stdout);
	int n;
	cin >> n;
	rep(i, 1, n) {
		int x;
		cin >> x;
		x += 3;
		d[x - 1]++;
		d[x + 2]--;
	}
	int ans = 0, ret = 0;
	rep(i, 0, N + 20) {
		ret += d[i];
		ans = max(ret, ans);
	}
	cout << ans;
}



Measured memory_bytes: 640
#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>;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> f(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    f.at(a).push_back(b);
    f.at(b).push_back(a);
  }

  vector<bool> checked(n, false);
  // 全部の点からはじまるグループの人数を求める
  deque<int> q;
  int ans = 0;
  rep(i, n) {
    if (checked.at(i)) continue;
    q.push_back(i);
    checked.at(i) = true;
    int tmp = 1;
    while (!q.empty()) {
      int x = q.front();
      q.pop_front();
      for (auto u : f.at(x)) {
        if (checked.at(u)) continue;
        q.push_back(u);
        checked.at(u) = true;
        tmp++;
      }
    }
    ans = max(ans, tmp);
  }

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

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

using namespace std;


int main(){
  
   int n,hp;
  cin>>n>>hp;
  int a[n];
  int b[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    cin>>b[i];}
  sort(a,a+n,greater<int>());
  sort(b,b+n,greater<int>());

      
       int abig=0;
       bool owari=true;
       if(a[0]>=b[0]){
         cout<<(hp+a[0]-1)/a[0]<<endl;}
       else {
       while(a[0]<b[abig]) abig++;
        
         
    
         for(int k=0;k<abig;k++){
           hp-=b[k];
             if(hp<=0) {cout<<k+1<<endl;
           owari=false;
           break;}
         }
         
         if(owari){
           cout<<abig+(hp+a[0]-1)/a[0]<<endl;}
         
       }
 
 
}


Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long n,m;
  	cin>>n>>m;
  	if(n==2||m==2){cout<<"0"<<endl;return 0;}
	cout<<max((long)1,n-2)*max((long)1,m-2)<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>

typedef long long ll;
using namespace std;
const ll x=1000000007;
int mod(ll a){
	return a%x;
}
int main(){
	ll x;
	cin>>x;
	ll y=((x%100)+4)/5;
	x/=100;
	if(x>=y){
		cout<<1;
	}
	else{
		cout<<0;
	}
	
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

int main() {
source:
    int a[3][3];
    bool judge[3][3];
    rep(i, 3) {
        rep(j, 3) {
            cin >> a[i][j];
            judge[i][j] = false;
        }
    }

    int n;
    cin >> n;
    rep(i, n) {
        int b;
        cin >> b;
        rep(l0, 3) {
            rep(l1, 3) {
                if (b == a[l0][l1]) {
                    judge[l0][l1] = true;
                }
            }
        }
    }

    bool ans = false;

    rep(i, 3) {
        bool line = true;
        rep(j, 3) {
            if (!judge[i][j]) {
                line = false;
            }
        }
        if (line) {
            ans = true;
        }
    }
    rep(i, 3) {
        bool line = true;
        rep(j, 3) {
            if (!judge[j][i]) {
                line = false;
            }
        }
        if (line) {
            ans = true;
        }
    }

    if (judge[0][0] && judge[1][1] && judge[2][2]) {
        ans = true;
    }
    if (judge[0][2] && judge[1][1] && judge[2][0]) {
        ans = true;
    }

    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

ll combi(ll x, ll y) {
    ll num = 1;
    for (int i = 1; i <= y; i++) {
        num = num * (x - i + 1) / i;
    }
    return num;
}

ll dp[20][20];

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    ll ans = 0;
    for (int i = 0; i < (1 << N); i++) {
        int a = 0;
        int b = 0;
        string ast = "";
        string bst = "";
        for (int j = 0; j < N; j++) {
            if (i & (1 << j)) {
                a++;
                ast = S[j] + ast;
            } else {
                b++;
                bst = S[j] + bst;
            }
        }
        // cout << ast << " " << bst << endl;
        for (int j = 0; j <= N; j++) {
            fill(dp[j], dp[j] + N + 1, 0);
        }
        dp[0][0] = 1;
        for (int j = 1; j <= N; j++) {
            char c = S[N - 1 + j];
            for (int k = 0; k < a; k++) {
                if (ast[k] == c) {
                    dp[j][k + 1] += dp[j - 1][k];
                }
            }
            for (int k = 0; k < b; k++) {
                if (bst[k] == c && j - k - 1 >= 0) {
                    dp[j][j - k - 1] += dp[j - 1][j - k - 1];
                }
            }
        }
        ans += dp[a + b][a];
        // for (int j = 0; j <= N; j++) {
        //     for (int k = 0; k <= N; k++) {
        //         cout << dp[j][k] << " ";
        //     }
        //     cout << endl;
        // }
        // cout << dp[a + b][a];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int D;
  cin >> D;
  vector<int64_t> C(26);
  rep(i, 26) { cin >> C[i]; }

  vector<vector<int64_t>> S(D, vector<int64_t>(26));
  rep(i, D) {
    rep(j, 26) {
      int s;
      cin >> s;
      S[i][j] = s;
    }
  }

  vector<int> T(D);
  vector<int> Last(26, 0);
  rep(i, D) {
    vector<int64_t> score(26);
    int64_t max_score = 0;
    int max_idx;
    rep(j, 26) {
      score[j] = S[i][j] + C[j] * (i + 1 - Last[j]);
      if (max_score < score[j]) {
        max_score = score[j];
        max_idx = j;
      }
    }
    T[i] = max_idx + 1;
  }

  rep(i, D) { cout << T[i] << endl; }
  return 0;
}


Measured memory_bytes: 3748
object Main extends App {
  val nm =  scala.io.StdIn.readLine()
  val nmArray = nm.split(" ").map(_.toInt).toSeq
  val n = nmArray(0)
  val m = nmArray(1)
  val aInput =  scala.io.StdIn.readLine()
  val aVecotor = aInput.split(" ").map(_.toInt).toVector

  val sabun = n - aVecotor.sum

  if (sabun >= 0) println(sabun) else println(-1)

}

Measured memory_bytes: 54940
use v5.18;
use warnings;

chomp (my $n = <STDIN>);
chomp (my $s = <STDIN>);
my @s = split '', $s;
map {$s[$_] = chr((ord($s[$_]) + $n) % ord("A") % 26 + ord("A"))} (0..@s-1);
say join('', @s);

Measured memory_bytes: 2176