akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll cnt=0;
for(int i=a;i<b;i++){
    for(int j=c;j<d;j++){
        if(i==j){
            cnt++;
        }
    }
}
cout<<cnt<<endl;

}












Measured memory_bytes: 256
s = input()
dic = {chr(c): 0 for c in range(ord('a'), ord('z') + 1)}
# -1のケース
if s == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()

# 出てきた文字をチェック
for c in s:
    dic[c] += 1

# 26文字未満の場合は最後に使っていない最小文字付け足す
if len(s) != 26:
    for k, v in dic.items():
        if v == 0:
            print(s + k)
            exit()
# 全種使っている
else:
    # どこからラストまで降順に並んでいるのか
    # ....stuvw zyx
    # ↑ならzyxが降順になっている
    left = 0
    for i in range(len(s) - 1):
        if s[i] > s[i + 1]:
            pass
        else:
            left = i + 1

    # 降順の部分を分離
    s_down = s[left:]
    check = s[left - 1]
    s_down = reversed(s_down)

    # s_down直前の文字より大きいかつs_down内の最小文字で直前の文字を置き換える
    # ....stuvw zyx
    # なら，wをzyxの中の最小かつwより大きいxで置き換え
    for c in s_down:
        if check < c:
            print(s[:left-1] + c)
            exit()


Measured memory_bytes: 9020
c = int(input())
n_list = list(map(int, input().split()))

if min(n_list) == 0:
    print(0)
else:
    i = 1
    ERR = 10 ** 18
    flag = False
    for n in n_list:
        i = i * n
        if i > ERR:
            flag = True
            break

    if flag:
        print(-1)
    else:
        print(i)


Measured memory_bytes: 21664
#include <bits/stdc++.h>
#define ll long long 
#define ld long double
using namespace std;
const ll INF = 1e18;
const ll MOD = 998244353;



int32_t main() {
	ios::sync_with_stdio(!cin.tie(NULL));

	int n;
	cin >> n;
	cout << 0 << endl;
	string tmp;
	map<string, int> mp;
	mp["Male"] = 0;
	mp["Female"] = 1;
	string vac = "Vacant";

	cin >> tmp;
	if(tmp == vac) return 0;

	int hi = n, lo = 0;
	int arr[2] = {mp[tmp], !mp[tmp]};
	int l = arr[0], r = arr[0];
	while(hi > lo){
		int mid = (hi + lo + 1) / 2;
		cout << mid << endl;
		cin >> tmp;
		if(tmp == vac)	return 0;
		if((mid - lo + 1)&1)	{
			if(l == mp[tmp])	lo = mid, l = mp[tmp];
			else	hi = mid, r = !mp[tmp];
		}
		else {
			if(l == !mp[tmp])	lo = mid, l = mp[tmp];
			else	hi = mid, r = !mp[tmp];
		}

	}
}



Measured memory_bytes: 3856
def main(N, K, h):
    dp = [float('INF')] * N
    dp[0] = 0
    for i in range(N):
        for j in range(1,K+1):
            if i+j <= N-1:
                dp[i+j] = min(dp[i+j], dp[i] + (abs(h[i+j] - h[i])))
    return dp[-1]

N,K = map(int, input().split())
h = list(map(int,input().split()))
print(main(N, K, h))

Measured memory_bytes: 55136
#

import sys
from copy import deepcopy
input=sys.stdin.readline

def main():
    a,b=map(int,input().split())
    if a*b<=0:
        print("Zero")
    elif a>0:
        print("Positive")
    else:
        pm=(b-a+1)
        if pm%2==0:
            print("Positive")
        else:
            print("Negative")
    
if __name__=="__main__":
    main()


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int n, a[100005];
long long m, ret, suff[100005];

