akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000],arr1[1000000];
int main()
{
	long long n,i,j,ans,k;
	ans=0;
	cin>>n;
	for (i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	for (i=0;i<n;i++)
	{
		cin>>arr1[i];
	}
	for (i=0;i<n;i++)
	{
		if (arr[i]<arr1[i])
		{
			ans+=(arr1[i]-arr[i])/2;
		}
		else
		{
			ans-=(arr[i]-arr1[i]);
		}
		//cout<<ans<<endl;
	}
	if (ans>=0)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 2432
#include<iostream>
using namespace std;
int a,b,c,d,e,f;
main()
{
	while(cin>>a>>b>>c>>d>>e>>f,f)
	{
		int now=(-f+e)*3+c*7+d*2+(a*5+b*3)*16+a*15+b*15;
		cout<<now+100<<endl;
	}
}



Measured memory_bytes: 3072
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        l: i64,
        r: i64,
    }
    let rmin = std::cmp::min(l + 2019 + 1, r + 1);

    let mut min_mod = 2019;
    for i in l..rmin {
        for j in i + 1..rmin {
            let m = (i * j) % 2019;
            min_mod = std::cmp::min(m, min_mod);
        }
    }
    println!("{}", min_mod);
}


Measured memory_bytes: 4352
N, M = map(int, input().split())
A = []
B = []
for i in range(N):
    A.append(list(input()))
for j in range(M):
    B.append(list(input()))
import copy
CA = copy.deepcopy(B)
ans = -1
for i in range(N - M + 1):
    for l in range(N - M + 1):
        for j in range(M):
            for k in range(M):
                CA[j][k] = A[i + j][l + k]
        if CA == B:
            print("Yes")
            ans = 1
            break
    if ans == 1:
        break
if ans == -1:
    print("No")

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
// #pragma GCC optimize ("-O3")
// using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
// typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
// 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; }
 
using namespace std;
 
int main()
{
  long long A;
  long double B;
  cin>>A>>B;
  
  cout<<(long long)(A*B)<<endl;
  
  return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    ll n,m;
    cin>>n>>m;
    vector<vector<pii>>v(n+1);
    rep(i,0,m){
        int p,y;
        cin>>p>>y;
        v[p].push_back(make_pair(y,i));
    }
    vector<pii> ans(m);
    rep(i,0,n+1){
        sort(all(v[i]));
        rep(j,0,v.at(i).size()){
            ans.at(v.at(i).at(j).second)={i,j+1};
        }
    }
    rep(i,0,m){
        printf("%06d%06d\n",ans.at(i).first,ans.at(i).second);
    }
return 0;
}

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

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

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







int main() 
{
    
    int p[3];
    scanf("%d%d%d", &p[0], &p[1], &p[2]);
    int ans = 1e9;
    sort(p, p + 3);
    ans = p[0] + p[1];
    printf("%d\n", ans);

}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    string s;
    cin >> s;
    if(s[5] <= '0' && s[6] <= '4') cout << "Heisei";
    else cout << "TBD";
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;
vector< int > dijkstra(graph &G, int s) {
	///stat must have "<"&">"
	///init d=vector<stat>
	vector< int > d(G.size(), LINF);
	d[s] = 0;
	//init q=p-queue<pair<stat,index> >
	priority_queue< pii, vector< pii >, greater< pii > > q;
	q.push(pii(0, s));

	while (!q.empty()) {
		pii p = q.top();
		q.pop();
		if (d[p.second] < p.first)
			continue;
		for (int i = 0; i < G[p.second].size(); i++) {
			edge e = G[p.second][i];
			if (p.first + e.d < d[e.to]) {
				d[e.to] = p.first + e.d;
				q.push(pii(d[e.to], e.to));
			}
		}
	}
	return d;
}
int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> M;
	vector< vector< edge > > G(3 * N);
	rep(i, M) {
		int u, v;
		cin >> u >> v;
		--u;
		--v;
		G[u].emplace_back(u, v + N, 1);
		G[u + N].emplace_back(u, v + 2 * N, 1);
		G[u + 2 * N].emplace_back(u, v, 1);
	}
	int s, t;
	cin >> s >> t;
	--s;
	--t;
	vector< int > d = dijkstra(G, s);
	if (d[t] == LINF) {
		cout << -1 << endl;
	} else {
		cout << d[t] / 3 << endl;
	}

	return 0;
}

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

