akhauriyash/Code-Regression huggingface dataset:
n, k = map(int, input().split())
R, S, P = map(int, input().split())
score = [P, R, S]
t = input()
INF = 10**9

ans = 0
for i in range(k):
    t2 = ""
    j = 0
    while i + j * k <= n-1:
        t2 += t[i+j*k]
        j += 1
    m = len(t2)
    dp = [[-INF, -INF, -INF] for _ in range(m+1)]
    for j in range(3):
        dp[0][j] = 0
    for x in range(m):
        for y in range(3):
            for z in range(3):
                if y != z:
                    if z == 0 and t2[x] == 'r':
                        dp[x+1][z] = max(dp[x+1][z], dp[x][y] + score[z])
                    if z == 1 and t2[x] == 's':
                        dp[x+1][z] = max(dp[x+1][z], dp[x][y] + score[z])
                    if z == 2 and t2[x] == 'p':
                        dp[x+1][z] = max(dp[x+1][z], dp[x][y] + score[z])
                    dp[x+1][z] = max(dp[x+1][z], dp[x][y])
    num = 0
    for z in range(3):
        num = max(num, dp[m][z])
    ans += num

print(ans)



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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

#define vi vector<int>
#define vll vector<long long>
#define ll long long
#define ull unsigned long long
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define nl cout<<'\n'
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pll pair<long long,long long>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define sll set<long long>
#define all(v) (v).begin(),(v).end()
#define Unique(x)           (x).erase(unique(all(x)), x.end())
#define v_present(vec,x)  (find(all(vec),x)!=(vec).end())
#define present(myset,x)    ((myset).find(x)!=(myset).end())
#define Cprint(c)  for(auto i:(c)) { cout<<i<<" "; } nl
#define trace2(x,y) cout<<x<<" "<<y<<endl;
#define trace3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define trace4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<endl;
ll mod = 1e9+7;
const int MAX = 1e5+5;
using namespace std;
ll dp[100005];

int main()
{
    FAST_IO;
    int n;
    cin>>n;
    int h[n+1];
    for(int i=1;i<=n;i++)
        cin>>h[i];
    dp[0]=0;
    dp[1]=0;
    dp[2]=dp[1]+abs(h[2]-h[1]);
    for(int i=3;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n];

    return 0;

}


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

typedef long long lli;

lli rec(int l, int r, vector<int> &A) {
  if(r-l <= 1) return 0;
  int m = (l+r)/2;
  lli res = rec(l, m, A) + rec(m, r, A);
  queue<int> a, b;
  for(int i = l; i < m; ++i) a.push(A[i]);
  for(int i = m; i < r; ++i) b.push(A[i]);
  int k = l;
  while(a.size() && b.size()) {
    if(a.front() <= b.front()) {
      A[k++] = a.front();
      a.pop();
    } else {
      A[k++] = b.front();
      b.pop();
      res += a.size();
    }
  }
  while(a.size()) {
    A[k++] = a.front();
    a.pop();
  }
  while(b.size()) {
    A[k++] = b.front();
    b.pop();
  }
  return res;
}

int main() {
  int n;
  vector<int> A;
  cin >> n;
  A.resize(n);
  for(int i = 0; i < n; ++i) cin >> A[i];
  cout << rec(0, n, A) << endl;
  return 0;
}

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

if (y - 2 * x) % 2 == 0:
    b = (y - 2 * x) // 2
    a = x - b
    if b >= 0 and a >= 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 9176
list=input().split()
w=int(list[0])
h=int(list[1])
x=int(list[2])
y=int(list[3])
r=int(list[4])

if w>=x+r and x-r>=0:
  if h>=y+r and y-r>=0:
    print("Yes")
  else:
    print("No")
else:
  print("No")


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

int main(){
  
  string a;
  cin >> a;
  
  if( a == "Sunny" ){
    
    cout << "Cloudy" << endl;
    
  }
  
  else if( a == "Cloudy" ){
    
    cout << "Rainy" << endl;
    
  }
  
  else{
    
    cout << "Sunny" << endl;
    
  }
  
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;



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

	int n,k;cin>>n>>k;

	if(k%2 ==0){

		ll a =n/k;
		ll b =(n+k/2)/k;

	writeln(a*a*a+b*b*b);
	}else {
		ll a =n/k;
		writeln(a*a*a);
	}



}



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