bool ok(int x) {
    ret = 0;
    long long numOps = 0;
    for (int i=0, j=n-1; j>=0; j--) {
        while (i < n && a[i] + a[j] < x)
            i++;
        numOps += n - i;
        ret += suff[i] + (long long) a[j] * (n - i);
    }
    if (numOps < m)
        return false;
    ret -= x * (numOps - m);
    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    sort(a, a + n);
    for (int i=n-1; i>=0; i--)
        suff[i] = a[i] + suff[i+1];

    int l = 0, r = 200005;
    while (l < r) {
        int x = (l + r) / 2;
        if (ok(x))
            l = x + 1;
        else
            r = x;
    }

    ok(l - 1);
    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 4796
// ABC152_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <cstring>  // std::memset
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define repr(i, n) for (ll i=n-1; i >= 0; i++)  // n-1 ~ 0
#define rep1(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define all(vec) (vec).begin(), (vec).end()
#define sum(vec) accumulate(all(vec), 0LL)  // 0 は初期値
#define min_vec(vec) min_element(all(vec))  // iterator: * を先頭につける
#define max_vec(vec) max_element(all(vec))  // iterator: * を先頭につける
#define idx(vec, element_iter) distance((vec).begin(), element_iter)
const ll INF = 1LL<<60;  // 10^18（const int inf = 1<<29;）
const double PI = acos(-1);


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    // input(sunippets: inpv, inpn, inps)
    ll N, M;
    cin >> N >> M;
    if (N >= M) swap(N, M);
    rep(i, M) cout << N;
    cout << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
#define pb push_back
#define pr pair<int,int>
using namespace std;
using ll = long long;
// using mod = 1000000000 + 7;
void self_max(int &a,int b){
	a = max(a,b);
}

void self_min(int &a,int b){
	a = min(a,b);
}
int main(){
	int n; cin >> n;
	unordered_map<int,int> m;
	// int a;
	ll sum = 0;
	while(n--){
		int a; cin >> a;
		m[a]++;
		sum +=a;
	}

	int q; cin >> q;
	while(q--){
		int from,to; cin >> from >> to;
		sum += (to-from)*m[from];
		m[to] += m[from];
		m.erase(from);
		cout << sum << endl;
	}

	return 0;
}


Measured memory_bytes: 6696
#include <bits/stdc++.h>
using i64 = long long;
using P = std::pair<int, int>;

struct Edge {
    int to, cost, index;
    Edge(int t, int c, int i) : to(t), cost(c), index(i) {}
};

int main() {
    constexpr int inf = std::numeric_limits<int>::max();
    int n, m;
    std::cin >> n >> m;
    std::vector<std::vector<Edge>> g(n);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        std::cin >> a >> b >> c;
        --a; --b;
        g[a].emplace_back(b, c, i);
        g[b].emplace_back(a, c, i);
    }

    std::vector<int> used(m);
    for (int s = 0; s < n; s++) {
        std::vector<int> dist(n, inf), prev(n, -1);
        std::priority_queue<P, std::vector<P>, std::greater<>> q;
        dist[s] = 0;
        q.emplace(0, s);

        while (!q.empty()) {
            auto curr = q.top();
            q.pop();
            if (dist[curr.second] < curr.first) continue;
            for (auto &e : g[curr.second]) {
                auto nc = curr.first + e.cost;
                if (dist[e.to] <= nc) continue;
                dist[e.to] = nc;
                prev[e.to] = e.index;
                q.emplace(nc, e.to);
            }
        }

        for (int i = 0; i < n; i++) {
            if (i == s) continue;
            used[prev[i]] = 1;
        }
    }

    std::cout << std::count(used.begin(), used.end(), 0) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1'000'000'007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0; i<N; i++) cin >> A[i];
  vector<ll> plus(N+1,0);
  vector<ll> S(N+1,0);
  for(int i=0; i<N; i++){
    S[i+1] = S[i] + A[i];
    plus[i+1] = plus[i] + max(0,A[i]);
  }
  ll ans = 0;
  for(int i=0; i+K<=N; i++){
    ll now = plus[i];
    now += max(0LL,S[i+K]-S[i]);
    now += plus[N] - plus[i+K];
    chmax(ans,now);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 5300
n, k = map(int, input().split())

a = [0] + list(map(int, input().split()))

cheak = [0] * (2*(10**5) + 1)

point = 1

dev = [1]
flag = 0

for i in range(1, k + 1):
    if cheak[point]:
        loop = i -cheak[point]
        pre_loop = cheak[point]
        flag = 1
        break
    else:
        cheak[point] = i
        point = a[point]
        #dev.append(point)

if flag:
    rest = (k + 1- pre_loop) % loop
    for j in range(rest):
        point = a[point]
        #dev.append(point)

print(point)

Measured memory_bytes: 32376
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

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

	cout << min(N%K, (N / K + 1)*K - N) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner stdIn=new Scanner(System.in);
        
        int N=stdIn.nextInt();
        int M=stdIn.nextInt();
        int count=0;
        int sum=0;
        
        int []a=new int[N];
        for(int i=0; i<N; i++){
            a[i]=stdIn.nextInt();
            sum+=a[i];
        }
        double Sum=sum/4.0/M;
        for(int i=0; i<a.length; i++){
            if(a[i]>=Sum){
                count++;
            }
        }
        if(count>=M){
            System.out.println("Yes");
            
        }
        else{
            System.out.println("No");
            
        }
        
    }

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	string s;
	cin >> s;
	isYes(s[0] == '7' || s[1] == '7' || s[2] == '7');
}