lint a, b, c, d;

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

bool contain_x() {
    return (a <= 0 && b >= 0) || (c <= 0 && d >= 0);
}

int main() {
    cin >> a >> b >> c >> d;
    lint ans = LLONG_MIN;
    chmax(ans, a * c);
    chmax(ans, a * d);
    chmax(ans, b * c);
    chmax(ans, b * d);
    if (contain_x()) {
        chmax(ans, 0LL);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
# ABC138D - Ki
from collections import deque
 
 
def dfs() -> None:
    # pop, appendまたはQueueライブラリだと間に合わない
    queue = deque([[0,1]])
    while queue:
        parent, node = queue.popleft()
        for leaf in T[node]:
            if leaf == parent:
                continue
            counter[leaf] += counter[node]
            queue.append([node, leaf])
 
 
def main():
    # Ai (A[i][0]) may be not a parent of Bi (A[i][1])
    global T, counter
    N, Q, *A = map(int, open(0).read().split())
    E, P = A[: (N - 1) * 2], A[(N - 1) * 2 :]
    T = [[] for _ in range(N + 1)]
    for v, u in zip(*[iter(E)] * 2):
        T[v].append(u), T[u].append(v)
    counter = [0] * (N + 1)
    for p, x in zip(*[iter(P)] * 2):
        counter[p] += x  # increase vertex p by x
    dfs()
    print(*counter[1:])
 
 
if __name__ == "__main__":
    main()


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

using namespace std;
#define int long long

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (c - a - b < 0) {
		cout << "No" << endl;
	}
	else if (4 * a * b < (c - a - b) * (c - a - b)) {
		cout << "Yes " << endl;
	}
	else {
		cout << "No " << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define mkp make_pair
#define pii pair<int,int>
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=2e5+200;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>

using namespace std;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> f(n + 1);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        f[a].push_back(b);
        f[b].push_back(a);
    }
    vector<int> g(n + 1, -1);
    int id = 0;
    for (int i = 1; i <= n; i++) {
        if (g[i] != -1) continue;
        stack<int> s;
        s.push(i);
        while (!s.empty()) {
            int t = s.top();
            s.pop();
            for (int j : f[t]) {
                if (g[j] != -1) continue;
                g[j] = id;
                s.push(j);
            }
        }
        id += 1;
    }
    vector<int> ans(id);
    for (int i : g) {
        if (i < 0) continue;
        ans[i] += 1;
    }
    int mx = 1;
    for (int i : ans) {
        mx = max(mx, i);
    }
    cout << mx << endl;
}


Measured memory_bytes: 15584
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
#define x first
#define y second

using pt = pair<int, int>;

int n, inside;
pt a[55];

void solve(){
    cin >> n >> inside;
    for(int i = 0; i < n; ++i) cin >> a[i].x >> a[i].y;
    
    ll ans = LLONG_MAX;
    for(int i = 0; i < n; ++i){
        for(int j = i+1; j < n; ++j){
             for(int k = 0; k < n; ++k){
                for(int l = k+1; l < n; ++l){
                    int mix = min(a[i].x, a[j].x), mxx = max(a[i].x, a[j].x);
                    int miy = min(a[k].y, a[l].y), mxy = max(a[k].y, a[l].y);
                    int cnt = 0;
                    for(int m = 0; m < n; ++m){  
                        if(a[m].x >= mix && a[m].x <= mxx && a[m].y >= miy && a[m].y <= mxy){
                            cnt++;
                        }
                    }

                    if(cnt >= inside){
                        ll area = (ll)(mxx-mix) * (mxy-miy);
                        ans = min(ans, area);
                    }
                }
            }
        }
    }

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3660
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int main() {
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  if(a<=b*c)cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}

Measured memory_bytes: 3620
from operator import itemgetter

def main():
    N,M = map(int,input().split())
    PY = [list(map(int,input().split())) + [index] for index  in range(M)]
    PY.sort(key = itemgetter(1))
    PY.sort(key = itemgetter(0))
    Ans = [""]*M
    Ken = [0]*(N + 1)
    for i  in range(M):
        p,y,index = PY[i]
        Ken[p] += 1
        Ans[index] = str(p).zfill(6) + str(Ken[p]).zfill(6)
    print(*Ans,sep="\n")
    return 

if __name__ == "__main__":
    main()

Measured memory_bytes: 34084
from collections import deque
N = int(input())
S = input()
d = deque()
cnt = 0
for x in S:
    if x == '(':
        d.append(1)
    elif x == ')' and d:
        d.pop()
    else:
        cnt += 1
print('(' * cnt + S + ')' * len(d))

Measured memory_bytes: 3316
#include <iostream>
using namespace std;
int shuu(int x, int y);
int menseki(int x, int y);
int main()
{
  int a,b;
  cin >> a >> b;
  cout << menseki(a, b) << " "<< shuu(a, b) << endl;
  return 0;
}

int shuu(int x, int y)
{
  return (x+y)*2;
}

int menseki(int x, int y)
{
  return x*y;
}

Measured memory_bytes: 1164
from sys import stdin

readline = stdin.readline


def read():
    return tuple(map(int, readline().split()))


def main():
    readline()
    A = read()
    B = read()
    pre = A[0]
    ans = 0
    for a, b in zip(A[1:], B):
        tmp1 = pre if pre < b else b
        b -= tmp1
        tmp2 = a if a < b else b
        ans += tmp1 + tmp2
        pre = a - tmp2
    print(ans)
    return


main()


Measured memory_bytes: 19376
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    if(n==1&&a!=b) cout<<0<<endl;
    else{
        cout<<max((n-1)*(b-a)+a-b+1,0LL)<<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 < (n); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)


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

    int ans = 0;
    rep2(i,1,n+1){
        int l;
        l = to_string(i).length();
        if(l%2==1) ++ans;
    }

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


Measured memory_bytes: 256
#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node {int parent, left, right; };

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
	if( u == NIL)
		return;
	D[u] = d;
	setDepth(T[u].left, d + 1);
	setDepth(T[u].right, d + 1);
}

int setHeight(int u){
	int h1 = 0, h2 = 0;
	if( T[u].left != NIL)
		h1 = setHeight(T[u].left) + 1;
	if( T[u].right != NIL)
		h2 = setHeight(T[u].right) + 1;
	return H[u] = (h1 > h2 ? h1: h2);
}

int getSibling(int u){
	if( T[u].parent == NIL)
		return NIL;
	if( T[T[u].parent].left != u && T[T[u].parent].left != NIL)
		return T[T[u].parent].left;
	if( T[T[u].parent].right != u && T[T[u].parent].right != NIL)
		return T[T[u].parent].right;
	return NIL;
}

void print(int u){
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].parent);
	printf("sibling = %d, ", getSibling(u));
	int deg = 0;
	if( T[u].left != NIL) deg++;
	if( T[u].right != NIL) deg++;
	printf("degree = %d, ", deg);
	printf("depth = %d, ", D[u]);
	printf("height = %d, ", H[u]);

	if( T[u].parent == NIL){
		printf("root\n");
	} else if (T[u].left == NIL && T[u].right == NIL){
		printf("leaf\n");
	} else {
		printf("internal node\n");
	}
}