int main() {
	int N, M;
	int A[100][100];
	int B[100];
	int C;
	int total[100];
	int ans = 0;
	cin >> N >> M >> C;

	for (int i = 1; i <= 100;i++){
		total[i] = 0;
	}
	for (int i = 1; i <= M; i++) {
		cin >> B[i];
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			cin >> A[i][j];
			total[i] += A[i][j] * B[j];
		}
		if (total[i] + C > 0){
			ans++;
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let mut x: usize = iterator.next().unwrap().parse().unwrap();

    if x == 2 {
        return String::from("2")
    }

    if x % 2 == 0 {
        x += 1
    }

    loop {
        if is_prime(x) {
            return x.to_string();
        }
        x += 2;
    }
}

fn is_prime(x: usize) -> bool {
    let mut n = 3;

    while n < x / 2 {
        if x % n == 0 {
            return false;
        }
        n += 2;
    }
    return true;
}


#[test]
fn test() {
    assert_eq!(
        solve(
            r"20"
        ),
        "23"
    );
    assert_eq!(
        solve(
            r"2"
        ),
        "2"
    );
    assert_eq!(
        solve(
            r"99992"
        ),
        "100003"
    );
}


Measured memory_bytes: 4352
use std::io;
use std::str::FromStr;

fn main() {
    let mut buf = String::new();

    let _ = io::stdin().read_line(&mut buf);
    let vec : Vec<i64> = buf.split_whitespace().map(|x| i64::from_str(x).unwrap()).collect();
    let (a, b) = (vec[0], vec[1]);

    println!("{} {} {:.5}", a/b, a%b, a as f64 /b as f64);
}



Measured memory_bytes: 5052
# -*- coding: utf-8 -*-
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

lis = list(range(1,n+1))

per = itertools.permutations(lis, len(lis))

all = []
for v in per:
    all.append(v)

tp_p = tuple(p)
tp_q = tuple(q)

for i in range(len(all)):
    if tp_p == all[i]:
        a = i+1
    if tp_q == all[i]:
        b = i+1

print(abs(a-b))

Measured memory_bytes: 7924
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
using position = pair<int, int>;
using data = pair<int, pair<int, int>>;

struct UnionFind {
    vector<int> data; int sz;
    UnionFind(int sz) : data(sz, -1), sz(sz) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) == (y = root(y))) { return false; }
        if (data[x] > data[y]) { swap(x, y); }
        data[x] += data[y]; data[y] = x; sz--; return true;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() { return sz; }
};