Measured memory_bytes: 3628
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <map>
#include <string>
#include <sstream>
#include <queue>


using namespace std;

#define ll long long int

bool essayer(ll k, ll N){
    //N%k = 0
    while(N%k == 0){
        N /= k;
    }
    
    if((N-1)%k == 0){
        return true;
    }
    return false;
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N;
    int count = 0;
    cin>>N;
    //cout<<N<<endl;
    count ++;
    ll d = 2;
    while(d*d <= N){
        if(N%d == 0){
            if(essayer(d, N)){
                //cout<<d<<endl;
                count ++;
            }
            if(essayer(N/d, N) && d != N/d){
                //cout<<N/d<<endl;
                count ++;
            }
        }
        
        
        d++;
        
    }
    //cout<<"aaand"<<endl;
    d = 2;
    if(N != 2){
        //cout<<N-1<<endl;
        count ++;
    }
    while(d*d <= N-1){
        if((N-1)%d == 0){
            //cout<<d<<endl;
            count ++;
            if((N-1)/d != d){
                //cout<<(N-1)/d<<endl;
                count ++;
            }
        }
        d++;
    }
    
    cout<<count<<endl;
    
    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;

ll dp[60][60][2510];
int main() {
  ll n, a;
  cin >> n >> a;
  vector<ll> x(n);
  REP(i, n) { cin >> x[i]; }

  dp[0][0][0] = 1;
  REP(i, n) {
    REP(j, n) {
      REP(k, 2500) {
        dp[i + 1][j][k] += dp[i][j][k];
        dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
      }
    }
  }
  ll ans = 0;
  FOR(i, 1, n + 1) ans += dp[n][i][i * a];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 60544
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    long S = scanner.nextLong();
    int x1 = 1_000_000_000;
    long y2 = (S - 1) / x1 + 1;
    long y1 = y2 * x1 - S;
    System.out.printf("%d %d %d %d %d %d\n", 0, 0, x1, y1, 1, y2);
  }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define max 1000000
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define lli long long int
#define endl '\n'
#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define InputArray(a,n) for(int i=0;i<n;i++) cin >> a[i];
#define CopyArray(a,temp,n) for(int i=0;i<n;i++) temp[i]=a[i];
#define PrintArray(a,n) for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
using namespace std;


int main() {
#ifdef Niloy
    read("input.txt");
    write("output.txt");
#endif

	lli p = 100, x, step = 0;
	cin >> x;
  while(p < x) {
	  p += p / 100;
	  step++;
  }

  cout << step << endl;

  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<lint> x(n), y(n);
    vector<lint> v(n), w(n);
    int parity = -1;
    bool ng    = false;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        v[i] = x[i] + y[i];
        w[i] = x[i] - y[i];
        if (parity == -1) {
            parity = 1 - abs(v[i]) % 2;
        } else if (parity != 1 - abs(v[i]) % 2) {
            ng = true;
        }
        v[i] += (1LL << 32) - 1;
        w[i] += (1LL << 32) - 1;
        if (parity == 1) {
            v[i]++;
            w[i]++;
        }
    }
    if (ng) {
        cout << -1 << "\n";
        return 0;
    }
    int m = 32;
    vector<lint> d(m);
    lint len = 1;
    for (int i = m - 1; i >= 0; --i) {
        d[i] = len;
        len *= 2;
    }
    if (parity == 1)
        d.push_back(1);
    cout << m + parity << "\n";
    for (int i = 0; i < m + parity; ++i) {
        if (i)
            cout << " ";
        cout << d[i];
    }
    cout << endl;
    for (int i = 0; i < n; ++i) {
        string ret = "";
        for (int j = 31; j >= 0; --j) {
            bool vp = false;
            bool wp = false;
            if ((v[i] >> (j + 1)) & 1) {
                vp = true;
            }
            if ((w[i] >> (j + 1)) & 1) {
                wp = true;
            }
            if (vp && wp)
                ret += 'R';
            else if (vp && !wp)
                ret += 'U';
            else if (!vp && wp)
                ret += 'D';
            else
                ret += 'L';
        }
        if (parity == 1)
            ret += 'L';
        cout << ret << endl;

        // { // ans check
        //     lint xx = 0, yy = 0;
        //     for (int j = 0; j < m + parity; ++j) {
        //         if (ret[j] == 'R')
        //             xx += d[j];
        //         else if (ret[j] == 'L')
        //             xx -= d[j];
        //         else if (ret[j] == 'U')
        //             yy += d[j];
        //         else
        //             yy -= d[j];
        //     }
        //     cout << xx << " " << yy << "\n";
        // }
    }
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(){

  int i,n,a[100],x[100];

    scanf("%d",&n);

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

  }

  for (i = n-1; i > 0; i--){

    printf("%d ",a[i]);

      }

  printf("%d\n",a[0]);

  return 0;
  
}

