akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N; cin >> N;
  auto ans = (N+1) / 2;
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF (ll)(1e12)

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

  ll a, b, q;
  cin >> a >> b >> q;

  vll s(a);
  vll t(b);
  vll x(q);
  rep(i, a) {
    cin >> s[i];
  }

  rep(i, b) {
    cin >> t[i];
  }

  rep(i, q) {
    cin >> x[i];
  }

  rep(i, q) {
    auto itr_sr = lower_bound(all(s), x[i]);
    auto itr_tr = lower_bound(all(t), x[i]);

    ll sl = -INF;
    ll sr = INF;
    ll tl = -INF;
    ll tr = INF;

    if (itr_sr != s.begin()) {
      sl = *prev(itr_sr);
    }
    if (itr_sr != s.end()) {
      sr = *itr_sr;
    }

    if (itr_tr != t.begin()) {
      tl = *prev(itr_tr);
    }
    if (itr_tr != t.end()) {
      tr = *itr_tr;
    }

    ll ans = max(sr, tr) - x[i];
    chmin(ans, x[i] - min(sl, tl));

    chmin(ans, x[i] - sl + tr - sl);
    chmin(ans, x[i] - tl + sr - tl);
    chmin(ans, sr - x[i] + sr - tl);
    chmin(ans, tr - x[i] + tr - sl);

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main()
{
    ll a, b, n;
    cin >> a >> b >> n;
    if (b == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    else
    {
        ll c = min(b - 1, n);
        cerr << c << endl;
        cout << (a * c) / b << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut n:usize = read();
    let mut m:usize = read();
    if n <= 3 && m <= 3 {
        if (n * m) % 2 == 0 {
            println!("0");
        } else {
            println!("1");
        }
        return
    }
    if n >= 2 {
        n -= 2;
    }
    if m >= 2 {
        m -= 2;
    }
    println!("{}", n * m);
}

Measured memory_bytes: 2096
N = int(input())
*H, = map(int, input().split())
for i in range(N-1, 0, -1):
    h1, h2 = H[i-1], H[i]
    if h1 <= h2: continue
    elif h1 == h2 + 1: H[i-1] -= 1
    else: print('No'); break;
else:
    print('Yes')

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template <typename T>
struct SegmentTree {
    int n;
    vector<T> node;
    T calc(T a, T b) {
        // return a + b;
        // return min(a, b);
        return max(a, b);
    }
    T e = 0ll;
    SegmentTree(vector<T> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) {
            n *= 2;
        }
        node.resize(2 * n - 1, e);
        for (int i = 0; i < sz; i++) {
            node[i + n - 1] = v[i];
        }
        for (int i = n - 2; i >= 0; i--) {
            node[i] = calc(node[2 * i + 1], node[2 * i + 2]);
        }
    }
    SegmentTree(T sz) {
        n = 1;
        while (n < sz) {
            n *= 2;
        }
        node.resize(2 * n - 1, e);
    }
    void update(int x, T val) {
        x = n + x - 1;
        node[x] = val;
        while (x > 0) {
            x = (x - 1) / 2;
            node[x] = calc(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    void add(int x, T val) {
        x = n + x - 1;
        node[x] += val;
        while (x > 0) {
            x = (x - 1) / 2;
            node[x] = calc(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return e;
        if (a <= l && r <= b) return node[k];
        T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return calc(vl, vr);
    }
    T at(int x) {
        return node[n + x - 1];
    }
};
int main() {
    int n;
    cin >> n;
    vector<ll> a(n), v(n);
    rep(i, n) {
        cin >> a[i];
        v[i] = a[i];
    }
    sort(all(v));
    get_unique(v);
    rep(i, n) a[i] = lower_bound(all(v), a[i]) - v.begin();
    SegmentTree<ll> segt(100100);
    vector<ll> dp(n + 1);
    rep(i, n) {
        chmax(dp[a[i]], segt.query(a[i], 100100) + 1);
        segt.update(a[i], dp[a[i]]);
    }
    ll ans = 0;
    rep(i, n) chmax(ans, dp[a[i]]);
    cout << ans << endl;
}


Measured memory_bytes: 4608
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] arg) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for(int i=1;i<=9;i++){
            for(int j=1;j<=9;j++){
                if(N == i*j){
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
        return;
    }
}

Measured memory_bytes: 22996
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int q = sc.nextInt();
        int[] aArr = new int[q];
        int[] bArr = new int[q];
        int[] cArr = new int[q];
        int[] dArr = new int[q];
        for (int i = 0; i < q; i++) {
            aArr[i] = sc.nextInt() - 1;
            bArr[i] = sc.nextInt() - 1;
            cArr[i] = sc.nextInt();
            dArr[i] = sc.nextInt();
        }
        Nums nums = new Nums(n, m);
        int max = 0;
        while (nums.next()) {
            int sum = 0;
            for (int i = 0; i < q; i++) {
                sum += nums.get(aArr[i], bArr[i], cArr[i], dArr[i]);
            }
            max = Math.max(max, sum);
        }
        System.out.println(max);
    }
    
    static class Nums {
        int[] arr;
        int length;
        int size;
        
        public Nums(int length, int size) {
            this.length = length;
            this.size = size;
            arr = new int[length];
            Arrays.fill(arr, 1);
            arr[length - 1] = 0;
        }
        
        public boolean next() {
            return next(length - 1);
        }
        
        public boolean next(int idx) {
            if (arr[idx] >= size) {
                if (idx == 0) {
                    return false;
                }
                if (next(idx - 1)) {
                    arr[idx] = arr[idx - 1];
                } else {
                    return false;
                }
            } else {
                arr[idx]++;
            }
            return true;
        }
        
        public int get(int left, int right, int value, int point) {
            if (arr[right] - arr[left] == value) {
                return point;
            } else {
                return 0;
            }
        }
    }
}

Measured memory_bytes: 37240
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

"""
各スライム（最終状態）に対して、どこで生産すればよかったか。
操作2の回数を決めるごとに計算できる。
"""

N,X = map(int,input().split())
A = np.array(input().split(), dtype=np.int64)

AA = np.concatenate([A,A])

answer = AA[N:].sum()
for n in range(1,N+1):
    np.minimum(AA[1:],AA.copy()[:-1],out=AA[1:])
    answer = min(answer, AA[N:].sum()+X*n)

print(answer)

Measured memory_bytes: 12508
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);
#define int long long
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vector<int> a(n+1);
	vector<int> b(n);
	for(int i=0;i<n+1;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	int res = 0;
	for(int i=0;i<n;i++)
	{
		if(a[i]>b[i])
		{		
			a[i]-=b[i];
			res+=b[i];
			continue;
		}
		if(a[i]<=b[i])
		{
			b[i]-=a[i];
			res+=a[i];
			a[i]=0;
			if(a[i+1]<=b[i])
			{
				res+=a[i+1];
				a[i+1]=0;
			}
			else a[i+1]-=b[i],res+=b[i];
		}
	}	
	cout<<res<<endl;
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++) cin >> X[i];
    int ans = 1e9;
    for (int i = 1; i <= 100; i++) {
        int d = 0;
        for (int j = 0; j < N; j++) {
            d += (i-X[j])*(i-X[j]);
        }
        ans = min(ans, d);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = list(map(int, input().split()))
s = n[0]
c = n[1]

ans = 0
if s * 2 < c:
    ans = s
    c = c - (s * 2)
else:
    # cが足りない場合、Sが作れないのでccを作れる数がMAX
    ans = int(c / 2)
    print(str(ans))
    quit()
# sは使い切っててcが4個2個でS+cc1増える
ans += int(c / 4)
print(str(ans))

Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <iomanip>
#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 <math.h>
using namespace std;

int main(){
  while(true){
    int n;
    cin >> n;
    if(n == 0) return 0;
    vector<double> s(n);
    double ave;
    double sum;
    sum = 0;
    for(int i = 0; i < n; i++){
      cin >> s.at(i);
      sum += s.at(i);
    }
    ave = sum / n;
    double dist_sum = 0;
    double dist;
    double stddev;
    for(int i = 0; i < n; i++){
      dist_sum += (s.at(i) - ave) * (s.at(i) - ave); 
    }
    dist = dist_sum / n;
    cout << fixed << setprecision(10);
    cout << sqrt(dist) << endl;
  }
}


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

int main() {
  int X,Y,Z;
  cin >> X >> Y >> Z;
   int A;
  A = X%(Y+Z);
  if(A<Z){
    cout << X/(Y+Z)-1 << endl;
  }
  else
    cout << X/(Y+Z) << endl;
   }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int n,k,x[maxn];
const int inf=0x3f3f3f3f;
long long a,b,now;
int topp,topn;
long long ans;
int main(){
	cin>>n>>k;
	ans=inf;
	for(int i=1;i<=n;i++){
		cin>>x[i];
	}
	for(int i=1;i+k-1<=n;i++){
		a=min(abs(x[i]),abs(x[i+k-1]));
		b=x[i+k-1]-x[i];
		ans=min(ans,a+b);
	}
	cout<<ans;
}

Measured memory_bytes: 640
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

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

int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = a;i <= b;i++) {
		if (i<a + k || i>b - k)cout << i << endl;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
vector<Int> func(const vector<int>& B)
{
    vector<array<Int, 16>> dp(B.size() + 1); // dp[i][j]: A[i] に j 回 4 を掛けたときの回数
    for (int j = 0; j < 16; j++) {
        dp[B.size()][j] = j;
    }
    for (int i = B.size()-1; i >= 0; i--) {
        for (int j = 0; j < 16; j++) {
            int t = max(0, j + B[i]);
            if (t >= 16) {
                dp[i][j] = j + dp[i+1][15] + (t - 15) * (B.size() - i);
            } else {
                dp[i][j] = j + dp[i+1][t];
            }
        }
    }
    vector<Int> ans(B.size() + 2);
    for (int i = 0; i < B.size(); i++) ans[i] = dp[i][0];
    return ans;
}
int main()
{
    int N; cin >> N;
    vector<int> A(N), B(N-1), C(N-1);
    for (auto &a : A) cin >> a;
    // B[i]: A[i] <= A[i+1] * 4^x を満たす最小の整数 x
    for (int i = 0; i < N-1; i++) {
        B[i] = ceil((log(A[i]) - log(A[i+1]) - 1e-10) / log(4));
        C[i] = ceil((log(A[i+1]) - log(A[i]) - 1e-10) / log(4));
    }
    reverse(begin(C), end(C));
    auto D = func(B), E = func(C);
    Int ans = 1e18;
    for (int i = 0; i <= N; i++) {
        ans = min<Int>(ans, D[i] * 2 + E[N - i] * 2 + i);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 30680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int W, H, N;
    cin >> W >> H >> N;
    vector<vector<int>> rect(H, vector<int>(W, 1));
    for (int i = 0; i < N; i++)
    {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1)
        {
            for (int j = 0; j < H; j++)
            {
                for (int k = 0; k < x; k++)
                {
                    rect[j][k] = 0;
                }
            }
        }
        else if (a == 2)
        {
            for (int j = 0; j < H; j++)
            {
                for (int k = x; k < W; k++)
                {
                    rect[j][k] = 0;
                }
            }
        }
        else if (a == 3)
        {
            for (int j = 0; j < y; j++)
            {
                for (int k = 0; k < W; k++)
                {
                    rect[j][k] = 0;
                }
            }
        }
        else if (a == 4)
        {
            for (int j = y; j < H; j++)
            {
                for (int k = 0; k < W; k++)
                {
                    rect[j][k] = 0;
                }
            }
        }
    }
    int area = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (rect[i][j] == 1)
            {
                area++;
                //cout << i << ", " << j << endl;
            }
        }
    }
    cout << area << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> d(n+1);
  for(int i = 1;i <= n;i++){
    cin >> d.at(i);
  }
  sort(d.begin(),d.end());
  cout << d.at(n/2 + 1) - d.at(n/2) << endl;
}

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

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

struct Node *root,*NIL;

void insert(int k){
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;

  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key < y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}

void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  char com[10];
  char *a="insert";
  char *b="print";

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);
    if(strcmp(a,com)==0){
      scanf("%d",&x);
    insert(x);
    }
    else if(strcmp(b,com)==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
      }
  }

  return 0;
}



