akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
    int n;
    cin>>n;
    vector<int> t(n),x(n),y(n);
    rep(i,n){
        cin>>t[i]>>x[i]>>y[i];
    }
    bool ans=true;
    rep(i,n){
        if((x[i]+y[i])%2!=t[i]%2){
            ans =false;
        }
        if(x[i]+y[i]>t[i]){
            ans = false;
        }
    }
    if(ans){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    cout << "ABC";
    cout << N << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin >> n;
  vector<ll> t(19),f(26);
  t[0]=1;
  f[0]=2;
  for(int i=1;i<=18;i++){
    t[i]=10*t[i-1];
  }
  for(int i=1;i<=25;i++){
    f[i]=5*f[i-1];
  }
  ll st=0,sf=0;
  for(ll i=1;i<=18;i++){
    st+=n/t[i];
  }
  for(ll i=1;i<=25;i++){
    sf+=n/f[i];
  }
  if(n%2==0){
    cout << sf << endl;
  }
  else{
    cout << 0 << endl;
  }
}

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

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


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in();
  string s;
  cin >> s;

  int cnt = 0;

  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'E') cnt++;
  }

  int ans = inf;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'E') cnt--;
    chmin(ans, sum + cnt);
    if (s[i] == 'W') sum++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 720
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
 
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();
    int sum = a+ b ;
    if(sum > a+c){
      sum = a+c;
    }
    if(sum > b+c){
      sum = b + c;
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 21844
nums = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(nums[k-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 2000;
const int INF = 1e9 + 5;

int a[MAXN+5], b[MAXN+5], N, K, Q;
vector<int> v;
priority_queue<int, vector<int>, greater<int>> pq;

void extract() {
	while (pq.size() >= K) {
		v.push_back(pq.top());
		pq.pop();
	}
	while (!pq.empty()) pq.pop();
}

int test(int x) {
	v.clear();
	while (!pq.empty()) pq.pop();
	for (int i = 0; i <= N; i++) {
		if (i == N || a[i] < x) {
			extract();
			continue;
		}
		
		pq.push(a[i]);
	}
	
	assert(pq.empty());
	sort(v.begin(), v.end());
	if (v.size() < Q) return INF;
	return v[Q - 1] - v[0];
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> K >> Q;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	
	int ans = INF;
	sort(b, b + N);
	for (int i = 0; N - i >= Q; i++) {
		ans = min(ans, test(b[i]));
	}
	
	assert(ans != INF);
	cout << ans << "\n";
	/**** Note MAXN ****/
}


Measured memory_bytes: 256
import time,sys
sys.setrecursionlimit(1000000000)

#jが残り
def search(i,j):

    if(memo[i][j]>=0):
        return memo[i][j]

    if i==N :
        res=0
    elif j<items[i][1]:
        #いれない。
        res = search(i+1,j)
    else:
        #            いれなかった場合       いれた場合、重さを引いて価値を追加
        res = max( search(i+1,j), search(i+1,j-items[i][1])+items[i][0] )
    memo[i][j] =res
    return res

N,W = map(int,input().split())
res=0
items=[]
for i in range(N) :
    array =list(map(int,input().split()))
    items.append(array)
# memo = np.arange(N*W).reshape(N,W)
memo=[[-1 for i in range(W+1)] for j in range(N+1)]
# print(*memo,sep="\n")

knapsack=0
print(search(0,W))




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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 998244353;

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



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

	VLL v;

	ll a = 1;
	ll sum = 0;

	if (n == 3) {
		cout << 2 << ' ' << 5 << ' ' << 63 << endl;
		return 0;
	}
	if (n == 4) {
		cout << 2 << ' ' << 5 << ' ' << 20 << ' ' << 63 << endl;
		return 0;
	}
	if (n == 5) {
		cout << 2 << ' ' << 5 << ' ' << 20 << ' ' << 30 << ' ' << 63 << endl;
		return 0;
	}

	REP(i, n) {
		while (true) {
			if (a % 2 == 0 || a % 3 == 0)break;
			a++;
		}
		v.push_back(a);
		sum += a;
		a++;
	}
	a++;

	if (sum % 6 == 0) {
		REP(i, n)cout << v[i] << ' ';
	}
	else if (sum % 6 == 2) {
		REP(i, n) {
			if (v[i] != 8)cout << v[i] << ' ';
		}
		if (a % 6 != 0) {
			a += 6 - a % 6;
		}
		cout << a << endl;
	}
	else if (sum % 6 == 3) {
		REP(i, n) {
			if (v[i] != 9)cout << v[i] << ' ';
		}
		if (a % 6 != 0) {
			a += 6 - a % 6;
		}
		cout << a << endl;
	}
	else {
		REP(i, n) {
			if (v[i] != 9)cout << v[i] << ' ';
		}
		while (true) {
			if (a % 6 == 4)break;
			a++;
		}
		cout << a << endl;
	}


	

}




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

int main(){
  
  double a, b;
  
  cin >> a >> b;
  
  double k = (a + b) / 2 + 0.5;
  
  int w = k / 1;
  
  cout << w << endl;
  
  return 0;
  
}

Measured memory_bytes: 3680
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long res = 0;
    for (int i = 0; i <= n; i++) {
      if (i%3 != 0 && i%5 != 0) {
        res += i;
      }
    }
    System.out.println(res);
    sc.close();
  }
}