Measured memory_bytes: 596
#include<iostream>
using namespace std;
int main(){
    int N,A[100];
    cin >>N;
    int count=0;
    int tmp;
    for(int i=0;i<N;i++){
        cin >>A[i];
    }
    for(int i=0;i<N;i++){
        for(int j=N-1;j>i;j--){
            if(A[j] < A[j-1]){
                tmp=A[j];
                A[j]=A[j-1];
                A[j-1]=tmp;
                count++;
            }
        }
    }
    for(int i=0;i<N;i++){
        if(i!=N-1){
            cout<<A[i]<<' ';
        }else{
            cout <<A[i]<<endl;
        }
    }
    cout <<count<<endl;
    return 0;
}



Measured memory_bytes: 3084
#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;
  string S;
  cin >> N >> A >> B >> S;
  int q = A + B;
  int i = 0;
  while(N > i){
    if(S[i] == 'a' && q > 0){
      cout << "Yes" << endl;
      q--;
    }else if(S[i] == 'b' && B > 0 && q > 0){
      cout << "Yes" << endl;
      B--;
      q--;
    }else{
      cout << "No" << endl;
    }
    i++;
  }
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)

long long int n,cnt=0,ans=0,a[100000],b=0,c=0,tmp=0;
string s,w;

int main(void){
    bool flag[10]={false};
      cin >> n;
      rep(i,n){
          cin >> a[i];
      }
      rep(i,n){
           if(flag[0]==false && a[i]>=1 && a[i]<=399){
               flag[0]=true;
              b++;
              c++;
          }
          else if(flag[1]==false && a[i]>=400 && a[i]<=799){
              flag[1]=true;
              b++;
              c++;
          }
          else if(flag[2]==false && a[i]>=800 && a[i]<=1199){
              flag[2]=true;
              b++;
              c++;
          }
          else if(flag[3]==false && a[i]>=1200 && a[i]<=1599){
              flag[3]=true;
              b++;
              c++;
          }
          else if(flag[4]==false && a[i]>=1600 && a[i]<=1999){
              flag[4]=true;
              b++;
              c++;
          }
          else if(flag[5]==false && a[i]>=2000 && a[i]<=2399){
              flag[5]=true;
              b++;
              c++;
          }
          else if(flag[6]==false && a[i]>=2400 && a[i]<=2799){
              flag[6]=true;
              b++;
              c++;
          }
          else if(flag[7]==false && a[i]>=2800 && a[i]<=3199){
              flag[7]=true;
              b++;
              c++;
          }
          else if(a[i]>=3200){
              c++;
          }
      }
     
      rep(i,n){
          if(a[i]>=3200){
              cnt++;
          }
      }
      if(cnt==n){
          b++;
      }
      
      cout << b << " " << c << endl;
      
      
      
return 0;
}


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

