akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

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


int main(){
	double a, b;cin >> a >> b;
	cout << Decimal << (a / b) << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
class c
{
  static void Main()
  {
    string[]s=Console.ReadLine().Split(' ');
    int x=int.Parse(s[0]);
    int y=int.Parse(s[1]);
    int z=int.Parse(s[2]);
    string ans="NO";
    if(x-y==y-z)ans="YES";
    
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define INF 114514810
#define FOR(i, r, n) for(int i=(r); i<(n); i++) 
#define REP(i, n) FOR(i, (0), n)

using namespace std;

int n, a, b, c, t = 0, sum = INF, ans, nodes = 0;
int d[50][50];

int main(){
	while (true){
		cin >> n;
		if (n == 0) break;
		REP(i, 10)
			REP(j, 10)
			d[i][j] = (i == j ? 0 : INF);
		REP(i, n){
			cin >> a >> b >> c;
			d[a][b] = d[b][a] = c;
			nodes = max(nodes, a);
			nodes = max(nodes, b);
		}
		REP(k, 10)
			REP(i, 10)
			REP(j, 10)
			d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
		REP(i, nodes + 1){
			REP(j, nodes + 1) t += d[i][j];
			if (sum > t){
				sum = t;
				ans = i;
			}
			t = 0;
		}
		cout << ans << " " << sum << endl;
		nodes = ans = 0;
		sum = INF;
	}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <vector>
using namespace std;
 
int main(){
    string S;
    cin >> S;
    if(S == "SUN"){
        cout << 7 << endl;
    }
     if(S == "MON"){
        cout << 6 << endl;
    }
     if(S == "TUE"){
        cout << 5 << endl;
    }
     if(S == "WED"){
        cout << 4 << endl;
    }
     if(S == "THU"){
        cout << 3 << endl;
    }
     if(S == "FRI"){
        cout << 2 << endl;
    }
     if(S == "SAT"){
        cout << 1 << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int>(1000,10000)(rng)

const int N=1e7+1;
ll sieve[N];
ll ans[N];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    for (int i=1;i<N;++i)
        for (int j=i;j<N;j+=i)
            ++sieve[j];
    for (int i=1;i<N;++i)
        ans[i]=ans[i-1]+(sieve[i]*i);
    int n;
    cin>>n;
    cout<<ans[n];
    return 0;
}

Measured memory_bytes: 159904
#include"bits/stdc++.h"
using namespace std;

int main() {
	int N, M;
	cin >> N;
	string s[10000];
	map<string,int>A;
	
	for (int i = 0; i < N; i++) {
		cin >> s[i];
		A[s[i]]++;
	}
	cin >> M;

	for (int i = N + 1; i <= N + M; i++)
	{
		cin >> s[i];
		A[s[i]]--;
	}
	int ans = 0;

	for (int i = 0; i < N + M; i++) {
		ans = max(ans, A[s[i]]);
	}

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

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
	int num, max = 0, ans = 0;

	for (int i = 0; i < 3; i++) {
		cin >> num;
		if (num > max) {
			ans += max;
			max = num;
		}
		else ans += num;
	}

	cout << ans + 10 * max << endl;

	return 0;
}

Measured memory_bytes: 256
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

s = input()
t = input()

l = len(s)
count = 0
for i in range(l):
    if s[i] != t[i]:
        count+=1
print(count)

Measured memory_bytes: 9612
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int r = i;
		while (r + 1 < n && a[r] >= a[r + 1]) r++;
		ans = max(ans, r - i + 1);
		i = r;
	}
	cout << ans - 1 << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n;
vector<int> loser[100001];

int dfs(int x) {
    vector<int> ch;
    for (int i : loser[x]) {
        ch.push_back(dfs(i));
    }
    sort(ch.begin(), ch.end(), greater<int>());
    int ret = -1;
    for (int i = 0; i < ch.size(); ++i) {
        ret = max(ret, ch[i] + i);
    }
    return ret + 1;
}

int main() {
    scanf("%d", &n);
    for (int i = 2; i <= n; ++i) {
        int x;
        scanf("%d", &x);
        loser[x].push_back(i);
    }
    printf("%d\n", dfs(1));
	return 0;
}


Measured memory_bytes: 13568
#include <stdio.h>
int main (){
// DECLARAÇÕES
int A,B,C;

// INSTRUÇÕES
scanf ("%d %d %d",&A,&B,&C);

if (A>B && B>C)
    printf ("%d\n",B*C/2);
else if (B>A && B>C)
    printf ("%d\n",A*C/2);
else
    printf ("%d\n",A*B/2);

return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main()
{
    int N, A, B, a;
    scanf("%d%d%d", &N, &A, &B);
    if (1 <= N <= 20 && 1 <= A <= 100 && 1 <= B <= 2000)
    {
        a = N * A;
        if (a > B)
        {
            printf("%d", B);
        }
        else
        {
            printf("%d", a);
        }
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0;i < N;i++) {
        cin >> A.at(i);
    }
    vector<int> B(N);
    for(int i = 0;i < N;i++) {
        cin >> B.at(i);
    }
    vector<P> cnt(N);
    cnt.at(0).first = A.at(0);
    cnt.at(0).second = A.at(0);
    for(int i = 0;i < N - 1;i++) {
        if(A.at(i) == A.at(i + 1)) {
            cnt.at(i + 1).first = 1;
            cnt.at(i + 1).second = cnt.at(i).second;
        }
        else {
            cnt.at(i + 1).first = A.at(i + 1);
            cnt.at(i + 1).second = A.at(i + 1);
        }
    }
    vector<P> cnt2(N);
    reverse(B.begin(),B.end());
    cnt2.at(0).first = B.at(0);
    cnt2.at(0).second = B.at(0);
    for(int i = 0;i < N - 1;i++) {
        if(B.at(i) == B.at(i + 1)) {
            cnt2.at(i + 1).first = 1;
            cnt2.at(i + 1).second = cnt2.at(i).second;
        }
        else {
            cnt2.at(i + 1).first = B.at(i + 1);
            cnt2.at(i + 1).second = B.at(i + 1);
        }
    }
    reverse(cnt2.begin(),cnt2.end());
    vector<P> ret(N);
    bool ret2 = true;
    for(int i = 0;i < N;i++) {
        ret.at(i).first = max(cnt.at(i).first,cnt2.at(i).first);
        ret.at(i).second = min(cnt.at(i).second,cnt2.at(i).second);
        if(ret.at(i).first > ret.at(i).second) {
            ret2 = false;
            break;
        }
    }
    if(ret2 == false) {
        cout << 0 << endl;
    }
    else {
        ll ret3 = 1;
        for(int i = 0;i < N;i++) {
            ret3 = ret3 * (ret.at(i).second - ret.at(i).first + 1) % MOD;
        }
        cout << ret3 << endl;
    }
}

Measured memory_bytes: 3328
import math
def main():
    N = int(input())
    rate = []
    for _ in range(N):
        T, A = map(int, input().split())
        rate.append([T, A])
    cur = [rate[0][0], rate[0][1]]
    # print(cur, rate[0])
    for i in range(1, N):
        if cur[0] % rate[i][0] == 0:
            dT = cur[0] // rate[i][0]
        else:
            dT = cur[0] // rate[i][0] + 1
        if cur[1] % rate[i][1] == 0:
            dA = cur[1] // rate[i][1]
        else:
            dA = cur[1] // rate[i][1] + 1
        d = max(dT, dA)

        cur = [d*rate[i][0], d*rate[i][1]]
        # print(cur, rate[i])
    return sum(cur)

if __name__ == '__main__':

    print(main())


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

struct Ant {
	int id, pos, dir;
	Ant(){}
	Ant(int id, int pos, int dir): id(id), pos(pos), dir(dir){}
};

int n, l;
vector<Ant> a;

void solve()
{
	vector<pair<int, int>> v;
	for (int t = 1; a.size(); t++){
		sort(a.begin(), a.end(), [](const Ant &a, const Ant &b){
			return a.pos == b.pos ? a.dir < b.dir : a.pos > b.pos;
		});
		for (int i = 0; i < a.size(); i++){
			auto &A = a[i];
			A.pos += A.dir;
			if (A.pos == 0 || A.pos == l){
				v.emplace_back(make_pair(t, A.id));
				a.erase(a.begin() + i--);
			}
		}
		sort(a.begin(), a.end(), [](const Ant &a, const Ant &b){
			return a.pos == b.pos ? a.dir < b.dir : a.pos < b.pos;
		});
		for (int i = 0; i + 1 < a.size(); i++){
			if (a[i].pos == a[i + 1].pos){
				swap(a[i].dir, a[i + 1].dir);
			}
		}
	}
	printf("%d %d\n", v.back().first, v.back().second);
}

int main()
{
	while (scanf("%d %d", &n, &l), n){
		a.clear();
		for (int i = 0; i < n; i++){
			string d;
			int p;
			cin >> d >> p;
			a.push_back(Ant(i + 1, p, d == "R" ? 1 : -1));
		}
		solve();
	}
}

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

ll n, ans = 0;
void dfs(ll num) {
  if (num > n) return;
  
  vector<ll> ok(10, 0);
  string s = to_string(num);
  rep(i,s.size()) ok[s[i] - '0']++;
  if (ok[3] && ok[5] && ok[7]) ans++;
  
  dfs(num * 10 + 3);
  dfs(num * 10 + 5);
  dfs(num * 10 + 7);
}

int main() {
  cin >> n;
  dfs(0);
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    deque<int>b;
    rep(i,n) {
        if(i%2==0) b.push_back(a[i]);
        else b.push_front(a[i]);
    }
    if(n%2==1) reverse(b.begin(),b.end());
    rep(i,n) {
        cout << b[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4824
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

#素因数分解
def factorization(n):
	arr = []
	tmp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if tmp%i == 0:
			cnt = 0
			while tmp%i == 0:
				cnt += 1
				tmp //= i
			arr.append([i, cnt])
	if tmp != 1:
		arr.append([tmp, 1])
	if arr == []:
		arr.append([n, 1])
	return arr
	

N = INT()

e = [0]*(N+1)
for i in range(2, N+1):
	for x in factorization(i):
		e[x[0]] += x[1]

def num(m):
	return len([x for x in e if x >= m-1])

print(num(75) + num(25)*(num(3)-1) + num(15)*(num(5)-1) + num(5)*(num(5)-1)*(num(3)-2)//2)

Measured memory_bytes: 10760
#include <iostream>

int main() {
  char c;
  
  std::cin >> c;
  if(c == 'A') std::cout << "T";
  else if(c == 'T') std::cout << "A";
  else if(c == 'C') std::cout << "G";
  else if(c == 'G') std::cout << "C";
  
  return 0;
}


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

int main() {
  int N; cin >> N;
  string s; cin >> s;
  int b, r = b = 0;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'R') r++;
    else b++;
  }
  if (r > b) cout << "Yes" << endl;
  else cout << "No" << endl;
}
  


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

typedef long long int ll;

int main()
{
    ll k, a, b;
    cin>> k;
    cin>>a>>b;

    for(ll i=a; i<=b; i++)
    {
        if(i%k==0)
        {
            cout<<"OK"<<endl;
            return 0;
        }

    }

    cout<<"NG"<<endl;

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
using namespace std;
#define lol long long


int main()
{
	string S;
	cin >> S;
	int size = S.size();
	int A = 0;
	int B = 0;
	for (int i = 0; i < size; i++) {
		if (i % 2 == 0 && S[i] == '0') {
			A++;
		}
		else if (i % 2 == 0 && S[i] == '1') {
			B++;
		}
		else if (i % 2 == 1 && S[i] == '0') {
			B++;
		}
		else {
			A++;
		}
	}
	cout << min(A, B) << endl;
}

Measured memory_bytes: 512
N, K = map(int, input().split())
A = list(map(int, input().split()))

res = 10 ** 15

for bit in range(2 ** N):
    cnt = 0
    for i in range(N):
        if (bit >> i) & 1:
            cnt += 1

    if cnt < K:
        continue

    cost = 0
    height = A[0]
    if (bit >> 0) & 1:
        for i in range(1, N):
            if (bit >> i) & 1 and height >= A[i]:
                cost += height - A[i] + 1
                height += 1
            elif height < A[i]:
                height = A[i]

        res = min(res, cost)

print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    rep(i, n-1) {
        if (h[i] - h[i+1] >= 2) {
            cout << "No" << endl;
            return 0; 
        }
        if (h[i] - h[i+1] == 1) {
            ++h[i+1];
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 4008
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct UnionFind{
  int data[10000];
  UnionFind(int N){
    REP(i, N) data[i] = i;
  }
  int root(int x){
    if(data[x] == x) return x;
    return data[x] = root(data[x]);
  }
  void uni(int x, int y){
    x = root(x); y = root(y);
    data[y] = x;
  }
};
struct Edge{
  int src, dst, cost;
  Edge(int a, int b, int c) : src(a), dst(b), cost(c) {}
  bool operator < (const Edge& e) const {
    return cost < e.cost;
  }
};

int main(){
  int S, D;
  while(cin >> S >> D && S){
    vector<Edge> edges;
    REP(i, S){
      REP(j, D){
        int c; cin >> c;
        if(c != 0) edges.push_back(Edge(D, j, c));
      }
    }
    for(int i = 0; i < D; i++){
      for(int j = 1; i + j < D; j++){
        int c; cin >> c;
        if(c != 0) edges.push_back(Edge(i, i + j, c));
      }
    }
    sort(edges.begin(), edges.end());
    int ans = 0;
    UnionFind uf(D + 1);
    FORIT(e, edges){
      int u = e->src, v = e->dst, c = e->cost;
      if(uf.root(u) == uf.root(v)){
      }else{
        uf.uni(u, v);
        ans += c;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main()
{
    string s, t; cin>>s>>t;
    const string INF="~";
    string res=INF;
    for(int i=0; i+t.size()<=s.size(); ++i) {
        bool ok=true;
        for(int j=0; ok && j<t.size(); ++j)
            ok=(s[i+j]==t[j] || s[i+j]=='?');
        if (ok) {
            string tmp=s;
            for(int j=0; j<t.size(); ++j) tmp[i+j]=t[j];
            for(auto& c: tmp) if (c=='?') c='a';
            res=min(res, tmp);
        }
    }
    cout<<(res==INF ? "UNRESTORABLE" : res)<<endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sa = sum(A)

for i, b in enumerate(B):
    tmp = min(A[i], b)  # 削り取れる分
    A[i] -= tmp  # 削り取る
    A[i + 1] -= min(A[i + 1], b - tmp)  # i+1から削れる分はここで削っておく。b-tmpがi時点でのA[i+1]への攻撃力

print(sa - sum(A))  # 全量から削れなかった分を引く

Measured memory_bytes: 18624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[100100];

int main(void){
	int n,i,m;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i]; 
	}
	sort(a,a+n);
	if(n%3){
		cout << ((a[0]==a[n-1] && a[0]==0)?"Yes":"No") << endl;
		return 0;
	}
	m = n/3;
	for(i=0; i<3; ++i){
		if(a[i*m]!=a[(i+1)*m-1]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << ((a[0]^a[m]^a[m*2])?"No":"Yes") << endl;
	return 0;
}


Measured memory_bytes: 1024
import bisect
A,B,Q = map(int, input().split())
SList=[]
TList=[]
for i in range(A):
  SList.append(int(input()))
for i in range(B):
  TList.append(int(input()))


  
for i in range(Q):
  x=int(input())
  kouho=[]
  insert_indexS=bisect.bisect_left(SList,x)
  if not insert_indexS==0:
    kyoriS0 = x-SList[insert_indexS-1]
    insert_indexT=bisect.bisect_left(TList,SList[insert_indexS-1])
    if not insert_indexT==0:
      kyoriS00 = kyoriS0+SList[insert_indexS-1]-TList[insert_indexT-1]
      kouho.append(kyoriS00)
    if not insert_indexT==len(TList):
      kyoriS01 = kyoriS0+TList[insert_indexT]-SList[insert_indexS-1]
      kouho.append(kyoriS01)
  if not insert_indexS == len(SList):
    kyoriS1=SList[insert_indexS]-x
    insert_indexT=bisect.bisect_left(TList,SList[insert_indexS])
    if not insert_indexT==0:
      kyoriS10 = kyoriS1+SList[insert_indexS]-TList[insert_indexT-1]
      kouho.append(kyoriS10)
    if not insert_indexT==len(TList):
      kyoriS11 = kyoriS1+TList[insert_indexT]-SList[insert_indexS]
      kouho.append(kyoriS11)

  insert_indexT=bisect.bisect_left(TList,x)
  if not insert_indexT==0:
    kyoriT0 = x-TList[insert_indexT-1]
    insert_indexS=bisect.bisect_left(SList,TList[insert_indexT-1])
    if not insert_indexS==0:
      kyoriT00 = kyoriT0+TList[insert_indexT-1]-SList[insert_indexS-1]
      kouho.append(kyoriT00)
    if not insert_indexS==len(SList):
      kyoriT01 = kyoriT0+SList[insert_indexS]-TList[insert_indexT-1]
      kouho.append(kyoriT01)
  if not insert_indexT == len(TList):
    kyoriT1=TList[insert_indexT]-x
    insert_indexS=bisect.bisect_left(SList,TList[insert_indexT])
    if not insert_indexS==0:
      kyoriT10 = kyoriT1+TList[insert_indexT]-SList[insert_indexS-1]
      kouho.append(kyoriT10)
    if not insert_indexS==len(SList):
      kyoriT11 = kyoriT1+SList[insert_indexS]-TList[insert_indexT]
      kouho.append(kyoriT11)
  print(min(kouho))  
      
      
      
      
      

Measured memory_bytes: 12104
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
func main(){
    S := nextInt()
    h := S/3600
    m := (S/60)%60
    s := S%60
    fmt.Printf("%v:%v:%v\n", h, m, s)

}

/* templates */

func Max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func Min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func Sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}

func Abs(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}

func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func nextString() string {
	return nextReader()
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}



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

int main(){
	int x;
	while(cin>>x){
		vector<int>ans;
		for(int i=0;i<10;i++){
			if((x>>i)&1)ans.push_back(1<<i);
		}
		for(int i=0;i<ans.size();i++){
			if(i>0)cout<<" ";
			cout<<ans[i];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1212
/************************************************
 * Au: Hany01
 * Date: Feb 27th, 2019
 * Prob: agc010f
 * Email: hany01dxx@gmail.com & hany01@foxmail.com
 * Inst: Yali High School
************************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
#define Rep(i, j) for (register int i = 0, i##_end_ = (j); i < i##_end_; ++ i)
#define For(i, j, k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define X first
#define Y second
#define PB(a) push_back(a)
#define MP(a, b) make_pair(a, b)
#define SZ(a) ((int)(a).size())
#define ALL(a) a.begin(), a.end()
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define y1 WoXiHuanNiA

template <typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template <typename T> inline T read() {
	register T _, __; register char c_;
    for (_ = 0, __ = 1, c_ = getchar(); c_ < '0' || c_ > '9'; c_ = getchar()) if (c_ == '-') __ = -1;
    for ( ; c_ >= '0' && c_ <= '9'; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}
//EOT


const int MAXN = 3005;

int n, a[MAXN];
vector<int> G[MAXN];

int DFS(int u) {
	for (int v: G[u])
		if (!DFS(v)) return 1;
	return 0;
}

int main() {
#ifdef hany01
	freopen("agc010f.in", "r", stdin);
	freopen("agc010f.out", "w", stdout);
#endif

	For(i, 1, n = read<int>())
		a[i] = read<int>();
	For(i, 2, n) {
		int u = read<int>(), v = read<int>();
		if (a[u] > a[v]) G[u].PB(v);
		else if (a[v] > a[u]) G[v].PB(u);
	}

	For(i, 1, n)
		if (DFS(i)) printf("%d ", i);

	return 0;
}

Measured memory_bytes: 384
n=int(input())
dp = [[0]*3 for k in range(n+1)]
l = [[0]*3 for k in range(n+1)]
for k in range(1,n+1):
  l[k][0],l[k][1],l[k][2] = map(int,input().split())

for k in range(1,n+1):
  for i in range(3):
    dp[k][i] = max(dp[k-1][(i+1)%3]+l[k][i],dp[k-1][(i+2)%3]+l[k][i])
    
print(max(dp[n]))

Measured memory_bytes: 42556
#include <cstdio>
#include <algorithm>
#include <queue>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

const int N(2010);
struct edge { int next, to; } e[N];
int head[N], e_num, n, A[N], vis[N], G[N][N], deg[N];
inline void add_edge(int from, int to)
{
	e[++e_num] = (edge) {head[from], to};
	head[from] = e_num;
}

void dfs(int x)
{
	for (int i = vis[x] = 1; i <= n; i++) if (!vis[i] && G[x][i])
		++deg[i], add_edge(x, i), dfs(i);
}

void TopSort()
{
	std::priority_queue<int> Q;
	for (int i = 1; i <= n; i++) if (!deg[i]) Q.push(i);
	while (!Q.empty())
	{
		int x = Q.top(); Q.pop(); printf("%d ", A[x]);
		for (int i = head[x]; i; i = e[i].next) Q.push(e[i].to);
	}
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", A + i);
	std::sort(A + 1, A + n + 1);
	for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++)
		if (std::__gcd(A[i], A[j]) != 1) G[i][j] = G[j][i] = 1;
	for (int i = 1; i <= n; i++) if (!vis[i]) dfs(i);
	TopSort();
	return 0;
}
//fdgdg

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

int main(void)
{
    double x,a,b;
    double L[2];
    cin >> x >> a >> b;
    L[0] = fabs(x-a);
    L[1] = fabs(x-b);
    
    if(L[0]>L[1]){
        cout << "B" << endl;
    }
    else if(L[0]<L[1]){
        cout << "A" << endl;
    }

}

Measured memory_bytes: 256
d = {"r": "p", "s": "r", "p": "s"}
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
score = {"r": r, "s": s, "p": p}
d2 = {}
r = 0


def set_hand(l, k):
    if l + k < n:
        if {d.get(t[l - k]), d.get(t[l + k])} == {"r", "s"}:
            return "p"
        if {d.get(t[l - k]), d.get(t[l + k])} == {"r", "p"}:
            return "s"
        if {d.get(t[l - k]), d.get(t[l + k])} == {"p", "s"}:
            return "r"
        return t[l]
    else:
        return t[l]


for i in range(n):
    for l in range(i, n, k):
        if d2.get(l) is not None:
            break
        if l - k >= 0:
            if d2[l - k] == d.get(t[l]):
                d2[l] = set_hand(l, k)
            else:
                d2[l] = d.get(t[l])
                r += score[d2[l]]
        if l - k < 0:
            d2[l] = d.get(t[l])
            r += score[d2[l]]
print(r)


Measured memory_bytes: 15404
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
lint power(lint x, lint n, lint mod) {
  lint ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
struct Node;
vector<Node> V;
struct Node {
  int idx;
  int parent;
  vector<int> nbr;
  bool vst = false;
  lint size = 1;
  lint dfs(int pa) {
    vst = true;
    parent = pa;
    for(int x : nbr) {
      if(!V[x].vst) {
        size += V[x].dfs(idx);
      }
    }
    return size;
  };
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N;
  cin >> N;
  REP(i, N) {
    V.emplace_back();
    V[i].idx = i;
  }
  REP(i, N-1) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    V[u].nbr.push_back(v);
    V[v].nbr.push_back(u);
  }
  V[0].dfs(-1);
  lint ans = 0;
  REP(i, N) {
    vector<lint> nbrsize;
    lint nbrsum = 0;
    REP(j, V[i].nbr.size()) {
      if(V[i].nbr[j] == V[i].parent) continue;
      nbrsize.push_back(V[V[i].nbr[j]].size);
      nbrsum += V[V[i].nbr[j]].size;
    }
    nbrsize.push_back(N-1-nbrsum);
    lint tmp = 1;
    REP(j, nbrsize.size()) {
      tmp = (tmp + power(2, nbrsize[j], MOD) - 1 + MOD) % MOD;
    }
    //cout << tmp << endl;
    ans = (ans + power(2, N-1, MOD) - tmp + MOD) % MOD;
  }
  ans = ans * power(power(2, N, MOD), MOD-2, MOD) % MOD;
  cout << ans << endl;
}

Measured memory_bytes: 21224
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp=0,tmp2=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld",&n);
  scanf("%s",s);
  rep(i,n){
    tmp2+=((s[i]=='.') ? 1 : 0);
  }
  result=tmp2;
  rep(i,n){
    tmp +=((s[i]=='#') ? 1 : 0);
    tmp2-=((s[i]=='.') ? 1 : 0);
    result=min(result,tmp+tmp2);
  }
  printf("%lld",result);
  
  return 0;
}



Measured memory_bytes: 384
#include <cstdio>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <ctype.h>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main(){
	string s[3];
	REP(3){
		cin >> s[i];
	}

	REP(3){
		cout << (char)toupper(s[i][0]);
	}
	cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.BigDecimal;

public class Main {
	public static void main(String[] args) {  
  		Scanner sc = new Scanner(System.in);
      	int[] ary = new int[3];
      	
      	for(int i = 0; i < 3; i++) {
        	ary[i] = sc.nextInt();  
        }
      	Arrays.sort(ary);
      	System.out.println((ary[0] * ary[1] ) / 2);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <queue>

typedef long long int ll;

using namespace std;

int n = 3;
int a, b;

int main(void) {

	cin >> a >> b;
	int in = 1, ret = 0;
	while (in < b)
	{
		// 一つの差込口を使いa口増やす
		in = in - 1 + a;
		ret++;
	}
	cout << ret;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
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 int INF = 1e9;
const LL LLINF = 1e16;

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if(x == y) return false;
        if(data[y] < data[x]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int root(int x) {
        return data[x]<0 ? x : (data[x]=root(data[x]));
    }

    int size(int x) {
        return -data[root(x)];
    }
};

int main(){
    fastcin();

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    vector<pair<int, int>> ca(n), cb(n);
    rep(i, n) ca[i] = make_pair(a[i], i);
    rep(i, n) cb[i] = make_pair(b[i], i);
    sort(all(ca));
    sort(all(cb));
    rep(i, n){
        if(ca[i].first > cb[i].first){
            cout << "No" << endl;
            return 0;
        }
    }

    UnionFind UF(n);
    rep(i, n){
        UF.merge(ca[i].second, cb[i].second);
    }

    int ct = 0;
    rep(i, n)if(UF.root(i) == i) ct++;

    if(ct >= 2){
        cout << "Yes" << endl;
        return 0;
    }

    rep(i, n-1){
        if(ca[i+1].first <= cb[i].first && ca[i].first <= cb[i+1].first){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

#define F first
#define S second
#define PB push_back
#define all(x) x.begin(), x.end()

typedef long long ll; 
typedef long double ld;

const int N = 1000 * 100 + 10, M = 210; 
const int mod = 1000 * 1000 * 1000 + 7;

string s;
string t, x;
int n, q;

int get(int i)
{
	for(int j = 0; j < q; j++)
	{
		if(s[i] != t[j]) continue;
		if(x[j] == 'L') i--;
		else i++;
		if(i < 0) return 1;
		if(i == n) return 2;
	}
	return 0;
}

int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin>> n >> q;
	cin>> s;
	for(int i = 0; i < q; i++)
	{
		char z, y;
		cin>> z >> y;
		t += z;
		x += y;
	}
	int l = -1, r = n;
	while(r - l > 1)
	{
		int mid = (l + r) / 2;
		if(get(mid) == 1) l = mid;
		else r = mid;
	}
	int lo = -1, hi = n;
	while(hi - lo > 1)
	{
		int mid = (hi + lo) / 2;
		if(get(mid) == 2) hi = mid;
		else lo = mid;
	}
	cout<< n - ((l + 1) + (n - hi)) << endl;
}


Measured memory_bytes: 1044
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, tmp=-1;
  cin >> A >> B;
  for (int i=1; i <= 1000; i++){
    if (floor(i*0.08) == A && floor(i*0.1) == B){
      tmp = i;
      break;
    }
  }
  cout << tmp << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;

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

        String str0=Weather.nextLine();


        String str1="Sunny";
        String str2="Cloudy";
        String str3="Rainy";

        //System.out.println("0"+str0);
        //System.out.println("1"+str1);
        //System.out.println("2"+str2);
        //System.out.println("3"+str3);


        if(str0.equals(str1)){
            System.out.println("Cloudy");
        }if(str0.equals(str2)){
            System.out.println("Rainy");
        }if(str0.equals(str3)){
            System.out.println("Sunny");
        }
    }
}

Measured memory_bytes: 20684
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            long n = sc.nextLong();
            if (n == 0) {
                break;
            }
            long r = n;
            long a1 = 3;
            long a2 = 4;
            long b = 8;
            long c = 1;
            while(n > a1) {
                r += (n + a1) / b * c;
                r += (n + a2) / b * c;
                a1 *= 8;
                a2 *= 8;
                b *= 8;
                c *= 10;
            }
            System.out.println(r);
        }
    }
}



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

int main() {
	int A, B, C;
  	cin >> A >> B;
  	C = 0;
  for(int i = A; i < B + 1; i++) {
  	int q, w, e, r, t;
    q = i % 10;
    w = (i - q) % 100 / 10;
    e = (i - q - w) % 1000 / 100;
    r = (i - q - w - e) % 10000 / 1000;
    t = (i - q - w - e - r) % 100000 / 10000;
    if (i == t + 10 * r + 100 * e + 1000 * w + 10000 * q) {
    C++;
    }
  }
  cout << C << endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static void Main()
    {
        Console.WriteLine(Console.ReadLine().Split().Select(int.Parse).Sum() / 2);
    }
}



Measured memory_bytes: 8256
def solve(N, LRs):
    from operator import itemgetter
    L = 0
    R = 1
    IND = 2

    LRs.sort(key=itemgetter(L))  # L昇順ソート
    LRs = tuple(LR + (ind,) for ind, LR in enumerate(LRs))

    min_r = min(LRs, key=itemgetter(R))  # R最小の区間 == 右端が一番左の区間
    max_l = max(LRs, key=itemgetter(L))  # L最大の区間 == 左端が一番右の区間

    ans = 0
    if min_r[IND] == max_l[IND]:
        # L最大とR最小の問題が一致する場合
        fixed = max(0, min_r[R] - max_l[L] + 1)
        max_ = max(0, max(x[R] - x[L] + 1 for x in LRs if x[IND] != max_l[IND]))
        ans = max(ans, fixed + max_)
    else:
        # L最大とR最小の問題が異なる場合

        # 両方の問題を同日実施する場合
        fixed = max(0, min_r[R] - max_l[L] + 1)
        max_ = max(0, max(x[R] - x[L] + 1 for x in LRs if x[IND] != max_l[IND]))
        ans = max(ans, fixed + max_)

        r_mins = []
        t = 10 ** 9 + 1
        for LR in reversed(LRs):
            if LR[IND] != min_r[IND]:
                t = min(t, LR[R])
            r_mins.append(t)
        r_mins.reverse()

        # 別日に実施する場合
        for x in LRs:
            # min_rと同日に実施する問題で、L最大の問題x
            if x[IND] == max_l[IND]:
                continue
            fixed = max(0, min_r[R] - x[L] + 1)
            r_ = r_mins[x[IND] + 1]
            opp = max(0, r_ - max_l[L] + 1)
            ans = max(ans, fixed + opp)

    return ans


if __name__ == '__main__':
    N = int(input())
    LRs = [tuple(map(int, input().split())) for _ in range(N)]
    print(solve(N, LRs))

# 残った区間
# <-->, <--->
# <>は、いずれかの区間の左右端なので、n通り**4ある
# 右端が一番左にあるような区間に注目すると
# どの区間と組み合わせても、右端は変わらない（emptyになることはある）
# 右端が一番左 / 左端が一番右 に注目する

# 例外 == 両者一致 == 含まれるケース
# <----->
#  <--->
#   <->    ... この区間を含むとこの区間だけになるので、最長区間とそれ以外(これを含む）に分ける

# 右端が一番左 / 左端が一番右 を同じ区間に入れる場合と違う区間に入れる場合に分ける
# 同じ区間に入れる場合は、例外同様、最長区間とその他に分ける

# 右端が一番左 / 左端が一番右 を別日に実施する場合、
# x---o (右端は固定）
# xに決めたとき、 o---y yを最長になるようにしたい
# x---o (右端は固定）
# <---            xより左に左端があるもの : 別グループ（左端が一番右の区間以下確定）に入れると、
#                                     区間長維持または減少なので、x----oと同じグループに入れて、別グループの長さを維持したい
#       <---     oより右に左端があるもの : 別グループに入れないとx---o区間を取るという決め方に反する


Measured memory_bytes: 78120
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int a,b,c,d;
   cin >> a >> b >> c >> d;

   if(a+b > c+d) cout << "Left" << endl;
   else if(a+b < c+d) cout << "Right" << endl;
   else cout << "Balanced" << endl;


   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    rep(i, 1, 3501){
        rep(j, 1, 3501){
            ld w = n * i * j / ld(4 * i * j - n * i - n * j);
            if(w >= 1 && w <= 3500 && w == ll(w)){
                cout << i << " " << j << " " << w << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;

  vector<int> nums;

  int now = 1;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '0' + now) cnt++;
    else {
      nums.push_back(cnt);
      now = 1 - now;
      cnt = 1;
    }
  }
  if (cnt != 0) nums.push_back(cnt);
  if(nums.size() % 2 == 0) nums.push_back(0);

  int ans = 0;
  int left = 0;
  int right = 0;
  int tmp = 0;
  int next = 2 * k + 1;
  for (int i = 0; i < nums.size(); i += 2) {
    int next_left = i;
    int next_right = min(i + next, (int)nums.size());

    while (next_left > left) {
      tmp -= nums[left];
      left++;
    }

    while (next_right > right) {
      tmp += nums[right];
      right++;
    }

    ans = max(tmp, ans);
  }

  cout << ans << endl;
}

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


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;
const int MOD=1000000007;

int main()
{
    speed;
    cout << fixed << setprecision(9);
    /*start*/
    int n, m;
    cin>>n>>m;
    map<int, bool>a;
    rep(i, m) {
        int b;
        cin>>b;
        a[b]=true;
    }
    vector<int>dp(n+1);
    dp[0]=1;
    dp[1]=a[1]?0:1;
    ffor(i, 2, n+1) {
        dp[i]=(dp[i-1]+dp[i-2])%MOD;
        if (a[i])dp[i]=0;
    }
    c(dp[n]);
}


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

using namespace std;

const int N = 1000001;

vector <int> D[N];

int main()
{
    for(int x = 1; x < N; x++)
        for(int y = x; y < N; y += x)
            D[y].push_back(x);

    int n;
    cin >> n;

    vector <int> a(n);
    vector <int> Cnt(N);
    for(int& x : a) scanf("%d", &x), Cnt[x]++;

    int Ans = 0;

    for(int x : a)
    {
        int Sum = 0;
        for(int y : D[x])   Sum += Cnt[y];
        if(Sum <= 1)    Ans++;
    }

    cout << Ans << endl;
}


Measured memory_bytes: 122328
s=input()
l=len(s)
c=0
m=0
s1=0
cc=0
k=0
for i in range(l):
    if s[i]=="<":
        c+=1
        s1+=c
        k=0
        cc=0
        m=0
    elif c==0:
        k-=1
        if k<0 and m==0:
            s1+=cc-k
            m=1
            cc+=1
        else:
            s1+=cc
        cc+=1
    else:
        k=c-1
        c=0
        cc+=1
print(s1)

Measured memory_bytes: 42912
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define inrep int t;cin>>t; while(t--)
#define pb emplace_back
using namespace std;
using namespace __gnu_pbds; 


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const ll MOD = 1e9+7;
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {

    for ( unsigned   i=0; i<v.size(); i++ )
        in>>v[i];
    return in;
}

ll extended_GCD(ll a , ll b , ll &x , ll &y){
    if(a == 0){
        x = 0;
        y = 1;
        return b;
    }
    ll x1 , y1;
    ll gcd = extended_GCD(b%a , a , x1 , y1);
    x = y1 - (b/a)*x1; 
    y = x1;
    return gcd;
}
ll power(ll a, ll b, ll m = MOD) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll modinv(ll a , ll mod ){
    ll x , y;
    extended_GCD(a , mod , x , y);
    if(x < 0) x += mod;
    return x;
}

ll mul(ll a,ll b,ll m)
{
    return (a%m*b%m)%m;
}
  
 


int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll x = n;ll ans = 0;
    for(ll i=2;i<=1000000;i++)
    {
        if(x%i==0)
        {
            int c = 0;
            while(x%i==0)
            {
                c++;
                x=x/i;
            }ll tmp = 0;
            for(int i=1;i<=50;i++)
            {
                ll j = i*(i+1)/2;
                if(j<=c)
                    tmp = i;
            }
            ans+=tmp;
        }
    }
    if(x>1)
    {
        ans++;
    }
    cout<<ans;
    
    
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll a, b, c;
  cin >> a >> b >> c;
  cout << (a==b and b==c ? "Yes" : "No") << newl;
  return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
int main()
{
 int n,m,flag=0;
 scanf("%d",&n);
 for(int i=1;i<=n;i++)
  {
    scanf("%d",&m);
    if(m!=i)
    flag++;
  }
 
  if(flag==0||flag==2)
    printf("YES\n");
  else
    printf("NO\n");
  
  return 0;
}

Measured memory_bytes: 1636
n=int(input())
ans=0
d={"a":0,"b":0,"w":0}
for i in range(n):
    s=input()
    if s[0]=="B" and s[-1]=="A": d["w"]+=1
    elif s[0]=="B" : d["b"]+=1
    elif s[-1]=="A" : d["a"]+=1
    ans+=s.count("AB")
if d["a"]==0 and d["w"]>0:
    d["a"]=1
    d["w"]-=1
if d["w"]>0:
    ans+=d["w"]
    d["w"]=0
    d["a"]-=1
    if d["b"]>0:
        ans+=1
        d["b"]-=1
ans+=max(0,min(d["a"],d["b"]))
print(ans)


Measured memory_bytes: 44520
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cmath>
#include <deque>
#include <bitset>
#include <unordered_map>
#define ll long long
#define PI 3.1415926535897932384626433832795
#define read(x) scanf("%d",&x);
#define readll(x) cin>>x;
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define MP make_pair
#define PB push_back
#define pii pair<int,int>
#define readN(N,X) for(int i=0;i<N;i++) cin>>X[i];
#define pff pair<double,double>
using namespace std;

int N,M;
pair<int,int> a[200005];
priority_queue<int, vector<int>, greater<int> > pq;
bool cmp(pii A, pii B){
	if (A.first == B.first)
		return (A.second > B.second);
	return A.first < B.first;
}

int main(){
	std::ios::sync_with_stdio(false); 
	cin>>N>>M;
	FOR(i,0,N){
		cin>>a[i].first>>a[i].second;
	}
	sort(a,a+N, cmp);
	int j =0;
	int ans=0;
	//for (int i=0;i<N;i++) cout<<a[i].first<<" "<<a[i].second<<endl;
	for (int i=1;i<=M;i++){
		
		while (j < N && a[j].first < i) {pq.push(a[j++].second);};
		if (j < N && a[j].first >= i) {j++; continue;}
		if (pq.size() && pq.top() <= i) pq.pop();
	}
	while (j < N) {j++; ans++;}
	cout<<ans + pq.size()<<endl;
}


Measured memory_bytes: 2936