Measured memory_bytes: 35764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main() {
    ll H, W, m;
    cin >> H >> W >> m;

    vector<ll> h(m), hcnt(H, 0);
    vector<ll> w(m), wcnt(W, 0);
    for(int i = 0; i < m; i++){
        cin >> h[i] >> w[i];
        h[i]--; w[i]--;
        hcnt[h[i]]++; wcnt[w[i]]++;
    }
    ll hmax = 0;
    ll wmax = 0;
    for(int i = 0; i < H; i++){
        hmax = max(hmax, hcnt[i]);
    }
    for(int i = 0; i < W; i++){
        wmax = max(wmax, wcnt[i]);
    }
    vector<ll> hmax_index;
    vector<ll> wmax_index;
    for(int i = 0; i < H; i++){
        if(hmax == hcnt[i]){hmax_index.push_back(i);}
    }
    for(int i = 0; i < W; i++){
        if(wmax == wcnt[i]){wmax_index.push_back(i);}
    }
    ll hcandidate_num = hmax_index.size();
    ll wcandidate_num = wmax_index.size();

    if(hcandidate_num * wcandidate_num > m){
        cout << hmax + wmax << endl;
    }else{
        set<pll> st;
        for(int i = 0; i < m; i++){
            st.insert({h[i],w[i]});
        }
        bool is_cross = true;
        for(int i = 0; i < hcandidate_num; i++){
            for(int j = 0; j < wcandidate_num; j++){
                if(st.find({hmax_index[i],wmax_index[j]}) == st.end()){
                    is_cross = false;
                }
            }
        }
        if(is_cross){
            cout << hmax + wmax - 1 << endl;
        }else{
            cout << hmax + wmax << endl;
        }
    }



    return 0;
}


Measured memory_bytes: 33696
import math
a, b, C = map(int, input().split())
C = math.radians(C)
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(C))
S = a * b * math.sin(C) / 2
print(f"{S:0.9f}")
print(f"{a+b+c:0.9f}")
print(f"{S*2/a:0.9f}")


Measured memory_bytes: 5720
#import math
#import itertools
from collections import deque

INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

class Graph():
    def __init__(self, v):
        self.v = v
        self.graph = [[] for _ in range(v)]
        self.INF = 10 ** 9
    
    def addEdge(self, start, end, dist):
        self.graph[start].append((end, dist))
        self.graph[end].append((start, dist))