typedef long long ll;

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

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n,m;
	cin >> n >> m;
	ll ans = pow(2,m) * (m * 1900 + 100 * (n-m));
	ANS(ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        String str = sc.next();

        String ans = "";
        for (int i = 0; i < str.length(); i++) {
            for (int j = i; j <= str.length(); j++) {
                String a = str.substring(i, j);
                char[] chars = a.toCharArray();
                boolean isACGT = true;
                for (int k = 0; k < chars.length; k++) {
                    if (chars[k] != 'A' && chars[k] != 'G' && chars[k] != 'C' && chars[k] != 'T') {
                        isACGT = false;
                    }
                }
                if (isACGT && (ans.length() < a.length())) {
                    ans = a;
                }
            }
        }
        System.out.println(ans.length());
    }

}

Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a, b;
		a = sc.nextLong();
		b = sc.nextLong();
		long tempa = a;
		long tempb = b;
		int temp[] = new int[64];
		int c[];
		int d[];
		int i = 0;
		if (a == b) {
			System.out.println(a);
			return;
		}
		while (b > 0) {
			temp[i] = (int) (b % 2);
			b = b / 2;
			i++;
		}
		c = new int[i];
		for (int j = 0; j < i; j++) {
			c[j] = temp[j];
		}
		i = 0;
		if (a > 1) {
			a--;
			while (a > 0) {
				temp[i] = (int) (a % 2);
				a = a / 2;
				i++;
			}
			d = new int[i];
			for (int j = 0; j < i; j++) {
				d[j] = temp[j];
			}
			for (i = c.length - 1; i >= 0; i--) {
				if (i > 0 && c[i] == 1 && c[0] == 1) {
					c[i] = 0;
				}
			}
			for (i = d.length - 1; i >= 0; i--) {
				if (i > 0 && d[i] == 1 && d[0] == 1) {
					d[i] = 0;
				}
			}
			for (i = 1; i < d.length; i++) {
				if (c[i] == d[i]) {
					c[i] = 0;
				} else {
					c[i] = 1;
				}
			}
			int t = (int) ((tempb - tempa) % 4);
			if (t == 3) {
				c[0] = 0;
			} else if (t == 2 ) {
				if (c[0] == 0) {
					c[0] = 1;
				} else {
					c[0] = 0;
				}
			} else if (t==1) {
				c[0] =1;
			}
		} else {
			for (i = c.length - 1; i > 0; i--) {
				if (i > 0 && c[i] == 1 && c[0] == 1) {
					c[i] = 0;
				}
			}
			int t = (int) (tempb % 4);
			if (t == 2 || t == 3) {
				if (c[0] == 0) {
					c[0] = 1;
				} else {
					c[0] = 0;
				}
			}
		}
		long result = 0;
		for (i = c.length - 1; i >= 0; i--) {
			result *= 2;
			result += c[i];
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 21972
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
vector<vpi> graph;
int ans[MX];

void dfs(int v, int p, int skip) {
    int c = 1;
    F0R(i, sz(graph[v])) {
        int nxt = graph[v][i].f;
        if (nxt == p) continue;
        if (c == skip) c++;
        ans[graph[v][i].s] = c;
        dfs(nxt, v, c);
        c++;
    }
}
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    int K = 0;
    F0R(i, N) {
        vpi blank; graph.pb(blank);
    }
    F0R(i, N-1) {
        int A, B; cin >> A >> B; A--; B--;
        graph[A].pb({B, i});
        graph[B].pb({A, i});
        K = max(K, sz(graph[A]));
        K = max(K, sz(graph[B]));
    }

    cout << K << endl;

    dfs(0, -1, -1);
    F0R(i, N-1) {
        cout << ans[i] << endl;
    }
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 6896
#include <iostream>

int sign(double x);

int main()
{
    double x1, y1, x2, y2, x3, y3;
    double xp, yp;

    while (std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
        double vec12_x_vec1p = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1);
        double vec23_x_vec2p = (x3 - x2) * (yp - y2) - (y3 - y2) * (xp - x2);
        double vec31_x_vec3p = (x1 - x3) * (yp - y3) - (y1 - y3) * (xp - x3);
        int judge = sign(vec12_x_vec1p) + sign(vec23_x_vec2p)
                  + sign(vec31_x_vec3p);

        if (judge == 1 + 1 + 1 || judge == -1 - 1 - 1) {
            std::cout << "YES" << std::endl;
        } else {
            std::cout << "NO" << std::endl;
        }
    }

    return 0;
}

int sign(double x)
{
    return ((x >= 0)? 1: (-1));
}

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

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> P;
typedef pair<lint, lint> Plint;
 
const int MOD = 1e9+7;
const int INF = 1<<18;
const lint INFLINT = 1LL<<60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define ALL(s) (s.begin(), s.end())
#define SZ(s) (s.size())

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

// Union-Find-Tree
class UnionFind {
	vector<int> par;
	UnionFind(int n):par(n){rep(i,n)par[i]=i;}
	int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
	void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
	bool same(int x,int y){return root(x)==root(y);}
};

// Final Weapon!
// #define int lint

int main() {
    string s, t;
    cin >> s >> t;
    if(s == t.substr(0, t.size() - 1)) cout << "Yes";
    else cout << "No";
    
    return 0;
}


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