Measured memory_bytes: 25208
#include <stdio.h>
#include <math.h>

int main()
{
    long long N,N0,i,sum=0,sum_max=0,a,count=0;

    scanf("%lld",&N);
    if(N<10){
        printf("%lld",N);
        return 0;
    }
    N0=N;
    while(N>=10){
        sum += 9;
        N = N/10;
        a = N%10;
        count++;
    }
    if(N0 == (a+1)*pow(10,count)-1){
        printf("%lld\n",sum+a);
    }else{
        printf("%lld\n",sum+a-1);
    }
    return 0;
}

Measured memory_bytes: 128
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

#define MOD 1000000007

LL N, K;

LL dp[102][32000];
LL sum[102][32000],keisu[102][32000];
LL solve(int now, LL bef){
	if(now >= K) return 1;
	LL ret = 0;
	for(LL i=1; i<=sqrt(N); i++){
		if(bef*i > N) break;
		ret += solve(now+1, i);
		ret %= MOD;
		//cout << "solve " << now << " " << bef << " " << i << " " << ret << endl;
	}
	//cout << ret << endl;
	if(bef*(sqrt(N)) <= N){
		if(now == K-1){
			ret += solve(now+2, 1)*max(0LL, N/bef-(LL)sqrt(N));
			ret %= MOD;
		}
		else{
			for(LL i=1; i<=sqrt(N); i++){
				ret += solve(now+2, i)*max(0LL, N/max(bef, i)-(LL)sqrt(N));
				ret %= MOD;
			}
		}
	}
	return ret;
}