def do():
    n=INT()
    g=Graph(n)
    for i in range(n-1):
        u,v,d=INTM()
        u-=1
        v-=1
        g.addEdge(u,v,d)

    que=deque()
    check=[True]*n
    dists=[-1]*n
    check[0]=False
    dists[0]=0
    que.append([0,0])
    while que:
        now,dist_f=que.popleft()
        for next,dist in g.graph[now]:
            if check[next]:
                check[next]=False
                temp=dist_f+dist
                dists[next]=temp
                que.append([next,temp])

    for i in dists:
        if i%2==0:
            print(0)
        else:
            print(1)
    
if __name__=='__main__':
    do()

Measured memory_bytes: 48508
n = gets.to_i
a = gets.split.map &:to_i
b = gets.split.map &:to_i
c = gets.split.map &:to_i
sum = 0
temp = 0
i = 0
a.each do |aa|
  if aa == temp + 1 && i > 0
    sum += c[temp - 1]
  end
  sum += b[aa - 1]
  temp = aa
  i += 1
end
p sum

Measured memory_bytes: 1788
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, M;
	cin >> N >> M;

	vector<lint> V(M);
	lint sum = 0;
	for (int i = 0; i < M; i++)
	{
		cin >> V[i];
	}

	lint diff = N - V[M - 1] + V[0];

	for (int i = 0; i + 1 < M; i++)
	{
		diff = max(diff, V[i + 1] - V[i]);
	}

	cout << N - diff << endl;
	return;
}

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

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 1792
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    X, t = map(int, input().split())
    print(max(0, X - t))


if __name__ == '__main__':
    main()


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

map<ll, ll> prime_factorize(ll N) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= N; ++i) {
        while (N % i == 0) {
            res[i]++;
            N /= i;
        }
    }
    if (N != 1) res[N] = 1;
    return res;
}

class mint {
    long long x;
public:
    constexpr mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}

    constexpr mint operator-() const {
        return mint(-x);
    }

    constexpr mint &operator+=(const mint &a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    constexpr mint &operator-=(const mint &a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    constexpr mint &operator*=(const mint &a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    constexpr mint operator+(const mint &a) const {
        mint res(*this);
        return res += a;
    }

    constexpr mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }

    constexpr mint operator*(const mint &a) const {
        mint res(*this);
        return res *= a;
    }

    [[nodiscard]] constexpr mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    constexpr mint inv() const {
        return pow(MOD - 2);
    }

    mint &operator/=(mint a) {
        return *this *= a.inv();
    }

    mint operator/(const mint a) const {
        return mint(*this) /= a;
    }

    constexpr bool operator==(const mint &a) const noexcept {
        return this->x == a.x;
    }

    constexpr bool operator!=(const mint &a) const noexcept {
        return this->x != a.x;
    }

    friend istream &operator>>(istream &is, mint &a) {
        is >> a.x;
        return is;
    }

    friend ostream &operator<<(ostream &os, const mint &a) {
        return os << a.x;
    }
};


void Main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    map<ll, ll> cnt;
    rep(i, N) {
        auto primes = prime_factorize(A[i]);
        for (P p : primes) {
            cnt[p.first] = max(p.second, cnt[p.first]);
        }
    }
    mint base = 1;
    for (P p : cnt) {
        base *= mint(p.first).pow(p.second);
    }
    mint ans = 0;
    rep(i, N) {
        ans += base / mint(A[i]);
    }
    cout << ans << '\n';
}

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


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

  int ans = 0;

  rep1(i, N) {
    if (i % 2 == 0) continue;

    int check = 1;
    rep(j, 1, i) {
      if (i % j == 0) check++;
    }
    if (check == 8) ans++;
  }

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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 ll INF = 1e18;

string s;
ll n,q;
vector<char>t,d;