int main (){
	int v, l, r, root = 0;
	scanf("%d", &n);
    
    for(int i = 0; i < n; i++) T[i].parent = NIL;

	for(int i = 0; i <  n; i++){
		scanf("%d %d %d", &v, &l, &r);
		T[v].left = l;
		T[v].right = r;
		if( l != NIL ) T[l].parent = v;
		if( r != NIL ) T[r].parent = v;
	}

	for(int i = 0; i < n; i++){
		if(T[i].parent == NIL )
			root = i;
	}
	setDepth(root, 0);
	setHeight(root);

	for(int i = 0; i < n; i++)
		print(i);

	return 0;
}

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

int main() {
  ll a,b,r,i,ans=1;
  bool flag;
  
  scanf("%lld%lld",&a,&b);
  while(a%b!=0){
    r = a%b;
    a = b;
    b = r;
  }
  
  for(i=2;i*i<=b;i++){
    flag = false;
    while(b%i==0){
      flag = true;
      b /= i;
    }
    if(flag)ans++;
  }
  if(b!=1)ans++;
  
  printf("%lld\n",ans);
  
  return 0;
}

Measured memory_bytes: 256
#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, A, B;
  cin >> N >> A >> B;

  if(N*A < B) cout << N*A << endl;
  else cout << B << endl;
}