int main(){
	cin >> N >> K;
	for(int i=K+1; i>=0; i--){
		sum[i][0] = 0;
		keisu[i][0] = 0;
		for(int j=1; j<=sqrt(N); j++){
			if(i >= K){
				dp[i][j] = 1;
			}
			else{
				dp[i][j] = 0;
				dp[i][j] += sum[i+1][min((LL)sqrt(N),N/j)];
				//cout << "dp " << i << " " << j << " " << min((LL)sqrt(N), N/j) << " " << dp[i][j] << endl;
				if(j*(LL)sqrt(N) <= N){
					if(i == K-1){
						dp[i][j] += dp[i+2][1] * max(0LL, N/j-(LL)sqrt(N));
					}
					else{
						dp[i][j] += sum[i+2][j]*max(0LL, N/j-(LL)sqrt(N));
						dp[i][j] += keisu[i+2][(LL)sqrt(N)]-keisu[i+2][j];
					}
				}
				dp[i][j] += 2*MOD;
				dp[i][j] %= MOD;
			}

			sum[i][j] = (dp[i][j] + sum[i][j-1]) % MOD;
			keisu[i][j] = (dp[i][j]*max(0LL,(N/j-(LL)sqrt(N))) + keisu[i][j-1]) % MOD;
		}
	}
	/*for(int i=0; i<K; i++){
		for(int j=1; j<=sqrt(N); j++){
			cout << solve(i, j) << " " << dp[i][j] << endl;
		}
	}*/
	//cout << dp[1][1] << endl;
	//cout << solve(1, 1) << endl;
	
	cout << dp[0][1] << endl;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vin(v,n) copy_n(istream_iterator<int>(cin),n,back_inserter(v));
#define all(v) v.begin(),v.end()
#define INF 2000000000
#define MOD 1000000007
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
// #define ll long long
#define ff first
#define ss second
#define f1(i,a,b) for(int i = a;i<b;i++)
#define f2(i,a,b) for(int i = a;i<=b;i++)

using namespace std;

const int N = 1e5+7;

vector<bool> vis;
vector<int> topst, dp, g[N];

void topo(int x)
{
	vis[x] = true;
	for(int ch:g[x])
		if(!vis[ch])
			topo(ch);
	topst.pb(x);
}

int findPath(int x)
{
	if(dp[x]!=-1)
		return dp[x];
	dp[x] = 0;
	for(int ch:g[x])
		dp[x] = max(dp[x], 1+findPath(ch));
	
	return dp[x];
}

int32_t main() 
{
	IOS;
	int n, m;
	cin >> n >> m;
	while(m--)
	{
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		// g[y].pb(x);
	}

	vis = vector<bool>(n+1, false);

	for(int i=1;i<=n;i++)
		if(!vis[i])
			topo(i);
		
	reverse(topst.begin(), topst.end());
	// for(int x:topst)
	// 	cout << x << " ";
	int ans = INT_MIN;
	dp = vector<int>(n+1, -1);
	for(int x:topst)
		ans = max(ans, findPath(x));
	// for(int x:dp)
	// 	cout << x << " ";
	
	cout << ans;


}

Measured memory_bytes: 11384
x = [list(map(str, input().split())) for i in range(2)]
a = int(x[0][0])
b = int(x[0][1])
s = x[1][0]
l = []
for i in range(a):
  l += s[i]
l[b-1] = l[b-1].lower()
my_result = l[0]
for i in range(1,a):
  my_result += l[i]
print(str(my_result))

Measured memory_bytes: 9116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        var m = new bool[n[1], n[0]];
        for(int i = 0; i < n[2]; i++)
        {
            var s = ReadLine().Split().Select(int.Parse).ToArray();
            switch(s[2])
            {
                case 1:
                    for(int y = 0; y < n[1]; y++)
                    {
                        for(int x = 0; x < s[0]; x++)
                        {
                            m[y, x] = true;
                        }
                    }
                    break;
                case 2:
                    for(int y = 0; y < n[1]; y++)
                    {
                        for(int x = s[0]; x < n[0]; x++)
                        {
                            m[y, x] = true;
                        }
                    }
                    break;
                case 3:
                    for(int y = 0; y < s[1]; y++)
                    {
                        for(int x = 0; x < n[0]; x++)
                        {
                            m[y, x] = true;
                        }
                    }
                    break;
                case 4:
                    for(int y = s[1]; y < n[1]; y++)
                    {
                        for(int x = 0; x < n[0]; x++)
                        {
                            m[y, x] = true;
                        }
                    }
                    break;
            }
        }
        var count = 0;
        for(int y = 0; y < n[1]; y++)
        {
            for(int x = 0; x < n[0]; x++)
            {
                if(!m[y, x])
                    count++;
            }
        }
        WriteLine(count);
    }
}