// index が条件を満たすかどうか
bool isOKleft(ll index) {
    ll now = index;
    rep(i,q){
        if(t[i]==s[now]){
            if(d[i]=='L'){
                now--;
            }
            else{
                now++;
            }
        }
        if(now<0){
            return false;
        }
        if(now>=n){
            return true;
        }
    }
    return true;
}
bool isOKright(ll index) {
    ll now = index;
    rep(i,q){
        if(t[i]==s[now]){
            if(d[i]=='L'){
                now--;
            }
            else{
                now++;
            }
        }
        if(now<0){
            return false;
        }
        if(now>=n){
            return true;
        }
    }
    return false;
}
// 汎用的な二分探索のテンプレ
int binary_search1() {
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = n; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOKleft(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}
int binary_search2() {
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = n; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOKright(mid)) ok = mid;
        else ng = mid;
    }
    return ng;
}

int main(){
    cin >> n >> q;
    cin >> s;
    t.resize(q);
    d.resize(q);
    rep(i,q){
        cin >> t[i] >> d[i];
    }
    cout << binary_search2() - binary_search1() + 1 << endl;
    return 0;
}


Measured memory_bytes: 900
//ABC153C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;



int main(){
	string s;
	cin >> s;
	for(int i=0;i<s.size()-1;i++){
		if(s.at(i) != s.at(i+1)){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

#define MX 100005
#define ll long long

vector < int > G[MX];
vector < int > topsort;
bool vis[MX];
ll dp[MX];

void dfs(int n){
    vis[n] = 1;
    for (int i = 0; i < G[n].size(); i++){
        int nxt = G[n][i];
        if (!vis[nxt])
            dfs(nxt);
    }
    topsort.push_back(n);
}

void solve(){
    for (int x = 0; x < topsort.size(); x++){
        int cur = topsort[x];
        if (G[cur].size() == 0){
            dp[cur] = 0;
        }
        else{
            ll mx = 0;
            for (int i = 0; i < G[cur].size(); i++){
                int nxt = G[cur][i];
                mx = max(mx, dp[nxt]);
            }
            dp[cur] = mx + 1;
        }
    }


}

int main()
{
    int n, m; scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++){
        int u, v; scanf("%d%d", &u, &v);
        G[u].push_back(v);
    }

    for (int i = 1; i <= n; i++){
        if (!vis[i])
            dfs(i);
    }
    solve();
    ll res = 0;
    for (int i = 1; i <= n; i++)
        res = max(res, dp[i]);

    printf("%lld\n", res);
    return 0;
}



Measured memory_bytes: 8440
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;

int main(void) {
	char s1, s2, s3;
    cin >> s1;
    cin >> s2;
    cin >> s3;
    cout << (s1-'0'+s2-'0'+s3-'0') << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdarg>
#include <set>

using namespace std;
#define INF 2e9 + 9
#define ALL(v) v.begin() , v.end()
#define Int int64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T, vector<T>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
#define ll(n) Int n; cin >> n;
#define LL(...) Int __VA_ARGS___; cin >> __VA_ARGS___;
#define OUT(...) cout << __VA_ARGS___;
#define RP(n, i, s) for(Int i = s ;i < n ;i++)
#define REP(n, i) for (Int i = 0; i < n; i++)
#define REPe(n, i) for (Int i = 1; i <= n; i++)
#define RPe(n, i, s) for (Int i = s; i <= n; i++)
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;

struct node {
    Int to;
    Int length;
};


vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return (ret);
}


vector<vector<int>> to;
vector<int> flag;
vector<int> c;

Int dfs(int from, int mae) {
    flag[from] = 1;
    Int mini = 0;
    for (auto next : to[from]) {
        if (next == mae) continue;
        if (flag[next] == 1) {
            return -1;
        } else {
            mini = min(mini, dfs(next, from));
        }
    }
    return mini;
}

int dx8[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};



int main(void) {
    Int x1, x2 ,y1 ,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    Int dx = x1 - x2;
    Int dy = y1 - y2;
    cout << x2 + dy <<" "  << y2 - dx << " " << x1 + dy << " " << y1 - dx << endl;
}

Measured memory_bytes: 256
N = int(input())
m = [0] * 5
s = "MARCH"
for i in range(N):
    a = input()
    for j in range(5):
        if s[j] == a[0]:
            m[j] += 1

ans = 0

for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            ans += m[i] * m[j] * m[k]

print(ans)


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
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; }

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

ll h,w;
ll ch, cw, dh, dw;
vector<string> s;


int main() {
    cout<<fixed<<setprecision(10);

    cin>>h>>w;
    cin>>ch>>cw;
    cin>>dh>>dw;

    ch--; cw--; dh--; dw--;

    rep(i,h){
        string tmp; cin>>tmp;
        s.push_back(tmp);
    }

    using T = tuple<ll,ll,ll>; // cnt, row, col
    priority_queue<T, vector<T>, greater<T>> pq;

    pq.push(make_tuple(0, ch, cw));
    vvint dist(h, vint(w,-1));

    while(!pq.empty()){
        ll cnt, row, col;
        tie(cnt, row, col) = pq.top(); pq.pop();
        if(dist[row][col] >= 0) continue;
        dist[row][col] = cnt;
        // 移動
        rep(i,4){
            ll nrow = row + dy[i];
            ll ncol = col + dx[i];
            if(nrow < 0 or nrow >= h or ncol < 0 or ncol >= w) continue;
            if(s[nrow][ncol] == '#') continue;
            pq.push(make_tuple(cnt, nrow, ncol));
        }

        // magic
        repf(nrow, row-2, row+3){
            repf(ncol, col-2, col+3){
                if(nrow < 0 or nrow >= h or ncol < 0 or ncol >= w) continue;
                if(s[nrow][ncol] == '#') continue;
                pq.push(make_tuple(cnt+1, nrow, ncol));
            }
        }
    }

    // for(auto v:dist){
    //     for(auto e:v) cout<<e<<" "; cout<<endl;
    // }

    cout<<dist[dh][dw]<<endl;


    return 0;

}

Measured memory_bytes: 18460
#include <iostream>
using namespace std;
const int nmax=40,abmax=10,inf = 1000000;

int a[nmax],b[nmax],c[nmax];
int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];