Measured memory_bytes: 256
const main = (input) => {
  var p = input.trim().split("\n");
  var ans = 0;
  var min = 10;
  for(var i=0;i<5;i++){
    if(p[i]%10 >0){
      ans += Number(p[i])+(10-p[i]%10);
      min = Math.min(min, p[i]%10);
    }else{
      ans += Math.floor(p[i]);
    }
  }
  console.log(min==10?ans:ans+min-10);
}

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


Measured memory_bytes: 7372
import java.util.*;
public class Main{
  public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    if((int)((n+1)/2)>=k){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }

	}
}

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

void Main() {
    int n, m;
    cin >> n;
    int t[100], p[100], x[100];

    int t_sum = 0;
    rep(i, 0, n) {
        cin >> t[i];
        t_sum += t[i];
    }

    cin >> m;
    rep(i, 0, m) { cin >> p[i] >> x[i]; }
    rep(i, 0, m) { cout << t_sum - t[p[i] - 1] + x[i] << endl; }
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15) << endl;
    Main();
    return 0;
}

Measured memory_bytes: 256
<?php
list($N) = ints();
$G = loadTree();
dfs(1, -1, 0);
$d1 = $distance;
dfs($N, -1, 0);
$d2 = $distance;
$fennec = 0;
for($i = 1; $i <= $N; $i++)$fennec+=$d1[$i]<=$d2[$i];
echo $fennec > $N/2 ? "Fennec" : "Snuke";

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function str(){return trim(fgets(STDIN));}
function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}



function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$M = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


Measured memory_bytes: 84472
n = int(input())
A = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
    V = [int(i) for i in input().split()]
    for j in V[2:]:
        A[i][j-1] = 1
for i in A:
    tmp =""
    for j in i:
        tmp+=str(j) + " "
    print(tmp[:-1])


Measured memory_bytes: 5676
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int x;
  cin >> x;
  x < 1200 ? cout << "ABC" << endl : cout << "ARC" << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    public static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int ab = s[0]*s[1];
        for (int i = 1; i <= 3; i ++) {
            if (ab*i%2 == 1) {
                Console.WriteLine("Yes");
                return;
            }
        }
        Console.WriteLine("No");
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

int expr(string &str, int &itr);
int number(string &str, int &itr);

int main() {
    int N;
    int start;
    string str;
    cin >> N;

    for(int i=0; i< N; i++){
        cin >> str;
        start=0;
        cout << expr(str, start) << endl;
    }
    return 0;
}

int expr(string &str, int &itr){
    int ans=0;
    vector<int> vect(0);
    for(;str[itr]=='[';){
        itr++;
        if(isdigit(str[itr])){
            vect.push_back((int)ceil(number(str,itr)/2.0));
        }else{
            vect.push_back(expr(str, itr));
        }
        if(str[itr]==']') itr++;
    }
    sort(vect.begin(), vect.end());
    for(int i=0 ; i< vect.size()/2 + 1; i++){
        ans+=vect[i];
    }
    return ans;
}

int number(string &str, int &itr){
    int num = 0;
    for(;isdigit(str[itr]);itr++) {
        num = num*10 + ( str[itr] -'0' );
    }
    return num;
}



Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
string s; 
int main(){
	cin>>s;
	
	if(s[2]==s[3] && s[4]==s[5])
		cout<<"Yes";
	else
		cout<<"No";
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int n;
 string s;
 int res =0;
 cin>>n>>s;
 
 for (int i=0;i<n-2 ;i++){
   if(s.at(i) == 'A' && s.at(i+1) =='B' && s.at(i+2)=='C'){
     res++;
   }
 }

 cout<<res<<endl;
 
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] arg){
		Scanner in = new Scanner(System.in);
		char[]  score = {'A','B','C','D','F'};
		while(true){
			int m = Integer.parseInt(in.next());
			int f = Integer.parseInt(in.next());
			int r = Integer.parseInt(in.next());
			if(m==-1 && f==-1 && r==-1)
				break;
			else if(m==-1 || f==-1)
				System.out.println(score[4]);
			else if(m+f >= 80)
				System.out.println(score[0]);
			else if(m+f <80 && m+f>=65)
				System.out.println(score[1]);
			else if(m+f <65 && m+f>=50)
				System.out.println(score[2]);
			else if(m+f <50 && m+f>=30){
				if(r >=50) System.out.println(score[2]);
				else System.out.println(score[3]);
			}
			else if(m+f<30)
				System.out.println(score[4]);	
		}
	}	
}