Measured memory_bytes: 18908
#include <stdio.h>
#include <stdint.h>
typedef int64_t i64;
#define SIZE 100001

int main(void){
    int n, i, a, count[SIZE] = {0}, q, b, c;
    i64 sum = 0;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &a);
        sum += a;
        count[a]++;
    }
    scanf("%d", &q);
    for(i = 0; i < q; i++){
        scanf("%d %d", &b, &c);
        sum += (c - b) * count[b];
        count[c] += count[b];
        count[b] = 0;
        printf("%ld\n", sum);
    }
    return 0;
}

Measured memory_bytes: 2044
s=input().lower()
cnt=0
while True:
    l=input().split()
    if l[0]=='END_OF_TEXT': break
    for i in range(len(l)):
        lg=len(l[i])-1
        if not l[i][lg].isalpha(): l[i]=l[i][:lg]
        cnt+=(s==l[i].lower())
print(cnt)

Measured memory_bytes: 7452
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC170D
//ABC170C
//ABC170B
int main(void) {
  int x, y, n, k, i, cou=0, tmp;
  scanf("%d %d", &x, &y);

  if(2*x<=y&&4*x>=y&&y%2==0) printf("Yes");
  else printf("No");
}

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

int main() {
	char s[200] = "";
	char p[100] = "";
	char temp[100] = "";

	scanf("%s", temp);
	sprintf(s, "%s%s", temp, temp);
	scanf("%s", p);

	int flag = 0;
	for (int i = 0; i < strlen(temp) + strlen(p); i++) {
		if (strncmp(&s[i], p, strlen(p)) == 0) {
			flag = 1;
		}
	}

	if (flag == 1) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1852
# D - Not Divisible

N = int(input())
A = list(int(a) for a in input().split())
A.sort()

M = max(A)
is_D = [0] * (M+1)
for i, a in enumerate(A):
    if is_D[a]:
        is_D[a] = 2
        continue
    for j in range(a, M+1, a):
        is_D[j] += 1

ans = 0
for a in A:
    if is_D[a] == 1:
        ans += 1
print(ans)

Measured memory_bytes: 32296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)