int main(void){
int n,ma,mb;
 cin >> n >> ma >> mb;

 for(int i=0;i<n;++i){
 cin >> a[i] >> b[i] >> c[i];
 }

 for(int i = 0; i <= n; ++i){
 for(int ca = 0; ca <= nmax*abmax; ++ca){
 for(int cb = 0; cb <= nmax*abmax; ++cb){
 dp[i][ca][cb]=inf;
 }
 }
 }

 dp[0][0][0]=0;


 for(int i = 0; i < n; ++i){
 for(int ca = 0; ca <= nmax*abmax; ++ca){
 for(int cb = 0; cb <= nmax*abmax; ++cb){
 if(dp[i][ca][cb]==inf) continue;
 dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]);
 dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]);
 }
 }
 }

 int ans=inf;
 for(int ca = 1; ca <= nmax*abmax; ++ca){
 for(int cb = 1; cb <= nmax*abmax; ++cb){
 if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]);
 }
 }

 if(ans==inf) ans=-1;
 cout << ans << endl;

 return 0;
 }

          
  

Measured memory_bytes: 25984
#include <bits/stdc++.h>
#include <sstream>
using namespace std;
 
int main() {
	int a, b;
  int count = 0;
  ostringstream os;
  cin >> a >> b;
  for(int i = a; i <= b; i++ ){
    os.str("");
    os << i;
    string s = os.str();
    int rc = s.size() - 1;
//    cout << "RC" << rc << ":" << i << ":" << s << endl;
    bool ne = false;
    for(int c = 0; c < rc; c++ ){
//         cout << s.at(c) << "==" << s.at(rc) << endl;
//      cout << c << "--" << rc << endl;
      if(s.at(c) != s.at(rc)){

        ne = true;
        break;
      }
      rc--;
    }
    if( !ne ){
      // cout << s << endl;
      count++;
    }
  }
  cout << count << endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;

int main() {
	cin >> n;
	cout << n / 3 << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <cstdio>
int n, v1[100005], v2[100005];
long long m, ans, x1[100005], x2[100005], max[100005];
void Add(int x, long long v) {
	for (; x <= n; x += x & -x)
		max[x] = std::max(max[x], v);
}
long long Max(int x) {
	long long Max = 0;
	for (; x; x -= x & -x)
		Max = std::max(Max, max[x]);
	return Max;
}
void Calc(long long x[], int v[]) {
	memset(max, 0, sizeof(max));
	long long sum = 0, dis = 0;
	for (int i = 1; i <= n; ++i) {
		sum += v[i];
		dis = x[i];
		Add(i, sum - 2 * dis);
	}
	sum = 0;
	dis = 0;
	for (int j = n; j; --j) {
		sum += v[j];
		dis = m - x[j];
		ans = std::max(ans, sum - dis + Max(j - 1));
	}
}
int main() {
	scanf("%d%lld", &n, &m);
	for (int i = 1; i <= n; ++i)
		scanf("%lld %d", &x1[i], &v1[i]);
	Calc(x1, v1);
	for (int i = 1; i <= n; ++i)
		x2[i] = m - x1[n - i + 1], v2[i] = v1[n - i + 1];
	Calc(x2, v2);
	printf("%lld\n", ans);
}

Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

internal static class CR
{
    public static string Get() { return Console.ReadLine(); }
    public static IEnumerable<string> GetTexts() { return Console.ReadLine().Split(' '); }
    public static int GetInteger() { return int.Parse(Console.ReadLine()); }
    public static IEnumerable<int> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)); }
}