Measured memory_bytes: 17328
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
T = LI()
A = LI()

if T[0] > A[0]:
    print(0)
    exit()

if T[N-1] < A[N-1]:
    print(0)
    exit()

ans = 1
for i in range(1,N-1):
    if T[i-1] != T[i]:
        if A[i] < T[i]:
            print(0)
            exit()
        else:
            continue
    else:
        if A[i+1] != A[i]:
            if T[i] < A[i]:
                print(0)
                exit()
            else:
                continue
        else:
            ans *= min(A[i],T[i])
            ans %= mod

print(ans)

Measured memory_bytes: 76328
import java.io.*;
import java.util.StringTokenizer;

class Main {
    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() { // reads in the next string
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        } // reads in the next int

        public long nextLong() {
            return Long.parseLong(next());
        } // reads in the next long

        public double nextDouble() {
            return Double.parseDouble(next());
        } // reads in the next double
    }

    static InputReader r = new InputReader(System.in);
    static PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        int number_of_rolls = r.nextInt();
        int num1 = 0, num2 = 0, plays = 0, inArow = 0, repeated = 0, notRepeating = 0;
        boolean good = false;
        while (plays < number_of_rolls) {
            num1 = r.nextInt();
            num2 = r.nextInt();
            if (num1 == num2) {
                repeated++;
            } else {
                repeated = 0;
            }
            if (repeated == 3) {
                good = true;
            }
            plays++;
        }
        if (good) {
            pw.println("Yes");
        } else {
            pw.println("No");
        }

        pw.close(); // flushes the output once printing is done
    }
}