int main() {
    // your code goes here
    ll n,a[200005],dpa[200005],dpb[200005],dp[200005],ans,mm;
    cin >> n;
    rep(i,1,n) cin >> a[i];
    if(n%2==0){
        dpa[n+2]=0;
        for(ll i=n;i>0;i=i-2){
            dpa[i]=dpa[i+2]+a[i];
        }
        dpb[1]=a[1];
        for(ll i=3;i<=n;i=i+2){
            dpb[i]=dpb[i-2]+a[i];
        }
        ans=dpa[2];
        for(ll i=1;i<=n;i=i+2){
            if(ans<dpa[i+3]+dpb[i]) ans=dpa[i+3]+dpb[i];
        }
    } else {
        dpa[1]=a[1];
        for(ll i=3;i<=n;i=i+2) dpa[i]=dpa[i-2]+a[i];
        dpa[n+2]=dpa[n];
        dp[0]=0;
        if(a[1]>a[2]) dp[2]=a[1];
        else dp[2]=a[2];
        for(ll i=4;i<=n;i=i+2){
            dp[i]=dp[i-2]+a[i];
            if(dp[i]<dpa[i-1]) dp[i]=dpa[i-1];
        }
        ans=dpa[n]-a[1];
        for(ll i=n;i>2;i=i-2){
            mm=dpa[n+2]-dpa[i]+a[i-1]+dp[i-3];
            if(ans<mm) ans=mm;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	int A,B,T;
	cin >> A >> B >> T;
	int i=1;
	int sum=0;
	while(A*i<=T){
		sum += B;
		i++;
	}
	cout << sum << endl;
}

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

int n,a,b;
int A[100002]={},B[100002]={};

int main()
{
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    A[a]++;
    B[b+1]++;
  }
  int sum=1,ans=0;
  for(int i=1;i<100002;i++){
    sum+=(A[i]-B[i]);
    //if(i<=10)cout<<i<<" "<<sum<<endl;
    if(i<=sum)ans=i;
  }
  cout<<ans-1<<endl;
  return 0;
}

Measured memory_bytes: 1944
function Main(input) {
  const data = input.split("\n").slice(0, 5).map(val => parseInt(val, 10));
  var min = data.map(function(i) {
    if(i%10 === 0) {
      return 0;
    } else {
      return (10 - i%10)
    }
  });
  var max = Math.max(...min);
  var sum = 0;
  data.forEach(function(e) {
    sum += e;
  });
  min.forEach(function(f) {
    sum += f;
  });
  var result = sum + max;

  console.log(parseInt(sum-max, 10));

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 100005;
vector<int> g[N];
int a[N], b[N], c[N];

void dfs(int v, int p, int col){
	int cind = 1;
	for(auto ind : g[v]){
		if(cind == col)cind++;
		int u = a[ind]^b[ind]^v;
		if(u != p){
			c[ind] = cind;
			dfs(u, v, cind);
			cind++;
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	for(int i = 1; i < n; i++){
		cin>>a[i]>>b[i];
		g[a[i]].push_back(i);
		g[b[i]].push_back(i);
	}
	int v = 1;
	for(int i = 2; i <= n; i++){
		if(g[i].size() > g[v].size())v = i;
	}
	dfs(v, -1, 0);
	int k = g[v].size();
	cout<<k<<'\n';
	for(int i = 1; i < n; i++){
		cout<<c[i]<<'\n';
	}

	return 0;
}

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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

class  UnionFind {
private:
	vector<int>par;
public:
	UnionFind(int n) {
		for (int i = 0; i < n; i++) {
			par.push_back(-1);
		}
	}

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	void unite(int x, int y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return;
	}
};

struct Edge {
	int a, b, cost;
	bool operator<(const Edge& o)const {
		return cost < o.cost;
	}
};

class Graph {
public:
	vector<Edge>es;

	int kruscal(int n) {
		sort(es.begin(), es.end());
		UnionFind uf(n);
		int min_cost = 0;
		for (int ei = 0; ei < es.size(); ei++) {
			Edge ed = es[ei];
			if (!uf.same(ed.a, ed.b)) {
				min_cost += ed.cost;
				uf.unite(ed.a, ed.b);
			}
		}
		return min_cost;
	}
};

signed main() {
	int n;
	cin >> n;
	P a[100005], b[100005];
	rep(i, n) {
		int x, y;
		cin >> x >> y;
		a[i] = P(x, i);
		b[i] = P(y, i);
	}
	sort(a, a + n), sort(b, b + n);
	Graph g;
	for (int i = 1; i < n; i++) {
		Edge e = { a[i - 1].second,a[i].second,abs(a[i].first - a[i - 1].first) };
		Edge f = { b[i - 1].second,b[i].second,abs(b[i].first - b[i - 1].first) };
		g.es.push_back(e);
		g.es.push_back(f);
	}
	cout << g.kruscal(n) << endl;

	return 0;
}


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

const int N = 1e5 + 33;
const int INF = -1e9 + 33;
struct fufs {
	int a, b, c;
}t[N];

int dp[N][3],n;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;	
	for(int i = 1; i <= n; i++) {
		cin >> t[i].a >> t[i].b >> t[i].c;	
		dp[i][0] = dp[i][1] = dp[i][2] = INF;
	}

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

	for(int i = 2; i <= n; i++) {
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + t[i].a;
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + t[i].b;
		dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + t[i].c;
	}
	
	cout << max(max(dp[n][0], dp[n][1]), dp[n][2]) ;
}


Measured memory_bytes: 2560
S=input()
N=len(S)
ans=[0]*N

cnt=1
idx=0
f=True   #True=R
for i in range(1,N):
    if f==True:
        if S[i]=="R":
            cnt+=1
        else:
            ans[i-1]+=(cnt+1)//2
            ans[i]=cnt//2
            cnt=1
            f=False
            idx=i
    else:
        if S[i]=="L":
            cnt+=1
        else:
            ans[idx]+=(cnt+1)//2
            ans[idx-1]+=cnt//2
            cnt=1

            f=True

ans[idx]+=(cnt+1)//2
ans[idx-1]+=cnt//2

print(*ans)


Measured memory_bytes: 6400
x,y = map(int, input().split())

A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]

if (x in A and y in A) or (x in B and y in B) or (x in C and y in C):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
using i64 = int64_t;
using namespace std;
int main() {
    int R;
    cin >> R;
    if(R < 1200) {
        cout << "ABC" << endl;
    } else if(R < 2800) {
        cout << "ARC" << endl;
    } else cout << "AGC" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;cin>>s>>t;
    ll ans = 0;
    for(int i=0; i<s.size(); i++){
        if(s[i]!=t[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    int a,b,c; cin >> a >> b >> c;
    bool ans = false;
    int tmp = a;
    rep(i,1000){
        if(tmp % b == c){
			ans = true;
            break;
        }
        tmp += a;
    }
    if(ans) cout << "YES";
    else cout << "NO";
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
typedef long long ll;
typedef long double ld;


#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll S[1000] = { 0 };
ll N,M,Q;


int main() {
	set<ll>A;
	cin >> Q;
	rep(i, Q) {
		ll a, b;
		cin >> a >> b;
		if (a==0) {
			A.insert(b);
			cout << A.size() << endl;
		}
		else if(a==1){
			if (A.find(b)!=A.end()) {
				cout << 1 << endl;
			}
			else {
				cout << 0 << endl;
			}
		}
		else {
			A.erase(b);
		}
	}
	return 0;
}





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

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

const long long INF = 1LL << 60;

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

  int mi = 1001001001;
  rep(i, n){
    int c, t; cin >> c >> t;
    if(t <= T) chmin(mi, c);
  }

  if(mi == 1001001001){
    cout << "TLE" << endl;
    return 0;
  }

  cout << mi << endl;

  return 0;
}


Measured memory_bytes: 256
x,y=map(int,input().split())
if (x==4 or x==6 or x==9 or x==11) and (y==4 or y==6 or y==9 or y==11):
    print('Yes')
elif (x==1 or x==3 or x==5 or x==7 or x==8 or x==10 or x==12) and (y==1 or y==3 or y==5 or y==7 or y==8 or y==10 or y==12):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>

int main(void){
	int n;
	std::cin >> n;
	
	char list[101][101] = {0};
	
	int ci, cn, cval;
	for(int i=0; i<n; i++){
		std::cin >> ci >> cn;
		for(int j=0; j<cn; j++){
			std::cin >> cval;
			list[ci][cval] = 1;
		}
	}
	
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			std::cout << (int)list[i][j];
			if(j!=n) std::cout << ' ';
		}
		std::cout << '\n';
	}
	
	return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <string>
using namespace std;
int main() {

	int n;
	string s, t;
	cin >> n >> s >> t;

	for (int i = 0; i < n * 2; i++) {
		if (i % 2 == 0) {
			cout << s[i / 2];
		}
		if (i % 2 == 1) {
			cout << t[i / 2];
		}

	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let n: usize = read();
    let a: Vec<usize> = read_vec();

    let mut now = 1;
    let mut ans = n;
    for &x in &a {
      if x == now {
        ans -= 1;
        now += 1;
      }
    }

    if ans == n {
       println!("{}", -1);
    } else {
      println!("{}", ans);
    }
}


Measured memory_bytes: 10492
d,e=[list(map(int,input().split()))for _ in range(2)]
e[3],e[4]=e[4],e[3]
t=0
for i in range(6):
 m={0:'012345',1:'152304',2:'215043',3:'310542',4:'402351',5:'513240'}[i]
 f=[d[int(j)]for j in m];f[3],f[4]=f[4],f[3]
 if f[0]==e[0]:
  f=f[1:5]*2
  for j in range(4):
   if f[j:j+4]==e[1:5]:t=1;break
print(('No','Yes')[t==1])

Measured memory_bytes: 5604
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <list>
using namespace std;

int main(){
  int n, tmp;
  while(cin >> n, n){
    list<int> a, b;
    bool submited[201];
    memset(submited, false, sizeof(submited));
    for(int i = 0 ; i < n ; i++){
      cin >> tmp;
      a.push_back(tmp);
      submited[tmp] = true;
    }
    
    for(int i = 1 ; i <= 2*n ; i++){
      if(!submited[i]) b.push_back(i);
    }
    
    a.sort();
    b.sort();
    
    int now = 0;
    bool turn = true;
    list<int>::iterator it;
    while(!(a.size() == 0) && !(b.size() == 0)){
      if(turn){
	it = upper_bound(a.begin(), a.end(), now);
	if(it == a.end()){
	  turn = false;
	  now = 0;
	  continue;
	}
	now = *it;
	a.remove(*it);
	turn = false;
      }
      else{
	it = upper_bound(b.begin(), b.end(), now);
	if(it == b.end()){
	  turn = true;
	  now = 0;
	  continue;
	}
	now = *it;
	b.remove(*it);
	turn = true;
      }
    }
    
    cout << b.size() << endl << a.size() << endl;
  }
  return 0;
}


  

Measured memory_bytes: 1200
while True:
    a, op, b= list(input().split())
    a = int(a)
    b = int(b)
    if op == "?":
        break
    elif op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a//b)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

//Union_Find
const ll max_n = 1e6+5;
ll ufpar[max_n], ufrank[max_n], ufnum[max_n];
//初期化忘れるな！
void init(ll n){
	rep(ii,0,n){
		ufpar[ii] = ii;
		ufrank[ii] = 0;
		ufnum[ii] = 1;
	}
}
ll ufind(ll x){
	if(ufpar[x] == x) {
		return x;
	} else {
		ll umm = ufind(ufpar[x]);
		return ufpar[x] = umm;
	}
}
bool unite(ll x, ll y){
	x = ufind(x);
	y = ufind(y);
	if(x == y) return false;
	if(ufrank[x] < ufrank[y]) swap(x,y);
	if(ufrank[x] == ufrank[y]) ufrank[y]++;
	ufpar[y] = x;
	ufnum[x] += ufnum[y];
	ufnum[y] = 0;
	return true;
}
//xとyが同じ連結成分か
bool usame(ll x, ll y){
	return ufind(x) == ufind(y);
}
//xを含む連結成分のサイズ
ll usz(ll x){
	return ufnum[ufind(x)];
}

int main() {
    // your code goes here
    ll n,q;
    cin >> n >> q;
    init(n);
    rep(r,1,q){
        ll a,b,c;
        cin >> a >> b >> c;
        if(a==0) unite(b,c);
        else cout << usame(b,c) << endl;
    }
    return 0;
}

Measured memory_bytes: 8156
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;


int main(){
    int a, b; cin >> a >> b;
    int ans = (a+b) % 24;

    cout << ans << endl;
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool OK = true;
  rep(i,n) {
    if(i%2==0 && s[i]=='L') OK = false;
    else if (i%2!=0 && s[i]=='R') OK = false;
  }
  if(OK) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

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

long long strToInt(const string &s) {
    long long res = 0;
    for (auto e : s) res = res * 10 + e - '0';
    return res;
}

long long calcDiff(const string &s, const string &news) {
    const int L = s.length();
    long long snum = strToInt(s), newsnum = strToInt(news);
    return min<long long>(llabs(snum - newsnum), powl(10, L) - llabs(snum - newsnum));
}

int main(void) {
    string s;
    cin >> s;
    vector<int> v(10);
    iota(begin(v), end(v), 0);
    string ans = s;
    const int L = s.length();
    long long diff = 0;
    do {
        string news = "";
        for (int i = 0; i < L; i++) {
            news += v[i] + '0';
        }
        const long long buf = calcDiff(s, news);
        if (diff < buf) {
            ans = news;
            diff = buf;
        } else if (diff == buf) {
            const long long newsnum = strToInt(news);
            const long long ansnum = strToInt(ans);
            if (newsnum < ansnum) {
                ans = news;
                diff = buf;
            }
        }
    } while (next_permutation(begin(v), end(v)));
    cout << ans << endl;
}

Measured memory_bytes: 3400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=10,INF=1<<29;

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

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    while(1){
        ll p,q;cin>>p>>q;
        
        q/=gcd(p,q);
        
        ll ans=1;
        
        for(ll i=2;i*i<=q;i++){
            if(q%i==0){
                ans*=i;
                
                while(q%i==0) q/=i;
            }
        }
        
        if(q!=1) ans*=q;
        
        cout<<ans<<endl;
        
        break;
    }
}



Measured memory_bytes: 3220
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int N, a, r{2};
  cin >> N;
  vector<int> A(N + 1);
  while (r--)
    for (int i = 1; i <= N; ++i) cin >> a, A[i] = a + max(A[i - 1], A[i]);
  cout << A[N] << endl;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll n ; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);

    ll cur = 1000, stock = 0, sell_timing = -1;

    rep(i,n){
        ll price = a.at(i);
        bool buy = 0;

        if(i==sell_timing){
            cur += stock * price;
            stock = 0;
            sell_timing = -1;
        }

        for(int j=i+1;j<n;j++){
            if(a.at(j)>price){
                buy = 1;
                sell_timing = j;
                break;
            }
        }
        for(int k=i+1;k<sell_timing;k++){
            if(a.at(k)<price){
                buy = 0;
                break;
            }
        }
        if(buy && !stock){
            stock = cur/price;
            cur -= stock * price;
        }
        //cout << i << " " << cur <<" " << stock << endl;
    }
    cout << cur << endl;
    return 0;
}

Measured memory_bytes: 3604