namespace AtCoderBeginnerContest
{
    internal class Program
    {
        public static int N { get; private set; }
        public static List<int> P { get; private set; }

        private static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.WriteLine(r); }

        private static object GetResult()
        {
            N = CR.GetInteger();
            P = CR.GetIntegers().ToList();

            var count = 1;
            var min = P[0];
            for (int i = 0; i < N; i++)
            {
                if (i != 0)
                {
                    min = min < P[i - 1] ? min : P[i - 1];
                }

                if (min > P[i])
                {
                    count++;
                }
            }

            return count;
        }
    }
}


Measured memory_bytes: 35676
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

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

void solve(){
    int x = scan!int;
    int y = x;

    foreach(k; 3 .. 1000){
        if((y * k) % 360 == 0){
            k.print;
            return;
        }
    }

}



Measured memory_bytes: 3220
def resolve():
    N,M = map(int,input().split())

    cmap = [N for _ in range(N)]
    for a,b in [map(int,input().split()) for _ in range(M)]:
        cmap[min(a-1,b-1)] = min(max(a-1,b-1),cmap[min(a-1,b-1)])

    min_ptr = N 
    counter = 0
    for i,c in enumerate(cmap):
        if i == min_ptr:
            counter += 1
            min_ptr = N
        min_ptr = min(cmap[i],min_ptr)
    print(counter)
resolve()

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

using namespace std;

#define long long long