Measured memory_bytes: 32880
#include<set>
#include<iostream>
int n;
std::set<int> s;
int main()
{
	scanf("%d",&n);
	for(int i=1,j;i<=n;i++)
	{
		scanf("%d",&j);
		if(s.count(j))
		{
			puts("NO");
			return 0;
		}
		s.insert(j);
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <vector>

using namespace std;


int main(){
    int N;
    cin>>N;
    vector<int> H(N,0);
    int idx = 0;
    for(int i=0; i<N; i++){
        cin>>H[i];
    }
    for(int i=1; i<N; i++){
        if(H[i-1]<H[i]){
            idx=i;
            continue;
        }

        if(H[i-1]>H[i]){
            for(int j=idx; j<i; j++)
                H[j]--;
            idx=i;
        }
    }

    for(int i=1; i<N; i++){
        if(H[i-1]>H[i]){
            cout << "No" <<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;
    return 0;
}


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

int main() {
  int N;
  int X;
  int count = 0;
  cin >> N;
  cin >> X;
  vector <int> L(N+1);
  vector <int> sumL(N+1);
  for (int i = 1; i < N + 1; i++)
  {
    cin >> L.at(i);
  }
  for(int j = 0; j < N+1; j++)
  {
    for (int i = 0; i < j+1; i++)
      {
        sumL.at(j) += L.at(i); 
      }
  }
  for (int i = 0; i < N+1; i++)
  {
    if(sumL.at(i) <= X)
      count++;
  }
  cout << count << endl;
  
}


Measured memory_bytes: 256
/*input
3
(((
)
)
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const int maxn=1e6+5;
const int maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
string s[maxn];
int cnt[maxn];
bool cmp(pair<int,string> &a,pair<int,string> &b){
    int cr=sz(a.s)-a.f,br=sz(b.s)-b.f;
    return (a.f-cr)<(b.f-br);
}
bool cmp2(string &a,string &b){
    return sz(a)>sz(b);
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
    cin>>n;
    REP(i,n){
        cnt[i]=0;
        string tmp;
        cin>>tmp;
        vector<char> st;
        REP(j,sz(tmp)){
            if(!sz(st) or !(st.back()=='(' and tmp[j]==')')){
                st.pb(tmp[j]);
            }
            else{
                st.pop_back();
            }
        }
        s[i]="";
        REP(j,sz(st)){
            if(st[j]==')') cnt[i]++;
            s[i]+=st[j];
        }
    }
    string ans="";
    REP(i,n){
        if(sz(s[i]) and s[i][0]=='('){
            ans+=s[i];
        }
    }
    vector<pair<int,string>> v;
    REP(i,n){
        if(sz(s[i]) and s[i][0]==')' and s[i].back()=='('){
            v.pb({cnt[i],s[i]});
        }        
    }
    sort(ALL(v),cmp);
    REP(i,sz(v)){
        ans+=v[i].s;
    }
    REP(i,n){
        if(sz(s[i]) and s[i][0]==')' and s[i].back()!='('){
            ans+=s[i];
        }        
    }
    stack<char> st;
    REP(j,sz(ans)){
        if(!sz(st) or !(st.top()=='(' and ans[j]==')')){
            st.push(ans[j]);
        }
        else{
            st.pop();
        }
    }  
    if(sz(st)) cout<<"No";
    else cout<<"Yes";  
}


Measured memory_bytes: 46248
from math import sqrt, ceil

a, b = map(int, input().split())

c_a = set()
c_b = set()

for i in range(1, ceil(sqrt(a))+1):
  if a % i == 0:
    c_a.add(i)
    if i > 1:
        while a % i == 0:
            a = a // i
if a != 1:
    c_a.add(a)

for j in range(1, ceil(sqrt(b))+1):
  if b % j == 0:
    c_b.add(j)
    if j > 1:
        while b % j == 0:
            b = b // j
if b != 1:
    c_b.add(b)

ans = c_a.intersection(c_b)

print(len(ans))


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  int n,l[200],a;
  cin>>n;
  for(int i=0;i<2*n;cin>>l[i],i++);
  sort(l,l+2*n);
  for(int i=2*(n-1);i>=0;a+=l[i],i-=2);
  cout<<a;
  return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $n);
$S = array_map('intval', explode(' ', trim(fgets(STDIN))));
fscanf(STDIN, "%d", $q);
$T = array_map('intval', explode(' ', trim(fgets(STDIN))));

$cnt = 0;
for ($i = 0; $i < $q; ++$i) {

    $l = 0;
    $r = $n;
    $flg = false;
    while ($r - $l >= 1) {
        $mid = floor(($l + $r) / 2);

        if ($S[$mid] === $T[$i]) {
            $flg = true;
            break;
        } else if ($T[$i] < $S[$mid]) {
            $r = $mid;
        } else {
            $l = $mid + 1;
        }
    }
    $cnt += $flg ? 1 : 0;
}

echo $cnt, PHP_EOL;



Measured memory_bytes: 40888
#include <iostream>
#include <string>
 
using namespace std;
 
class Dice{
private:
  int D1;
  int D2;
  int D3;
  int D4;
  int D5;
  int D6;
 
public:
  Dice(int d1,int d2,int d3,int d4,int d5,int d6){
  D1=d1;
  D2=d2;
  D2=d2;
  D3=d3;
  D4=d4;
  D5=d5;
  D6=d6;
  }
 
  void roll(char dire){
  int dd1=D1;
  int dd2=D2;
  int dd3=D3;
  int dd4=D4;
  int dd5=D5;
  int dd6=D6;
   
  if(dire=='E')
    {
    D1=dd4;
    D3=dd1;
    D4=dd6;
    D6=dd3;
    }
  if(dire=='N')
  {
    D1=dd2;
    D2=dd6;
    D5=dd1;
    D6=dd5;
  }
  if(dire=='S')
  {
    D1=dd5;
    D5=dd6;
    D6=dd2;
    D2=dd1;
  }
  if(dire=='W')
  {
    D1=dd3;
    D3=dd6;
    D6=dd4;
    D4=dd1;
  }
   
  }
   
  int ue(){
  return D1;
  }
   
  int light(int up,int mae){
    int i;
    int j;
    int k;
      for(i=0;i<4;i++)
      {
      roll('E');
     for(j=0;j<4;j++)
     {
      roll('S');
     for(k=0;k<4;k++)
     {
        roll('E');
         
        if(up==D1 && mae==D2)
          return D3;
     }
     }
    }
  }
   
   
};
 
int main()
{
  int di[6]={};
  int i;
  int q;
  int up;
  int mae;
   
  for(i=0;i<6;i++)
    cin >> di[i];
     
  Dice dice1(di[0],di[1],di[2],di[3],di[4],di[5]);
   
  cin >> q;
   
  for(i=0;i<q;i++)
  {
    cin >> up >> mae;
    cout << dice1.light(up,mae) <<"\n";
  }
}

Measured memory_bytes: 3084
S=input()
N=len(S)
sen10=0
sen01=0
if N==1:
    print(0)
else:
    for i in range(N):
        if i%2==0:
            if S[i]=='0':
                sen10 +=1
            else:
                sen01 +=1
        else:
            if S[i]=='1':
                sen10 +=1
            else:
                sen01 +=1
    print(min(sen01,sen10))

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

using namespace std;

const int MAXN = 112345;

int N, a[MAXN], b[MAXN], c[MAXN], dp[MAXN][4];

int main () {

	ios_base::sync_with_stdio(false); cin.tie(NULL);


	////
	cin >> N;
	for (int i = 1; i <= N; ++i) 
		cin >> a[i] >> b[i] >> c[i];

	///

	dp[1][0] = a[1];
	dp[1][1] = b[1];
	dp[1][2] = c[1];

	for (int i = 2; i <= N; ++i) {

		dp[i][0] = a[i] + max (dp[i-1][1], dp[i-1][2]);
		dp[i][1] = b[i] + max (dp[i-1][0], dp[i-1][2]);
		dp[i][2] = c[i] + max (dp[i-1][0], dp[i-1][1]);

	}

	dp[N][0] = max (dp[N][0], dp[N][1]);
	dp[N][0] = max (dp[N][0], dp[N][2]);

	cout << dp[N][0] << '\n';


	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int ans = 6 - a - b;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<functional>
#define rep(i,a) for(i=0;i<a;i++)
#define LL long long int
#define MAX_VAL 2100000000
using namespace std;
LL dist[114][114];
int main(void)
{
	int n,m,i,j,k;
	int a,b,c,d;
	int s,g,v,p;
	cin>>n>>m;
	rep(i,n)rep(j,n)dist[i][j]=MAX_VAL;
	rep(i,n)dist[i][i]=0;
	rep(i,m) {
		scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		a--,b--;
		dist[a][b]=c,dist[b][a]=d;
	}
	scanf("%d,%d,%d,%d",&s,&g,&v,&p);
	s--,g--;
	rep(k,n)rep(i,n)rep(j,n) dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);	
	cout<<v-p-dist[s][g]-dist[g][s]<<endl;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

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


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

typedef long long ll;
const int MAXN = 2e5 + 10;
const ll INF = 1e15;
ll A[MAXN];
ll s[MAXN];
int N;
ll res = 0x7f7f7f7f;

ll S(int l, int r, int nl, int nr) {
	if(l == r) return l;
	int mid = (l + r) >> 1;
	if(s[nr] - s[mid] > s[mid] - s[nl - 1])
		if(mid + 1 <= r && abs(s[nr]-s[mid+1]-s[mid+1]+s[nl-1])<abs(s[nr]-s[mid]-s[mid]+s[nl-1]))return S(mid+1,r,nl,nr);
		else return mid;
	else if(mid - 1 >= l && abs(s[mid-1]-s[nl-1]+s[mid-1]-s[nr])<abs(s[mid]+s[mid]-s[nl-1]-s[nr]))return S(l, mid-1, nl, nr);
		else return mid;
}

ll solve(int x) {
	ll MAX = 0, MIN = INF;
	int d1 = S(1, x-1, 1, x), d2 = S(x+1, N, x+1, N);
	MAX = max(max(s[d1], s[x]-s[d1]), max(s[N]-s[d2], s[d2]-s[x]));
	MIN = min(min(s[d1], s[x]-s[d1]), min(s[N]-s[d2], s[d2]-s[x]));
	return MAX - MIN;
}

int main() {
	scanf("%d", &N);
	for(int i = 1; i <= N; ++i)
		scanf("%lld", A + i), s[i] = s[i-1] + A[i];
	for(int i = 2; i < N; ++i)
		res = min(res, solve(i));
	printf("%lld\n", res);
	return 0;
}

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  while (true) {
    int m, n;
    cin >> m >> n;
    if (m == 0 && n == 0) break;
    vector<bool> v(7368792);
    for (int i = m; ; ++i) {
      if (v[i]) continue;
      if (n == 0) {
        cout << i << endl;
        break;
      }
      --n;
      for (uint j = 2 * i; j < v.size(); j += i) v[j] = true;
    }
  }
}

Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ACはうれCすぎてうれD */

int main(void){ 
    int n;
    string s;
    cin >> n;
    cin >> s;
    for(int i=0; i<s.length(); i++){
        int add = n % 26;
        if(s[i] + add > 'Z'){
            s[i] = 'A' + (s[i] + add - 'Z' - 1);
        }
        else{
            s[i] += add;
        }
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    void solve() throws IOException {
        int n = ni();
        int ma = ni(), mb = ni();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = ni();
            b[i] = ni();
            c[i] = ni();
        }

        int[][] dp = new int[401][401];
        for (int i = 0; i < 401; i++) {
            Arrays.fill(dp[i], Integer.MAX_VALUE / 2);
        }
        dp[0][0] = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 400; j >= 0; j--) {
                for (int k = 400; k >= 0; k--) {
                    if (j + a[i] <= 400 && k + b[i] <= 400) {
                        dp[j + a[i]][k + b[i]] = Math.min(dp[j + a[i]][k + b[i]], dp[j][k] + c[i]);
                    }
                }
            }
        }

        int ans = Integer.MAX_VALUE / 2;
        for (int i = 1; i * ma <= 400 && i * mb <= 400; i++) {
            ans = Math.min(ans, dp[i * ma][i * mb]);
        }
        out.println(ans == Integer.MAX_VALUE / 2 ? -1 : ans);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 9684
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
using namespace std;

struct UnionFind{
    vector<int> par,rank;
    
    //初期化
    UnionFind(int n){
        for(int i=0;i<=n;++i){
            par.push_back(i);
            rank.push_back(0);
        }
    }

    //根をFind
    int find(int i){
        if(par[i]==i)return i;

        return par[i]=find(par[i]);
    }

    //Union
    void unite(int x,int y){
        int rx=find(x);
        int ry=find(y);

        if(rx==ry)return;

        if(rank[rx]>rank[ry])par[ry]=rx;
        else{
            par[rx]=ry;
            if(rank[rx]==rank[ry])
                rank[ry]++;
        }
    }

    //同じ木に属するか判定
    bool same(int x,int y){
        return find(x)==find(y);
    }
};

int main(){
    int N,M;cin>>N>>M;
    UnionFind UF(N);
    int p[100010];
    for(int i=1;i<=N;i++)
        cin>>p[i];
    
    int x,y;
    for(int i=0;i<M;i++){
        cin>>x>>y;
        UF.unite(x,y);
    }
    int ans=0;
    for(int i=1;i<=N;i++)
        if(UF.same(i,p[i]))ans++;
    
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

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

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};

int W, H, C;
bool inRange(int x, int y) {
	return 0 <= x && x < W && 0 <= y && y < H;
}
int paint(vector< vector<int> >& p, int x, int y, int c, int c0) {
	if (c == c0) return 0;
	if ( !inRange(x, y) ) return 0;
	if (p[y][x] != c0) return 0;
	p[y][x] = c;
	int res = 1;
	for (int i = 0; i < 4; ++i) {
		res += paint(p, x+dx[i], y+dy[i], c, c0);
	}
	return res;
}
vector< vector<int> > f(vector< vector<int> > p, int c) {
	paint(p, 0, 0, c, p[0][0]);
	return p;
}
int dfs(int n, vector< vector<int> > p) {
	if (n == 5) {
		if (p[0][0] != C) return 0;
		return paint(p, 0, 0, 10, p[0][0]);
	}
	else {
		int res = 0;
		for (int i = 0; i < 6; ++i) {
			res = max(res, dfs(n+1, f(p, i)));
		}
		return res;
	}
}
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	while (cin >> H >> W >> C, H || W || C) {
		--C;
		vector< vector<int> > p(H, vector<int>(W));
		for (int y = 0; y < H; ++y) {
			for (int x = 0; x < W; ++x) {
				cin >> p[y][x]; p[y][x]--;
			}
		}
		cout << dfs(0, p) << endl;
	}
}

Measured memory_bytes: 3132