int main()
{
	int N;

	cin >> N;

	string S[N];

	for (int i = 0; i < N; i++)
	{
		cin >> S[i];
	}

	int MARCHcount[5] = {};

	for (int i = 0; i < N; i++)
	{
		if (S[i][0] == 'M')
		{
			MARCHcount[0]++;
		}
		else if (S[i][0] == 'A')
		{
			MARCHcount[1]++;
		}
		else if (S[i][0] == 'R')
		{
			MARCHcount[2]++;
			;
		}
		else if (S[i][0] == 'C')
		{
			MARCHcount[3]++;
		}
		else if (S[i][0] == 'H')
		{
			MARCHcount[4]++;
		}
	}

	long long int ans = 0;

	for (int i = 0; i < 5; i++)
	{
		for (int j = i + 1; j < 5; j++)
		{
			for (int k = j + 1; k < 5; k++)
			{
				ans += (long long int)MARCHcount[i] * (long long int)MARCHcount[j] * (long long int)MARCHcount[k];
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define ar array

const int mod = 1e9 + 7;

const int N = 1e5 + 5;
ll dp[N][13];
 
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
 
    string s;
    cin >> s;
    int n = (int) s.size();
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        int c = (s[i] == '?') ? -1 : (s[i] - '0');
        for (int j = 0; j < 10; j++) {
            if (c != -1 && c != j) continue;
            for (int r = 0; r < 13; r++) {
                dp[i + 1][(r * 10 + j) % 13] += dp[i][r];
            }
        }
        for (int j = 0; j < 13; j++) {
            dp[i + 1][j] %= mod;
        }
    }
    cout << dp[n][5] << '\n';
}

Measured memory_bytes: 10604
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<string.h>
using namespace std;
struct t
{
	long long  w,v;
}a[105],b[105],c[105],d[105];
bool cmp(t a,t b)
{
	if(a.v>b.v)
	return true;
	else
	return false;
}
int main()
{
    long long n,vv,i,j,k,h,m,len0,len1,len2,len3,maxm;
    long long w,v,x0,x1,x2,y0,y1,y2,s;
	while(scanf("%lld%lld",&n,&vv)!=EOF)
	{
		j=k=h=m=0;len0=len1=len2=len3=0;
		maxm=-1;
		for(i=0;i<n;i++)
		{
			scanf("%lld%lld",&w,&v);
			if(i==0)
			s=w;
			if(w==s)
			{
				len0++;
				a[j].w=w;
				a[j].v=v;
				j++;
			}
			else if(w==s+1)
			{
				len1++;
				b[k].w=w;
				b[k].v=v;
				k++;
			}
			else if(w==s+2)
			{
				len2++;
				c[h].w=w;
				c[h].v=v;
				h++;
			}
			else
			{
				len3++;
				d[m].w=w;
				d[m].v=v;
				m++;
			}
		}
		sort(a,a+n,cmp);
		sort(b,b+n,cmp);
		sort(c,c+n,cmp);
		sort(d,d+n,cmp);
		w=v=0;
		//cout<<len2<<endl;
		//for(i=0;i<len2;i++)
		//{
		//	printf("%d %d\n",c[i].w,c[i].v);
		//}
		for(i=0;i<=len0;i++)
		{
			x0=w;y0=v;
			if(i)
			{
				w+=a[i-1].w;
			    v+=a[i-1].v;
			    x0=w;
			    y0=v;
			}
			for(j=0;j<=len1;j++)
			{
				x1=w;y1=v;
				if(j)
				{
					w+=b[j-1].w;
					v+=b[j-1].v;
					x1=w;
					y1=v;
				}
				for(k=0;k<=len2;k++)
				{
					x2=w;y2=v;
					if(k)
					{
						w+=c[k-1].w;
						v+=c[k-1].v;
						x2=w;
						y2=v;
					}
					for(h=0;h<=len3;h++)
					{
						if(h)
						{
							w+=d[h-1].w;
							v+=d[h-1].v;
						}
						if(w<=vv&&v>maxm)
						{
							maxm=v;
							//printf("%d %d %d %d %d\n",i,j,k,h,maxm);
						}
					}
					w=x2;
					v=y2;
					//printf("%d %d\n",w,v);
				}
				w=x1;
			    v=y1;
			    //printf("%d %d\n",w,v);
			}
			w=x0;
			v=y0;
			//printf("%d %d\n",w,v);
		}
		printf("%lld\n",maxm);
	}
    return 0;
}

Measured memory_bytes: 256
a1,a2,a3=map(int,input().split())
print(min(abs(a1-a2)+abs(a2-a3),abs(a1-a3)+abs(a2-a3),abs(a2-a1)+abs(a1-a3),abs(a2-a3)+abs(a1-a3),abs(a3-a1)+abs(a1-a2),abs(a3-a2)+abs(a2-a1)))

Measured memory_bytes: 3060
#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;
const int  N = 2e5 + 314;
void foo(){
    int n;
    cin>>n;
    vi v(n);
    int mn=INF, cnt=0;
    for(int i = 0; i < n; i++)cin>>v[i];
    for(int i = 0; i < n; i++){
        if(mn>v[i]){
            mn=v[i];
            cnt++;
        }
    }
    cout<<cnt;
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,n,i,j,r=0;
    string s;
    cin>>t;
    cin>>s;
   for(i=0;i<s.size();i++)
    {
        j=0;
        r=int(s[i]);
        n=s[i]+t;
        if(n>90){
        s[i]-=(26-(n-r));

        }
        else
            s[i]=s[i]+t;
    }


    cout<<s<<"\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 all(v) begin(v),end(v)
using ll = long long;

int main() {
  ll n;cin>>n;
  int ans;
  for(int i=1;i<=sqrt(n);i++)if(n%i==0)ans=i;
  cout<<ans-1+n/ans-1<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;
//using namespace boost::multiprecision;

int main(){

    ll n,d,a;
    cin >> n >> d >> a;

    vector<pair<ll,ll>> v;
    vector<ll> imos(n + 3);

    rep(i,n){
        ll x, h;
        cin >> x >> h;

        v.pback(mpair(x,h));
    }

    sort(ALL(v));
    ll ans = 0;

    for(int i = 1; i <= n; i++){

        int idx = i - 1;
        imos[i] = imos[i] + imos[i - 1];

        ll curd = imos[i];

        if(curd < v[idx].second){
            ll tmp = v[idx].second - curd;
            ll tmpc = (tmp + a - 1) / a;

            ans += tmpc;

            ll left = v[idx].first;

            auto itr = lower_bound(ALL(v), mpair(left + 2 * d + 1 ,(ll)0));
            int right_index = distance(v.begin(), itr) + 1;

            imos[i] += tmpc * a;
            imos[right_index] -= tmpc * a;
        }
    }

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

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

int top, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop(void) {
	top--;
	return S[top + 1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];
	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		} else if (s[0] == '-') {
			b= pop();
			a = pop();
			push(a - b);
		} else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		} else {
			push(atoi(s));
		}
	}
	printf("%d\n", pop());
	return 0;
}

Measured memory_bytes: 548
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=500010,inf=0X3f3f3f3f;
int n,f[maxn][3],suml[maxn],sumr[maxn],last,ans=0;
char s[maxn];
int main(){
	scanf("%d",&n); scanf("%s",s+1);
	f[1][1]=f[2][1]=-inf;
	int co=0,cnt=0;
	for (int i=1;i<=n;i++){
		if (s[i]=='1') co++;
		else {
			cnt++;
			suml[i]=co; 
			co=0;
		}
	}
	co=0;
	for (int i=n,tot=cnt;i>=1;i--){
		if (s[i]=='1') co++;
		else {
			sumr[i]=co;
			co=0;
			tot--;
		}
	}
	f[0][0]=0;f[0][1]=f[0][2]=-inf;
	for (int i=1;i<=n;i++) if (s[i]=='0'){
		f[i][0]=max(f[last][0],max(f[last][1],f[last][2]));
		f[i][1]=suml[i] && sumr[i]?max(f[last][0]+suml[i],suml[i]>=1?f[last][1]+suml[i]-1:-inf):-inf;
		f[i][2]=suml[i] && sumr[i]?
		max(max(f[last][0]+sumr[i],suml[i]>=2?f[last][1]+sumr[i]:0),suml[i]>=1?f[last][2]+sumr[i]-1:-inf):-inf;
		ans=max(ans,max(f[i][0],max(f[i][1],f[i][2])));
		last=i;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 10368
#import<iostream>
int i,j,n,P[9999];int main(){for(i=2;i*i<9999;i++)for(j=i;j<9999;P[j+=i]=1);for(;std::cin>>n,n;printf("%d %d\n",i-2,i))for(i=n;P[i]||P[i-2];i--);}

Measured memory_bytes: 0
from collections import defaultdict


class UnionFind:

    def __init__(self, n):
        # * Access m-th node by index `m`, not `m - 1`.
        self.parents = [i for i in range(n + 1)]
        self.ranks = [0 for _ in range(n + 1)]

    def find_root(self, node):
        parent_node = self.parents[node]
        if parent_node == node:
            return node
        else:
            root_node = self.find_root(parent_node)
            self.parents[node] = root_node  # reduction
            return root_node

    def union(self, one, other):
        one_root = self.find_root(one)
        other_root = self.find_root(other)
        if one_root == other_root:
            return
        if self.ranks[one_root] < self.ranks[other_root]:
            self.parents[one_root] = other_root
        else:
            self.parents[other_root] = one_root
            if self.ranks[one_root] == self.ranks[other_root]:
                self.ranks[one_root] += 1

    def is_same_group(self, one, other):
        one_root = self.find_root(one)
        other_root = self.find_root(other)
        return one_root == other_root


def main():
    N, K, L = list(map(int, input().split(' ')))
    road_tree = UnionFind(N)
    for _ in range(K):
        p, q = list(map(int, input().split(' ')))
        road_tree.union(p, q)
    train_tree = UnionFind(N)
    for _ in range(L):
        r, s = list(map(int, input().split(' ')))
        train_tree.union(r, s)
    # Calculate groups
    group_count = defaultdict(int)
    group_list = list()
    for node in range(1, N + 1):
        group = (road_tree.find_root(node), train_tree.find_root(node))
        group_count[group] += 1
        group_list.append(group)
    answer = ' '.join(list(map(
        lambda g: str(group_count[g]),
        group_list
    )))
    print(answer)


if __name__ == '__main__':
    main()

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

L = [0] * (N + 1)
L[0] = 2
L[1] = 1
if N == 1:
    print(L[1])
else:
    for i in range(2, N + 1):
        L[i] = L[i - 1] + L[i - 2]
    print(L[N])

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#define rep(i,a) for(int i=0;i<(a);++i)
#define rrep(i,a) for(int i=(a)-1;i>=0;--i)

using namespace std;

int main() {
	int n;
	while(cin >> n,n){
		vector<vector<int> > v(5,vector<int>(n));
		rrep(i,n) rep(j,5) cin >> v[j][i];
		int sum=0,lsum;
		do{
			lsum = sum;
			rep(i,n){
				bool rm[5];
				memset(rm,false,sizeof(rm));
				rep(j,3){
					if(v[j][i] && v[j][i] == v[j+1][i] && v[j+1][i] == v[j+2][i]){
						rm[j]=rm[j+1]=rm[j+2]=true;
					}
				}
				rep(j,5){
					if(rm[j]){
						sum+=v[j][i];
						v[j][i]=0;
					}
				}
			}
			rep(i,5){
				fill(remove(v[i].begin(),v[i].end(),0),v[i].end(),0);
			}
		}while(lsum!=sum);
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long A, B, C, X;
  cin >> A >> B >> C >> X;

  long ans = 0;

  for (long a = 0; a <= A; a++) for (long b = 0; b <= B; b++) for (long c = 0; c <= C; c++) if (a * 500 + b * 100 + c * 50 == X) ans++;

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
   int n;
   ll L[87];
   cin >> n;
   L[0] = 2; L[1] = 1;
   for(int i=2; i<=n; i++)L[i]=L[i-2]+L[i-1];
   cout <<L[n] << endl;
}


Measured memory_bytes: 256
def gcd(x, y):
    if x > y:
        x, y = y, x
    if x == 0:
        return y
    else:
        return gcd(y%x, x)

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

if gcd(a, b) == 1:
    print("YES")
else:
    if c%gcd(a, b) == 0:
        print("YES")
    else:
        print("NO")

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

int n;
double a, ans;
string s;


int main(){
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a >> s;
    ans += s == "BTC" ? a*380000.0 : a;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INT(a) scanf("%d",&a)
#define STR(a) scanf("%s",a)
#define DBL(a) scanf("%lf",&a)
#define LNG(a) scanf("%lld",&a)
#define PI acos(-1)
#define MX 100005

int u[MX], v[MX];
long long ans[MX];
long long cur;


struct UF{
    int root[MX],SZ[MX];
    UF(){}
    UF(int n){ for(int i=0;i<=n;i++) root[i]=i, SZ[i]=1; }

    int find(int n){ return n==root[n] ? n : root[n]=find(root[n]); }
    
    void unite(int x, int y){
        int px = find(x), py = find(y);
        if(px==py) return;

        //cout<<cur<<endl;
        cur-=SZ[px]*SZ[py]*1LL;
        //cout<<SZ[px]<<SZ[py]<<cur<<endl;
        if(SZ[px]<SZ[py]) swap(px, py);
        root[py]=px;
        SZ[px]+=SZ[py];
    }
    
};



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

	UF uf(n);
	for(int i=1;i<=m;i++){
		cin>>u[i]>>v[i];
	}

	cur = (n*(n-1LL))/2;

	for(int i=m;i>=1;i--){
		ans[i]=cur;
		uf.unite(u[i], v[i]);
	}

	for(int i=1;i<=m;i++) cout<<ans[i]<<endl;

	return 0;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

const int MAX = 55555;

int main() {

    vector<bool> primes(MAX, true);
    for (int i = 2; i < MAX; i++) {
        if (!primes[i]) continue;
        for (int j = 2; i * j <= MAX; j++) {
            primes[i * j] = false;
        }
    }
    set<int> ps;
    for (int i = 2; i < MAX; i++) if (primes[i]) ps.insert(i);

    queue<int> q;
    for (int i : ps) {
        if (i % 5 == 1) {
            q.push(i);
        }
    }

    int n;
    cin >> n;
    rep(i, n) {
        cout << q.front() << ' ';
        q.pop();
    }
    cout << endl;
}





Measured memory_bytes: 512