int main() {
    string s;
    cin >> s;

    map<string, int> m = {
            {"MON", 6},
            {"TUE", 5},
            {"WED", 4},
            {"THU", 3},
            {"FRI", 2},
            {"SAT", 1},
            {"SUN", 7},
    };

    cout << m[s];
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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)++)


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m,k;cin>>n>>m>>k;
    string ans = "No";
    for(int i=0; i<=n; i++){
        for(int j=0; j<=m; j++){
            if(k==i*j+(n-i)*(m-j))ans="Yes";
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
counter = Counter()

max_count = 0
for _ in range(N):
    s = input()
    counter[s] += 1
    max_count = max(max_count, counter[s])

results = sorted([k for k, v in counter.items() if v == max_count])
print('\n'.join(results))


Measured memory_bytes: 36020
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#include <queue>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <ctime>

using namespace std;

typedef int INT;
#define int long long






INT main()
{
	int n, c;
	cin >> n >> c;
	vector <vector <int> > a(c, vector <int>(c)), b(n, vector <int>(n)), p(3, vector <int>(c)), z(3, vector <int>(c));
	for (int i = 0; i < c; i++)
		for (int j = 0; j < c; j++)
			cin >> a[i][j];

	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
		{
			cin >> b[i][j];
			p[(i + 1 + j + 1) % 3][b[i][j] - 1]++;
		}
	int sum = 0;
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < c; j++)
		{
			int r = 0;
			for (int v = 0; v < c; v++)
			{
				r += p[i][v] * a[v][j];
			}
			z[i][j] = r;
		}
	}
	int t = -1;
	for (int i=0; i<c; i++)
		for (int j=0; j<c; j++)
			for (int v = 0; v < c; v++)
			{
				if (i != j && j != v && i != v)
				{
					int u = z[0][i] + z[1][j] + z[2][v];
					if (u < t || t == -1)
						t = u;
				}
			}
	cout << t;
	//system("pause");
	return 0;
}




Measured memory_bytes: 2176
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

#pragma gcc target ("avx2")
#pragma gcc optimization ("o3")
#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2.0) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}
#define nopf(T) [](T a){return a;}
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	string s;
	scans(s);
	sort(all(s));
	printynl(!distance(unique(all(s)), s.end()));

	Please AC;
}