int main() {
    int n;
    cin >> n;
    vector<position> a, b;
    vector<data> c;
    UnionFind uf(n);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        a.emplace_back(x, i);
        b.emplace_back(y, i);
    }
    
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    
    for (int i = 1; i < n; i++) {
        int dx = abs(a[i-1].first - a[i].first);
        int dy = abs(b[i-1].first - b[i].first);
        c.emplace_back(dx, make_pair(a[i-1].second, a[i].second));
        c.emplace_back(dy, make_pair(b[i-1].second, b[i].second));
    }
    
    sort(c.begin(), c.end());
    
    long long ans = 0;
    for (auto p : c) {
        int s, t; tie(s, t) = p.second;
        int cost = p.first;
        if (uf.unionSet(s, t)) ans += cost;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7528
#include <iostream>
#include <vector>
#include <string>
using namespace std;

class Node {
public:
  int key;
  Node* parent;
  Node* left;
  Node* right;
  Node(int key) {
    this->key = key;
    this->parent = NULL;
    this->left = NULL;
    this->right = NULL;
  }
  void append_left(Node* left) {
    this->left = left;
  }
  void append_right(Node* right) {
    this->right = right;
  }
  void append_parent(Node* parent) {
    this->parent = parent;
  }
};

Node* root;

void insert(int key) {
  Node* z = new Node(key);
  Node* cur = root; Node* x = root;
  while(cur != NULL) {
    x = cur;
    if(z->key > cur->key)
      cur = cur->right;
    else
      cur = cur->left;
  }
  if(z->key > x->key) {
    x->append_right(z);
  }
  else {
    x->append_left(z);
  }
  z->append_parent(x);
}
Node* find(int key) {
  Node* z = root;
  while(z != NULL) {
    if(key == z->key)
      return z;
    else if(key > z->key)
      z = z->right;
    else
      z = z->left;
  }
  return NULL;
}
void delete_node(Node *z) {
  if(z==NULL) return;

  int degree = 0;
  if(z->left != NULL) degree++;
  if(z->right != NULL) degree++;

  if(degree == 0) {
    Node* parent = z->parent;
    if(parent == NULL) {
      delete z;
      root = NULL;
      return;
    }
    if(parent->left == z) parent->left = NULL;
    else parent->right = NULL;
    delete z;
  }
  else if(degree == 1) {
    Node* parent = z->parent;
    Node* child;
    if(z->left != NULL) child = z->left;
    else child = z->right;
    if(parent == NULL) {
      root = child;
      root->parent = NULL;
      delete z;
      return;
    }
    if(parent->left == z) parent->left = child;
    else parent->right = child;
    child->parent = parent;
    delete z;
    return;
  }
  else if(degree == 2) {
    Node *y = z->right;
    while(y->left != NULL) {
      y = y->left;
    }
    z->key = y->key;
    delete_node(y);
  }
  return;
}

void print_crawl_preorder(Node* node) {
  if(node == NULL) return;
  cout << " " << node->key;
  if(node->left != NULL) {
    print_crawl_preorder(node->left);
  }
  if(node->right != NULL) {
    print_crawl_preorder(node->right);
  }
  return;
}
void print_crawl_inorder(Node* node) {
  if(node == NULL) return;
  if(node->left != NULL) {
    print_crawl_inorder(node->left);
  }
  cout << " " << node->key;
  if(node->right != NULL) {
    print_crawl_inorder(node->right);
  }
  return;
}

int main() {
  int n; cin >> n;
  root = NULL;
  for(int i=0;i<n;i++) {
    string command; cin >> command;
    if(command == "insert") {
      int key; cin >> key;
      if(root == NULL) {
        root = new Node(key);
      }
      else {
        insert(key);
      }
    }
    else if(command == "find") {
      int key; cin >> key;
      if(find(key) != NULL) cout << "yes" << endl;
      else cout << "no" << endl;
    }
    else if(command == "delete") {
      int key; cin >> key;
      delete_node(find(key));
    }
    else if(command == "print") {
      print_crawl_inorder(root); cout << endl;
      print_crawl_preorder(root); cout << endl;
    }
  }
}

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

#define ll long long
#define endl '\n'

void max_self(int &a, int b){ a = max(a, b);}
void min_self(int &a, int b){ a = min(a, b);}

void solve(){
	int n; cin>>n;
	vector< int > l(n);
	for(int &i : l) cin>>i;
	sort(l.begin(), l.end());
	int cnt = 0;
	for(int i = 0; i<n; i++){
		for(int j = i + 1; j<n; j++){
			for(int k = j + 1; k<n; k++){
				if(l[i] != l[j] && l[j] != l[k]) if(l[i] + l[j] > l[k]) cnt++;
			}
		}
	}
	cout<<cnt<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;// cin>>t;
	for(int i = 1; i<=t; i++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> 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,M;
    cin >> N >> M;
    ll K;
    cin >> K;
    
    vl A(N+1),B(M+1);
    A[0] = 0, B[0] = 0;
    rep(i,N){
        ll a;
        cin >> a;
        
        A[i+1] = A[i] + a;
    }
    rep(i,M){
        ll b;
        cin >> b;
        
        B[i+1] = B[i]+b;
    }
    
    int ans = 0;
    rep(i,N+1){
        int an = i;
        if(K < A[i]) break;
        int j = upbi(B,K-A[i]) - 1;
        chmax(ans,an+j);
        //cout << i csp j << endl;
    }
    
    cout << ans << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 6332
import itertools
import sys

input = sys.stdin.readline

maxn = 10000000000

X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

cand = []
for i, a in enumerate(A):
    for j, b in enumerate(B):
        for k, c in enumerate(C):
            if (i + 1) * (j + 1) * (k + 1) <= K:
                cand.append(a + b + c)
            else:
                break

cand.sort(reverse=True)
for k in range(K):
    print(cand[k])


Measured memory_bytes: 8772
//ABC 051-A
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;

int main() {
	int K, S, X, Y, Z, ans = 0;
	cin >> K >> S;

	for (Z = min(K, S); Z >= max(S - 2 * K, 0); Z--) {
		Y = min(S - Z, K);
		X = S - Z - Y;
		ans += Y - X + 1;
	}
	cout << ans << endl;
	system("pause");
}

Measured memory_bytes: 504
#!/usr/bin/env python3
import sys, math


def solve(a: int, b: int, x: int):
    r = 1/2 * a**2 * b
    if x >= r:
        if a**2*b-x != 0:
            tan = a**3/(2*(a**2*b-x))
        else:
            print(0)
            return
    else:
        tan = (2*x)/(a*b**2)
    print(90-math.degrees(math.atan(tan)))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    solve(a, b, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}

signed main(){
  int n; cin>>n;
	string s1,s2; cin>>s1>>s2;
	VI s;
	rep(i,n){
		if(s1[i]==s2[i]) s.PB(0);
		else{
			if(s1[i]==s1[i+1]) s.PB(1),i++;
		}
	}
	int m = s.size();
	ll ans = 1;
	rep(i,m){
		if(i==0){
			if(s[0]) ans*=6;
			else ans*=3;
		}else{
			if(s[i-1]==0) ans*=2;
			if(s[i-1] and s[i]) ans*=3;
			ans%=MOD;
		}
	}
	cout << ans << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

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

int main() {
  ll x, k, d;
  cin >> x >> k >> d;
  ll p = abs(x) / d;
  if (p >= k) {
    ll ans = min(abs(x - d * k), abs(x + d * k));
    cout << ans << endl;
    return 0;
  }

  if ((k - p) % 2 == 0) {
    ll ans = min(abs(x - d * p), abs(x + d * p));
    cout << ans << endl;
  } else {
    ll ans = min(abs(x - d * p), abs(x + d * p));
    ans = min(abs(ans + d), abs(ans - d));
    cout << ans << endl;
  }
  return 0;
}


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

const ll maxnode = 1e18;

int main() {
    int N; cin >> N;
    vector<ll> A(N+1);
    for (int i = 0; i <= N; i++) cin >> A[i];

    bool flag = true;
    vector<ll> possibility(N+1);
    possibility[0] = 1 - A[0];
    if (possibility[0] < 0) flag = false;

    for (int i = 1; i <= N; i++) 
    {
        possibility[i] = min(maxnode, possibility[i-1] * 2 - A[i]);
        if (possibility[i] < 0) flag = false;
    }

    // for (int i = 0; i <= N; i++) cout << possibility[i] << ' ';
    // cout << endl;

    ll node = 0, ans = 0;
    for (int i = N; 0 <= i; i--) 
    {
        node = min(node, possibility[i]) + A[i];
        ans += node;
    }

    if (flag) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 4844
package main

import (
	"fmt"
)

const mod = 1000000007

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	var ans int
	if n == m {
		f := factorial(n)
		ans = 2 * f * f
	} else if abs(n-m) == 1 {
		ans = factorial(n) * factorial(m)
	} else {
		ans = 0
	}
	fmt.Println(ans % mod)
}

func factorial(n int) int {
	v := 1
	for i := 0; i < n; i++ {
		v *= n - i
		v %= mod
	}
	return v
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


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

using namespace std;
#define N 111111

int n,k;
int a[N],dp[N];
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    for (int i=1; i<=n; i++) cin>>a[i];
    fill(dp,dp+N,-1);
    dp[1]=0;
    for (int i=2; i<=n; i++){
        for (int j=1; j<=k; j++){
            if (i-j==0) break;
            if (dp[i]==-1) dp[i]=abs(a[i]-a[i-j])+dp[i-j]; else
                dp[i]=min(dp[i],abs(a[i]-a[i-j])+dp[i-j]);
        }
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define ll long long
using namespace std;
const int MOD = 1000000007;
const long long INF = 1LL << 60;
map<ll, ll> primary_map;
void factorize(ll num) {
  for (ll i = 2; i * i <= num; i++) {
    if (num % i != 0) continue;
    ll ex = 0;
    while (num % i == 0) {
      ex++;
      num /= i;
    }
    primary_map[i] += ex;
  }
  if (num != 1) primary_map[num] += 1;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll num = 1;
  for (ll i = 2; i <= n; i++) {
    factorize(i);
  }
  ll ans = 1;
  auto begin = primary_map.begin(), end = primary_map.end();
  for (auto iter = begin; iter != end; iter++) {
    ans *= iter->second + 1;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
ll h[100000];
ll dp[100000];
int main() {
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> h[i];
	fill(dp, dp + N, 1LL << 60);
	dp[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 1; j <= K; j++) {
			if (i + j >= N) break;
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}
	cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;

	if (N % 2 == 1) cout << N * 2 << endl;
	else cout << N << endl;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
int i, j, n, m, k, ans;
int a[200000];
int b[200000];

int main() {
    scanf(" %d %d", &n, &k);
    rep(0,n) {
        scanf(" %d", &a[i]);
    }
    repj(0,k) {
        rep(0, n) b[i] = 0;
        rep(0, n) {
            int l = max(0, i-a[i]);
            int r = min(n-1, i+a[i]);
            b[l]++;
            if (r+1<n) b[r+1]--;
        }
        bool saturated = b[0] == n;
        a[0] = b[0];
        rep(1,n) {
            b[i]+=b[i-1];
            a[i] = b[i];
            saturated = saturated && b[i] == n;
        }
        if (saturated) break;
    }

    rep(0, n) printf("%d ", b[i]);
    printf("\n");
}

Measured memory_bytes: 5380
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long


int main()
{
	string s;
	cin >> s;
	for (int i = s.size()-1; i >= 0; i--)
	{
		cout << s[i];
	}
	cout << endl;
	return 0;

}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N>>A;
    cout<<N - A + 1<<endl;
}


Measured memory_bytes: 256
import java.util.*;

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

		int n = sc.nextInt();

		int a[] = new int[n];
		int cnt1[] = new int[100001];
		int cnt2[] = new int[100001];
		
		for(int i=0;i<n;i++){
			a[i] = sc.nextInt();
		}

		for(int i=0;i<n;i+=2){
			cnt1[a[i]]++;
			cnt2[a[i+1]]++;				
		}

		int max1=0, max2=0;
		for(int i=0;i<100001;i++){
			if(cnt1[i] >= cnt1[max1])
				max1 = i;
			if(cnt2[i] >= cnt2[max2])
				max2 = i;
		}

		if(max1 == max2){
			int t1 = 0, t2=0;
			for(int i=0;i<100001;i++){
				if(cnt1[i] >= cnt1[t1] && i != max2)
					t1 = i;
				if(cnt2[i] >= cnt2[t2] && i != max1)
					t2 = i;
			}
			
			System.out.println(Math.min((n/2-cnt1[max1]) + (n/2-cnt2[t2]), 
				(n/2-cnt1[t1]) + (n/2-cnt2[max2])));
		}
		else{
			System.out.print((n/2-cnt1[max1]) + (n/2-cnt2[max2]));
		}
	}
}

Measured memory_bytes: 61700
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int N,A,B;
int x,y,z;
int len;
char S[100001];

int main(void){

	scanf("%d%d%d",&N,&A,&B);
	scanf("%s",S);
	len=strlen(S);

	for (int i = 0; i < len; ++i)
	{
		if(S[i]=='a'){
			if(x+y<A+B){
				printf("Yes\n");
				x++;
			}else{
				printf("No\n");
			}
		}else
		if(S[i]=='b'){
			z++;
			if(x+y<A+B&&z<=B){
				printf("Yes\n");
				y++;
			}else{
				printf("No\n");
			}
		}else{
			printf("No\n");
		}
	}

	return 0;

}


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

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

  int a, b;
  cin >> a >> b;
  string s_a, s_b;
  rep(i, b) { s_a += to_string(a); }
  rep(i, a) { s_b += to_string(b); }
  if (s_a < s_b) {
    cout << s_a << endl;
  } else {
    cout << s_b << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n;
  scanf("%d",&n);
  
  int a[n+1] , b[n];
  long long count = 0;
  for(int i = 0;i < n+1;i ++){
    scanf("%d",&a[i]);
    count += a[i];
  }
  
  for(int i = 0;i < n;i ++){
    scanf("%d",&b[i]);
  }
  
  long long geki = 0;
  
  for(int i = 0;i < n;i ++){
    if(a[i] < b[i]){
      int temp = b[i] - a[i];
      a[i] = 0;
      if(a[i+1] >= temp){
        a[i+1] -= temp;
      }
      else{
        a[i +1] = 0;
      }
    }
    else{
      a[i] -= b[i];
    }
    geki += a[i];
  }
  
  geki += a[n];
  
  printf("%lld\n",count - geki);
  
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <stack>
#include <vector>
#include <set>
#include <sstream>
using namespace std;

int main() {
  string c;
  stack<int> nums;
  while(cin >> c) {
    if(set<string>({"*", "+", "-"}).count(c)) {
      int b = nums.top();
      nums.pop();
      int a = nums.top();
      nums.pop();
      nums.push(
          (c == "+") ? a + b :
          (c == "-") ? a - b :
          a * b
      );
    } else {
      stringstream ss;
      ss << c;
      int n;
      ss >> n;
      nums.push(n);
    }
  }
  cout << nums.top() << endl;
  return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

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

    int A = 1;
    rep(i, N) {
        A = min(A * 2, A + K);
    }

    cout << A << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

h,w = map(int,input().split())
S = [[] for _ in range(h)]
for i in range(h):
    S[i] = list(input())
ANS = [[0]*(w+2) for _ in range(h+2)]
for i in range(h):
    for j in range(w):
        if S[i][j] == "#":
            ANS[i+1][j+1] = "#"
            for k,l in [(i,j),(i,j+1),(i,j+2),(i+1,j),(i+1,j+2),(i+2,j),(i+2,j+1),(i+2,j+2)]:
                if not ANS[k][l] == "#": ANS[k][l] += 1
for i in range(1,h+1):
    a = map(str,ANS[i][1:-1])
    print("".join(a))


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

int N, t, x, y, nx, ny;

int main() {
    cin >> N;
    string ans = "Yes";
    while (N--) {
        cin >> t >> x >> y;
        int dist = abs(nx - x) + abs(ny - y);
        if (dist > t || (dist - t) % 2) ans = "No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pp;

int dp[100001];int n,k;
int a[100001];

int f(int k1)
{
	if(dp[k1]!=-1)
	return dp[k1];
    int b=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]<=k1)
        {
            if(f(k1-a[i])==0)
            {
                b=1;break;
            }
        }
    }
    dp[k1]=b;
    return b;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


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

	for(int i=0;i<=k;i++)
	dp[i]=-1;
	
	int res=f(k);
	if(res==1)
    cout<<"First"<<"\n";
    else
    cout<<"Second"<<"\n";

}


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

int main(){

    int A,B;
    cin >> A >> B;
    int cnt = 0;

    for(int i = A;i<=B;i++){
        int O = i,temp = i,R=0;

        //逆にする
        while(true){
            R += O%10;
            O /= 10;
            if(O == 0) break;
            else R *= 10;
        }

        if(temp == R) cnt += 1;

    }

    cout << cnt << endl;
    
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string s;

    cin >> s;

    string top_s = s.substr(0, 2);
    string back_s = s.substr(2, 2);

    int top = atoi(top_s.c_str());
    int back = atoi(back_s.c_str());

    if (top > 0 && top < 13) {
        if (back >0 && back < 13) {
            cout << "AMBIGUOUS" << endl;
            return 0;
        }
        cout << "MMYY" << endl;
    }
    else if (back > 0 && back < 13) {
        cout << "YYMM" << endl;
    }
    else cout << "NA" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

// Data structrue for card
struct card {
	char c;
	int value;
};

// Print cards
void print(struct card C[], int n)
{
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << C[i].c << C[i].value;
	}
	cout << endl;
}


// Sort by bubble sort
void bubbleSort(struct card C[], int n)
{
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; j > i; j--) {
			// Cheack if the order of card is corrent
			if (C[j].value < C[j - 1].value) {
				// Swap
				struct card tmp = C[j];
				C[j] = C[j - 1];
				C[j - 1] = tmp;
			}
		}
	}
}

// Sort by selection sort
void selectionSort(struct card C[], int n)
{
	for (int i = 0; i < n; i++) {
		int min = i;
		for (int j = i; j < n; j++) {
			if (C[j].value < C[min].value)
				min = j;
		}
		if (min != i) {
			struct card tmp = C[min];
			C[min] = C[i];
			C[i] = tmp;
		}
	}
}


// Cheack if selection sort is stable
bool isStable(struct card C1[], struct card C2[],int n) {
	for (int i = 0; i < n; i++) {
		if (C1[i].c != C2[i].c)
			return false;
	}
	return true;
}

// MAIN FUNCTION
int main()
{
	// Input data
	// Variable for the number of cards
	int n;
	struct card C1[36],C2[36];
	cin >> n;
	// Input n cards
	for (int i = 0; i < n; i++) {
		cin >> C1[i].c >> C1[i].value;
		C2[i].c = C1[i].c;
		C2[i].value = C1[i].value;
	}

	// Do bubble sort
	bubbleSort(C1, n);
	
	// Print cards
	print(C1, n);
	// Print "Stable"
	cout << "Stable" << endl;

	// Do selection sort
	selectionSort(C2, n);
	//Print result
	print(C2, n);

	// Cheack if selection sort is stable
	if (isStable(C1, C2, n))
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  map<int, int> mp;
  for (int i = 0, t; i < n; i++) {
    cin >> t;
    mp[t]++;
  }
  int mx = 0;
  for (int i = 0; i <= 100000; i++) {
    mx = max(mx, mp[i] + mp[i - 1] + mp[i + 1]);
  }
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 4992
#グラフの連結成分を調べる
def Graph(ab):
    G=[[] for i in range(n)]
    for a,b in ab:
        G[a-1].append(b)
        G[b-1].append(a)
    return G
#BFS
from collections import deque
def bfs(G):
    q=deque()
    q.append((1, -1))
    log = [0] * n
    log[0] = 1
    while q:
        #qの先頭を取り出す
        V, P = q.popleft()
        for new_v in G[V - 1]:
            if new_v == P:continue
            if log[new_v - 1] != 0:continue
            log[new_v - 1] = V
            q.append((new_v, V))

    return log



n, m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
G = Graph(ab)
log = bfs(G)
print('Yes')
print(*log[1:], sep='\n')

Measured memory_bytes: 129904
#include<stdio.h>
#include<math.h>
#define PI 3.14159265358979323846264338327950L

int main(void) {
  int a,b,h,m;
  scanf("%d%d%d%d", &a, &b, &h, &m);
  
  long double rad = PI* 2 * (
  (long double)h/ 12.0 + ((long double)m/ 60.0) / 12.0 - (long double)m/ 60.0);
  long double rsq= (long double)(a*a+b*b) - (long double)(2 *a*b) *cosl(rad);
  
  printf("%20.20Lf\n",sqrtl(rsq));
  
  return 0;
}

Measured memory_bytes: 2496
import sys
import numpy as np
readline = sys.stdin.buffer.readline

N,K = map(int,readline().split())
people = np.array(readline().split(),np.int64)
food = np.array(readline().split(),np.int64)
 
people.sort()
food.sort()
food=food[::-1]

#2分探索　Kの値で
_max = max(people)*max(food)
_min = 0

while _max>_min:
  mean = (_max+_min)//2
  # 各人が修行をする回数の配列　負の値もでる
  _K = np.maximum(0,people - mean//food).sum()
  if _K > K:
    _min = mean+1
  else:
    _max = mean
    
print(_max)
  

Measured memory_bytes: 26172
#define errOut(s) \
  { std::cerr << __LINE__ << ":" << #s << ":" << (s) << std::endl; }

#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
//#include <boost/multi_array.hpp>
//#include <boost/optional.hpp>
//#include <boost/range/adaptors.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

static std::string const YES = "Yes";
static std::string const NO = "No";

bool solve(int64_t d, int64_t t, int64_t s) { return d <= t * s; }

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t d;
  std::cin >> d;
  int64_t t;
  std::cin >> t;
  int64_t s;
  std::cin >> s;
  auto const res = solve(d, t, s);
  std::cout << (res ? YES : NO) << std::endl;
  return 0;
}


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

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

  if(n < 10) {
    cout << n;
    return 0;
  }else if(n < 100) {
    cout << 9;
  }else if(n < 1000) {
    cout << 9 + (n - 100 + 1);
  }else if(n < 10000) {
    cout << 9 + 900;
  }else if(n < 100000) {
    cout << 9 + 900 + (n - 10000 + 1);
  }else if(n == 100000) {
    cout << 9 + 900 + 90000;
  }

  // int cnt = 0;
  // int x;
  // for(int i = 1; n/i > 0; i *= 10) {
  //   cnt++;
  //   x = i;
  // }
  //
  // int ans = 9;
  //
  //
  // if(cnt % 2 != 0) ans += n%x + 1;
  //
  // cout << ans << endl;
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
from bisect import bisect, bisect_left
from itertools import product, permutations, combinations
from fractions import gcd
import sys
sys.setrecursionlimit(int(1e7))

def inpl(): return list(map(int, input().split()))

N = int(input())
S = input()

ans = 1e10
changes = S.count("#")
ans = min(changes, ans)
for i in range(N-1, -1,-1):
    if S[i] == ".":
        changes += 1
    else:
        changes -= 1
    ans = min(ans, changes)
print(ans)


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

int main(){
    string s;
    cin >> s;
    cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}


vector<vector<ll>> edge;

ll vis[100005];
ll bfs(int s, int K) {
	ll ans = K;
	queue<ll> q;

	q.push(s);
	vis[s] = 1;
	
	ll oft;
	while (!q.empty()) {
		ll cur = q.front();
		q.pop();
		vis[cur] = 1;

		if (cur == s)
			oft = 1;
		else
			oft = 2;

		ll ind = 0;
		rep(i, edge[cur].size()) {
			if (vis[edge[cur][i]] == 0) {
				ans = ans * max((K - oft - ind), 0);
				ans %= mod;
				ind += 1;
				q.push(edge[cur][i]);
			}
		}

	}
	return ans;
}


int main() {
	ll N, K;

	cin >> N >> K;
	edge.resize(N);

	rep(i, N - 1) {
		ll a, b;

		cin >> a >> b;
		a--, b--;
		edge[a].push_back(b);
		edge[b].push_back(a);

	}



	

	cout << bfs(0, K) << endl;
	return 0;
}

Measured memory_bytes: 8052
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Net;
using System.Numerics;
using System.Reflection.Metadata;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics.X86;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;

namespace AtCoder
{
	public class Program
	{
		static void Main()
		{
			int n = int.Parse(Console.ReadLine());
			var a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = int.Parse(Console.ReadLine()) - 1;
			}

			var done = new HashSet<int>();
			
			int ans = 0;
			bool ok = false;
			int current = 0;
			while (done.Contains(current) == false) {
				++ans;
				done.Add(current);
				current = a[current];
				if (current == 1) {
					ok = true;
					break;
				}
			}

			Console.WriteLine(ok ? ans : -1);
		}
	}
}


Measured memory_bytes: 34832
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

int main(void)
{
  int n, m, lr[100001][2];
  scanf("%d %d", &n, &m);

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

  int first = 1, last = n;
  for (i = 0; i < m; i++)
  {
    first = max(lr[i][0], first);
    last = min(lr[i][1], last);
  }

  printf("%d\n", max(last - first + 1, 0));
  return 0;
}


Measured memory_bytes: 896
A,B,C,D = map(int,input().split())
if A%D == 0 and C%B==0:
    if A/D < C/B:
        print("No")
    else:
        print("Yes")
elif A%D!=0 and C%B==0:
    if (A//D)+1 < C/B:
        print("No")
    else:
        print("Yes")
elif A%D==0 and C%B!=0:
    if A/D < (C//B)+1:
        print("No")
    else:
        print("Yes")
else:
    if (A//D)+1 < (C//B)+1:
        print("No")
    else:
        print("Yes")

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;
#define debug(x) cerr << #x << ": " << (x) << "\n";

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

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

  int k;
  cin >> k;

  string ans;
  int cnt = 0;
  queue<string> q;
  q.push("1");
  q.push("2");
  q.push("3");
  q.push("4");
  q.push("5");
  q.push("6");
  q.push("7");
  q.push("8");
  q.push("9");
  while (cnt <= k) {
    string s2 = q.front(); q.pop();
    cnt++;
    if (cnt == k) {
      ans = s2;
      break;
    }
    char last = s2[s2.size()-1];
    int num = last - '0';
    if (num == 0) {
      q.push(s2+'0');
      q.push(s2+'1');
    } else if (num == 9) {
      q.push(s2+'8');
      q.push(s2+'9');
    } else {
      char a = (num-1) + '0';
      char b = (num) + '0';
      char c = (num+1) + '0';
      q.push(s2+a);
      q.push(s2+b);
      q.push(s2+c);
    }
  }

  cout << ans << endl;




  return 0;
};


Measured memory_bytes: 13824
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, h, m float64
	fmt.Scan(&a, &b, &h, &m)

	Adeg := h * 30 + m/60 * 30
	Bdeg := m/5 * 30

	Deg := math.Abs(Adeg-Bdeg)
	if Deg > 180 {
		Deg = 360 - Deg
	}

	X := math.Pow(a,2) + math.Pow(b,2) - 2*a*b*math.Cos(Deg / 180 * math.Pi)
	
	fmt.Println(math.Sqrt(X))
}


Measured memory_bytes: 1824
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cstdio>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef pair<ll,ll> P;
int d,l;
int main(void){
    cin>>d>>l;
    cout<<d/l+d%l<<endl;
}



Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
using namespace std;
typedef long long unsigned int llui_t;
typedef long long int lli_t;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

/* inputs */
llui_t X, Y;

int main() {
    cin >> X >> Y;

    llui_t n = 1;
    llui_t x = X;
    while(1) {
        x *= 2;
        if(x <= Y) {
            n++;
        } else {
            break;
        }
    }
	cout << n << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>
using namespace std;

int main(int argc,char** argv)
{

	int n,count=0;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	for(int i = 0; i < n-1; i++){
		if(a[i] != a[i+1]){
			count++;
		}
	}
	cout << count + 1 <<endl;


	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    string S, T;
    ll al[26], i, j, k=-1, judge=0;
    char ch, ch2;

    cin >> S;

    for(i=0; i<26; i++){
        al[i] = 0;
    }

    for(i=0; i<S.size(); i++){
        al[S[i]-'a']++;
    }

    i = 0;
    while(al[i]==1){
        i++;
        if(al[i]==0){
            j = i;
            break;
        }
        else if(i==25){
            judge = 1;
            break;
        }
    }

    if(judge==1){ // 26文字のとき
        for(i=25; i>=1; i--){
            if(S[i-1] < S[i]){
                k = i-1;
                break;
            }
        }

        if(k==-1) cout << -1 << endl;
        else{
            T = S.substr(0, k);
            ch = S[k];
            ch2 = ch;
            for(i=k+1; i<=25; i++){
                if(ch==ch2 && S[i]>ch){
                    ch = S[i];
                }
                else if(ch!=ch2 && ch2<S[i] && S[i]<ch){
                    ch = S[i];
                }
            }
            cout << T << ch << endl;
        }
    }

    else{ // 25文字以下のとき
        ch = 'a'+j;

        cout << S << ch << endl;
    }

    return 0;
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

string S;

int dfs(string &S, vector<int> &seen, int i) {
    int res = 0;
    if (seen[i]!=0) return seen[i];
    else if (S[i]=='R' && S[i+1]=='L') {
        seen[i] = 1;
        return 1;    
    }
    else if (S[i]=='L' && S[i-1]=='R') {
        seen[i] = 1;
        return 1;
    }
    else {
        if (S[i]=='R') {
            res = dfs(S,seen,i+1) + 1;
            seen[i] = res;
        }
        else {
            res = dfs(S,seen,i-1) + 1;
            seen[i] = res;
        }
        return res;
    }
}

int main(){
    cin >> S;
    vector<int> seen(S.size(),0);
    int N = seen.size();
    int ans[N] = {};
    rep(i,N) {
        seen[i] = dfs(S,seen,i);
        if (S[i]=='R' && seen[i]%2==0) ans[i+seen[i]]++;
        else if (S[i]=='R' && seen[i]%2!=0) ans[i+seen[i]-1]++;
        else if (S[i]=='L' && seen[i]%2==0) ans[i-seen[i]]++;
        else ans[i-seen[i]+1]++;
    }
    rep(i,N) {
        cout << ans[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 7424