Measured memory_bytes: 632
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
	char a[1005], b[1005];
	scanf("%s %s",a,b);
	int len1 = strlen(a);
	int len2 = strlen(b);
	if(len1 > len2) printf("GREATER\n");
	if(len1 < len2) printf("LESS\n");
	if(len1 == len2)
	{
		if(strcmp(a,b) > 0) printf("GREATER\n");
		if(strcmp(a,b) < 0) printf("LESS\n");
		if(strcmp(a,b) == 0) printf("EQUAL\n");
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi= vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
ab.sort()

ans = 0
L,R = 0,n
for a,b in ab:
    if b <= L or a >= R:
        ans += 1
        L,R = a,b
        continue
    L = max(L,a)
    R = min(R,b)
    # print(L,R)
print(ans+1)

Measured memory_bytes: 27876
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int main() {
    int n;
    cin >> n;
    vi l; l.resize(n);
    rep(i, n) cin >> l[i];
    sort(all(l), greater<int>());
    int sum = 0;
    for(int i = 1; i < n; i++) sum += l[i];
    if (sum <= l[0]) puts("No");
    else puts("Yes");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
    long long k, n;
    cin >> k >> n;
    long long max_dist = 0;
    long long sum_dist = 0;
    vector<long long> a(n);
    for (long long i = 0; i < n; ++i) {
        cin >> a[i];
        if (i != 0) {
            long long dist = a[i] - a[i - 1];
            sum_dist += dist;
            if (dist > max_dist) max_dist = dist;
        }
    }
    long long dist = k - a[n - 1] + a[0];
    sum_dist += dist;
    if (dist > max_dist) max_dist = dist;
    cout << sum_dist - max_dist << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool dfs(int pos, const vector<vector<pair<int, int>>>& g, const vector<int>& state, vector<int>& check, vector<int>& res){
    if(check[pos]) return false;
    check[pos] = 1;
    int cnt = state[pos];
    for(auto& p : g[pos]){
        if(dfs(p.first, g, state, check, res)){
            cnt = 1 - cnt;
            res.push_back(p.second);
        }
    }
    return cnt == 1;
}

vector<int> solve(int M, const vector<pair<int,int>>& bomb){
    const int N = bomb.size();
    vector<int> cur(N+1, 0);
    cur[0] = bomb[0].second;
    for(int i=1;i<N;i++){
        cur[i] = (bomb[i].second == bomb[i-1].second ? 0 : 1);
    }
    cur[N] = bomb.back().second;
    vector<vector<pair<int,int>>> g(N+1);
    for(int i=0;i<M;i++){
        int L, R; cin >> L >> R;
        if(R < bomb[0].first || bomb.back().first < L) continue;
        int a = distance(bomb.begin(), lower_bound(bomb.begin(), bomb.end(), make_pair(L, 0)));
        int b = distance(bomb.begin(), upper_bound(bomb.begin(), bomb.end(), make_pair(R, 1)));
        g[a].emplace_back(b, i+1);
        g[b].emplace_back(a, i+1);
    }
    vector<int> res;
    vector<int> check(N+1, 0);
    for(int i=0;i<=N;i++){
        if(check[i]) continue;
        if(dfs(i, g, cur, check, res)) return vector<int>();
    }
    sort(res.begin(), res.end());
    return res;
}

int main(){
    int N, M;
    while(cin >> N >> M){
        vector<pair<int, int>> bomb(N);
        for(auto& p : bomb) cin >> p.first >> p.second;
        sort(bomb.begin(), bomb.end());
        if(all_of(bomb.begin(), bomb.end(), [](pair<int,int>& p){ return p.second == 0; })){
            int L, R;
            for(int i=0;i<M;i++) cin >> L >> R;
            cout << 0 << endl << endl;
            continue;
        }
        auto res = solve(M, bomb);
        if(res.empty()){
            cout << -1 << endl;
        } else {
            cout << res.size() << endl;
            cout << res[0];
            for(int i=1;i<res.size();i++) cout << " " << res[i];
            cout << endl;
        }
    }
}

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

int mygcd(long long &x, long long &y){
  long long a = max(x,y);
  long long b = min(x,y);
  while(true){
    long long c = a % b;
    if(c == 0){
      return b;
    }
    a = b;
    b = c;
  }
}

long long mylcm(long long x, long long y){
  long long lcm = (x * y) / mygcd(x, y);
  return lcm;
}

long long check(long long x,long long c,long long d){
  long long cCount = x/c;
  long long dCount = x/d;
  long long l = x/mylcm(c,d);
  return cCount + dCount - l;
}

int main() {
  long long a, b, c, d; cin >> a >> b >> c >> d;
  long long x = b - a + 1;

  long long ans = x - (check(b,c,d) - check(a-1,c,d));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const long long INF = 1LL << 60;
const int MOD = 1000000007;
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
template <class T> inline bool chmin(T &a, T b) { if ( a > b ) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T &a, T b) { if ( a < b ) { a = b; return 1; } return 0; }
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

int N, K;
ll dp[100100];
ll H[100100];

int main(int argc, char *argv[]){
    cin >> N >> K;
    rep(i, N) cin >> H[i];
    rep(i, N) dp[i] = INF;
    dp[0] = 0;
    rfor(i, 0, N)
        rfor(j, 1, K + 1)
            chmin(dp[i + j], dp[i] + abs(H[i + j] - H[i]));
    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,num=0;
int main(){
	cin>>n;
	for(int i=sqrt(n);i>0;i--)
		if(n%i==0){
			b=n/i;
			while(b!=0){
				num++;
				b/=10;
			}
			cout<<num<<endl;
			return 0;
		}
	
}

Measured memory_bytes: 256
N = int(input())
table = [[int(i) for i in input().split()] for n in range(N)]
can = True
for i in range(N):
    if(i != 0):
        dt = table[i][0] - table[i-1][0]
        dist = abs(table[i][1]-table[i-1][1]) +abs(table[i][2]-table[i-1][2])
    else:
        dt = table[i][0]
        dist = abs(table[0][1]) + abs(table[0][2])
    if(dist > dt):
        can = False
        break
    elif((dt-dist)%2 != 0):
        can = False
        break
if(can == True):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 21156